Canvas question
by Dave Strock · in Torque Game Engine · 06/01/2002 (11:50 pm) · 5 replies
I'm having a slight problem with a gui that I'm working on for my inventory system at the momemnt. I started off using Tim Newell's excelent tutorials, but I've added quite a bit to it now.
I have a key to toggle the inventory, and my problem is this: When the inventory gui is displayed, all other gui stuff goes away. Chat hud, health bar, etc. So I'm wondering if there is some way to get better control than a call like:
I'd like to just add a gui to the display, instead of replace everything with one, when I hit the toggle. Any advice would be great. Thanks.
I have a key to toggle the inventory, and my problem is this: When the inventory gui is displayed, all other gui stuff goes away. Chat hud, health bar, etc. So I'm wondering if there is some way to get better control than a call like:
Canvas.setContent( someGui );
I'd like to just add a gui to the display, instead of replace everything with one, when I hit the toggle. Any advice would be great. Thanks.
#2
06/02/2002 (1:33 am)
Below is the code that I use for toggleing a GUI element onto the whatever the current Canvas content is.function Object::togglegui(%this){
if(!%this.show){
%this.controlcanvas = Canvas.getContent();
Canvas.getContent().add(guiobject);
Canvas.repaint();
%this.show = 1;
}
else {
%this.controlcanvas.remove(guiobject);
%this.show = 0;
canvas.repaint();
}
}
#3
Edit: Ok, well I sort of got it to work. What happens now is when I toggle the gui, it adds an entire new view to the upper left corner which shows the gui I wanted to toggle on, along with another view of the player. Basically, a smaller version of the main view. Both views move correctly to follow the players movment, etc. Here is a screenshot so you can see what I'm talking about:
www.nu-frontier.com/design/screenshots/doublewindow.png
Also, the inventory system doesn't work as it should.
I basically just took Harold's code and added it to my InventoryGui.cs. Any ideas on whats going on here?
Thanks
06/02/2002 (9:48 am)
Ah, thats perfect. Thanks guys.Edit: Ok, well I sort of got it to work. What happens now is when I toggle the gui, it adds an entire new view to the upper left corner which shows the gui I wanted to toggle on, along with another view of the player. Basically, a smaller version of the main view. Both views move correctly to follow the players movment, etc. Here is a screenshot so you can see what I'm talking about:
www.nu-frontier.com/design/screenshots/doublewindow.png
Also, the inventory system doesn't work as it should.
I basically just took Harold's code and added it to my InventoryGui.cs. Any ideas on whats going on here?
Thanks
#4
06/02/2002 (6:31 pm)
I'm guessing that your Inventory GUI object has the playGUI included with it.
#5
Whats happening is its putting that new window, that you see in the upper left with the inventory gui, on top of the regular window but underneather the playGui. Thats why you still see the chat hud. It should be adding just the inventory gui to the lower left of the big window.
I've managed to get it so that the invetory actually works now, except it still displays in that second window when you toggle it on. Then when you toggle it off its like normal with just the playGui. Also or some reason, the guiBitmapCtrl's and the guiObjectView work fine, but the guiTextCtrl's don't display anything.
After looking at PlayerListGui, which has a nice toggle() member that works exactly like what I'd like to do, I think I may have to make my inventory gui a modless dialog. PlayerListGui has a profile of "GuiModelessDialogProfile", is there anything special, other than that, to make a modless dialog work?
PlayerListGui.toggle() is dead simple:
Anyway, thanks for the help so far.
06/02/2002 (7:31 pm)
No, my inventory gui is just the bluish grey window with the gold trim that you see in the screenshot there.Whats happening is its putting that new window, that you see in the upper left with the inventory gui, on top of the regular window but underneather the playGui. Thats why you still see the chat hud. It should be adding just the inventory gui to the lower left of the big window.
I've managed to get it so that the invetory actually works now, except it still displays in that second window when you toggle it on. Then when you toggle it off its like normal with just the playGui. Also or some reason, the guiBitmapCtrl's and the guiObjectView work fine, but the guiTextCtrl's don't display anything.
After looking at PlayerListGui, which has a nice toggle() member that works exactly like what I'd like to do, I think I may have to make my inventory gui a modless dialog. PlayerListGui has a profile of "GuiModelessDialogProfile", is there anything special, other than that, to make a modless dialog work?
PlayerListGui.toggle() is dead simple:
function PlayerListGui::toggle(%this)
{
if (%this.isAwake())
Canvas.popDialog(%this);
else
Canvas.pushDialog(%this);
}Anyway, thanks for the help so far.
Associate Stefan Beffy Moises
function toggleRVM( %val ) { if(%val) RearViewMirror.visible = !RearViewMirror.visible; }...