10 public override object CreateExtra()
27 public Color colorDefault
31 return base.config.skin.BG.colors.textDefault;
41 return base.config.skin.BG.colors.textBad;
47 public Color colorVeryBad
51 return base.config.skin.BG.colors.textBad;
56 public override void OnActivate()
58 WidgetStatsBar.Instance =
this;
59 this.mold = this.layout.CreateMold(
null);
61 base.InvokeRepeating(
"Refresh", 0.2f, 0.2f);
68 this.layout.DestroyChildren(
false,
true);
69 if (this.extra.attributes)
71 foreach (
Element ele
in EMono.pc.elements.ListElements((
Element e) => e.HasTag(
"primary"),
null))
73 this.Add(ele,
"",
null,
null,
null,
null);
75 this.Add(
EMono.pc.elements.GetElement(79),
"",
null,
null,
null,
null);
77 if (this.extra.maxAlly)
79 this.Add(
null,
"maxAlly", this.iconMaxAlly, () => (
EMono.pc.party.members.Count - 1).ToString() +
"/" +
EMono.player.MaxAlly.ToString(), delegate
81 if (EMono.player.lastEmptyAlly >= 0)
83 return FontColor.Default;
90 this.Add(
null,
"money", this.iconMoney, () =>
EMono.pc.GetCurrency(
"money").ToString(
"#,0") ??
"",
null,
null);
92 if (this.extra.money2)
94 this.Add(
null,
"money2", this.iconMoney2, () =>
EMono.pc.GetCurrency(
"money2").ToString(
"#,0") ??
"",
null,
null);
98 this.Add(
null,
"plat", this.iconPlat, () =>
EMono.pc.GetCurrency(
"plat").ToString(
"#,0") ??
"",
null,
null);
100 if (this.extra.medal)
102 this.Add(
null,
"medal", this.iconMedal, () =>
EMono.pc.GetCurrency(
"medal").ToString(
"#,0") ??
"",
null,
null);
104 if (this.extra.karma)
106 this.Add(
null,
"karma", this.iconKarma, () =>
EMono.player.karma.ToString() ??
"",
null,
null);
110 this.Add(
null,
"mood", this.iconGodMood, () =>
EMono.pc.faith.TextMood ??
"",
null,
null);
114 this.Add(
null,
"fame", this.iconFame, () =>
EMono.player.fame.ToString() ??
"",
null,
null);
116 if (this.extra.influence)
118 this.Add(
null,
"influence", this.iconInfluence, () =>
EMono._zone.influence.ToString() ??
"",
null, () =>
EMono._zone.influence != 0);
120 if (this.extra.tourism_value)
122 this.Add(
null,
"tourism_value", this.iconTourismValue, delegate
124 if (
EMono.Branch !=
null)
126 return EMono.Branch.tourism.ToFormat();
129 },
null, () =>
EMono._zone.IsPCFaction);
131 if (this.extra.hearthLv)
133 this.Add(
null,
"hearth_lv", this.iconHearth, delegate
135 if (
EMono.Branch !=
null)
137 return EMono.Branch.TextLv;
142 if (
EMono.Branch !=
null &&
EMono.Branch.exp <
EMono.Branch.GetNextExp(-1))
144 return FontColor.Default;
146 return FontColor.Good;
147 }, () =>
EMono._zone.IsPCFaction);
149 if (this.extra.weight)
151 this.Add(
null,
"weight", this.iconWeight, () => ((
float)
EMono.pc.ChildrenWeight / 1000f).ToString(
"F1") +
" / " + ((
float)
EMono.pc.WeightLimit / 1000f).ToString(
"F1"), delegate
153 int phase = EMono.pc.burden.GetPhase();
156 return FontColor.Default;
160 return FontColor.Bad;
162 return FontColor.Warning;
169 public UIItem Add(
Element ele,
string id =
"", Sprite sprite =
null, Func<string> func =
null, Func<FontColor> funcCol =
null, Func<bool> funcShow =
null)
171 UIItem uiitem = Util.Instantiate<UIItem>(this.mold, this.layout);
183 uiitem.image1.sprite = sprite;
187 uiitem.image1.sprite = ele.GetIcon(
"_m");
189 uiitem.image1.SetNativeSize();
190 uiitem.text1.skinRoot = base.skinRoot;
191 Shadow component = uiitem.text1.GetComponent<Shadow>();
194 component.enabled = base.config.skin.BG.textShadow;
196 this.items.Add(item);
201 public void Refresh()
206 string text = item.component.text1.text;
207 FontColor fontColor = FontColor.Default;
209 if (!item.id.IsEmpty())
212 if (item.funcCol !=
null)
214 fontColor = item.funcCol();
220 text2 = (ele.DisplayValue.ToString() ??
"");
221 if (ele.DisplayValue < ele.ValueWithoutLink)
223 text2 = text2 +
" (" + ele.ValueWithoutLink.ToString() +
")";
225 if (ele.DisplayValue < ele.ValueWithoutLink)
227 fontColor = FontColor.Bad;
229 else if (
EMono.pc.tempElements !=
null)
231 Element element =
EMono.pc.tempElements.GetElement(ele.id);
232 if (element !=
null && element.vBase > 0)
234 fontColor = FontColor.Good;
238 if (text2 != text || item.lastColor != fontColor)
240 item.component.text1.SetText(text2, fontColor);
241 item.component.RebuildLayout(
false);
243 item.lastColor = fontColor;
245 if (item.funcShow !=
null)
247 item.component.SetActive(item.funcShow());
252 this.layout.RebuildLayout(
false);
253 this.RebuildLayout(
false);
258 public override void OnSetContextMenu(UIContextMenu m)
260 UIContextMenu uicontextMenu = m.AddChild(
"setting");
261 uicontextMenu.AddToggle(
"attributes", this.extra.attributes, delegate(
bool a)
263 this.extra.attributes = a;
266 uicontextMenu.AddToggle(
"maxAlly", this.extra.maxAlly, delegate(
bool a)
268 this.extra.maxAlly = a;
271 uicontextMenu.AddToggle(
"money", this.extra.money, delegate(
bool a)
273 this.extra.money = a;
276 uicontextMenu.AddToggle(
"money2", this.extra.money2, delegate(
bool a)
278 this.extra.money2 = a;
281 uicontextMenu.AddToggle(
"plat", this.extra.plat, delegate(
bool a)
286 uicontextMenu.AddToggle(
"medal", this.extra.medal, delegate(
bool a)
288 this.extra.medal = a;
291 uicontextMenu.AddToggle(
"influence", this.extra.influence, delegate(
bool a)
293 this.extra.influence = a;
296 uicontextMenu.AddToggle(
"karma", this.extra.karma, delegate(
bool a)
298 this.extra.karma = a;
301 uicontextMenu.AddToggle(
"fame", this.extra.fame, delegate(
bool a)
308 uicontextMenu.AddToggle(
"godMood", this.extra.mood, delegate(
bool a)
314 uicontextMenu.AddToggle(
"tourism_value", this.extra.tourism_value, delegate(
bool a)
316 this.extra.tourism_value = a;
319 uicontextMenu.AddToggle(
"hearth_lv", this.extra.hearthLv, delegate(
bool a)
321 this.extra.hearthLv = a;
324 uicontextMenu.AddToggle(
"invWeight", this.extra.weight, delegate(
bool a)
326 this.extra.weight = a;
329 base.SetBaseContextMenu(m);
333 public override void OnApplySkin()
343 public LayoutGroup layout;
349 public Sprite iconMoney;
352 public Sprite iconMoney2;
355 public Sprite iconPlat;
358 public Sprite iconMedal;
361 public Sprite iconKarma;
364 public Sprite iconWeight;
367 public Sprite iconInfluence;
370 public Sprite iconMaxAlly;
373 public Sprite iconGodMood;
376 public Sprite iconHearth;
379 public Sprite iconTourismValue;
382 public Sprite iconFame;
391 public UIItem component;
400 public Sprite sprite;
403 public Func<string> func;
406 public Func<FontColor> funcCol;
409 public Func<bool> funcShow;
412 public FontColor lastColor;
419 public bool attributes;
443 public bool influence;
449 public bool hearthLv;
452 public bool tourism_value;