Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

GUI2K4.UT2K4VideoChangeOK


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
// ====================================================================
// (C) 2002, Epic Games
// ====================================================================

class UT2K4VideoChangeOK extends UT2K4GenericMessageBox;

var() noexport enum EVideoChangeType { VCT_Resolution, VCT_FullScreen, VCT_Device } ChangeType;
var() noexport transient int    Count;
var() noexport transient string RevertString;
var() localized string  RestoreText, SecondText, SecondsText;
var() string OverrideResNotice;

var automated GUIButton b_Cancel;

function InitComponent(GUIController InController, GUIComponent InOwner)
{
    Super.InitComponent(InController, InOwner);

    OverrideResNotice =
        Localize( "UT2DeferChangeRes", "DialogText.Caption", "XInterface" ) $ "|" $
        Localize( "UT2DeferChangeRes", "DialogText2.Caption", "XInterface" );
}

function Execute(string DesiredRes)
{
    if ( DesiredRes == "" )
    {
        KillTimer();
        if ( Controller.ActivePage == Self )
            Controller.CloseMenu();

        return;
    }

    if ( InStr(DesiredRes, "x16") != -1 || InStr(DesiredRes, "x32") != -1 )
    {
        ChangeType = VCT_Resolution;
        ChangeResolution(DesiredRes);
    }

    else if ( DesiredRes ~= "togglefullscreen" )
    {
        ChangeType = VCT_FullScreen;
        ToggleFullScreen();
    }
    else
    {
        ChangeType = VCT_Device;
        SetDevice(DesiredRes);
    }
}

function ToggleFullScreen()
{
    RevertString = "togglefullscreen";
    PlayerOwner().ConsoleCommand(RevertString);
    StartTimer();
}

function ChangeResolution( string DesiredRes )
{
    local int i;
    local string CurrentRes, NewX, NewY, NewDepth, NewScreen;
    local bool lowres;

    // Create the string we'll use to revert settings if change is undesireable
    CurrentRes  = Controller.GetCurrentRes();
    lowres = bool(PlayerOwner().ConsoleCommand("get ini:Engine.Engine.RenderDevice Use16bit"));

    RevertString = "setres" @ CurrentRes;
    if (lowres)
        RevertString $= "x16";
    else
        RevertString $= "x32";

    if(bool(PlayerOwner().ConsoleCommand("ISFULLSCREEN")))
        RevertString $= "f";
    else
        RevertString $= "w";


    // Apply new resolution and wait for acceptance
    PlayerOwner().ConsoleCommand("set ini:Engine.Engine.RenderDevice Use16bit"@(InStr(DesiredRes,"x16") != -1));

    i = InStr(DesiredRes, "x");

    NewX = Left(DesiredRes, i);
    NewY = Mid( DesiredRes, i + 1 );
    i = InStr( NewY, "x" );
    if ( i != -1 )
    {
        NewDepth = Mid(NewY, i);
        NewY = Left(NewY, i);

        if ( Right(NewDepth,1) ~= "f" || Right(NewDepth,1) ~= "w" )
        {
            NewScreen = Right(NewDepth,1);
            NewDepth = Left(NewDepth, Len(NewDepth)-1);
        }
    }

    if( int(NewX) < 640 || int(NewY) < 480 )
    {
        KillTimer();
        PlayerOwner().ConsoleCommand("TEMPSETRES 640x480" $ NewDepth $ NewScreen);
        if ( Controller.OpenMenu("GUI2K4.UT2K4GenericMessageBox","",OverrideResNotice) )
            Controller.ActivePage.OnClose = DeferChangeOnClose;
    }
    else
    {
        PlayerOwner().ConsoleCommand( "SETRES" @ DesiredRes );
        StartTimer();
    }
}

function SetDevice( string NewRenderDevice )
{
    RevertString = PlayerOwner().ConsoleCommand("get ini:Engine.Engine.RenderDevice Class");
    if ( RevertString ~= NewRenderDevice || !Controller.SetRenderDevice(NewRenderDevice) )
    {
        KillTimer();
        if ( Controller.ActivePage == Self )
            Controller.CloseMenu();

        return;
    }

    StartTimer();
}

function DeferChangeOnClose(optional Bool bCancelled)
{
    StartTimer();
}

function StartTimer()
{
    Count=15;
    SetTimer(1.0,true);
}

event Timer()
{
    Count--;
    l_Text2.Caption = Repl(RestoreText, "%count%", Count);

    if ( Count == 1 )
        l_Text2.Caption = Repl(l_Text2.Caption, "%seconds%", SecondText);
    else l_Text2.Caption = Repl(l_Text2.Caption, "%seconds%", SecondsText);

    if ( Count <= 0 )
        InternalOnClick(b_Cancel);
}

function bool InternalOnClick(GUIComponent Sender)
{
    KillTimer();
    if (Sender==b_Cancel)
    {
        switch (ChangeType)
        {
        case VCT_Resolution:
            PlayerOwner().ConsoleCommand("set ini:Engine.Engine.RenderDevice Use16bit"@(InStr(RevertString,"x16")!=-1));
            PlayerOwner().ConsoleCommand(RevertString);
            break;

        case VCT_FullScreen:
            PlayerOwner().ConsoleCommand(RevertString);
            break;

        case VCT_Device:
            Controller.SetRenderDevice(RevertString);
            break;
        }
    }

    Controller.CloseMenu(Sender == b_Cancel);
    return true;
}

defaultproperties
{
     RestoreText="(Original settings will be restored in %count% %seconds%)"
     SecondText="second"
     SecondsText="seconds"
     Begin Object Class=GUIButton Name=bCancel
         Caption="Restore Settings"
         WinTop=0.558334
         WinLeft=0.650000
         WinWidth=0.200000
         bBoundToParent=Wahr
         OnClick=UT2K4VideoChangeOK.InternalOnClick
         OnKeyEvent=bCancel.InternalOnKeyEvent
     End Object
     b_Cancel=GUIButton'GUI2K4.UT2K4VideoChangeOK.bCancel'

     Begin Object Class=GUIButton Name=bOk
         Caption="Keep Settings"
         WinTop=0.558334
         WinLeft=0.175000
         WinWidth=0.200000
         bBoundToParent=Wahr
         OnClick=UT2K4VideoChangeOK.InternalOnClick
         OnKeyEvent=bOk.InternalOnKeyEvent
     End Object
     b_OK=GUIButton'GUI2K4.UT2K4VideoChangeOK.bOk'

     Begin Object Class=GUILabel Name=lbText
         Caption="Accept these settings?"
         TextAlign=TXTA_Center
         FontScale=FNS_Large
         StyleName="TextLabel"
         WinTop=0.390000
         WinHeight=0.068750
     End Object
     l_Text=GUILabel'GUI2K4.UT2K4VideoChangeOK.lbText'

     Begin Object Class=GUILabel Name=lbText2
         Caption="(Original settings will be restored in 15 seconds)"
         TextAlign=TXTA_Center
         StyleName="TextButton"
         WinTop=0.460000
         WinHeight=0.045000
     End Object
     l_Text2=GUILabel'GUI2K4.UT2K4VideoChangeOK.lbText2'

     InactiveFadeColor=(B=128,G=128,R=128)
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fr 30.3.2007 08:43:56.000 - Creation time: Mo 16.4.2007 11:20:56.875 - Created with UnCodeX