Elin Decompiled Documentation EA 23.186 Nyaightly
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
39
40 public int limitSec;
41
42 public HashSet<string> invalidIds = new HashSet<string>();
43
44 [NonSerialized]
45 public bool validId;
46
47 [NonSerialized]
48 public bool validPass;
49
50 private string savePath => CorePath.ZoneSaveUser + inputId.text + ".z";
51
52 public override void OnInit()
53 {
55 string text = ini.GetKey("pass") ?? "password";
56 inputId.text = ELayer._map.custom?.id ?? "new_zone";
57 inputPassword.text = text;
58 if (ELayer._map.exportSetting == null)
59 {
60 ELayer._map.exportSetting = new MapExportSetting();
61 }
63 inputWelcome.text = ex.textWelcome.IsEmpty("");
64 inputWelcome.onValueChanged.AddListener(delegate(string s)
65 {
66 ex.textWelcome = s;
67 });
69 {
70 ex.clearLocalCharas = on;
71 });
72 toggleAdult.SetToggle(ELayer._map.exportSetting.tag.HasTag("adult"), delegate(bool on)
73 {
74 ELayer._map.exportSetting.tag = ELayer._map.exportSetting.tag.SetTag("adult", on);
75 Debug.Log(ELayer._map.exportSetting.tag + " / " + ELayer._map.exportSetting.tag.HasTag("adult"));
76 });
77 }
78
79 private void Update()
80 {
81 string text = inputId.text;
82 validId = text.Length >= 3 && text.IndexOfAny(InvalidChars) == -1 && !invalidIds.Contains(text);
83 text = inputPassword.text;
84 validPass = text.Length >= 3 && text.IndexOfAny(InvalidChars) == -1;
85 textInvalidId.SetActive(!validId);
86 textInvalidPass.SetActive(!validPass);
87 bool interactableWithAlpha = validId && validPass;
88 buttonSave.SetInteractableWithAlpha(interactableWithAlpha);
89 int num = nextUpload - (int)Time.realtimeSinceStartup;
90 textNextUpload.SetActive(num > 0);
91 if (num > 0)
92 {
93 textNextUpload.text = "net_nextUpload".lang(num.ToString() ?? "");
94 if (!ELayer.debug.enable)
95 {
96 interactableWithAlpha = false;
97 }
98 }
99 buttonUpload.SetInteractableWithAlpha(interactableWithAlpha);
100 }
101
102 public override void OnKill()
103 {
104 if (validId && validPass)
105 {
106 SaveID();
107 }
108 }
109
110 public void SaveID()
111 {
112 if (ELayer._map.custom != null)
113 {
114 ELayer._map.custom.id = inputId.text;
115 }
116 ini.Global["pass"] = inputPassword.text;
118 }
119
120 public void ExportMap()
121 {
122 ELayer._zone.Export(savePath, null, usermap: true);
123 Msg.Say("net_mapSaved".lang(savePath));
124 SE.WriteJournal();
125 }
126
127 public void Upload()
128 {
129 if (ini.Global["agreed_usercontents_upload_terms"] != "yes")
130 {
131 string[] items = new string[3] { "readTerms", "agree", "disagree" };
132 Dialog.List("dialogTermsOfUse".lang(), items, (string j) => j, delegate(int c, string d)
133 {
134 switch (c)
135 {
136 case 0:
137 LayerHelp.Toggle("custom", "terms");
138 return false;
139 case 1:
140 ini.Global["agreed_usercontents_upload_terms"] = "yes";
141 Upload();
142 break;
143 }
144 return true;
145 }, canCancel: true);
146 }
147 else
148 {
149 Debug.Log("Uploading map");
150 string text = inputId.text;
151 string text2 = inputPassword.text;
152 SaveID();
153 ExportMap();
155 nextUpload = (int)Time.realtimeSinceStartup + limitSec;
156 }
157 }
158}
string NameBraced
Definition: Chara.cs:512
bool enable
Definition: CoreDebug.cs:286
Definition: Core.cs:14
static void SaveElinIni(IniData ini)
Definition: Core.cs:800
static IniData GetElinIni()
Definition: Core.cs:766
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()
UIButton toggleAdult
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, string cat="Home", string tag="")
Definition: Net.cs:105
virtual string Name
Definition: Spatial.cs:497
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:3053