| Home Page | Recent Changes

Punk129/Savegames 2k4 Gui

For my current project I played a bit with the savegame function of UT2004.

But because there is neither a GUI nor a chance to get a list of all savegames, I decided to make my own functions using config variables. (original is available [here])

The parent class: Interface_SaveGamePage.uc

Because we have 2 different pages looking for the same information (load/save) we need a common parent class offering the globalconfig vars:

//=============================================================================
// © 2004 Steffen 'punk129' Windhab
// -punk129@blackshadowstudios.com-
//=============================================================================
// The parent class: Interface_SaveGamePage.uc
//=============================================================================
class Interface_SaveGamePage extends UT2K4GUIPage config(User);

#EXEC OBJ LOAD FILE=BSInterface.utx

var Automated GUIImage MyBackGround;

//list including all saved games
var Automated GUIList SaveGameList;

//textbox showing the saved map's description
var Automated GUIScrollTextBox TBDesc;

//check if the "empty slot" is needed
var bool bSaving;

//the config var saving the savegame names
var globalconfig array<string> SaveCaptions;

//the config var saving the savegame descs
var globalconfig array<string> SaveDescs;

function InternalOnOpen()
{
    local PlayerController PC;
    local BS_Pawn P;
    local int i;

        PC = PlayerOwner();
        P = BS_Pawn(PC.Pawn);

        for(i=0; i < SaveCaptions.Length; i++)
        {
                //add all saved games to the savegame list
                SaveGameList.Add(SaveCaptions[i],,SaveDescs[i]);
        }
        if (bSaving)
                //if saving add an empty slot
                SaveGameList.Add("Empty Slot");
}


function bool InternalOnDblClick(GUIComponent Sender)
{
        //added for delegate
        return true;
}

function InternalOnChange(GUIComponent Sender)
{
        if (sender == SaveGameList)
        {
                //set the textbox's content
                TBDesc.SetContent(SaveGameList.GetExtra());
        }
}

DefaultProperties
{
        OnOpen=InternalOnOpen

        Begin Object class=GUIImage name=BackGround
                WinWidth=1
                WinHeight=1
                WinLeft=0
                WinTop=0
                Image=Material'BSInterface.background_default'
                ImageStyle=ISTY_Scaled
                ImageRenderStyle=MSTY_Normal
                bVisible=true
        End Object
        MyBackGround=BackGround

        Begin Object class=GUIScrollTextBox name=TextBox_Desc
                WinWidth=0.4
                WinHeight=0.4
                WinLeft=0.55
                WinTop=0.055
                bNoTeletype=true
                bVisible=true
        End Object
        TBDesc=TextBox_Desc

        Begin Object Class=GUIList Name=List_Saves
                OnDblClick=InternalOnDblClick
                OnChange=InternalOnChange
                WinTop=0.055
                WinLeft=0.05
                WinWidth=0.4
                WinHeight=0.89
        End Object
        SaveGameList=List_Saves



        WinWidth=1.0
        WinHeight=1.0
        WinTop=0.0
        WinLeft=0.0

        bAllowedAsLast=true
}

The savepage: Interface_SavePage.uc

This is the guipage, where games will be saved from.

//=============================================================================
// © 2004 Steffen 'punk129' Windhab
// -punk129@blackshadowstudios.com-
//=============================================================================
// The savepage: Interface_SavePage.uc
//=============================================================================
class Interface_SavePage extends Interface_SaveGamePage;

var Automated GUIButton bSave;

function bool LeftButtonClick(GUIComponent Sender)
{
    local PlayerController PC;
    local int i;

        PC = PlayerOwner();

        if (Sender == bSave)
        {
                //get the slot for save
                i = SaveGameList.FindIndex(SaveGameList.Get());

                //save the game
                PC.ConsoleCommand("SaveGame "$i);

                //save caption and desc to the ini file
                SaveCaptions[i] = PC.Level.Title$" | "$PC.Level.Day$"/"$PC.Level.Month$"/"$PC.Level.Year$" | "$PC.Level.Hour$":"$PC.Level.Minute$":"$PC.Level.Second;
                SaveDescs[i] = PC.Level.Description;
                SaveConfig();

                Controller.CloseMenu(false);
        }

        return true;
}


//just the same, but on double click
function bool InternalOnDblClick(GUIComponent Sender)
{
    local PlayerController PC;
    local int i;

        PC = PlayerOwner();

        if (Sender == SaveGameList)
        {
                //get the slot for save
                i = SaveGameList.FindIndex(SaveGameList.Get());

                //save the game
                PC.ConsoleCommand("SaveGame "$i);

                //save caption and desc to the ini file
                SaveCaptions[i] = PC.Level.Title$" | "$PC.Level.Day$"/"$PC.Level.Month$"/"$PC.Level.Year$" | "$PC.Level.Hour$":"$PC.Level.Minute$":"$PC.Level.Second;
                SaveDescs[i] = PC.Level.Description;
                SaveConfig();

                Controller.CloseMenu(false);
        }

        return true;
}

DefaultProperties
{
        Begin Object Class=GUIButton Name=Button_Save
                OnClick=LeftButtonClick
                bVisible=true
                bTabStop=False
                RenderWeight=0.6
                TabOrder=0
                WinWidth=0.26
                WinHeight=0.08
                WinLeft=0.63
                WinTop=0.8
                Caption="Save Game"
        End Object
        bSave=Button_Save

    //add empty slot
    bSaving=true
}

screen of my dev. version:

The loadpage: Interface_LoadPage.uc

This is the guipage, where games will be saved from.

//=============================================================================
// © 2004 Steffen 'punk129' Windhab
// -punk129@blackshadowstudios.com-
//=============================================================================
// The loadpage: Interface_LoadPage.uc
//=============================================================================
class Interface_LoadPage extends Interface_SaveGamePage;

var Automated GUIButton bLoad;

function bool LeftButtonClick(GUIComponent Sender)
{
    local PlayerController PC;
    local int i;

        PC = PlayerOwner();

        if (Sender == bLoad)
        {
                //get the slot where the game is saved
                i = SaveGameList.FindIndex(SaveGameList.Get());

                //load the savegame
                PC.ClientTravel( "?load="$i, TRAVEL_Absolute, false);
        }

        return true;
}


//just the same, but on double click
function bool InternalOnDblClick(GUIComponent Sender)
{
    local PlayerController PC;
    local int i;

        PC = PlayerOwner();

        if (Sender == SaveGameList)
        {
                //get the slot where the game is saved
                i = SaveGameList.FindIndex(SaveGameList.Get());

                //load the savegame
                PC.ClientTravel( "?load="$i, TRAVEL_Absolute, false);
        }

        return true;
}

DefaultProperties
{
        Begin Object Class=GUIButton Name=Button_Load
                OnClick=LeftButtonClick
                bVisible=true
                bTabStop=False
                RenderWeight=0.6
                TabOrder=0
                WinWidth=0.26
                WinHeight=0.08
                WinLeft=0.63
                WinTop=0.8
                Caption="Load Game"
        End Object
        bLoad=Button_Load

    //don't add the empty slot, because we are loading
    bSaving=false
}

screen of my dev. version:

Related Topics

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In