Elin Decompiled Documentation EA 23.188 Stable
Loading...
Searching...
No Matches
LayerWorldSetting.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using UnityEngine;
4using UnityEngine.UI;
5
7{
9
10 public List<UIButton> buttonTemplates;
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
42 public Image imageScoreBar;
43
45
47
49
51
53
54 public Transform transCustom;
55
56 public Transform transMold;
57
58 public Transform transHint;
59
60 public List<Sprite> sprites;
61
62 private bool started;
63
64 public int IdxCustom => 3;
65
66 public bool IsEmbark
67 {
68 get
69 {
71 {
73 }
74 return true;
75 }
76 }
77
78 public override void OnInit()
79 {
80 buttonEmbark.SetActive(IsEmbark);
81 buttonWorkaround.SetActive(enable: true);
82 transHint.SetActive(IsEmbark);
83 if (IsEmbark)
84 {
86 }
87 pp = IO.DeepCopy(ELayer.game.principal);
88 transMold.SetActive(enable: false);
89 for (int j = 0; j < buttonTemplates.Count; j++)
90 {
91 int i = j;
92 UIButton uIButton = buttonTemplates[i];
93 uIButton.mainText.SetText(Lang.GetList("pp_templates")[i]);
94 if (i != IdxCustom)
95 {
96 uIButton.refObj = ELayer.setting.start.principals[i];
97 }
98 uIButton.SetOnClick(delegate
99 {
100 SetTemplate(i);
101 });
102 }
104 {
105 ELayer.player.showWorkaround = a;
106 Refresh();
107 });
108 Refresh();
109 }
110
111 public void SetTemplate(int idx)
112 {
113 pp.id = idx;
114 if (idx == IdxCustom)
115 {
116 pp.id = -1;
117 }
118 else
119 {
120 pp = IO.DeepCopy(ELayer.setting.start.principals[idx]);
121 }
122 Refresh();
123 }
124
125 public void RefreshTemplate()
126 {
127 if (pp.IsCustom)
128 {
130 }
131 else
132 {
134 }
135 textDetail.SetText(("vow_" + pp.id).lang());
136 }
137
138 public void Refresh()
139 {
141 transCustom.DestroyChildren();
142 List<GamePrincipal.Item> items = pp.ListItems();
143 AddCategory(GamePrincipal.Type.Oath);
145 {
146 AddCategory(GamePrincipal.Type.Workaround);
147 AddCategory(GamePrincipal.Type.Legacy);
148 }
149 transCustom.RebuildLayout();
150 void AddCategory(GamePrincipal.Type type)
151 {
152 Util.Instantiate(moldHeader, transCustom).text1.SetText(("pp_" + type).lang());
153 foreach (GamePrincipal.Item item in items.Where((GamePrincipal.Item a) => a.type == type))
154 {
155 UIButton b = null;
157 if (itemSlider == null)
158 {
159 if (item != null)
160 {
161 _ = item;
162 b = Util.Instantiate(moldToggle, transCustom);
163 }
164 }
165 else
166 {
167 b = Util.Instantiate(moldSlider, transCustom);
168 b.GetComponentInChildren<UISlider>().SetSlider(itemSlider.GetInt(), delegate(float a)
169 {
170 itemSlider.SetInt((int)a);
171 return itemSlider.funcText((int)a);
172 }, 0, itemSlider.max, notify: false);
173 }
174 bool flag = item.id == "permadeath" && !IsEmbark && !item.WasSealed();
175 b.mainText.SetText(("pp_" + item.id).lang());
176 b.icon.SetActive(item.grade >= 0 && (item.IsSealed() || item.WasSealed()));
177 b.icon.SetAlpha(item.IsSealed() ? 1f : 0.3f);
178 b.icon.sprite = ((item.grade < 0) ? null : sprites[item.grade]);
179 b.icon.SetNativeSize();
180 b.GetOrCreate<CanvasGroup>().alpha = (flag ? 0.5f : 1f);
181 string text = "pp_" + item.id + "_hint";
182 b.SetTooltipLang(text);
183 b.tooltip.enable = Lang.Has(text);
184 b.interactable = !flag;
185 b.SetToggle(item.Get(), delegate(bool a)
186 {
187 item.Set(a);
188 if (!pp.IsCustom)
189 {
190 pp.id = -1;
191 RefreshTemplate();
192 }
193 b.icon.SetActive(item.grade >= 0 && (item.IsSealed() || item.WasSealed()));
194 b.icon.SetAlpha(item.IsSealed() ? 1f : 0.3f);
195 });
196 }
197 }
198 }
199
200 public void StartGame()
201 {
203 {
204 Close();
205 return;
206 }
207 started = true;
208 Close();
209 if (!LayerDrama.Instance)
210 {
211 LayerDrama.ActivateMain("mono", "1-1");
212 }
213 }
214
215 public override void OnKill()
216 {
217 Apply();
218 }
219
220 public void Apply()
221 {
222 if (!IsEmbark)
223 {
224 pp.modified = ELayer.game.principal.modified;
225 foreach (GamePrincipal.Item item in pp.ListItems())
226 {
227 if (item.IsModified())
228 {
229 pp.modified.Add(item.id);
230 }
231 }
232 }
233 ELayer.game.principal = pp;
235 {
236 ELayer.player.resetPrincipal = false;
237 }
238 ELayer.pc.SetFeat(1220, pp.permadeath ? 1 : 0);
239 }
240}
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:9377
bool IsGameStarted
Definition: Core.cs:84
Definition: ELayer.cs:4
static Chara pc
Definition: ELayer.cs:15
static Player player
Definition: ELayer.cs:13
static Core core
Definition: ELayer.cs:7
static Game game
Definition: ELayer.cs:9
static GameSetting setting
Definition: ELayer.cs:33
Func< int, string > funcText
void SetInt(int value)
HashSet< string > modified
List< Item > ListItems()
List< GamePrincipal > principals
Definition: GameSetting.cs:244
StartSetting start
Definition: GameSetting.cs:305
GamePrincipal principal
Definition: Game.cs:221
Definition: Lang.cs:6
static string[] GetList(string id)
Definition: Lang.cs:114
static bool Has(string id)
Definition: Lang.cs:100
static LayerDrama Instance
Definition: LayerDrama.cs:20
static LayerDrama ActivateMain(string idSheet, string idStep=null, Chara target=null, Card ref1=null, string tag="")
Definition: LayerDrama.cs:61
override void OnInit()
UIButton toggleUsermapBenefit
UIButton toggleInfiniteMarketFund
UIButton toggleDeathPenaltyProtection
void SetTemplate(int idx)
UISelectableGroup groupTemplate
List< UIButton > buttonTemplates
List< Sprite > sprites
override void OnKill()
virtual void Close()
Definition: Layer.cs:463
bool resetPrincipal
Definition: Player.cs:1097
bool showWorkaround
Definition: Player.cs:921
Image icon
Definition: UIButton.cs:110
UIText mainText
Definition: UIButton.cs:102
void SetTooltipLang(string lang=null)
Definition: UIButton.cs:373
void SetToggle(bool isOn, Action< bool > onToggle=null)
Definition: UIButton.cs:341
Definition: UIItem.cs:5
void Select(UIButton button, bool check=true)
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:159