Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerUploader.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using IniParser.Model;
4using UnityEngine;
5using UnityEngine.UI;
6
7public class LayerUploader : ELayer
8{
9 public static int nextUpload;
10
11 public static char[] InvalidChars = new char[21]
12 {
13 '*', '&', '|', '#', '\\', '/', '?', '!', '"', '>',
14 '<', ':', ';', '.', ',', '~', '@', '^', '$', '%',
15 ' '
16 };
17
18 public InputField inputId;
19
20 public InputField inputPassword;
21
22 public InputField inputWelcome;
23
24 public IniData ini;
25
27
29
31
33
35
37
38 public int limitSec;
39
40 public HashSet<string> invalidIds = new HashSet<string>();
41
42 [NonSerialized]
43 public bool validId;
44
45 [NonSerialized]
46 public bool validPass;
47
48 private string savePath => CorePath.ZoneSaveUser + inputId.text + ".z";
49
50 public override void OnInit()
51 {
53 string text = ini.GetKey("pass") ?? "password";
54 inputId.text = ELayer._map.custom?.id ?? "new_zone";
55 inputPassword.text = text;
56 if (ELayer._map.exportSetting == null)
57 {
58 ELayer._map.exportSetting = new MapExportSetting();
59 }
61 inputWelcome.text = ex.textWelcome.IsEmpty("");
62 inputWelcome.onValueChanged.AddListener(delegate(string s)
63 {
64 ex.textWelcome = s;
65 });
67 {
68 ex.clearLocalCharas = on;
69 });
70 }
71
72 private void Update()
73 {
74 string text = inputId.text;
75 validId = text.Length >= 3 && text.IndexOfAny(InvalidChars) == -1 && !invalidIds.Contains(text);
76 text = inputPassword.text;
77 validPass = text.Length >= 3 && text.IndexOfAny(InvalidChars) == -1;
78 textInvalidId.SetActive(!validId);
79 textInvalidPass.SetActive(!validPass);
80 bool interactableWithAlpha = validId && validPass;
81 buttonSave.SetInteractableWithAlpha(interactableWithAlpha);
82 int num = nextUpload - (int)Time.realtimeSinceStartup;
83 textNextUpload.SetActive(num > 0);
84 if (num > 0)
85 {
86 textNextUpload.text = "net_nextUpload".lang(num.ToString() ?? "");
87 if (!ELayer.debug.enable)
88 {
89 interactableWithAlpha = false;
90 }
91 }
92 buttonUpload.SetInteractableWithAlpha(interactableWithAlpha);
93 }
94
95 public override void OnKill()
96 {
97 if (validId && validPass)
98 {
99 SaveID();
100 }
101 }
102
103 public void SaveID()
104 {
105 if (ELayer._map.custom != null)
106 {
107 ELayer._map.custom.id = inputId.text;
108 }
109 ini.Global["pass"] = inputPassword.text;
111 }
112
113 public void ExportMap()
114 {
115 ELayer._zone.Export(savePath, null, usermap: true);
116 Msg.Say("net_mapSaved".lang(savePath));
117 SE.WriteJournal();
118 }
119
120 public void Upload()
121 {
122 if (ini.Global["agreed_usercontents_upload_terms"] != "yes")
123 {
124 string[] items = new string[3] { "readTerms", "agree", "disagree" };
125 Dialog.List("dialogTermsOfUse".lang(), items, (string j) => j, delegate(int c, string d)
126 {
127 switch (c)
128 {
129 case 0:
130 LayerHelp.Toggle("custom", "terms");
131 return false;
132 case 1:
133 ini.Global["agreed_usercontents_upload_terms"] = "yes";
134 Upload();
135 break;
136 }
137 return true;
138 }, canCancel: true);
139 }
140 else
141 {
142 Debug.Log("Uploading map");
143 string text = inputId.text;
144 string text2 = inputPassword.text;
145 SaveID();
146 ExportMap();
148 nextUpload = (int)Time.realtimeSinceStartup + limitSec;
149 }
150 }
151}
string NameBraced
Definition: Chara.cs:499
bool enable
Definition: CoreDebug.cs:285
Definition: Core.cs:14
static void SaveElinIni(IniData ini)
Definition: Core.cs:793
static IniData GetElinIni()
Definition: Core.cs:759
string id
Definition: CustomData.cs:6
Definition: Dialog.cs:7
Definition: ELayer.cs:4
static Chara pc
Definition: ELayer.cs:15
static CoreDebug debug
Definition: ELayer.cs:43
static Map _map
Definition: ELayer.cs:23
static Zone _zone
Definition: ELayer.cs:25
Definition: Lang.cs:6
static string langCode
Definition: Lang.cs:28
static void Toggle(string idFile, string idTopic=null)
Definition: LayerHelp.cs:32
HashSet< string > invalidIds
override void OnInit()
override void OnKill()
UIButton toggleClearLocalCharas
UIText textInvalidId
UIButton buttonSave
static char[] InvalidChars
UIText textNextUpload
static int nextUpload
Definition: LayerUploader.cs:9
UIButton buttonUpload
InputField inputPassword
UIText textInvalidPass
InputField inputId
InputField inputWelcome
CustomData custom
Definition: Map.cs:40
MapExportSetting exportSetting
Definition: Map.cs:73
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
Definition: Net.cs:11
static async UniTask< bool > UploadFile(string id, string password, string name, string title, string path, string idLang)
Definition: Net.cs:97
virtual string Name
Definition: Spatial.cs:495
void SetToggle(bool isOn, Action< bool > onToggle=null)
Definition: UIButton.cs:341
void SetInteractableWithAlpha(bool enable)
Definition: UIButton.cs:732
Definition: UIText.cs:6
string lang
Definition: UIText.cs:9
void Export(string path, PartialMap partial=null, bool usermap=false)
Definition: Zone.cs:2898