| Home Page | Recent Changes | Preferences

# GUIPage

UT2003 :: GUI >> GUIComponent >> GUIMultiComponent >> GUIPage

VERY IMPORTANT FOR n00bs:

if, when you close your GUIPages, it exits the level to the main menu, READ THIS:

from GUIPage.uc

    ...
    var bool bAllowedAsLast;    // If this is true, closing this page will not bring up the main menu
    ...

HEHEHE, so your GUIPAge subclass better have bAllowedAsLast=true in defaultproperties, or else, you will spend two days figuring it out and, will even dream about it!

by AlphaOne

### Using GUIPage To Make a GUI

The general need for a GUI is to provide some level of interaction with the player. If you just want to display something, chance are you want to use the ScoreBoard or some other Canvas-aimed class. So let's start with something simple: a button. It will call the SetupStuff() function in the player.

The first thing you'll need to do is create a Subobject in your default properties (this isn't mandatory, but it fits perfectly with the purpose.) It looks like this:

    defaultproperties
    {
        Begin Object Class=GUIButton Name=SetupButton
            Caption   = "Setup Stuff";
            //Size of this button
            WinTop    = 0.800;  //NOTE!! This is 0-1, with 0 being the *top* of the screen.
            WinLeft   = 0.100;
            WinWidth  = 0.300;
            WinHeight = 0.040;
            StyleName = "RoundButton";
            OnClick   = InternalOnClick;
        End Object

        Controls[0] = GUIButton'SetupButton';
    }

Notice the OnClick delegate function assignment. There are numerous delegate functions in the GUIComponent class and the important thing to remember is that whatever function you assign it to, it has the same arguments. In the case of the delegate OnClick, right here, we are passed a GUIComponent, which will be the component clicked. We can use this function to check what was clicked and act on it, like so:

    function bool InternalOnClick(GUIComponent Sender)
    {
        //My custom player controller that needs to be set up.
        local myPlayerController PC;

        //Check to see if our SetupButton was what was clicked
        if( Sender == Controls[0] )
        {
            //ViewportOwner comes from Interaction, which
            //our GUIController (the dude who manages this)
            //is a subclass of
            PC = myPlayerController(Controller.ViewportOwner);

            //Always check!
            if( PC == none )
                return false;

            //Set up our player's stuff!
            PC.SetupStuff();
            return true;
        }

        return false;
    }

So we first check to see if it was our button that called the function (sometimes you'll have several you want to differentiate between.) Then we get our playercontroller and call the function on it. Simple!

You can use a lot besides buttons, just check out the GUI Class Hierarchy.

A special note: This is in fact client side which means that if you want it to affect things on the server you must use proper replication. For instance, if you want SetupStuff() to set health and armor data, you would want to replicate that function to the server.

### How to Change the Music Played at the Main Menu

One of the common things a Mod Maker will want to do is alter the Music played during the main menu. The easiest way to do this is by adding this simple piece of code to your GUIPage (could even use different music for difference pages in theory).

    function InitComponent(GUIController MyController, GUIComponent MyOwner)
    {
        Super.InitComponent(MyController, MyOwner);
        Controller.ViewPortOwner.Actor.GetEntryLevel().Song = "UMS_Main_Menu_Music";
    }

The other way of achieving this is to use a custom Entry.ut2 map. This map is always loaded even when playing other maps, so for performance reasons it is best to keep this simple. When making your own Entry.ut2 map, it's recommended to place this in a separate directory (eg. UT2003/MyMod/Maps). You can use all manner of mapping tools here, such a matinee sequences. It's easy enough to set the level music for this map. To make use of this, your mod would need to use it's own .ini file. Find the Core.System and place your ../MyMod/Maps/*.ut2 entry above the existing Maps entry.

      [Core.System]
      ...
      ...
      Paths=../MyMod/Maps/*.ut2
      Paths=../Maps/*.ut2
      Paths= ...
      ...
      ...

Using this method Unreal will find your custom Entry.ut2 map before the default one and use that. Just keep in mind this map is always loaded, so keep it fairly simple.

Haral: I decided to make something of a practical GUI guide here. If I just missed someone else's, it sucks, or something of that nature delete it, move it, or whatever.

Wormbo: We definately have a Category To Do here. Wiki class header, properties, methods and known subclasses like on other class pages should be added.

Daemonica: I've added some knowledge I've picked up about changing the music played during maps. This can be found at Daemonica/Previous Problems, hope it's helpful.

Category Class (UT2003)
Category To Do

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In