Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
UIDynamicList Class Reference
Inheritance diagram for UIDynamicList:
BaseList

Classes

class  Row
 

Public Member Functions

Row NewRow ()
 
override void Clear ()
 
override void Add (object o)
 
void RemoveObj (object o)
 
void AddHeader (Action< UIItem > onSetHeader)
 
void Refresh ()
 
int GetIndex (object o)
 
void UpdateRow (DSVRow dsvRow, int index)
 
override void Redraw ()
 
override void List ()
 
override void List (UIList.SortMode m)
 
void OnResizeWindow ()
 
void Select< T > (Func< T, bool > func, bool invoke=false)
 
bool Select (object o, bool invoke=false)
 
bool RefreshHighlight (bool invoke=false)
 
void Scroll (int index=0)
 
void Scroll (object o)
 
GetComp< T > (object o)
 
- Public Member Functions inherited from BaseList
virtual void NextSort ()
 
virtual void List ()
 
virtual void List (UIList.SortMode sort)
 
virtual void Redraw ()
 
virtual void Clear ()
 
virtual void Add (object o)
 
void RefreshNoItem ()
 
void RefreshBGGrid ()
 

Public Attributes

DynamicScrollView dsv
 
Transform moldItem
 
Transform moldHeader
 
int columns = 1
 
bool autoSize = true
 
bool captureScreen = true
 
bool refreshHighlight = true
 
bool rebuildLayout = true
 
bool useGrid
 
bool useHighlight
 
List< Rowrows = new List<Row>()
 
List< object > objects = new List<object>()
 
object selectedObject
 
float minHeight
 
bool first = true
 
- Public Attributes inherited from BaseList
UIList.BGType bgType
 
Vector2 bgFix
 
Vector2 bgUvFix = Vector2.one
 
UIList.ICallback callbacks
 
UIList.SortMode[] sorts
 
Action onBeforeRedraw
 
Action onAfterRedraw
 
bool useDefaultNoItem = true
 
bool numbering
 
SkinType skinType
 
RawImage bgGrid
 
UIList.SortMode sortMode
 
bool isBuilt
 

Properties

override int ItemCount [get]
 
override int RowCount [get]
 
- Properties inherited from BaseList
virtual int ItemCount [get]
 
virtual int RowCount [get]
 
SkinRootStatic Skin [get]
 

Private Member Functions

void _Add (object o)
 

Private Attributes

bool autoSized
 

Additional Inherited Members

- Protected Attributes inherited from BaseList
Transform transNoItem
 

Detailed Description

Definition at line 7 of file UIDynamicList.cs.

Member Function Documentation

◆ _Add()

void UIDynamicList._Add ( object  o)
inlineprivate

Definition at line 80 of file UIDynamicList.cs.

81 {
82 if (autoSize && !autoSized)
83 {
84 autoSized = true;
85 this.RebuildLayoutTo<Layer>();
86 GridLayoutGroup component = dsv.itemPrototype.GetComponent<GridLayoutGroup>();
87 columns = (int)(this.Rect().rect.width / (component.spacing.x + component.cellSize.x));
88 if (columns < 1)
89 {
90 columns = 1;
91 }
92 }
93 if (rows.Count == 0)
94 {
95 NewRow();
96 }
97 Row row = rows.LastItem();
98 if (row.objects.Count >= columns)
99 {
100 row = NewRow();
101 }
102 row.objects.Add(o);
103 }
List< Row > rows
DynamicScrollView dsv

References autoSize, autoSized, columns, dsv, Mosframe.DynamicScrollView.itemPrototype, NewRow(), UIDynamicList.Row.objects, and rows.

Referenced by List().

◆ Add()

◆ AddHeader()

void UIDynamicList.AddHeader ( Action< UIItem onSetHeader)
inline

Definition at line 109 of file UIDynamicList.cs.

110 {
111 Row row = NewRow();
112 row.isHeader = true;
113 row.onSetHeader = onSetHeader;
114 NewRow();
115 }

References NewRow().

◆ Clear()

override void UIDynamicList.Clear ( )
inlinevirtual

◆ GetComp< T >()

T UIDynamicList.GetComp< T > ( object  o)
inline
Type Constraints
T :Component 

Definition at line 383 of file UIDynamicList.cs.

383 : Component
384 {
385 foreach (DSVRow container in dsv.containers)
386 {
387 foreach (DSVRow.Item item in container.items)
388 {
389 if (item.obj == o)
390 {
391 return item.comp as T;
392 }
393 }
394 }
395 return null;
396 }
Definition: DSVRow.cs:7
List< Item > items
Definition: DSVRow.cs:15
LinkedList< DSVRow > containers

References Mosframe.DynamicScrollView.containers, dsv, item, and DSVRow.items.

◆ GetIndex()

int UIDynamicList.GetIndex ( object  o)
inline

Definition at line 135 of file UIDynamicList.cs.

136 {
137 for (int i = 0; i < rows.Count; i++)
138 {
139 for (int j = 0; j < rows[i].objects.Count; j++)
140 {
141 if (rows[i].objects[j] == o)
142 {
143 return i;
144 }
145 }
146 }
147 return -1;
148 }

References objects, and rows.

Referenced by BuildMenu.Select().

◆ List() [1/2]

◆ List() [2/2]

override void UIDynamicList.List ( UIList::SortMode  m)
inlinevirtual

Reimplemented from BaseList.

Definition at line 240 of file UIDynamicList.cs.

241 {
242 if (!first && captureScreen)
243 {
245 }
246 first = false;
247 sortMode = m;
248 Clear();
249 callbacks.OnList(sortMode);
250 foreach (object @object in objects)
251 {
252 _Add(@object);
253 }
254 Layer root = base.transform.GetComponentInParent<Layer>();
255 root = root.parent?.GetComponent<Layer>() ?? root;
256 if (objects.Count != 0)
257 {
259 {
261 UIButton.TryShowTip(root.transform);
263 {
265 UIButton.TryShowTip(root.transform);
266 if (captureScreen)
267 {
269 {
271 });
272 }
273 });
274 }
275 }
276 else
277 {
279 }
280 Refresh();
281 }
virtual void FreezeScreen(float duration=0.3f)
Definition: BaseCore.cs:80
void WaitForEndOfFrame(Action action)
Definition: BaseCore.cs:61
virtual void UnfreezeScreen()
Definition: BaseCore.cs:84
static BaseCore Instance
Definition: BaseCore.cs:11
UIList.ICallback callbacks
Definition: BaseList.cs:13
Definition: Layer.cs:9
Layer parent
Definition: Layer.cs:104
static TooltipManager Instance
void HideTooltips(bool immediate=false)
static void TryHihlight()
Definition: UIButton.cs:768
static void TryShowTip(Transform root=null, bool highlight=true, bool ignoreWhenRightClick=true)
Definition: UIButton.cs:778
void _Add(object o)
override void Clear()
bool refreshHighlight

References _Add(), BaseList.callbacks, captureScreen, Clear(), first, BaseCore.FreezeScreen(), TooltipManager.HideTooltips(), BaseCore.Instance, TooltipManager.Instance, objects, Layer.parent, Refresh(), refreshHighlight, BaseList.sortMode, UIButton.TryHihlight(), UIButton.TryShowTip(), BaseCore.UnfreezeScreen(), and BaseCore.WaitForEndOfFrame().

◆ NewRow()

Row UIDynamicList.NewRow ( )
inline

Definition at line 55 of file UIDynamicList.cs.

56 {
57 Row row = new Row();
58 rows.Add(row);
59 return row;
60 }

References rows.

Referenced by _Add(), and AddHeader().

◆ OnResizeWindow()

void UIDynamicList.OnResizeWindow ( )
inline

Definition at line 283 of file UIDynamicList.cs.

284 {
285 if (autoSize)
286 {
287 this.RebuildLayoutTo<Layer>();
288 GridLayoutGroup component = dsv.itemPrototype.GetComponent<GridLayoutGroup>();
289 columns = (int)(this.Rect().rect.width / (component.spacing.x + component.cellSize.x));
290 if (columns < 1)
291 {
292 columns = 1;
293 }
294 List();
295 dsv.OnResize();
296 }
297 }

References autoSize, columns, dsv, Mosframe.DynamicScrollView.itemPrototype, List(), and Mosframe.DynamicScrollView.OnResize().

Referenced by Window.Update().

◆ Redraw()

override void UIDynamicList.Redraw ( )
inlinevirtual

◆ Refresh()

void UIDynamicList.Refresh ( )
inline

Definition at line 117 of file UIDynamicList.cs.

118 {
119 dsv.prevTotalItemCount = -1;
120 dsv.totalItemCount = rows.Count;
121 this.RebuildLayoutTo<Layer>();
122 if (!isBuilt)
123 {
124 dsv.Build();
125 isBuilt = true;
126 }
127 else
128 {
129 dsv.Update();
130 }
133 }
void RefreshNoItem()
Definition: BaseList.cs:69
bool isBuilt
Definition: BaseList.cs:36
void RefreshBGGrid()
Definition: BaseList.cs:89

References Mosframe.DynamicScrollView.Build(), dsv, BaseList.isBuilt, BaseList.RefreshBGGrid(), BaseList.RefreshNoItem(), rows, and Mosframe.DynamicScrollView.Update().

Referenced by List(), and BuildMenu.Select().

◆ RefreshHighlight()

bool UIDynamicList.RefreshHighlight ( bool  invoke = false)
inline

Definition at line 325 of file UIDynamicList.cs.

326 {
327 bool result = false;
328 foreach (DSVRow container in dsv.containers)
329 {
330 foreach (DSVRow.Item item in container.items)
331 {
332 UIButton b = item.comp as UIButton;
333 if (b == null || !b.gameObject.activeInHierarchy)
334 {
335 continue;
336 }
337 b.selected = item.obj == selectedObject;
338 if (b.selected)
339 {
341 {
342 if (b != null)
343 {
345 b.DoHighlightTransition(instant: true);
346 }
347 });
348 result = true;
349 b.DoHighlightTransition(instant: true);
350 if (invoke)
351 {
352 callbacks.OnClick(item.obj, item.comp);
353 }
354 }
355 else
356 {
358 }
359 }
360 }
361 return result;
362 }
List< Action > actionsNextFrame
Definition: BaseCore.cs:31
void DoHighlightTransition(bool instant=false)
Definition: UIButton.cs:526
bool selected
Definition: UIButton.cs:163
void DoNormalTransition(bool instant=true)
Definition: UIButton.cs:531
object selectedObject

References BaseCore.actionsNextFrame, BaseList.callbacks, Mosframe.DynamicScrollView.containers, UIButton.DoHighlightTransition(), UIButton.DoNormalTransition(), dsv, BaseCore.Instance, item, DSVRow.items, UIButton.selected, and selectedObject.

Referenced by BuildMenu.Refresh(), and Select().

◆ RemoveObj()

void UIDynamicList.RemoveObj ( object  o)
inline

Definition at line 105 of file UIDynamicList.cs.

106 {
107 }

◆ Scroll() [1/2]

void UIDynamicList.Scroll ( int  index = 0)
inline

Definition at line 364 of file UIDynamicList.cs.

365 {
366 if (index <= 0)
367 {
368 dsv.contentAnchoredPosition = 0f;
369 }
370 else
371 {
372 dsv.scrollByItemIndex(index);
373 }
374 dsv.refresh();
375 }
void scrollByItemIndex(int itemIndex)

References dsv, Mosframe.DynamicScrollView.refresh(), and Mosframe.DynamicScrollView.scrollByItemIndex().

Referenced by BuildMenu.RefreshCategory(), LayerCraft.RefreshCategory(), and Scroll().

◆ Scroll() [2/2]

void UIDynamicList.Scroll ( object  o)
inline

Definition at line 377 of file UIDynamicList.cs.

378 {
379 int index = objects.IndexOf(o);
380 Scroll(index);
381 }
void Scroll(int index=0)

References objects, and Scroll().

◆ Select()

bool UIDynamicList.Select ( object  o,
bool  invoke = false 
)
inline

◆ Select< T >()

void UIDynamicList.Select< T > ( Func< T, bool >  func,
bool  invoke = false 
)
inline

Definition at line 299 of file UIDynamicList.cs.

300 {
301 foreach (DSVRow container in dsv.containers)
302 {
303 foreach (DSVRow.Item item in container.items)
304 {
305 UIButton uIButton = item.comp as UIButton;
306 if (!(uIButton == null) && uIButton.gameObject.activeInHierarchy)
307 {
308 T arg = (T)item.obj;
309 if (func(arg))
310 {
311 Select(item.obj, invoke);
312 return;
313 }
314 }
315 }
316 }
317 }
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
bool Select(object o, bool invoke=false)

References Mosframe.DynamicScrollView.containers, dsv, if(), item, DSVRow.items, and Select().

◆ UpdateRow()

void UIDynamicList.UpdateRow ( DSVRow  dsvRow,
int  index 
)
inline

Definition at line 150 of file UIDynamicList.cs.

151 {
152 Row row = rows[index];
153 for (int i = 0; i < columns; i++)
154 {
155 if (dsvRow.items.Count <= i)
156 {
157 dsvRow.items.Add(new DSVRow.Item
158 {
159 comp = callbacks.GetComponent(Util.Instantiate(moldItem, dsvRow.transform).transform)
160 });
161 }
162 Component comp = dsvRow.items[i].comp;
163 bool flag = !row.isHeader && row.objects.Count > i;
164 comp.SetActive(flag);
165 dsvRow.items[i].obj = null;
166 if (!flag)
167 {
168 continue;
169 }
170 object obj = row.objects[i];
171 dsvRow.items[i].obj = obj;
172 callbacks.OnRedraw(obj, comp, columns * index + i);
173 UIButton uIButton = comp as UIButton;
174 if (!uIButton)
175 {
176 uIButton = (comp as UIItem)?.button1;
177 }
178 if ((bool)uIButton && callbacks.useOnClick)
179 {
180 uIButton.onClick.RemoveAllListeners();
181 uIButton.onClick.AddListener(delegate
182 {
183 callbacks.OnClick(obj, comp);
184 });
185 }
186 if (useHighlight)
187 {
188 uIButton.selected = obj == selectedObject;
189 if (uIButton.selected)
190 {
191 uIButton.DoHighlightTransition(instant: true);
192 }
193 else
194 {
195 uIButton.DoNormalTransition();
196 }
197 }
198 }
199 if (dsvRow.items.Count > columns)
200 {
201 for (int j = columns; j < dsvRow.items.Count; j++)
202 {
203 dsvRow.items[j].comp.SetActive(enable: false);
204 dsvRow.items[j].obj = null;
205 }
206 }
207 if ((bool)dsvRow.itemHeader)
208 {
209 if (row.isHeader)
210 {
211 dsvRow.itemHeader.SetActive(enable: true);
212 row.onSetHeader(dsvRow.itemHeader);
213 }
214 else
215 {
216 dsvRow.itemHeader.SetActive(enable: false);
217 }
218 }
219 if ((bool)dsvRow.bgGrid)
220 {
221 dsvRow.bgGrid.SetActive(useGrid);
222 }
223 if (useGrid)
224 {
225 dsvRow.bgGrid.Rect().sizeDelta = new Vector2((float)row.objects.Count * dsvRow.GetComponent<GridLayoutGroup>().cellSize.x, 0f);
226 dsvRow.bgGrid.uvRect = new Rect(0f, 0f, row.objects.Count, 1f);
227 }
228 }
UIItem itemHeader
Definition: DSVRow.cs:17
RawImage bgGrid
Definition: DSVRow.cs:19
Definition: UIItem.cs:5

References DSVRow.bgGrid, BaseList.callbacks, columns, UIButton.DoHighlightTransition(), UIButton.DoNormalTransition(), UIDynamicList.Row.isHeader, DSVRow.itemHeader, DSVRow.items, UIDynamicList.Row.objects, UIDynamicList.Row.onSetHeader, rows, UIButton.selected, selectedObject, useGrid, and useHighlight.

Referenced by Mosframe.DynamicScrollView.updateItem().

Member Data Documentation

◆ autoSize

bool UIDynamicList.autoSize = true

Definition at line 26 of file UIDynamicList.cs.

Referenced by _Add(), and OnResizeWindow().

◆ autoSized

bool UIDynamicList.autoSized
private

Definition at line 49 of file UIDynamicList.cs.

Referenced by _Add().

◆ captureScreen

bool UIDynamicList.captureScreen = true

Definition at line 28 of file UIDynamicList.cs.

Referenced by List().

◆ columns

int UIDynamicList.columns = 1

Definition at line 24 of file UIDynamicList.cs.

Referenced by _Add(), OnResizeWindow(), and UpdateRow().

◆ dsv

◆ first

bool UIDynamicList.first = true

Definition at line 47 of file UIDynamicList.cs.

Referenced by List().

◆ minHeight

float UIDynamicList.minHeight

Definition at line 44 of file UIDynamicList.cs.

◆ moldHeader

Transform UIDynamicList.moldHeader

Definition at line 22 of file UIDynamicList.cs.

◆ moldItem

Transform UIDynamicList.moldItem

Definition at line 20 of file UIDynamicList.cs.

◆ objects

List<object> UIDynamicList.objects = new List<object>()

◆ rebuildLayout

bool UIDynamicList.rebuildLayout = true

Definition at line 32 of file UIDynamicList.cs.

◆ refreshHighlight

bool UIDynamicList.refreshHighlight = true

Definition at line 30 of file UIDynamicList.cs.

Referenced by List().

◆ rows

List<Row> UIDynamicList.rows = new List<Row>()

◆ selectedObject

object UIDynamicList.selectedObject

Definition at line 42 of file UIDynamicList.cs.

Referenced by RefreshHighlight(), Select(), and UpdateRow().

◆ useGrid

bool UIDynamicList.useGrid

Definition at line 34 of file UIDynamicList.cs.

Referenced by UpdateRow().

◆ useHighlight

bool UIDynamicList.useHighlight

Definition at line 36 of file UIDynamicList.cs.

Referenced by UpdateRow().

Property Documentation

◆ ItemCount

override int UIDynamicList.ItemCount
get

Definition at line 51 of file UIDynamicList.cs.

Referenced by LayerCraftFloat.RefreshSize().

◆ RowCount

override int UIDynamicList.RowCount
get

Definition at line 53 of file UIDynamicList.cs.


The documentation for this class was generated from the following file: