State manager.

Hello.

I'm currently have some design issues on my state manager, and I'd appricate if someone would be kind to lend me a helping hand.

The problem is that I can't change to another state, from within another state (except if pull all the code together to a big bowl of pasta).

I'd be very thankfull if somone would manage to help me figuring this out.

src: http://agate.pastebin.com/m5fa02933
note: se marked line for example.

meno
Posted - Fri, 01/08/2010 - 06:34

just tell the state who the statemanager is (on constructing or on adding it to the statemanager, which would be handier i guess)

  1.         public void Add(string key, State state)
  2.         {
  3.                 states.Add(key, state);
  4.                 state.StateManager = this;
  5.  
  6.                 if (states.Count == 1)
  7.                         current = state;
  8.                
  9.                 states[key].Initialize();
  10.         }

ioou
Posted - Fri, 01/08/2010 - 08:47

I had already tried that, and thanks for the reply.

The thing is, is there a better way to design this?
So it's dynamic and clean.

Cheers, F.

edit:
By the way, is there a way to pass (set) properties for AgateApplication before initalizing the window, such as size and title?

Thanks in advance!

kanato
Posted - Fri, 01/08/2010 - 10:20

Quick answer to the last question: you can override ApplicationTitle and WindowSize to set size and title. For more fine grain control, override either GetAppInitParameters or AdjustAppInitParameters (for the SVN version)

ioou
Posted - Fri, 01/08/2010 - 10:50

Thanks a lot, I appreciate the quick answers.

Cheers, F.