Elin Decompiled Documentation EA 23.359.1 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 s = "";
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 + s;
99 void Append(string text)
100 {
101 if (text != null)
102 {
103 s = s + 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());
140 {
141 gameList.Insert(0, null);
142 }
143 if (gameList.Count > 0)
144 {
145 saveIndex = gameList[0];
146 ddSave.SetList(0, gameList, (GameIndex a, int b) => (a != null) ? a.FormTitle : "feedbackCurrentSave".lang(), delegate(int a, GameIndex b)
147 {
148 saveIndex = b;
149 });
150 }
151 else
152 {
153 toggleSave.SetActive(enable: false);
154 }
155 toggleSave.onValueChanged.AddListener(delegate(bool a)
156 {
157 ddSave.SetActive(a);
158 });
159 toggleSave.isOn = false;
160 ddSave.SetActive(toggleSave.isOn);
161 form.Init();
162 inputDetail.onValueChanged.AddListener(delegate
163 {
164 Validate();
165 });
166 inputSummary.onValueChanged.AddListener(delegate
167 {
168 Validate();
169 });
170 Validate();
171 }
172
173 public void Validate()
174 {
175 bool interactable = true;
176 if (inputSummary.text.Length < 4)
177 {
178 interactable = false;
179 }
180 if (inputDetail.text.Length < 4)
181 {
182 interactable = false;
183 }
184 buttonSubmit.interactable = interactable;
185 }
186
187 public void CollectFiles()
188 {
189 byte[] array = (toggleSave.isOn ? ZipSave() : null);
190 ReportTitle.ignore = false;
191 ReportTitle.strAdd = "";
192 TextField.strAddText = "";
193 string text = Application.persistentDataPath + "/";
194 string text2 = text + "_temp";
195 string text3 = text2 + "/log.zip";
196 IO.CreateDirectory(text2);
197 IO.Copy(text + "Player.log", text2);
198 IO.Copy(text + "Player-prev.log", text2);
199 IO.SaveText(text2 + "/System.txt", GetSystemText());
200 int errors = 0;
201 ParseLog(text2 + "/Player.log");
202 ParseLog(text2 + "/Player-prev.log");
203 ReportTitle.strAdd = ((errors == 0) ? "" : ("(" + errors + ")"));
204 if (ELayer.debug.enable)
205 {
206 ReportTitle.strAdd += "(debug)";
207 }
208 string text4 = inputDetail.text;
209 int num = 0;
210 string[] array2 = new string[23]
211 {
212 "シーラカンス", "ナーフ", "つまらない", "面白くない", "不合理", "やめて", "無駄", "弱体化", "不親切", "クソ",
213 "糞", "バカ", "馬鹿", "coelacanth", "nerf", "boring", "please don't", "waste", "fuck", "suck",
214 "tbh", "shit", "stupid"
215 };
216 foreach (string c in array2)
217 {
218 num += CountString(text4, c);
219 }
220 ReportTitle.strAdd = header + ReportTitle.strAdd;
221 if (num > 0)
222 {
223 ReportTitle.strAdd = ReportTitle.strAdd + "[ignore:" + num + "]";
224 ReportTitle.strAdd = ReportTitle.strAdd + " " + steamName + "/" + userName + "/" + backerId;
225 ReportTitle.ignore = true;
226 }
227 using (ZipFile zipFile = new ZipFile())
228 {
229 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
230 zipFile.AddDirectory(text2);
231 zipFile.Save(text3);
232 }
233 form.CurrentReport.AttachFile("log.zip", File.ReadAllBytes(text3));
234 if (array != null)
235 {
236 form.CurrentReport.AttachFile((saveIndex?.id ?? Game.id) + ".zip", array);
237 }
238 IO.DeleteDirectory(text2);
239 static int CountString(string s, string text5)
240 {
241 string newValue = text5.Substring(0, text5.Length - 1);
242 return s.Length - s.Replace(text5, newValue).Length;
243 }
244 void ParseLog(string path)
245 {
246 if (File.Exists(path))
247 {
248 string[] array3 = IO.LoadTextArray(path);
249 foreach (string text5 in array3)
250 {
251 switch (text5)
252 {
253 case "InvalidOperationException: Collection was modified; enumeration operation may not execute.":
254 case "NullReferenceException: Object reference not set to an instance of an object":
255 errors++;
256 break;
257 default:
258 if (text5.Contains("exception"))
259 {
260 errors++;
261 }
262 else if (text5.Contains("Exception"))
263 {
264 errors++;
265 }
266 break;
267 case "InvalidOperationException: Steamworks is not initialized.":
268 break;
269 }
270 }
271 }
272 }
273 }
274
275 private byte[] ZipSave()
276 {
277 bool flag = ELayer.core.config.cloud || (ELayer.core.IsGameStarted && ELayer.game.isCloud);
278 string text = ((saveIndex == null) ? (Application.persistentDataPath + "/_temp_save") : ((flag ? CorePath.RootSaveCloud : CorePath.RootSave) + saveIndex.id));
279 try
280 {
281 if (saveIndex == null)
282 {
283 IO.DeleteDirectory(text);
284 GameIO.SaveGameCopy(text + "/");
285 }
286 using ZipFile zipFile = new ZipFile();
287 using MemoryStream memoryStream = new MemoryStream();
288 zipFile.AddDirectory(text);
289 zipFile.Save(memoryStream);
290 return memoryStream.ToArray();
291 }
292 catch (Exception exception)
293 {
294 Debug.LogException(exception);
295 return null;
296 }
297 finally
298 {
299 if (saveIndex == null)
300 {
301 IO.DeleteDirectory(text);
302 }
303 }
304 }
305
306 public void OnCancel()
307 {
308 lastDetail = inputDetail.text;
310 form.Clean();
311 Close();
312 }
313
314 public void Submit()
315 {
316 int num = 0;
317 foreach (BaseModPackage package in ELayer.core.mods.packages)
318 {
319 if (!package.builtin && package.activated)
320 {
321 num++;
322 }
323 }
324 if (num > 0)
325 {
326 Dialog.YesNo("warn_mod".lang(num.ToString() ?? ""), delegate
327 {
328 }, delegate
329 {
330 form.Submit();
331 }, "warn_mod_yes", "warn_mod_no");
332 }
333 else
334 {
335 form.Submit();
336 }
337 }
338
339 public void OnSubmit()
340 {
341 if (!inputEmail.text.IsEmpty())
342 {
343 ELayer.config.emailReport = inputEmail.text;
344 }
345 if (!inputName.text.IsEmpty())
346 {
347 ELayer.config.nameReport = inputName.text;
348 }
349 transUpload.SetActive(enable: true);
350 form.IncludeScreenshot = toggleScreenshot.isOn;
351 cgForm.alpha = 0.5f;
352 form.transform.SetParent(ELayer.ui.transform, worldPositionStays: false);
353 Close();
354 lastDetail = (lastSummary = "");
355 }
356
357 public string GetSystemText()
358 {
359 string txt = "";
360 Append("OS: " + SystemInfo.operatingSystem);
361 Append("Processor: " + SystemInfo.processorType);
362 Append("Memory: " + SystemInfo.systemMemorySize);
363 Append("Graphics API: " + SystemInfo.graphicsDeviceType);
364 Append("Graphics Processor: " + SystemInfo.graphicsDeviceName);
365 Append("Graphics Memory: " + SystemInfo.graphicsMemorySize);
366 Append("Graphics Vendor: " + SystemInfo.graphicsDeviceVendor);
367 Append("Quality Level: " + QualitySettings.names[QualitySettings.GetQualityLevel()]);
368 Append("Resolution: " + Screen.width + "x" + Screen.height);
369 Append("Full Screen: " + Screen.fullScreen);
370 return txt;
371 void Append(string s)
372 {
373 txt = txt + s + Environment.NewLine;
374 }
375 }
376}
Version version
Definition: BaseCore.cs:17
string NameSimple
Definition: Card.cs:2193
string Aka
Definition: Chara.cs:222
string nameReport
Definition: CoreConfig.cs:607
string emailReport
Definition: CoreConfig.cs:609
bool cloud
Definition: CoreConfig.cs:619
string lang
Definition: CoreConfig.cs:605
bool enable
Definition: CoreDebug.cs:302
static string RootSave
Definition: CorePath.cs:202
static string RootSaveCloud
Definition: CorePath.cs:204
static string rootExe
Definition: CorePath.cs:168
ModManager mods
Definition: Core.cs:39
bool IsGameStarted
Definition: Core.cs:87
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:252
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:11
static void SaveGameCopy(string path)
Definition: GameIO.cs:102
static List< GameIndex > GetGameList(string path, bool sortByName=false, bool includeEmptyFolder=false)
Definition: GameIO.cs:310
string id
Definition: GameIndex.cs:13
string FormTitle
Definition: GameIndex.cs:56
Definition: Game.cs:9
static string id
Definition: Game.cs:148
bool isCloud
Definition: Game.cs:246
byte[] ZipSave()
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:468
Definition: UIText.cs:6
string GetText()
Definition: Version.cs:34