Announcement

Collapse
No announcement yet.

Custom GUI Controller

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

    Custom GUI Controller

    Hello there. I am having a bit of a problem with a custom GUI controller. It stems to the point of when I change it in my mods .ini file the game crashes on load saying theres a Runtime Error!. I think this all back tracks for me making a custom font style for the main menu so I will post the code based on this. All of the code is held in a folder called MyModMenu.

    In MyMod.ini I have this line of code.

    Code:
    [Engine.Engine]
    GUIController=MyModMenu.MyModGUIController
    Here is the custom GUI controller code.

    Code:
    class MyModGUIController extends UT2k4GUIController;
    
    defaultproperties
    {
         Begin Object Class=MyModMenu.jrFontMenu Name=MyModGUI_MenuFont
         End Object
    
         FontStack(12)=MyModGUI_MenuFont
         FONT_NUM=13
    
         DefaultStyleNames(60)="MyModMenu.MyModTextButtonStyle"
         STYLE_NUM=61
    }
    Here is the code for the custom font.

    Code:
    class MyModFontMenu extends GUIFont;
    
    defaultproperties
    {
         KeyName="MyModMenuFont"
         FontArrayNames(0)="MyModTestFont.Arial"
         FontArrayNames(1)="MyModTestFont.Arial"
         FontArrayNames(2)="MyModTestFont.Arial"
         FontArrayNames(3)="MyModTestFont.Arial"
         FontArrayNames(4)="MyModTestFont.Arial"
    }
    Here is the code for the custom style.

    Code:
    class MyModTextButtonStyle extends GUIStyles;
    
    defaultproperties
    {
         KeyName="MyModTextButton"
    
         FontNames(0)="MyModMenuFont"
         FontNames(1)="MyModMenuFont"
         FontNames(2)="MyModMenuFont"
         FontNames(3)="MyModMenuFont"
         FontNames(4)="MyModMenuFont"
         FontNames(5)="MyModMenuFont"
         FontNames(6)="MyModMenuFont"
         FontNames(7)="MyModMenuFont"
         FontNames(8)="MyModMenuFont"
         FontNames(9)="MyModMenuFont"
         FontNames(10)="MyModMenuFont"
         FontNames(11)="MyModMenuFont"
         FontNames(12)="MyModMenuFont"
         FontNames(13)="MyModMenuFont"
         FontNames(14)="MyModMenuFont"
    }

    Finally I have in my MainMenu class a GUIButton which uses MyModTextButton as its stylename. Any help for reading through my horrendously named code would be extremely helpful. Many thanks.

    #2
    Have you checked the log file for error messages and additional details? "Runtime Error" doesn't exactly provide information about the problem.

    Comment


      #3
      I know it doesn't but thats all it says.

      Runtime Error!

      Program: C:\UT2004\System\UT2004.exe

      This application has requested Runtime to terminate in an unusual way. Please contact the application's support team for more information.

      If I change the GUIController line in the ini back to the original GUI2k4 one its fine and runs. No log is created unfortunately it remains blank. So it must be an error somewhere in the use of the GUIController.

      Comment


        #4
        Does the class you specified actually exist in any of the packages located in the directories specified by the Paths=... list under [Core.System]?

        Comment


          #5
          Yeah its there, theres a line which says

          Paths=../MyMod/System/*.u

          this folder contains the compiled .u file.

          I notice however when compiling MyModGUIController class it says ...deferring. Specifically at the point where the defaults are being imported.

          This is the command prompt output for MyModMenu when compiling.

          Code:
          Importing Defaults for MyModGUIController
          ... deferring
          Importing Defaults for MyModMainMenu
          Importing Defaults for MyModTextButtonStyle
          Importing Defaults for MyModFontMenu
          Importing Defaults for MyModGUIController
          Is it likely to be a script error. I wouldn't have thought so personally I know the system is pretty robust and would just show an error in the log. This doesn't even achieve that. So it could be a reference to something not existing but it's clearly stated. I will test some things see what happens if I give it a different name.

          Comment


            #6
            "...deferring" only means that the compiler can not yet import defaults for the class and moves that class to the end of its "import todo list". As you can see "Importing Defaults for MyModGUIController" shows up again after all other defaults are imported. Before a class's defaults can be imported, its superclass's defaults and the defaults of any subobject classes have to be imported. If that condition isn't met, importing is deferred. That's not an error or warning, only an info.

            Comment


              #7
              Ah ok well the word deferring would tend to suggest that Doh silly me! :P. Erm... this error is really starting to bug me gonna have to download a mod and look at what they did in thier GUIController. Any money its something really simple that I have forgotten.

              Comment


                #8
                Here's an idea, make your GUI controller just subclass of the normal gui controller with the following line of code:
                Code:
                function Initialize()
                {
                    Super.Initialize();
                    log("GUI Created");
                }
                And that is all, if it starts form there, then you know it's a problem with something else.

                Comment


                  #9
                  Yes!!!! I got it to work. I instead of subclassing the UT2k4GuiController I extended GUIController. Copied the UT2k4GuiController script over and adjusted what I needed to in regards to the fontstack and stylestack. Many thanks for your help guys.

                  Comment


                    #10
                    If you ever get errors like this again, try starting your mod from the community menu. That usually gives you a better error message. Also I've found that sometimes GUIController errors actually have nothing at all to do with the GUIController.

                    Comment

                    Working...
                    X