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