Announcement

Collapse
No announcement yet.

Populating Drop Down Menu via Unrealscript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Populating Drop Down Menu via Unrealscript

    Could someone explain to me how to populate a drop down menu via unrealscript?

    #2
    Ok well, I solved a few of my problems. The first one was that the drop down menu was not setup properly on the flash stage. I had to replace several properties like dropdown, itemRenderer and scrollBar with DefaultScrollingList, DefaultListItemRenderer and DefaultScrollbar respectively. I also found out how to populate the drop down in actionscript, it's pretty simple:

    Code:
    DetailModeDropDown.dataProvider = new DataProvider(["Low", "Medium", "High"]);
    Alternatively, I found that you can create a dataProvider in Unrealscript like this and populate the drop down this way. This is from this tutorial:


    Code:
    var config array<string> ResolutionList;
    
    function SetDataProvider(GFxClikWidget Widget)
    {
    	local byte i;
    	local GFxObject DataProvider;
    
    	DataProvider = CreateObject("scaleform.clik.data.DataProvider");
    
    	for (i = 0; i < ResolutionList.Length; i++)
    	{
    		DataProvider.SetElementString(i, ResolutionList[i]);
    	}
    
    	Widget.SetObject("dataProvider", DataProvider);
    }
    The problem I'm running into now is that I'm not entirely sure how to access a string element in a dataprovider to get the specific item selected. This is what I have so far:

    Code:
    function ResolutionOptionPressed(EventData data)
    {
    	local GFxObject DataProvider;
    
    	if(ResolutionIndex != ResolutionDropDown.GetInt("selectedIndex"))
    	{
    		ResolutionIndex = ResolutionDropDown.GetInt("selectedIndex");
    		DataProvider = ResolutionDropDown.GetObject("dataProvider");
    		
                    // I don't exactly know what the string member parameter of this function is asking for
                   ConsoleCommand("Setres" @ DataProvider.GetElementMemberString(ResolutionIndex, //Not sure what goes here);
                   
                   // Resolution Index is saved in a config to properly update the menu on creation, so save the config because the index changed
                   SaveConfig();
    	}
    	
    }

    I'm pretty close to figuring this out but I just don't know what the second parameter of the GetElementMemberString is asking for. I'm trying to retrieve the text from the currently selected item in the drop down list instead of having a switch which corresponds to the selected index and having another array of resolution strings.

    Comment


      #3
      Ok, I just figured that last part out. I was using the wrong function. It looks like GetElementMemberString would be used if an element of the array in the dataprovider has several members itself. So therefore since my dataprovider only has strings I can use GetElementString and just pass in the selected index.

      Comment


        #4
        Alternatively, create an array in Unreal script that keeps a list of the resolutions at the same indexes as the dataprovider.

        Code:
        var array<string> Resolutions;
        ..
        ...
        ....
        
        function ResolutionOptionPressed(EventData ev)
        {
            local int Index;
            
            Index = ev._this.GetInt("index");
            
            // Make sure it is a valid index.
            if ((Index >= 0) && (sIdx < Resolutions.Length))
            {
                ConsoleCommand("Setres" @ Resolutions[index]);
                      
                SaveConfig();
            }
        }

        Comment

        Working...
        X