Game Development Community

Changing GUI Focus?

by J.C. Smith · in Torque Game Engine · 11/07/2005 (10:37 pm) · 6 replies

Hey all. I've been scouring thruogh threads and resources for a couple hours and I can't find any information on this, so figured I'd just ask.

What's the easiest way to shift focus through multiple GUIs? I need to design an advanced menuing system for a project and I don't want to manually insert the menus everyplace. Basically the way the system is set up right now is that I have a control the pops up at the top of the screen which allows you to jump between menus such as starting a game, options, etc. I like that there so I can allow users to access that quickly from in-game, etc.

The problem I'm having is it will only allow focus on one GUI at a time. For an example of this load up starter.fps or whatnot and bring up any of the menu items. If you bring up the Start Mision or Join mission the menu dissapears because they are setting a new canvas. If you bring up the options menu though the main menu stays, yet you can't press any of the buttons because the focus is apparently on the options menu.

So basically the problem I have now is that while I can get my menu pushed through various canvas' or dialogues, I can't actually click on anything. Anyone know how to approach this?

#1
11/08/2005 (12:16 am)
Have you looked at what functions Canvas has? specifically PopDialog?
#2
11/08/2005 (1:38 am)
Yes, PushDialog and PopDialog work fine for displaying the various GUIs. The problem is illustrated well if you look at starter.fps and open up Options, although you can see the main menu options (Join Mission, Start Mission etc) you can not actually interact with them, only with the options menu until you exit the options menu, it get's popped and focus goes back to the mainmenu.

I am also aware that I can work around the problem by setting the canvas depending on what areas I'm going into to create the menu at the top each time and get the same effect accomplished. I'd rather avoid having to actually redefine the main menu though in each sub-area, so that I can easily add and change in the future without needing to change it in every area. I tried to use exec similar to a server side include inside of a canvas setup to accomplish the same effect but it can't be used there.

Maybe I'm not explaning this well. Okay I have a GUI called TopMenuGUI, which is basically a GUIControl set to be invisible so that I can overlay it on top of my canvas. Inside of that Control I have various GUIButtonControls for the main menu, using starter.fps terminology things up there would be Start Mission, Join Server, Options, About, and Quit. It's just basically a menu on the very top of the screen, but separated from the MainMenuGUI. The mainmenu basicaly does a pushdialogue when it wakes and sets a global to indicate of the top menu is active or not. That allows me to use that same menu in-game when users hit escape to open or close it. That way if they hit escape in-game it doesn't fill a full screen menu on them.

The options menu is an easiest addition in to there. If I open it, the menu stays put because options is just a dialog box that pops up onto the screen. The probelm of course is that although you can see the topmenu still, you can't interact with it at all because the options dialogue has focus. Implementing join server menus was a bit tricker, if you an to use their canvas you have to close the topmenu and then recreat it on the new canvas for it to appear. If you hard rig it into the new GUI then you could interact with it (I assume, haven't actually done it because was working a more elegant solution) but in every single sub-menu if you used that type of approach you would need to have the code for the GUI. I don't like that because it's redundant for one, and more importantly, it makes it a lot harder to change things later.

So in a nutshell I'm looking for a way to switch focus between the top menu and sub-menus when I mouse over them or whatnot but can't figure out how to approach it.
#3
11/08/2005 (2:32 am)
I understand what you want now. Unfortunately i have no clue.
#4
11/08/2005 (3:25 am)
Why don't you put all these in the same GUI control, but as sub-GUI's that you can activate and deactivate? Much like how the options menu works in the starter.fps, where you have Video/Sound/Controls.
#5
11/08/2005 (6:16 am)
I wound up just hard coding it to load the menu in each GUI. Not as easy to expand as I would have liked but it works.
#6
11/08/2005 (8:10 am)
... the method I outlined is easy to expand.