Elin Modding Docs Doc
Loading...
Searching...
No Matches
LayerTextureViewer.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6// Token: 0x020005C3 RID: 1475
8{
9 // Token: 0x06002865 RID: 10341 RVA: 0x000E4570 File Offset: 0x000E2770
10 public override void OnInit()
11 {
12 this.windows[0].AddBottomSpace(20);
13 this.windows[0].AddBottomButton("openUser", delegate
14 {
15 Util.ShowExplorer(CorePath.user + "Texture Replace/dummy.txt", false);
16 }, false);
17 this.windows[0].AddBottomButton("toggleSnowTexture", delegate
18 {
19 SE.Tab();
20 this.snow = !this.snow;
21 this.OnSwitchContent(this.windows[0]);
22 }, false);
23 }
24
25 // Token: 0x06002866 RID: 10342 RVA: 0x000E45EC File Offset: 0x000E27EC
26 public override void OnSwitchContent(Window window)
27 {
28 this.data = (ELayer.core.textures.texMap.TryGetValue(window.CurrentTab.idLang + (this.snow ? "Snow" : ""), null) ?? ELayer.core.textures.texMap[window.CurrentTab.idLang]);
29 this.RefreshPage();
30 this.scrollbarH.value = 0f;
31 this.scrollvarV.value = 1f;
32 }
33
34 // Token: 0x06002867 RID: 10343 RVA: 0x000E4684 File Offset: 0x000E2884
35 public void RefreshPage()
36 {
37 this.scale = 0.5f;
38 string id = this.data.id;
39 if (id == "objS" || id == "objSS" || id == "objSSnow" || id == "objSSSnow")
40 {
41 this.scale = 1f;
42 }
43 if (this.zoom)
44 {
45 this.scale *= 2f;
46 }
47 if (this.fixZoom)
48 {
49 this.scale /= ELayer.ui.canvasScaler.scaleFactor;
50 }
51 this.imageTex.texture = null;
52 this.imageTex.texture = this.data.tex;
53 this.imageTex.rectTransform.sizeDelta = new Vector2((float)this.data.tex.width * this.scale, (float)this.data.tex.height * this.scale);
54 this.imageTex.RebuildLayoutTo<Layer>();
55 foreach (Image image in this.markers)
56 {
57 UnityEngine.Object.Destroy(image.gameObject);
58 }
59 this.markers.Clear();
60 foreach (TextureReplace textureReplace in this.data.dictReplace.Values)
61 {
62 Image image2 = Util.Instantiate<Image>(this.moldMarker, this.imageTex.transform.parent);
63 image2.rectTransform.sizeDelta = new Vector2(((float)Mathf.Max(textureReplace.w, this.data.tileW) + this.highlightSize * 2f) * this.scale, ((float)Mathf.Max(textureReplace.h, this.data.tileH) + this.highlightSize * 2f) * this.scale);
64 this.SetPos(image2, textureReplace.index % 100, textureReplace.index / 100 * -1, this.highlightSize, this.markerFix);
65 image2.color = ((textureReplace.source == TextureReplace.Source.Local) ? this.colorLocal : ((textureReplace.source == TextureReplace.Source.User) ? this.colorUser : this.colorMod));
66 this.markers.Add(image2);
67 }
68 }
69
70 // Token: 0x06002868 RID: 10344 RVA: 0x000E4934 File Offset: 0x000E2B34
71 public void SetPos(Component r, int x, int y, float size = 0f, Vector2 posFix = default(Vector2))
72 {
73 r.Rect().anchoredPosition = new Vector2((float)(x * this.data.tileW) * this.scale * this.test.x - this.highlightSize * this.scale, (float)(y * this.data.tileH) * this.scale * this.test.y + this.highlightSize * this.scale) + posFix;
74 }
75
76 // Token: 0x06002869 RID: 10345 RVA: 0x000E49B8 File Offset: 0x000E2BB8
77 private void Update()
78 {
79 RectTransform rectTransform = this.imageTex.rectTransform;
80 Vector2 vector;
81 RectTransformUtility.ScreenPointToLocalPointInRectangle(this.imageTex.rectTransform, Input.mousePosition, ELayer.ui.canvas.worldCamera, out vector);
82 int num = (int)vector.x / (int)((float)this.data.tileW * this.scale);
83 int num2 = (int)vector.y / (int)((float)this.data.tileH * this.scale);
84 if (EInput.axis != Vector2.zero)
85 {
86 this.sizeX = Mathf.Clamp(this.sizeX + (int)EInput.axis.x, 1, 5);
87 this.sizeY = Mathf.Clamp(this.sizeY + (int)EInput.axis.y * -1, 1, 5);
88 EInput.requireAxisReset = true;
89 }
90 if (EInput.middleMouse.clicked)
91 {
92 SE.Tab();
93 this.zoom = !this.zoom;
94 this.RefreshPage();
95 }
96 bool flag = InputModuleEX.IsPointerOver(this.transMask);
97 this.highlight.SetActive(flag);
98 if (flag)
99 {
100 this.highlight.rectTransform.sizeDelta = new Vector2(((float)(this.data.tileW * this.sizeX) + this.highlightSize * 2f) * this.scale, ((float)(this.data.tileH * this.sizeY) + this.highlightSize * 2f) * this.scale);
101 this.SetPos(this.highlight, num, num2, this.highlightSize, default(Vector2));
102 string str = this.data.id + "_";
103 int index = Mathf.Abs(num2) * 100 + num;
104 str += index.ToString();
105 this.textHint.text = str + ((this.sizeX == 1 && this.sizeY == 1) ? "" : string.Concat(new string[]
106 {
107 "(",
108 this.sizeX.ToString(),
109 "x",
110 this.sizeY.ToString(),
111 ")"
112 }));
113 if (EInput.leftMouse.clicked)
114 {
115 UIContextMenu uicontextMenu = ELayer.ui.CreateContextMenuInteraction();
116 TextureReplace replace = this.data.dictReplace.TryGetValue(index, null);
117 if (replace != null)
118 {
119 uicontextMenu.AddButton("open_replace", delegate()
120 {
121 Util.Run(replace.file.FullName);
122 }, true);
123 if (replace.source != TextureReplace.Source.Mod)
124 {
125 uicontextMenu.AddButton("delete_replace", delegate()
126 {
127 try
128 {
129 this.data.DeleteReplace(replace);
130 this.data.ForceRefresh();
131 }
132 catch
133 {
134 }
135 SE.Trash();
136 this.RefreshPage();
137 }, true);
138 }
139 }
140 else
141 {
142 uicontextMenu.AddButton("create_replace", delegate()
143 {
144 this.data.CreateReplace(index, CorePath.user + "Texture Replace/", TextureReplace.Source.User, this.sizeX, this.sizeY);
145 SE.Change();
146 this.RefreshPage();
147 }, true);
148 }
149 if (ELayer._zone.isMapSaved && (replace == null || replace.source != TextureReplace.Source.Local))
150 {
151 uicontextMenu.AddButton("create_replaceLocal", delegate()
152 {
153 string text = ELayer._zone.pathSave + "Texture Replace";
154 IO.CreateDirectory(text);
155 this.data.CreateReplace(index, text + "/", TextureReplace.Source.Local, this.sizeX, this.sizeY);
156 SE.Change();
157 this.RefreshPage();
158 }, true);
159 }
160 uicontextMenu.Show();
161 }
162 }
163 }
164
165 // Token: 0x0400168C RID: 5772
166 public RawImage imageTex;
167
168 // Token: 0x0400168D RID: 5773
169 public Image highlight;
170
171 // Token: 0x0400168E RID: 5774
172 public Image moldMarker;
173
174 // Token: 0x0400168F RID: 5775
175 public TextureData data;
176
177 // Token: 0x04001690 RID: 5776
178 public UIScrollView view;
179
180 // Token: 0x04001691 RID: 5777
181 public Scrollbar scrollbarH;
182
183 // Token: 0x04001692 RID: 5778
184 public Scrollbar scrollvarV;
185
186 // Token: 0x04001693 RID: 5779
187 public UIText textHint;
188
189 // Token: 0x04001694 RID: 5780
190 public Transform transMask;
191
192 // Token: 0x04001695 RID: 5781
193 public float scale;
194
195 // Token: 0x04001696 RID: 5782
196 public float highlightSize;
197
198 // Token: 0x04001697 RID: 5783
199 public List<Image> markers = new List<Image>();
200
201 // Token: 0x04001698 RID: 5784
202 public Vector2 markerFix;
203
204 // Token: 0x04001699 RID: 5785
205 public Color colorUser;
206
207 // Token: 0x0400169A RID: 5786
208 public Color colorMod;
209
210 // Token: 0x0400169B RID: 5787
211 public Color colorLocal;
212
213 // Token: 0x0400169C RID: 5788
214 public int sizeX;
215
216 // Token: 0x0400169D RID: 5789
217 public int sizeY;
218
219 // Token: 0x0400169E RID: 5790
220 public bool fixZoom;
221
222 // Token: 0x0400169F RID: 5791
223 public bool snow;
224
225 // Token: 0x040016A0 RID: 5792
226 public Vector2 test;
227
228 // Token: 0x040016A1 RID: 5793
229 private bool zoom;
230}