Elin Decompiled Documentation EA 23.102 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 }
145 transCustom.RebuildLayout();
146 void AddCategory(GamePrincipal.Type type)
147 {
148 Util.Instantiate(moldHeader, transCustom).text1.SetText(("pp_" + type).lang());
149 foreach (GamePrincipal.Item item in items.Where((GamePrincipal.Item a) => a.type == type))
150 {
151 UIButton b = null;
153 if (itemSlider == null)
154 {
155 if (item != null)
156 {
157 _ = item;
158 b = Util.Instantiate(moldToggle, transCustom);
159 }
160 }
161 else
162 {
163 b = Util.Instantiate(moldSlider, transCustom);
164 b.GetComponentInChildren<UISlider>().SetSlider(itemSlider.GetInt(), delegate(float a)
165 {
166 itemSlider.SetInt((int)a);
167 return itemSlider.funcText((int)a);
168 }, 0, itemSlider.max, notify: false);
169 }
170 bool flag = item.id == "permadeath" && !IsEmbark && !item.WasSealed();
171 b.mainText.SetText(("pp_" + item.id).lang());
172 b.icon.SetActive(item.IsSealed() || item.WasSealed());
173 b.icon.SetAlpha(item.IsSealed() ? 1f : 0.3f);
174 b.icon.sprite = sprites[item.grade];
175 b.icon.SetNativeSize();
176 b.GetOrCreate<CanvasGroup>().alpha = (flag ? 0.5f : 1f);
177 string text = "pp_" + item.id + "_hint";
178 b.SetTooltipLang(text);
179 b.tooltip.enable = Lang.Has(text);
180 b.interactable = !flag;
181 b.SetToggle(item.Get(), delegate(bool a)
182 {
183 item.Set(a);
184 if (!pp.IsCustom)
185 {
186 pp.id = -1;
187 RefreshTemplate();
188 }
189 b.icon.SetActive(item.IsSealed() || item.WasSealed());
190 b.icon.SetAlpha(item.IsSealed() ? 1f : 0.3f);
191 });
192 }
193 }
194 }
195
196 public void StartGame()
197 {
199 {
200 Close();
201 return;
202 }
203 started = true;
204 Close();
205 if (!LayerDrama.Instance)
206 {
207 LayerDrama.ActivateMain("mono", "1-1");
208 }
209 }
210
211 public override void OnKill()
212 {
213 Apply();
214 }
215
216 public void Apply()
217 {
218 if (!IsEmbark)
219 {
220 pp.modified = ELayer.game.principal.modified;
221 foreach (GamePrincipal.Item item in pp.ListItems())
222 {
223 if (item.IsModified())
224 {
225 pp.modified.Add(item.id);
226 }
227 }
228 }
229 ELayer.game.principal = pp;
231 {
232 ELayer.player.resetPrincipal = false;
233 }
234 ELayer.pc.SetFeat(1220, pp.permadeath ? 1 : 0);
235 }
236}
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:8964
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:978
bool showWorkaround
Definition: Player.cs:802
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