How Exactly Do I make another .gui popup
by Richard Preziosi · in Torque Game Engine · 04/24/2008 (3:25 pm) · 1 replies
Topic says it all, basically what it is, is this: I have my playgui that is just that, my crosshair, healthbar etc. Then I have a seperate gamemenu.gui that I want to make popup when i press the "m" key.
Here is my code for the files i'm trying to do this with.
Main.cs
The guiMap.push(); is what I thought I needed to load my new guimap.cs which is this:
Now my gamemenu.gui
I'm probably going about this the "hard" way, or perhaps doing it all wrong. Either way, I can't get it to work. Thanks for any help.
Here is my code for the files i'm trying to do this with.
Main.cs
function initClient()
{
echo("\n--------- Initializing TTB: Client ---------");
// The common module provides basic client functionality
initBaseClient();
// InitCanvas starts up the graphics system.
// The canvas needs to be constructed before the gui scripts are
// run because many of the controls assume the canvas exists at
// load time.
initCanvas("Torque Tutorial Base");
// Interface Definitions
exec("./client/profiles/default_profiles.cs");
// Load client-side Audio Profiles/Descriptions
exec("./client/audioProfiles.cs");
// Load up the shell and game GUIs
exec("./client/ui/PlayGui.gui");
exec("./client/ui/mainMenuGui.gui");
exec("./client/ui/optionsDlg.gui");
exec("./client/ui/loadingGui.gui");
exec("./client/ui/chatbox.gui");
exec("./client/ui/messagebox.gui");
exec("./client/ui/gamemenu.gui");
//Character Stat/Exp sheet
exec("./client/ui/statsGui.gui");
// Client scripts
exec("./client/optionsDlg.cs");
exec("./client/missionDownload.cs");
exec("./client/serverConnection.cs");
exec("./client/loadingGui.cs");
exec("./client/playGui.cs");
exec("./client/clientGame.cs");
exec("./client/chatbox.cs");
exec("./client/messagebox.cs");
exec("./client/cursor.cs");
exec("./client/guimap.cs");
// Default player key bindings
exec("./client/default.bind.cs");
// Copy saved script prefs into C++ code.
setShadowDetailLevel( $pref::shadows );
setDefaultFov( $pref::Player::defaultFov );
setZoomSpeed( $pref::Player::zoomSpeed );
guiMap.push();
// Start up the main menu...
Canvas.setContent(MainMenuGui);
Canvas.setCursor("defaultcursor");
}The guiMap.push(); is what I thought I needed to load my new guimap.cs which is this:
if ( isObject( guiMap) )
guiMap.delete();
new ActionMap(guiMap);
function showGameMenu(%val)
{
if(%val)
{
if(GameMenu.isVisible())
GameMenu.setVisible(false);
else
GameMenu.setVisible(true);
}
}
guiMap.bind(keyboard, m, showGameMenu);Now my gamemenu.gui
//--- OBJECT WRITE BEGIN ---
new GuiChunkedBitmapCtrl(GameMenu) {
canSaveDynamicFields = "0";
Profile = "GuiPopupMenuProfile";
HorizSizing = "center";
VertSizing = "center";
position = "0 0";
Extent = "640 480";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "showGameMenu();";
hovertime = "1000";
bitmap = "./gamemenubackground.png";
useVariable = "0";
tile = "1";
new GuiBitmapCtrl() {
canSaveDynamicFields = "1";
Profile = "GuiDefaultProfile";
HorizSizing = "center";
VertSizing = "center";
position = "70 -10";
Extent = "500 500";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
bitmap = "./gamemenuwindow.png";
wrap = "0";
};
};
//--- OBJECT WRITE END ---I'm probably going about this the "hard" way, or perhaps doing it all wrong. Either way, I can't get it to work. Thanks for any help.
Torque Owner Richard Preziosi
WinterLeaf Entertainment
At the bottom of your gui file that will be your popup, add these two functions after everything:
function toggle"whatever you named your control"(%val) { if(%val) "control name".toggle(); } function "control name"::toggle(%this) { if (%this.isAwake()) Canvas.popDialog(%this); else Canvas.pushDialog(%this); }then in your default.bind.cs add this somewhere:
That's it, just take the quotation marks out after you've entered the needed information. Hopefully no one else has this problem, but since i couldn't find any solution when i first had it, here is the answer if anyone else ever does have the problem i did.