Compare commits
No commits in common. "afe8d53638e354bd45497148555f0cd27c323f86" and "cf7aa467b9d65d69fbd9a621b0ba6797c0091383" have entirely different histories.
afe8d53638
...
cf7aa467b9
13
.idea/.idea.Zerolauncher/.idea/.gitignore
vendored
13
.idea/.idea.Zerolauncher/.idea/.gitignore
vendored
@ -1,13 +0,0 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider 忽略的文件
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
/.idea.Zerolauncher.iml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@ -28,7 +28,7 @@ namespace Zerolauncher.AboutDialog
|
||||
|
||||
private void Hyperlink_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("已拷贝到粘贴板呢喵", "提示");
|
||||
MessageBox.Show("已拷贝到粘贴板", "提示");
|
||||
Clipboard.SetDataObject("ddfgame@foxmail.com", true);
|
||||
}
|
||||
|
||||
|
||||
@ -82,9 +82,9 @@ namespace Zerolauncher
|
||||
for (int i = 0; i < 3 && !TryDeleteDirectory(@"./cache", true); i++) await Task.Delay(3000);
|
||||
}
|
||||
});
|
||||
DataStreamNew.Load();
|
||||
DataStream.Load();
|
||||
_ = WebApiManager.StartListener();
|
||||
AccountManager.InitLoadData();
|
||||
AccountManager.initLoadData();
|
||||
}
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
|
||||
|
||||
namespace Zerolauncher.Defender
|
||||
{
|
||||
class SystemSha
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -29,18 +29,13 @@ namespace Zerolauncher
|
||||
|
||||
memberBG.ContextMenu = CreateContextMenu();
|
||||
int i = 0;
|
||||
foreach (var account in AccountManager.AccountsList)
|
||||
foreach (var account in AccountManager.accountsList)
|
||||
{
|
||||
var member = new MemberControl();
|
||||
member.memberId = i++;
|
||||
member.text.Content = ServicesStaticInfo.ServicesShortName[account.ProviderId] + "-" + account.nickName;
|
||||
member.text.Content = ServicesStaticInfo.ServicesShortName[account.providerId] + "-" + account.nickName;
|
||||
mLayout.Children.Add(member);
|
||||
}
|
||||
if (i ==0)
|
||||
{
|
||||
EditMemberDialog.CreateDailog(null);
|
||||
MessageBox.Show("下次右键账号和窗口空白处可以打菜单喵", "小提示");
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadBtn()
|
||||
@ -48,11 +43,11 @@ namespace Zerolauncher
|
||||
//foreach (var btn in mLayout.Children.)
|
||||
mLayout.Children.Clear();
|
||||
int i = 0;
|
||||
foreach (var account in AccountManager.AccountsList)
|
||||
foreach (var account in AccountManager.accountsList)
|
||||
{
|
||||
var member = new MemberControl();
|
||||
member.memberId = i++;
|
||||
member.text.Content = ServicesStaticInfo.ServicesShortName[account.ProviderId] + "-" + account.nickName;
|
||||
member.text.Content = ServicesStaticInfo.ServicesShortName[account.providerId] + "-" + account.nickName;
|
||||
mLayout.Children.Add(member);
|
||||
}
|
||||
}
|
||||
@ -97,7 +92,7 @@ namespace Zerolauncher
|
||||
MenuItem menuItem = sender as MenuItem;
|
||||
int i = (int)menuItem.Tag;
|
||||
Trace.WriteLine("Clicked item index: " + i);
|
||||
AccountManager.ChangeTeam(i);
|
||||
AccountManager.reloadData(i);
|
||||
ReloadBtn();
|
||||
};
|
||||
changeTeamItem.Items.Add(menuItem);
|
||||
@ -124,7 +119,7 @@ namespace Zerolauncher
|
||||
|
||||
private void editTeamItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EditTeamDialog.CreateDailog(AccountManager.TeamName);
|
||||
EditTeamDialog.CreateDailog(AccountManager.teamName);
|
||||
}
|
||||
|
||||
private void Button_Click_3(object sender, RoutedEventArgs e)
|
||||
|
||||
@ -1,132 +1,155 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Zerolauncher.Manager
|
||||
{
|
||||
internal static class AccountManager
|
||||
internal class AccountManager
|
||||
{
|
||||
static int _teamId;
|
||||
static int teamIndex=0;
|
||||
|
||||
public static string TeamName = "";
|
||||
public static string teamName = "";
|
||||
|
||||
public static List<AccountNew>? AccountsList;
|
||||
public static List<Account> accountsList = new List<Account>();
|
||||
|
||||
public static void InitLoadData()
|
||||
public static void initLoadData()
|
||||
{
|
||||
_teamId = AccountData.TeamIndex;
|
||||
foreach (var pair in GroupsData.Data)
|
||||
teamIndex = DataStream.dataStream.teamIndex;
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
teamName = group.Name;
|
||||
foreach (var acc in group.Accounts)
|
||||
{
|
||||
Trace.WriteLine(pair.Key, pair.Value);
|
||||
accountsList.Add(acc);
|
||||
}
|
||||
TeamName = GroupsData.Data[_teamId];
|
||||
AccountsList = AccountData.Data[_teamId];
|
||||
}
|
||||
|
||||
public static void ChangeTeam(int index)
|
||||
public static void reloadData(int index = -1)
|
||||
{
|
||||
_teamId = TeamManager.Index2Key(index);
|
||||
AccountData.TeamIndex = _teamId;
|
||||
TeamName = GroupsData.Data[_teamId];
|
||||
if (!AccountData.Data.ContainsKey(_teamId))
|
||||
AccountData.Data.Add(_teamId, []);
|
||||
AccountsList = AccountData.Data[_teamId];
|
||||
DataStreamNew.Save();
|
||||
}
|
||||
if (index < 0) index = teamIndex;
|
||||
var group = DataStream.dataStream.Groups[index];
|
||||
if (teamIndex!=index)
|
||||
{
|
||||
teamIndex = index;
|
||||
teamName = group.Name;
|
||||
DataStream.dataStream.teamIndex = index;
|
||||
DataStream.write();
|
||||
}
|
||||
accountsList.Clear();
|
||||
foreach (var acc in group.Accounts)
|
||||
{
|
||||
accountsList.Add(acc);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveEdit()
|
||||
public static void saveEdit()
|
||||
{
|
||||
DataStreamNew.Save();
|
||||
DataStream.write();
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
}
|
||||
|
||||
public static bool AddAccount(AccountNew account)
|
||||
public static bool AddAccount(Account account)
|
||||
{
|
||||
account.GroupId = _teamId;
|
||||
AccountData.AddAccount(account);
|
||||
|
||||
DataStreamNew.Save();
|
||||
if (TeamManager.Nick2Acc(account.nickName) != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Accounts.Add(account);
|
||||
|
||||
accountsList.Add(account);
|
||||
DataStream.write();
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool AddAccounts(AccountNew account)
|
||||
public static bool AddAccounts(Account account)
|
||||
{
|
||||
account.GroupId = _teamId;
|
||||
AccountData.AddAccount(account);
|
||||
if (TeamManager.Nick2Acc(account.nickName) != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Accounts.Add(account);
|
||||
|
||||
accountsList.Add(account);
|
||||
//DataStream.write(); 不写
|
||||
//MainWindow.Instance.ReloadBtn(); 不更新
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void MoveAccount(int memberId, int newIndex)
|
||||
{
|
||||
var groupId = TeamManager.Index2Key(newIndex);
|
||||
if (AccountsList != null)
|
||||
{
|
||||
var acc = AccountsList[memberId];
|
||||
AccountsList.RemoveAt(memberId);
|
||||
if (!AccountData.CheckGroup(groupId)) return;
|
||||
AccountData.Data[groupId].Add(acc);
|
||||
}
|
||||
|
||||
DataStreamNew.Save();
|
||||
var group1 = DataStream.dataStream.Groups[newIndex];
|
||||
group1.Accounts.Add(accountsList[memberId]);
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Accounts.RemoveAt(memberId);
|
||||
DataStream.write();
|
||||
reloadData();
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
}
|
||||
|
||||
public static void DeleteAccount(int index) {
|
||||
if (AccountsList != null)
|
||||
{
|
||||
var nick = AccountsList[index].nickName;
|
||||
AccountsList.RemoveAt(index);
|
||||
AccountData.Dict.Remove(nick);
|
||||
}
|
||||
|
||||
DataStreamNew.Save();
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Accounts.RemoveAt(index);
|
||||
DataStream.write();
|
||||
reloadData();
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
}
|
||||
|
||||
public static void EditTeamName(string teamName0)
|
||||
public static void editTeamName(string teamName0)
|
||||
{
|
||||
TeamName = teamName0;
|
||||
GroupsData.Data[_teamId] = TeamName;
|
||||
DataStreamNew.Save();
|
||||
teamName = teamName0;
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Name = teamName;
|
||||
DataStream.write();
|
||||
}
|
||||
|
||||
public static bool DeleteTeam()
|
||||
{
|
||||
if (GroupsData.Data.Keys.Count == 1)
|
||||
if (DataStream.dataStream.Groups.Count == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
AccountData.RemoveGroup();
|
||||
ChangeTeam(GroupsData.Data.Keys.First());
|
||||
DataStreamNew.Save();
|
||||
DataStream.dataStream.Groups.RemoveAt(teamIndex);
|
||||
DataStream.write();
|
||||
reloadData(0);
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal static class TeamManager
|
||||
internal class TeamManager
|
||||
{
|
||||
|
||||
public static int Index2Key(int index) { return GroupsData.Data.ElementAt(index).Key; }
|
||||
public static string[] GetAllTeamName()
|
||||
{
|
||||
return GroupsData.Data.Values.ToArray();
|
||||
string[] names = new string[DataStream.dataStream.Groups.Count];
|
||||
int i = 0;
|
||||
foreach (var group in DataStream.dataStream.Groups)
|
||||
{
|
||||
names[i++] = group.Name;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static void AddTeam(string teamName)
|
||||
public static void addTeam(string teamName)
|
||||
{
|
||||
var key = GroupsData.Data.Keys.LastOrDefault() + 1;
|
||||
GroupsData.Data.Add(key, teamName);
|
||||
DataStreamNew.Save();
|
||||
var group = new Group { Name = teamName, Accounts = new List<Account> { } };
|
||||
DataStream.dataStream.Groups.Add(group);
|
||||
DataStream.write();
|
||||
}
|
||||
|
||||
//运行时才能决定是否执行内联
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
public static AccountNew? Nick2Acc(string nickName)
|
||||
public static Account? Nick2Acc(string nickName)
|
||||
{
|
||||
return AccountData.Dict.GetValueOrDefault(nickName);
|
||||
// find and return first take
|
||||
foreach (var group in DataStream.dataStream.Groups)
|
||||
{
|
||||
foreach (var acc in group.Accounts)
|
||||
{
|
||||
if (acc.nickName.Equals(nickName)) return acc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
|
||||
|
||||
namespace Zerolauncher.Manager
|
||||
{
|
||||
static class BusinessManager
|
||||
{
|
||||
public static bool checkIsBuy()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
90
Manager/DataStream.cs
Normal file
90
Manager/DataStream.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Zerolauncher.Manager
|
||||
{
|
||||
class DataStream
|
||||
{
|
||||
private const string path = "user.data";
|
||||
public static Data dataStream;
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
dataStream = JsonConvert.DeserializeObject<Data>(Encoding.UTF8.GetString(Decompress(File.ReadAllBytes(path))));
|
||||
}
|
||||
else
|
||||
{
|
||||
dataStream = JsonConvert.DeserializeObject<Data>(
|
||||
"{\"teamIndex\":0,\"Groups\":[{\"Name\":\"队伍1\", \"Accounts\": [{\"providerId\":0,\"userName\":\"test\",\"userPWD\":\"test\",\"nickName\":\"测试账号\",\"serverId\":\"1\"}]}], \"ecs\": \"\"}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void write()
|
||||
{
|
||||
string? data = JsonConvert.SerializeObject(dataStream);
|
||||
//Trace.WriteLine(data);
|
||||
if (data == null) return;
|
||||
File.WriteAllBytes(path, CompressBytes(Encoding.UTF8.GetBytes(data)));
|
||||
}
|
||||
|
||||
//压缩字节
|
||||
//1.创建压缩的数据流
|
||||
//2.设定compressStream为存放被压缩的文件流,并设定为压缩模式
|
||||
//3.将需要压缩的字节写到被压缩的文件流
|
||||
public static byte[] CompressBytes(byte[] bytes)
|
||||
{
|
||||
using (MemoryStream compressStream = new MemoryStream())
|
||||
{
|
||||
using (var zipStream = new GZipStream(compressStream, CompressionMode.Compress))
|
||||
zipStream.Write(bytes, 0, bytes.Length);
|
||||
return compressStream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
//解压缩字节
|
||||
//1.创建被压缩的数据流
|
||||
//2.创建zipStream对象,并传入解压的文件流
|
||||
//3.创建目标流
|
||||
//4.zipStream拷贝到目标流
|
||||
//5.返回目标流输出字节
|
||||
public static byte[] Decompress(byte[] bytes)
|
||||
{
|
||||
using (var compressStream = new MemoryStream(bytes))
|
||||
{
|
||||
using (var zipStream = new GZipStream(compressStream, CompressionMode.Decompress))
|
||||
{
|
||||
using (var resultStream = new MemoryStream())
|
||||
{
|
||||
zipStream.CopyTo(resultStream);
|
||||
return resultStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Account
|
||||
{
|
||||
public int providerId, serverId;
|
||||
public string userName, userPWD, nickName;
|
||||
}
|
||||
|
||||
class Group
|
||||
{
|
||||
public string Name;
|
||||
public List<Account> Accounts;
|
||||
}
|
||||
|
||||
struct Data
|
||||
{
|
||||
public int teamIndex;
|
||||
public List<Group> Groups;
|
||||
public string ecs;
|
||||
}
|
||||
}
|
||||
@ -1,276 +0,0 @@
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace Zerolauncher.Manager
|
||||
{
|
||||
|
||||
class DiyWriteSteamer()
|
||||
{
|
||||
ArrayBufferWriter<byte> data = new();
|
||||
|
||||
|
||||
public void WriteInt(int value)
|
||||
{
|
||||
data.Write(BitConverter.GetBytes(value));
|
||||
}
|
||||
|
||||
public void WriteString(string value)
|
||||
{
|
||||
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(value);
|
||||
WriteInt(bytes.Length);
|
||||
data.Write(bytes);
|
||||
}
|
||||
|
||||
public byte[] GetBytes() => data.WrittenSpan.ToArray();
|
||||
}
|
||||
|
||||
class DiyReader(byte[] data, int _offset=0)
|
||||
{
|
||||
public int ReadInt()
|
||||
{
|
||||
_offset += 4;
|
||||
return BitConverter.ToInt32(data, _offset - 4);
|
||||
|
||||
}
|
||||
public string ReadStr()
|
||||
{
|
||||
int lenght = ReadInt();
|
||||
_offset += lenght;
|
||||
return System.Text.Encoding.UTF8.GetString(data, _offset - lenght, lenght);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class DataStreamNew
|
||||
{
|
||||
private const string Path = "users.data";
|
||||
private static readonly byte[] Key = [9, 5, 33, 64, 99, 200, 66, 77];
|
||||
private const int HeaderVersion = 20240531;
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
if (File.Exists(Path))
|
||||
{
|
||||
byte[] byteArray;
|
||||
using (var fs = new FileStream(Path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
byteArray = new byte[fs.Length];
|
||||
fs.ReadExactly(byteArray, 0, byteArray.Length);
|
||||
}
|
||||
|
||||
ByteCry(byteArray);
|
||||
byteArray = Decompress(byteArray);
|
||||
{
|
||||
var data = new DiyReader(byteArray);
|
||||
if (data.ReadInt() != HeaderVersion)
|
||||
{
|
||||
OldDataUpdate(data);
|
||||
return;
|
||||
}
|
||||
GroupsData.Init(data);
|
||||
AccountData.Init(data);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
InitDefaultData();
|
||||
}
|
||||
|
||||
static void OldDataUpdate(DiyReader _item)
|
||||
{
|
||||
InitDefaultData();
|
||||
}
|
||||
|
||||
static void InitDefaultData()
|
||||
{
|
||||
Trace.WriteLine("加载初始数据");
|
||||
GroupsData.InitDefaultData();
|
||||
AccountData.InitDefaultData();
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
var data = new DiyWriteSteamer();
|
||||
|
||||
data.WriteInt(HeaderVersion);
|
||||
GroupsData.Out(data);
|
||||
AccountData.Out(data);
|
||||
|
||||
var buffer = CompressBytes(data.GetBytes());
|
||||
ByteCry(buffer);
|
||||
|
||||
|
||||
using (FileStream file = new(Path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
{
|
||||
file.Seek(0, SeekOrigin.Begin);
|
||||
file.Write(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void ByteCry(byte[] data)
|
||||
{
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
data[i] = (byte)(data[i] ^ Key[i % Key.Length]);
|
||||
}
|
||||
}
|
||||
|
||||
//压缩字节
|
||||
//1.创建压缩的数据流
|
||||
//2.设定compressStream为存放被压缩的文件流,并设定为压缩模式
|
||||
//3.将需要压缩的字节写到被压缩的文件流
|
||||
static byte[] CompressBytes(byte[] bytes)
|
||||
{
|
||||
using var compressStream = new MemoryStream();
|
||||
using (var zipStream = new GZipStream(compressStream, CompressionMode.Compress))
|
||||
zipStream.Write(bytes, 0, bytes.Length);
|
||||
return compressStream.ToArray();
|
||||
}
|
||||
|
||||
//解压缩字节
|
||||
//1.创建被压缩的数据流
|
||||
//2.创建zipStream对象,并传入解压的文件流
|
||||
//3.创建目标流
|
||||
//4.zipStream拷贝到目标流
|
||||
//5.返回目标流输出字节
|
||||
static byte[] Decompress(byte[] bytes)
|
||||
{
|
||||
using (var compressStream = new MemoryStream(bytes))
|
||||
{
|
||||
using (var zipStream = new GZipStream(compressStream, CompressionMode.Decompress))
|
||||
{
|
||||
using (var resultStream = new MemoryStream())
|
||||
{
|
||||
zipStream.CopyTo(resultStream);
|
||||
return resultStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class AccountNew
|
||||
{
|
||||
public int GroupId, ProviderId, ServerId;
|
||||
public string userName, userPWD, nickName;
|
||||
}
|
||||
|
||||
|
||||
internal static class AccountData
|
||||
{
|
||||
public static int TeamIndex = 0;
|
||||
|
||||
public static readonly Dictionary<int, List<AccountNew>> Data = [];
|
||||
|
||||
public static readonly Dictionary<string, AccountNew> Dict = [];
|
||||
|
||||
public static void Init(DiyReader data)
|
||||
{
|
||||
TeamIndex = data.ReadInt();
|
||||
var accountCount = data.ReadInt();
|
||||
for (var i = 0; i < accountCount; i++)
|
||||
{
|
||||
AddAccount(new AccountNew()
|
||||
{
|
||||
GroupId = data.ReadInt(),
|
||||
ProviderId = data.ReadInt(),
|
||||
ServerId = data.ReadInt(),
|
||||
userName = data.ReadStr(),
|
||||
userPWD = data.ReadStr(),
|
||||
nickName = data.ReadStr()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitDefaultData()
|
||||
{
|
||||
AddAccount(new AccountNew()
|
||||
{
|
||||
GroupId = 0,
|
||||
ProviderId = 0,
|
||||
ServerId = 1,
|
||||
userName = "test",
|
||||
userPWD = "test",
|
||||
nickName = "右键修改账号"
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddAccount(AccountNew item)
|
||||
{
|
||||
var count = 0;
|
||||
while (Dict.ContainsKey(item.nickName))
|
||||
item.nickName += count++.ToString();
|
||||
if (CheckGroup(item.GroupId))
|
||||
Data[item.GroupId].Add(item);
|
||||
}
|
||||
|
||||
public static bool CheckGroup(int groupId)
|
||||
{
|
||||
if (!GroupsData.Data.ContainsKey(groupId)) return false;
|
||||
if (!Data.ContainsKey(groupId)) Data.Add(groupId, []);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void RemoveGroup()
|
||||
{
|
||||
GroupsData.Data.Remove(TeamIndex);
|
||||
foreach (var item in Data[TeamIndex])
|
||||
{
|
||||
Dict.Remove(item.nickName);
|
||||
}
|
||||
Data.Remove(TeamIndex);
|
||||
}
|
||||
|
||||
public static void Out(DiyWriteSteamer data)
|
||||
{
|
||||
data.WriteInt(TeamIndex);
|
||||
|
||||
var arr = new List<AccountNew>();
|
||||
foreach (var item in Data.Values)
|
||||
arr.AddRange(item);
|
||||
data.WriteInt(arr.Count);
|
||||
foreach (var item in arr)
|
||||
{
|
||||
data.WriteInt(item.GroupId);
|
||||
data.WriteInt(item.ProviderId);
|
||||
data.WriteInt(item.ServerId);
|
||||
data.WriteString(item.userName);
|
||||
data.WriteString(item.userPWD);
|
||||
data.WriteString(item.nickName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class GroupsData
|
||||
{
|
||||
public static readonly Dictionary<int, string> Data = [];
|
||||
public static void Init(DiyReader dataItem)
|
||||
{
|
||||
var count = dataItem.ReadInt();
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
Data.Add(dataItem.ReadInt(), dataItem.ReadStr());
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitDefaultData()
|
||||
{
|
||||
Data.Add(0, "队伍1");
|
||||
}
|
||||
|
||||
public static void Out(DiyWriteSteamer data)
|
||||
{
|
||||
data.WriteInt(Data.Count);
|
||||
foreach (var item in Data)
|
||||
{
|
||||
data.WriteInt(item.Key);
|
||||
data.WriteString(item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -12,36 +12,36 @@ namespace Zerolauncher.Manager
|
||||
|
||||
//运行时才能决定是否执行内联
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
private static string AccToKey(AccountNew account)
|
||||
private static string AccToKey(Account account)
|
||||
{
|
||||
return string.Format("{0}{1}{2}", account.ProviderId, account.ServerId, account.userName);
|
||||
return string.Format("{0}{1}{2}", account.providerId, account.serverId, account.userName);
|
||||
}
|
||||
|
||||
public static bool CreateGame(AccountNew account)
|
||||
public static bool CreateGame(Account account)
|
||||
{
|
||||
if (UpDateData.is_check == false)
|
||||
{
|
||||
MessageBox.Show("正在更新游戏数据,请等待1-3秒喵。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return true;
|
||||
}
|
||||
if (UpDateManager.state)
|
||||
{
|
||||
UpDateManager.DoUpdate();
|
||||
MessageBox.Show("正在更新游戏数据,请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return true;
|
||||
}
|
||||
//if (UpDateManager.state)
|
||||
//{
|
||||
// UpDateManager.DoUpdate();
|
||||
// return true;
|
||||
//}
|
||||
var key = AccToKey(account);
|
||||
if (mGame.ContainsKey(key)) { return false; }
|
||||
if (CacheSha.errorCode != 0) {
|
||||
switch (CacheSha.errorCode)
|
||||
{
|
||||
case 1:
|
||||
MessageBox.Show("发生网络错误==EMS。\n 请检查网络喵", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("发生网络错误==EMS。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
case 2:
|
||||
MessageBox.Show("发生游戏服务错误==EMS。\n 请联系管理员喵", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("发生游戏服务错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
default:
|
||||
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员喵", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@ -59,17 +59,17 @@ namespace Zerolauncher.Manager
|
||||
|
||||
public static bool CreateGame(int memberId)
|
||||
{
|
||||
return CreateGame(AccountManager.AccountsList[memberId]);
|
||||
return CreateGame(AccountManager.accountsList[memberId]);
|
||||
}
|
||||
|
||||
public static int CheckGameState(AccountNew account)
|
||||
public static int CheckGameState(Account account)
|
||||
{
|
||||
var key = AccToKey(account);
|
||||
if (mGame.ContainsKey(key)) { return mGame[key].mHandle; }
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static short TurnGameSizeMini(AccountNew account)
|
||||
public static short TurnGameSizeMini(Account account)
|
||||
{
|
||||
var key = AccToKey(account);
|
||||
if (mGame.ContainsKey(key))
|
||||
@ -85,7 +85,7 @@ namespace Zerolauncher.Manager
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static short TurnGameSizeNormal(AccountNew account)
|
||||
public static short TurnGameSizeNormal(Account account)
|
||||
{
|
||||
var key = AccToKey(account);
|
||||
if (mGame.ContainsKey(key))
|
||||
@ -101,7 +101,7 @@ namespace Zerolauncher.Manager
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static bool ExitGame(AccountNew account)
|
||||
public static bool ExitGame(Account account)
|
||||
{
|
||||
var key = AccToKey(account);
|
||||
if (!mGame.ContainsKey(key)) { return false; }
|
||||
@ -109,7 +109,7 @@ namespace Zerolauncher.Manager
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void OnGameExit(AccountNew account)
|
||||
public static void OnGameExit(Account account)
|
||||
{
|
||||
mGame.Remove(AccToKey(account));
|
||||
}
|
||||
@ -125,10 +125,10 @@ namespace Zerolauncher.Manager
|
||||
Process process;
|
||||
string? restartUrl;
|
||||
public int mHandle;
|
||||
public AccountNew? account;
|
||||
public Account? account;
|
||||
string gameMode;
|
||||
|
||||
public SingleGame(AccountNew? acc, string mod = StaticHandleA.GameMode)
|
||||
public SingleGame(Account? acc, string mod = StaticHandleA.GameMode)
|
||||
{
|
||||
restartUrl = null;
|
||||
account = acc;
|
||||
@ -155,7 +155,6 @@ namespace Zerolauncher.Manager
|
||||
|
||||
private void Process_Exited(object? sender, EventArgs e)
|
||||
{
|
||||
if (account == null) return;
|
||||
Trace.WriteLine(
|
||||
$"Exit time : {process.ExitTime}\n" +
|
||||
$"Exit code : {process.ExitCode}\n" +
|
||||
@ -181,7 +180,7 @@ namespace Zerolauncher.Manager
|
||||
UpDateManager.DoUpdate1();
|
||||
return;
|
||||
}
|
||||
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.ProviderId]}-{account.nickName}");
|
||||
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.providerId]}-{account.nickName}");
|
||||
break;
|
||||
case StaticHandleC.StartDone:
|
||||
if (gameMode == StaticHandleA.UpdateMode)
|
||||
@ -252,27 +251,45 @@ namespace Zerolauncher.Manager
|
||||
{
|
||||
bool is_first_luancher = EngineManager.CheckEmpy();
|
||||
#region 检测代码
|
||||
if (mod == StaticHandleA.UpdateMode)
|
||||
{
|
||||
}
|
||||
else if (!is_check && is_first_luancher)
|
||||
{
|
||||
string? now_bit;
|
||||
using (SHA256 sha256 = SHA256.Create())
|
||||
{
|
||||
using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
{
|
||||
byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
}
|
||||
}
|
||||
if (CacheSha.GetE() != now_bit)
|
||||
{
|
||||
Trace.WriteLine("lalalala1");
|
||||
throw new FileReadException("error esu0!");
|
||||
}
|
||||
is_check = true;
|
||||
}
|
||||
//if (mod == StaticHandleA.UpdateMode)
|
||||
//{
|
||||
// if (DataStream.dataStream.ecs.Length > 10)
|
||||
// {
|
||||
// string? now_bit;
|
||||
// using (SHA256 sha256 = SHA256.Create())
|
||||
// {
|
||||
// using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
// {
|
||||
// byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
// }
|
||||
// }
|
||||
// if (DataStream.dataStream.ecs != now_bit)
|
||||
// {
|
||||
// Trace.WriteLine("lalalala" + DataStream.dataStream.ecs);
|
||||
// throw new FileReadException("error esu1!");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//else if (!is_check && is_first_luancher)
|
||||
//{
|
||||
// string? now_bit;
|
||||
// using (SHA256 sha256 = SHA256.Create())
|
||||
// {
|
||||
// using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
// {
|
||||
// byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
// }
|
||||
// }
|
||||
// if (CacheSha.GetE() != now_bit)
|
||||
// {
|
||||
// Trace.WriteLine("lalalala1");
|
||||
// throw new FileReadException("error esu0!");
|
||||
// }
|
||||
// if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); }
|
||||
// is_check = true;
|
||||
//}
|
||||
#endregion
|
||||
|
||||
var process = new Process
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Zerolauncher.util;
|
||||
@ -70,15 +69,15 @@ namespace Zerolauncher.Manager
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0");
|
||||
string? need_web = null;
|
||||
client.Timeout = TimeSpan.FromSeconds(3);
|
||||
game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.ProviderId]}的{ServicesStaticInfo.ServerNames[game.account.ServerId]}服");
|
||||
switch (game.account.ProviderId)
|
||||
game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.providerId]}的{ServicesStaticInfo.ServerNames[game.account.serverId]}服");
|
||||
switch (game.account.providerId)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
need_web = "https://www.917play.com.tw/ddt_webserver";
|
||||
break;
|
||||
default:
|
||||
game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.ServerId}");
|
||||
game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.serverId}");
|
||||
break;
|
||||
}
|
||||
client.Dispose();
|
||||
@ -88,7 +87,7 @@ namespace Zerolauncher.Manager
|
||||
// await Task.Delay(1000);
|
||||
// if (!game.Send($"{StaticHandleS.HintText} 自动登录失败,将在{i}后启用网页登录,关闭窗口取消")) { return; }
|
||||
//}
|
||||
game.Send($"{StaticHandleS.UseBrowser} {need_web} {game.account.ProviderId + 4} {ServicesStaticInfo.ServerIds[game.account.ServerId]} {game.account.userName} {game.account.userPWD}");
|
||||
game.Send($"{StaticHandleS.UseBrowser} {need_web} {game.account.providerId + 4} {ServicesStaticInfo.ServerIds[game.account.serverId]} {game.account.userName} {game.account.userPWD}");
|
||||
}
|
||||
|
||||
public static async Task DoVerify(SingleGame game, string vid, string cookie)
|
||||
@ -103,12 +102,7 @@ namespace Zerolauncher.Manager
|
||||
if (OnnxManager.onnxVerify == null) OnnxManager.onnxVerify = new OnnxVerify();
|
||||
|
||||
var verify = OnnxManager.onnxVerify.RunInference(new Bitmap(bin));
|
||||
//using (var fileStream = File.Create("tmp.png"))
|
||||
//{
|
||||
// bin.Seek(0, SeekOrigin.Begin);//设置复制开始的地方
|
||||
// bin.CopyTo(fileStream);
|
||||
//}
|
||||
game.Send($"{StaticHandleS.VerifyDone} {verify}");
|
||||
game.Send($"{StaticHandleS.VerifyDone} {verify}");
|
||||
Trace.WriteLine(verify);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -58,31 +58,30 @@ namespace Zerolauncher.Manager
|
||||
switch (CacheSha.errorCode)
|
||||
{
|
||||
case 1:
|
||||
MessageBox.Show("检查更新出错喵。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("检查更新出错。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
case 2:
|
||||
MessageBox.Show("软件已停止服务或服务错误喵。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("软件已停止服务或服务错误。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
default:
|
||||
MessageBox.Show("检查更新出错喵。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("检查更新出错。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
MessageBoxResult result = MessageBox.Show($"大厅组件需要更新\n是否更新?喵", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
|
||||
MessageBoxResult result = MessageBox.Show($"大厅组件需要更新\n是否更新?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(UpDateData.lanzou + UpDateData.user_packet_url) { UseShellExecute = true });
|
||||
// try
|
||||
// {
|
||||
// updateProcess = new SingleGame(null, StaticHandleA.UpdateMode);
|
||||
// return;
|
||||
// }
|
||||
// catch (Exception _ex)
|
||||
// {
|
||||
// MessageBox.Show("执行自动更新失败!,\n请手动访问链接重新下载大厅文件或联系管理员喵。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
//}
|
||||
}
|
||||
try
|
||||
{
|
||||
updateProcess = new SingleGame(null, StaticHandleA.UpdateMode);
|
||||
return;
|
||||
}
|
||||
catch (Exception _ex)
|
||||
{
|
||||
MessageBox.Show("执行自动更新失败!,\n请手动访问链接重新下载大厅文件或联系管理员。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoUpdate1()
|
||||
|
||||
@ -4,23 +4,23 @@ using System.Net;
|
||||
using System.Text;
|
||||
namespace Zerolauncher.Manager
|
||||
{
|
||||
internal static class WebApiManager
|
||||
internal class WebApiManager
|
||||
{
|
||||
static readonly HttpListener Listener = new HttpListener();
|
||||
static readonly CancellationTokenSource Cts = new CancellationTokenSource();
|
||||
static HttpListener listener = new HttpListener();
|
||||
static CancellationTokenSource cts = new CancellationTokenSource();
|
||||
public static async Task StartListener()
|
||||
{
|
||||
Listener.Prefixes.Add("http://127.0.0.1:7233/");
|
||||
Listener.Start();
|
||||
listener.Prefixes.Add("http://127.0.0.1:7233/");
|
||||
listener.Start();
|
||||
Trace.WriteLine("Listening...");
|
||||
|
||||
while (!Cts.Token.IsCancellationRequested)
|
||||
while (!cts.Token.IsCancellationRequested)
|
||||
{
|
||||
var context = await Listener.GetContextAsync();
|
||||
var request = context.Request;
|
||||
var response = context.Response;
|
||||
HttpListenerContext context = await listener.GetContextAsync();
|
||||
HttpListenerRequest request = context.Request;
|
||||
HttpListenerResponse response = context.Response;
|
||||
var raw = request.RawUrl;
|
||||
ResponseBody? rb = null;
|
||||
ResponesBody? rb = null;
|
||||
if (raw != null && raw.Contains("?"))
|
||||
{
|
||||
var lines = raw.Split("?");
|
||||
@ -34,79 +34,121 @@ namespace Zerolauncher.Manager
|
||||
switch (lines[0])
|
||||
{
|
||||
case "/CloseGame":
|
||||
{
|
||||
rb = EngineManager.ExitGame(acc) ? new ResponseBody(1, 0, $"Account [{nick}] successful to close.") : new ResponseBody($"Account [{nick}] is unluacher.");
|
||||
}
|
||||
{
|
||||
if (EngineManager.ExitGame(acc))
|
||||
{
|
||||
rb = new ResponesBody(1, 0, $"Account [{nick}] successful to close.");
|
||||
}
|
||||
else
|
||||
{
|
||||
rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/ToNormalSize":
|
||||
{
|
||||
rb = EngineManager.TurnGameSizeNormal(acc) switch
|
||||
{
|
||||
2 => new ResponseBody(1, 0, $"Account [{nick}] now is normal size."),
|
||||
1 => new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait."),
|
||||
0 => new ResponseBody($"Account [{nick}] is unluacher."),
|
||||
_ => rb
|
||||
};
|
||||
}
|
||||
switch (EngineManager.TurnGameSizeNormal(acc))
|
||||
{
|
||||
case 2:
|
||||
rb = new ResponesBody(1, 0, $"Account [{nick}] now is normal size.");
|
||||
break;
|
||||
case 1:
|
||||
rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
||||
break;
|
||||
case 0:
|
||||
rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/ToMiniSize":
|
||||
{
|
||||
rb = EngineManager.TurnGameSizeMini(acc) switch
|
||||
{
|
||||
2 => new ResponseBody(1, 0, $"Account [{nick}] now is mini size."),
|
||||
1 => new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait."),
|
||||
0 => new ResponseBody($"Account [{nick}] is unluacher."),
|
||||
_ => rb
|
||||
};
|
||||
}
|
||||
switch (EngineManager.TurnGameSizeMini(acc))
|
||||
{
|
||||
case 2:
|
||||
rb = new ResponesBody(1, 0, $"Account [{nick}] now is mini size.");
|
||||
break;
|
||||
case 1:
|
||||
rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
||||
break;
|
||||
case 0:
|
||||
rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/LoginGame":
|
||||
{
|
||||
if (EngineManager.CreateGame(acc))
|
||||
{
|
||||
rb = new ResponseBody(0, 0, $"Account [{nick}] successful to start.");
|
||||
rb = new ResponesBody(0, 0, $"Account [{nick}] successful to start.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var hwnd = EngineManager.CheckGameState(acc);
|
||||
rb = hwnd <= 0 ? new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait.") : new ResponseBody(1, hwnd, $"Account [{nick}] now is running.");
|
||||
int hwnd = EngineManager.CheckGameState(acc);
|
||||
if (hwnd <= 0)
|
||||
{
|
||||
rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
||||
}
|
||||
else
|
||||
{
|
||||
rb = new ResponesBody(1, hwnd, $"Account [{nick}] now is running.");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rb = new ResponseBody($"commad [{lines[0]}] undefind.");
|
||||
rb = new ResponesBody($"commad [{lines[0]}] undefind.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rb = new ResponseBody($"Account [{nick}] undefind.");
|
||||
rb = new ResponesBody($"Account [{nick}] undefind.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rb = new ResponseBody("args is missing.");
|
||||
rb = new ResponesBody("args is missing.");
|
||||
}
|
||||
|
||||
}
|
||||
rb ??= new ResponseBody();
|
||||
var buffer = Encoding.UTF8.GetBytes(rb.Encode());
|
||||
if (rb == null)
|
||||
{
|
||||
rb = new ResponesBody();
|
||||
}
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(rb.Encode());
|
||||
|
||||
response.ContentLength64 = buffer.Length;
|
||||
var output = response.OutputStream;
|
||||
Stream output = response.OutputStream;
|
||||
await output.WriteAsync(buffer, 0, buffer.Length);
|
||||
output.Close();
|
||||
}
|
||||
Listener.Stop();
|
||||
listener.Stop();
|
||||
}
|
||||
|
||||
public static void StopListener() { Cts.Cancel(); }
|
||||
public static void StopListener() { cts.Cancel(); }
|
||||
}
|
||||
|
||||
class ResponseBody(int status = -1, int hwnd = 0, string message = "Hello, World!")
|
||||
class ResponesBody
|
||||
{
|
||||
public ResponseBody(string message) : this(-1, 0, message)
|
||||
public int status;
|
||||
public int hwnd;
|
||||
public string message;
|
||||
|
||||
public ResponesBody(string message)
|
||||
{
|
||||
this.status = -1;
|
||||
this.hwnd = 0;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ResponesBody(int status=-1, int hwnd=0, string message= "Hello, World!")
|
||||
{
|
||||
this.status = status;
|
||||
this.hwnd = hwnd;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public string Encode()
|
||||
|
||||
@ -50,7 +50,6 @@
|
||||
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.17.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.4" />
|
||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,200 +0,0 @@
|
||||
Subject: [PATCH] clean up code
|
||||
---
|
||||
Index: Manager/WebApiManager.cs
|
||||
IDEA additional info:
|
||||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||
<+>UTF-8
|
||||
===================================================================
|
||||
diff --git a/Manager/WebApiManager.cs b/Manager/WebApiManager.cs
|
||||
--- a/Manager/WebApiManager.cs (revision 5129f68dadfebc3477fa29452cc914fcbcbb0106)
|
||||
+++ b/Manager/WebApiManager.cs (revision cc94e7fcc8edfcb500c176ec8e111d0f8ca98866)
|
||||
@@ -4,23 +4,23 @@
|
||||
using System.Text;
|
||||
namespace Zerolauncher.Manager
|
||||
{
|
||||
- internal class WebApiManager
|
||||
+ internal static class WebApiManager
|
||||
{
|
||||
- static HttpListener listener = new HttpListener();
|
||||
- static CancellationTokenSource cts = new CancellationTokenSource();
|
||||
+ static readonly HttpListener Listener = new HttpListener();
|
||||
+ static readonly CancellationTokenSource Cts = new CancellationTokenSource();
|
||||
public static async Task StartListener()
|
||||
{
|
||||
- listener.Prefixes.Add("http://127.0.0.1:7233/");
|
||||
- listener.Start();
|
||||
+ Listener.Prefixes.Add("http://127.0.0.1:7233/");
|
||||
+ Listener.Start();
|
||||
Trace.WriteLine("Listening...");
|
||||
|
||||
- while (!cts.Token.IsCancellationRequested)
|
||||
+ while (!Cts.Token.IsCancellationRequested)
|
||||
{
|
||||
- HttpListenerContext context = await listener.GetContextAsync();
|
||||
- HttpListenerRequest request = context.Request;
|
||||
- HttpListenerResponse response = context.Response;
|
||||
+ var context = await Listener.GetContextAsync();
|
||||
+ var request = context.Request;
|
||||
+ var response = context.Response;
|
||||
var raw = request.RawUrl;
|
||||
- ResponesBody? rb = null;
|
||||
+ ResponseBody? rb = null;
|
||||
if (raw != null && raw.Contains("?"))
|
||||
{
|
||||
var lines = raw.Split("?");
|
||||
@@ -34,121 +34,79 @@
|
||||
switch (lines[0])
|
||||
{
|
||||
case "/CloseGame":
|
||||
- {
|
||||
- if (EngineManager.ExitGame(acc))
|
||||
- {
|
||||
- rb = new ResponesBody(1, 0, $"Account [{nick}] successful to close.");
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ {
|
||||
+ rb = EngineManager.ExitGame(acc) ? new ResponseBody(1, 0, $"Account [{nick}] successful to close.") : new ResponseBody($"Account [{nick}] is unluacher.");
|
||||
+ }
|
||||
break;
|
||||
case "/ToNormalSize":
|
||||
- {
|
||||
- switch (EngineManager.TurnGameSizeNormal(acc))
|
||||
- {
|
||||
- case 2:
|
||||
- rb = new ResponesBody(1, 0, $"Account [{nick}] now is normal size.");
|
||||
- break;
|
||||
- case 1:
|
||||
- rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
||||
- break;
|
||||
- case 0:
|
||||
- rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ {
|
||||
+ rb = EngineManager.TurnGameSizeNormal(acc) switch
|
||||
+ {
|
||||
+ 2 => new ResponseBody(1, 0, $"Account [{nick}] now is normal size."),
|
||||
+ 1 => new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait."),
|
||||
+ 0 => new ResponseBody($"Account [{nick}] is unluacher."),
|
||||
+ _ => rb
|
||||
+ };
|
||||
+ }
|
||||
break;
|
||||
case "/ToMiniSize":
|
||||
- {
|
||||
- switch (EngineManager.TurnGameSizeMini(acc))
|
||||
- {
|
||||
- case 2:
|
||||
- rb = new ResponesBody(1, 0, $"Account [{nick}] now is mini size.");
|
||||
- break;
|
||||
- case 1:
|
||||
- rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
||||
- break;
|
||||
- case 0:
|
||||
- rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ {
|
||||
+ rb = EngineManager.TurnGameSizeMini(acc) switch
|
||||
+ {
|
||||
+ 2 => new ResponseBody(1, 0, $"Account [{nick}] now is mini size."),
|
||||
+ 1 => new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait."),
|
||||
+ 0 => new ResponseBody($"Account [{nick}] is unluacher."),
|
||||
+ _ => rb
|
||||
+ };
|
||||
+ }
|
||||
break;
|
||||
case "/LoginGame":
|
||||
{
|
||||
if (EngineManager.CreateGame(acc))
|
||||
{
|
||||
- rb = new ResponesBody(0, 0, $"Account [{nick}] successful to start.");
|
||||
+ rb = new ResponseBody(0, 0, $"Account [{nick}] successful to start.");
|
||||
}
|
||||
else
|
||||
{
|
||||
- int hwnd = EngineManager.CheckGameState(acc);
|
||||
- if (hwnd <= 0)
|
||||
- {
|
||||
- rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- rb = new ResponesBody(1, hwnd, $"Account [{nick}] now is running.");
|
||||
- }
|
||||
+ var hwnd = EngineManager.CheckGameState(acc);
|
||||
+ rb = hwnd <= 0 ? new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait.") : new ResponseBody(1, hwnd, $"Account [{nick}] now is running.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
- rb = new ResponesBody($"commad [{lines[0]}] undefind.");
|
||||
+ rb = new ResponseBody($"commad [{lines[0]}] undefind.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
- rb = new ResponesBody($"Account [{nick}] undefind.");
|
||||
+ rb = new ResponseBody($"Account [{nick}] undefind.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
- rb = new ResponesBody("args is missing.");
|
||||
+ rb = new ResponseBody("args is missing.");
|
||||
}
|
||||
|
||||
}
|
||||
- if (rb == null)
|
||||
- {
|
||||
- rb = new ResponesBody();
|
||||
- }
|
||||
- byte[] buffer = Encoding.UTF8.GetBytes(rb.Encode());
|
||||
+ rb ??= new ResponseBody();
|
||||
+ var buffer = Encoding.UTF8.GetBytes(rb.Encode());
|
||||
|
||||
response.ContentLength64 = buffer.Length;
|
||||
- Stream output = response.OutputStream;
|
||||
+ var output = response.OutputStream;
|
||||
await output.WriteAsync(buffer, 0, buffer.Length);
|
||||
output.Close();
|
||||
}
|
||||
- listener.Stop();
|
||||
+ Listener.Stop();
|
||||
}
|
||||
|
||||
- public static void StopListener() { cts.Cancel(); }
|
||||
+ public static void StopListener() { Cts.Cancel(); }
|
||||
}
|
||||
|
||||
- class ResponesBody
|
||||
+ class ResponseBody(int status = -1, int hwnd = 0, string message = "Hello, World!")
|
||||
{
|
||||
- public int status;
|
||||
- public int hwnd;
|
||||
- public string message;
|
||||
-
|
||||
- public ResponesBody(string message)
|
||||
+ public ResponseBody(string message) : this(-1, 0, message)
|
||||
{
|
||||
- this.status = -1;
|
||||
- this.hwnd = 0;
|
||||
- this.message = message;
|
||||
- }
|
||||
-
|
||||
- public ResponesBody(int status=-1, int hwnd=0, string message= "Hello, World!")
|
||||
- {
|
||||
- this.status = status;
|
||||
- this.hwnd = hwnd;
|
||||
- this.message = message;
|
||||
}
|
||||
|
||||
public string Encode()
|
||||
@ -5,9 +5,10 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="75" d:DesignWidth="65" Margin="5">
|
||||
|
||||
<DockPanel>
|
||||
<Image Name="icon" DockPanel.Dock="Top" Source="/res/player_ico1.png" Width="60" Height="60"/>
|
||||
<Label Name="text" DockPanel.Dock="Bottom" Content="43-测试账号" FontSize="9" Padding="0" Width="65"/>
|
||||
</DockPanel>
|
||||
<Grid>
|
||||
<DockPanel>
|
||||
<Image Name="icon" DockPanel.Dock="Top" Source="/res/player_ico1.png" Width="60" Height="60"/>
|
||||
<Label Name="text" DockPanel.Dock="Bottom" Content="43-测试账号" FontSize="9" Padding="0" Width="65"/>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@ -27,7 +27,8 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--<Button x:Name="btn_diy" Content="自定义图片"/>-->
|
||||
<Button x:Name="btn_diy" Content="自定义图片"/>
|
||||
<Button x:Name="btn_clut" Content="截取游戏" Grid.Row="1"/>
|
||||
<Image Grid.Column="1" Grid.RowSpan="2" Source="/res/player_ico1.png"/>
|
||||
</Grid>
|
||||
<DockPanel Grid.ColumnSpan="1" Margin="2">
|
||||
|
||||
@ -28,9 +28,9 @@ namespace Zerolauncher.dialog
|
||||
if (EditMemberDialog.member != null)
|
||||
{
|
||||
int index = (int)EditMemberDialog.member;
|
||||
var acc = AccountManager.AccountsList[index];
|
||||
cb_pid.SelectedIndex = acc.ProviderId;
|
||||
cb_sid.SelectedIndex = acc.ServerId;
|
||||
var acc = AccountManager.accountsList[index];
|
||||
cb_pid.SelectedIndex = acc.providerId;
|
||||
cb_sid.SelectedIndex = acc.serverId;
|
||||
edit_acc.Text = acc.userName;
|
||||
edit_pwd.Password = acc.userPWD;
|
||||
edit_nick.Text = acc.nickName;
|
||||
@ -64,19 +64,19 @@ namespace Zerolauncher.dialog
|
||||
}
|
||||
if (EditMemberDialog.member == null)
|
||||
{
|
||||
AccountManager.AddAccount(new AccountNew { ProviderId = cb_pid.SelectedIndex, ServerId = cb_sid.SelectedIndex, userName = edit_acc.Text, userPWD = edit_pwd.Password, nickName = edit_nick.Text });
|
||||
AccountManager.AddAccount(new Account { providerId = cb_pid.SelectedIndex, serverId = cb_sid.SelectedIndex, userName = edit_acc.Text, userPWD = edit_pwd.Password, nickName = edit_nick.Text });
|
||||
|
||||
EditMemberDialog.Close();
|
||||
return;
|
||||
}
|
||||
int index = (int)EditMemberDialog.member;
|
||||
var acc = AccountManager.AccountsList[index];
|
||||
acc.ProviderId = cb_pid.SelectedIndex;
|
||||
acc.ServerId = cb_sid.SelectedIndex;
|
||||
var acc = AccountManager.accountsList[index];
|
||||
acc.providerId = cb_pid.SelectedIndex;
|
||||
acc.serverId = cb_sid.SelectedIndex;
|
||||
acc.userName = edit_acc.Text;
|
||||
acc.userPWD = edit_pwd.Password;
|
||||
acc.nickName = edit_nick.Text;
|
||||
AccountManager.SaveEdit();
|
||||
AccountManager.saveEdit();
|
||||
EditMemberDialog.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -22,24 +22,21 @@ namespace Zerolauncher.dialog
|
||||
{
|
||||
if(string.IsNullOrEmpty(edit_name.Text))
|
||||
{
|
||||
MessageBox.Show("昵称不能为空喵!", "提示");
|
||||
MessageBox.Show("昵称不能为空!", "提示");
|
||||
return;
|
||||
}
|
||||
if (isEditModle) AccountManager.EditTeamName(edit_name.Text); else TeamManager.AddTeam(edit_name.Text);
|
||||
if (isEditModle) AccountManager.editTeamName(edit_name.Text); else TeamManager.addTeam(edit_name.Text);
|
||||
EditTeamDialog.Close();
|
||||
}
|
||||
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBoxResult result = MessageBox.Show("放生此队伍以及队伍里所有的账号\n为你带来114514点功德\n要执行此操作喵?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
|
||||
MessageBoxResult result = MessageBox.Show("即将放生此队伍以及队伍里所有的账号\n将会为你带来114点功德\n您确定要执行此操作吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
if (!AccountManager.DeleteTeam())
|
||||
{
|
||||
MessageBox.Show("已经是最后一个队伍了喵!\n新建一个队伍后再放生这个~", "提示");
|
||||
}
|
||||
if (!AccountManager.DeleteTeam()) MessageBox.Show("少爷这已经是最后一个队伍了!\n请新建一个队伍后再放生这个吧~", "提示");
|
||||
else EditTeamDialog.Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
<Window x:Class="Zerolauncher.dialog.RegDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="注册账号.."
|
||||
MinHeight="200"
|
||||
MinWidth="300"
|
||||
SizeToContent="WidthAndHeight"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
FocusManager.FocusedElement="{Binding ElementName=leftMarginTextBox}">
|
||||
<Grid Margin="10">
|
||||
<Grid.Resources>
|
||||
<!-- Default settings for controls -->
|
||||
<Style TargetType="{x:Type Label}">
|
||||
<Setter Property="Margin" Value="0,3,5,5" />
|
||||
<Setter Property="Padding" Value="0,0,0,5" />
|
||||
</Style>
|
||||
<Style TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Margin" Value="0,0,0,5" />
|
||||
</Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Width" Value="70" />
|
||||
<Setter Property="Height" Value="25" />
|
||||
<Setter Property="Margin" Value="5,0,0,0" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Left,Top,Right,Bottom margins-->
|
||||
<Button Width="200" Margin="0, 0, 0, 30" Height="50" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Grid.RowSpan="2" Click="FleshPic">
|
||||
<Image x:Name="CapPic" Source="/res/captcha.jpg"/>
|
||||
</Button>
|
||||
|
||||
<Label Grid.Column="0" Grid.Row="2">验证码:</Label>
|
||||
<TextBox Name="RightMarginTextBox" Grid.Column="1" Grid.Row="2" />
|
||||
|
||||
<Label Grid.Column="0" Grid.Row="3">注册邮箱:</Label>
|
||||
<TextBox Name="BottomMarginTextBox" Grid.Column="1" Grid.Row="3" />
|
||||
|
||||
<!-- Accept or Cancel -->
|
||||
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Name="OkButton" IsDefault="True" Click="okButton_Click" >确定</Button>
|
||||
<Button Name="CancelButton" IsCancel="True" Click="cancelButton_Click">取消</Button>
|
||||
</StackPanel>
|
||||
</Grid >
|
||||
</Window>
|
||||
@ -1,94 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Zerolauncher.Manager;
|
||||
|
||||
namespace Zerolauncher.dialog
|
||||
{
|
||||
/// <summary>
|
||||
/// RegDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class RegDialog : Window
|
||||
{
|
||||
private HttpClient client;
|
||||
private string user;
|
||||
private string password;
|
||||
public RegDialog(String acc, String pwd)
|
||||
{
|
||||
user = acc;
|
||||
password = pwd;
|
||||
InitializeComponent();
|
||||
client = new();
|
||||
FleshPic(null, null);
|
||||
}
|
||||
|
||||
private async void FleshPic(object _, RoutedEventArgs e)
|
||||
{
|
||||
// var main_ip = UpDateData.game_url;
|
||||
// HttpResponseMessage? response = null;
|
||||
// try
|
||||
// {
|
||||
// response = await client.GetAsync($"http://{main_ip}/module/captcha.php");
|
||||
// if (response != null)
|
||||
// {
|
||||
// foreach (var item in response.Headers)
|
||||
// Console.WriteLine($"{item.Key}");
|
||||
// }
|
||||
// //var bin = response.Content.ReadAsStream();
|
||||
// //verify = ocr.RunInference(new Bitmap(bin));
|
||||
// //using (var fileStream = File.Create("tmp.png"))
|
||||
// //{
|
||||
// // bin.Seek(0, SeekOrigin.Begin);//设置复制开始的地方
|
||||
// // bin.CopyTo(fileStream);
|
||||
// //}
|
||||
// using (var stream = response.Content.ReadAsStream())
|
||||
// {
|
||||
// BitmapImage bitmap = new BitmapImage();
|
||||
// bitmap.BeginInit();
|
||||
// bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
||||
// bitmap.StreamSource = stream;
|
||||
// bitmap.EndInit();
|
||||
// bitmap.Freeze(); // 为了线程安全
|
||||
//
|
||||
// CapPic.Source = bitmap; // 设置Image控件的Source
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine($" 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||
// }
|
||||
}
|
||||
|
||||
private async void okButton_Click(object _, RoutedEventArgs e)
|
||||
{
|
||||
// var main_ip = UpDateData.game_url;
|
||||
// var values = new Dictionary<string, string>
|
||||
// {
|
||||
// { "rUsername", user },
|
||||
// { "rPassword", password },
|
||||
// { "rPasswords", password },
|
||||
// { "rEmail", BottomMarginTextBox.Text },
|
||||
// { "rCode", RightMarginTextBox.Text }
|
||||
// };
|
||||
// var content = new FormUrlEncodedContent(values);
|
||||
// try
|
||||
// {
|
||||
// var response = await client.PostAsync($"http://{main_ip}/form/register.php", content);
|
||||
// var src = await response.Content.ReadAsStringAsync();
|
||||
// var jsonObj = JObject.Parse(src);
|
||||
// MessageBox.Show(jsonObj["content"].ToString(), jsonObj["title"].ToString());
|
||||
// if(int.Parse(jsonObj["type"].ToString()) == 0) Close();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// MessageBox.Show($"类型:{ex.GetType().Name},消息:{ex.Message}", "发生错误喵");
|
||||
// }
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@
|
||||
<TextBlock DockPanel.Dock="Top" Margin="5" Text="文本格式:一行一个账号,如:
 服务器---区号---账号---密码---备注
服务器填代号:
 如[0, 4399大区]意味着4399大区的代号是0,
 具体查看添加账号时,以列表显示的为准" Foreground="#FFB44242"/>
|
||||
<DockPanel DockPanel.Dock="Bottom">
|
||||
<Button DockPanel.Dock="Right" Content="选择文件" Click="Button_Click"/>
|
||||
<TextBox Name="InputSplit" DockPanel.Dock="Right" Text="---" Width="100"/>
|
||||
<TextBox Name="input_split" DockPanel.Dock="Right" Text="---" Width="100"/>
|
||||
<TextBlock DockPanel.Dock="Right" Text="分隔符:" Foreground="#FFEE9595"/>
|
||||
<Label/>
|
||||
</DockPanel>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Zerolauncher.Manager;
|
||||
|
||||
namespace Zerolauncher.dialog
|
||||
@ -9,7 +10,7 @@ namespace Zerolauncher.dialog
|
||||
/// <summary>
|
||||
/// UseAccDataTextAdd.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class UseAccDataTextAdd
|
||||
public partial class UseAccDataTextAdd : UserControl
|
||||
{
|
||||
public UseAccDataTextAdd()
|
||||
{
|
||||
@ -19,55 +20,54 @@ namespace Zerolauncher.dialog
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//创建一个打开文件式的对话框
|
||||
var ofd = new OpenFileDialog
|
||||
{
|
||||
//设置这个对话框的起始打开路径
|
||||
InitialDirectory = @"C:\",
|
||||
//设置打开的文件的类型,注意过滤器的语法
|
||||
Filter = "账号文本|*.txt|其他格式|*."
|
||||
};
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
//设置这个对话框的起始打开路径
|
||||
ofd.InitialDirectory = @"C:\";
|
||||
//设置打开的文件的类型,注意过滤器的语法
|
||||
ofd.Filter = "账号文本|*.txt|其他格式|*.";
|
||||
//调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
|
||||
if (ofd.ShowDialog() == true)
|
||||
{
|
||||
var lines = File.ReadAllLines(ofd.FileName, Encoding.UTF8);
|
||||
for (var i = 0; i < lines.Length; i++)
|
||||
string[] lines = File.ReadAllLines(ofd.FileName, Encoding.UTF8);
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
var accTexts = lines[i].Split(InputSplit.Text);
|
||||
var accTexts = lines[i].Split(input_split.Text);
|
||||
if (accTexts.Length != 5)
|
||||
{
|
||||
MessageBox.Show($"文本在{i}行非法喵!\n{lines[i]}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show($"文本在{i}行非法!\n{lines[i]}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
var acc = new AccountNew { };
|
||||
if (!int.TryParse(accTexts[0], out acc.ProviderId))
|
||||
var acc = new Account { };
|
||||
if (!int.TryParse(accTexts[0], out acc.providerId))
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误喵!在{i}行\n错误:[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show($"输入的服务商代号错误!在{i}行\n错误:[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
if(0 < acc.ProviderId || acc.ProviderId > ServicesStaticInfo.ServicesName.Length)
|
||||
if(0 < acc.providerId || acc.providerId > ServicesStaticInfo.ServicesName.Length)
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误喵!在{i}行\n错误:[{acc.ProviderId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
if (!int.TryParse(accTexts[1], out acc.ServerId))
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误喵!在{i}行\n错误:[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
if (0 < acc.ProviderId || acc.ProviderId > ServicesStaticInfo.ServerIds.Length)
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误喵!在{i}行\n错误:[{acc.ProviderId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show($"输入的服务商代号错误!在{i}行\n错误:[{acc.providerId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
if (!int.TryParse(accTexts[1], out acc.serverId))
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误!在{i}行\n错误:[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
if (0 < acc.providerId || acc.providerId > ServicesStaticInfo.ServerIds.Length)
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误!在{i}行\n错误:[{acc.providerId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
acc.userName = accTexts[2];
|
||||
acc.userPWD = accTexts[3];
|
||||
acc.nickName = accTexts[4];
|
||||
if (AccountManager.AddAccounts(acc)) continue;
|
||||
MessageBox.Show($"文本在{i}行出错喵!\n警告:[{acc.nickName}]昵称冲突,将跳过添加此账号", "Warring", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
if (!AccountManager.AddAccounts(acc))
|
||||
{
|
||||
MessageBox.Show($"文本在{i}行出错!\n警告:[{acc.nickName}]昵称冲突,将跳过添加此账号", "Warring", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
MessageBox.Show("添加完成喵!", "提示");
|
||||
AccountManager.SaveEdit();
|
||||
MessageBox.Show("添加完成!", "提示");
|
||||
AccountManager.saveEdit();
|
||||
AddMemebersDialog.Close();
|
||||
}
|
||||
else
|
||||
|
||||
BIN
res/captcha.jpg
BIN
res/captcha.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB |
@ -83,109 +83,4 @@ namespace Zerolauncher.util
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
class UrlEncoder
|
||||
{
|
||||
static readonly Dictionary<char, char> map = new Dictionary<char, char> {
|
||||
{'0', (char)8194},
|
||||
{'1', (char)8196},
|
||||
{'2', (char)8197},
|
||||
{'3', (char)8198},
|
||||
{'4', (char)8199},
|
||||
{'5', (char)8200},
|
||||
{'6', (char)8201},
|
||||
{'7', (char)8202},
|
||||
{'8', (char)8239},
|
||||
{'9', (char)8287},
|
||||
};
|
||||
|
||||
static readonly Dictionary<char, char> map1 = new Dictionary<char, char>
|
||||
{
|
||||
{'.', (char)8192},
|
||||
{':', (char)8194},
|
||||
};
|
||||
|
||||
static readonly Dictionary<char, char> dmap1 = new Dictionary<char, char>
|
||||
{
|
||||
{(char)8192, '.'},
|
||||
{(char)8194, ':'},
|
||||
};
|
||||
|
||||
static readonly Dictionary<char, char> dmap = new Dictionary<char, char> {
|
||||
{(char)8194, '0'},
|
||||
{(char)8196, '1'},
|
||||
{(char)8197, '2'},
|
||||
{(char)8198, '3'},
|
||||
{(char)8199, '4'},
|
||||
{(char)8200, '5'},
|
||||
{(char)8201, '6'},
|
||||
{(char)8202, '7'},
|
||||
{(char)8239, '8'},
|
||||
{(char)8287, '9'},
|
||||
};
|
||||
|
||||
static readonly char end_line = (char)8193;
|
||||
|
||||
static readonly char sec_char = (char)32;
|
||||
|
||||
public static string? Encode(string url, out int counter)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append(end_line);
|
||||
counter = 0;
|
||||
foreach (var item in url)
|
||||
{
|
||||
if (map.ContainsKey(item)) sb.Append(map[item]);
|
||||
else if (map1.ContainsKey(item)) { sb.Append(sec_char); sb.Append(map1[item]); }
|
||||
else return null;
|
||||
counter++;
|
||||
}
|
||||
sb.Append(end_line);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string? Decode(string space, out int counter)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
counter = 0;
|
||||
bool is_sec_char = false;
|
||||
foreach (var item in space)
|
||||
{
|
||||
if (counter != 0)
|
||||
{
|
||||
if (item == end_line) break;
|
||||
else if (is_sec_char)
|
||||
{
|
||||
if (!dmap1.ContainsKey(item)) return null;
|
||||
sb.Append(dmap1[item]);
|
||||
is_sec_char = false;
|
||||
}
|
||||
else if (item == sec_char) is_sec_char = true;
|
||||
else if (dmap.ContainsKey(item)) sb.Append(dmap[item]);
|
||||
else return null;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class KeyUrlEncoder
|
||||
{
|
||||
static readonly string key = "TestKey123456";
|
||||
|
||||
public static string XorEncryptDecrypt(string input)
|
||||
{
|
||||
char[] output = new char[input.Length];
|
||||
|
||||
for (int i = 0; i < input.Length; i++)
|
||||
{
|
||||
output[i] = (char)(input[i] ^ key[i % key.Length]);
|
||||
}
|
||||
|
||||
return new string(output);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
|
||||
|
||||
namespace Zerolauncher.util
|
||||
{
|
||||
static class SyStemExcuteCommand
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user