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 00665 00666 00667 00668 00669 00670 00671 00672 00673 00674 00675 00676 00677 00678 00679 00680 00681 00682 00683 00684 00685 00686 00687 00688 00689 00690 00691 00692 00693 00694 00695 00696 00697 00698 00699 00700 00701 00702 00703 00704 00705 00706 00707 00708 00709 00710 00711 00712 00713 00714 00715 00716 00717 00718 00719 00720 00721 00722 00723 00724 00725 00726 00727 00728 00729 00730 00731 00732 00733 00734 00735 00736 00737 00738 00739 00740 00741 00742 00743 00744 00745 00746 00747 00748 00749 00750 00751 00752 00753 00754 00755 00756 00757 00758 00759 00760 00761 00762 00763 00764 00765 00766 00767 00768 00769 00770 00771 00772 00773 00774 00775 00776 00777 00778 00779 00780 00781 00782 00783 00784 00785 00786 00787 00788 00789 00790 00791 00792 00793 00794 00795 00796 00797 00798 00799 00800 00801 00802 00803 00804 00805 00806 00807 00808 00809 00810 00811 00812 00813 00814 00815 00816 00817 00818 00819 00820 00821 00822 00823 00824 00825 00826 00827 00828 00829 00830 00831 00832 00833 00834 00835 00836 00837 00838 00839 00840 00841 00842 00843 00844 00845 00846 00847 00848 00849 00850 00851 00852 00853 00854 00855 00856 00857 00858 00859 00860 00861 00862 00863 00864 00865 00866 00867 00868 00869 |
/** * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. * * Options tab page, autocreates a set of options widgets using the datasource provided. */ class UTUIOptionList extends UTDrawPanel placeable native(UIFrontEnd) implements(UIDataStoreSubscriber); // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) /** Scrollbar to let PC users scroll up and down the list freely. */ var transient UIScrollbar VerticalScrollbar; /** Info about an option we have generated. */ struct native GeneratedObjectInfo { var name OptionProviderName; var UIObject LabelObj; var UIObject OptionObj; var UIDataProvider OptionProvider; var float OptionY; var float OptionHeight; var float OptionX; var float OptionWidth; }; /** Current option index. */ var transient int CurrentIndex; /** Previously selected option index. */ var transient int PreviousIndex; /** Start time for animating option switches. */ var transient float StartMovementTime; /** Whether or not we are currently animating the background prefab. */ var transient bool bAnimatingBGPrefab; /** List of auto-generated objects, anything in this array will be removed from the children's array before presave. */ var transient array<GeneratedObjectInfo> GeneratedObjects; /** The data store that this list is bound to */ var(Data) UIDataStoreBinding DataSource; /** the list element provider referenced by DataSource */ var const transient UIListElementProvider DataProvider; /** Background prefab for the currently selected item. */ var() UIPrefab BGPrefab; /** Instance of the background prefab. */ var transient UIPrefabInstance BGPrefabInstance; /** Maximum number of visible items. */ var transient int MaxVisibleItems; /** Flag to let the optionlist know that it should regenerate its options on next tick. */ var transient bool bRegenOptions; /** Properties for the scroll arrows. */ var float ScrollArrowWidth; var color ArrowColor; var texture2D SelectionImage; var texture2D ArrowImage; /** Properties for individual option spacing */ var() float DefaultOptionHeight; var() float DefaultOptionPadding; var() float DefaultOptionTopMargin; var() float DefaultOptionRightMargin; /** Current state of the arrows. */ var transient float DragDeadZone; var transient bool bDragging; var transient float SelectionSpeed; /** Speed to increase or decrease the currently selected element when dragging, in seconds. */ var transient float LastDragSelection; /** Last time we changed the current selection due to dragging. */ var transient vector DragClickPosition; var transient float UpArrowBounds[4]; var transient float DownArrowBounds[4]; var transient bool bUpArrowPressed; var transient bool bDownArrowPressed; /** Delegate called when an option gains focus. */ delegate OnOptionFocused(UIScreenObject InObject, UIDataProvider OptionProvider); /** Delegate for when the user changes one of the options in this option list. */ delegate OnOptionChanged(UIScreenObject InObject, name OptionName, int PlayerIndex); /** Accept button was pressed on the option list. */ delegate OnAcceptOptions(UIScreenObject InObject, int PlayerIndex); event GetSupportedUIActionKeyNames(out array<Name> out_KeyNames ) { out_KeyNames[out_KeyNames.Length] = 'MouseMoveX'; out_KeyNames[out_KeyNames.Length] = 'MouseMoveY'; out_KeyNames[out_KeyNames.Length] = 'Click'; out_KeyNames[out_KeyNames.Length] = 'SelectionUp'; out_KeyNames[out_KeyNames.Length] = 'SelectionDown'; out_KeyNames[out_KeyNames.Length] = 'SelectionHome'; out_KeyNames[out_KeyNames.Length] = 'SelectionEnd'; out_KeyNames[out_KeyNames.Length] = 'SelectionPgUp'; out_KeyNames[out_KeyNames.Length] = 'SelectionPgDn'; out_KeyNames[out_KeyNames.Length] = 'AcceptOptions'; } /** Generates widgets for all of the options. */ native function RegenerateOptions(); /** Repositions all of the visible options. */ native function RepositionOptions(); /** Sets the currently selected option index. */ native function SetSelectedOptionIndex(int OptionIdx); /** Refreshes the value of all of the options by having them pull their options from the datastore again. */ function RefreshAllOptions() { local int OptionIdx; for(OptionIdx=0; OptionIdx<GeneratedObjects.length; OptionIdx++) { UIDataStoreSubscriber(GeneratedObjects[OptionIdx].OptionObj).RefreshSubscriberValue(); } } /** Post initialize, binds callbacks for all of the generated options. */ event PostInitialize() { Super.PostInitialize(); // Setup handler for input keys OnProcessInputKey=ProcessInputKey; OnProcessInputAxis=ProcessInputAxis; RegenerateOptions(); } /** Sets up the option bindings. */ event SetupOptionBindings() { local int ObjectIdx; // Go through all of the generated object and set the OnValueChanged delegate. for(ObjectIdx=0; ObjectIdx < GeneratedObjects.length; ObjectIdx++) { GeneratedObjects[ObjectIdx].OptionObj.OnValueChanged = OnValueChanged; GeneratedObjects[ObjectIdx].OptionObj.NotifyActiveStateChanged = OnOption_NotifyActiveStateChanged; } // Setup scroll callbacks if ( VerticalScrollbar != None ) { VerticalScrollbar.OnScrollActivity = ScrollVertical; VerticalScrollbar.OnClickedScrollZone = ClickedScrollZone; } } /** Initializes combobox widgets. */ native function InitializeComboboxWidgets(); /** Initializes the scrollbar widget for the option list. */ native function InitializeScrollbars(); /** * Handler for the vertical scrollbar's OnClickedScrollZone delegate. Scrolls the list by a full page (MaxVisibleItems). * * @param Sender the scrollbar that was clicked. * @param PositionPerc a value from 0.0 - 1.0, representing the location of the click within the region between the increment * and decrement buttons. Values closer to 0.0 means that the user clicked near the decrement button; values closer * to 1.0 are nearer the increment button. * @param PlayerIndex Player that performed the action that issued the event. */ function ClickedScrollZone( UIScrollbar Sender, float PositionPerc, int PlayerIndex ) { local int MouseX, MouseY; local float MarkerPosition; local bool bDecrement; local int NewTopItem; if ( GetCursorPosition(MouseX, MouseY) ) { // this is the position of the marker's minor side (left or top) MarkerPosition = Sender.GetMarkerButtonPosition(); // determine whether the user clicked in the region above or below the marker button. bDecrement = (Sender.ScrollbarOrientation == UIORIENT_Vertical) ? MouseY < MarkerPosition : MouseX < MarkerPosition; NewTopItem = bDecrement ? (CurrentIndex - 1) : (CurrentIndex + 1); SelectItem(NewTopItem); } } /** * Handler for vertical scrolling activity * PositionChange should be a number of nudge values by which the slider was moved * * @param Sender the scrollbar that generated the event. * @param PositionChange indicates how many items to scroll the list by * @param bPositionMaxed indicates that the scrollbar's marker has reached its farthest available position, * unused in this function */ function bool ScrollVertical( UIScrollbar Sender, float PositionChange, optional bool bPositionMaxed=false ) { local int NewIndex; if ( bPositionMaxed ) { NewIndex = Clamp(PositionChange > 0 ? GeneratedObjects.Length - 1 : 0, 0, GeneratedObjects.Length - 1); } else { NewIndex = CurrentIndex + Round(PositionChange); } SelectItem(NewIndex); return true; } /** @return Returns the object info struct index given a provider namename. */ function int GetObjectInfoIndexFromName(name ProviderName) { local int ObjectIdx; local int Result; Result = INDEX_NONE; // Resolve the option name for(ObjectIdx=0; ObjectIdx < GeneratedObjects.length; ObjectIdx++) { if(GeneratedObjects[ObjectIdx].OptionProviderName==ProviderName) { Result = ObjectIdx; break; } } return Result; } /** @return Returns the object info struct given a sender object. */ function int GetObjectInfoIndexFromObject(UIObject Sender) { local int ObjectIdx; local int Result; Result = INDEX_NONE; // Resolve the option name for(ObjectIdx=0; ObjectIdx < GeneratedObjects.length; ObjectIdx++) { if(GeneratedObjects[ObjectIdx].OptionObj==Sender) { Result = ObjectIdx; break; } } return Result; } /** Callback for all of the options we generated. */ function OnValueChanged( UIObject Sender, int PlayerIndex ) { local name OptionProviderName; local int ObjectIdx; OptionProviderName = ''; // Resolve the option name ObjectIdx = GetObjectInfoIndexFromObject(Sender); if(ObjectIdx != INDEX_NONE) { OptionProviderName = GeneratedObjects[ObjectIdx].OptionProviderName; } // Call the option changed delegate OnOptionChanged(Sender, OptionProviderName, PlayerIndex); } /** Callback for when the object's active state changes. */ function OnOption_NotifyActiveStateChanged( UIScreenObject Sender, int PlayerIndex, UIState NewlyActiveState, optional UIState PreviouslyActiveState ) { local int ObjectIndex; ObjectIndex = GetObjectInfoIndexFromObject(UIObject(Sender)); if(ObjectIndex != INDEX_NONE) { if(NewlyActiveState.Class == class'UIState_Focused'.default.Class) { SetSelectedOptionIndex(ObjectIndex); OnOptionFocused(Sender, GeneratedObjects[ObjectIndex].OptionProvider); // Play a sound cue depending on which way the selection moved. if(CurrentIndex != PreviousIndex) { if(CurrentIndex < PreviousIndex) { if(CurrentIndex==0 && PreviousIndex==GeneratedObjects.length-1) { PlayUISound('ListDown'); } else { PlayUISound('ListUp'); } } else { if(PreviousIndex==0 && CurrentIndex==GeneratedObjects.length-1) { PlayUISound('ListUp'); } else { PlayUISound('ListDown'); } } } } } } /** * Enables / disables an item in the list. If the item is the currently selected item, selects the next item in the list, if possible. * * @param OptionIdx the index for the option that should be updated * @param bShouldEnable TRUE to enable the item; FALSE to disable. * * @return TRUE if the item's state was successfully changed; FALSE if it couldn't be changed or OptionIdx was invalid. */ function bool EnableItem( int PlayerIndex, UIObject ChosenObj, bool bShouldEnable=true ) { return EnableItemAtIndex(PlayerIndex, GetObjectInfoIndexFromObject(ChosenObj), bShouldEnable); } function bool EnableItemAtIndex( int PlayerIndex, int OptionIdx, bool bShouldEnable=true ) { local bool bResult, bStateChangeAllowed; local int idx; local UIObject ChosenObj; if ( OptionIdx >= 0 && OptionIdx < GeneratedObjects.Length ) { ChosenObj = GeneratedObjects[OptionIdx].OptionObj; if ( ChosenObj != None ) { bStateChangeAllowed = true; if ( !bShouldEnable ) { if ( OptionIdx == CurrentIndex ) { bStateChangeAllowed = false; for ( idx = (OptionIdx + 1) % GeneratedObjects.Length; idx != CurrentIndex; idx = (idx + 1) % GeneratedObjects.Length ) { if ( SelectItem(idx, PlayerIndex, false) ) { bStateChangeAllowed = true; break; } } } else if ( ChosenObj == GetFocusedControl(false, PlayerIndex) ) { bStateChangeAllowed = ChosenObj.KillFocus(None, PlayerIndex); } } if ( bStateChangeAllowed ) { bResult = ChosenObj.SetEnabled(bShouldEnable, PlayerIndex); } } } return bResult; } /** Returns the currently selected option object */ function UIObject GetCurrentlySelectedOption() { if ( CurrentIndex >= 0 && CurrentIndex < GeneratedObjects.Length ) { return GeneratedObjects[CurrentIndex].OptionObj; } return None; } /** Selects the specified option item. */ function bool SelectItem(int OptionIdx, optional int PlayerIndex=GetBestPlayerIndex(), optional bool bClampValue=true ) { local bool bResult; if ( bClampValue ) { OptionIdx = Clamp(OptionIdx, 0, GeneratedObjects.length - 1); } if ( OptionIdx >= 0 && OptionIdx < GeneratedObjects.length && GeneratedObjects[OptionIdx].OptionObj.IsEnabled(GetBestPlayerIndex())) { if ( IsFocused(PlayerIndex) ) { bResult = GeneratedObjects[OptionIdx].OptionObj.SetFocus(none); } else { OverrideLastFocusedControl(PlayerIndex, GeneratedObjects[OptionIdx].OptionObj); bResult = true; } } return bResult; } /** Selects the next item in the list. */ function bool SelectNextItem(optional bool bWrap=false, optional int PlayerIndex=GetBestPlayerIndex()) { local int TargetIndex; TargetIndex = CurrentIndex; //Continue to search the list while we have disabled options do { TargetIndex++; if(bWrap) { TargetIndex = TargetIndex%(GeneratedObjects.length); } //Keep going until we find an enabled widget, we've exceed bounds or we wrapped back around } until(TargetIndex >= GeneratedObjects.length || TargetIndex == CurrentIndex || GeneratedObjects[TargetIndex].OptionObj.IsEnabled(PlayerIndex) == true ); return SelectItem(TargetIndex, PlayerIndex); } /** Selects the previous item in the list. */ function bool SelectPreviousItem(optional bool bWrap=false, optional int PlayerIndex=GetBestPlayerIndex()) { local int TargetIndex; TargetIndex = CurrentIndex; //Continue to search the list while we have disabled options do { TargetIndex--; if(bWrap && TargetIndex<0) { TargetIndex=GeneratedObjects.length-1; } //Keep going until we find an enabled widget, we've exceed bounds or we wrapped back around } until( TargetIndex < 0 || TargetIndex == CurrentIndex || GeneratedObjects[TargetIndex].OptionObj.IsEnabled(PlayerIndex) == true ); return SelectItem(TargetIndex, PlayerIndex); } /** Checks to see if the user has clicked on the scroll arrows. */ function CheckArrowInput(const SubscribedInputEventParameters EventParms) { if(EventParms.EventType==IE_Pressed||EventParms.EventType==IE_DoubleClick) { if(CursorCheck(UpArrowBounds[0],UpArrowBounds[1],UpArrowBounds[2],UpArrowBounds[3])) { bUpArrowPressed=true; } else if(CursorCheck(DownArrowBounds[0],DownArrowBounds[1],DownArrowBounds[2],DownArrowBounds[3])) { bDownArrowPressed=true; } DragClickPosition=GetMousePosition(); } else if(EventParms.EventType==IE_Released) { // If we are not dragging, check for a mouse click. if(bDragging==false) { if(bUpArrowPressed && CursorCheck(UpArrowBounds[0],UpArrowBounds[1],UpArrowBounds[2],UpArrowBounds[3])) { // The user released their mouse on the button. SelectPreviousItem(); } else if(bDownArrowPressed && CursorCheck(DownArrowBounds[0],DownArrowBounds[1],DownArrowBounds[2],DownArrowBounds[3])) { // The user released their mouse on the button. SelectNextItem(); } } bDragging = false; bDownArrowPressed=false; bUpArrowPressed=false; } } /** * 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 ProcessInputKey( const out SubscribedInputEventParameters EventParms ) { local int OptionIdx; if (EventParms.EventType == IE_Pressed) { if ( EventParms.InputAliasName == 'SelectionUp' ) { SelectPreviousItem(false); } else if ( EventParms.InputAliasName == 'SelectionDown' ) { SelectNextItem(false); } else if ( EventParms.InputAliasName == 'SelectionHome' ) { SelectItem(0); } else if ( EventParms.InputAliasName == 'SelectionEnd' ) { SelectItem(GeneratedObjects.Length-1); } else if ( EventParms.InputAliasName == 'SelectionPgUp' ) { SelectItem(CurrentIndex - MaxVisibleItems); } else if ( EventParms.InputAliasName == 'SelectionPgDn' ) { SelectItem(CurrentIndex + MaxVisibleItems); } else if ( EventParms.InputAliasName == 'Click' ) { CheckArrowInput(EventParms); } } else if ( EventParms.EventType == IE_Released ) { if ( EventParms.InputAliasName == 'AcceptOptions' ) { PlayUISound('ListSubmit'); OnAcceptOptions(self, EventParms.PlayerIndex); } else if ( EventParms.InputAliasName == 'Click' ) { CheckArrowInput(EventParms); for(OptionIdx=0; OptionIdx<GeneratedObjects.length; OptionIdx++) { if(CursorCheck(GeneratedObjects[OptionIdx].OptionX, GeneratedObjects[OptionIdx].OptionY, GeneratedObjects[OptionIdx].OptionX+GeneratedObjects[OptionIdx].OptionWidth, GeneratedObjects[OptionIdx].OptionY+GeneratedObjects[OptionIdx].OptionHeight)) { if(CurrentIndex!=OptionIdx) { SelectItem(OptionIdx); } break; } } } } return true; } /** * Enable hottracking if we are dragging */ function bool ProcessInputAxis( const out SubscribedInputEventParameters EventParms ) { local vector CurrentMousePosition; local vector DeltaPosition; // If the user pressed down on the up or down arrow and then dragged their mouse // a distance greater than the 'deadzone' then enable drag mode. if ( (bUpArrowPressed || bDownArrowPressed) && EventParms.InputKeyName=='MouseY' ) { CurrentMousePosition = GetMousePosition(); DeltaPosition = CurrentMousePosition-DragClickPosition; if(Abs(DeltaPosition.Y) > DragDeadZone) { bDragging = true; } return true; } return false; } /** * @Returns the mouse position in widget space */ function Vector GetMousePosition() { local int x,y; local vector2D MousePos; local vector AdjustedMousePos; class'UIRoot'.static.GetCursorPosition( X, Y ); MousePos.X = X; MousePos.Y = Y; AdjustedMousePos = PixelToCanvas(MousePos); AdjustedMousePos.X -= GetPosition(UIFACE_Left,EVALPOS_PixelViewport); AdjustedMousePos.Y -= GetPosition(UIFACE_Top, EVALPOS_PixelViewport); return AdjustedMousePos; } /** * All are in pixels * * @Param X1 Left * @Param Y1 Top * @Param X2 Right * @Param Y2 Bottom * * @Returns true if the mouse is within the bounds given */ function bool CursorCheck(float X1, float Y1, float X2, float Y2) { local vector MousePos;; MousePos = GetMousePosition(); return ( (MousePos.X >= X1 && MousePos.X <= X2) && (MousePos.Y >= Y1 && MousePos.Y <= Y2) ); } /** If we are dragging, this function will increment the current selection based on the location of the mouse cursor. */ function CheckAndUpdateDragging() { local vector MousePos; local int OptionIdx; // See if we are dragging, if we are, then try to select the item under the mouse cursor. if(bDragging) { MousePos = GetMousePosition(); for(OptionIdx=0; OptionIdx<GeneratedObjects.length; OptionIdx++) { if(MousePos.Y >= GeneratedObjects[OptionIdx].OptionY && MousePos.Y <= (GeneratedObjects[OptionIdx].OptionY+GeneratedObjects[OptionIdx].OptionHeight)) { SelectItem(OptionIdx); break; } } } } /** * Render's the list's selection elements. */ event DrawPanel() { /* - Disabled completely, we use scrollbars on all platforms. local float Width,Height; local float AWidth, AHeight, AYPos; local bool bOverArrow; local float YPos; CheckAndUpdateDragging(); YPos = BGPrefabInstance.GetPosition(UIFACE_Top, EVALPOS_PixelOwner); Height = BGPrefabInstance.GetPosition(UIFACE_Bottom, EVALPOS_PixelOwner); Width = ScrollArrowWidth * GetPosition(UIFACE_Right, EVALPOS_PixelOwner); // Draw up down arrows on the console. if(IsConsole()) { // ------------ Draw the up/Down Arrows // Calculate the sizes AWidth = Width * 0.8; AHeight = AWidth * 2.0; AYPos = YPos - AHeight - (Height * 0.1); // Draw The up button // Cache the bounds for mouse lookup later UpArrowBounds[0] = Width*0.5f - (AWidth * 0.5); UpArrowBounds[2] = UpArrowBounds[0] + AWidth; UpArrowBounds[1] = AYPos; UpArrowBounds[3] = AYPos + AHeight; bOverArrow = CursorCheck(UpArrowBounds[0],UpArrowBounds[1],UpArrowBounds[2],UpArrowBounds[3]); DrawSpecial(UpArrowBounds[0],UpArrowBounds[1], AWidth, AHeight, 77, 198, 63, 126, ArrowColor, bOverArrow, bUpArrowPressed); // Draw The down button // Cache the bounds for mouse lookup later AYPos = YPos + Height + (Height * 0.1); DownArrowBounds[0] = Width*0.5f - (AWidth * 0.5); DownArrowBounds[2] = DownArrowBounds[0] + AWidth; DownArrowBounds[1] = AYPos; DownArrowBounds[3] = AYPos + AHeight; bOverArrow = CursorCheck(DownArrowBounds[0],DownArrowBounds[1],DownArrowBounds[2],DownArrowBounds[3]); DrawSpecial(DownArrowBounds[0],DownArrowBounds[1], AWidth, AHeight, 77, 358, 63, 126, ArrowColor, bOverArrow, bDownArrowPressed); } */ } function DrawSpecial(float x, float y, float w, float h, float u, float v, float ul, float vl, color DrawColor, bool bOver, bool bPressed) { if (bDragging || bOver || bPressed) { Canvas.SetDrawColor(255,0,0,255); Canvas.SetPos(x-2,y-2); Canvas.DrawTile(ArrowImage, w+4, h+4, u,v,ul,vl); } if (!bDragging && !bPressed ) { Canvas.SetPos(x,y); Canvas.DrawColor = DrawColor; Canvas.DrawTile(ArrowImage, w, h, u, v, ul, vl); } } /** UIDataSourceSubscriber interface */ /** * Sets the data store binding for this object to the text specified. * * @param MarkupText a markup string which resolves to data exposed by a data store. The expected format is: * <DataStoreTag:DataFieldTag> * @param BindingIndex optional parameter for indicating which data store binding is being requested 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. */ native final virtual function SetDataStoreBinding( string MarkupText, optional int BindingIndex=INDEX_NONE ); /** * Retrieves the markup string corresponding to the data store that this object is bound to. * * @param BindingIndex optional parameter for indicating which data store binding is being requested 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. * * @return a datastore markup string which resolves to the datastore field that this object is bound to, in the format: * <DataStoreTag:DataFieldTag> */ native final virtual function string GetDataStoreBinding( optional int BindingIndex=INDEX_NONE ) const; /** * Resolves this subscriber's data store binding and updates the subscriber with the current value from the data store. * * @return TRUE if this subscriber successfully resolved and applied the updated value. */ native final virtual function bool RefreshSubscriberValue( optional int BindingIndex=INDEX_NONE ); /** * Handler for the UIDataStore.OnDataStoreValueUpdated delegate. Used by data stores to indicate that some data provided by the data * has changed. Subscribers should use this function to refresh any data store values being displayed with the updated value. * notify subscribers when they should refresh their values from this data store. * * @param SourceDataStore the data store that generated the refresh notification; useful for subscribers with multiple data store * bindings, to tell which data store sent the notification. * @param PropertyTag the tag associated with the data field that was updated; Subscribers can use this tag to determine whether * there is any need to refresh their data values. * @param SourceProvider for data stores which contain nested providers, the provider that contains the data which changed. * @param ArrayIndex for collection fields, indicates which element was changed. value of INDEX_NONE indicates not an array * or that the entire array was updated. */ native function NotifyDataStoreValueUpdated( UIDataStore SourceDataStore, bool bValuesInvalidated, name PropertyTag, UIDataProvider SourceProvider, int ArrayIndex ); /** * Retrieves the list of data stores bound by this subscriber. * * @param out_BoundDataStores receives the array of data stores that subscriber is bound to. */ native final virtual function GetBoundDataStores( out array<UIDataStore> out_BoundDataStores ); /** * Notifies this subscriber to unbind itself from all bound data stores */ native final virtual function ClearBoundDataStores(); defaultproperties { DataSource=(RequiredFieldType=DATATYPE_Collection) BGPrefab=UIPrefab'UI_Scenes_FrontEnd.Prefabs.OptionBG' ScrollArrowWidth=0.040000 ArrowColor=(B=1,G=0,R=128,A=255) SelectionImage=Texture2D'UI_HUD.HUD.UI_HUD_BaseD' ArrowImage=Texture2D'UI_HUD.HUD.UI_HUD_BaseC' DefaultOptionHeight=32.000000 DefaultOptionPadding=12.000000 DefaultOptionTopMargin=-3.000000 DefaultOptionRightMargin=10.000000 bRequiresTick=True DefaultStates(3)=Class'Engine.UIState_Active' Begin Object Class=UIComp_Event Name=WidgetEventComponent ObjName=WidgetEventComponent Archetype=UIComp_Event'UTGame.Default__UTDrawPanel:WidgetEventComponent' ObjectArchetype=UIComp_Event'UTGame.Default__UTDrawPanel:WidgetEventComponent' End Object EventProvider=WidgetEventComponent Name="Default__UTUIOptionList" ObjectArchetype=UTDrawPanel'UTGame.Default__UTDrawPanel' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |