10 public override void OnInit()
12 this.windows[0].AddBottomSpace(20);
13 this.windows[0].AddBottomButton(
"openUser", delegate
15 Util.ShowExplorer(CorePath.user +
"Texture Replace/dummy.txt",
false);
17 this.windows[0].AddBottomButton(
"toggleSnowTexture", delegate
20 this.snow = !this.snow;
21 this.OnSwitchContent(this.windows[0]);
26 public override void OnSwitchContent(Window window)
28 this.data = (
ELayer.core.textures.texMap.TryGetValue(window.CurrentTab.idLang + (
this.snow ?
"Snow" :
""),
null) ??
ELayer.core.textures.texMap[window.CurrentTab.idLang]);
30 this.scrollbarH.value = 0f;
31 this.scrollvarV.value = 1f;
35 public void RefreshPage()
38 string id = this.data.id;
39 if (
id ==
"objS" ||
id ==
"objSS" ||
id ==
"objSSnow" ||
id ==
"objSSSnow")
49 this.scale /=
ELayer.ui.canvasScaler.scaleFactor;
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)
57 UnityEngine.Object.Destroy(image.gameObject);
60 foreach (
TextureReplace textureReplace
in this.data.dictReplace.Values)
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);
71 public void SetPos(Component r,
int x,
int y,
float size = 0f, Vector2 posFix =
default(Vector2))
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;
79 RectTransform rectTransform = this.imageTex.rectTransform;
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)
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;
90 if (EInput.middleMouse.clicked)
93 this.zoom = !this.zoom;
96 bool flag = InputModuleEX.IsPointerOver(this.transMask);
97 this.highlight.SetActive(flag);
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[]
108 this.sizeX.ToString(),
110 this.sizeY.ToString(),
113 if (EInput.leftMouse.clicked)
115 UIContextMenu uicontextMenu =
ELayer.ui.CreateContextMenuInteraction();
116 TextureReplace replace = this.data.dictReplace.TryGetValue(index,
null);
119 uicontextMenu.AddButton(
"open_replace", delegate()
121 Util.Run(replace.file.FullName);
125 uicontextMenu.AddButton(
"delete_replace", delegate()
129 this.data.DeleteReplace(replace);
130 this.data.ForceRefresh();
142 uicontextMenu.AddButton(
"create_replace", delegate()
144 this.data.CreateReplace(index, CorePath.user +
"Texture Replace/",
TextureReplace.Source.User,
this.sizeX,
this.sizeY);
149 if (
ELayer._zone.isMapSaved && (replace ==
null || replace.source !=
TextureReplace.Source.Local))
151 uicontextMenu.AddButton(
"create_replaceLocal", delegate()
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);
160 uicontextMenu.Show();
166 public RawImage imageTex;
169 public Image highlight;
172 public Image moldMarker;
178 public UIScrollView view;
181 public Scrollbar scrollbarH;
184 public Scrollbar scrollvarV;
187 public UIText textHint;
190 public Transform transMask;
196 public float highlightSize;
199 public List<Image> markers =
new List<Image>();
202 public Vector2 markerFix;
205 public Color colorUser;
208 public Color colorMod;
211 public Color colorLocal;