Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 |
// ============================================================================ // JBInteractionKeys // Copyright 2004 by Mychaeel <mychaeel@planetjailbreak.com> // $Id: JBInteractionKeys.uc,v 1.12 2007-04-29 13:49:06 jrubzjeknf Exp $ // // Temporarily assigns keys which have not been bound by the user. // ============================================================================ class JBInteractionKeys extends Interaction config; // ============================================================================ // Types // ============================================================================ struct TBinding { var string Alias; // alias to auto-bind if necessary var byte iKeyPreferred; // preferred key to auto-bind var private bool bIsBoundAuto; // alias has been auto-bound var private bool bIsBoundConfig; // alias bound by configuration var private int iKeyAuto; // index of auto-bound key }; struct TDialog { var Material MaterialFrame; // dialog box frame and background var vector Margins; // margins within dialog box frame var string FontTitle; // font for dialog box title var string FontText; // font for text in dialog box var string FontKey; // font for key names var string FontClose; // font for closing hint var Color ColorTextTitle; // color for dialog box title var Color ColorTextKey; // color for key names var Color ColorText; // color for text in dialog box var Color ColorTextClose; // color for closing hint var vector OffsetTextTitle; // offset dialog title from top var vector OffsetTextClose; // offset closing hint from bottom var private GUIFont GUIFontTitle; // loaded font for title var private GUIFont GUIFontKey; // loaded font for key names var private GUIFont GUIFontText; // loaded font for text var private GUIFont GUIFontClose; // loaded font for closing hint }; // ============================================================================ // Configuration // ============================================================================ var config string AutoBoundKeys; // last known auto-bound keys // ============================================================================ // Localization // ============================================================================ var localized string TextDialogTitle; // title at top of dialog box var localized string TextDialogTopS; // first line in dialog box (sing) var localized string TextDialogTopP; // first line in dialog box (plur) var localized string TextDialogBottomS; // last line in dialog box (sing) var localized string TextDialogBottomP; // last line in dialog box (plur) var localized string TextDialogClose; // hint at bottom of dialog box var localized array<string> TextDescription; // key binding descriptions // ============================================================================ // Variables // ============================================================================ var array<TBinding> Bindings; // temporary key bindings var private int iBindingByKey[256]; // index of auto-binding, by key var TDialog Dialog; // dialog box layout var private float TimeFadeoutDialog; // fadeout start time for dialog var private byte bIsBoundToPrevWeapon[256]; // key is bound to PrevWeapon var private byte bIsBoundToNextWeapon[256]; // key is bound to NextWeapon // ============================================================================ // Initialized // // Checks which of the required aliases are bound already and finds temporary // assignments for those which are not. // ============================================================================ event Initialized() { local bool bAutoBoundKeys; local byte bIsKeyBound [256]; local byte bIsKeyUnknown[256]; local int iBinding; local int iKey; local int iKeyAuto; local string Alias; local string Key; for (iKey = 0; iKey < EInputKey.EnumCount; iKey++) { iBindingByKey[iKey] = -1; Key = ViewportOwner.Actor.ConsoleCommand("KeyName" @ iKey); Alias = ViewportOwner.Actor.ConsoleCommand("KeyBinding" @ Key); bIsKeyUnknown[iKey] = byte(Left(Key, 7) ~= "Unknown"); if (Alias != "") { bIsKeyBound[iKey] = byte(True); for (iBinding = 0; iBinding < Bindings.Length; iBinding++) if (InStr(Caps(Alias), Caps(Bindings[iBinding].Alias)) >= 0) Bindings[iBinding].bIsBoundConfig = True; if (InStr(Caps(Alias), Caps("PrevWeapon")) >= 0) bIsBoundToPrevWeapon[iKey] = byte(True); if (InStr(Caps(Alias), Caps("NextWeapon")) >= 0) bIsBoundToNextWeapon[iKey] = byte(True); } } bIsKeyUnknown[EInputKey.IK_Select ] = byte(True); bIsKeyUnknown[EInputKey.IK_Print ] = byte(True); bIsKeyUnknown[EInputKey.IK_Execute ] = byte(True); bIsKeyUnknown[EInputKey.IK_PrintScrn] = byte(True); bIsKeyUnknown[EInputKey.IK_Help ] = byte(True); bIsKeyUnknown[EInputKey.IK_Separator] = byte(True); for (iBinding = 0; iBinding < Bindings.Length; iBinding++) { if (Bindings[iBinding].bIsBoundConfig) continue; iKeyAuto = Bindings[iBinding].iKeyPreferred; if (bool(bIsKeyBound[iKeyAuto])) for (iKeyAuto = EInputKey.IK_Escape; iKeyAuto <= EInputKey.IK_F12; iKeyAuto++) if (!bool(bIsKeyBound [iKeyAuto]) && !bool(bIsKeyUnknown[iKeyAuto])) break; if (iKeyAuto >= EInputKey.EnumCount) continue; // no unbound key found bAutoBoundKeys = True; iBindingByKey[iKeyAuto] = iBinding; Bindings[iBinding].bIsBoundAuto = True; Bindings[iBinding].iKeyAuto = iKeyAuto; bIsKeyBound[iKeyAuto] = byte(True); } if (bAutoBoundKeys) { Log("Auto-bound keys:"); for (iBinding = 0; iBinding < Bindings.Length; iBinding++) if (Bindings[iBinding].bIsBoundAuto) Log("Temporarily bound" @ GetKeyForCommand(Bindings[iBinding].Alias) @ "to '" $ Bindings[iBinding].Alias $ "'"); bVisible = (GetAutoBoundKeys() != AutoBoundKeys); } } // ============================================================================ // GetAutoBoundKeys // // Returns a string containing a list of current auto key bindings. // ============================================================================ function string GetAutoBoundKeys() { local int iBinding; local string Result; for (iBinding = 0; iBinding < Bindings.Length; iBinding++) if (Bindings[iBinding].bIsBoundAuto) Result = Result $ GetEnum(Enum'EInputKey', Bindings[iBinding].iKeyAuto) $ ","; else Result = Result $ "None,"; if (Len(Result) > 0) Result = Left(Result, Len(Result) - 1); return Result; } // ============================================================================ // KeyEvent // // Checks whether the entered key has been auto-assigned and executes the // attached console command, if so. If a key bound to PrevWeapon or NextWeapon // is pressed and the player is using a camera, passes those events to it. // ============================================================================ event bool KeyEvent(out EInputKey InputKey, out EInputAction InputAction, float Delta) { local bool bPressedAltFire; local bool bPressedFire; local int iBinding; local string Alias; local string Key; local PlayerController PlayerController; local JBCamera Camera; if (InputAction != IST_Press) return False; PlayerController = ViewportOwner.Actor; iBinding = iBindingByKey[InputKey]; if (iBinding >= 0) { Key = PlayerController.ConsoleCommand("KeyName" @ InputKey); Alias = PlayerController.ConsoleCommand("KeyBinding" @ Key); if (Alias != "") return False; return ConsoleCommand(Bindings[iBinding].Alias); } if (PlayerController.Pawn == None) { Camera = JBCamera(PlayerController.ViewTarget); if (Camera != None && Camera.Switching.bAllowManual) { if (bool(bIsBoundToPrevWeapon[InputKey])) { GetTagClientLocal().ServerSwitchToPrevCamera(Camera, True); return True; } if (bool(bIsBoundToNextWeapon[InputKey])) { GetTagClientLocal().ServerSwitchToNextCamera(Camera, True); return True; } } } if (bVisible && TimeFadeoutDialog == 0.0) { Key = PlayerController.ConsoleCommand("KeyName" @ InputKey); Alias = Caps(PlayerController.ConsoleCommand("KeyBinding" @ Key)); bPressedAltFire = (InStr(Alias, "ALTFIRE") >= 0); bPressedFire = (InStr(Alias, "FIRE") >= 0 && !bPressedAltFire); if (bPressedAltFire) AutoBoundKeys = GetAutoBoundKeys(); else AutoBoundKeys = ""; SaveConfig(); if (bPressedAltFire || bPressedFire) { TimeFadeoutDialog = PlayerController.Level.TimeSeconds; return True; } } return False; } // ============================================================================ // GetTagClientLocal // // Returns a reference to the JBTagClient actor of the local player. // ============================================================================ function JBTagClient GetTagClientLocal() { return Class'JBTagClient'.Static.FindFor(ViewportOwner.Actor); } // ============================================================================ // PostRender // // Draws the list of automatically assigned key bindings on the screen. // ============================================================================ event PostRender(Canvas Canvas) { local int iBinding; local int nBindings; local float Alpha; local float TimeCurrent; local vector LocationDialog; local vector LocationText; local vector SizeDialog; local vector SizeText; local vector SizeTextMax; local vector SizeTextKey; local vector SizeTextKeyMax; local vector Spacing; local string TextDialogTop; local string TextDialogBottom; local array<string> Key; local Font FontTitle; local Font FontText; local Font FontKey; local Font FontClose; local GUIController GUIController; local PlayerController PlayerController; PlayerController = ViewportOwner.Actor; GUIController = GUIController(ViewportOwner.GUIController); if (PlayerController.myHUD.bShowScoreBoard) return; TimeCurrent = PlayerController.Level.TimeSeconds; if (TimeFadeoutDialog == 0.0) Alpha = 1.0; else Alpha = FMax(0.0, 1.0 - (TimeCurrent - TimeFadeoutDialog) * 2.0); if (Alpha == 0.0) { bVisible = False; return; } if (Dialog.GUIFontTitle == None) Dialog.GUIFontTitle = GUIController.GetMenuFont(Dialog.FontTitle); if (Dialog.GUIFontText == None) Dialog.GUIFontText = GUIController.GetMenuFont(Dialog.FontText); if (Dialog.GUIFontKey == None) Dialog.GUIFontKey = GUIController.GetMenuFont(Dialog.FontKey); if (Dialog.GUIFontClose == None) Dialog.GUIFontClose = GUIController.GetMenuFont(Dialog.FontClose); FontTitle = Dialog.GUIFontTitle.GetFont(Canvas.ClipX); FontText = Dialog.GUIFontText .GetFont(Canvas.ClipX); FontKey = Dialog.GUIFontKey .GetFont(Canvas.ClipX); FontClose = Dialog.GUIFontClose.GetFont(Canvas.ClipX); for (iBinding = 0; iBinding < Bindings.Length; iBinding++) { if (!Bindings[iBinding].bIsBoundAuto) continue; Key[iBinding] = PlayerController.ConsoleCommand("LocalizedKeyName" @ Bindings[iBinding].iKeyAuto); Canvas.Font = FontText; Canvas.TextSize(TextDescription[iBinding], SizeText .X, SizeText .Y); Canvas.Font = FontKey; Canvas.TextSize(Key [iBinding], SizeTextKey.X, SizeTextKey.Y); if (SizeText .X > SizeTextMax .X) SizeTextMax .X = SizeText .X; if (SizeTextKey.X > SizeTextKeyMax.X) SizeTextKeyMax.X = SizeTextKey.X; nBindings += 1; } Spacing.X = SizeText.Y * 1.5; Spacing.Y = SizeText.Y; SizeDialog.X = Spacing.X + SizeTextKeyMax.X + Spacing.X + SizeTextMax.X; SizeDialog.Y = SizeText.Y + Spacing.Y + SizeText.Y * nBindings + Spacing.Y + SizeText.Y; if (nBindings == 1) { TextDialogTop = TextDialogTopS; TextDialogBottom = TextDialogBottomS; } else { TextDialogTop = TextDialogTopP; TextDialogBottom = TextDialogBottomP; } Canvas.Font = FontText; Canvas.TextSize(TextDialogTop, SizeText.X, SizeText.Y); if (SizeText.X > SizeDialog.X) SizeDialog.X = SizeText.X; Canvas.TextSize(TextDialogBottom, SizeText.X, SizeText.Y); if (SizeText.X > SizeDialog.X) SizeDialog.X = SizeText.X; SizeDialog += Dialog.Margins * 2; SizeDialog.Y *= 0.5 + Alpha * 0.5; LocationDialog.X = int((Canvas.ClipX - SizeDialog.X) / 2); LocationDialog.Y = int((Canvas.ClipY - SizeDialog.Y) / 2); Canvas.Style = 5; // ERenderStyle.STY_Alpha; Canvas.DrawColor = Canvas.MakeColor(255, 255, 255); Canvas.DrawColor.A = 255 * Alpha; Canvas.SetPos( LocationDialog.X, LocationDialog.Y); Canvas.DrawTileStretched( Dialog.MaterialFrame, SizeDialog.X, SizeDialog.Y); LocationText = LocationDialog + Dialog.Margins; Dialog.ColorText .A = Canvas.DrawColor.A; Dialog.ColorTextTitle.A = Canvas.DrawColor.A; Dialog.ColorTextKey .A = Canvas.DrawColor.A; Dialog.ColorTextClose.A = Canvas.DrawColor.A; Canvas.SetClip( LocationDialog.X + SizeDialog.X - Dialog.Margins.X, LocationDialog.Y + SizeDialog.Y - Dialog.Margins.Y); Canvas.Font = FontTitle; Canvas.DrawColor = Dialog.ColorTextTitle; Canvas.DrawScreenText( TextDialogTitle, (LocationDialog.X + SizeDialog.X / 2.0 + Dialog.OffsetTextTitle.X) / Canvas.SizeX, (LocationDialog.Y + Dialog.OffsetTextTitle.Y) / Canvas.SizeY, DP_MiddleMiddle); Canvas.Font = FontText; Canvas.DrawColor = Dialog.ColorText; Canvas.SetPos( LocationText.X, LocationText.Y); Canvas.DrawTextClipped(TextDialogTop); LocationText.Y += SizeText.Y + Spacing.Y; for (iBinding = 0; iBinding < Bindings.Length; iBinding++) { if (!Bindings[iBinding].bIsBoundAuto) continue; Canvas.Font = FontKey; Canvas.DrawColor = Dialog.ColorTextKey; Canvas.SetPos( LocationText.X + Spacing.X, LocationText.Y); Canvas.DrawTextClipped(Key[iBinding]); Canvas.Font = FontText; Canvas.DrawColor = Dialog.ColorText; Canvas.SetPos( LocationText.X + Spacing.X + SizeTextKeyMax.X + Spacing.X, LocationText.Y); Canvas.DrawTextClipped(TextDescription[iBinding]); LocationText.Y += SizeText.Y; } Canvas.SetPos( LocationText.X, LocationText.Y + Spacing.Y); Canvas.DrawTextClipped(TextDialogBottom); Canvas.SetClip( Canvas.SizeX, Canvas.SizeY); Canvas.Font = FontClose; Canvas.DrawColor = Dialog.ColorTextClose; Canvas.DrawScreenText( TextDialogClose, (LocationDialog.X + SizeDialog.X / 2.0 + Dialog.OffsetTextClose.X) / Canvas.SizeX, (LocationDialog.Y + SizeDialog.Y + Dialog.OffsetTextClose.Y) / Canvas.SizeY, DP_MiddleMiddle); } // ============================================================================ // NotifyLevelChange // // Removes this Interaction before level change. Calls NotifyLevelChange in // all JBAddon actors which are around. // ============================================================================ event NotifyLevelChange() { local JBAddon thisAddon; Master.RemoveInteraction(Self); foreach ViewportOwner.Actor.DynamicActors(Class'JBAddon', thisAddon) thisAddon.NotifyLevelChange(); } // ============================================================================ // GetKeyForCommand // // Returns the name of the key bound to the given command. Partial commands // match. Prefers actual keys over mouse commands over joystick commands. // Returns an the fallback string if no match is found. // ============================================================================ static function string GetKeyForCommand(string Command, optional string Fallback) { local int iBinding; local int iKey; local int RatingKey; local int RatingKeyBest; local string Alias; local string Key; local string KeyBest; local PlayerController PlayerController; local JBInteractionKeys InteractionKeys; foreach Default.Class.AllObjects(Class'JBInteractionKeys', InteractionKeys) break; if (InteractionKeys == None) return Fallback; PlayerController = InteractionKeys.ViewportOwner.Actor; for (iBinding = 0; iBinding < InteractionKeys.Bindings.Length; iBinding++) if (InteractionKeys.Bindings[iBinding].Alias ~= Command && InteractionKeys.Bindings[iBinding].bIsBoundAuto) return PlayerController.ConsoleCommand("LocalizedKeyName" @ InteractionKeys.Bindings[iBinding].iKeyAuto); for (iKey = 0; iKey < EInputKey.EnumCount; iKey++) { Key = PlayerController.ConsoleCommand("KeyName" @ iKey); Alias = PlayerController.ConsoleCommand("KeyBinding" @ Key); if (InStr(Caps(Alias), Caps(Command)) < 0) continue; if (Left(Key, 3) ~= "Joy") RatingKey = 1; else if (Left(Key, 5) ~= "Mouse") RatingKey = 2; else RatingKey = 3; if (RatingKey > RatingKeyBest) { KeyBest = PlayerController.ConsoleCommand("LocalizedKeyName" @ iKey); RatingKeyBest = RatingKey; } } if (KeyBest != "") return KeyBest; return Fallback; } // ============================================================================ // Defaults // ============================================================================ defaultproperties { Bindings[0] = (Alias="TeamTactics Up",iKeyPreferred=107); // GreyPlus Bindings[1] = (Alias="TeamTactics Down",iKeyPreferred=109); // GreyMinus Bindings[2] = (Alias="TeamTactics Auto",iKeyPreferred=111); // GreySlash Bindings[3] = (Alias="ArenaCam",iKeyPreferred=106); // GreyStar Bindings[4] = (Alias="ViewTeamFree",iKeyPreferred=110); // NumPadPeriod Dialog = (MaterialFrame=Texture'2K4Menus.Display99',Margins=(X=30,Y=44),FontTitle="UT2DefaultFont",FontText="UT2SmallFont",FontKey="UT2SmallFont",FontClose="UT2SmallFont",ColorTextTitle=(R=255,G=210,B=0),ColorText=(R=255,G=255,B=255),ColorTextKey=(R=255,G=210,B=0),ColorTextClose=(R=255,G=210,B=0),OffsetTextTitle=(Y=16),OffsetTextClose=(Y=-16)); TextDialogTitle = "Temporary Key Bindings"; TextDialogTopS = "Jailbreak has temporarily bound the following key for you:"; TextDialogTopP = "Jailbreak has temporarily bound the following keys for you:"; TextDialogBottomS = "Use the key binder to permanently bind a key to this function."; TextDialogBottomP = "Use the key binder to permanently bind keys to these functions."; TextDialogClose = "Press FIRE to close, ALT-FIRE to close permanently"; TextDescription[0] = "Sets team tactics to a more aggressive stance."; TextDescription[1] = "Sets team tactics to a more defensive stance."; TextDescription[2] = "Returns to auto-selection of team tactics."; TextDescription[3] = "Activates the Arena Live Feed."; TextDescription[4] = "View your teammates who battle in freedom."; } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |