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 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 00577 00578 00579 00580 00581 00582 00583 00584 00585 00586 00587 00588 00589 00590 00591 00592 00593 00594 00595 00596 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 00610 00611 00612 00613 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 00639 00640 00641 00642 00643 00644 00645 00646 00647 00648 00649 00650 00651 00652 00653 00654 00655 00656 00657 00658 00659 00660 00661 00662 00663 00664 |
/** * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. * * Tab page to let user's select which mutators to use. */ class UTUITabPage_Mutators extends UTTabPage placeable; /** List of available mutators. */ var transient UIList AvailableList; var transient UIImage ListBackground_Available; /** List of enabled mutators. */ var transient UIList EnabledList; var transient UIImage ListBackground_Enabled; /** The last list that was focused. */ var transient UIList LastFocusedList; /** Label describing the currently selected mutator. */ var transient UILabel DescriptionLabel; /** Arrow images. */ var transient UIImage ShiftRightImage; var transient UIImage ShiftLeftImage; /** Reference to the menu datastore */ var transient UTUIDataStore_MenuItems MenuDataStore; const MANUAL_LIST_REFRESH_DATABINDING_INDEX=50; /** Callback for when the user decides to accept the current set of mutators. */ delegate OnAcceptMutators(string InEnabledMutators); /** Post initialization event - Setup widget delegates.*/ event PostInitialize() { Super.PostInitialize(); // Store widget references AvailableList = UIList(FindChild('lstAvailable', true)); AvailableList.OnValueChanged = None; AvailableList.OnSubmitSelection = None; AvailableList.NotifyActiveStateChanged = OnList_NotifyActiveStateChanged; AvailableList.OnRawInputKey=None; AvailableList.OnRefreshSubscriberValue = None; EnabledList = UIList(FindChild('lstEnabled', true)); EnabledList.OnValueChanged = None; EnabledList.OnSubmitSelection = None; EnabledList.NotifyActiveStateChanged = OnList_NotifyActiveStateChanged; EnabledList.OnRawInputKey=None; EnabledList.OnRefreshSubscriberValue = None; DescriptionLabel = UILabel(FindChild('lblDescription', true)); ShiftRightImage = UIImage(FindChild('imgArrowLeft', true)); ShiftLeftImage = UIImage(FindChild('imgArrowRight', true)); ListBackground_Available = UIImage(FindChild('imgAvailable', true)); ListBackground_Enabled = UIImage(FindChild('imgEnabled', true)); // Get reference to the menu datastore MenuDataStore = UTUIDataStore_MenuItems(GetCurrentUIController().DataStoreManager.FindDataStore('UTMenuItems')); // Set default focused list LastFocusedList = AvailableList; // Set the button tab caption. SetDataStoreBinding("<Strings:UTGameUI.FrontEnd.TabCaption_Mutators>"); } /** * Called when this widget receives a call to RefreshSubscriberValue. * * @param BindingIndex optional parameter for indicating which data store binding is being refreshed, for those * objects which have multiple data store bindings. How this parameter is used is up to the * class which implements this interface, but typically the "primary" data store will be index 0, * while values greater than FIRST_DEFAULT_DATABINDING_INDEX correspond to tooltips and context * menus. * * @return TRUE to indicate that this widget is going to refresh its value manually. */ function bool HandleRefreshSubscriberValue( UIObject Sender, int BindingIndex ) { if ( BindingIndex < FIRST_DEFAULT_DATABINDING_INDEX && Sender.IsInitialized() ) { if ( BindingIndex != MANUAL_LIST_REFRESH_DATABINDING_INDEX && Sender != EnabledList ) { OnMutatorListChanged(); return true; } } return false; } /** Sets up the button bar for the parent scene. */ function SetupButtonBar(UTUIButtonBar ButtonBar) { if(IsVisible()) { ButtonBar.SetButton(1,"<Strings:UTGameUI.ButtonCallouts.Next>", OnButtonBar_Next); if(EnabledList.IsFocused()) { ButtonBar.SetButton(2,"<Strings:UTGameUI.ButtonCallouts.RemoveMutator>", OnButtonBar_RemoveMutator); } else { ButtonBar.SetButton(2,"<Strings:UTGameUI.ButtonCallouts.AddMutator>", OnButtonBar_AddMutator); } // Only set the configure button if they are able to configure the currently selected mutator. ButtonBar.ClearButton(3); if(EnabledList.IsFocused() && IsCurrentMutatorConfigurable()) { ButtonBar.SetButton(3,"<Strings:UTGameUI.ButtonCallouts.ConfigureMutator>", OnButtonBar_ConfigureMutator); } } } /** @return Returns the current list of enabled mutators, separated by commas. */ function string GetEnabledMutators() { local string MutatorString; local string ClassName; local int MutatorIdx; for(MutatorIdx=0; MutatorIdx < MenuDataStore.EnabledMutators.length; MutatorIdx++) { if ( class'UTUIMenuList'.static.GetCellFieldString(EnabledList, 'ClassName', MenuDataStore.EnabledMutators[MutatorIdx], ClassName)) { if(MutatorIdx > 0) { MutatorString $= ","; } MutatorString $= ClassName; } } return MutatorString; } /** Applies the game mode filter to the enabled and available mutator lists. */ function ApplyGameModeFilter() { local int MutatorIdx; local array<int> FinalItems; for(MutatorIdx=0; MutatorIdx<MenuDataStore.EnabledMutators.length; MutatorIdx++) { if(MenuDataStore.IsProviderFiltered('Mutators', MenuDataStore.EnabledMutators[MutatorIdx])==false) { FinalItems.AddItem(MenuDataStore.EnabledMutators[MutatorIdx]); } } MenuDataStore.EnabledMutators = FinalItems; OnMutatorListChanged(); } /** Attempts to filter the mutator list to ensure that there are no duplicate groups or mutators enabled that can not be enabled. */ function AddMutatorAndFilterList(int NewMutator) { local bool bFiltered; local int MutatorIdx, GroupIdx; local string StringValue; local array<string> GroupNames, CompareGroupNames; local array<int> FinalItems; // Group Name if (class'UTUIMenuList'.static.GetCellFieldString(EnabledList, 'GroupNames', NewMutator, StringValue)) { ParseStringIntoArray(StringValue, GroupNames, "|", true); } // we can only have 1 mutator of a specified group enabled at a time, so filter all of the mutators that are of the group we are currently adding. if (GroupNames.length > 0) { LogInternal("Filtering group: '" $ StringValue $ "'"); for (MutatorIdx = 0; MutatorIdx < EnabledList.Items.length; MutatorIdx++) { bFiltered = false; if (class'UTUIMenuList'.static.GetCellFieldString(EnabledList, 'GroupNames', EnabledList.Items[MutatorIdx], StringValue)) { ParseStringIntoArray(StringValue, CompareGroupNames, "|", true); for (GroupIdx = 0; GroupIdx < GroupNames.length; GroupIdx++) { if (CompareGroupNames.Find(GroupNames[GroupIdx]) != INDEX_NONE) { bFiltered = true; break; } } } if (!bFiltered) { FinalItems.AddItem(EnabledList.Items[MutatorIdx]); } } } else { FinalItems = EnabledList.Items; } // Update final item list. FinalItems.AddItem(NewMutator); MenuDataStore.EnabledMutators = FinalItems; ApplyGameModeFilter(); } function name GetClassNameFromIndex(int MutatorIndex) { local name Result; local string DataStoreMarkup; local string OutValue; Result = ''; DataStoreMarkup = "<UTMenuItems:Mutators;"$MutatorIndex$".ClassName>"; if(GetDataStoreStringValue(DataStoreMarkup, OutValue)) { Result = name(OutValue); } return Result; } /** * Repopulate the lists; called whenever items are added or removed to one of the lists. */ function OnMutatorListChanged() { local int i, EnabledIndex, EnabledItem, AvailableIndex, AvailableItem; AvailableIndex = AvailableList.Index; AvailableItem = AvailableList.GetCurrentItem(); EnabledIndex = EnabledList.Index; EnabledItem = EnabledList.GetCurrentItem(); // Have both lists refresh their subscriber values AvailableList.IncrementAllMutexes(); EnabledList.IncrementAllMutexes(); // directly set the indexes to a bad value so that when we call SetIndex later, we're guaranteed to get an update notification AvailableList.Index = -2; EnabledList.Index = -2; // now repopulate the lists AvailableList.RefreshSubscriberValue(MANUAL_LIST_REFRESH_DATABINDING_INDEX); EnabledList.RefreshSubscriberValue(MANUAL_LIST_REFRESH_DATABINDING_INDEX); // first, we'll attempt to reselect the same mutator that was previously selected by searching for the previously // selected item. it might not be there if that item was just moved to another list or something, in which case we'll // just select the item now in that position in the list i = AvailableList.Items.Find(AvailableItem); if ( i == INDEX_NONE ) { i = AvailableIndex; } AvailableList.DecrementAllMutexes(); AvailableList.SetIndex(i); // now do the same for the list of active mutators. i = EnabledList.Items.Find(EnabledItem); if ( i == INDEX_NONE ) { i = EnabledIndex; } EnabledList.DecrementAllMutexes(); EnabledList.SetIndex(i); // if the number of items in one of the lists was less than the number of items it can display but now is more, then // the list that didn't lose an item will have re-selected the same element, meaning that it won't trigger a scene update // so let's do that manually ourselves RequestFormattingUpdate(); RequestSceneUpdate(false,true); } /** Modifies the enabled mutator array to enable/disable a mutator. */ function SetMutatorEnabled(int MutatorId, bool bEnabled) { LogInternal("UTUITabPage_Mutators::SetMutatorEnabled() - MutatorId: "$MutatorId$", bEnabled: "$bEnabled); // Get Mutator class from index if(bEnabled) { if(MenuDataStore.EnabledMutators.Find(MutatorId)==INDEX_NONE) { AddMutatorAndFilterList(MutatorId); // no need to call this here - AddMutatorAndFilterList calls ApplyGameModeFilter, which calls OnMutatorListChanged. //OnMutatorListChanged(); } } else { if(MenuDataStore.EnabledMutators.Find(MutatorId)!=INDEX_NONE) { MenuDataStore.EnabledMutators.RemoveItem(MutatorId); // If we removed all of the enabled mutators, set focus back to the available list. if(MenuDataStore.EnabledMutators.length==0 && EnabledList.IsFocused()) { AvailableList.SetFocus(none); } OnMutatorListChanged(); } } } /** Clears the enabled mutator list. */ function OnClearMutators() { MenuDataStore.EnabledMutators.length=0; // Set focus to the available list. AvailableList.SetFocus(none); // now repopulate the lists OnMutatorListChanged(); } /** Updates widgets when the currently selected mutator changes. */ function OnSelectedMutatorChanged() { UpdateDescriptionLabel(); SetupButtonBar(UTUIFrontEnd(GetScene()).ButtonBar); // Update arrows if(LastFocusedList==EnabledList) { ShiftLeftImage.SetEnabled(false); ShiftRightImage.SetEnabled(true); } else { ShiftLeftImage.SetEnabled(true); ShiftRightImage.SetEnabled(false); } } /** Callback for when the user tries to move a mutator from one list to another. */ function OnMoveMutator(bool bAddMutator) { if(bAddMutator==false) { if(EnabledList.Items.length > 0) { SetMutatorEnabled(EnabledList.GetCurrentItem(), false); } } else { if(AvailableList.Items.length > 0) { SetMutatorEnabled(AvailableList.GetCurrentItem(), true); } } // OnSelectedMutatorChanged(); } /** @return Returns whether or not the current mutator is configurable. */ function bool IsCurrentMutatorConfigurable() { local string ConfigureSceneName; local bool bResult; bResult = false; if(class'UTUIMenuList'.static.GetCellFieldString(EnabledList, 'UIConfigScene', EnabledList.GetCurrentItem(), ConfigureSceneName)) { bResult = ConfigureSceneName != ""; } return bResult; } /** Loads the configuration scene for the currently selected mutator. */ function OnConfigureMutator() { local string ConfigureSceneName; local UIScene ConfigureScene; local UTUIScene OwnerUTScene; if(class'UTUIMenuList'.static.GetCellFieldString(EnabledList, 'UIConfigScene', EnabledList.GetCurrentItem(), ConfigureSceneName)) { if (class'WorldInfo'.static.IsConsoleBuild()) { ConfigureScene = UIScene(FindObject(ConfigureSceneName, class'UIScene')); } else { ConfigureScene = UIScene(DynamicLoadObject(ConfigureSceneName, class'UIScene')); } if(ConfigureScene != none) { OwnerUTScene = UTUIScene(GetScene()); OwnerUTScene.OpenScene(ConfigureScene); } else { LogInternal("UTUITabPage_Mutators::OnConfigureMutator() - Unable to find scene '"$ConfigureSceneName$"'"); } } } /** The user has finished setting up their mutators and wants to continue on. */ function OnNext() { // Fire our mutators accepted delegate. OnAcceptMutators(GetEnabledMutators()); } /** Updates the description label. */ function UpdateDescriptionLabel() { local string NewDescription; local int SelectedItem; SelectedItem = LastFocusedList.GetCurrentItem(); if(class'UTUIMenuList'.static.GetCellFieldString(LastFocusedList, 'Description', SelectedItem, NewDescription)) { DescriptionLabel.SetDataStoreBinding(NewDescription); } } /** * Callback for when the user selects a new item in the available list. */ function OnAvailableList_ValueChanged( UIObject Sender, int PlayerIndex ) { if ( Sender == LastFocusedList ) { OnSelectedMutatorChanged(); } } /** * Callback for when the user submits the selection on the available list. */ function OnAvailableList_SubmitSelection( UIList Sender, optional int PlayerIndex=GetBestPlayerIndex() ) { OnMoveMutator(true); } /** Callback for when the object's active state changes. */ function OnList_NotifyActiveStateChanged( UIScreenObject Sender, int PlayerIndex, UIState NewlyActiveState, optional UIState PreviouslyActiveState ) { local UIList ListSender; ListSender = UIList(Sender); if ( ListSender != None ) { ListSender.OnStateChanged(Sender, PlayerIndex, NewlyActiveState, PreviouslyActiveState); if ( UIState_Focused(NewlyActiveState) != None ) { LastFocusedList = ListSender; OnSelectedMutatorChanged(); // for visual effect - the disabled state of these images contains the data to make the background image appear focused if ( ListSender == EnabledList ) { if ( ListBackground_Enabled != None ) { ListBackground_Enabled.SetEnabled(false, PlayerIndex); } } else { if ( ListBackground_Available != None ) { ListBackground_Available.SetEnabled(false, PlayerIndex); } } } else if ( UIState_Focused(PreviouslyActiveState) != None && !ListSender.IsFocused(PlayerIndex) ) { // for visual effect - the enabled state of these images contains the data to make the background image appear not-focused if ( ListSender == EnabledList ) { if ( ListBackground_Enabled != None ) { ListBackground_Enabled.SetEnabled(true, PlayerIndex); } } else { if ( ListBackground_Available != None ) { ListBackground_Available.SetEnabled(true, PlayerIndex); } } } } } /** * Callback for when the user selects a new item in the enabled list. */ function OnEnabledList_ValueChanged( UIObject Sender, int PlayerIndex ) { if ( Sender == LastFocusedList ) { OnSelectedMutatorChanged(); } } /** * Callback for when the user submits the selection on the enabled list. */ function OnEnabledList_SubmitSelection( UIList Sender, optional int PlayerIndex=GetBestPlayerIndex() ) { OnMoveMutator(false); } /** Callback for the mutator lists, captures the accept button before the mutators get to it. */ function bool OnMutatorList_RawInputKey( const out InputEventParameters EventParms ) { local bool bResult; bResult = false; if(EventParms.EventType==IE_Released && EventParms.InputKeyName=='XboxTypeS_A') { OnNext(); bResult = true; } return bResult; } /** * Causes this page to become (or no longer be) the tab control's currently active page. * * @param PlayerIndex the index [into the Engine.GamePlayers array] for the player that wishes to activate this page. * @param bActivate TRUE if this page should become the tab control's active page; FALSE if it is losing the active status. * @param bTakeFocus specify TRUE to give this panel focus once it's active (only relevant if bActivate = true) * * @return TRUE if this page successfully changed its active state; FALSE otherwise. */ event bool ActivatePage( int PlayerIndex, bool bActivate, optional bool bTakeFocus=true ) { local bool bResult; bResult = Super.ActivatePage(PlayerIndex, bActivate, bTakeFocus); if ( bResult && bActivate && bTakeFocus ) { AvailableList.SetFocus(None); } return bResult; } /** Buttonbar Callbacks. */ function bool OnButtonBar_ConfigureMutator(UIScreenObject InButton, int PlayerIndex) { OnConfigureMutator(); return true; } function bool OnButtonBar_ClearMutators(UIScreenObject InButton, int PlayerIndex) { OnClearMutators(); return true; } function bool OnButtonBar_AddMutator(UIScreenObject InButton, int PlayerIndex) { AvailableList.SetFocus(none); OnMoveMutator(true); return true; } function bool OnButtonBar_RemoveMutator(UIScreenObject InButton, int PlayerIndex) { EnabledList.SetFocus(none); OnMoveMutator(false); return true; } function bool OnButtonBar_Next(UIScreenObject InButton, int PlayerIndex) { OnNext(); return true; } /** * Provides a hook for unrealscript to respond to input using actual input key names (i.e. Left, Tab, etc.) * * Called when an input key event is received which this widget responds to and is in the correct state to process. The * keys and states widgets receive input for is managed through the UI editor's key binding dialog (F8). * * This delegate is called BEFORE kismet is given a chance to process the input. * * @param EventParms information about the input event. * * @return TRUE to indicate that this input key was processed; no further processing will occur on this input key event. */ function bool HandleInputKey( const out InputEventParameters EventParms ) { local bool bResult; bResult=false; if(EventParms.EventType==IE_Released) { if(EventParms.InputKeyName=='XboxTypeS_A' || EventParms.InputKeyName=='XboxTypeS_Enter') // Accept mutators { OnNext(); bResult=true; } else if(EventParms.InputKeyName=='XboxTypeS_Y') // Move mutator { OnMoveMutator(AvailableList.IsFocused()); bResult=true; } else if(EventParms.InputKeyName=='XboxTypeS_X') // Clear mutators { OnConfigureMutator(); bResult=true; } } return bResult; } defaultproperties { Begin Object Class=UIComp_Event Name=WidgetEventComponent ObjName=WidgetEventComponent Archetype=UIComp_Event'UTGame.Default__UTTabPage:WidgetEventComponent' ObjectArchetype=UIComp_Event'UTGame.Default__UTTabPage:WidgetEventComponent' End Object EventProvider=WidgetEventComponent Name="Default__UTUITabPage_Mutators" ObjectArchetype=UTTabPage'UTGame.Default__UTTabPage' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |