Elin Modding Docs Doc
Loading...
Searching...
No Matches
UIScreenshot.cs
1using System;
2using System.Collections.Generic;
3using System.IO;
4using UnityEngine;
5using UnityEngine.UI;
6
7// Token: 0x020005EA RID: 1514
8public class UIScreenshot : EMono
9{
10 // Token: 0x060029B0 RID: 10672 RVA: 0x000EB3AA File Offset: 0x000E95AA
11 public static UIScreenshot Create()
12 {
13 return Util.Instantiate<UIScreenshot>("UI/Util/UIScreenshot", EMono.ui);
14 }
15
16 // Token: 0x060029B1 RID: 10673 RVA: 0x000EB3BB File Offset: 0x000E95BB
17 private void Awake()
18 {
19 UIScreenshot.Instance = this;
20 EMono.ui.Hide(0f);
21 }
22
23 // Token: 0x060029B2 RID: 10674 RVA: 0x000EB3D4 File Offset: 0x000E95D4
24 public void Activate(PartialMap partial, DirectoryInfo dir, Action<PartialMap> onSave = null, bool isUpdate = false)
25 {
26 UIScreenshot.<>c__DisplayClass8_0 CS$<>8__locals1 = new UIScreenshot.<>c__DisplayClass8_0();
27 CS$<>8__locals1.dir = dir;
28 CS$<>8__locals1.<>4__this = this;
29 CS$<>8__locals1.isUpdate = isUpdate;
30 CS$<>8__locals1.partial = partial;
31 CS$<>8__locals1.onSave = onSave;
32 this.inputName.text = (MapPiece.IsEditor ? CS$<>8__locals1.<Activate>g__GetUniqueName|0("") : EMono._zone.Name);
33 if (CS$<>8__locals1.isUpdate)
34 {
35 this.inputName.text = (MapPiece.IsEditor ? CS$<>8__locals1.partial.ID : CS$<>8__locals1.partial.name);
36 }
37 this.buttonSave.SetOnClick(delegate
38 {
39 CS$<>8__locals1.<>4__this.isDeactivating = true;
40 SE.Play("camera");
41 CS$<>8__locals1.<>4__this.GetComponent<CanvasGroup>().alpha = 0f;
42 string text = CS$<>8__locals1.dir.FullName + "/" + (MapPiece.IsEditor ? CS$<>8__locals1.<>4__this.inputName.text.IsEmpty("new") : base.<Activate>g__GetUniqueName|0("user")) + ".mp";
43 if (CS$<>8__locals1.isUpdate)
44 {
45 if (MapPiece.IsEditor)
46 {
47 PartialMap.Delete(CS$<>8__locals1.partial.path);
48 }
49 else
50 {
51 text = CS$<>8__locals1.partial.path;
52 }
53 }
54 CS$<>8__locals1.partial.name = CS$<>8__locals1.<>4__this.inputName.text.IsEmpty(EMono._zone.Name);
55 CS$<>8__locals1.partial.path = text;
56 File.Copy(PartialMap.PathTemp, text, true);
57 string path = text;
58 string name = CS$<>8__locals1.partial.name;
59 Action onSave2;
60 if ((onSave2 = CS$<>8__locals1.<>9__2) == null)
61 {
62 onSave2 = (CS$<>8__locals1.<>9__2 = delegate()
63 {
64 if (PartialMapMenu.Instance)
65 {
66 PartialMapMenu.Instance.Refresh();
67 }
68 CS$<>8__locals1.<>4__this.Deactivate();
69 if (CS$<>8__locals1.onSave != null)
70 {
71 CS$<>8__locals1.onSave(CS$<>8__locals1.partial);
72 }
73 });
74 }
75 UIScreenshot.SavePreview(path, name, onSave2);
76 });
77 }
78
79 // Token: 0x060029B3 RID: 10675 RVA: 0x000EB47D File Offset: 0x000E967D
80 private void Update()
81 {
82 if (this.isDeactivating)
83 {
84 EInput.Consume(false, 1);
85 return;
86 }
87 if (EInput.rightMouse.clicked || Input.GetKeyDown(KeyCode.Escape))
88 {
89 this.Deactivate();
90 }
91 }
92
93 // Token: 0x060029B4 RID: 10676 RVA: 0x000EB4AC File Offset: 0x000E96AC
94 public static void SavePreview(string path, string name, Action onSave)
95 {
96 Action <>9__1;
97 EMono.core.actionsNextFrame.Add(delegate
98 {
99 List<Action> actionsNextFrame = EMono.core.actionsNextFrame;
100 Action item;
101 if ((item = <>9__1) == null)
102 {
103 item = (<>9__1 = delegate()
104 {
105 Texture2D texture2D = ScreenCapture.CaptureScreenshotAsTexture();
106 texture2D.filterMode = FilterMode.Point;
107 int num = 300;
108 int num2 = 200;
109 float num3 = (float)num / (float)Screen.width;
110 float num4 = (float)num2 / (float)Screen.height;
111 Vector2 scale = new Vector2(num3, num4);
112 Vector2 offset = new Vector2((1f - num3) * 0.5f, (1f - num4) * 0.5f);
113 RenderTexture renderTexture = new RenderTexture(num, num2, 0);
114 renderTexture.filterMode = FilterMode.Point;
115 renderTexture.Create();
116 RenderTexture active = RenderTexture.active;
117 RenderTexture.active = renderTexture;
118 Graphics.Blit(texture2D, renderTexture, scale, offset);
119 Texture2D texture2D2 = new Texture2D(num, num2, texture2D.format, false);
120 texture2D2.filterMode = FilterMode.Point;
121 texture2D2.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0);
122 texture2D2.Apply();
123 RenderTexture.active = active;
124 renderTexture.Release();
125 File.WriteAllBytes(path.GetFullFileNameWithoutExtension() + ".jpg", texture2D2.EncodeToJPG());
126 File.WriteAllText(path.GetFullFileNameWithoutExtension() + ".txt", name);
127 UnityEngine.Object.Destroy(texture2D2);
128 UnityEngine.Object.Destroy(texture2D);
129 UnityEngine.Object.Destroy(renderTexture);
130 Action onSave2 = onSave;
131 if (onSave2 == null)
132 {
133 return;
134 }
135 onSave2();
136 });
137 }
138 actionsNextFrame.Add(item);
139 });
140 }
141
142 // Token: 0x060029B5 RID: 10677 RVA: 0x000EB4EF File Offset: 0x000E96EF
143 public void Deactivate()
144 {
145 UnityEngine.Object.Destroy(base.gameObject);
146 EMono.ui.Show(0f);
147 EInput.Consume(false, 1);
148 }
149
150 // Token: 0x0400178B RID: 6027
151 public static UIScreenshot Instance;
152
153 // Token: 0x0400178C RID: 6028
154 public Image imageFrame;
155
156 // Token: 0x0400178D RID: 6029
157 public InputField inputName;
158
159 // Token: 0x0400178E RID: 6030
160 public UIButton buttonSave;
161
162 // Token: 0x0400178F RID: 6031
163 public UIButton buttonCancel;
164
165 // Token: 0x04001790 RID: 6032
166 public bool isDeactivating;
167}
Definition EMono.cs:6