Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerFeedback.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Globalization;
4using System.IO;
5using System.Threading;
6using AeLa.EasyFeedback;
7using AeLa.EasyFeedback.FormElements;
8using AeLa.EasyFeedback.FormFields;
9using Ionic.Zip;
10using UnityEngine;
11using UnityEngine.UI;
12
13public class LayerFeedback : ELayer
14{
15 public static string lastSummary = "";
16
17 public static string lastDetail = "";
18
19 public static string steamName = "";
20
21 public static string userName = "";
22
23 public static string backerId = "";
24
25 public static string header = "";
26
27 public static int playedHours;
28
30
31 public InputField inputVersion;
32
33 public InputField inputName;
34
35 public InputField inputEmail;
36
37 public InputField inputLang;
38
39 public InputField inputSummary;
40
41 public InputField inputDetail;
42
43 public FeedbackForm form;
44
45 public DebugLogCollector collector;
46
47 public Transform transUpload;
48
50
51 public Toggle toggleSave;
52
53 public Toggle toggleScreenshot;
54
56
57 public CanvasGroup cgForm;
58
59 public CategoryDropdown category;
60
62
64
66
67 public override void OnInit()
68 {
69 inputVersion.text = ELayer.core.version.GetText() + "/" + ELayer.config.lang + " " + steamName + "/" + userName + " hours:" + playedHours + " backer:" + backerId;
70 TextField.onAddEmail = delegate
71 {
72 string s2 = "";
73 foreach (BaseModPackage package in ELayer.core.mods.packages)
74 {
75 if (!package.builtin)
76 {
77 Append(package.id + "/" + package.activated);
78 }
79 }
80 Append("");
81 Append("Save Path: " + CorePath.RootSave);
82 Append("EXE Path: " + CorePath.rootExe);
83 Append("OS: " + SystemInfo.operatingSystem);
84 Append("Processor: " + SystemInfo.processorType);
85 Append("Memory: " + SystemInfo.systemMemorySize);
86 Append("Graphics API: " + SystemInfo.graphicsDeviceType);
87 Append("Graphics Processor: " + SystemInfo.graphicsDeviceName);
88 Append("Graphics Memory: " + SystemInfo.graphicsMemorySize);
89 Append("Graphics Vendor: " + SystemInfo.graphicsDeviceVendor);
90 Append("Quality Level: " + QualitySettings.names[QualitySettings.GetQualityLevel()]);
91 Append("Resolution: " + Screen.width + "x" + Screen.height);
92 Append("Full Screen: " + Screen.fullScreen);
93 Append("regionName: " + RegionInfo.CurrentRegion.Name);
94 Append("cultureName: " + CultureInfo.CurrentCulture.Name);
95 Append("cname: " + Thread.CurrentThread.CurrentCulture.Name);
96 Append("uiname: " + Thread.CurrentThread.CurrentUICulture.Name);
97 Append("device identifier: " + SystemInfo.deviceUniqueIdentifier);
98 return Environment.NewLine + Environment.NewLine + s2;
99 void Append(string text)
100 {
101 if (text != null)
102 {
103 s2 = s2 + text + Environment.NewLine;
104 }
105 }
106 };
107 buttonLinkFAQ.SetOnClick(delegate
108 {
109 LayerHelp.Toggle("general", "FAQ");
110 });
111 buttonLinkDiscord.SetOnClick(delegate
112 {
113 SE.Click();
114 Application.OpenURL("https://discord.gg/elona");
115 });
116 transUpload.SetActive(enable: false);
117 buttonSubmit.interactable = false;
118 if (!ELayer.config.nameReport.IsEmpty())
119 {
120 inputName.text = ELayer.config.nameReport;
121 }
122 else if (ELayer.core.IsGameStarted)
123 {
124 inputName.text = "nameBraced".lang(ELayer.pc.NameSimple, ELayer.pc.Aka);
125 }
126 if (!ELayer.config.emailReport.IsEmpty())
127 {
128 inputEmail.text = ELayer.config.emailReport;
129 }
130 inputLang.text = ELayer.config.lang;
131 inputDetail.text = lastDetail;
132 inputSummary.text = lastSummary;
133 collector.onSubmit = delegate
134 {
135 CollectFiles();
136 };
137 category.Init((string s) => ("form_" + s).lang());
139 if (gameList.Count > 0)
140 {
141 int index = 0;
142 saveIndex = gameList[0];
143 for (int i = 0; i < gameList.Count; i++)
144 {
145 if (ELayer.core.IsGameStarted && gameList[i].id == Game.id)
146 {
147 index = i;
148 saveIndex = gameList[i];
149 }
150 }
151 ddSave.SetList(index, gameList, (GameIndex a, int b) => ((ELayer.core.IsGameStarted && a.id == Game.id) ? "currentSave".lang() : "") + a.FormTitle, delegate(int a, GameIndex b)
152 {
153 saveIndex = b;
154 });
155 }
156 else
157 {
158 toggleSave.SetActive(enable: false);
159 }
160 toggleSave.onValueChanged.AddListener(delegate(bool a)
161 {
162 ddSave.SetActive(a);
163 });
164 toggleSave.isOn = false;
165 ddSave.SetActive(toggleSave.isOn);
166 form.Init();
167 inputDetail.onValueChanged.AddListener(delegate
168 {
169 Validate();
170 });
171 inputSummary.onValueChanged.AddListener(delegate
172 {
173 Validate();
174 });
175 Validate();
176 }
177
178 public void Validate()
179 {
180 bool interactable = true;
181 if (inputSummary.text.Length < 4)
182 {
183 interactable = false;
184 }
185 if (inputDetail.text.Length < 4)
186 {
187 interactable = false;
188 }
189 buttonSubmit.interactable = interactable;
190 }
191
192 public void CollectFiles()
193 {
194 ReportTitle.ignore = false;
195 ReportTitle.strAdd = "";
196 TextField.strAddText = "";
197 string text = Application.persistentDataPath + "/";
198 string text2 = text + "_temp";
199 string text3 = text2 + "/log.zip";
200 IO.CreateDirectory(text2);
201 IO.Copy(text + "Player.log", text2);
202 IO.Copy(text + "Player-prev.log", text2);
203 IO.SaveText(text2 + "/System.txt", GetSystemText());
204 int errors = 0;
205 ParseLog(text2 + "/Player.log");
206 ParseLog(text2 + "/Player-prev.log");
207 ReportTitle.strAdd = ((errors == 0) ? "" : ("(" + errors + ")"));
208 if (ELayer.debug.enable)
209 {
210 ReportTitle.strAdd += "(debug)";
211 }
212 string text4 = inputDetail.text;
213 int num = 0;
214 string[] array = new string[23]
215 {
216 "シーラカンス", "ナーフ", "つまらない", "面白くない", "不合理", "やめて", "無駄", "弱体化", "不親切", "クソ",
217 "糞", "バカ", "馬鹿", "coelacanth", "nerf", "boring", "please don't", "waste", "fuck", "suck",
218 "tbh", "shit", "stupid"
219 };
220 foreach (string c2 in array)
221 {
222 num += CountString(text4, c2);
223 }
224 ReportTitle.strAdd = header + ReportTitle.strAdd;
225 if (num > 0)
226 {
227 ReportTitle.strAdd = ReportTitle.strAdd + "[ignore:" + num + "]";
228 ReportTitle.strAdd = ReportTitle.strAdd + " " + steamName + "/" + userName + "/" + backerId;
229 ReportTitle.ignore = true;
230 }
231 using (ZipFile zipFile = new ZipFile())
232 {
233 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
234 zipFile.AddDirectory(text2);
235 zipFile.Save(text3);
236 }
237 form.CurrentReport.AttachFile("log.zip", File.ReadAllBytes(text3));
238 if (toggleSave.isOn)
239 {
240 bool flag = ELayer.core.config.cloud || (ELayer.core.IsGameStarted && ELayer.game.isCloud);
241 string text5 = text2 + "/save.zip";
242 using (ZipFile zipFile2 = new ZipFile())
243 {
244 zipFile2.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
245 zipFile2.AddDirectory((flag ? CorePath.RootSaveCloud : CorePath.RootSave) + saveIndex.id);
246 zipFile2.Save(text5);
247 }
248 form.CurrentReport.AttachFile(saveIndex.id + ".zip", File.ReadAllBytes(text5));
249 }
250 IO.DeleteDirectory(text2);
251 static int CountString(string s, string c)
252 {
253 string newValue = c.Substring(0, c.Length - 1);
254 return s.Length - s.Replace(c, newValue).Length;
255 }
256 void ParseLog(string path)
257 {
258 if (File.Exists(path))
259 {
260 string[] array2 = IO.LoadTextArray(path);
261 foreach (string text6 in array2)
262 {
263 switch (text6)
264 {
265 case "InvalidOperationException: Collection was modified; enumeration operation may not execute.":
266 case "NullReferenceException: Object reference not set to an instance of an object":
267 errors++;
268 break;
269 default:
270 if (text6.Contains("exception"))
271 {
272 errors++;
273 }
274 else if (text6.Contains("Exception"))
275 {
276 errors++;
277 }
278 break;
279 case "InvalidOperationException: Steamworks is not initialized.":
280 break;
281 }
282 }
283 }
284 }
285 }
286
287 public void OnCancel()
288 {
289 lastDetail = inputDetail.text;
291 form.Clean();
292 Close();
293 }
294
295 public void Submit()
296 {
297 int num = 0;
298 foreach (BaseModPackage package in ELayer.core.mods.packages)
299 {
300 if (!package.builtin && package.activated)
301 {
302 num++;
303 }
304 }
305 if (num > 0)
306 {
307 Dialog.YesNo("warn_mod".lang(num.ToString() ?? ""), delegate
308 {
309 }, delegate
310 {
311 form.Submit();
312 }, "warn_mod_yes", "warn_mod_no");
313 }
314 else
315 {
316 form.Submit();
317 }
318 }
319
320 public void OnSubmit()
321 {
322 if (!inputEmail.text.IsEmpty())
323 {
324 ELayer.config.emailReport = inputEmail.text;
325 }
326 if (!inputName.text.IsEmpty())
327 {
328 ELayer.config.nameReport = inputName.text;
329 }
330 transUpload.SetActive(enable: true);
331 form.IncludeScreenshot = toggleScreenshot.isOn;
332 cgForm.alpha = 0.5f;
333 form.transform.SetParent(ELayer.ui.transform, worldPositionStays: false);
334 Close();
335 lastDetail = (lastSummary = "");
336 }
337
338 public string GetSystemText()
339 {
340 string txt = "";
341 Append("OS: " + SystemInfo.operatingSystem);
342 Append("Processor: " + SystemInfo.processorType);
343 Append("Memory: " + SystemInfo.systemMemorySize);
344 Append("Graphics API: " + SystemInfo.graphicsDeviceType);
345 Append("Graphics Processor: " + SystemInfo.graphicsDeviceName);
346 Append("Graphics Memory: " + SystemInfo.graphicsMemorySize);
347 Append("Graphics Vendor: " + SystemInfo.graphicsDeviceVendor);
348 Append("Quality Level: " + QualitySettings.names[QualitySettings.GetQualityLevel()]);
349 Append("Resolution: " + Screen.width + "x" + Screen.height);
350 Append("Full Screen: " + Screen.fullScreen);
351 return txt;
352 void Append(string s)
353 {
354 txt = txt + s + Environment.NewLine;
355 }
356 }
357}
Version version
Definition: BaseCore.cs:17
List< BaseModPackage > packages
string NameSimple
Definition: Card.cs:2015
string Aka
Definition: Chara.cs:201
string nameReport
Definition: CoreConfig.cs:572
string emailReport
Definition: CoreConfig.cs:574
bool cloud
Definition: CoreConfig.cs:586
string lang
Definition: CoreConfig.cs:570
bool enable
Definition: CoreDebug.cs:285
static string RootSave
Definition: CorePath.cs:206
static string RootSaveCloud
Definition: CorePath.cs:208
static string rootExe
Definition: CorePath.cs:172
ModManager mods
Definition: Core.cs:39
bool IsGameStarted
Definition: Core.cs:84
CoreConfig config
Definition: Core.cs:70
Definition: Dialog.cs:7
static Dialog YesNo(string langDetail, Action actionYes, Action actionNo=null, string langYes="yes", string langNo="no")
Definition: Dialog.cs:244
Definition: ELayer.cs:4
static Chara pc
Definition: ELayer.cs:15
static Core core
Definition: ELayer.cs:7
static Game game
Definition: ELayer.cs:9
static CoreDebug debug
Definition: ELayer.cs:43
static CoreConfig config
Definition: ELayer.cs:31
static UI ui
Definition: ELayer.cs:21
Definition: GameIO.cs:10
static List< GameIndex > GetGameList(string path, bool sortByName=false, bool includeEmptyFolder=false)
Definition: GameIO.cs:286
string id
Definition: GameIndex.cs:13
string FormTitle
Definition: GameIndex.cs:56
Definition: Game.cs:8
static string id
Definition: Game.cs:147
bool isCloud
Definition: Game.cs:239
CanvasGroup cgForm
UIDropdown ddSave
Toggle toggleScreenshot
InputField inputName
InputField inputSummary
static string lastSummary
Button buttonSubmit
void CollectFiles()
InputField inputEmail
InputField inputLang
GameIndex saveIndex
Transform transUpload
override void OnInit()
CategoryDropdown category
static string steamName
InputField inputDetail
static string backerId
string GetSystemText()
UIButton buttonLinkDiscord
UIButton buttonLinkFAQ
static int playedHours
DebugLogCollector collector
FeedbackForm form
static string userName
static string header
UIText textProgress
InputField inputVersion
Toggle toggleSave
static string lastDetail
static void Toggle(string idFile, string idTopic=null)
Definition: LayerHelp.cs:32
virtual void Close()
Definition: Layer.cs:463
Definition: UIText.cs:6
string GetText()
Definition: Version.cs:16