-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
325 lines (299 loc) · 12.6 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using CSGOMultiAccsCFG;
using Newtonsoft.Json;
namespace CSGOACCOUNTCFG
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
LoadingXml();
}
private string path;
private string pathtwo;
bool pathCorrect;
// В целом все работает, осталось настроить параметры запуска для всех акков это чтение json localconfig и изменение launchOptions !!!
private string getPath()
{
return path;
}
private string getPathtwo()
{
return pathtwo;
}
private void setPath(string path, string pathtwo)
{
this.path = path;
this.pathtwo = pathtwo;
}
private void CheckPath()
{
if (File.Exists(getPath() + @"\steam.exe") && System.IO.File.Exists(getPath() + @"\Steam.dll"))
{
pathCorrect = true;
}
//else
//{
// MessageBox.Show("Steam Path Incorrect");
// pathCorrect = false;
//}
}
private void CheckPathSource()
{
if (File.Exists(getPath() + @"\steam.exe") && System.IO.File.Exists(getPath() + @"\Steam.dll"))
{
pathCorrect = true;
}
//else
//{
// MessageBox.Show("Steam Path Incorrect");
// pathCorrect = false;
//}
}
private void LoadingXml()
{
string FileName = "setting.xml";
if (File.Exists(FileName))
{
XmlDocument doc = new XmlDocument();
doc.Load(FileName);
XmlNode child = doc.SelectSingleNode("/setting/path");
XmlNode childtwo = doc.SelectSingleNode("/setting/path2");
if (child != null && childtwo != null)
{
XmlNodeReader nr = new XmlNodeReader(child);
XmlNodeReader nrtwo = new XmlNodeReader(childtwo);
while (nr.Read() && nrtwo.Read())
if (nr.Value != "" && nrtwo.Value != "")
{
setPath(nr.Value, nrtwo.Value);
CheckPath();
txtPath.Text = nr.Value;
SourcePath.Text = nrtwo.Value;
}
}
}
else
{
//Default Path
CreatePathData("setting.xml", "C:\\Program Files (x86)\\Steam\\userdata", "C:\\Program Files (x86)\\Steam\\userdata\\cfg cs");
LoadingXml();
}
}
private void CreatePathData(string Filename, string path, string pathtwo)
{
XmlDocument doc = new XmlDocument();
XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
doc.AppendChild(docNode);
XmlElement node = doc.CreateElement("setting");
XmlElement userDataPath = doc.CreateElement("path");
XmlElement sourceDataPath = doc.CreateElement("path2");
if (path != null)
{
userDataPath.InnerText = path;
sourceDataPath.InnerText = pathtwo;
}
else
{
userDataPath.InnerText = getPath();
sourceDataPath.InnerText = getPathtwo();
}
node.AppendChild(userDataPath);
node.AppendChild(sourceDataPath);
doc.AppendChild(node);
StreamWriter outStream = File.CreateText(Filename);
doc.Save(outStream);
outStream.Close();
}
public static string Steam64ToSteam32(long communityId)
{
if (communityId < 76561197960265729L || !Regex.IsMatch(communityId.ToString((IFormatProvider)CultureInfo.InvariantCulture), "^7656119([0-9]{10})$"))
{
return string.Empty;
}
return string.Format("U:1:{0}", communityId - 76561197960265728L);
}
public static void Copy(string sourceDirectory, string targetDirectory)
{
DirectoryInfo diSource = new DirectoryInfo(sourceDirectory);
DirectoryInfo diTarget = new DirectoryInfo(targetDirectory);
CopyAll(diSource, diTarget);
}
public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
{
if (Directory.Exists(target.FullName) == false)
{
Directory.CreateDirectory(target.FullName);
}
foreach (FileInfo fi in source.GetFiles())
{
Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), true);
}
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
{
DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
CopyAll(diSourceSubDir, nextTargetSubDir);
}
}
private void ImportMafileBtn_Click(object sender, EventArgs e)
{
if (Browsec.ShowDialog() != DialogResult.OK) return;
string path = Browsec.SelectedPath;
if (!Directory.Exists(path)) return;
string[] files = Directory.GetFiles(path, "*.mafile");
int counter = 0;
for (int i = 0, a = files.Count(); i < a; i++)
{
try
{
string json = File.ReadAllText(files[i]);
MafileDeserialize.Root accountinfo = JsonConvert.DeserializeObject<MafileDeserialize.Root>(json);
string accountname = accountinfo.account_name;
string steamid = accountinfo.Session.SteamID.ToString();
// ПРЕОБРАЗОВАНИЕ SteamID64toSTEAM32
string steamidparse = Steam64ToSteam32(long.Parse(steamid));
string[] steamid32 = steamidparse.Split(':');
// СОЗДАНИЕ ПАПОК СО ВСЕМИ СТИМ АЙДИ32
string rootDir = txtPath.Text;
if (!Directory.Exists(Path.Combine(rootDir, steamid32[2])))
Directory.CreateDirectory(Path.Combine(rootDir, steamid32[2]));
// КОПИРОВАНИЕ В ЭТИ ПАПКИ ОПРЕДЕЛЕННОЙ ПАПКИ С ФАЙЛАМИ
string sourceDirectory = SourcePath.Text;
string targetDirectory = txtPath.Text + "/" + steamid32[2];
Copy(sourceDirectory, targetDirectory);
counter++;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
MessageBox.Show("Загруженно " + counter.ToString() + " аккаунтов");
}
private void Convert64to3btn_Click(object sender, EventArgs e)
{
string a = Steam64ToSteam32(long.Parse(SteamID64textbox.Text));
string[] steamid32 = a.Split(':');
STEAMID3textbox.Text = steamid32[2];
}
private void ImportMFOne_btn_Click(object sender, EventArgs e)
{
if (Importer.ShowDialog() != DialogResult.OK) return;
string file = Importer.FileName;
int counter = 0;
string json = File.ReadAllText(file);
CSGOMultiAccsCFG.MafileDeserialize.Root accountinfo = JsonConvert.DeserializeObject<CSGOMultiAccsCFG.MafileDeserialize.Root>(json);
string steamid = accountinfo.Session.SteamID.ToString();
string steamidparse = Steam64ToSteam32(long.Parse(steamid));
string[] steamid32 = steamidparse.Split(':');
string rootDir = txtPath.Text;
if (!Directory.Exists(Path.Combine(rootDir, steamid32[2])))
Directory.CreateDirectory(Path.Combine(rootDir, steamid32[2]));
string sourceDirectory = SourcePath.Text;
string targetDirectory = txtPath.Text + "/" + steamid32[2];
Copy(sourceDirectory, targetDirectory);
counter++;
MessageBox.Show("Загружено " + counter + " аккаунтов");
}
private void ImportOneTxt_btn_Click(object sender, EventArgs e)
{
if (Importer.ShowDialog() != DialogResult.OK) return;
string file = Importer.FileName;
string[] steamiddata = File.ReadAllLines(file);
int counter = 0;
foreach (var line in steamiddata)
{
var steamid = line;
string steamidparse = Steam64ToSteam32(long.Parse(steamid));
string[] steamid32 = steamidparse.Split(':');
string rootDir = txtPath.Text;
if (!Directory.Exists(Path.Combine(rootDir, steamid32[2])))
Directory.CreateDirectory(Path.Combine(rootDir, steamid32[2]));
string sourceDirectory = SourcePath.Text;
string targetDirectory = txtPath.Text + "/" + steamid32[2];
Copy(sourceDirectory, targetDirectory);
counter++;
}
MessageBox.Show("Загружено " + counter + " аккаунтов");
}
private void SelectToPath_btn_Click(object sender, EventArgs e)
{
LoadingXml();
}
private void btnSelectPath_Click(object sender, EventArgs e)
{
if (Browsec.ShowDialog() == DialogResult.OK)
{
txtPath.Text = Browsec.SelectedPath;
setPath(Browsec.SelectedPath, getPathtwo());
CheckPath();
CreatePathData("setting.xml", getPath(), getPathtwo());
}
}
private void btnSelectSourcePath_Click(object sender, EventArgs e)
{
if (Browsec.ShowDialog() == DialogResult.OK)
{
SourcePath.Text = Browsec.SelectedPath;
setPath(getPath(), Browsec.SelectedPath);
CheckPathSource();
CreatePathData("setting.xml", getPath(), getPathtwo());
}
}
private void DefaultPathsBtn_Click(object sender, EventArgs e)
{
txtPath.Text = "C:\\Program Files (x86)\\Steam\\userdata";
//SourcePath.Text = "C:\\Program Files (x86)\\Steam\\userdata\\cfg cs";
SourcePath.Text = "C:\\Program Files (x86)\\Steam\\userdata\\{YOUR MAIN ACCOUNT FOR EXPORT CFG}";
}
private void SavePathSettings_Click(object sender, EventArgs e)
{
CreatePathData("setting.xml", txtPath.Text, SourcePath.Text);
LoadingXml();
}
private void button2_Click(object sender, EventArgs e)
{
int counter = 0;
string steamid32 = STEAMID3textbox.Text;
if (steamid32 != "")
{
string rootDir = txtPath.Text;
if (!Directory.Exists(Path.Combine(rootDir, steamid32)))
Directory.CreateDirectory(Path.Combine(rootDir, steamid32));
string sourceDirectory = SourcePath.Text;
//string sourceDirectory = @"D:\Макс Системные Папки\Desktop\ПРОКЕТ КСГО КФГ\конфиг для кс";
string targetDirectory = txtPath.Text + "/" + steamid32;
Copy(sourceDirectory, targetDirectory);
counter++;
MessageBox.Show("Загружено " + counter + " аккаунтов");
}
else
{
MessageBox.Show("STEAMID32 Пустой");
}
}
private void UserDataGetFolderName_btn_Click(object sender, EventArgs e)
{
string pathfolder = "C:\\Program Files (x86)\\Steam\\userdata";
string[] allfiles = Directory.GetFiles(pathfolder);
foreach (string filename in allfiles)
{
Console.WriteLine(filename);
}
}
}
}