Core.Object | +--Engine.Actor | +--Engine.Menu | +--UnrealShare.UnrealMenu | +--UnrealShare.UnrealLongMenu | +--UnrealShare.UnrealServerMenu
string
BotTitle
int
CurrentGame
byte
Difficulty
class
GameClass
GameType
Games[16]
Map
MaxGames
bool
bStandalone
void
DrawMenu(Canvas Canvas)
PostBeginPlay()
ProcessLeft()
ProcessRight()
ProcessSelection()
SaveConfigs()
SetGameClass()
UpdateGameClass(string NewGame, int Offset)
00001 //============================================================================= 00002 // UnrealServerMenu 00003 //============================================================================= 00004 class UnrealServerMenu extends UnrealLongMenu; 00005 00006 var config string Map; 00007 var config string GameType; 00008 var string Games[16]; 00009 var int MaxGames; 00010 var int CurrentGame; 00011 var class<GameInfo> GameClass; 00012 var bool bStandalone; 00013 var localized string BotTitle; 00014 var byte Difficulty; 00015 00016 function PostBeginPlay() 00017 { 00018 local string NextGame; 00019 local bool bFoundSavedGameClass; 00020 00021 Super.PostBeginPlay(); 00022 Difficulty = -1; // 00023 NextGame = GetNextInt("GameInfo", 0); 00024 while ( (NextGame != "") && (MaxGames < 16) ) 00025 { 00026 if ( !bFoundSavedGameClass && (NextGame ~= GameType) ) 00027 { 00028 bFoundSavedGameClass = true; 00029 CurrentGame = MaxGames; 00030 } 00031 Games[MaxGames] = NextGame; 00032 MaxGames++; 00033 NextGame = GetNextInt("GameInfo", MaxGames); 00034 } 00035 } 00036 00037 function UpdateGameClass( string NewGame, int Offset ) 00038 { 00039 Games[Offset] = NewGame; 00040 } 00041 00042 function SetGameClass() 00043 { 00044 local int i; 00045 00046 GameType = Games[CurrentGame]; 00047 GameClass = class<gameinfo>(DynamicLoadObject(GameType, class'Class')); 00048 if ( GameClass == None ) 00049 { 00050 MaxGames--; 00051 if ( MaxGames > CurrentGame ) 00052 { 00053 for ( i=CurrentGame; i<MaxGames; i++ ) 00054 Games[i] = Games[i+1]; 00055 } 00056 else if ( CurrentGame > 0 ) 00057 CurrentGame--; 00058 SetGameClass(); 00059 return; 00060 } 00061 Map = GetMapName(GameClass.Default.MapPrefix, Map,0); 00062 } 00063 00064 function bool ProcessLeft() 00065 { 00066 local int i; 00067 00068 if ( Selection == 1 ) 00069 { 00070 if ( MaxGames == 0 ) 00071 { 00072 CurrentGame = 0; 00073 return true; 00074 } 00075 CurrentGame--; 00076 if ( CurrentGame < 0 ) 00077 CurrentGame = MaxGames - 1; 00078 SetGameClass(); 00079 if ( (GameClass == None) && (MaxGames > 0) ) 00080 ProcessLeft(); 00081 } 00082 else if ( Selection == 2 ) 00083 { 00084 GameClass = class<gameinfo>(DynamicLoadObject(GameType, class'Class')); 00085 if ( GameClass == None ) 00086 { 00087 MaxGames--; 00088 if ( MaxGames > CurrentGame ) 00089 { 00090 for ( i=CurrentGame; i<MaxGames; i++ ) 00091 Games[i] = Games[i+1]; 00092 } 00093 else if ( CurrentGame > 0 ) 00094 CurrentGame--; 00095 } 00096 Map = GetMapName(GameClass.Default.MapPrefix, Map, -1); 00097 } 00098 else 00099 return false; 00100 00101 return true; 00102 } 00103 00104 function bool ProcessRight() 00105 { 00106 local int i; 00107 00108 if ( Selection == 1 ) 00109 { 00110 if ( MaxGames == 0 ) 00111 { 00112 CurrentGame = 0; 00113 return true; 00114 } 00115 CurrentGame++; 00116 if ( CurrentGame >= MaxGames ) 00117 CurrentGame = 0; 00118 SetGameClass(); 00119 if ( (GameClass == None) && (MaxGames > 0) ) 00120 ProcessRight(); 00121 } 00122 else if ( Selection == 2 ) 00123 { 00124 GameClass = class<gameinfo>(DynamicLoadObject(GameType, class'Class')); 00125 if ( GameClass == None ) 00126 { 00127 MaxGames--; 00128 if ( MaxGames > CurrentGame ) 00129 { 00130 for ( i=CurrentGame; i<MaxGames; i++ ) 00131 Games[i] = Games[i+1]; 00132 } 00133 else if ( CurrentGame > 0 ) 00134 CurrentGame--; 00135 } 00136 Map = GetMapName(GameClass.Default.MapPrefix, Map, 1); 00137 } 00138 else 00139 return false; 00140 00141 return true; 00142 } 00143 00144 function bool ProcessSelection() 00145 { 00146 local Menu ChildMenu; 00147 local string URL; 00148 local GameInfo NewGame; 00149 local int i; 00150 00151 GameClass = class<gameinfo>(DynamicLoadObject(GameType, class'Class')); 00152 if ( GameClass == None ) 00153 { 00154 MaxGames--; 00155 if ( MaxGames > CurrentGame ) 00156 { 00157 for ( i=CurrentGame; i<MaxGames; i++ ) 00158 Games[i] = Games[i+1]; 00159 } 00160 else if ( CurrentGame > 0 ) 00161 CurrentGame--; 00162 return true; 00163 } 00164 00165 if( Selection == 3 ) 00166 { 00167 ChildMenu = spawn( GameClass.Default.GameMenuType, owner ); 00168 HUD(Owner).MainMenu = ChildMenu; 00169 ChildMenu.ParentMenu = self; 00170 ChildMenu.PlayerOwner = PlayerOwner; 00171 return true; 00172 } 00173 else if ( Selection == 4 ) 00174 { 00175 NewGame = Spawn(GameClass); 00176 NewGame.ResetGame(); 00177 NewGame.Destroy(); 00178 00179 URL = Map $ "?Game="$GameType; 00180 if ( (Difficulty < 0) || (Difficulty > 3) ) 00181 Difficulty = 1; 00182 URL = URL$"?Difficulty="$Difficulty; 00183 if ( Level.Game != None ) 00184 URL = URL$"?GameSpeed="$Level.Game.GameSpeed; 00185 if( !bStandAlone ) 00186 URL = URL $ "?Listen"; 00187 SaveConfigs(); 00188 ChildMenu = spawn(class'UnrealMeshMenu', owner); 00189 if ( ChildMenu != None ) 00190 { 00191 UnrealMeshMenu(ChildMenu).StartMap = URL; 00192 HUD(Owner).MainMenu = ChildMenu; 00193 ChildMenu.ParentMenu = self; 00194 ChildMenu.PlayerOwner = PlayerOwner; 00195 } 00196 log( "URL: '" $ URL $ "'" ); 00197 return true; 00198 } 00199 else if ( Selection == 5 ) 00200 { 00201 NewGame = Spawn(GameClass); 00202 NewGame.ResetGame(); 00203 NewGame.Destroy(); 00204 00205 URL = Map $ "?Game="$GameType; 00206 if ( (Difficulty < 0) || (Difficulty > 3) ) 00207 Difficulty = 1; 00208 URL = URL$"?Difficulty="$Difficulty; 00209 SaveConfigs(); 00210 PlayerOwner.ConsoleCommand("RELAUNCH "$URL$" -server log=server.log"); 00211 return true; 00212 } 00213 else return false; 00214 } 00215 00216 function SaveConfigs() 00217 { 00218 SaveConfig(); 00219 PlayerOwner.SaveConfig(); 00220 //PlayerOwner.PlayerReplicationInfo.SaveConfig(); 00221 } 00222 00223 function DrawMenu(canvas Canvas) 00224 { 00225 local int i, StartX, StartY, Spacing; 00226 local string MapName; 00227 00228 DrawBackGround(Canvas, false); 00229 00230 // Draw Title 00231 if ( bStandAlone ) 00232 { 00233 MenuLength = 4; 00234 MenuTitle = BotTitle; 00235 } 00236 DrawTitle(Canvas); 00237 00238 Spacing = Clamp(0.07 * Canvas.ClipY, 12, 48); 00239 StartX = Max(40, 0.5 * Canvas.ClipX - 120); 00240 StartY = Max(40, 0.5 * (Canvas.ClipY - MenuLength * Spacing - 128)); 00241 Canvas.Font = Canvas.MedFont; 00242 00243 // draw text 00244 for( i=1; i<MenuLength+1; i++ ) 00245 MenuList[i] = Default.MenuList[i]; 00246 00247 DrawList(Canvas, false, Spacing, StartX, StartY); 00248 00249 // draw values 00250 SetGameClass(); 00251 MenuList[1] = GameClass.Default.GameName; 00252 MapName = Left(Map, Len(Map) - 4 ); 00253 MenuList[2] = MapName; 00254 MenuList[3] = ""; 00255 MenuList[4] = ""; 00256 MenuList[5] = ""; 00257 DrawList(Canvas, false, Spacing, StartX + 100, StartY); 00258 00259 // Draw help panel 00260 DrawHelpPanel(Canvas, StartY + MenuLength * Spacing + 8, 228); 00261 } 00262 00263 defaultproperties 00264 { 00265 GameType="UnrealShare.DeathMatchGame" 00266 BotTitle="BOTMATCH" 00267 MenuLength=5 00268 HelpMessage(1)="Choose Game Type." 00269 HelpMessage(2)="Choose Map." 00270 HelpMessage(3)="Modify Game Options." 00271 HelpMessage(4)="Start Game." 00272 HelpMessage(5)="Start a dedicated server on this machine." 00273 MenuList(1)="Select Game" 00274 MenuList(2)="Select Map" 00275 MenuList(3)="Configure Game" 00276 MenuList(4)="Start Game" 00277 MenuList(5)="Launch Dedicated Server" 00278 MenuTitle="MULTIPLAYER" 00279 }