17 return EMono.setting.ui.widgetMetas;
27 return EMono.player.widgets.dict;
32 public void OnActivateZone()
41 if (config.state ==
Widget.State.Active)
43 this.ActivateWidget(config);
47 if (this.GetWidget(
"Equip") ==
null)
51 this.Activate(
"Equip");
57 this.DeactivateWidget(
"Equip");
62 public void OnGameInstantiated()
64 if (Application.isEditor &&
EMono.debug.resetPlayerConfig && !
EMono.player.isEditor)
66 EMono.player.useSubWidgetTheme =
false;
67 EMono.ui.widgets.Load(
false,
null);
70 if (
EMono.player.useSubWidgetTheme)
72 if (
EMono.player.subWidgets ==
null)
74 this.Load(
true,
null);
77 else if (
EMono.player.mainWidgets ==
null)
79 this.Load(
false,
null);
80 if (Screen.width <= 1300 && !
EMono.player.useSubWidgetTheme)
82 foreach (KeyValuePair<string, Widget.Config> keyValuePair
in EMono.player.mainWidgets.dict)
84 if (keyValuePair.Key ==
"StatsBar")
86 keyValuePair.Value.state =
Widget.State.Inactive;
91 if (this.metaMap.Count == 0)
95 this.metaMap.Add(meta.id, meta);
100 if (!this.configs.ContainsKey(meta2.id))
107 state = (meta2.enabled ? Widget.State.Active :
Widget.State.Inactive),
108 locked = meta2.locked
110 config.skin.SetID(0);
111 this.configs.Add(meta2.id, config);
116 config2.valid =
true;
117 config2.meta = meta2;
124 this.configs.Remove(config3.id);
130 public void OnKillGame()
136 public void OnChangeActionMode()
138 foreach (
Widget widget
in this.list)
140 widget.OnChangeActionMode();
145 public void UpdateConfigs()
147 foreach (
Widget widget
in this.list)
149 widget.UpdateConfig();
154 public void Activate(
string id)
156 if (!this.GetWidget(
id))
158 this.ActivateWidget(this.configs[
id]);
163 public Widget Toggle(
string id)
165 Widget widget = this.GetWidget(
id);
168 this.DeactivateWidget(widget);
171 return this.ActivateWidget(this.configs[
id]);
177 Widget widget = this.GetWidget(c.id);
180 this.DeactivateWidget(widget);
183 return this.ActivateWidget(c);
189 c.locked = !c.locked;
190 this.RefreshWidget(c);
196 return this.ActivateWidget(c.id);
200 public Widget ActivateWidget(
string id)
202 string text =
"Widget" + id;
203 Widget widget = Util.Instantiate<
Widget>(
"UI/Widget/" + text,
this) ?? Util.Instantiate<
Widget>(
"UI/Widget/" + text +
"/" + text,
this);
206 Debug.LogError(
"Widget:" +
id +
" not found.");
209 this.list.Add(widget);
210 widget.gameObject.name = text;
212 this.RefreshWidget(widget);
215 widget.OnManagerActivate();
217 if (widget.AlwaysBottom)
219 Type setSiblingAfter = widget.SetSiblingAfter;
221 if (setSiblingAfter !=
null)
223 foreach (
Widget widget2
in this.list)
225 if (widget2.GetType() == setSiblingAfter)
227 widget.transform.SetSiblingIndex(widget2.transform.GetSiblingIndex() + 1);
235 widget.transform.SetAsFirstSibling();
244 this.RefreshWidget(this.GetWidget(c.id));
248 public void RefreshWidget(
Widget w)
254 w.dragPanel.GetComponent<Graphic>().raycastTarget = !w.config.locked;
258 public Widget GetWidget(
string id)
260 foreach (
Widget widget
in this.list)
262 if (widget.gameObject.name ==
"Widget" +
id)
271 public void DeactivateWidget(
string id)
273 this.DeactivateWidget(this.GetWidget(
id));
277 public void DeactivateWidget(
Widget w)
292 public void KillWidgets()
294 this.DestroyChildren(
true,
true);
302 foreach (
Widget widget
in this.list)
304 if (widget.IsInRightMode())
306 widget.gameObject.SetActive(
true);
314 foreach (
Widget widget
in this.list)
318 widget.gameObject.SetActive(
false);
324 public void Reset(
bool toggleTheme)
332 (WidgetMainText.boxBk =
WidgetMainText.Instance.box).transform.SetParent(base.transform.parent,
false);
337 EMono.player.useSubWidgetTheme = !
EMono.player.useSubWidgetTheme;
339 this.OnGameInstantiated();
340 this.OnActivateZone();
341 this.OnChangeActionMode();
345 public void DialogSave(Action onSave =
null)
347 EMono.core.WaitForEndOfFrame(delegate
349 string text = StandaloneFileBrowser.SaveFilePanel(
"Save Widget Theme", CorePath.WidgetSave,
"new theme",
"json");
350 if (!
string.IsNullOrEmpty(text))
352 if (!
EMono.debug.enable && (text.Contains(
"Default.json") || text.Contains(
"Modern.json") || text.Contains(
"Classic.json")))
354 Dialog.Ok(
"dialogInvalidTheme");
367 public void DialogLoad(Action onLoad =
null)
369 EMono.core.WaitForEndOfFrame(delegate
371 string[] array = StandaloneFileBrowser.OpenFilePanel(
"Load Widget Theme", CorePath.WidgetSave,
"json",
false);
372 if (array.Length != 0)
374 this.Load(
EMono.player.useSubWidgetTheme, array[0]);
385 public void Save(
string path =
null)
389 path = CorePath.WidgetSave + (EMono.player.useSubWidgetTheme ? EMono.core.config.other.idSubWidgetTheme :
EMono.core.config.other.idMainWidgetTheme) +
".json";
391 this.UpdateConfigs();
392 IO.SaveFile(path,
EMono.player.widgets,
false,
null);
396 public void Load(
bool isSubTheme,
string path =
null)
400 path = CorePath.WidgetSave + (isSubTheme ? EMono.core.config.other.idSubWidgetTheme :
EMono.core.config.other.idMainWidgetTheme) +
".json";
405 EMono.player.subWidgets = saveData;
409 EMono.player.mainWidgets = saveData;
411 this.currentPath = path;
418 public string currentPath;
422 public List<Widget> list =
new List<Widget>();