Core.Object | +--Engine.Actor | +--Engine.Menu | +--UnrealShare.UnrealMenu | +--UnrealShare.UnrealLongMenu | +--UnrealShare.UnrealBotConfigMenu
string
MenuValues[20]
void
AdjustDifficulty(int Dir)
DrawMenu(Canvas Canvas)
DrawValues(Canvas Canvas, Font RegFont, int Spacing, int StartX, int StartY)
InitConfig(GameInfo G)
bool
ProcessLeft()
ProcessNo()
ProcessRight()
ProcessSelection()
ProcessYes()
SaveConfigs()
00001 //============================================================================= 00002 // UnrealBotConfigMenu 00003 //============================================================================= 00004 class UnrealBotConfigMenu extends UnrealLongMenu; 00005 00006 var string MenuValues[20]; 00007 var bool bAdjustSkill; 00008 var bool bRandomOrder; 00009 var UnrealServerMenu SvMenu; 00010 var GameInfo GameType; 00011 var byte Difficulty; 00012 00013 function InitConfig(GameInfo G) 00014 { 00015 local BotInfo BotConfig; 00016 00017 GameType = G; 00018 00019 if ( (Level.Game != None) && Level.Game.IsA('DeathMatchGame') ) 00020 BotConfig = DeathMatchGame(Level.Game).BotConfig; 00021 else 00022 BotConfig = Spawn(DeathMatchGame(GameType).Default.BotConfigType); 00023 00024 bAdjustSkill = BotConfig.bAdjustSkill; 00025 bRandomOrder = BotConfig.bRandomOrder; 00026 00027 if ( (Level.Game == None) || !Level.Game.IsA('DeathMatchGame') ) 00028 BotConfig.Destroy(); 00029 00030 SvMenu = UnrealServerMenu(ParentMenu.ParentMenu); 00031 Difficulty = BotConfig.Difficulty; 00032 00033 if ( SvMenu != None ) 00034 SvMenu.Difficulty = Difficulty; 00035 } 00036 00037 function AdjustDifficulty(int Dir) 00038 { 00039 Difficulty = Clamp(Difficulty + Dir, 0, 3); 00040 00041 if ( SvMenu != None ) 00042 SvMenu.Difficulty = Difficulty; 00043 if ( Level.Game.IsA('DeathMatchGame') ) 00044 Level.Game.Difficulty = Difficulty; 00045 } 00046 00047 function bool ProcessYes() 00048 { 00049 if ( Selection == 1 ) 00050 bAdjustSkill = true; 00051 else if ( Selection == 3 ) 00052 bRandomOrder = true; 00053 else if ( Selection == 6 ) 00054 DeathMatchGame(GameType).bMultiPlayerBots = True; 00055 else 00056 return false; 00057 00058 return true; 00059 } 00060 00061 function bool ProcessNo() 00062 { 00063 if ( Selection == 1 ) 00064 bAdjustSkill = false; 00065 else if ( Selection == 3 ) 00066 bRandomOrder = false; 00067 else if ( Selection == 6 ) 00068 DeathMatchGame(GameType).bMultiPlayerBots = false; 00069 else 00070 return false; 00071 00072 return true; 00073 } 00074 00075 function bool ProcessLeft() 00076 { 00077 if ( Selection == 1 ) 00078 bAdjustSkill = !bAdjustSkill; 00079 else if ( Selection == 2 ) 00080 AdjustDifficulty(- 1); 00081 else if ( Selection == 3 ) 00082 bRandomOrder = !bRandomOrder; 00083 else if ( Selection == 5 ) 00084 DeathMatchGame(GameType).InitialBots = Max(0, DeathMatchGame(GameType).InitialBots - 1); 00085 else if ( Selection == 6 ) 00086 DeathMatchGame(GameType).bMultiPlayerBots = !DeathMatchGame(GameType).bMultiPlayerBots; 00087 else 00088 return false; 00089 00090 00091 return true; 00092 } 00093 00094 function bool ProcessRight() 00095 { 00096 if ( Selection == 1 ) 00097 bAdjustSkill = !bAdjustSkill; 00098 else if ( Selection == 2 ) 00099 AdjustDifficulty(1); 00100 else if ( Selection == 3 ) 00101 bRandomOrder = !bRandomOrder; 00102 else if ( Selection == 5 ) 00103 DeathMatchGame(GameType).InitialBots = Min(15, DeathMatchGame(GameType).InitialBots + 1); 00104 else if ( Selection == 6 ) 00105 DeathMatchGame(GameType).bMultiPlayerBots = !DeathMatchGame(GameType).bMultiPlayerBots; 00106 else 00107 return false; 00108 00109 return true; 00110 } 00111 00112 function bool ProcessSelection() 00113 { 00114 local Menu ChildMenu; 00115 00116 if ( Selection == 1 ) 00117 bAdjustSkill = !bAdjustSkill; 00118 else if ( Selection == 3 ) 00119 bRandomOrder = !bRandomOrder; 00120 else if ( Selection == 4 ) 00121 { 00122 ChildMenu = spawn(class'UnrealIndivBotMenu', owner); 00123 UnrealIndivBotMenu(ChildMenu).InitConfig(GameType); 00124 } 00125 else if ( Selection == 6 ) 00126 DeathMatchGame(GameType).bMultiPlayerBots = !DeathMatchGame(GameType).bMultiPlayerBots; 00127 else 00128 return false; 00129 00130 if ( ChildMenu != None ) 00131 { 00132 HUD(Owner).MainMenu = ChildMenu; 00133 ChildMenu.ParentMenu = self; 00134 ChildMenu.PlayerOwner = PlayerOwner; 00135 } 00136 return true; 00137 } 00138 00139 function SaveConfigs() 00140 { 00141 local BotInfo BotConfig; 00142 00143 if ( Level.Game.IsA('DeathMatchGame') ) 00144 { 00145 DeathMatchGame(Level.Game).BotConfig.bAdjustSkill = bAdjustSkill; 00146 DeathMatchGame(Level.Game).BotConfig.bRandomOrder = bRandomOrder; 00147 DeathMatchGame(Level.Game).BotConfig.Difficulty = Difficulty; 00148 } 00149 BotConfig = Spawn(DeathMatchGame(GameType).Default.BotConfigType); 00150 BotConfig.bAdjustSkill = bAdjustSkill; 00151 BotConfig.bRandomOrder = bRandomOrder; 00152 BotConfig.Difficulty = Difficulty; 00153 Level.Game.SaveConfig(); 00154 Level.Game.GameReplicationInfo.SaveConfig(); 00155 BotConfig.SaveConfig(); 00156 BotConfig.Destroy(); 00157 } 00158 00159 function DrawValues(canvas Canvas, Font RegFont, int Spacing, int StartX, int StartY) 00160 { 00161 local int i; 00162 00163 Canvas.Font = RegFont; 00164 for (i=0; i< MenuLength; i++ ) 00165 { 00166 SetFontBrightness( Canvas, (i == Selection - 1) ); 00167 Canvas.SetPos(StartX, StartY + Spacing * i); 00168 Canvas.DrawText(MenuValues[i + 1], false); 00169 } 00170 Canvas.DrawColor = Canvas.Default.DrawColor; 00171 } 00172 00173 function DrawMenu(canvas Canvas) 00174 { 00175 local DeathMatchGame DMGame; 00176 local int StartX, StartY, Spacing, i; 00177 local bool bFoundValue; 00178 00179 DMGame = DeathMatchGame(GameType); 00180 00181 DrawBackGround(Canvas, (Canvas.ClipY < 250) ); 00182 00183 // Draw Title 00184 DrawTitle(Canvas); 00185 00186 Spacing = Clamp(0.04 * Canvas.ClipY, 11, 32); 00187 StartX = Max(40, 0.5 * Canvas.ClipX - 120); 00188 StartY = Max(36, 0.5 * (Canvas.ClipY - MenuLength * Spacing - 128)); 00189 00190 // draw text 00191 DrawList(Canvas, false, Spacing, StartX, StartY); 00192 00193 MenuValues[1] = string(bAdjustSkill); 00194 MenuValues[2] = string(Difficulty); 00195 MenuValues[3] = string(bRandomOrder); 00196 MenuValues[5] = string(DMGame.InitialBots); 00197 MenuValues[6] = string(DMGame.bMultiPlayerBots); 00198 00199 DrawValues(Canvas, Canvas.MedFont, Spacing, StartX+160, StartY); 00200 00201 // Draw help panel 00202 DrawHelpPanel(Canvas, StartY + MenuLength * Spacing, 228); 00203 } 00204 00205 defaultproperties 00206 { 00207 MenuLength=6 00208 HelpMessage(1)="If true, bots adjust their skill level based on how they are doing against players." 00209 HelpMessage(2)="Base skill level of bots (between 0 and 3)." 00210 HelpMessage(3)="If true, bots enter the game in random order. If false, they enter in their configuration order." 00211 HelpMessage(4)="Change the configuration of individual bots." 00212 HelpMessage(5)="Number of bots to start play (max 15)." 00213 HelpMessage(6)="Use bots when playing with other people." 00214 MenuList(1)="Auto-Adjust Skills" 00215 MenuList(2)="Base Skill" 00216 MenuList(3)="Random Order" 00217 MenuList(4)="Configure Individual Bots" 00218 MenuList(5)="Number of Bots" 00219 MenuList(6)="Bots in Multiplayer" 00220 MenuTitle="BOTS" 00221 }