Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerEditPortrait.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
5
7{
9
10 public Chara chara;
11
13
15
17
18 public PCCData pcc;
19
21
23
25
26 public Action<Color> action;
27
28 private bool hasColorChanged;
29
30 private bool gender = true;
31
32 private bool unique;
33
34 public void Activate(Chara _chara, PCCData _pcc = null, Action<Color> _action = null)
35 {
36 chara = _chara;
37 pcc = _pcc;
38 action = _action;
39 if (action == null)
40 {
41 action = delegate
42 {
43 };
44 }
46 if (chara.GetInt(105) == 0)
47 {
49 }
50 else
51 {
53 }
54 if (pcc != null)
55 {
56 hairColor = pcc.GetHairColor();
57 }
59 {
60 ColorUtility.TryParseHtmlString("#" + ColorUtility.ToHtmlStringRGBA(_c), out var color);
61 if (pcc == null)
62 {
63 chara.SetInt(105, IntColor.ToInt(color));
64 }
65 else
66 {
67 pcc.SetColor("hair", color);
68 }
70 action(color);
71 hairColor = color;
72 hasColorChanged = true;
73 });
75 InvokeRepeating("RefreshHairColor", 0f, 0.1f);
76 buttonGender = windows[0].AddBottomButton("portrait_gender", delegate
77 {
78 gender = !gender;
80 list.List();
81 });
82 buttonUnique = windows[0].AddBottomButton("portrait_unique", delegate
83 {
84 unique = !unique;
86 list.List();
87 });
89 }
90
91 public void RefreshButtons()
92 {
93 buttonGender.mainText.SetText("portrait_gender".lang() + " (" + (gender ? "On" : "Off") + ")");
94 buttonUnique.mainText.SetText("portrait_unique".lang() + " (" + (unique ? "On" : "Off") + ")");
95 buttonGender.RebuildLayout();
96 buttonUnique.RebuildLayout();
97 }
98
99 public void OnClickClear()
100 {
101 SE.Trash();
102 chara.c_idPortrait = null;
105 }
106
107 public void RefreshHairColor()
108 {
109 if (hasColorChanged)
110 {
111 list.Redraw();
112 hasColorChanged = false;
113 }
114 }
115
116 public void RefreshList()
117 {
118 list.Clear();
119 list.callbacks = new UIList.Callback<ModItem<Sprite>, Portrait>
120 {
121 onClick = delegate(ModItem<Sprite> a, Portrait b)
122 {
123 list.Select(a);
124 SE.Click();
125 chara.c_idPortrait = a.id;
128 },
129 onRedraw = delegate(ModItem<Sprite> a, Portrait b, int i)
130 {
131 b.mainText.SetText(a.id);
133 b.tooltip.lang = a.id;
134 },
135 onList = delegate
136 {
137 int num = (gender ? chara.bio.gender : 0);
138 IEnumerable<ModItem<Sprite>> enumerable = Portrait.ListPortraits(num, "c").Concat(Portrait.ListPortraits(num, "guard")).Concat(Portrait.ListPortraits(num, "special"))
139 .Concat(Portrait.ListPortraits(num, "foxfolk"));
140 if (unique)
141 {
142 enumerable = enumerable.Concat(Portrait.ListPortraits(0, "UN"));
143 }
144 foreach (ModItem<Sprite> item in enumerable.ToList())
145 {
146 list.Add(item);
147 }
148 }
149 };
150 list.List();
152 }
153}
PickerState
Definition: PickerState.cs:2
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
string c_idPortrait
Definition: Card.cs:1409
Definition: Chara.cs:10
Definition: ELayer.cs:4
static int ToInt(ref Color c)
Definition: IntColor.cs:24
static Color32 FromInt(int i)
Definition: IntColor.cs:15
Action< Color > action
UIDynamicList list
UIColorPicker uiPicker
void Activate(Chara _chara, PCCData _pcc=null, Action< Color > _action=null)
List< Window > windows
Definition: Layer.cs:116
string id
Definition: ModItem.cs:10
static List< ModItem< Sprite > > ListPortraits(string idDict)
Definition: Portrait.cs:59
void SetPortrait(string id, Color colorOverlay=default(Color), bool applyColorMod=true)
Definition: Portrait.cs:213
Color GetRandomHairColor(Chara c)
Definition: Portrait.cs:205
void SetChara(Chara c, PCCData pccData=null)
Definition: Portrait.cs:138
UIText mainText
Definition: UIButton.cs:102
void SetColor(Color _startColor, Color _resetColor, Action< PickerState, Color > _onChangeColor)
override void List()
override void Redraw()
override void Add(object o)
bool Select(object o, bool invoke=false)
override void Clear()
Definition: UIList.cs:9
void SetText(string s)
Definition: UIText.cs:159