Author Topic: Automatic multiple panel navigation?  (Read 4860 times)

Arowx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Automatic multiple panel navigation?
« on: November 08, 2012, 02:34:10 PM »
Hi Just learning the ropes with NGUI currently using the UIButton Play Animation script to bring in panels, which works fine for simple one stop panels.

The problem is I would like to bring in the shop panel from multiple places in the menu graph and have it return to where the user was after visiting.

E.g. Possible Menu Panel Graphs
Main Menu -> Shop ( close returns to Main Menu )
Main Menu -> Player 1 Setup -> Shop ( close returns to current Player X Setup )

Is there a script(s) in NGUI that handle the stacking of Panel Activation 'Events' in a clean and easy to use way?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Automatic multiple panel navigation?
« Reply #1 on: November 09, 2012, 04:49:56 AM »
In Windward I achieve this by activating panels  through a manager that keeps history. This lets me navigate back by calling a simple function. I suggest you write something similar.

HitStop

  • Guest
Re: Automatic multiple panel navigation?
« Reply #2 on: November 15, 2012, 09:53:54 AM »
I was just thinking about this very issue. I'm working on something more app than game at the moment, and made the mistake of hacking the GUI together without some sort of design. This guy is facing something similar: http://www.tasharen.com/forum/index.php?topic=1792.0

Copying iOS' or three20's navigation controller could be a solution. iOS uses UINavigationController, three20 uses TTBaseNavigator. I'm not sure how other platforms handle this. At the very least, it probably needs a stack of views or panels to push and pop onto. As the UI gets heavier, using native UI probably becomes a more attractive solution so that you do not have to reinvent the wheel.

I might not mind forking out some cash for a full featured manager and view controller solution. Extra points if animations can be specified conveniently with arguments or something similar.
« Last Edit: November 15, 2012, 09:55:52 AM by HitStop »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Automatic multiple panel navigation?
« Reply #3 on: November 15, 2012, 05:27:50 PM »
Easier to make it yourself, I'd say. Consider making something like a UIScreen class that every screen inherits from that has init, show and hide methods - then you have a common place you know you can run certain things in. That's what we're doing with subway surfers.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Automatic multiple panel navigation?
« Reply #4 on: November 15, 2012, 10:14:24 PM »
It's easier than that. Instead of inheriting, just have a class that you use to activate your panels. Instead of using NGUITools.SetActive, use YourCustomManager.Show(yourNewWindow). This will automatically play the animation in reverse on any window that was shown currently, and play the animation forward on the new window you specified.

That's what I did for Windward.

Since this class stores a stack of windows, adding something like YourCustomManager.GoBack() is trivial.