Elin Modding Docs Doc
All Classes Namespaces
LayerUploader.cs
1using System;
2using System.Collections.Generic;
3using IniParser;
4using IniParser.Model;
5using UnityEngine;
6using UnityEngine.UI;
7
8// Token: 0x020005C7 RID: 1479
9public class LayerUploader : ELayer
10{
11 // Token: 0x17000BCB RID: 3019
12 // (get) Token: 0x0600288D RID: 10381 RVA: 0x000E5765 File Offset: 0x000E3965
13 private string savePath
14 {
15 get
16 {
17 return CorePath.ZoneSaveUser + this.inputId.text + ".z";
18 }
19 }
20
21 // Token: 0x0600288E RID: 10382 RVA: 0x000E5784 File Offset: 0x000E3984
22 public override void OnInit()
23 {
24 this.ini = ELayer.core.mods.GetElinIni();
25 string text = this.ini.GetKey("pass") ?? "password";
26 InputField inputField = this.inputId;
27 CustomData custom = ELayer._map.custom;
28 inputField.text = (((custom != null) ? custom.id : null) ?? "new_zone");
29 this.inputPassword.text = text;
30 }
31
32 // Token: 0x0600288F RID: 10383 RVA: 0x000E57F8 File Offset: 0x000E39F8
33 private void Update()
34 {
35 string text = this.inputId.text;
36 this.validId = (text.Length >= 3 && text.IndexOfAny(LayerUploader.InvalidChars) == -1 && !this.invalidIds.Contains(text));
37 text = this.inputPassword.text;
38 this.validPass = (text.Length >= 3 && text.IndexOfAny(LayerUploader.InvalidChars) == -1);
39 this.textInvalidId.SetActive(!this.validId);
40 this.textInvalidPass.SetActive(!this.validPass);
41 bool interactableWithAlpha = this.validId && this.validPass;
42 this.buttonSave.SetInteractableWithAlpha(interactableWithAlpha);
43 int num = LayerUploader.nextUpload - (int)Time.realtimeSinceStartup;
44 this.textNextUpload.SetActive(num > 0);
45 if (num > 0)
46 {
47 this.textNextUpload.text = "net_nextUpload".lang(num.ToString() ?? "", null, null, null, null);
48 if (!ELayer.debug.enable)
49 {
50 interactableWithAlpha = false;
51 }
52 }
53 this.buttonUpload.SetInteractableWithAlpha(interactableWithAlpha);
54 }
55
56 // Token: 0x06002890 RID: 10384 RVA: 0x000E5915 File Offset: 0x000E3B15
57 public override void OnKill()
58 {
59 if (this.validId && this.validPass)
60 {
61 this.SaveID();
62 }
63 }
64
65 // Token: 0x06002891 RID: 10385 RVA: 0x000E5930 File Offset: 0x000E3B30
66 public void SaveID()
67 {
68 if (ELayer._map.custom != null)
69 {
70 ELayer._map.custom.id = this.inputId.text;
71 }
72 this.ini.Global["pass"] = this.inputPassword.text;
73 new FileIniDataParser().WriteFile(ModManager.PathIni, this.ini, null);
74 }
75
76 // Token: 0x06002892 RID: 10386 RVA: 0x000E5999 File Offset: 0x000E3B99
77 public void ExportMap()
78 {
79 ELayer._zone.Export(this.savePath, null, true);
80 Msg.Say("net_mapSaved".lang(this.savePath, null, null, null, null));
81 SE.WriteJournal();
82 }
83
84 // Token: 0x06002893 RID: 10387 RVA: 0x000E59CC File Offset: 0x000E3BCC
85 public void Upload()
86 {
87 Debug.Log("aaaa");
88 if (this.ini.Global["agreed"].IsEmpty())
89 {
90 string[] items = new string[]
91 {
92 "readTerms",
93 "agree",
94 "disagree"
95 };
96 Dialog.List<string>("dialogTermsOfUse".lang(), items, (string j) => j, delegate(int c, string d)
97 {
98 if (c == 0)
99 {
100 LayerHelp.Toggle("custom", "terms");
101 return false;
102 }
103 if (c == 1)
104 {
105 this.ini.Global["agreed"] = "yes";
106 this.Upload();
107 }
108 return true;
109 }, true);
110 return;
111 }
112 Debug.Log("Uploading map");
113 string text = this.inputId.text;
114 string text2 = this.inputPassword.text;
115 this.SaveID();
116 this.ExportMap();
117 Net.UploadFile(text, text2, ELayer.pc.NameBraced, ELayer._zone.Name, this.savePath, Lang.langCode);
118 LayerUploader.nextUpload = (int)Time.realtimeSinceStartup + this.limitSec;
119 }
120
121 // Token: 0x040016C3 RID: 5827
122 public static int nextUpload;
123
124 // Token: 0x040016C4 RID: 5828
125 public static char[] InvalidChars = new char[]
126 {
127 '*',
128 '&',
129 '|',
130 '#',
131 '\\',
132 '/',
133 '?',
134 '!',
135 '"',
136 '>',
137 '<',
138 ':',
139 ';',
140 '.',
141 ',',
142 '~',
143 '@',
144 '^',
145 '$',
146 '%',
147 ' '
148 };
149
150 // Token: 0x040016C5 RID: 5829
151 public InputField inputId;
152
153 // Token: 0x040016C6 RID: 5830
154 public InputField inputPassword;
155
156 // Token: 0x040016C7 RID: 5831
157 public IniData ini;
158
159 // Token: 0x040016C8 RID: 5832
160 public UIText textInvalidId;
161
162 // Token: 0x040016C9 RID: 5833
163 public UIText textInvalidPass;
164
165 // Token: 0x040016CA RID: 5834
166 public UIText textNextUpload;
167
168 // Token: 0x040016CB RID: 5835
169 public UIButton buttonUpload;
170
171 // Token: 0x040016CC RID: 5836
172 public UIButton buttonSave;
173
174 // Token: 0x040016CD RID: 5837
175 public int limitSec;
176
177 // Token: 0x040016CE RID: 5838
178 public HashSet<string> invalidIds = new HashSet<string>();
179
180 // Token: 0x040016CF RID: 5839
181 [NonSerialized]
182 public bool validId;
183
184 // Token: 0x040016D0 RID: 5840
185 [NonSerialized]
186 public bool validPass;
187}
Definition Msg.cs:7
Definition Net.cs:12