bignsyd / gqe

Automatically exported from code.google.com/p/gqe
MIT License
0 stars 0 forks source link

Reset any state without secondary states. #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Sometimes the programmer would like to reset a state completly. In such a case 
there for now three options and all of them aren't that nice.
a) Remove and reset all variables and class internally created and used by the 
state.
b) Create a drop-back state, which creats automaticly a new state when the 
first one is removed from the stack.
c) Just create a new state over the other one, leave all the allocated memory 
in the stack/heap and remove all states at the end.

If there would be a function like 'ResetActiveState()', which unloads and 
reloads the active state, that would be very helpfull in some situations.

Original issue reported on code.google.com by youtube@my-gate.net on 14 Feb 2011 at 1:50

GoogleCodeExporter commented 9 years ago
I have finished implementing two new methods in the StateManager: 
InactivateActiveState and ResetActiveState.  The InactivateActiveState will 
make the currently active state inactive without calling its DeInit method.  
That way the state can retain its assets.  The ResetActiveState will pause the 
currently active state, call its ReInit method (newly added to the IState 
interface class), and resume the currently active state.  This will allow you 
to restart the currently active state.  This is the only way the ReInit method 
is called so far.  I also added better handling of HandleCleanup for recently 
dropped states.  Previously, the DropActiveState would not call HandleCleanup 
ever.  Now it gets called by IState::DoInit if mCleanup is true, this means 
that ALL game states should call IState::DoInit FIRST before performing their 
own DoInit stuff.

Original comment by RyanLind...@gmail.com on 19 Feb 2011 at 4:38