Fix onSquadSelectionPage dispatching for weapons #217
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.
Addresses #216
The event
onSquadSelectionPage
could be incorrectly dispatched when changing the weapon inventory page during a run. It will now only be dispatched while the squad selection window is visible.The game remembers the squad selection pages for the squad selection page in the hangar and the statistics separately, so
sdlext.squadSelectionPage
and the locallastSquadPage
has been been re-specified, so that both can be known at all times.sdlext.squadSelectionPage
->sdlext.squadSelectionPageInHangar
|sdlext.squadSelectionPageInStatistics
lastSquadPage
->lastSquadPageInHangar
|lastSquadPageInStatistics
The existing code has also been refactored.
GetText
, into its own function.GetText
, and into its ownonFrameDrawStart
event.windows.Hangar_Select.show
function, and moved the logic to anonSquadSelectionWindowShown
event.Removed behavior that caused
onSquadSelectionPageChanged
to be dispatched, potentially several times over several frames, when opening the squad selection window. Replaced with logic that sets the correct page immediately as the window has been detected.The 3rd argument dispatched with
onSquadSelectionPageChanged
has been removed. I could not find the documentation for this argument, but it appears to have been there to distinguish false from true page changes. As the new code does not dispatch false page changes, this is no longer needed.Testing PR:
The following functions can be copy-pasted into the console to add debug logs, to test whether the events are dispatched correctly.