So here is the situation:
I have some views in the stack, and I push/pop /set them when needed. All was good, until I wanted to place some logic to pause/resume, assuming when user sees the view it will start doing some game things (not reactive from input, but proactive), and best place for such behavior is Resume (as I think and hope, pls correct me if needed). Let’s imagine:
I have menu view, scenario selection view , game view, and gameview is in the viewstack, I click “to menu” button in game view, this pushes menu view on top of game view, and I show “back to game” button in menu ( when I have not finished “game session”). Now I have 2 options - return to game (player wants to continue) or I can start fresh (and go to new scenario). First is trivial push and works fine, as game logic is the same. But if I go for new game, I click new scenario, which reinintializes the game logic , and does Container.View := ViewScenario; thus removing all the views from the viewstack. That’s my logic, kinda intuitive , I think.
But what’s happening in reality:
Container.View := ViewScenario; does make
while ViewStackCount <> 0 do
PopView;
and PopView does FViewStack.Last.Resume; for really short moment (the cycle is intended in general to remove all the views this way with Pop-s), but at this moment gameView thinks it got the timeslot and makes some game things within the old game state (but it is now reinited).
So, the question is, does it really necessary to call resume from this while-loop ? it doesn’t seem so to me.
I did a workaround in ancestor view-class in my project for the SetView process:
DontFireResumeOnSetView := True;
Container.View := nil;
DontFireResumeOnSetView := False;
Container.View := AView;
and the descendant view who wants to protect itself from this “technical” not real Resume, just does in Resume:
if DontFireResumeOnSetView then Exit;
Your thoughts are welcome ![]()