Results 1 to 3 of 3
  1. #1
    MSgt. Shooter Person
    Join Date
    Nov 2007
    Posts
    90

    Default Multiple console commands in a menu

    i used the scaleform video on youtube to create my menu but the problem is that i can only open one command. currently i have one clik button which opens a map, and the other click button is meant to exit the game. the only one which works at the moment is the map command. heres the code if anyone needs it:
    Code:
    var GFxClikWidget SecretBaseButton;
    var GFXClikWidget ExitButton;
    
    /** Callback when a CLIK widget with enableInitCallback set to TRUE is initialized.  Returns TRUE if the widget was handled, FALSE if not. */
    event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget)
    {    
        switch(WidgetName)
        {                 
            case ('SecretBaseButton'):
                SecretBaseButton = GFxClikWidget(Widget);
                SecretBaseButton.AddEventListener('CLIK_press', OnSecretBasebuttonPress);
                break;
            default:
                break;
        }
        return true;
    
    switch(WidgetName)
        {                 
            case ('ExitButton'):
                ExitButton = GFxClikWidget(Widget);
                ExitButton.AddEventListener('CLIK_press', OnExitButtonPress);
                break;
            default:
                break;
        }
        return true;
    }
    
    
    function OnSecretBasebuttonPress(GFxClikWidget.EventData ev)
    {
        ConsoleCommand("open DF-SecretBase_P");
    }
    
    
    function OnExitButtonPress(GFxClikWidget.EventData ev)
    {
        ConsoleCommand("exit");
    }
    
    defaultproperties
    {    
       	WidgetBindings.Add((WidgetName="SecretBaseButton",WidgetClass=class'GFxClikWidget'))   
    	WidgetBindings.Add((WidgetName="ExitButton",WidgetClass=class'GFxClikWidget'))                   
    }

  2. #2
    The Sacrifice
    Join Date
    Nov 2009
    Posts
    228
    Gamer IDs

    Gamertag: GeekyPayback

    Default

    Ok. Breaking down your code

    Code:
        //This is a switch statement, which means that it runs which ever bit of code matches the Widget name.  
        //If it doesnt find one that matches, it runs the default code;	
        switch(WidgetName)
        {                 
            case ('SecretBaseButton'):
                SecretBaseButton = GFxClikWidget(Widget);
                SecretBaseButton.AddEventListener('CLIK_press', OnSecretBasebuttonPress);
                break;
            default:
                break;
        }
    	
        // This line exits the function - THIS IS YOUR PROBLEM
        return true;
    
        //This is a switch statement, which means that it runs which ever bit of code matches the Widget name.  
        //If it doesnt find one that matches, it runs the default code;
        switch(WidgetName)
        {                 
            case ('ExitButton'):
                ExitButton = GFxClikWidget(Widget);
                ExitButton.AddEventListener('CLIK_press', OnExitButtonPress);
                break;
            default:
                break;
        }
    	
    	// This line exits the function
        return true;
    Hopefully you can see now that the reason your code only runs the map loading command (because you have a return true command after the first switch).
    Removing it will make your code run correctly, but you've still missed the point of the switch statement. Heres how it should be written -

    Code:
        //This is a switch statement, which means that it runs which ever bit of code matches the Widget name.  
        //If it doesnt find one that matches, it runs the default code;	
        switch(WidgetName)
        {                 
            case ('SecretBaseButton'):
                SecretBaseButton = GFxClikWidget(Widget);
                SecretBaseButton.AddEventListener('CLIK_press', OnSecretBasebuttonPress);
                break;
    	 case ('ExitButton'):
                ExitButton = GFxClikWidget(Widget);
                ExitButton.AddEventListener('CLIK_press', OnExitButtonPress);
                break;
            default:
                break;
        }
    	
        // This line exits the function 
        return true;

  3. #3
    MSgt. Shooter Person
    Join Date
    Nov 2007
    Posts
    90

    Default

    Thanks for that. and i do understand what i was doing wrong. im just getting into coding and i tried looking at the scaleform page for help but obviously couldn't find the answer.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.