Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerEditHouse.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.IO;
3using System.Linq;
4using SFB;
5using UnityEngine;
6
7public class LayerEditHouse : ELayer
8{
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
47 public int maxWallDeco;
48
49 private bool first = true;
50
52
53 public override void OnInit()
54 {
55 windows[0].AddBottomButton("save", delegate
56 {
58 {
59 string text = StandaloneFileBrowser.SaveFilePanel("Save Template", CorePath.LotTemplate, "new house", "tpl");
60 if (!string.IsNullOrEmpty(text))
61 {
62 IO.SaveFile(text, board.data);
64 }
65 });
66 });
67 }
68
70 {
71 if ((bool)BuildMenu.Instance)
72 {
73 BuildMenu.Instance.SetActive(enable: false);
74 }
75 ELayer.screen.tileMap.usingHouseBoard = true;
76 board = b;
77 ddRoofStyle.SetList(data.idRoofStyle, ELayer.screen.tileMap.roofStyles, (RoofStyle a, int b) => a.GetName(b).lang(), delegate(int a, RoofStyle b)
78 {
79 data.idRoofStyle = a;
80 ApplyData();
82 });
83 toggleReverse.SetToggle(data.reverse, delegate(bool on)
84 {
85 data.reverse = on;
86 ApplyData();
87 });
88 toggleAltRoof.SetToggle(data.altRoof, delegate(bool on)
89 {
90 data.altRoof = on;
91 ApplyData();
92 });
93 List<int> blocks = new List<int>();
94 int num = 0;
95 blocks.Add(0);
96 foreach (SourceObj.Row row in ELayer.sources.objs.rows)
97 {
98 if (row.tileType == TileType.Roof && !row.tag.Contains("hidden"))
99 {
100 blocks.Add(row.id);
101 }
102 }
103 num = blocks.IndexOf(data.idRoofTile);
104 if (num == -1)
105 {
106 num = 0;
107 }
108 sliderRoof.SetList(num, blocks, delegate(int a, int b)
109 {
110 data.idRoofTile = b;
111 ApplyData();
112 }, (int a) => blocks.IndexOf(a).ToString() ?? "");
113 List<int> ramps = new List<int>();
114 foreach (SourceBlock.Row row2 in ELayer.sources.blocks.rows)
115 {
116 if (row2.tileType == TileType.Stairs || row2.tileType == TileType.Slope)
117 {
118 ramps.Add(row2.id);
119 }
120 }
121 int num2 = ramps.IndexOf(data.idRamp);
122 if (num2 == -1)
123 {
124 num2 = 0;
125 }
126 sliderRamp.SetList(num2, ramps, delegate(int a, int b)
127 {
128 data.idRamp = b;
129 ApplyData();
130 }, (int a) => ramps.IndexOf(a).ToString() ?? "");
131 sliderWallHeight.SetSlider(data.height, delegate(float a)
132 {
133 data.height = (int)a;
134 ApplyData();
135 return a.ToString() ?? "";
136 }, 1, 20);
137 sliderHeightFix.SetSlider(data.heightFix, delegate(float a)
138 {
139 data.heightFix = (int)a;
140 ApplyData();
141 return a.ToString() ?? "";
142 }, 0, 60);
143 sliderDecoFix.SetSlider(data.decoFix, delegate(float a)
144 {
145 data.decoFix = (int)a;
146 ApplyData();
147 return a.ToString() ?? "";
148 }, -20, 20);
149 sliderDecoFix2.SetSlider(data.decoFix2, delegate(float a)
150 {
151 data.decoFix2 = (int)a;
152 ApplyData();
153 return a.ToString() ?? "";
154 }, -20, 400);
155 sliderDeco.SetSlider(data.idDeco, delegate(float a)
156 {
157 data.idDeco = (int)a;
158 ApplyData();
159 return a.ToString() ?? "";
160 }, 0, maxWallDeco);
161 sliderDeco2.SetSlider(data.idDeco2, delegate(float a)
162 {
163 data.idDeco2 = (int)a;
164 ApplyData();
165 return a.ToString() ?? "";
166 }, 0, maxWallDeco);
167 if (first)
168 {
170 }
172 first = false;
173 }
174
175 private void RefreshBlockList()
176 {
177 bool num = ELayer.screen.tileMap.roofStyles[data.idRoofStyle].type != RoofStyle.Type.FlatFloor;
178 List<int> blocks = new List<int>();
179 if (num)
180 {
181 foreach (SourceBlock.Row row in ELayer.sources.blocks.rows)
182 {
183 if (row.tileType == TileType.Block)
184 {
185 blocks.Add(row.id);
186 }
187 }
188 }
189 else
190 {
191 foreach (SourceFloor.Row row2 in ELayer.sources.floors.rows)
192 {
193 blocks.Add(row2.id);
194 }
195 }
196 int num2 = blocks.IndexOf(data.idBlock);
197 if (num2 == -1)
198 {
199 num2 = 0;
200 }
201 sliderBlock.SetList(num2, blocks, delegate(int a, int b)
202 {
203 data.idBlock = b;
204 ApplyData();
205 }, (int a) => blocks.IndexOf(a).ToString() ?? "");
206 buttonColorRoof.icon.color = IntColor.FromInt(data.colRoof);
207 buttonColorRoof.SetOnClick(delegate
208 {
209 ELayer.ui.AddLayer<LayerColorPicker>().SetColor(IntColor.FromInt(data.colRoof), IntColor.FromInt(data.colRoof), delegate(PickerState state, Color c)
210 {
211 data.colRoof = IntColor.ToInt(c);
212 buttonColorRoof.icon.color = c;
214 });
215 });
216 buttonColorBlock.icon.color = IntColor.FromInt(data.colBlock);
217 buttonColorBlock.SetOnClick(delegate
218 {
219 ELayer.ui.AddLayer<LayerColorPicker>().SetColor(IntColor.FromInt(data.colBlock), IntColor.FromInt(data.colBlock), delegate(PickerState state, Color c)
220 {
221 data.colBlock = IntColor.ToInt(c);
222 buttonColorBlock.icon.color = c;
224 });
225 });
226 buttonColorDeco.icon.color = IntColor.FromInt(data.colDeco);
227 buttonColorDeco.SetOnClick(delegate
228 {
229 ELayer.ui.AddLayer<LayerColorPicker>().SetColor(IntColor.FromInt(data.colDeco), IntColor.FromInt(data.colDeco), delegate(PickerState state, Color c)
230 {
231 data.colDeco = IntColor.ToInt(c);
232 buttonColorDeco.icon.color = c;
234 });
235 });
236 buttonColorDeco2.icon.color = IntColor.FromInt(data.colDeco2);
237 buttonColorDeco2.SetOnClick(delegate
238 {
239 ELayer.ui.AddLayer<LayerColorPicker>().SetColor(IntColor.FromInt(data.colDeco2), IntColor.FromInt(data.colDeco2), delegate(PickerState state, Color c)
240 {
241 data.colDeco2 = IntColor.ToInt(c);
242 buttonColorDeco2.icon.color = c;
244 });
245 });
246 }
247
248 public void RefreshTemplates()
249 {
250 FileInfo[] list = (from a in new DirectoryInfo(CorePath.LotTemplate).GetFiles()
251 where a.Name.EndsWith(".tpl")
252 select a).ToArray();
253 ddTemplate.SetList(0, list, (FileInfo a, int b) => a.Name, delegate(int a, FileInfo b)
254 {
255 int idBGM = board.data.idBGM;
256 board.data = IO.LoadFile<TraitHouseBoard.Data>(b.FullName);
257 board.data.idBGM = idBGM;
258 ApplyData();
260 });
261 }
262
263 public void ApplyData()
264 {
266 toggleAltRoof.SetActive(board.data.idRoofTile != 0);
267 }
268
269 public override void OnKill()
270 {
271 ELayer.screen.tileMap.usingHouseBoard = false;
272 if ((bool)BuildMenu.Instance)
273 {
274 BuildMenu.Instance.SetActive(enable: true);
275 }
276 }
277}
PickerState
Definition: PickerState.cs:2
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
void WaitForEndOfFrame(Action action)
Definition: BaseCore.cs:61
BaseTileMap tileMap
RoofStyle[] roofStyles
Definition: BaseTileMap.cs:500
static BuildMenu Instance
Definition: BuildMenu.cs:77
static string LotTemplate
Definition: CorePath.cs:192
Definition: ELayer.cs:4
static Core core
Definition: ELayer.cs:7
static SourceManager sources
Definition: ELayer.cs:37
static UI ui
Definition: ELayer.cs:21
static BaseGameScreen screen
Definition: ELayer.cs:29
static int ToInt(ref Color c)
Definition: IntColor.cs:24
static Color32 FromInt(int i)
Definition: IntColor.cs:15
UIButton buttonColorBlock
UIButton toggleAltRoof
UISlider sliderHeightFix
UISlider sliderRamp
UISlider sliderDecoFix
UIButton buttonColorDeco
TraitHouseBoard board
UISlider sliderDeco
UISlider sliderBlock
UIButton toggleReverse
UIDropdown ddRoofStyle
UISlider sliderWallHeight
UIButton toggleAtrium
void SetBoard(TraitHouseBoard b)
UISlider sliderRoof
void RefreshTemplates()
UISlider sliderDeco2
UISlider sliderDecoFix2
override void OnKill()
TraitHouseBoard.Data data
override void OnInit()
UIButton buttonColorRoof
UIButton buttonColorDeco2
void RefreshBlockList()
UIDropdown ddTemplate
List< Window > windows
Definition: Layer.cs:116
string GetName(int i)
Definition: RoofStyle.cs:45
Type type
Definition: RoofStyle.cs:17
static string SaveFilePanel(string title, string directory, string defaultName, string extension)
SourceObj objs
SourceBlock blocks
SourceFloor floors
static TileTypeSlope Slope
Definition: TileType.cs:23
static TileTypeRoof Roof
Definition: TileType.cs:105
static TileTypeStairs Stairs
Definition: TileType.cs:29
static TileTypeBlock Block
Definition: TileType.cs:19
void SetToggle(bool isOn, Action< bool > onToggle=null)
Definition: UIButton.cs:341