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 |
//============================================================================== // Created on: 01/19/2004 // Tooltip that appears when this component is moused over // // Written by Ron Prestenback // © 2003, Epic Games, Inc. All Rights Reserved //============================================================================== class GUIToolTip extends GUIComponent native; // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) var() bool bResetPosition; // Position of this component needs to be updated var() bool bTrackMouse; // This tooltip will follow the mouse as it moves var() bool bMultiLine; // Allow hint text to be wrapped if it's too long var() bool bTrackInput; // Should this tooltip disappear when input is received var() const string Text; // Entire tooltip var() const array<string> Lines; // If multiline == true, contains the tooltip lines var() noexport float StartTime; var() noexport float CurrentTime; var() globalconfig float MaxWidth; // Max width of the tooltip area, in percent of the screen width var() globalconfig float InitialDelay; // Number of seconds of inactivity before appearing var() globalconfig float ExpirationSeconds; // Number of seconds to display before fading out // Return true to override default behavior // SetPosition() is called at the end of the native PreDraw(), if (bResetPosition || bTrackMouse), // which means SetPosition() will NOT be called if you return true from OnPreDraw() // delegate bool OnPreDraw( Canvas C ); // Draw will NOT be called if bResetPosition == true // delegate bool OnDraw( Canvas C ); // called when the mouse is first moved over the component associated with this tooltip delegate GUIToolTip EnterArea() { return InternalEnterArea(); } function GUIToolTip InternalEnterArea() { if (Controller==None) { if ( class'GUIController'.default.bModAuthor ) log("ToolTip ("$self$") not initialized"); return none; } StartTime = PlayerOwner().Level.TimeSeconds; // if there was a hint currently being displayed, bypass the initial delay if ( Controller != None && Controller.MouseOver != None && Controller.MouseOver != Self && Controller.MouseOver.bVisible ) CurrentTime = InitialDelay; else CurrentTime = 0.0; bResetPosition = true; return self; } // Called when the mouse is moved away from the component associated with this tooltip // Return false to keep displaying the tooltip - though sometimes controller will force the tooltip to disappear // (for instance, if opening a context menu, etc.) delegate bool LeaveArea() { return InternalLeaveArea(); } function bool InternalLeaveArea() { StartTime = -1; CurrentTime = -1; SetVisibility(false); if ( Controller != None && Controller.MouseOver == Self ) Controller.MouseOver = None; return true; } // Only received when active delegate Tick( float RealSeconds ) { CurrentTime += RealSeconds; if ( !bVisible && CurrentTime > InitialDelay && (ExpirationSeconds == 0.0 || CurrentTime <= ExpirationSeconds) ) ShowToolTip(); if ( bVisible && CurrentTime > ExpirationSeconds && ExpirationSeconds > 0.0 ) HideToolTip(); } delegate ShowToolTip() { SetVisibility(true); } delegate HideToolTip() { SetVisibility(false); } // This is normally called at the end of PreDraw(). event UpdatePosition( Canvas C ) { WinWidth = GetWidth(C); WinHeight = GetHeight(C); WinLeft = GetLeft(C); WinTop = GetTop(C); bResetPosition = false; } delegate float GetLeft( Canvas C ) { local float X; if ( C == None || MenuOwner == None || Style == None ) return -1.0; X = FMin(Controller.MouseX, Controller.MouseCursorBounds.X1); if ( X + WinWidth > C.SizeX ) X -= WinWidth + 10; return X; } delegate float GetTop( Canvas C ) { local float TargetTop; if ( C == None || MenuOwner == None || Style == None ) return -1.0; if ( Controller.MouseY > C.SizeY / 8 ) TargetTop = GetTopAboveCursor(C); else TargetTop = GetTopBelowCursor(C); if ( TargetTop < 0 ) TargetTop = GetTopBelowCursor(C); return TargetTop; } delegate float GetWidth( Canvas C ) { local int i; local float MaxLineWidth, XL, YL; if ( C == None || Lines.Length == 0 || MenuOwner == None || Style == None ) return 0.0; for ( i = 0; i < Lines.Length; i++ ) { Style.TextSize(C, MenuOwner.MenuState, Lines[i], XL, YL, FontScale); if ( XL > MaxLineWidth ) MaxLineWidth = XL; } return FMin( MaxLineWidth, MaxWidth * C.SizeX ) + Style.BorderOffsets[0] + Style.BorderOffsets[2]; } delegate float GetHeight( Canvas C ) { local float XL, YL; if ( C == None || Lines.Length == 0 || MenuOwner == None || Style == None ) return 0.0; Style.TextSize( C, MenuOwner.MenuState, Lines[0], XL, YL, FontScale ); return (YL * Lines.Length) + Style.BorderOffsets[1] + Style.BorderOffsets[3]; } singular function float GetTopAboveCursor( Canvas C ) { local float TargetY, TempY; if ( MenuOwner == None || C == None || Controller == None ) return -1.0; TargetY = FMin(Controller.MouseCursorBounds.Y1, Controller.MouseY) - (WinHeight + 10); if ( TargetY < 0 ) TempY = GetTopBelowCursor(C); return FMax(TempY, TargetY); } singular function float GetTopBelowCursor( Canvas C ) { local float TargetY, TempY; if ( MenuOwner == None || C == None || Controller == None ) return -1.0; TargetY = FMax(Controller.MouseCursorBounds.Y2, Controller.MouseY) + 10; if ( TargetY + WinHeight > C.SizeY ) TempY = GetTopAboveCursor(C); return FMax(TargetY, TempY); } native final function SetTip( coerce string NewTip ); defaultproperties { bMultiLine=Wahr bTrackInput=Wahr MaxWidth=0.300000 InitialDelay=0.250000 ExpirationSeconds=3.000000 StyleName="MouseOver" bVisible=Falsch } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |