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 |
//============================================================================== // Created on: 11/15/2003 // Specialized array property page for dynamic arrays // // Written by Ron Prestenback // © 2003, Epic Games, Inc. All Rights Reserved //============================================================================== class GUIDynArrayPage extends GUIArrayPropPage; struct ArrayControl { var() GUIButton b_New; var() GUIButton b_Remove; }; var() array<ArrayControl> ArrayButton; var() string SizingCaption; var() localized string NewText, RemoveText; function InitComponent(GUIController MyController, GUIComponent MyOwner) { Super.InitComponent(MyController, MyOwner); li_Values.OnAdjustTop = InternalOnAdjustTop; SizingCaption = RemoveText; } // Create buttons and controls for array members function InitializeList() { local int i; local float AW, AL, Y; // ItemsPerPage is set in PreDraw, so if li_Values hasn't received a call to PreDraw() yet, stop here if ( !li_Values.bPositioned ) return; bListInitialized = True; // Unset bInit so that InternalOnPreDraw won't call InitializeList() again if (Item.RenderType == PIT_Check) MOType = "XInterface.moCheckBox"; else if (Item.RenderType == PIT_Select) MOType = "XInterface.moComboBox"; AW = li_Values.ActualWidth(); AL = li_Values.ActualLeft(); Clear(); for (i = 0; i < PropValue.Length; i++) AddListItem(i); ArrayButton.Length = li_Values.ItemsPerPage; Y = li_Values.ClientBounds[1]; for (i = 0; i < li_Values.ItemsPerPage; i++) { ArrayButton[i] = AddButton(i); ArrayButton[i].b_New.WinLeft = ArrayButton[i].b_New.RelativeLeft((AL + AW) + 5); ArrayButton[i].b_Remove.WinLeft = ArrayButton[i].b_New.WinLeft; ArrayButton[i].b_New.WinTop = ArrayButton[i].b_New.RelativeTop(Y); ArrayButton[i].b_Remove.WinTop = ArrayButton[i].b_Remove.RelativeTop(Y); Y += li_Values.ItemHeight; } UpdateListCaptions(); UpdateListValues(); UpdateButtons(); RemapComponents(); } function ArrayControl AddButton(int Index) { local ArrayControl AC; AC.b_New = GUIButton(AddComponent("XInterface.GUIButton",True)); AC.b_New.TabOrder = Index+1; AC.b_New.Tag = Index; AC.b_New.OnClick = InternalOnClick; AC.b_New.Caption = NewText; AC.b_New.SizingCaption = SizingCaption; AC.b_Remove = GUIButton(AddComponent("XInterface.GUIButton",True)); AC.b_Remove.TabOrder = Index+1; AC.b_Remove.Tag = Index; AC.b_Remove.OnClick = InternalOnClick; AC.b_Remove.Caption = RemoveText; AC.b_Remove.SizingCaption = SizingCaption; return AC; } function Clear() { local int i; for (i = 0; i < ArrayButton.Length; i++) { RemoveComponent(ArrayButton[i].b_New, True); RemoveComponent(ArrayButton[i].b_Remove, True); } ArrayButton.Remove(0, ArrayButton.Length); Super.Clear(); RemapComponents(); } // Resets the button captions and roles to correspond to the currently displayed array members // (Makes sure that the last button says "New" while all others say "Remove" function UpdateButtons() { local int i, j; j = li_Values.Top; for (i = 0; i < ArrayButton.Length; i++) { SetElementState(i, j == li_Values.Elements.Length && j < li_Values.Top + li_Values.ItemsPerPage, j < li_Values.Elements.Length && j < li_Values.Top + li_Values.ItemsPerPage); SetElementCaption(i, j); j++; } } protected function SetElementState(int Index, bool bNewOn, bool bRemoveOn) { if (Index < 0 || Index >= ArrayButton.Length) return; ArrayButton[Index].b_New.TabOrder = Index + 1; ArrayButton[Index].b_Remove.TabOrder = Index + 1; if (ArrayButton[Index].b_New.bVisible != bNewOn) ArrayButton[Index].b_New.SetVisibility(bNewOn); if (ArrayButton[Index].b_Remove.bVisible != bRemoveOn) ArrayButton[Index].b_Remove.SetVisibility(bRemoveOn); if (bNewOn) EnableComponent(ArrayButton[Index].b_New); else DisableComponent(ArrayButton[Index].b_New); if (bRemoveOn) EnableComponent(ArrayButton[Index].b_Remove); else DisableComponent(ArrayButton[Index].b_Remove); } protected function SetElementCaption(int ButtonArrayIndex, int ListElementIndex) { ArrayButton[ButtonArrayIndex].b_New.Caption = NewText; ArrayButton[ButtonArrayIndex].b_New.Tag = ListElementIndex; ArrayButton[ButtonArrayIndex].b_Remove.Caption = RemoveText; ArrayButton[ButtonArrayIndex].b_Remove.Tag = ListElementIndex; } function bool InternalOnClick(GUIComponent Sender) { local int i; if ( Super.InternalOnClick(Sender) ) return true; if (GUIButton(Sender) != None) { for (i = 0; i < ArrayButton.Length; i++) { if (Sender == ArrayButton[i].b_New) { PropValue.Insert(ArrayButton[i].b_New.Tag, 1); AddListItem(ArrayButton[i].b_New.Tag).SetFocus(None); break; } if (Sender == ArrayButton[i].b_Remove) { if (ArrayButton[i].b_Remove.Tag != -1 && ArrayButton[i].b_Remove.Tag < li_Values.Elements.Length) { li_Values.RemoveItem(ArrayButton[i].b_Remove.Tag); PropValue.Remove(ArrayButton[i].b_Remove.Tag, 1); } break; } } if (i < ArrayButton.Length) { UpdateListCaptions(); UpdateButtons(); RemapComponents(); } } return false; } function InternalOnAdjustTop(GUIComponent Sender) { UpdateButtons(); li_Values.InternalOnAdjustTop(Sender); } function bool FloatingPreDraw(Canvas C) { local float XL, YL, XL2, YL2; if ( bInit ) { b_OK.Style.TextSize(C, MSAT_Blurry, NewText, XL, YL, FNS_Medium); b_OK.Style.TextSize(C, MSAT_Blurry, RemoveText, XL2, YL2, FNS_Medium); if ( XL > XL2 ) SizingCaption = NewText; else SizingCaption = RemoveText; } return Super.FloatingPreDraw(C); } defaultproperties { NewText="New" RemoveText="Remove" } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |