Elin Modding Docs Doc
Loading...
Searching...
No Matches
UIHomeInfo.cs
1using System;
2using System.Collections.Generic;
3using System.Runtime.CompilerServices;
4using UnityEngine;
5using UnityEngine.UI;
6
7// Token: 0x02000558 RID: 1368
8public class UIHomeInfo : EMono
9{
10 // Token: 0x17000B24 RID: 2852
11 // (get) Token: 0x0600251D RID: 9501 RVA: 0x000D2715 File Offset: 0x000D0915
12 public int tabResearch
13 {
14 get
15 {
16 return 1;
17 }
18 }
19
20 // Token: 0x0600251E RID: 9502 RVA: 0x000D2718 File Offset: 0x000D0918
21 public void Refresh()
22 {
23 EMono._zone.RefreshElectricity();
24 this.reports.Clear();
25 this.faction = EMono.pc.faction;
26 this.branch = (EMono.Branch ?? EMono.pc.homeZone.branch);
27 FactionBranch factionBranch = EMono.Branch;
28 this.zone = (((factionBranch != null) ? factionBranch.owner : null) ?? EMono.pc.homeZone);
29 this.branch.resources.Refresh();
30 this.RefreshInfo();
31 this.RefreshResources();
32 this.RefreshReport();
33 this.transLayout.RebuildLayoutTo(this);
34 }
35
36 // Token: 0x0600251F RID: 9503 RVA: 0x000D27BC File Offset: 0x000D09BC
37 public void RefreshInfo()
38 {
39 this.textHeaderReport.text = "headerHomeReport".lang(EMono.world.date.year.ToString() ?? "", EMono.world.date.month.ToString() + "/" + EMono.world.date.day.ToString(), null, null, null);
40 this.textFaction.text = EMono.pc.faction.Name;
41 this.textGod.text = this.branch.faith.Name;
42 this.textContentLv.text = this.branch.DangerLV.ToString() + " " + ("(" + this.branch.ContentLV.ToString() + ")").TagSize(12);
43 this.textDateFound.text = Date.GetText(this.branch.dateFound, Date.TextFormat.YearMonthDay);
44 this.textPasture.text = this.branch.CountPasture().ToString() + " " + ("(-" + this.branch.GetPastureCost().ToString() + "dailyIncome".lang() + ")").TagSize(12);
45 bool flag = this.branch.CountMembers(FactionMemberType.Default, false) > this.branch.MaxPopulation;
46 this.textMember.SetText(this.branch.CountMembers(FactionMemberType.Default, false).ToString() + " / " + this.branch.MaxPopulation.ToString(), flag ? FontColor.Bad : FontColor.Default);
47 if (flag)
48 {
49 this.AddReport("rPopOver", UIHomeInfo.ReportData.ReportType.Warning, null, null);
50 }
51 this.textDev.text = ((EMono._zone.development / 10).ToString() ?? "");
52 this.textLand.text = (EMono._map.bounds.Width * EMono._map.bounds.Height / 100).ToString() + " ㎢";
53 int civility = this.branch.GetCivility();
54 this.textCivility.text = civility.ToString() + " " + ("(" + Lang.GetList("civility")[Mathf.Clamp(civility / 20, 0, 4)] + ")").TagSize(12);
55 int electricity = EMono._zone.GetElectricity(true);
56 int electricity2 = EMono._zone.GetElectricity(false);
57 this.textElec.SetText("elecLv".lang(electricity2.ToString() ?? "", (electricity.ToString() ?? "").TagColor((electricity <= electricity2) ? FontColor.Good : FontColor.Bad, null), null, null, null));
58 if (electricity > electricity2)
59 {
60 this.AddReport("rElecOver", UIHomeInfo.ReportData.ReportType.Warning, null, null);
61 }
62 int soilCost = this.zone.GetSoilCost();
63 int maxSoil = this.branch.MaxSoil;
64 this.textSoil.SetText("soilLv".lang(maxSoil.ToString() ?? "", ((maxSoil - soilCost).ToString() ?? "").TagColor((soilCost <= maxSoil) ? FontColor.Good : FontColor.Bad, null), null, null, null));
65 if (soilCost > maxSoil)
66 {
67 this.AddReport("rSoilOver", UIHomeInfo.ReportData.ReportType.Warning, null, null);
68 }
69 this.textName.SetText(this.zone.Name);
70 this.textRank.SetText(this.branch.RankText);
71 this.textPopu.SetText(this.faction.name);
72 this.textFaith.SetText(this.branch.faith.Name + Environment.NewLine + (" ♥" + this.branch.RankText).TagSize(13));
73 this.imageFaith.sprite = this.branch.faith.GetSprite();
74 this.textTemper.SetText(this.branch.faith.GetTextTemper(this.branch.temper));
75 this.barTemper.fillAmount = 0.5f + (float)this.branch.temper * 0.01f * 0.5f;
76 this.barTemper.color = ((this.branch.temper > -25) ? SkinManager.CurrentColors.textGood : SkinManager.CurrentColors.textBad);
77 if (this.buttonWorth)
78 {
79 this.buttonWorth.mainText.SetText(this.branch.Worth.ToFormat());
80 this.buttonWorth.SetTooltip(delegate(UITooltip t)
81 {
82 this.branch.resources.worth.WriteNote(t.note);
83 }, true);
84 }
85 this.buttonLv.mainText.SetText(this.branch.lv.ToString() ?? "");
86 this.buttonLv.SetTooltip(delegate(UITooltip t)
87 {
88 UIHomeInfo.<>c__DisplayClass38_0 CS$<>8__locals1;
89 CS$<>8__locals1.n = t.note;
90 CS$<>8__locals1.n.Clear();
91 CS$<>8__locals1.n.AddHeader("branchLv".lang(), null);
92 CS$<>8__locals1.n.AddTopic("TopicLeft", "vCurrent".lang(), EMono.Branch.TextLv);
93 CS$<>8__locals1.n.Space(0, 1);
94 this.<RefreshInfo>g__Write|38_6(this.branch.lv, ref CS$<>8__locals1);
95 if (this.branch.lv < this.branch.MaxLv)
96 {
97 CS$<>8__locals1.n.Space(0, 1);
98 CS$<>8__locals1.n.AddHeaderTopic("nextLevel", null);
99 this.<RefreshInfo>g__Write|38_6(this.branch.lv + 1, ref CS$<>8__locals1);
100 }
101 t.note.Build();
102 }, true);
103 this.buttonRanking.mainText.SetText(EMono.game.spatials.ranks.GetRankText(EMono._zone));
104 this.buttonRanking.SetTooltip(delegate(UITooltip t)
105 {
106 UINote note = t.note;
107 note.Clear();
108 note.AddHeader("homeRanking".lang(), null);
109 note.AddTopic("TopicLeft", "vCurrent".lang(), EMono.game.spatials.ranks.GetRankText(EMono._zone));
110 note.Space(0, 1);
111 note.AddHeader("HeaderTopic", "rank_income".lang(), null);
112 note.Space(1, 1);
113 note.AddText("rank_income2".lang(EMono.game.spatials.ranks.GetIncome(EMono._zone).ToFormat(), null, null, null, null), FontColor.DontChange);
114 t.note.Build();
115 }, true);
116 this.buttonRank.mainText.SetText(this.branch.rank.ToString() ?? "");
117 this.buttonRank.SetTooltip(delegate(UITooltip t)
118 {
119 UINote note = t.note;
120 note.Clear();
121 note.AddHeader("factionRank2".lang(), null);
122 note.AddTopic("TopicLeft", "vCurrent".lang(), this.branch.rank.ToString() ?? "");
123 t.note.Build();
124 }, true);
125 this.buttonHappinessResident.mainText.text = this.branch.happiness.residents.GetText();
126 this.buttonHappinessLivestock.mainText.text = this.branch.happiness.livestocks.GetText();
127 this.buttonHappinessResident.subText.text = (this.branch.CountMembers(FactionMemberType.Default, false).ToString() ?? "");
128 this.buttonHappinessLivestock.subText.text = (this.branch.CountMembers(FactionMemberType.Livestock, false).ToString() ?? "");
129 this.buttonHappinessResident.SetTooltip(delegate(UITooltip t)
130 {
131 this.branch.happiness.residents.WriteNote(t.note);
132 }, true);
133 this.buttonHappinessLivestock.SetTooltip(delegate(UITooltip t)
134 {
135 this.branch.happiness.livestocks.WriteNote(t.note);
136 }, true);
137 }
138
139 // Token: 0x06002520 RID: 9504 RVA: 0x000D2E6C File Offset: 0x000D106C
140 public string GetTextHappiness(List<Chara> list)
141 {
142 int num = 0;
143 int num2 = 0;
144 int num3 = 0;
145 int num4 = 0;
146 foreach (Chara chara in list)
147 {
148 int happiness = chara.GetHappiness();
149 if (happiness >= 80)
150 {
151 num2++;
152 }
153 else if (happiness >= 30)
154 {
155 num3++;
156 }
157 else
158 {
159 num4++;
160 }
161 num += happiness;
162 }
163 int avg = (list.Count == 0) ? 0 : (num / list.Count);
164 string s = string.Concat(new string[]
165 {
166 "(",
167 num2.ToString().TagColor(FontColor.Good, null),
168 "/",
169 num3.ToString().TagColor(FontColor.Default, null),
170 "/",
171 num4.ToString().TagColor(FontColor.Bad, null),
172 ")"
173 });
174 return (((list.Count == 0) ? " - " : avg.ToString()) + "%").TagColorGoodBad(() => list.Count == 0 || avg >= 50, false) + " " + s.TagSize(13);
175 }
176
177 // Token: 0x06002521 RID: 9505 RVA: 0x000D2FCC File Offset: 0x000D11CC
178 public void RefreshResources()
179 {
180 this.listCurrencies.Clear();
181 BaseList baseList = this.listCurrencies;
182 UIList.Callback<BaseHomeResource, ItemHomeResource> callback = new UIList.Callback<BaseHomeResource, ItemHomeResource>();
183 callback.onInstantiate = delegate(BaseHomeResource a, ItemHomeResource b)
184 {
185 b.SetResource(a);
186 };
187 callback.onList = delegate(UIList.SortMode m)
188 {
189 foreach (BaseHomeResource baseHomeResource in this.branch.resources.list)
190 {
191 if (baseHomeResource.IsCurrency && baseHomeResource.IsAvailable)
192 {
193 this.listCurrencies.Add(baseHomeResource);
194 }
195 }
196 };
197 baseList.callbacks = callback;
198 this.listCurrencies.List(false);
199 this.listResources.Clear();
200 BaseList baseList2 = this.listResources;
201 UIList.Callback<BaseHomeResource, ItemHomeResource> callback2 = new UIList.Callback<BaseHomeResource, ItemHomeResource>();
202 callback2.onInstantiate = delegate(BaseHomeResource a, ItemHomeResource b)
203 {
204 b.SetResource(a);
205 };
206 callback2.onList = delegate(UIList.SortMode m)
207 {
208 foreach (BaseHomeResource baseHomeResource in this.branch.resources.list)
209 {
210 if (baseHomeResource.IsRate && baseHomeResource.IsAvailable)
211 {
212 this.listResources.Add(baseHomeResource);
213 }
214 }
215 };
216 baseList2.callbacks = callback2;
217 this.listResources.List(false);
218 this.listSkill.Clear();
219 BaseList baseList3 = this.listSkill;
220 UIList.Callback<BaseHomeResource, ItemHomeResource> callback3 = new UIList.Callback<BaseHomeResource, ItemHomeResource>();
221 callback3.onInstantiate = delegate(BaseHomeResource a, ItemHomeResource b)
222 {
223 b.SetResource(a);
224 };
225 callback3.onList = delegate(UIList.SortMode m)
226 {
227 foreach (BaseHomeResource baseHomeResource in this.branch.resources.list)
228 {
229 if (baseHomeResource.IsSkill)
230 {
231 this.listSkill.Add(baseHomeResource);
232 }
233 }
234 };
235 baseList3.callbacks = callback3;
236 this.listSkill.List(false);
237 }
238
239 // Token: 0x06002522 RID: 9506 RVA: 0x000D30F4 File Offset: 0x000D12F4
240 public void AddReport(string text, UIHomeInfo.ReportData.ReportType type = UIHomeInfo.ReportData.ReportType.Default, Action onClick = null, Action<UITooltip> onShowTooltip = null)
241 {
243 {
244 text = text.lang(),
245 type = type,
246 onClick = onClick,
247 onShowTooltip = onShowTooltip
248 };
249 this.reports.Add(item);
250 }
251
252 // Token: 0x06002523 RID: 9507 RVA: 0x000D3138 File Offset: 0x000D1338
253 public void RefreshReport()
254 {
255 if (EMono.Branch.meetings.list.Count > 0)
256 {
257 this.AddReport("rMeeting".lang(EMono.Branch.meetings.list.Count.ToString() ?? "", null, null, null, null), UIHomeInfo.ReportData.ReportType.Default, null, null);
258 }
259 foreach (ZoneEvent zoneEvent in this.branch.owner.events.list)
260 {
261 if (zoneEvent.HasReport)
262 {
263 this.AddReport(zoneEvent.GetText(), UIHomeInfo.ReportData.ReportType.Trial, null, null);
264 }
265 }
266 foreach (ResearchPlan researchPlan in this.branch.researches.newPlans)
267 {
268 this.AddReport("rNewPlan".lang(researchPlan.Name ?? "", null, null, null, null), UIHomeInfo.ReportData.ReportType.Good, delegate
269 {
270 }, null);
271 }
272 foreach (ResearchPlan researchPlan2 in this.branch.researches.plans)
273 {
274 if (researchPlan2.exp == researchPlan2.MaxExp)
275 {
276 this.AddReport("vResearched".lang(researchPlan2.Name, null, null, null, null), UIHomeInfo.ReportData.ReportType.Great, delegate
277 {
278 }, null);
279 }
280 }
281 foreach (Chara chara in this.branch.members)
282 {
283 if (!chara.isDead && !chara.IsPCParty && chara.memberType == FactionMemberType.Default && !chara.noMove)
284 {
285 bool flag = false;
286 if (EMono.game.activeZone == this.branch.owner)
287 {
288 using (List<Hobby>.Enumerator enumerator4 = chara.ListWorks(true).GetEnumerator())
289 {
290 while (enumerator4.MoveNext())
291 {
292 if (enumerator4.Current.GetEfficiency(chara) > 0)
293 {
294 flag = true;
295 break;
296 }
297 }
298 goto IL_26A;
299 }
300 goto IL_259;
301 }
302 goto IL_259;
303 IL_26A:
304 if (!flag)
305 {
306 this.AddReport("rNoWork".lang(chara.Name, null, null, null, null).ToTitleCase(false), UIHomeInfo.ReportData.ReportType.Warning, null, null);
307 continue;
308 }
309 continue;
310 IL_259:
311 if (chara.GetWorkSummary().work != null)
312 {
313 flag = true;
314 goto IL_26A;
315 }
316 goto IL_26A;
317 }
318 }
319 if (EMono.player.taxBills > 0)
320 {
321 this.AddReport("rBill".lang(EMono.player.taxBills.ToString() ?? "", null, null, null, null), UIHomeInfo.ReportData.ReportType.Warning, null, null);
322 }
323 if (this.reports.Count == 0)
324 {
325 this.AddReport("rNoReport", UIHomeInfo.ReportData.ReportType.Good, null, null);
326 }
327 this.AddReport("rTax".lang((30 - EMono.world.date.day + 1).ToString() ?? "", this.faction.GetTotalTax(false).ToFormat(), null, null, null), UIHomeInfo.ReportData.ReportType.Default, null, delegate(UITooltip t)
328 {
329 t.note.Clear();
330 this.faction.SetTaxTooltip(t.note);
331 t.note.Build();
332 });
333 if (EMono.debug.showExtra)
334 {
335 this.AddReport("efficiency:" + this.branch.efficiency.ToString(), UIHomeInfo.ReportData.ReportType.Default, null, null);
336 }
337 this.reports.Sort((UIHomeInfo.ReportData a, UIHomeInfo.ReportData b) => b.type - a.type);
338 this.listReport.Clear();
339 BaseList baseList = this.listReport;
340 UIList.Callback<UIHomeInfo.ReportData, ItemGeneral> callback = new UIList.Callback<UIHomeInfo.ReportData, ItemGeneral>();
341 callback.onClick = delegate(UIHomeInfo.ReportData a, ItemGeneral b)
342 {
343 if (a.onClick != null)
344 {
345 a.onClick();
346 }
347 };
348 callback.onInstantiate = delegate(UIHomeInfo.ReportData a, ItemGeneral b)
349 {
350 b.SetMainText(a.text, this.iconReports[(int)a.type], true);
351 b.button1.mainText.SetColor(a.GetFontColor());
352 if (a.onClick != null)
353 {
354 b.AddSubButton(EMono.core.refs.icons.go, a.onClick, null, null);
355 }
356 b.Build();
357 if (a.onShowTooltip != null)
358 {
359 b.button1.SetTooltip(a.onShowTooltip, true);
360 }
361 };
362 callback.onList = delegate(UIList.SortMode m)
363 {
364 foreach (UIHomeInfo.ReportData o in this.reports)
365 {
366 this.listReport.Add(o);
367 }
368 };
369 callback.onRefresh = null;
370 baseList.callbacks = callback;
371 this.listReport.List(false);
372 }
373
374 // Token: 0x06002527 RID: 9511 RVA: 0x000D36BC File Offset: 0x000D18BC
375 [CompilerGenerated]
376 private void <RefreshInfo>g__Write|38_6(int lv, ref UIHomeInfo.<>c__DisplayClass38_0 A_2)
377 {
378 string[] array = this.branch.GetHearthHint(lv).SplitNewline();
379 for (int i = 0; i < array.Length; i++)
380 {
381 string text = array[i].Replace(Environment.NewLine, "");
382 if (!text.IsEmpty())
383 {
384 A_2.n.AddText(text, FontColor.DontChange);
385 }
386 }
387 }
388
389 // Token: 0x040014A9 RID: 5289
390 public Transform transLayout;
391
392 // Token: 0x040014AA RID: 5290
393 public UIText textFaction;
394
395 // Token: 0x040014AB RID: 5291
396 public UIText textDateFound;
397
398 // Token: 0x040014AC RID: 5292
399 public UIText textGod;
400
401 // Token: 0x040014AD RID: 5293
402 public UIText textMember;
403
404 // Token: 0x040014AE RID: 5294
405 public UIText textLand;
406
407 // Token: 0x040014AF RID: 5295
408 public UIText textHeaderReport;
409
410 // Token: 0x040014B0 RID: 5296
411 public UIText textDev;
412
413 // Token: 0x040014B1 RID: 5297
414 public UIText textElec;
415
416 // Token: 0x040014B2 RID: 5298
417 public UIText textCivility;
418
419 // Token: 0x040014B3 RID: 5299
420 public UIText textName;
421
422 // Token: 0x040014B4 RID: 5300
423 public UIText textRank;
424
425 // Token: 0x040014B5 RID: 5301
426 public UIText textPopu;
427
428 // Token: 0x040014B6 RID: 5302
429 public UIText textFaith;
430
431 // Token: 0x040014B7 RID: 5303
432 public UIText textTemper;
433
434 // Token: 0x040014B8 RID: 5304
435 public UIText textSoil;
436
437 // Token: 0x040014B9 RID: 5305
438 public UIText textContentLv;
439
440 // Token: 0x040014BA RID: 5306
441 public UIText textPasture;
442
443 // Token: 0x040014BB RID: 5307
444 public UIButton buttonHappinessResident;
445
446 // Token: 0x040014BC RID: 5308
447 public UIButton buttonHappinessLivestock;
448
449 // Token: 0x040014BD RID: 5309
450 public UIButton buttonWorth;
451
452 // Token: 0x040014BE RID: 5310
453 public UIButton buttonRank;
454
455 // Token: 0x040014BF RID: 5311
456 public UIButton buttonLv;
457
458 // Token: 0x040014C0 RID: 5312
459 public UIButton buttonRanking;
460
461 // Token: 0x040014C1 RID: 5313
462 public UIList listCurrencies;
463
464 // Token: 0x040014C2 RID: 5314
465 public UIList listResources;
466
467 // Token: 0x040014C3 RID: 5315
468 public UIList listSkill;
469
470 // Token: 0x040014C4 RID: 5316
471 public UIList listReport;
472
473 // Token: 0x040014C5 RID: 5317
474 public Faction faction;
475
476 // Token: 0x040014C6 RID: 5318
477 public FactionBranch branch;
478
479 // Token: 0x040014C7 RID: 5319
480 public Zone zone;
481
482 // Token: 0x040014C8 RID: 5320
483 public Image imageFaith;
484
485 // Token: 0x040014C9 RID: 5321
486 public Image barTemper;
487
488 // Token: 0x040014CA RID: 5322
489 public List<UIHomeInfo.ReportData> reports = new List<UIHomeInfo.ReportData>();
490
491 // Token: 0x040014CB RID: 5323
492 public Sprite[] iconReports;
493
494 // Token: 0x02000A81 RID: 2689
495 public class ReportData
496 {
497 // Token: 0x06004129 RID: 16681 RVA: 0x00150BC0 File Offset: 0x0014EDC0
498 public FontColor GetFontColor()
499 {
500 switch (this.type)
501 {
502 case UIHomeInfo.ReportData.ReportType.Warning:
503 return FontColor.Warning;
504 case UIHomeInfo.ReportData.ReportType.Critical:
505 return FontColor.Bad;
506 case UIHomeInfo.ReportData.ReportType.Good:
507 return FontColor.Good;
508 case UIHomeInfo.ReportData.ReportType.Great:
509 return FontColor.Good;
510 case UIHomeInfo.ReportData.ReportType.Trial:
511 return FontColor.Great;
512 default:
513 return FontColor.Default;
514 }
515 }
516
517 // Token: 0x04002AF2 RID: 10994
518 public UIHomeInfo.ReportData.ReportType type;
519
520 // Token: 0x04002AF3 RID: 10995
521 public string text;
522
523 // Token: 0x04002AF4 RID: 10996
524 public Action onClick;
525
526 // Token: 0x04002AF5 RID: 10997
527 public Action<UITooltip> onShowTooltip;
528
529 // Token: 0x02000C6B RID: 3179
530 public enum ReportType
531 {
532 // Token: 0x040030D9 RID: 12505
533 Default,
534 // Token: 0x040030DA RID: 12506
535 Warning,
536 // Token: 0x040030DB RID: 12507
537 Critical,
538 // Token: 0x040030DC RID: 12508
539 Good,
540 // Token: 0x040030DD RID: 12509
541 Great,
542 // Token: 0x040030DE RID: 12510
543 Trial
544 }
545 }
546}
Definition Chara.cs:12
Definition Date.cs:6
Definition EMono.cs:6
Definition Zone.cs:14