Elin Decompiled Documentation EA 23.288 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 Remove (object o)
 
override void AddDynamic (object item)
 
override void RemoveDynamic (object item)
 
override void OnMove (object o, object select=null)
 
override bool Contains (object item)
 
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)
 
virtual void AddDynamic (object item)
 
virtual void RemoveDynamic (object item)
 
virtual bool Contains (object item)
 
virtual void OnMove (object o, object select=null)
 
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
 
Func< object, bool > funcFilter
 
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 82 of file UIDynamicList.cs.

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

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

Referenced by List().

◆ Add()

◆ AddDynamic()

override void UIDynamicList.AddDynamic ( object  item)
inlinevirtual

Reimplemented from BaseList.

Definition at line 115 of file UIDynamicList.cs.

116 {
117 Add(item);
118 Refresh();
119 }
override void Add(object o)

References Add(), item, and Refresh().

◆ AddHeader()

void UIDynamicList.AddHeader ( Action< UIItem onSetHeader)
inline

Definition at line 141 of file UIDynamicList.cs.

142 {
143 Row row = NewRow();
144 row.isHeader = true;
145 row.onSetHeader = onSetHeader;
146 NewRow();
147 }

References NewRow().

◆ Clear()

override void UIDynamicList.Clear ( )
inlinevirtual

◆ Contains()

override bool UIDynamicList.Contains ( object  item)
inlinevirtual

Reimplemented from BaseList.

Definition at line 136 of file UIDynamicList.cs.

137 {
138 return objects.Contains(item);
139 }

References item, and objects.

◆ GetComp< T >()

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

Definition at line 432 of file UIDynamicList.cs.

432 : Component
433 {
434 foreach (DSVRow container in dsv.containers)
435 {
436 foreach (DSVRow.Item item in container.items)
437 {
438 if (item.obj == o)
439 {
440 return item.comp as T;
441 }
442 }
443 }
444 return null;
445 }
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 167 of file UIDynamicList.cs.

168 {
169 for (int i = 0; i < rows.Count; i++)
170 {
171 for (int j = 0; j < rows[i].objects.Count; j++)
172 {
173 if (rows[i].objects[j] == o)
174 {
175 return i;
176 }
177 }
178 }
179 return -1;
180 }

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 272 of file UIDynamicList.cs.

273 {
274 if (!first && captureScreen)
275 {
277 }
278 first = false;
279 sortMode = m;
280 Clear();
281 callbacks.OnList(sortMode);
282 if (callbacks.useSort)
283 {
284 objects.Sort((object a, object b) => callbacks.OnSort(b, sortMode) - callbacks.OnSort(a, sortMode));
285 }
286 if (funcFilter != null)
287 {
288 foreach (object @object in objects)
289 {
290 if (funcFilter(@object))
291 {
292 _Add(@object);
293 }
294 }
295 }
296 else
297 {
298 foreach (object object2 in objects)
299 {
300 _Add(object2);
301 }
302 }
303 Layer root = base.transform.GetComponentInParent<Layer>();
304 root = root.parent?.GetComponent<Layer>() ?? root;
305 if (objects.Count != 0)
306 {
308 {
310 UIButton.TryShowTip(root.transform);
312 {
314 UIButton.TryShowTip(root.transform);
315 if (captureScreen)
316 {
318 {
320 });
321 }
322 });
323 }
324 }
325 else
326 {
328 }
329 Refresh();
330 }
void WaitForEndOfFrame(Action action)
Definition: BaseCore.cs:61
virtual void UnfreezeScreen()
Definition: BaseCore.cs:84
static BaseCore Instance
Definition: BaseCore.cs:11
virtual void FreezeScreen(float duration=0.2f)
Definition: BaseCore.cs:80
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
Func< object, bool > funcFilter
void _Add(object o)
override void Clear()
bool refreshHighlight

References _Add(), BaseList.callbacks, captureScreen, Clear(), first, BaseCore.FreezeScreen(), funcFilter, 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 57 of file UIDynamicList.cs.

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

References rows.

Referenced by _Add(), and AddHeader().

◆ OnMove()

override void UIDynamicList.OnMove ( object  o,
object  select = null 
)
inlinevirtual

Reimplemented from BaseList.

Definition at line 128 of file UIDynamicList.cs.

129 {
131 List();
132 Select(select ?? o);
133 SE.Click();
134 }
bool Select(object o, bool invoke=false)

References BaseCore.FreezeScreen(), BaseCore.Instance, List(), and Select().

◆ OnResizeWindow()

void UIDynamicList.OnResizeWindow ( )
inline

Definition at line 332 of file UIDynamicList.cs.

333 {
334 if (autoSize)
335 {
336 this.RebuildLayoutTo<Layer>();
337 GridLayoutGroup component = dsv.itemPrototype.GetComponent<GridLayoutGroup>();
338 columns = (int)(this.Rect().rect.width / (component.spacing.x + component.cellSize.x));
339 if (columns < 1)
340 {
341 columns = 1;
342 }
343 List();
344 dsv.OnResize();
345 }
346 }

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 149 of file UIDynamicList.cs.

150 {
151 dsv.prevTotalItemCount = -1;
152 dsv.totalItemCount = rows.Count;
153 this.RebuildLayoutTo<Layer>();
154 if (!isBuilt)
155 {
156 dsv.Build();
157 isBuilt = true;
158 }
159 else
160 {
161 dsv.Update();
162 }
165 }
void RefreshNoItem()
Definition: BaseList.cs:86
bool isBuilt
Definition: BaseList.cs:36
void RefreshBGGrid()
Definition: BaseList.cs:106

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

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

◆ RefreshHighlight()

bool UIDynamicList.RefreshHighlight ( bool  invoke = false)
inline

Definition at line 374 of file UIDynamicList.cs.

375 {
376 bool result = false;
377 foreach (DSVRow container in dsv.containers)
378 {
379 foreach (DSVRow.Item item in container.items)
380 {
381 UIButton b = item.comp as UIButton;
382 if (b == null || !b.gameObject.activeInHierarchy)
383 {
384 continue;
385 }
386 b.selected = item.obj == selectedObject;
387 if (b.selected)
388 {
390 {
391 if (b != null)
392 {
394 b.DoHighlightTransition(instant: true);
395 }
396 });
397 result = true;
398 b.DoHighlightTransition(instant: true);
399 if (invoke)
400 {
401 callbacks.OnClick(item.obj, item.comp);
402 }
403 }
404 else
405 {
407 }
408 }
409 }
410 return result;
411 }
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().

◆ Remove()

void UIDynamicList.Remove ( object  o)
inline

Definition at line 110 of file UIDynamicList.cs.

111 {
112 objects.Remove(o);
113 }

References objects.

Referenced by RemoveDynamic().

◆ RemoveDynamic()

override void UIDynamicList.RemoveDynamic ( object  item)
inlinevirtual

Reimplemented from BaseList.

Definition at line 121 of file UIDynamicList.cs.

122 {
124 Remove(item);
125 List();
126 }
void Remove(object o)

References BaseCore.FreezeScreen(), BaseCore.Instance, item, List(), and Remove().

Referenced by ListOwner< T1, T2 >.MoveToOther().

◆ Scroll() [1/2]

void UIDynamicList.Scroll ( int  index = 0)
inline

Definition at line 413 of file UIDynamicList.cs.

414 {
415 if (index <= 0)
416 {
417 dsv.contentAnchoredPosition = 0f;
418 }
419 else
420 {
421 dsv.scrollByItemIndex(index);
422 }
423 dsv.refresh();
424 }
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 426 of file UIDynamicList.cs.

427 {
428 int index = objects.IndexOf(o);
429 Scroll(index);
430 }
void Scroll(int index=0)

References objects, and Scroll().

◆ Select()

◆ Select< T >()

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

Definition at line 348 of file UIDynamicList.cs.

349 {
350 foreach (DSVRow container in dsv.containers)
351 {
352 foreach (DSVRow.Item item in container.items)
353 {
354 UIButton uIButton = item.comp as UIButton;
355 if (!(uIButton == null) && uIButton.gameObject.activeInHierarchy)
356 {
357 T arg = (T)item.obj;
358 if (func(arg))
359 {
360 Select(item.obj, invoke);
361 return;
362 }
363 }
364 }
365 }
366 }
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627

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

◆ UpdateRow()

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

Definition at line 182 of file UIDynamicList.cs.

183 {
184 Row row = rows[index];
185 for (int i = 0; i < columns; i++)
186 {
187 if (dsvRow.items.Count <= i)
188 {
189 dsvRow.items.Add(new DSVRow.Item
190 {
191 comp = callbacks.GetComponent(Util.Instantiate(moldItem, dsvRow.transform).transform)
192 });
193 }
194 Component comp = dsvRow.items[i].comp;
195 bool flag = !row.isHeader && row.objects.Count > i;
196 comp.SetActive(flag);
197 dsvRow.items[i].obj = null;
198 if (!flag)
199 {
200 continue;
201 }
202 object obj = row.objects[i];
203 dsvRow.items[i].obj = obj;
204 callbacks.OnRedraw(obj, comp, columns * index + i);
205 UIButton uIButton = comp as UIButton;
206 if (!uIButton)
207 {
208 uIButton = (comp as UIItem)?.button1;
209 }
210 if ((bool)uIButton && callbacks.useOnClick)
211 {
212 uIButton.onClick.RemoveAllListeners();
213 uIButton.onClick.AddListener(delegate
214 {
215 callbacks.OnClick(obj, comp);
216 });
217 }
218 if (useHighlight)
219 {
220 uIButton.selected = obj == selectedObject;
221 if (uIButton.selected)
222 {
223 uIButton.DoHighlightTransition(instant: true);
224 }
225 else
226 {
227 uIButton.DoNormalTransition();
228 }
229 }
230 }
231 if (dsvRow.items.Count > columns)
232 {
233 for (int j = columns; j < dsvRow.items.Count; j++)
234 {
235 dsvRow.items[j].comp.SetActive(enable: false);
236 dsvRow.items[j].obj = null;
237 }
238 }
239 if ((bool)dsvRow.itemHeader)
240 {
241 if (row.isHeader)
242 {
243 dsvRow.itemHeader.SetActive(enable: true);
244 row.onSetHeader(dsvRow.itemHeader);
245 }
246 else
247 {
248 dsvRow.itemHeader.SetActive(enable: false);
249 }
250 }
251 if ((bool)dsvRow.bgGrid)
252 {
253 dsvRow.bgGrid.SetActive(useGrid);
254 }
255 if (useGrid)
256 {
257 dsvRow.bgGrid.Rect().sizeDelta = new Vector2((float)row.objects.Count * dsvRow.GetComponent<GridLayoutGroup>().cellSize.x, 0f);
258 dsvRow.bgGrid.uvRect = new Rect(0f, 0f, row.objects.Count, 1f);
259 }
260 }
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 51 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 49 of file UIDynamicList.cs.

Referenced by List().

◆ funcFilter

Func<object, bool> UIDynamicList.funcFilter

Definition at line 46 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

◆ 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 53 of file UIDynamicList.cs.

Referenced by LayerCraftFloat.RefreshSize().

◆ RowCount

override int UIDynamicList.RowCount
get

Definition at line 55 of file UIDynamicList.cs.


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