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 |
// ==================================================================== // Class: GUI. UT2NumericEdit // // A Combination of an EditBox and 2 spinners // // Written by Joe Wilcox // (c) 2002, Epic Games, Inc. All Rights Reserved // ==================================================================== /*============================================================================= In Game GUI Editor System V1.0 2003 - Irrational Games, LLC. * Dan Kaplan =============================================================================*/ #if !IG_GUI_LAYOUT #error This code requires IG_GUI_LAYOUT to be defined due to extensive revisions of the origional code. [DKaplan] #endif /*===========================================================================*/ class GUINumericEdit extends GUIMultiComponent HideCategories(Menu,Object) Native; cpptext { void Draw(UCanvas* Canvas); } var GUIEditBox MyEditBox; var GUISpinnerButton MyPlus; var GUISpinnerButton MyMinus; var(GUINumericEdit) config int Value "Value of this edit box"; var(GUINumericEdit) config bool bLeftJustified "Is the text left justified"; var(GUINumericEdit) config int MinValue "Minimum value allowed"; var(GUINumericEdit) config int MaxValue "Maximum value allowed"; var(GUINumericEdit) config int Step "Step to use for additive/subtractive increments"; var(GUINumericEdit) config bool bDisplayAsTime "If true, will convert the display string to a time display (assumes time entered in seconds)"; var(GUINumericEdit) config bool bReadOnly "If true, will not allow the user to edit this box"; function OnConstruct(GUIController MyController) { Super.OnConstruct(MyController); MyEditBox=GUIEditBox(AddComponent( "GUI.GUIEditBox" , self.Name$"_EditBox")); if( !bReadOnly ) { MyPlus=GUISpinnerButton(AddComponent( "GUI.GUISpinnerButton" , self.Name$"_Plus")); MyMinus=GUISpinnerButton(AddComponent( "GUI.GUISpinnerButton" , self.Name$"_Minus")); } } function InitComponent(GUIComponent MyOwner) { Super.InitComponent(MyOwner); MyEditBox.SetText(""); MyEditBox.bIntOnly=true; if( !bReadOnly ) { MyPlus.PlusButton=true; MyMinus.PlusButton=false; } MyEditBox.OnChange = EditOnChange; if( bDisplayAsTime || bReadOnly ) MyEditBox.bReadOnly = true; SetValue(Value); MyEditBox.OnKeyEvent = EditKeyEvent; CalcMaxLen(); if( !bReadOnly ) { MyPlus.OnClick = SpinnerPlusClick; MyPlus.SetFocusInstead(MyEditBox); MyMinus.OnClick = SpinnerMinusClick; MyMinus.SetFocusInstead(MyEditBox); } SetHint(Hint); } function CalcMaxLen() { local int digitcount,x; digitcount=1; x=10; while (x<MaxValue) { digitcount++; x*=10; } MyEditBox.MaxWidth = DigitCount; } function SetMinValue(int inMin) { MinValue = inMin; //change Value if it is no longer in [MinValue, MaxValue] SetValue(Value); } function SetMaxValue(int inMax) { MaxValue = inMax; //change Value if it is no longer in [MinValue, MaxValue] SetValue(Value); } function SetValue(int V, optional bool bForceCallbacks) { local String TimeStr; local int hours, mins, secs; if (V<MinValue) V=MinValue; if (V>MaxValue) V=MaxValue; if (!bForceCallbacks && Value == V) return; Value = V; if( bDisplayAsTime ) { hours = V/3600; mins = (V%3600)/60; secs = V%60; TimeStr = "" $ secs; if( mins > 0 || hours > 0 ) { if( secs < 10 ) TimeStr = "0" $ TimeStr; TimeStr = mins $ ":" $ TimeStr; } if( hours > 0 ) { if( mins < 10 ) TimeStr = "0" $ TimeStr; TimeStr = hours $ ":" $ TimeStr; } MyEditBox.SetText(TimeStr); } else MyEditBox.SetText(""$V); } function SpinnerPlusClick(GUIComponent Sender) { SetValue(Value + Step); } function SpinnerMinusClick(GUIComponent Sender) { SetValue(Value - Step); } function bool EditKeyEvent(out byte Key, out byte State, float delta) { if ( (key==0xEC) && (State==3) ) { SpinnerPlusClick(none); return true; } if ( (key==0xED) && (State==3) ) { SpinnerMinusClick(none); return true; } return MyEditBox.InternalOnKeyEvent(Key,State,Delta); } function EditOnChange(GUIComponent Sender) { if( !bDisplayAsTime ) Value = int(MyEditBox.GetText()); OnChange(Sender); } function SetHint(string NewHint) { local int i; Super.SetHint(NewHint); for (i=0;i<Controls.Length;i++) Controls[i].SetHint(NewHint); } defaultproperties { Value=0 Step=1 bAcceptsInput=true; bLeftJustified=false; WinHeight=0.06 PropagateVisibility=true MaxValue=9999 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |