Page MenuHomeWildfire Games

Allow the JS GUI to subscribe to window resize events
ClosedPublic

Authored by elexis on Jun 29 2017, 4:06 AM.

Details

Summary

D689 shows one use case where we would like to execute some JS code after the window was resized (to conditionally show the follow-player label).

Test Plan

Confirm that the message is also received even if multiple GUI pages are opened, for example a delete dialog in the session.
Consider whether the SendEventToAll should be done in a separate loop after the existing loop instead (doesn't seem needed to me, since those are different GUI contexts to begin with that can't influence each other afaik).

Event Timeline

elexis created this revision.Jun 29 2017, 4:06 AM
Vulcan added a subscriber: Vulcan.Jun 29 2017, 5:15 AM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1656/ for more details.

Executing section Default...
Executing section Source...
Executing section JS...
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/259/ for more details.

elexis updated this revision to Diff 2750.Jun 29 2017, 5:35 AM

As reported by temple, Engine.GetGUIObjectByName fails because it looked in the top page instead of the page were called the event in.
If we look into that function we see that it checks for m_CurrentGUI and that TickObjects changes that member.
Changing that member here as well fixes the issue.

elexis updated this revision to Diff 2751.Jun 29 2017, 5:42 AM

Updated the wrong diff with the last update.
Simplification: Call CList::UpdateCachedSize() only from CDropDown::UpdateCachedSize(), not from CDropDown::SetupText().

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1658/ for more details.

Executing section Default...
Executing section Source...
Executing section JS...
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/261/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1659/ for more details.

Executing section Default...
Executing section Source...
Executing section JS...
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/262/ for more details.

vladislavbelov added a subscriber: vladislavbelov.EditedJun 29 2017, 9:48 AM

The patch looks good for me. Since it just adds a SetupText tree call.

elexis updated this revision to Diff 2753.Jun 29 2017, 12:28 PM

Updated D692 instead of D694 again.
See Vladislav two comments in https://code.wildfiregames.com/D692?id=2749#27635
(As reported by temple, Engine.GetGUIObjectByName fails because it looked in the top page instead of the page were called the event in.
If we look into that function we see that it checks for m_CurrentGUI and that TickObjects changes that member.
Changing that member here as well fixes the issue.)

Answering https://code.wildfiregames.com/D692?id=2749#27635

See the upload commnet for that.
We have to use m_CurrentGUI, because the code executed in the JS event would be executed in the top page, not the page of the stack.
For example if subscribe session.xml to the resized event but opened a delete-dialog, then the session.js code would look for the civ icon in the delete dialog (top page).
We have to reset afterwards, so that the GUI manager doesn't do things on that pointer anymore but on the top page by default.

Answering https://code.wildfiregames.com/D692?id=2749#27643
The name is accurate and this is the only resized stack afaics.

source/gui/GUIManager.cpp
409

Compare with this

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1661/ for more details.

Executing section Default...
Executing section Source...
Executing section JS...
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/264/ for more details.

temple accepted this revision.EditedJun 29 2017, 7:37 PM

I don't know the details of the code, but this and D692 fixed the problems with hiding the follow player label and getting the right dropdown length when resizing the window (D689 plus the on WindowResized action).

Edit: I didn't phrase that in the best way, so to be clear: this patch allows the follow player label to hide when the window's resized. D692 fixing the dropdown height is independent of this.

This revision is now accepted and ready to land.Jun 29 2017, 7:37 PM
elexis updated this revision to Diff 2761.Jun 29 2017, 8:08 PM

Copy the page stack so that all pages are traversed properly, even if the we would push or pop GUI pages in the script handler

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1666/ for more details.

Executing section Default...
Executing section Source...
Executing section JS...
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/267/ for more details.

This revision was automatically updated to reflect the committed changes.