Announcement

Collapse
No announcement yet.

Changing the main menu font...

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

    Changing the main menu font...

    I' am having trouble understanding the main menu font change. I look at code of other mods who have changed their main menu font like "Muralis" and "Neotokyo", and I don't know why, but in their main menu class they do not even create/define objects for each of the buttons.

    Here is some advice from UDN, in changing the font by using guistyles.


    Fonts, like styles, need to be registered with the GUIController. This is done differently than styles because the FontStack is an array of GUIFont objects as opposed to an array of String names. To put fonts into this array, you need to create objects in default properties and then assign them like so:


    defaultproperties
    {
    Begin Object Class=fntGreekFont Name=GUIGreekFont
    bFixedSize=false
    End Object
    FontStack(6)=GUIGreekFont
    }
    My question is:

    1. Where are these objects made (what class)?
    2. How do these other mods not even declare objects and still work perfectly well?


    Here is some code from default properties from the mod "Muralis", for reference.

    Code:
    //Muralis code
    defaultproperties
    {
        i_Background=BackgroundImage'MurGuiMainMenu.PageBackground'
        i_MuralisLogo=GUIImage'MurGuiMainMenu.ImgMuralisLogo'
        i_AscLogo=GUIImage'MurGuiMainMenu.ImgAscLogo'
        b_Practice=GUIButton'MurGuiMainMenu.PracticeButton'
        b_MultiPlayer=GUIButton'MurGuiMainMenu.MultiplayerButton'
        b_Host=GUIButton'MurGuiMainMenu.HostButton'
        b_Settings=GUIButton'MurGuiMainMenu.SettingsButton'
        b_Quit=GUIButton'MurGuiMainMenu.QuitButton'
        lblVersion=GUILabel'MurGuiMainMenu.VersionLabel'
        MenuSong="Muralis"
        bDisconnectOnOpen=True
        bAllowedAsLast=True
        __OnOpen__Delegate="MurGuiMainMenu.InternalOnOpen"
        __OnReOpen__Delegate="MurGuiMainMenu.MainReopened"
        __OnCanClose__Delegate="MurGuiMainMenu.CanClose"
        WinTop=0.00
        WinHeight=1.00
        bDebugging=True
        __OnKeyEvent__Delegate="MurGuiMainMenu.MyKeyEvent"
    }
    Help would be appreciated.

    #2
    Ok I found out the first answer, basically these objects are created in a guicontroller subclass of your own creation. I downloaded the example code and have this in theirs...


    Code:
    class TotrStyleGuiController extends GUIcontroller;
    
    defaultproperties
    {
    Begin Object class=Totguifont Name=Vianta
    bFixedSize=false
    End Object
    FontStack(6)=Vianta
    
    StyleNames(17)="STY_Totrmenu"
    }
    This is their code with basically references to my own stuff. Problem is 'bFixedSize' is not recognized on compile and gives an error. But this is what they have in their own code.


    My only guess is this method is old as its from a very old build (2200 approx.). But where can I find info about any new methods?

    I will appreciate ANY light to be shed on the situation.

    Comment


      #3
      Just leave out the bFixedSize

      Here's what a font in the LawDogs GUI controller class looks like:
      Code:
      Begin Object Class=LDMainMenuFont Name=LDMainMenuFont
          Name="LDMainMenuFont"
      End Object
      FontStack(11)=LDMainMenuFont'LDMainMenuFont'
      and you need a class for the font itself:
      Code:
      class LDMainMenuFont extends GUIFont;
      
      defaultproperties
      {
      	KeyName="LDMainMenuFont"
      
      	bScaled=true
      	NormalXRes=800
      	FallBackRes=512
      	FontArrayNames(0)="LawDogsFonts.Cowboys24"
      	FontArrayNames(1)="LawDogsFonts.Cowboys32"
      }
      and finally you need a style which actually uses the font:
      Code:
      // ====================================================================
      //  Buttons in main menu.
      // ====================================================================
      class LDSTYTextButton extends LDGUIStyles;
      
      defaultproperties
      {
      	KeyName="TextButton"
      
      	Images(0)=None
      	Images(1)=None
      	Images(2)=None
      	Images(3)=None
      
      	FontNames(0)="LDMainMenuFont"
      	FontNames(1)="LDMainMenuFont"
      	FontNames(2)="LDMainMenuFont"
      	FontNames(3)="LDMainMenuFont"
      	FontNames(4)="LDMainMenuFont"
      
      	FontColors(0)=(R=207,G=185,B=103,A=255)
      	FontColors(1)=(R=244,G=237,B=205,A=255)
      	FontColors(2)=(R=244,G=237,B=205,A=255)
      	FontColors(3)=(R=244,G=237,B=205,A=255)
      	FontColors(4)=(R=244,G=237,B=205,A=255)
      }
      You have to actually import the font first, which you can do with the TrueTypeFontfactory (search the Wiki for info on that).

      Comment


        #4
        Thanks for replying mr.evil,

        I setup a very similar code structure, my guicontroller subclass looks like this:


        Code:
        class TotrStyleGuiController extends GUIcontroller;
        
        defaultproperties
        {
        Begin Object class=Totguifont Name=Totguifont
        End Object
        FontStack(11)=Totrguifont'Totrguifont'
        StyleNames(17)="STY_Totrmenu"
        }
        On compilation of "ALL" my class files, I get and error in this class on the line (FontStack(11)=Totrguifont'Totrguifont')

        ERROR:
        Default Properties (TotrStyleGuiController): Error: ObjectProperty XInterface.GUIController.FontStack.FontStack: unresolved reference to 'Totrguifont'Totrguifont''.


        The font is imported properly using a font importer and resides in the texture package totrtex. Here is another class, the font class where you can see the reference to the font textures.

        Code:
        class Totrguifont extends GUIfont;
        
        defaultproperties
        {
        KeyName="Totrguifont";
        bScaled=true
        FontArrayNames(0)="Totrtex.Viantafont_PageA"
        FontArrayNames(1)="Totrtex.Viantafont_PageB"
        FontArrayNames(2)="Totrtex.Viantafont_PageC"
        FontArrayNames(3)="Totrtex.Viantafont_PageD"
        FontArrayNames(4)="Totrtex.Viantafont_PageE"
        }

        Please help.

        Comment


          #5
          With the help of another coder I realized a stupid mistake and it has been fixed (naming mistake).

          Now its just a matter of getting the font working. My fonts are textures with the following names, is this correct?

          Code:
          class Totrguifont extends GUIfont;
          
          defaultproperties
          {
          KeyName="Totrguifont";
          bScaled=true
          FontArrayNames(0)="Totrtex.Viantafont_PageA"
          FontArrayNames(1)="Totrtex.Viantafont_PageB"
          FontArrayNames(2)="Totrtex.Viantafont_PageC"
          FontArrayNames(3)="Totrtex.Viantafont_PageD"
          FontArrayNames(4)="Totrtex.Viantafont_PageE"
          }

          Comment


            #6
            Originally posted by Smood
            ...Now its just a matter of getting the font working. My fonts are textures with the following names, is this correct?..
            No. There is a font object created in the package which uses the textures, but the textures themselves are not the font.

            The name of the font object is what you specify in Name= when you import the font.

            Comment


              #7
              Ok Mr.Evil... I used a UFONTMatrial importer for my true type font. It imported the font and I called it 'Viantafont'. I can see the fonts in the texture browser.

              As per your instructions I rewrote my font class to reference this.

              Code:
              class Totrguifont extends GUIfont;
              
              defaultproperties
              {
              KeyName="Totrguifont";
              bScaled=true
              FontArrayNames(0)="Totrtex.Viantafont"
              FontArrayNames(1)="Totrtex.Viantafont"
              FontArrayNames(2)="Totrtex.Viantafont"
              FontArrayNames(3)="Totrtex.Viantafont"
              FontArrayNames(4)="Totrtex.Viantafont"
              }
              Now I only applied my new style to the first gui button, and when I run it, the button is black with the same ut2004 font :\. So something is not working. I appreciate your help immensely, and anything more you can tell me would be helpful!

              Comment


                #8
                I can't think what else could be wrong. Try using the GUI design mode to verify that the right style/font/etc is applied.

                Comment

                Working...
                X