Game Development Community

How do you make a menu window popup

by hbomega · in Torque 2D Beginner · 08/30/2013 (9:40 am) · 5 replies

on my main menu screen i got an option button when i click the button i want a small window to appear at the center of the current screen displaying the adjustable content, my problem is i'm not sure how to go about it i tried using a guispritectrl but when i try displaying it using the canvas.push.Dialog when the option button is clicked i get an invalid control error in my console log, i tried looking over the sandbox multiple window toy :(

also how would i go about locking all input/control to the new window

#1
08/30/2013 (9:46 am)
That's [b]canvas.pushDialog()[b] - not [b]canvas.push.Dialog()[b].

Also - are you sure you're loading the gui's TAML file? Using the correct name? All of the other usual suspects?

Next, I tinkered with this for a minute and the only solution I could come up with was this gui control setup:
<GuiControl
    Name="InventoryDialog"
    canSaveDynamicFields="0"
    isContainer="1"
    Profile="GuiDefaultProfile"
    HorizSizing="right"
    VertSizing="bottom"
    Position="0 0"
    Extent="800 600"
    MinExtent="8 2"
    canSave="1"
    Visible="1"
    Active="0"
    hovertime="1000">
	<GuiWindowCtrl
		Name="InventoryWindow"
		canSaveDynamicFields="0"
		isContainer="1"
		Profile="InventoryWindowProfile"
		HorizSizing="right"
		VertSizing="bottom"
		Position="10 10"
		Extent="500 350"
		MinExtent="8 2"
		canSave="1"
		Visible="1"
		Active="1"
		tooltipWidth="250"
		hovertime="1000"
		maxLength="1024"
		truncate="0"
		resizeWidth="0"
		resizeHeight="0"
		canMove="1"
		canClose="1"
		closeCommand="Canvas.popDialog(InventoryDialog);"
		canMinimize="0"
		canMaximize="0"
		minSize="50 50"
		text="Inventory:" />
</GuiControl>
You get a floating window over your screen. If you just try to use the GuiWindowCtrl it will always resize to fill the canvas. You could also replace that GuiWindowCtrl with a sprite control or whatever.

The containing GuiControl should catch all input that falls outside of your GuiWindowCtrl - no worries.
#2
08/30/2013 (9:54 am)
Thanks Richard gonna go try it, PS thank for the quick reponse
#3
08/30/2013 (10:39 am)
you were right about checking how i was loading my .taml, once i corrected that the window came up but now i can't control the size i'm using a guiSpriteCtrl, i dont get a floating window, i tried using your code substituting the necessary fields but got a bitmap array error
#4
08/30/2013 (6:57 pm)
Yeah - that error was caused by the control profile that my GuiWindowCtrl uses. You could change that to GuiDefauiltProfile and it should work (might need GuiWindowProfile). Easier to replace the GuiWindowCtrl with your GuiSpriteCtrl:
<GuiControl
	Name="InventoryDialog"
    canSaveDynamicFields="0"
    isContainer="1"
    Profile="GuiDefaultProfile"
    HorizSizing="right"
    VertSizing="bottom"
    Position="0 0"
    Extent="800 600"
    MinExtent="8 2"
    canSave="1"
    Visible="1"
    Active="0"
    hovertime="1000">
    <GuiSpriteCtrl
        Name="mainMenuBackground"
        canSaveDynamicFields="0"
        isContainer="0"
        Profile="GuiDefaultProfile"
        HorizSizing="relative"
        VertSizing="relative"
        Position="60 60"
        Extent="400 400"
        MinExtent="8 2"
        canSave="1"
        Visible="1"
        Active="1"
        hovertime="1000"
        Image="@asset=TraderAssets:background" />
</GuiControl>
Of course, replace my asset and object names....
#5
08/30/2013 (8:40 pm)
Thanks it works :)