Elin Decompiled Documentation EA 23.167 Nightly
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 List<Sprite> sprites;
59
60 private bool started;
61
62 public int IdxCustom => 3;
63
64 public bool IsEmbark
65 {
66 get
67 {
69 {
71 }
72 return true;
73 }
74 }
75
76 public override void OnInit()
77 {
78 buttonEmbark.SetActive(IsEmbark);
79 buttonWorkaround.SetActive(enable: true);
80 if (IsEmbark)
81 {
83 }
84 pp = IO.DeepCopy(ELayer.game.principal);
85 transMold.SetActive(enable: false);
86 for (int j = 0; j < buttonTemplates.Count; j++)
87 {
88 int i = j;
89 UIButton uIButton = buttonTemplates[i];
90 uIButton.mainText.SetText(Lang.GetList("pp_templates")[i]);
91 if (i != IdxCustom)
92 {
93 uIButton.refObj = ELayer.setting.start.principals[i];
94 }
95 uIButton.SetOnClick(delegate
96 {
97 SetTemplate(i);
98 });
99 }
101 {
102 ELayer.player.showWorkaround = a;
103 Refresh();
104 });
105 Refresh();
106 }
107
108 public void SetTemplate(int idx)
109 {
110 pp.id = idx;
111 if (idx == IdxCustom)
112 {
113 pp.id = -1;
114 }
115 else
116 {
117 pp = IO.DeepCopy(ELayer.setting.start.principals[idx]);
118 }
119 Refresh();
120 }
121
122 public void RefreshTemplate()
123 {
124 if (pp.IsCustom)
125 {
127 }
128 else
129 {
131 }
132 textDetail.SetText(("vow_" + pp.id).lang());
133 }
134
135 public void Refresh()
136 {
138 transCustom.DestroyChildren();
139 List<GamePrincipal.Item> items = pp.ListItems();
140 AddCategory(GamePrincipal.Type.Oath);
142 {
143 AddCategory(GamePrincipal.Type.Workaround);
144 AddCategory(GamePrincipal.Type.Legacy);
145 }
146 transCustom.RebuildLayout();
147 void AddCategory(GamePrincipal.Type type)
148 {
149 Util.Instantiate(moldHeader, transCustom).text1.SetText(("pp_" + type).lang());
150 foreach (GamePrincipal.Item item in items.Where((GamePrincipal.Item a) => a.type == type))
151 {
152 UIButton b = null;
154 if (itemSlider == null)
155 {
156 if (item != null)
157 {
158 _ = item;
159 b = Util.Instantiate(moldToggle, transCustom);
160 }
161 }
162 else
163 {
164 b = Util.Instantiate(moldSlider, transCustom);
165 b.GetComponentInChildren<UISlider>().SetSlider(itemSlider.GetInt(), delegate(float a)
166 {
167 itemSlider.SetInt((int)a);
168 return itemSlider.funcText((int)a);
169 }, 0, itemSlider.max, notify: false);
170 }
171 bool flag = item.id == "permadeath" && !IsEmbark && !item.WasSealed();
172 b.mainText.SetText(("pp_" + item.id).lang());
173 b.icon.SetActive(item.grade >= 0 && (item.IsSealed() || item.WasSealed()));
174 b.icon.SetAlpha(item.IsSealed() ? 1f : 0.3f);
175 b.icon.sprite = ((item.grade < 0) ? null : sprites[item.grade]);
176 b.icon.SetNativeSize();
177 b.GetOrCreate<CanvasGroup>().alpha = (flag ? 0.5f : 1f);
178 string text = "pp_" + item.id + "_hint";
179 b.SetTooltipLang(text);
180 b.tooltip.enable = Lang.Has(text);
181 b.interactable = !flag;
182 b.SetToggle(item.Get(), delegate(bool a)
183 {
184 item.Set(a);
185 if (!pp.IsCustom)
186 {
187 pp.id = -1;
188 RefreshTemplate();
189 }
190 b.icon.SetActive(item.grade >= 0 && (item.IsSealed() || item.WasSealed()));
191 b.icon.SetAlpha(item.IsSealed() ? 1f : 0.3f);
192 });
193 }
194 }
195 }
196
197 public void StartGame()
198 {
200 {
201 Close();
202 return;
203 }
204 started = true;
205 Close();
206 if (!LayerDrama.Instance)
207 {
208 LayerDrama.ActivateMain("mono", "1-1");
209 }
210 }
211
212 public override void OnKill()
213 {
214 Apply();
215 }
216
217 public void Apply()
218 {
219 if (!IsEmbark)
220 {
221 pp.modified = ELayer.game.principal.modified;
222 foreach (GamePrincipal.Item item in pp.ListItems())
223 {
224 if (item.IsModified())
225 {
226 pp.modified.Add(item.id);
227 }
228 }
229 }
230 ELayer.game.principal = pp;
232 {
233 ELayer.player.resetPrincipal = false;
234 }
235 ELayer.pc.SetFeat(1220, pp.permadeath ? 1 : 0);
236 }
237}
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:9121
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