//----------------------------------------------------------- // //----------------------------------------------------------- class UT2K4MidGameMenu extends UT2K4GUIPage; //if _RO_ // else //#EXEC OBJ LOAD FILE=2K4Menus.utx // end if _RO_ var bool bIgnoreEsc; var localized string LeaveMPButtonText; var localized string LeaveSPButtonText; var localized string LeaveEntryButtonText; var bool bPerButtonSizes; var GUIButton SizingButton; var Automated GUIImage MyHeader; var Automated GUIButton bContinue, bQuit, bForfit, bSettings, bChangeTeam, bAdd2Favorites, bServerBrowser, bVoting, bMapVoting, bKickVoting, bMatchSetup; function InitComponent(GUIController MyController, GUIComponent MyOwner) { local PlayerController PC; Super.InitComponent(MyController, MyOwner); PC = PlayerOwner(); if (PC.GameReplicationInfo == None || !PC.GameReplicationInfo.bTeamGame || PC.GameReplicationInfo.bNoTeamChanges ) RemoveComponent(bChangeTeam); // if (PC.Level.NetMode != NM_Client || CurrentServerIsInFavorites()) // RemoveComponent(bAdd2Favorites); // Set 'leave' button text depending on if we are SP or MP if( PC.Level.NetMode != NM_StandAlone ) bForfit.Caption = LeaveMPButtonText; else bForfit.Caption = LeaveSPButtonText; // disable voting in single player mode if( PC.Level.NetMode == NM_StandAlone ) { RemoveComponent(bVoting); RemoveComponent(bMapVoting); RemoveComponent(bKickVoting); RemoveComponent(bMatchSetup); } GetSizingButton(); } function GetSizingButton() { local int i; for (i = 0; i < Components.Length; i++) { if (GUIButton(Components[i]) != None) { if (SizingButton == None || Len(GUIButton(Components[i]).Caption) > Len(SizingButton.Caption)) SizingButton = GUIButton(Components[i]); } } } function bool InternalOnPreDraw(Canvas Canvas) { local int i, X, Y; local float XL,YL; SizingButton.Style.TextSize(Canvas, SizingButton.MenuState, SizingButton.Caption, XL, YL, SizingButton.FontScale); XL += 16; YL += 8; bQuit.WinWidth = XL; bQuit.WinLeft = Canvas.ClipX - bQuit.WinWidth; bQuit.WinTop = 0; bQuit.WinHeight = YL; for (i = 0; i < Components.Length; i++) { if (GUIButton(Components[i]) != None && Components[i] != bQuit) { if (bPerButtonSizes) { Components[i].Style.TextSize(Canvas, Components[i].MenuState, GUIButton(Components[i]).Caption, XL, YL, Components[i].FontScale); YL += 8; } if (X + XL > bQuit.WinLeft) { X = 0; Y += YL; } Components[i].WinTop = Y; Components[i].WinLeft = X; Components[i].WinWidth = XL; Components[i].WinHeight = YL; X += XL; } } MyHeader.WinHeight = Y + YL + 2; return false; } function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) { // Swallow first escape key event (key up from key down that opened menu) if(bIgnoreEsc && Key == 0x1B) { bIgnoreEsc = false; return true; } return false; } /* // See if we already have this server in our favorites function bool CurrentServerIsInFavorites() { local string address, ipString, portString; local int colonPos, portNum, i; // Get current network address address = PlayerOwner().GetServerNetworkAddress(); if(address == "") return true; // slightly hacky - dont want to add "none"! // Parse text to find IP and possibly port number colonPos = InStr(address, ":"); if(colonPos < 0) { // No colon - assume port 7777 ipString = address; portNum = 7777; } else { // Parse out port number ipString = Left(address, colonPos); portString = Mid(address, colonPos+1); portNum = int(portString); } for(i=0; i