Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerAbility.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
6{
7 [Serializable]
8 public class Config
9 {
10 public bool autoHideBG;
11
12 public bool hideDepletedSpell;
13
14 public bool fixedSize;
15
16 public bool fixedPos;
17
18 public int bgAlpha;
19 }
20
21 public static LayerAbility Instance;
22
24
26
27 public Chara chara;
28
29 public Transform headerRow;
30
31 [NonSerialized]
32 public string[] idGroup = new string[6] { "all", "attack", "defense", "util", "ability", "favAbility" };
33
35
36 public override void OnInit()
37 {
38 chara = ELayer.pc;
39 string[] array = idGroup;
40 foreach (string text in array)
41 {
42 windows[0].AddTab("cat_" + text, windows[0].CurrentContent);
43 }
44 Instance = this;
45 list.sortMode = ELayer.player.pref.sortAbility;
47 {
48 UIButton buttonSort = windows[0].buttonSort;
49 buttonSort.onClick.RemoveAllListeners();
50 buttonSort.onClick.AddListener(delegate
51 {
52 UIContextMenu uIContextMenu = ELayer.ui.CreateContextMenuInteraction();
53 uIContextMenu.layoutGroup.childAlignment = TextAnchor.UpperLeft;
54 uIContextMenu.alwaysPopLeft = true;
55 UIContextMenu uIContextMenu2 = uIContextMenu.AddChild("sort", TextAnchor.UpperRight);
56 UIList.SortMode[] sorts = list.sorts;
57 for (int j = 0; j < sorts.Length; j++)
58 {
59 UIList.SortMode sortMode = sorts[j];
60 string text2 = ((list.sortMode == sortMode) ? "context_checker".lang() : "");
61 UIList.SortMode _sort = sortMode;
62 uIContextMenu2.AddButton(text2 + sortMode.ToString().lang(), delegate
63 {
64 list.List(_sort);
65 SE.Click();
66 });
67 }
68 UIContextMenu uIContextMenu3 = uIContextMenu.AddChild("config", TextAnchor.UpperRight);
69 uIContextMenu3.AddSlider("alpha", (float a) => a.ToString() ?? "", config.bgAlpha, delegate(float b)
70 {
71 config.bgAlpha = (int)b;
73 }, 0f, 100f, isInt: true, hideOther: false);
74 uIContextMenu3.AddToggle("autoHideBG", config.autoHideBG, delegate(bool a)
75 {
76 config.autoHideBG = a;
78 });
79 uIContextMenu3.AddToggle("hideDepletedSpell", config.hideDepletedSpell, delegate(bool a)
80 {
81 config.hideDepletedSpell = a;
82 list.List();
83 });
84 uIContextMenu3.AddToggle("fixedSize", config.fixedSize, delegate(bool a)
85 {
86 config.fixedSize = a;
88 });
89 uIContextMenu3.AddToggle("fixedPos", config.fixedPos, delegate(bool a)
90 {
91 config.fixedPos = a;
93 });
94 uIContextMenu.Show();
95 });
96 }
99 }
100
101 public void RefreshConfig()
102 {
103 Window window = windows[0];
104 window.imageBG.color = Color.white.SetAlpha(0.01f * (float)config.bgAlpha);
105 window.listCgFloat.Clear();
106 if (config.autoHideBG)
107 {
108 window.listCgFloat.Add(window.cgBG);
109 }
110 window.cgBG.enabled = config.autoHideBG;
111 window.setting.allowMove = !config.fixedPos;
112 window.setting.allowResize = !config.fixedSize;
113 }
114
115 public static void SetDirty(Element a)
116 {
117 if ((bool)Instance)
118 {
120 }
122 {
123 foreach (UIList.ButtonPair button in item.invs[0].list.buttons)
124 {
125 ButtonGrid buttonGrid = button.component as ButtonGrid;
126 if (buttonGrid.card != null && buttonGrid.card.trait is TraitAbility)
127 {
128 item.invs[0].list.callbacks.OnRedraw(buttonGrid.card, buttonGrid, buttonGrid.index);
129 }
130 }
131 }
133 {
134 return;
135 }
137 {
138 ButtonGrid buttonGrid2 = button2.component as ButtonGrid;
139 if (buttonGrid2.card != null && buttonGrid2.card.trait is TraitAbility)
140 {
141 WidgetCurrentTool.Instance.list.callbacks.OnRedraw(buttonGrid2.card, buttonGrid2, buttonGrid2.index);
142 }
143 }
145 }
146
147 public override void OnSwitchContent(Window window)
148 {
149 ELayer.player.pref.lastIdTabAbility = window.idTab;
150 SelectGroup(windows[0].setting.tabs[window.idTab].idLang.Replace("cat_", ""));
151 }
152
153 public override void OnUpdateInput()
154 {
156 {
157 ButtonAbility componentOf = InputModuleEX.GetComponentOf<ButtonAbility>();
158 if ((bool)componentOf)
159 {
161 SE.SelectHotitem();
162 return;
163 }
164 }
165 base.OnUpdateInput();
166 }
167
168 public static void ClearHotElement()
169 {
170 ButtonAbility buttonAbility = hotElement;
171 hotElement = null;
173 if ((bool)buttonAbility && buttonAbility.attach != null)
174 {
175 UnityEngine.Object.Destroy(buttonAbility.attach.gameObject);
176 }
177 EInput.Consume();
178 ELayer.ui.hud.SetDragImage(null);
179 }
180
181 public void SelectGroup(string id)
182 {
183 list.Clear();
184 list.callbacks = new UIList.Callback<Element, ButtonAbility>
185 {
186 onClick = delegate(Element a, ButtonAbility b)
187 {
188 if (ELayer.ui.IsActive)
189 {
190 SE.BeepSmall();
191 }
192 else
193 {
194 SE.Equip();
195 hotElement = b;
196 b.attach = Util.Instantiate("UI/Element/Grid/Attach/guide_ability", b.transform);
198 ELayer.ui.hud.SetDragImage(b.icon);
199 }
200 },
201 onRedraw = delegate(Element a, ButtonAbility b, int i)
202 {
203 b.dragParent = this;
204 b.SetAct(chara, a);
205 },
206 onList = delegate(UIList.SortMode m)
207 {
208 List<Element> list = new List<Element>();
209 foreach (Element value in ELayer.pc.elements.dict.Values)
210 {
211 string categorySub = value.source.categorySub;
212 if (value.Value != 0 && (!config.hideDepletedSpell || !value.PotentialAsStock || value.vPotential > 0))
213 {
214 if (id == "favAbility" && ELayer.player.favAbility.Contains(value.id))
215 {
216 list.Add(value);
217 }
218 else if (id == categorySub || (id == "all" && idGroup.Contains(categorySub)))
219 {
220 list.Add(value);
221 }
222 }
223 }
224 list.Sort((Element a, Element b) => a.GetSortVal(m) - b.GetSortVal(m));
225 foreach (Element item in list)
226 {
227 this.list.Add(item);
228 }
229 }
230 };
231 list.List();
232 }
233
234 public static void Redraw()
235 {
236 if ((bool)Instance)
237 {
239 }
240 }
241
242 public void _Redraw()
243 {
244 list.List();
245 }
246
247 public void OnStartDrag(UIButton b)
248 {
249 ELayer.ui.hud.SetDragImage(b.icon);
250 }
251
252 public void OnDrag(UIButton b)
253 {
254 ButtonAbility buttonAbility = b as ButtonAbility;
255 string text = "";
257 if ((bool)(layer?.GetButton() ?? null))
258 {
259 text = "hotitemRegister";
260 }
261 else if (!layer)
262 {
263 ELayer.ui.AddLayer<LayerRegisterHotbar>().SetItem(buttonAbility.source);
264 }
265 ELayer.ui.hud.SetDragText(text);
266 }
267
268 public void OnEndDrag(UIButton b, bool cancel = false)
269 {
270 ELayer.ui.hud.imageDrag.SetActive(enable: false);
271 _ = (b as ButtonAbility).source;
273 if ((bool)layer)
274 {
275 layer.OnEndDrag();
276 ELayer.ui.RemoveLayer<LayerRegisterHotbar>();
277 }
278 }
279
280 public void OnDisable()
281 {
282 ELayer.player.pref.sortAbility = list.sortMode;
283 ELayer.ui.hud.imageDrag.SetActive(enable: false);
284 ELayer.ui.RemoveLayer<LayerRegisterHotbar>();
285 }
286}
UIList.SortMode[] sorts
Definition: BaseList.cs:15
UIList.ICallback callbacks
Definition: BaseList.cs:13
UIList.SortMode sortMode
Definition: BaseList.cs:33
void SetAct(Chara _chara, Element e)
SourceElement.Row source
Definition: ButtonAbility.cs:8
Transform attach
Card card
Definition: ButtonGrid.cs:24
ElementContainerCard elements
Definition: Card.cs:37
Trait trait
Definition: Card.cs:49
Definition: Chara.cs:10
Definition: EInput.cs:8
static ButtonState middleMouse
Definition: EInput.cs:353
static void Consume(int _skipFrame)
Definition: EInput.cs:656
Definition: ELayer.cs:4
static Chara pc
Definition: ELayer.cs:15
static Player player
Definition: ELayer.cs:13
static Game game
Definition: ELayer.cs:9
static GameSetting setting
Definition: ELayer.cs:33
static UI ui
Definition: ELayer.cs:21
Dictionary< int, Element > dict
int id
Definition: ELEMENT.cs:240
SourceElement.Row source
Definition: ELEMENT.cs:263
int vPotential
Definition: ELEMENT.cs:246
int GetSortVal(UIList.SortMode m)
Definition: ELEMENT.cs:834
int Value
Definition: ELEMENT.cs:282
virtual bool PotentialAsStock
Definition: ELEMENT.cs:326
bool altAbility
Definition: Game.cs:267
void OnStartDrag(UIButton b)
void OnDrag(UIButton b)
override void OnUpdateInput()
void _Redraw()
static void Redraw()
static ButtonAbility hotElement
Definition: LayerAbility.cs:23
Transform headerRow
Definition: LayerAbility.cs:29
static void ClearHotElement()
UIDynamicList list
Definition: LayerAbility.cs:25
void OnDisable()
static LayerAbility Instance
Definition: LayerAbility.cs:21
override void OnInit()
Definition: LayerAbility.cs:36
static void SetDirty(Element a)
void OnEndDrag(UIButton b, bool cancel=false)
void RefreshConfig()
override void OnSwitchContent(Window window)
void SelectGroup(string id)
string[] idGroup
Definition: LayerAbility.cs:32
new Config config
Definition: LayerAbility.cs:34
static void SetDirtyAll(bool immediate=false)
static List< LayerInventory > listInv
ButtonHotItem GetButton()
List< Window > windows
Definition: Layer.cs:116
int lastIdTabAbility
Definition: Player.cs:31
UIList.SortMode sortAbility
Definition: Player.cs:53
Pref pref
Definition: Player.cs:814
HashSet< int > favAbility
Definition: Player.cs:868
LayerAbility.Config layerAbilityConfig
Definition: Player.cs:838
void SetCurrentHotItem(HotItem item)
Definition: Player.cs:2046
Image icon
Definition: UIButton.cs:110
UIContextMenuItem AddToggle(string idLang="", bool isOn=false, UnityAction< bool > action=null)
void Show(UIItem i)
UIContextMenuItem AddSlider(string text, Func< float, string > textFunc, float value, Action< float > action, float min=0f, float max=1f, bool isInt=false, bool hideOther=true, bool useInput=false)
void AddButton(Func< string > funcText, UnityAction action=null)
UIContextMenu AddChild(string idLang, TextAnchor anchor)
override void List()
override void Redraw()
override void Add(object o)
override void Clear()
Definition: UIList.cs:9
List< ButtonPair > buttons
Definition: UIList.cs:244
SortMode
Definition: UIList.cs:27
static WidgetCurrentTool Instance
static void RefreshCurrentHotItem()
Definition: Window.cs:13
int idTab
Definition: Window.cs:694
List< CanvasGroup > listCgFloat
Definition: Window.cs:672
CanvasGroup cgBG
Definition: Window.cs:666