Elin Decompiled Documentation EA 23.357 Nightly
Loading...
Searching...
No Matches
WidgetManager Class Reference
Inheritance diagram for WidgetManager:
EMono

Classes

class  SaveData
 

Public Member Functions

void OnActivateZone ()
 
void OnGameInstantiated ()
 
void RegisterMeta (Widget.Meta meta)
 
void OnKillGame ()
 
void OnChangeActionMode ()
 
void UpdateConfigs ()
 
void Activate (string id)
 
Widget Toggle (string id)
 
Widget Toggle (Widget.Config c)
 
void ToggleLock (Widget.Config c)
 
Widget ActivateWidget (Widget.Config c)
 
Widget ActivateWidget (string id)
 
void RefreshWidget (Widget.Config c)
 
void RefreshWidget (Widget w)
 
Widget GetWidget (string id)
 
void DeactivateWidget (string id)
 
void DeactivateWidget (Widget w)
 
void KillWidgets ()
 
void Show ()
 
void Hide ()
 
void Reset (bool toggleTheme)
 
void DialogSave (Action onSave=null)
 
void DialogLoad (Action onLoad=null)
 
void Save (string path=null)
 
void Load (bool isSubTheme, string path=null)
 

Public Attributes

Dictionary< string, Widget.Meta > metaMap = new Dictionary<string, Widget.Meta>()
 
string currentPath
 
List< Widget > list = new List<Widget>()
 

Static Public Attributes

static readonly List< Func< string, WidgetManager, Widget > > widgetLoaders = new List<Func<string, WidgetManager, Widget>>()
 
- Static Public Attributes inherited from EMono
static Core core
 

Properties

List< Widget.Meta > metas [get]
 
Dictionary< string, Widget.Config > configs [get]
 
- Properties inherited from EMono
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SoundManager Sound [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static CoreDebug debug [get]
 

Private Member Functions

Widget.Config CreateConfig (Widget.Meta m)
 
Widget LoadCustomWidget (string id)
 

Private Attributes

bool first
 

Additional Inherited Members

- Static Public Member Functions inherited from EMono
static int rnd (int a)
 

Detailed Description

Definition at line 8 of file WidgetManager.cs.

Member Function Documentation

◆ Activate()

void WidgetManager.Activate ( string  id)
inline

Definition at line 175 of file WidgetManager.cs.

176 {
177 if (!GetWidget(id))
178 {
180 }
181 }
Widget GetWidget(string id)
Widget ActivateWidget(Widget.Config c)
Dictionary< string, Widget.Config > configs

References ActivateWidget(), configs, and GetWidget().

Referenced by OnActivateZone().

◆ ActivateWidget() [1/2]

Widget WidgetManager.ActivateWidget ( string  id)
inline

Definition at line 216 of file WidgetManager.cs.

217 {
218 string text = "Widget" + id;
219 Widget widget = LoadCustomWidget(id);
220 if (!widget)
221 {
222 widget = Util.Instantiate<Widget>("UI/Widget/" + text, this) ?? Util.Instantiate<Widget>("UI/Widget/" + text + "/" + text, this);
223 }
224 if (!widget)
225 {
226 Debug.LogError("Widget:" + id + " not found.");
227 return null;
228 }
229 list.Add(widget);
230 widget.gameObject.name = text;
231 widget.Activate();
232 RefreshWidget(widget);
233 if ((bool)LayerWidget.Instance)
234 {
235 widget.OnManagerActivate();
236 }
237 return widget;
238 }
static LayerWidget Instance
Definition: LayerWidget.cs:5
Definition: Util.cs:10
static Transform Instantiate(string path, Component parent=null)
Definition: Util.cs:67
Widget LoadCustomWidget(string id)
List< Widget > list
void RefreshWidget(Widget.Config c)
Definition: Widget.cs:7
void Activate()
Definition: Widget.cs:225
virtual void OnManagerActivate()
Definition: Widget.cs:330

References Widget.Activate(), Debug, LayerWidget.Instance, list, LoadCustomWidget(), Widget.OnManagerActivate(), RefreshWidget(), and Util.

◆ ActivateWidget() [2/2]

Widget WidgetManager.ActivateWidget ( Widget::Config  c)
inline

Definition at line 211 of file WidgetManager.cs.

212 {
213 return ActivateWidget(c.id);
214 }
string id
Definition: Widget.cs:47

References ActivateWidget().

Referenced by Activate(), ActivateWidget(), OnActivateZone(), and Toggle().

◆ CreateConfig()

Widget.Config WidgetManager.CreateConfig ( Widget::Meta  m)
inlineprivate

Definition at line 142 of file WidgetManager.cs.

143 {
144 Widget.Config config = new Widget.Config();
145 config.meta = m;
146 config.valid = true;
147 config.id = m.id;
148 config.state = ((!m.enabled) ? Widget.State.Inactive : Widget.State.Active);
149 config.locked = m.locked;
150 config.skin.SetID(0);
151 return config;
152 }
void SetID(int _id)
Definition: SkinConfig.cs:133
SkinConfig skin
Definition: Widget.cs:61
bool enabled
Definition: Widget.cs:13
bool locked
Definition: Widget.cs:15
string id
Definition: Widget.cs:11
State
Definition: Widget.cs:141

References Widget.Config.id, SkinConfig.SetID(), and Widget.Config.skin.

Referenced by OnGameInstantiated(), and RegisterMeta().

◆ DeactivateWidget() [1/2]

void WidgetManager.DeactivateWidget ( string  id)
inline

Definition at line 285 of file WidgetManager.cs.

286 {
288 }
void DeactivateWidget(string id)

References DeactivateWidget(), and GetWidget().

Referenced by DeactivateWidget(), OnActivateZone(), and Toggle().

◆ DeactivateWidget() [2/2]

void WidgetManager.DeactivateWidget ( Widget  w)
inline

Definition at line 290 of file WidgetManager.cs.

291 {
292 if (!(w == null))
293 {
294 list.Remove(w);
295 w.Deactivate();
296 if ((bool)LayerWidget.Instance)
297 {
299 }
300 }
301 }
void Refresh()
Definition: LayerWidget.cs:124
void Deactivate()
Definition: Widget.cs:307

References Widget.Deactivate(), LayerWidget.Instance, list, and LayerWidget.Refresh().

◆ DialogLoad()

void WidgetManager.DialogLoad ( Action  onLoad = null)
inline

Definition at line 383 of file WidgetManager.cs.

384 {
386 {
387 string[] array = StandaloneFileBrowser.OpenFilePanel("Load Widget Theme", CorePath.WidgetSave, "json", multiselect: false);
388 if (array.Length != 0)
389 {
390 Load(EMono.player.useSubWidgetTheme, array[0]);
391 Reset(toggleTheme: false);
392 if (onLoad != null)
393 {
394 onLoad();
395 }
396 }
397 });
398 }
if(!match.Success)
void WaitForEndOfFrame(Action action)
Definition: BaseCore.cs:61
static string WidgetSave
Definition: CorePath.cs:186
Definition: EMono.cs:4
static Core core
Definition: EMono.cs:5
static string[] OpenFilePanel(string title, string directory, string extension, bool multiselect)

References EMono.core, if(), SFB.StandaloneFileBrowser.OpenFilePanel(), BaseCore.WaitForEndOfFrame(), and CorePath.WidgetSave.

◆ DialogSave()

void WidgetManager.DialogSave ( Action  onSave = null)
inline

Definition at line 360 of file WidgetManager.cs.

361 {
363 {
364 string text = StandaloneFileBrowser.SaveFilePanel("Save Widget Theme", CorePath.WidgetSave, "new theme", "json");
365 if (!string.IsNullOrEmpty(text))
366 {
367 if (!EMono.debug.enable && (text.Contains("Default.json") || text.Contains("Modern.json") || text.Contains("Classic.json")))
368 {
369 Dialog.Ok("dialogInvalidTheme");
370 }
371 else
372 {
373 Save(text);
374 if (onSave != null)
375 {
376 onSave();
377 }
378 }
379 }
380 });
381 }
bool enable
Definition: CoreDebug.cs:302
static CoreDebug debug
Definition: EMono.cs:45
static string SaveFilePanel(string title, string directory, string defaultName, string extension)

References EMono.core, EMono.debug, CoreDebug.enable, if(), SFB.StandaloneFileBrowser.SaveFilePanel(), BaseCore.WaitForEndOfFrame(), and CorePath.WidgetSave.

◆ GetWidget()

Widget WidgetManager.GetWidget ( string  id)
inline

Definition at line 273 of file WidgetManager.cs.

274 {
275 foreach (Widget item in list)
276 {
277 if (item.gameObject.name == "Widget" + id)
278 {
279 return item;
280 }
281 }
282 return null;
283 }

References item, and list.

Referenced by Activate(), DeactivateWidget(), OnActivateZone(), RefreshWidget(), and Toggle().

◆ Hide()

void WidgetManager.Hide ( )
inline

Definition at line 321 of file WidgetManager.cs.

322 {
323 foreach (Widget item in list)
324 {
326 {
327 item.gameObject.SetActive(value: false);
328 }
329 }
330 }

References item, and list.

Referenced by UI.OnChangeLayer().

◆ KillWidgets()

void WidgetManager.KillWidgets ( )
inline

Definition at line 303 of file WidgetManager.cs.

304 {
305 this.DestroyChildren(destroyInactive: true);
306 list.Clear();
307 first = true;
308 }

References first, and list.

Referenced by OnKillGame(), and Reset().

◆ Load()

void WidgetManager.Load ( bool  isSubTheme,
string  path = null 
)
inline

Definition at line 410 of file WidgetManager.cs.

411 {
412 if (path == null)
413 {
414 path = CorePath.WidgetSave + (isSubTheme ? EMono.core.config.other.idSubWidgetTheme : EMono.core.config.other.idMainWidgetTheme) + ".json";
415 }
416 SaveData saveData = IO.LoadFile<SaveData>(path);
417 if (isSubTheme)
418 {
419 EMono.player.subWidgets = saveData;
420 }
421 else
422 {
423 EMono.player.mainWidgets = saveData;
424 }
425 currentPath = path;
426 }
OtherSetting other
Definition: CoreConfig.cs:639
CoreConfig config
Definition: Core.cs:70
Definition: IO.cs:10
string currentPath

References Core.config, EMono.core, CoreConfig.OtherSetting.idMainWidgetTheme, and CoreConfig.other.

Referenced by OnGameInstantiated().

◆ LoadCustomWidget()

Widget WidgetManager.LoadCustomWidget ( string  id)
inlineprivate

Definition at line 240 of file WidgetManager.cs.

241 {
242 foreach (Func<string, WidgetManager, Widget> widgetLoader in widgetLoaders)
243 {
244 try
245 {
246 Widget widget = widgetLoader(id, this);
247 if ((bool)widget)
248 {
249 return widget;
250 }
251 }
252 catch (Exception exception)
253 {
254 Debug.LogException(exception);
255 }
256 }
257 return null;
258 }
static readonly List< Func< string, WidgetManager, Widget > > widgetLoaders

References Debug, and widgetLoaders.

Referenced by ActivateWidget().

◆ OnActivateZone()

void WidgetManager.OnActivateZone ( )
inline

Definition at line 30 of file WidgetManager.cs.

31 {
32 if (!first)
33 {
34 return;
35 }
36 first = false;
37 foreach (Widget.Config value in configs.Values)
38 {
39 if (value.state == Widget.State.Active)
40 {
41 ActivateWidget(value);
42 }
43 }
44 bool flag = EMono.ui.layerFloat.GetLayer<LayerInventory>();
45 if (GetWidget("Equip") == null)
46 {
47 if (flag)
48 {
49 Activate("Equip");
50 }
51 }
52 else if (!flag)
53 {
54 DeactivateWidget("Equip");
55 }
56 }
static UI ui
Definition: EMono.cs:15
void Activate(string id)

References Activate(), ActivateWidget(), configs, DeactivateWidget(), first, GetWidget(), and EMono.ui.

Referenced by UI.OnActivateZone(), and Reset().

◆ OnChangeActionMode()

void WidgetManager.OnChangeActionMode ( )
inline

Definition at line 159 of file WidgetManager.cs.

160 {
161 foreach (Widget item in list)
162 {
163 item.OnChangeActionMode();
164 }
165 }

References item, and list.

Referenced by Reset().

◆ OnGameInstantiated()

void WidgetManager.OnGameInstantiated ( )
inline

Definition at line 58 of file WidgetManager.cs.

59 {
60 if (Application.isEditor && EMono.debug.resetPlayerConfig && !EMono.player.isEditor)
61 {
62 EMono.player.useSubWidgetTheme = false;
63 EMono.ui.widgets.Load(isSubTheme: false);
64 }
65 first = true;
67 {
68 if (EMono.player.subWidgets == null)
69 {
70 Load(isSubTheme: true);
71 }
72 }
73 else if (EMono.player.mainWidgets == null)
74 {
75 Load(isSubTheme: false);
76 if (Screen.width <= 1300 && !EMono.player.useSubWidgetTheme)
77 {
78 foreach (KeyValuePair<string, Widget.Config> item in EMono.player.mainWidgets.dict)
79 {
80 if (item.Key == "StatsBar")
81 {
82 item.Value.state = Widget.State.Inactive;
83 }
84 }
85 }
86 }
87 BaseModManager.PublishEvent("elin.widget.metas_building", this);
88 foreach (Widget.Meta meta in metas)
89 {
90 metaMap[meta.id] = meta;
91 }
92 foreach (Widget.Meta meta2 in metas)
93 {
94 if (!configs.ContainsKey(meta2.id))
95 {
96 configs.Add(meta2.id, CreateConfig(meta2));
97 continue;
98 }
99 Widget.Config config = configs[meta2.id];
100 config.valid = true;
101 config.meta = meta2;
102 }
103 foreach (Widget.Config item2 in configs.Values.ToList())
104 {
105 if (!item2.valid)
106 {
107 configs.Remove(item2.id);
108 }
109 }
110 }
static void PublishEvent(string eventId, object data=null)
bool resetPlayerConfig
Definition: CoreDebug.cs:136
static Player player
Definition: EMono.cs:11
bool useSubWidgetTheme
Definition: Player.cs:1059
WidgetManager.SaveData subWidgets
Definition: Player.cs:1110
WidgetManager.SaveData mainWidgets
Definition: Player.cs:1107
bool isEditor
Definition: Player.cs:1074
List< Widget.Meta > metas
Dictionary< string, Widget.Meta > metaMap
Widget.Config CreateConfig(Widget.Meta m)
void Load(bool isSubTheme, string path=null)

References configs, CreateConfig(), EMono.debug, first, Player.isEditor, item, Load(), Player.mainWidgets, metaMap, metas, EMono.player, BaseModManager.PublishEvent(), CoreDebug.resetPlayerConfig, Player.subWidgets, EMono.ui, and Player.useSubWidgetTheme.

Referenced by Reset().

◆ OnKillGame()

void WidgetManager.OnKillGame ( )
inline

Definition at line 154 of file WidgetManager.cs.

155 {
156 KillWidgets();
157 }
void KillWidgets()

References KillWidgets().

Referenced by UI.OnKillGame().

◆ RefreshWidget() [1/2]

void WidgetManager.RefreshWidget ( Widget  w)
inline

Definition at line 265 of file WidgetManager.cs.

266 {
267 if ((bool)w)
268 {
269 w.dragPanel.GetComponent<Graphic>().raycastTarget = !w.config.locked;
270 }
271 }

References Widget.config, Widget.dragPanel, and Widget.Config.locked.

◆ RefreshWidget() [2/2]

void WidgetManager.RefreshWidget ( Widget::Config  c)
inline

Definition at line 260 of file WidgetManager.cs.

261 {
263 }

References GetWidget(), and RefreshWidget().

Referenced by ActivateWidget(), RefreshWidget(), and ToggleLock().

◆ RegisterMeta()

void WidgetManager.RegisterMeta ( Widget::Meta  meta)
inline

Definition at line 112 of file WidgetManager.cs.

113 {
114 if (meta == null || meta.id.IsEmpty())
115 {
116 return;
117 }
118 int num = metas.FindIndex((Widget.Meta m) => m.id == meta.id);
119 if (num >= 0)
120 {
121 metas[num] = meta;
122 }
123 else
124 {
125 metas.Add(meta);
126 }
127 metaMap[meta.id] = meta;
128 if (EMono.player?.widgets != null)
129 {
130 if (configs.TryGetValue(meta.id, out var value))
131 {
132 value.valid = true;
133 value.meta = meta;
134 }
135 else
136 {
137 configs.Add(meta.id, CreateConfig(meta));
138 }
139 }
140 }
WidgetManager.SaveData widgets
Definition: Player.cs:1318

References configs, CreateConfig(), metaMap, metas, EMono.player, and Player.widgets.

◆ Reset()

void WidgetManager.Reset ( bool  toggleTheme)
inline

Definition at line 332 of file WidgetManager.cs.

333 {
334 MsgBox msgBox = null;
335 if ((bool)WidgetMainText.Instance)
336 {
338 {
340 }
341 msgBox = (WidgetMainText.boxBk = WidgetMainText.Instance.box);
342 msgBox.transform.SetParent(base.transform.parent, worldPositionStays: false);
343 }
344 KillWidgets();
345 if (toggleTheme)
346 {
347 EMono.player.useSubWidgetTheme = !EMono.player.useSubWidgetTheme;
348 }
354 if (!WidgetMainText.Instance && (bool)msgBox)
355 {
356 UnityEngine.Object.Destroy(msgBox.gameObject);
357 }
358 }
void ResetHotbar(int id)
Definition: HotbarManager.cs:8
Definition: MsgBox.cs:8
bool isShowingLog
Definition: MsgBox.cs:55
HotbarManager hotbars
Definition: Player.cs:1164
static WidgetMainText Instance
void OnActivateZone()
void OnGameInstantiated()
void OnChangeActionMode()

References WidgetMainText._ToggleLog(), WidgetMainText.box, Player.hotbars, WidgetMainText.Instance, MsgBox.isShowingLog, KillWidgets(), OnActivateZone(), OnChangeActionMode(), OnGameInstantiated(), EMono.player, HotbarManager.ResetHotbar(), and Player.useSubWidgetTheme.

Referenced by HotItemToggleWidget.OnClick().

◆ Save()

void WidgetManager.Save ( string  path = null)
inline

Definition at line 400 of file WidgetManager.cs.

401 {
402 if (path == null)
403 {
404 path = CorePath.WidgetSave + (EMono.player.useSubWidgetTheme ? EMono.core.config.other.idSubWidgetTheme : EMono.core.config.other.idMainWidgetTheme) + ".json";
405 }
408 }
static void SaveFile(string path, object obj, bool compress=false, JsonSerializerSettings setting=null)
Definition: IO.cs:88
void UpdateConfigs()

References Core.config, EMono.core, CoreConfig.OtherSetting.idMainWidgetTheme, CoreConfig.other, EMono.player, and Player.widgets.

◆ Show()

void WidgetManager.Show ( )
inline

Definition at line 310 of file WidgetManager.cs.

311 {
312 foreach (Widget item in list)
313 {
314 if (item.IsInRightMode())
315 {
316 item.gameObject.SetActive(value: true);
317 }
318 }
319 }

References item, and list.

◆ Toggle() [1/2]

Widget WidgetManager.Toggle ( string  id)
inline

Definition at line 183 of file WidgetManager.cs.

184 {
185 Widget widget = GetWidget(id);
186 if ((bool)widget)
187 {
188 DeactivateWidget(widget);
189 return null;
190 }
191 return ActivateWidget(configs[id]);
192 }

References ActivateWidget(), configs, DeactivateWidget(), and GetWidget().

Referenced by LayerWidget.OnInit().

◆ Toggle() [2/2]

Widget WidgetManager.Toggle ( Widget::Config  c)
inline

Definition at line 194 of file WidgetManager.cs.

195 {
196 Widget widget = GetWidget(c.id);
197 if ((bool)widget)
198 {
199 DeactivateWidget(widget);
200 return null;
201 }
202 return ActivateWidget(c);
203 }

References ActivateWidget(), DeactivateWidget(), and GetWidget().

◆ ToggleLock()

void WidgetManager.ToggleLock ( Widget::Config  c)
inline

Definition at line 205 of file WidgetManager.cs.

206 {
207 c.locked = !c.locked;
208 RefreshWidget(c);
209 }
bool locked
Definition: Widget.cs:55

References RefreshWidget().

Referenced by LayerWidget.OnInit().

◆ UpdateConfigs()

void WidgetManager.UpdateConfigs ( )
inline

Definition at line 167 of file WidgetManager.cs.

168 {
169 foreach (Widget item in list)
170 {
171 item.UpdateConfig();
172 }
173 }

References item, and list.

Referenced by HotItemToggleWidget.OnClick().

Member Data Documentation

◆ currentPath

string WidgetManager.currentPath

Definition at line 19 of file WidgetManager.cs.

◆ first

bool WidgetManager.first
private

Definition at line 24 of file WidgetManager.cs.

Referenced by KillWidgets(), OnActivateZone(), and OnGameInstantiated().

◆ list

List<Widget> WidgetManager.list = new List<Widget>()

◆ metaMap

Dictionary<string, Widget.Meta> WidgetManager.metaMap = new Dictionary<string, Widget.Meta>()

Definition at line 17 of file WidgetManager.cs.

Referenced by OnGameInstantiated(), and RegisterMeta().

◆ widgetLoaders

readonly List<Func<string, WidgetManager, Widget> > WidgetManager.widgetLoaders = new List<Func<string, WidgetManager, Widget>>()
static

Definition at line 15 of file WidgetManager.cs.

Referenced by LoadCustomWidget().

Property Documentation

◆ configs

Dictionary<string, Widget.Config> WidgetManager.configs
get

Definition at line 28 of file WidgetManager.cs.

Referenced by Activate(), OnActivateZone(), OnGameInstantiated(), RegisterMeta(), and Toggle().

◆ metas

List<Widget.Meta> WidgetManager.metas
get

Definition at line 26 of file WidgetManager.cs.

Referenced by OnGameInstantiated(), and RegisterMeta().


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