Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
UICharaMaker.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using DG.Tweening;
5using UnityEngine;
6using UnityEngine.UI;
7
8public class UICharaMaker : EMono
9{
10 public Chara chara;
11
13
15
16 public InputField inputName;
17
18 public InputField inputAlias;
19
20 public InputField inputJob;
21
22 public InputField inputRace;
23
24 public InputField inputGender;
25
26 public InputField inputAge;
27
29
30 public List<SourceRace.Row> races = new List<SourceRace.Row>();
31
32 public List<SourceJob.Row> jobs = new List<SourceJob.Row>();
33
35
37
38 public UINote note;
39
40 public UINote note2;
41
43
45
46 public bool addShadow;
47
48 public bool extraRace;
49
51
53
54 public int ageIndex;
55
56 public Vector2 posList;
57
58 public Vector2 posList2;
59
60 [NonSerialized]
61 public string[] listMode;
62
63 [NonSerialized]
64 public string[] listDifficulties;
65
67
68 public string TextUnknown => "lore_unknown".lang();
69
70 public void SetChara(Chara c)
71 {
72 listMode = Lang.GetList("startMode");
73 listDifficulties = Lang.GetList("difficulties");
75 chara = c;
76 BuildRaces();
80 Refresh();
81 toggleExtra.SetToggle(extraRace, delegate(bool a)
82 {
83 extraRace = a;
84 BuildRaces();
85 SE.Tab();
86 });
87 }
88
89 public void BuildRaces()
90 {
91 races.Clear();
92 jobs.Clear();
93 bool flag = EMono.core.config.test.extraRace;
94 foreach (SourceRace.Row row in EMono.sources.races.rows)
95 {
96 if (row.playable == 1 || (row.playable <= 6 && extraRace) || (flag && row.playable != 9))
97 {
98 races.Add(row);
99 }
100 }
101 foreach (SourceJob.Row row2 in EMono.sources.jobs.rows)
102 {
103 if (row2.playable == 1 || (row2.playable <= 6 && extraRace) || (flag && row2.playable != 9))
104 {
105 jobs.Add(row2);
106 }
107 }
108 races.Sort((SourceRace.Row a, SourceRace.Row b) => (a.playable - b.playable) * 10000 + a._index - b._index);
109 jobs.Sort((SourceJob.Row a, SourceJob.Row b) => (a.playable - b.playable) * 10000 + a._index - b._index);
110 }
111
112 private void Update()
113 {
115 }
116
117 public void RefreshPortraitZoom(bool force = false)
118 {
119 if (!portraitZoom)
120 {
121 return;
122 }
123 List<GameObject> hovered = InputModuleEX.GetPointerEventData().hovered;
124 bool enable = false;
125 foreach (GameObject item in hovered)
126 {
127 if (item.transform.IsChildOf(portrait.transform))
128 {
129 enable = true;
130 break;
131 }
132 }
133 portraitZoom.SetActive(enable);
134 }
135
136 public void Refresh()
137 {
139 Prologue prologue = EMono.game.Prologue;
140 textSign.SetText("signDisembark".lang(prologue.month.ToString() ?? "", prologue.day.ToString() ?? "", prologue.year.ToString() ?? ""));
142 inputAlias.text = chara.Aka;
143 inputName.text = chara.c_altName;
144 inputRace.text = chara.race.GetText().ToTitleCase(wholeText: true);
145 inputJob.text = chara.job.GetText().ToTitleCase(wholeText: true);
146 inputGender.text = Lang._gender(chara.bio.gender);
147 inputAge.text = Lang.GetList("ages")[ageIndex];
148 note.Clear();
149 note.AddTopic("name".lang(), "nameBio".lang(chara.NameSimple, chara.Aka));
150 note.AddTopic("birthday".lang(), bio.TextBirthDate(chara, _age: true) + ((ageIndex == 0) ? "" : (" (" + Lang.GetList("ages")[ageIndex] + ")")));
151 note.AddTopic("appearance".lang(), bio.TextAppearance());
152 note.AddTopic("dad".lang(), bio.nameDad.ToTitleCase());
153 note.AddTopic("mom".lang(), bio.nameMom.ToTitleCase());
154 note.AddTopic("birthLoc".lang(), bio.nameBirthplace.ToTitleCase());
155 note.Build();
156 noteRace.Clear();
157 noteRace.AddHeaderTopic("race".lang() + ": " + chara.race.GetText().ToTitleCase(wholeText: true));
158 noteRace.Space(8);
159 noteRace.AddText("NoteText_long", chara.race.GetDetail().IsEmpty(TextUnknown)).Hyphenate();
160 noteRace.Build();
161 noteJob.Clear();
162 noteJob.AddHeaderTopic("job".lang() + ": " + chara.job.GetText().ToTitleCase(wholeText: true));
163 noteJob.Space(8);
164 noteJob.AddText("NoteText_long", chara.job.GetDetail().IsEmpty(TextUnknown)).Hyphenate();
165 AddDomain(noteJob, EMono.player.GetDomains(), button: true);
166 noteJob.Build();
167 note2.Clear();
168 note2.AddHeaderTopic("attributes".lang());
169 chara.elements.AddNote(note2, (Element e) => e.HasTag("primary"), null, ElementContainer.NoteMode.CharaMake);
170 note2.Space();
171 note2.AddHeaderTopic("skills".lang());
172 chara.elements.AddNote(note2, (Element e) => e.source.category == "skill" && e.ValueWithoutLink > 1 && e.source.categorySub != "weapon", null, ElementContainer.NoteMode.CharaMake);
173 note2.Space();
174 note2.AddHeaderTopic("feats".lang());
175 chara.elements.AddNote(note2, (Element e) => e is Feat && e.id != 1220, null, ElementContainer.NoteMode.CharaMake, addRaceFeat: true);
176 note2.Build();
177 if (!addShadow)
178 {
179 return;
180 }
181 Text[] componentsInChildren = note2.gameObject.GetComponentsInChildren<Text>();
182 foreach (Text text in componentsInChildren)
183 {
184 Shadow shadow = text.GetComponent<Shadow>();
185 if (!shadow)
186 {
187 shadow = text.gameObject.AddComponent<Shadow>();
188 }
189 shadow.effectColor = Color.black;
190 }
191 }
192
193 public void ListModes()
194 {
195 EMono.ui.AddLayer<LayerList>().SetStringList(() => listMode, delegate(int a, string b)
196 {
197 EMono.game.idPrologue = a;
198 Prologue prologue = EMono.game.Prologue;
199 EMono.world.date.year = prologue.year;
200 EMono.world.date.month = prologue.month;
201 EMono.world.date.day = prologue.day;
202 EMono.world.weather._currentCondition = prologue.weather;
204 Refresh();
205 }).SetSize()
206 .SetTitles("wStartMode");
207 }
208
209 public void RerollAlias()
210 {
211 chara._alias = AliasGen.GetRandomAlias();
212 Refresh();
213 }
214
215 public void ListAlias()
216 {
217 EMono.ui.AddLayer<LayerList>().SetStringList(delegate
218 {
219 List<string> list = new List<string>();
220 for (int i = 0; i < 10; i++)
221 {
222 list.Add(AliasGen.GetRandomAlias());
223 }
224 return list;
225 }, delegate(int a, string b)
226 {
227 chara._alias = b;
228 Refresh();
229 }).SetSize()
230 .EnableReroll()
231 .SetTitles("wAlias");
232 }
233
234 public void RerollName()
235 {
236 chara.c_altName = NameGen.getRandomName();
237 Refresh();
238 }
239
240 public void EditName()
241 {
242 Dialog.InputName("dialogChangeName", chara.c_altName.IsEmpty(chara.NameSimple), delegate(bool cancel, string text)
243 {
244 if (!cancel)
245 {
246 chara.c_altName = text;
247 Refresh();
248 }
249 }).SetOnKill(delegate
250 {
251 EMono.ui.hud.hint.Show("hintEmbarkTop".lang(), icon: false);
252 });
253 }
254
255 public void OnEndEditName()
256 {
257 chara.c_altName = inputName.text;
258 }
259
260 public void RerollRace()
261 {
262 chara.ChangeRace(races.RandomItem(chara.race).id);
263 RerollBio(keepParent: true);
264 }
265
266 public void ListRace()
267 {
268 TooltipManager.Instance.HideTooltips(immediate: true);
269 TooltipManager.Instance.disableHide = "note";
270 bool first = true;
271 EMono.ui.AddLayer<LayerList>().SetPivot(0.5f, 0.2f).SetSize(260f)
272 .SetList2(races, (SourceRace.Row a) => a.GetText().ToTitleCase(wholeText: true), delegate(SourceRace.Row a, ItemGeneral b)
273 {
274 chara.ChangeRace(a.id);
275 RerollBio(keepParent: true);
276 }, delegate(SourceRace.Row a, ItemGeneral item)
277 {
278 UIButton b2 = item.button1;
279 b2.SetTooltip(delegate(UITooltip t)
280 {
281 ElementContainer elementContainer = new ElementContainer();
282 elementContainer.ApplyElementMap(EMono.pc.uid, SourceValueType.Chara, a.elementMap, 1);
283 elementContainer.ApplyPotential(1);
284 t.note.Clear();
285 t.note.AddHeader(a.GetText().ToTitleCase(wholeText: true));
286 elementContainer.AddNoteAll(t.note);
287 t.note.AddHeader("lore");
288 t.note.AddText("NoteText_long", a.GetDetail().IsEmpty(TextUnknown)).Hyphenate();
289 t.note.Space(8);
290 t.note.Build();
291 });
292 if (first)
293 {
294 TooltipManager.Instance.GetComponent<CanvasGroup>().alpha = 0f;
295 TooltipManager.Instance.GetComponent<CanvasGroup>().DOFade(1f, 0.3f);
296 EMono.core.actionsNextFrame.Add(delegate
297 {
299 });
300 }
301 first = false;
302 })
303 .SetTitles("wRace");
304 RectTransform rectTransform = EMono.ui.GetLayer<LayerList>().windows[0].Rect();
305 rectTransform.pivot = new Vector2(0.5f, 0.5f);
306 rectTransform.anchoredPosition = posList;
307 TweenUtil.Tween(0.3f, null, delegate
308 {
310 });
311 }
312
313 public void RerollJob()
314 {
315 chara.ChangeJob(jobs.RandomItem(chara.job).id);
317 Refresh();
318 }
319
320 public void ListJob()
321 {
322 TooltipManager.Instance.HideTooltips(immediate: true);
323 TooltipManager.Instance.disableHide = "note";
324 bool first = true;
325 EMono.ui.AddLayer<LayerList>().SetPivot(0.5f, 0.1f).SetSize(260f)
326 .SetList2(jobs, (SourceJob.Row a) => a.GetText().ToTitleCase(wholeText: true), delegate(SourceJob.Row a, ItemGeneral b)
327 {
328 chara.ChangeJob(a.id);
330 RerollBio(keepParent: true);
331 }, delegate(SourceJob.Row a, ItemGeneral item)
332 {
333 UIButton b2 = item.button1;
334 b2.SetTooltip(delegate(UITooltip t)
335 {
336 ElementContainer elementContainer = new ElementContainer();
337 elementContainer.ApplyElementMap(EMono.pc.uid, SourceValueType.Chara, a.elementMap, 1);
338 elementContainer.ApplyPotential(2);
339 t.note.Clear();
340 t.note.AddHeader(a.GetText().ToTitleCase(wholeText: true));
341 elementContainer.AddNoteAll(t.note);
342 t.note.AddHeader("lore");
343 t.note.AddText("NoteText_long", a.GetDetail().IsEmpty(TextUnknown)).Hyphenate();
344 AddDomain(t.note, new ElementContainer().ImportElementMap(a.domain), button: false);
345 t.note.Build();
346 });
347 if (first)
348 {
349 TooltipManager.Instance.GetComponent<CanvasGroup>().alpha = 0f;
350 TooltipManager.Instance.GetComponent<CanvasGroup>().DOFade(1f, 0.3f);
351 EMono.core.actionsNextFrame.Add(delegate
352 {
354 });
355 }
356 first = false;
357 })
358 .SetTitles("wClass");
359 RectTransform rectTransform = EMono.ui.GetLayer<LayerList>().windows[0].Rect();
360 rectTransform.pivot = new Vector2(0.5f, 0.5f);
361 rectTransform.anchoredPosition = posList;
362 TweenUtil.Tween(0.3f, null, delegate
363 {
365 });
366 }
367
368 public void AddDomain(UINote n, ElementContainer domains, bool button)
369 {
370 n.Space(8);
371 string text = "";
372 foreach (Element value in domains.dict.Values)
373 {
374 text = text + ((value == domains.dict.Values.First()) ? "" : ", ") + value.Name;
375 }
376 UIItem uIItem = n.AddTopic("TopicDomain", "domain".lang(), text);
377 uIItem.button1.SetActive(button && EMono.pc.HasElement(1402));
378 uIItem.button1.SetOnClick(delegate
379 {
381 });
382 }
383
384 public void ListGender()
385 {
386 EMono.ui.AddLayer<LayerList>().SetStringList(() => Lang.GetList("genders"), delegate(int a, string b)
387 {
388 if (chara.bio.gender != a)
389 {
394 }
396 Refresh();
397 }).SetTitles("wGender");
398 }
399
400 public void ListAge()
401 {
402 EMono.ui.AddLayer<LayerList>().SetStringList(() => Lang.GetList("ages"), delegate(int a, string b)
403 {
404 if (ageIndex != a)
405 {
406 ageIndex = a;
407 RerollBio(keepParent: true);
408 }
409 Refresh();
410 }).SetTitles("wAge");
411 }
412
413 public void SetPortraitSlider()
414 {
415 }
416
417 public void RerollPCC()
418 {
419 chara.pccData.Randomize(null, null, randomizeHairColor: false);
422 }
423
424 public void RerollHair()
425 {
426 chara.pccData.SetRandomColor("hair");
429 }
430
431 public void RerollBio()
432 {
433 RerollBio(keepParent: false);
434 }
435
436 public void RerollBio(bool keepParent)
437 {
438 bio.RerollBio(chara, ageIndex, keepParent);
439 Refresh();
440 }
441
442 public void EditPCC()
443 {
444 EMono.ui.AddLayer<LayerEditPCC>().Activate(chara, UIPCC.Mode.Body, null, delegate
445 {
448 });
449 }
450
452 {
453 EMono.ui.AddLayer<LayerEditPortrait>().Activate(chara, chara.pccData, delegate
454 {
455 portrait.SetChara(chara, chara.pccData);
456 });
457 }
458}
SourceValueType
List< Action > actionsNextFrame
Definition: BaseCore.cs:31
void SetGender(int g)
Definition: Biography.cs:450
string nameBirthplace
Definition: Biography.cs:264
string nameDad
Definition: Biography.cs:260
string TextBirthDate(Chara c, bool _age=false)
Definition: Biography.cs:489
void RerollBio(Chara c, int ageIndex=0, bool keepParent=false)
Definition: Biography.cs:377
string nameMom
Definition: Biography.cs:262
int gender
Definition: Biography.cs:29
string TextAppearance()
Definition: Biography.cs:494
ElementContainerCard elements
Definition: Card.cs:37
bool HasElement(int ele, int req=1)
Definition: Card.cs:5214
string c_altName
Definition: Card.cs:1493
Biography bio
Definition: Card.cs:40
int uid
Definition: Card.cs:118
string NameSimple
Definition: Card.cs:2015
Definition: Chara.cs:10
void ChangeRace(string idNew)
Definition: Chara.cs:1989
SourceJob.Row job
Definition: Chara.cs:451
string Aka
Definition: Chara.cs:201
string GetIdPortraitCat()
Definition: Chara.cs:7320
void ChangeJob(string idNew)
Definition: Chara.cs:1891
PCCData pccData
Definition: Chara.cs:64
SourceRace.Row race
Definition: Chara.cs:449
CoreConfig config
Definition: Core.cs:70
Definition: Dialog.cs:7
static Dialog InputName(string langDetail, string text, Action< bool, string > onClose, InputType inputType=InputType.Default)
Definition: Dialog.cs:528
Definition: EMono.cs:4
static Core core
Definition: EMono.cs:5
static Chara pc
Definition: EMono.cs:13
static Player player
Definition: EMono.cs:11
static Game game
Definition: EMono.cs:7
static UI ui
Definition: EMono.cs:15
static SourceManager sources
Definition: EMono.cs:41
void ApplyPotential(int mode=0)
void AddNoteAll(UINote n)
void AddNote(UINote n, Func< Element, bool > isValid=null, Action onAdd=null, NoteMode mode=NoteMode.Default, bool addRaceFeat=false, Func< Element, string, string > funcText=null, Action< UINote, Element > onAddNote=null)
void ApplyElementMap(int uid, SourceValueType type, Dictionary< int, int > map, int lv, bool invert=false, bool applyFeat=false)
int ValueWithoutLink
Definition: ELEMENT.cs:284
int id
Definition: ELEMENT.cs:240
SourceElement.Row source
Definition: ELEMENT.cs:263
bool HasTag(string tag)
Definition: ELEMENT.cs:463
Definition: FEAT.cs:249
Prologue Prologue
Definition: Game.cs:257
int idPrologue
Definition: Game.cs:200
static PointerEventData GetPointerEventData(int pointerId=-1)
Definition: Lang.cs:6
static string _gender(int id)
Definition: Lang.cs:177
static string[] GetList(string id)
Definition: Lang.cs:114
LayerList SetSize(float w=450f, float h=-1f)
Definition: LayerList.cs:96
LayerList EnableReroll()
Definition: LayerList.cs:259
Layer SetTitles(string langList, string idHeaderRow=null)
Definition: Layer.cs:688
Layer SelectDomain(Action onKill=null)
Definition: Player.cs:1342
void RefreshDomain()
Definition: Player.cs:1323
ElementContainer GetDomains()
Definition: Player.cs:1332
static string GetRandomPortrait(string idDict)
Definition: Portrait.cs:105
void SetChara(Chara c, PCCData pccData=null)
Definition: Portrait.cs:138
Weather.Condition weather
Definition: Prologue.cs:27
int month
Definition: Prologue.cs:15
int day
Definition: Prologue.cs:17
int year
Definition: Prologue.cs:13
SourceRace races
SourceJob jobs
static TooltipManager Instance
void HideTooltips(bool immediate=false)
void SetTooltip(Action< UITooltip > onShowTooltip=null, bool enable=true)
Definition: UIButton.cs:361
void ShowTooltipForced(bool ignoreWhenRightClick=true)
Definition: UIButton.cs:387
void SetToggle(bool isOn, Action< bool > onToggle=null)
Definition: UIButton.cs:341
static void TryShowTip(Transform root=null, bool highlight=true, bool ignoreWhenRightClick=true)
Definition: UIButton.cs:778
void RefreshPortraitZoom(bool force=false)
InputField inputName
Definition: UICharaMaker.cs:16
void AddDomain(UINote n, ElementContainer domains, bool button)
UINote note2
Definition: UICharaMaker.cs:40
void RerollHair()
void BuildRaces()
Definition: UICharaMaker.cs:89
void RerollPCC()
UISlider sliderPortrait
Definition: UICharaMaker.cs:28
InputField inputGender
Definition: UICharaMaker.cs:24
void EditPCC()
void ListGender()
string TextUnknown
Definition: UICharaMaker.cs:68
void RerollJob()
void Refresh()
List< SourceRace.Row > races
Definition: UICharaMaker.cs:30
Portrait portraitZoom
Definition: UICharaMaker.cs:14
UIButton toggleParentLock
Definition: UICharaMaker.cs:36
UINote noteJob
Definition: UICharaMaker.cs:42
string[] listDifficulties
Definition: UICharaMaker.cs:64
void SetPortraitSlider()
Biography bio
Definition: UICharaMaker.cs:66
void ListModes()
Vector2 posList2
Definition: UICharaMaker.cs:58
void ListRace()
void RerollBio()
void EditName()
UIButton toggleExtra
Definition: UICharaMaker.cs:34
InputField inputJob
Definition: UICharaMaker.cs:20
void SetChara(Chara c)
Definition: UICharaMaker.cs:70
InputField inputAlias
Definition: UICharaMaker.cs:18
UIText textMode
Definition: UICharaMaker.cs:52
UIText textSign
Definition: UICharaMaker.cs:50
void OnClickChangePortrait()
void ListJob()
void RerollName()
UINote noteRace
Definition: UICharaMaker.cs:44
void ListAlias()
void ListAge()
InputField inputAge
Definition: UICharaMaker.cs:26
string[] listMode
Definition: UICharaMaker.cs:61
void OnEndEditName()
Portrait portrait
Definition: UICharaMaker.cs:12
Vector2 posList
Definition: UICharaMaker.cs:56
void RerollRace()
List< SourceJob.Row > jobs
Definition: UICharaMaker.cs:32
InputField inputRace
Definition: UICharaMaker.cs:22
void RerollBio(bool keepParent)
void RerollAlias()
Definition: UIItem.cs:5
UIButton button1
Definition: UIItem.cs:18
void Hyphenate()
Definition: UIItem.cs:45
Definition: UINote.cs:6
UIItem AddHeaderTopic(string text, Sprite sprite=null)
Definition: UINote.cs:89
void Clear()
Definition: UINote.cs:35
UIItem AddHeader(string text, Sprite sprite=null)
Definition: UINote.cs:79
UIItem AddTopic(string id, string text, string value=null)
Definition: UINote.cs:144
UIItem AddText(string text, FontColor color=FontColor.DontChange)
Definition: UINote.cs:113
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62
void Build()
Definition: UINote.cs:49
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:159
UINote note
Definition: UITooltip.cs:21