Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
UIDistribution.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2
3public class UIDistribution : EMono
4{
5 public Card container;
6
7 public UIList list;
8
10
11 public bool needRefresh;
12
13 private void OnEnable()
14 {
15 if (needRefresh)
16 {
17 needRefresh = false;
18 Refresh();
19 }
20 }
21
22 public void SetContainer(Card t, Window.SaveData d)
23 {
24 container = t;
25 data = d;
26 needRefresh = true;
27 this.SetActive(enable: false);
28 }
29
30 public void Refresh()
31 {
32 HashSet<int> cats = data.cats;
33 list.callbacks = new UIList.Callback<SourceCategory.Row, ButtonCategory>
34 {
35 onClick = delegate(SourceCategory.Row a, ButtonCategory b)
36 {
37 if (a.children.Count > 0)
38 {
39 b.buttonFold.onClick.Invoke();
40 }
41 },
42 onInstantiate = delegate(SourceCategory.Row a, ButtonCategory b)
43 {
44 b.uid = a.uid;
45 b.mainText.text = a.GetName().ToTitleCase();
46 bool flag3 = false;
47 foreach (int item in cats)
48 {
49 if (a.Contatin(item))
50 {
51 flag3 = true;
52 break;
53 }
54 }
55 b.SetFold(a.children.Count > 0, !flag3, delegate(UIList l)
56 {
57 foreach (SourceCategory.Row child in a.children)
58 {
59 l.Add(child);
60 }
61 });
62 b.buttonToggle.icon.SetActive(cats.Contains(a.uid));
63 b.buttonToggle.SetOnClick(delegate
64 {
65 bool flag4 = !cats.Contains(a.uid);
66 b.buttonToggle.icon.SetActive(flag4);
67 if (flag4)
68 {
69 cats.Add(a.uid);
70 }
71 else
72 {
73 cats.Remove(a.uid);
74 }
75 SetAll(a.uid, flag4);
76 SE.Click();
77 });
78 },
79 onRefresh = null
80 };
81 foreach (SourceCategory.Row row2 in EMono.sources.categories.rows)
82 {
83 if (row2.parent == null && row2.id != "new" && row2.id != "none")
84 {
85 list.Add(row2);
86 }
87 }
88 list.Refresh();
89 void SetAll(int uid, bool enable)
90 {
91 SourceCategory.Row row = EMono.sources.categories.rows.Find((SourceCategory.Row a) => a.uid == uid);
92 if (row != null)
93 {
94 foreach (SourceCategory.Row row3 in EMono.sources.categories.rows)
95 {
96 if (row.Contatin(row3.uid))
97 {
98 if (enable)
99 {
100 cats.Add(row3.uid);
101 }
102 else
103 {
104 cats.Remove(row3.uid);
105 }
106 }
107 else if (row.IsChildOf(row3.uid) && enable)
108 {
109 cats.Add(row3.uid);
110 }
111 }
112 bool flag;
113 do
114 {
115 flag = true;
116 foreach (SourceCategory.Row row4 in EMono.sources.categories.rows)
117 {
118 if (row4.children.Count != 0 && cats.Contains(row4.uid))
119 {
120 bool flag2 = false;
121 foreach (int item2 in cats)
122 {
123 if (item2 != row4.uid && row4.Contatin(item2))
124 {
125 flag2 = true;
126 break;
127 }
128 }
129 if (!flag2)
130 {
131 cats.Remove(row4.uid);
132 flag = false;
133 }
134 }
135 }
136 }
137 while (!flag);
138 ButtonCategory[] componentsInChildren = list.GetComponentsInChildren<ButtonCategory>();
139 foreach (ButtonCategory buttonCategory in componentsInChildren)
140 {
141 buttonCategory.buttonToggle.icon.SetActive(cats.Contains(buttonCategory.uid));
142 }
143 }
144 }
145 }
146}
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
UIButton buttonFold
UIButton buttonToggle
void SetFold(bool show, bool folded)
Definition: Card.cs:11
Definition: EMono.cs:4
static SourceManager sources
Definition: EMono.cs:41
bool Contatin(int _uid)
List< Row > children
bool IsChildOf(string id)
SourceCategory categories
Image icon
Definition: UIButton.cs:110
void SetContainer(Card t, Window.SaveData d)
Window.SaveData data
Definition: UIList.cs:9
override void Add(object item)
Definition: UIList.cs:302
virtual void Refresh(bool highlightLast=false)
Definition: UIList.cs:424
Definition: Window.cs:13