Fix reports being shown out of screen #2420
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When connecting to a game and receiving an historian report, they would often be shown out-of-screen. This is ultimately caused by the resizing of the client window happening only after the game state is fully loaded. The placement algorithm has to provide sensible results when the widget doesn't fit inside the (small) base window size.
The complicated placement algorithm relied on an initial guess for the position and could result in the widget being shown off-screen when the window was too small. Replace it with a linear scan going left-to-right and top-to-bottom across the entire screen. Also avoid recursion, permitting more attempts by lifting the limitation due to the stack size.
This doesn't entirely solve the issue of widgets being shown in an unexpected location when connecting to a game: when the algorithm finds no solution, it now defaults to 0,0 to maximize visible content. This can in particular be the case for the small window size used right before connecting. I think a full revision of the pregame screens is needed, but this is way beyond the scope of this PR and won't make it to 3.1.
Closes #1989.
Before Patch
After Patch
The Demographics report gets placed correctly when invoked: