Announcement

Collapse
No announcement yet.

A good way to setup Localized Text in your Menus... Plus other initialization

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

    A good way to setup Localized Text in your Menus... Plus other initialization

    In another thread, I asked Matt how to go about localizing the text on disabled CLIK widgets because they don't fire off WidgetInitialized events. He made a good suggestion about calling into another SWF file, but I did some more digging and I came up with the following solution that is useful for more than just localized text. I'm still new to this, so maybe there are problems with this method, but so far it seems to be working well to me.

    NOTE: This explanation does not talk about HOW to localize text, that is pretty well covered in the docs. Instead, it talks about how to get that localized text into your SWF files as the player navigates around your menu.

    In my Flash Files, I have the following for each menu page:

    Code:
    import flash.external.ExternalInterface;
    
    <lots more stuff>
    
    ExternalInterface.call("MenuActive","Options");  //This could be MainMenu, Tutorials, Credits, etc.
    stop();
    So each menu page calls into my unreal script letting it know that the page has changed.

    In unrealscript, I have:

    Code:
    function MenuActive(String menuName)
    {
    	switch(menuName)
    	{
    		case ("MainMenu"):
    			LoadLocalizedText(menuName);
    			break;
    		case ("Options"):
    			LoadLocalizedText(menuName);
    			break;
    		default:
    			break;
    	}
    	
    }
    You can obviously do more than just localize text in that switch statement... like do other initialization or trigger UDK to send more data the menu might need.

    For localization though, you then use something like this:

    Code:
    function LoadLocalizedText (String menuName)
    {
    	switch(menuName)
    	{
    		case ("MainMenu"):
    			Label_Button_MM_Play = GetVariableObject("_root.button_MM_Play.textField");
    			Label_Button_MM_Play.SetText(Label_Button_MM_Play_loc);
    			Label_Button_MM_Options = GetVariableObject("_root.button_MM_Options.textField");
    			Label_Button_MM_Options.SetText(Label_Button_MM_Options_loc);
    			Label_Button_MM_Tutorials = GetVariableObject("_root.button_MM_Tutorials.textField");
    			Label_Button_MM_Tutorials.SetText(Label_Button_MM_Tutorials_loc);
    			Label_Button_MM_Credits = GetVariableObject("_root.button_MM_Credits.textField");
    			Label_Button_MM_Credits.SetText(Label_Button_MM_Credits_loc);
    			Label_Button_MM_Quit = GetVariableObject("_root.button_MM_Quit.textField");
    			Label_Button_MM_Quit.SetText(Label_Button_MM_Quit_loc);
    			break;
    		case ("Options"):
    			Label_Button_OM_Back = GetVariableObject("_root.button_OM_Back.textField");
    			Label_Button_OM_Back.SetText(Label_Button_OM_Back_loc);
    			break;
    		default:
    			break;
    	}
    	
    }

    Anyone see any problems with this method? So far it seems to be working well.

    Z
Working...
X