Core.Object | +--UWindow.UWindowBase | +--UWindow.UWindowWindow | +--UTMenu.NotifyWindow | +--UTMenu.SpeechWindow
SpeechButton
BottomButton
Texture
BottomTexture
Class
ButtonClass
int
CurrentType
float
FadeFactor
PlayerReplicationInfo
IdentifyTarget
NumOptions
OptionButtons[32]
string
Options[32]
SpeechWindow
SpeechChild
TopButton
TopTexture
WindowTitle
XOffset
bFadeIn,
bFadeOut
bSlideIn,
bSlideOut
byte
currentkey
void
BeforePaint(Canvas C, float X, float Y)
Created()
FadeIn()
FadeOut()
HideChildren()
Notify(UWindowWindow B, byte E)
SetButtonTextures(int i, optional bool, optional bool, optional bool)
SlideInWindow()
SlideOutWindow()
Tick(float Delta)
00001 class SpeechWindow extends NotifyWindow; 00002 00003 #exec TEXTURE IMPORT NAME=OrdersTop FILE=TEXTURES\Orders\OrdersTop.PCX GROUP=Skins MIPS=OFF 00004 #exec TEXTURE IMPORT NAME=OrdersTop2 FILE=TEXTURES\Orders\OrdersTop2.PCX GROUP=Skins MIPS=OFF 00005 #exec TEXTURE IMPORT NAME=OrdersMid FILE=TEXTURES\Orders\OrdersMid.PCX GROUP=Skins MIPS=OFF 00006 #exec TEXTURE IMPORT NAME=OrdersMidL FILE=TEXTURES\Orders\OrdersMidL.PCX GROUP=Skins MIPS=OFF 00007 #exec TEXTURE IMPORT NAME=OrdersMidLR FILE=TEXTURES\Orders\OrdersMidLR.PCX GROUP=Skins MIPS=OFF 00008 #exec TEXTURE IMPORT NAME=OrdersMidR FILE=TEXTURES\Orders\OrdersMidR.PCX GROUP=Skins MIPS=OFF 00009 #exec TEXTURE IMPORT NAME=OrdersBtm FILE=TEXTURES\Orders\OrdersBtm.PCX GROUP=Skins MIPS=OFF 00010 00011 #exec TEXTURE IMPORT NAME=OrdersTopArrow FILE=TEXTURES\Orders\OrdersTopArow.PCX GROUP=Skins MIPS=OFF 00012 #exec TEXTURE IMPORT NAME=OrdersBtmArrow FILE=TEXTURES\Orders\OrdersBtmArow.PCX GROUP=Skins MIPS=OFF 00013 00014 #exec AUDIO IMPORT NAME=SpeechWindowClick FILE=SOUNDS\click4.wav GROUP=SpeechWindow 00015 00016 // Top list of options. 00017 var SpeechButton TopButton; 00018 var SpeechButton OptionButtons[32]; 00019 var SpeechButton BottomButton; 00020 var localized string Options[32]; 00021 var int NumOptions; 00022 var Class<SpeechButton> ButtonClass; 00023 00024 // Voice information. 00025 var int CurrentType; 00026 00027 // Textures 00028 var texture TopTexture; 00029 var texture BottomTexture; 00030 00031 // XOffset 00032 var float XOffset; 00033 var bool bSlideIn, bSlideOut; 00034 00035 // Title 00036 var localized string WindowTitle; 00037 00038 // SpeechChildren 00039 var SpeechWindow SpeechChild; 00040 00041 var PlayerReplicationInfo IdentifyTarget; 00042 00043 // Fade control 00044 var float FadeFactor; 00045 var bool bFadeIn, bFadeOut; 00046 00047 // current key pressed for key based menu navigation 00048 var byte currentkey; 00049 00050 function Created() 00051 { 00052 local int W, H; 00053 local float XWidth, YHeight, XMod, YMod, XPos, YPos, YOffset, BottomTop; 00054 local color TextColor; 00055 local int i; 00056 00057 bAlwaysOnTop = True; 00058 bLeaveOnScreen = True; 00059 00060 Super.Created(); 00061 00062 W = Root.WinWidth / 4; 00063 H = W; 00064 00065 if(W > 256 || H > 256) 00066 { 00067 W = 256; 00068 H = 256; 00069 } 00070 00071 XMod = 4*W; 00072 YMod = 3*H; 00073 00074 WinTop = 0; 00075 WinLeft = 0; 00076 WinWidth = Root.WinWidth; 00077 WinHeight = Root.WinHeight; 00078 00079 TopButton = SpeechButton(CreateWindow(class'SpeechButton', 100, 100, 100, 100)); 00080 TopButton.NotifyWindow = Self; 00081 TopButton.Text = WindowTitle; 00082 TopButton.MyFont = class'UTLadderStub'.Static.GetStubClass().Static.GetBigFont(Root); 00083 TopButton.TextColor.R = 255; 00084 TopButton.TextColor.G = 255; 00085 TopButton.TextColor.B = 255; 00086 TopButton.XOffset = 20.0/1024.0 * XMod; 00087 TopButton.FadeFactor = 1.0; 00088 TopButton.bDisabled = True; 00089 TopButton.DisabledTexture = TopTexture; 00090 TopButton.bStretched = True; 00091 for (i=0; i<NumOptions; i++) 00092 { 00093 OptionButtons[i] = SpeechButton(CreateWindow(ButtonClass, 100, 100, 100, 100)); 00094 OptionButtons[i].NotifyWindow = Self; 00095 OptionButtons[i].Text = Options[i]; 00096 OptionButtons[i].MyFont = class'UTLadderStub'.Static.GetStubClass().Static.GetBigFont(Root); 00097 OptionButtons[i].bLeftJustify = True; 00098 OptionButtons[i].TextColor.R = 255; 00099 OptionButtons[i].TextColor.G = 255; 00100 OptionButtons[i].TextColor.B = 255; 00101 OptionButtons[i].XOffset = 20.0/1024.0 * XMod; 00102 OptionButtons[i].FadeFactor = 1.0; 00103 OptionButtons[i].bHighlightButton = True; 00104 OptionButtons[i].OverTexture = texture'OrdersMid'; 00105 OptionButtons[i].UpTexture = texture'OrdersMid'; 00106 OptionButtons[i].DownTexture = texture'OrdersMid'; 00107 OptionButtons[i].Type = i; 00108 OptionButtons[i].bStretched = True; 00109 } 00110 BottomButton = SpeechButton(CreateWindow(class'SpeechButton', 100, 100, 100, 100)); 00111 BottomButton.NotifyWindow = Self; 00112 BottomButton.MyFont = class'UTLadderStub'.Static.GetStubClass().Static.GetBigFont(Root); 00113 BottomButton.TextColor.R = 255; 00114 BottomButton.TextColor.G = 255; 00115 BottomButton.TextColor.B = 255; 00116 BottomButton.XOffset = 20.0/1024.0 * XMod; 00117 BottomButton.FadeFactor = 1.0; 00118 BottomButton.bDisabled = True; 00119 BottomButton.DisabledTexture = BottomTexture; 00120 BottomButton.bStretched = True; 00121 } 00122 00123 function BeforePaint(Canvas C, float X, float Y) 00124 { 00125 local int W, H; 00126 local float XWidth, YHeight, XMod, YMod, XPos, YPos, YOffset, BottomTop, XL, YL; 00127 local color TextColor; 00128 local int i; 00129 00130 Super.BeforePaint(C, X, Y); 00131 00132 W = Root.WinWidth / 4; 00133 H = W; 00134 00135 if(W > 256 || H > 256) 00136 { 00137 W = 256; 00138 H = 256; 00139 } 00140 00141 XMod = 4*W; 00142 YMod = 3*H; 00143 00144 WinTop = 0; 00145 WinLeft = 0; 00146 WinWidth = Root.WinWidth; 00147 WinHeight = Root.WinHeight; 00148 00149 XWidth = 256.0/1024.0 * XMod; 00150 YHeight = 32.0/768.0 * YMod; 00151 YPos = 164.0/768.0 * YMod; 00152 TopButton.SetSize(XWidth, YHeight); 00153 TopButton.XOffset = 20.0/1024.0 * XMod; 00154 TopButton.WinLeft = XOffset; 00155 TopButton.WinTop = YPos; 00156 TopButton.MyFont = class'UTLadderStub'.Static.GetStubClass().Static.GetBigFont(Root); 00157 for(i=0; i<NumOptions; i++) 00158 { 00159 OptionButtons[i].SetSize(XWidth, YHeight); 00160 OptionButtons[i].XOffset = 20.0/1024.0 * XMod; 00161 OptionButtons[i].WinLeft = XOffset; 00162 OptionButtons[i].WinTop = YPos + (32.0/768.0*YMod)*(i+1); 00163 OptionButtons[i].MyFont = class'UTLadderStub'.Static.GetStubClass().Static.GetBigFont(Root); 00164 } 00165 BottomButton.SetSize(XWidth, YHeight); 00166 BottomButton.XOffset = 20.0/1024.0 * XMod; 00167 BottomButton.WinLeft = XOffset; 00168 BottomButton.WinTop = YPos + (32.0/768.0*YMod)*(NumOptions+1); 00169 BottomButton.MyFont = class'UTLadderStub'.Static.GetStubClass().Static.GetBigFont(Root); 00170 } 00171 00172 function SlideOutWindow() 00173 { 00174 SetButtonTextures(-1, False, False); 00175 XOffset = 0; 00176 bSlideOut = True; 00177 bSlideIn = False; 00178 if (SpeechChild != None) 00179 SpeechChild.FadeOut(); 00180 SpeechChild = None; 00181 CurrentKey = -1; 00182 } 00183 00184 function SlideInWindow() 00185 { 00186 local int W, H; 00187 local float XWidth, YHeight, XMod, YMod, XPos, YPos, YOffset, BottomTop; 00188 local color TextColor; 00189 local int i; 00190 00191 W = Root.WinWidth / 4; 00192 H = W; 00193 00194 if(W > 256 || H > 256) 00195 { 00196 W = 256; 00197 H = 256; 00198 } 00199 00200 XMod = 4*W; 00201 YMod = 3*H; 00202 00203 XOffset = -256.0/1024.0 * XMod; 00204 bSlideIn = True; 00205 bSlideOut = False; 00206 ShowWindow(); 00207 00208 IdentifyTarget = None; 00209 NumOptions = Default.NumOptions - 1; 00210 OptionButtons[NumOptions].HideWindow(); 00211 if (GetPlayerOwner().MyHUD.IsA('ChallengeHUD')) 00212 { 00213 if (( ChallengeHUD(GetPlayerOwner().MyHUD).IdentifyTarget != None ) && 00214 ( ChallengeHUD(GetPlayerOwner().MyHUD).IdentifyTarget.Team == GetPlayerOwner().PlayerReplicationInfo.Team ) && 00215 ( ChallengeHUD(GetPlayerOwner().MyHUD).IdentifyFadeTime > 2.0 )) 00216 { 00217 IdentifyTarget = ChallengeHUD(GetPlayerOwner().MyHUD).IdentifyTarget; 00218 NumOptions = Default.NumOptions; 00219 OptionButtons[Default.NumOptions - 1].ShowWindow(); 00220 } 00221 } 00222 } 00223 00224 function FadeIn() 00225 { 00226 FadeFactor = 0; 00227 bFadeIn = True; 00228 } 00229 00230 function FadeOut() 00231 { 00232 FadeFactor = 100; 00233 bFadeOut = True; 00234 SetButtonTextures(-1, False, False); 00235 SpeechChild = None; 00236 CurrentKey = -1; 00237 } 00238 00239 function Tick(float Delta) 00240 { 00241 local int W, H; 00242 local float XWidth, YHeight, XMod, YMod, XPos, YPos, YOffset, BottomTop; 00243 local color TextColor; 00244 local int i; 00245 00246 W = Root.WinWidth / 4; 00247 H = W; 00248 00249 if(W > 256 || H > 256) 00250 { 00251 W = 256; 00252 H = 256; 00253 } 00254 00255 XMod = 4*W; 00256 YMod = 3*H; 00257 00258 if (bSlideIn) 00259 { 00260 XOffset += Delta*800; 00261 if (XOffset >= 0) 00262 { 00263 XOffset = 0; 00264 bSlideIn = False; 00265 } 00266 } 00267 00268 if (bSlideOut) 00269 { 00270 XOffset -= Delta*800; 00271 if (XOffset <= -256.0/1024.0 * XMod) 00272 { 00273 XOffset = -256.0/1024.0 * XMod; 00274 bSlideOut = False; 00275 if (NextSiblingWindow == None) 00276 { 00277 HideWindow(); 00278 Root.Console.CloseUWindow(); 00279 Root.Console.bQuickKeyEnable = False; 00280 } 00281 else 00282 HideWindow(); 00283 } 00284 } 00285 00286 if (bFadeIn) 00287 { 00288 FadeFactor += Delta * 700; 00289 if (FadeFactor > 100) 00290 { 00291 FadeFactor = 100; 00292 bFadeIn = False; 00293 } 00294 } 00295 00296 if (bFadeOut) 00297 { 00298 FadeFactor -= Delta * 700; 00299 if (FadeFactor <= 0) 00300 { 00301 FadeFactor = 0; 00302 bFadeOut = False; 00303 HideWindow(); 00304 00305 } 00306 } 00307 } 00308 00309 event bool KeyEvent( byte Key, byte Action, FLOAT Delta ) 00310 { 00311 local byte B; 00312 00313 if ( CurrentKey == Key ) 00314 { 00315 if ( Action == 3 ) // IST_Release 00316 CurrentKey = -1; 00317 return false; 00318 } 00319 00320 if ( SpeechChild != None ) 00321 return SpeechChild.KeyEvent(Key, Action, Delta); 00322 00323 if ( Key == 38 ) 00324 { 00325 CurrentKey = Key; 00326 Notify( TopButton, DE_Click ); 00327 return true; 00328 } 00329 00330 if ( Key == 40 ) 00331 { 00332 CurrentKey = Key; 00333 Notify( BottomButton, DE_Click ); 00334 return true; 00335 } 00336 00337 B = Key - 48; 00338 if ( B == 0 ) 00339 B = 9; 00340 else 00341 B -= 1; 00342 if ( (B>=0) && (B<10) ) 00343 { 00344 CurrentKey = Key; 00345 Notify( OptionButtons[B], DE_Click ); 00346 return true; 00347 } 00348 00349 return false; 00350 } 00351 00352 function Notify(UWindowWindow B, byte E) 00353 { 00354 local int W, H; 00355 local float XWidth, YHeight, XMod, YMod, XPos, YPos, YOffset, BottomTop; 00356 local color TextColor; 00357 local int i; 00358 00359 W = Root.WinWidth / 4; 00360 H = W; 00361 00362 if(W > 256 || H > 256) 00363 { 00364 W = 256; 00365 H = 256; 00366 } 00367 00368 XMod = 4*W; 00369 YMod = 3*H; 00370 00371 switch (E) 00372 { 00373 case DE_Click: 00374 GetPlayerOwner().PlaySound(sound'SpeechWindowClick', SLOT_Interact); 00375 switch (B) 00376 { 00377 case OptionButtons[0]: 00378 case OptionButtons[1]: 00379 case OptionButtons[3]: 00380 case OptionButtons[4]: 00381 SetButtonTextures(SpeechButton(B).Type, False, True); 00382 HideChildren(); 00383 CurrentType = SpeechButton(B).Type; 00384 SpeechChild = SpeechWindow(CreateWindow(class'SpeechChildWindow', 100, 100, 100, 100)); 00385 SpeechChild.FadeIn(); 00386 break; 00387 case OptionButtons[2]: 00388 case OptionButtons[6]: 00389 SetButtonTextures(SpeechButton(B).Type, False, True); 00390 HideChildren(); 00391 CurrentType = SpeechButton(B).Type; 00392 SpeechChild = SpeechWindow(CreateWindow(class'OrdersChildWindow', 100, 100, 100, 100)); 00393 SpeechChild.FadeIn(); 00394 OrdersChildWindow(SpeechChild).TargetPRI = IdentifyTarget; 00395 break; 00396 case OptionButtons[5]: 00397 SetButtonTextures(SpeechButton(B).Type, False, True); 00398 HideChildren(); 00399 CurrentType = SpeechButton(B).Type; 00400 SpeechChild = SpeechWindow(CreateWindow(class'PhysicalChildWindow', 100, 100, 100, 100)); 00401 SpeechChild.FadeIn(); 00402 break; 00403 } 00404 break; 00405 } 00406 } 00407 00408 function HideChildren() 00409 { 00410 if (SpeechChild != None) 00411 SpeechChild.HideWindow(); 00412 } 00413 00414 function SetButtonTextures(int i, optional bool bLeft, optional bool bRight, optional bool bPreserve) 00415 { 00416 local int j; 00417 00418 for (j=0; j<NumOptions; j++) 00419 { 00420 if (j == i) 00421 { 00422 if (bLeft && bRight) 00423 { 00424 OptionButtons[j].OverTexture = texture'OrdersMidLR'; 00425 OptionButtons[j].UpTexture = texture'OrdersMidLR'; 00426 OptionButtons[j].DownTexture = texture'OrdersMidLR'; 00427 } else if (bRight) { 00428 OptionButtons[j].OverTexture = texture'OrdersMidR'; 00429 OptionButtons[j].UpTexture = texture'OrdersMidR'; 00430 OptionButtons[j].DownTexture = texture'OrdersMidR'; 00431 } else if (bLeft) { 00432 OptionButtons[j].OverTexture = texture'OrdersMidL'; 00433 OptionButtons[j].UpTexture = texture'OrdersMidL'; 00434 OptionButtons[j].DownTexture = texture'OrdersMidL'; 00435 } 00436 } else { 00437 if (bPreserve && j == 0) 00438 { 00439 // Do nothing. 00440 } else { 00441 OptionButtons[j].OverTexture = texture'OrdersMid'; 00442 OptionButtons[j].UpTexture = texture'OrdersMid'; 00443 OptionButtons[j].DownTexture = texture'OrdersMid'; 00444 } 00445 } 00446 } 00447 } 00448 00449 defaultproperties 00450 { 00451 Options(0)="Acknowledge" 00452 Options(1)="Friendly Fire" 00453 Options(2)="Orders" 00454 Options(3)="Taunts" 00455 Options(4)="Other/Misc" 00456 Options(5)="Gesture" 00457 Options(6)="Order This Bot" 00458 NumOptions=7 00459 ButtonClass=Class'UTMenu.SpeechButton' 00460 TopTexture=Texture'UTMenu.Skins.OrdersTop' 00461 BottomTexture=Texture'UTMenu.Skins.OrdersBtm' 00462 WindowTitle="Orders" 00463 }