Elin Modding Docs Doc
Loading...
Searching...
No Matches
LayerAbility.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5// Token: 0x02000521 RID: 1313
6public class LayerAbility : ELayer, IDragParent
7{
8 // Token: 0x17000B14 RID: 2836
9 // (get) Token: 0x06002338 RID: 9016 RVA: 0x000C64EB File Offset: 0x000C46EB
10 public new LayerAbility.Config config
11 {
12 get
13 {
14 return ELayer.player.layerAbilityConfig;
15 }
16 }
17
18 // Token: 0x06002339 RID: 9017 RVA: 0x000C64F8 File Offset: 0x000C46F8
19 public override void OnInit()
20 {
21 this.chara = ELayer.pc;
22 foreach (string str in this.idGroup)
23 {
24 this.windows[0].AddTab("cat_" + str, this.windows[0].CurrentContent, null, null, null);
25 }
26 LayerAbility.Instance = this;
27 this.list.sortMode = ELayer.player.pref.sortAbility;
28 if (ELayer.game.altAbility)
29 {
30 UIButton buttonSort = this.windows[0].buttonSort;
31 buttonSort.onClick.RemoveAllListeners();
32 buttonSort.onClick.AddListener(delegate()
33 {
34 UIContextMenu uicontextMenu = ELayer.ui.CreateContextMenuInteraction();
35 uicontextMenu.layoutGroup.childAlignment = TextAnchor.UpperLeft;
36 uicontextMenu.alwaysPopLeft = true;
37 UIContextMenu uicontextMenu2 = uicontextMenu.AddChild("sort", TextAnchor.UpperRight);
38 UIList.SortMode[] sorts = this.list.sorts;
39 for (int j = 0; j < sorts.Length; j++)
40 {
41 UIList.SortMode sortMode = sorts[j];
42 string str2 = (this.list.sortMode == sortMode) ? "context_checker".lang() : "";
43 UIList.SortMode _sort = sortMode;
44 uicontextMenu2.AddButton(str2 + sortMode.ToString().lang(), delegate()
45 {
46 this.list.List(_sort);
47 SE.Click();
48 }, true);
49 }
50 UIContextMenu uicontextMenu3 = uicontextMenu.AddChild("config", TextAnchor.UpperRight);
51 uicontextMenu3.AddSlider("alpha", (float a) => a.ToString() ?? "", (float)this.config.bgAlpha, delegate(float b)
52 {
53 this.config.bgAlpha = (int)b;
54 this.RefreshConfig();
55 }, 0f, 100f, true, false, false);
56 uicontextMenu3.AddToggle("autoHideBG", this.config.autoHideBG, delegate(bool a)
57 {
58 this.config.autoHideBG = a;
59 this.RefreshConfig();
60 });
61 uicontextMenu3.AddToggle("hideDepletedSpell", this.config.hideDepletedSpell, delegate(bool a)
62 {
63 this.config.hideDepletedSpell = a;
64 this.list.List();
65 });
66 uicontextMenu.Show();
67 });
68 }
69 this.windows[0].idTab = ELayer.player.pref.lastIdTabAbility;
70 this.RefreshConfig();
71 }
72
73 // Token: 0x0600233A RID: 9018 RVA: 0x000C65E0 File Offset: 0x000C47E0
74 public void RefreshConfig()
75 {
76 Window window = this.windows[0];
77 window.imageBG.color = Color.white.SetAlpha(0.01f * (float)this.config.bgAlpha);
78 window.listCgFloat.Clear();
79 if (this.config.autoHideBG)
80 {
81 window.listCgFloat.Add(window.cgBG);
82 }
83 window.cgBG.enabled = this.config.autoHideBG;
84 }
85
86 // Token: 0x0600233B RID: 9019 RVA: 0x000C6660 File Offset: 0x000C4860
87 public static void SetDirty(Element a)
88 {
89 if (LayerAbility.Instance)
90 {
91 LayerAbility.Instance.list.Redraw();
92 }
93 foreach (LayerInventory layerInventory in LayerInventory.listInv)
94 {
95 foreach (UIList.ButtonPair buttonPair in layerInventory.invs[0].list.buttons)
96 {
97 ButtonGrid buttonGrid = buttonPair.component as ButtonGrid;
98 if (buttonGrid.card != null && buttonGrid.card.trait is TraitAbility)
99 {
100 layerInventory.invs[0].list.callbacks.OnRedraw(buttonGrid.card, buttonGrid, buttonGrid.index);
101 }
102 }
103 }
104 if (WidgetCurrentTool.Instance)
105 {
106 foreach (UIList.ButtonPair buttonPair2 in WidgetCurrentTool.Instance.list.buttons)
107 {
108 ButtonGrid buttonGrid2 = buttonPair2.component as ButtonGrid;
109 if (buttonGrid2.card != null && buttonGrid2.card.trait is TraitAbility)
110 {
111 WidgetCurrentTool.Instance.list.callbacks.OnRedraw(buttonGrid2.card, buttonGrid2, buttonGrid2.index);
112 }
113 }
114 WidgetCurrentTool.RefreshCurrentHotItem();
115 }
116 }
117
118 // Token: 0x0600233C RID: 9020 RVA: 0x000C6808 File Offset: 0x000C4A08
119 public override void OnSwitchContent(Window window)
120 {
121 ELayer.player.pref.lastIdTabAbility = window.idTab;
122 this.SelectGroup(this.windows[0].setting.tabs[window.idTab].idLang.Replace("cat_", ""));
123 }
124
125 // Token: 0x0600233D RID: 9021 RVA: 0x000C6868 File Offset: 0x000C4A68
126 public override void OnUpdateInput()
127 {
128 if (EInput.middleMouse.down)
129 {
130 ButtonAbility componentOf = InputModuleEX.GetComponentOf<ButtonAbility>();
131 if (componentOf)
132 {
133 ELayer.player.SetCurrentHotItem(new HotItemAct(componentOf.source));
134 SE.SelectHotitem();
135 return;
136 }
137 }
138 base.OnUpdateInput();
139 }
140
141 // Token: 0x0600233E RID: 9022 RVA: 0x000C68B0 File Offset: 0x000C4AB0
142 public static void ClearHotElement()
143 {
144 ButtonAbility buttonAbility = LayerAbility.hotElement;
145 LayerAbility.hotElement = null;
146 LayerInventory.SetDirtyAll(false);
147 if (buttonAbility && buttonAbility.attach != null)
148 {
149 UnityEngine.Object.Destroy(buttonAbility.attach.gameObject);
150 }
151 EInput.Consume(false, 1);
152 ELayer.ui.hud.SetDragImage(null, null, null);
153 }
154
155 // Token: 0x0600233F RID: 9023 RVA: 0x000C6910 File Offset: 0x000C4B10
156 public void SelectGroup(string id)
157 {
158 this.list.Clear();
159 BaseList baseList = this.list;
160 UIList.Callback<Element, ButtonAbility> callback = new UIList.Callback<Element, ButtonAbility>();
161 callback.onClick = delegate(Element a, ButtonAbility b)
162 {
163 if (ELayer.ui.IsActive)
164 {
165 SE.BeepSmall();
166 return;
167 }
168 SE.Equip();
169 LayerAbility.hotElement = b;
170 b.attach = Util.Instantiate("UI/Element/Grid/Attach/guide_ability", b.transform);
171 LayerInventory.SetDirtyAll(false);
172 ELayer.ui.hud.SetDragImage(b.icon, null, null);
173 };
174 callback.onRedraw = delegate(Element a, ButtonAbility b, int i)
175 {
176 b.dragParent = this;
177 b.SetAct(this.chara, a);
178 };
179 callback.onList = delegate(UIList.SortMode m)
180 {
181 List<Element> list = new List<Element>();
182 foreach (Element element in ELayer.pc.elements.dict.Values)
183 {
184 string categorySub = element.source.categorySub;
185 if (element.Value != 0 && (!this.config.hideDepletedSpell || !element.PotentialAsStock || element.vPotential > 0))
186 {
187 if (id == "favAbility" && ELayer.player.favAbility.Contains(element.id))
188 {
189 list.Add(element);
190 }
191 else if (id == categorySub || (id == "all" && this.idGroup.Contains(categorySub)))
192 {
193 list.Add(element);
194 }
195 }
196 }
197 list.Sort((Element a, Element b) => a.GetSortVal(m) - b.GetSortVal(m));
198 foreach (Element o in list)
199 {
200 this.list.Add(o);
201 }
202 };
203 baseList.callbacks = callback;
204 this.list.List();
205 }
206
207 // Token: 0x06002340 RID: 9024 RVA: 0x000C69A0 File Offset: 0x000C4BA0
208 public static void Redraw()
209 {
210 if (LayerAbility.Instance)
211 {
212 LayerAbility.Instance._Redraw();
213 }
214 }
215
216 // Token: 0x06002341 RID: 9025 RVA: 0x000C69B8 File Offset: 0x000C4BB8
217 public void _Redraw()
218 {
219 this.list.List();
220 }
221
222 // Token: 0x06002342 RID: 9026 RVA: 0x000C69C5 File Offset: 0x000C4BC5
223 public void OnStartDrag(UIButton b)
224 {
225 ELayer.ui.hud.SetDragImage(b.icon, null, null);
226 }
227
228 // Token: 0x06002343 RID: 9027 RVA: 0x000C69E0 File Offset: 0x000C4BE0
229 public void OnDrag(UIButton b)
230 {
231 ButtonAbility buttonAbility = b as ButtonAbility;
232 string text = "";
233 LayerRegisterHotbar layer = ELayer.ui.GetLayer<LayerRegisterHotbar>(false);
234 if (((layer != null) ? layer.GetButton() : null) ?? null)
235 {
236 text = "hotitemRegister";
237 }
238 else if (!layer)
239 {
240 ELayer.ui.AddLayer<LayerRegisterHotbar>().SetItem(buttonAbility.source);
241 }
242 ELayer.ui.hud.SetDragText(text, null);
243 }
244
245 // Token: 0x06002344 RID: 9028 RVA: 0x000C6A54 File Offset: 0x000C4C54
246 public void OnEndDrag(UIButton b, bool cancel = false)
247 {
248 ELayer.ui.hud.imageDrag.SetActive(false);
249 SourceElement.Row source = (b as ButtonAbility).source;
250 LayerRegisterHotbar layer = ELayer.ui.GetLayer<LayerRegisterHotbar>(false);
251 if (layer)
252 {
253 layer.OnEndDrag();
254 ELayer.ui.RemoveLayer<LayerRegisterHotbar>();
255 return;
256 }
257 }
258
259 // Token: 0x06002345 RID: 9029 RVA: 0x000C6AA9 File Offset: 0x000C4CA9
260 public void OnDisable()
261 {
262 ELayer.player.pref.sortAbility = this.list.sortMode;
263 ELayer.ui.hud.imageDrag.SetActive(false);
264 ELayer.ui.RemoveLayer<LayerRegisterHotbar>();
265 }
266
267 // Token: 0x040012BD RID: 4797
268 public static LayerAbility Instance;
269
270 // Token: 0x040012BE RID: 4798
271 public static ButtonAbility hotElement;
272
273 // Token: 0x040012BF RID: 4799
274 public UIDynamicList list;
275
276 // Token: 0x040012C0 RID: 4800
277 public Chara chara;
278
279 // Token: 0x040012C1 RID: 4801
280 public Transform headerRow;
281
282 // Token: 0x040012C2 RID: 4802
283 [NonSerialized]
284 public string[] idGroup = new string[]
285 {
286 "all",
287 "attack",
288 "defense",
289 "util",
290 "ability",
291 "favAbility"
292 };
293
294 // Token: 0x02000A30 RID: 2608
295 [Serializable]
296 public class Config
297 {
298 // Token: 0x040029E0 RID: 10720
299 public bool autoHideBG;
300
301 // Token: 0x040029E1 RID: 10721
302 public bool hideDepletedSpell;
303
304 // Token: 0x040029E2 RID: 10722
305 public int bgAlpha;
306 }
307}
Definition Chara.cs:12