Compare commits
16 Commits
master
...
TaiWanMast
| Author | SHA1 | Date | |
|---|---|---|---|
| 6507b43b23 | |||
| afe8d53638 | |||
| e92c497407 | |||
| 3b2f350439 | |||
| b532d7ae05 | |||
| e069c3ccbc | |||
| 779c59f112 | |||
| 4d0cf5a012 | |||
| b5c7241fcb | |||
| f34713b9f3 | |||
| 6f4515cfe3 | |||
| b2fdb364bf | |||
| 05e0baac8f | |||
| 788a823b60 | |||
| cf7aa467b9 | |||
| ff2a27a08d |
13
.idea/.idea.Zerolauncher/.idea/.gitignore
vendored
Normal file
13
.idea/.idea.Zerolauncher/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Rider 忽略的文件
|
||||||
|
/modules.xml
|
||||||
|
/contentModel.xml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/.idea.Zerolauncher.iml
|
||||||
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
4
.idea/.idea.Zerolauncher/.idea/encodings.xml
Normal file
4
.idea/.idea.Zerolauncher/.idea/encodings.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
8
.idea/.idea.Zerolauncher/.idea/indexLayout.xml
Normal file
8
.idea/.idea.Zerolauncher/.idea/indexLayout.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/.idea.Zerolauncher/.idea/vcs.xml
Normal file
6
.idea/.idea.Zerolauncher/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?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)
|
private void Hyperlink_Click_1(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
MessageBox.Show("已拷贝到粘贴板", "提示");
|
MessageBox.Show("已拷贝到粘贴板呢喵", "提示");
|
||||||
Clipboard.SetDataObject("ddfgame@foxmail.com", true);
|
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);
|
for (int i = 0; i < 3 && !TryDeleteDirectory(@"./cache", true); i++) await Task.Delay(3000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
DataStream.Load();
|
DataStreamNew.Load();
|
||||||
_ = WebApiManager.StartListener();
|
_ = WebApiManager.StartListener();
|
||||||
AccountManager.initLoadData();
|
AccountManager.InitLoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnExit(ExitEventArgs e)
|
protected override void OnExit(ExitEventArgs e)
|
||||||
|
|||||||
9
Defender/SystemSha.cs
Normal file
9
Defender/SystemSha.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
namespace Zerolauncher.Defender
|
||||||
|
{
|
||||||
|
class SystemSha
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -29,13 +29,18 @@ namespace Zerolauncher
|
|||||||
|
|
||||||
memberBG.ContextMenu = CreateContextMenu();
|
memberBG.ContextMenu = CreateContextMenu();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var account in AccountManager.accountsList)
|
foreach (var account in AccountManager.AccountsList)
|
||||||
{
|
{
|
||||||
var member = new MemberControl();
|
var member = new MemberControl();
|
||||||
member.memberId = i++;
|
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);
|
mLayout.Children.Add(member);
|
||||||
}
|
}
|
||||||
|
if (i ==0)
|
||||||
|
{
|
||||||
|
EditMemberDialog.CreateDailog(null);
|
||||||
|
MessageBox.Show("下次右键账号和窗口空白处可以打菜单喵", "小提示");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadBtn()
|
public void ReloadBtn()
|
||||||
@ -43,11 +48,11 @@ namespace Zerolauncher
|
|||||||
//foreach (var btn in mLayout.Children.)
|
//foreach (var btn in mLayout.Children.)
|
||||||
mLayout.Children.Clear();
|
mLayout.Children.Clear();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var account in AccountManager.accountsList)
|
foreach (var account in AccountManager.AccountsList)
|
||||||
{
|
{
|
||||||
var member = new MemberControl();
|
var member = new MemberControl();
|
||||||
member.memberId = i++;
|
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);
|
mLayout.Children.Add(member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +97,7 @@ namespace Zerolauncher
|
|||||||
MenuItem menuItem = sender as MenuItem;
|
MenuItem menuItem = sender as MenuItem;
|
||||||
int i = (int)menuItem.Tag;
|
int i = (int)menuItem.Tag;
|
||||||
Trace.WriteLine("Clicked item index: " + i);
|
Trace.WriteLine("Clicked item index: " + i);
|
||||||
AccountManager.reloadData(i);
|
AccountManager.ChangeTeam(i);
|
||||||
ReloadBtn();
|
ReloadBtn();
|
||||||
};
|
};
|
||||||
changeTeamItem.Items.Add(menuItem);
|
changeTeamItem.Items.Add(menuItem);
|
||||||
@ -119,7 +124,7 @@ namespace Zerolauncher
|
|||||||
|
|
||||||
private void editTeamItem_Click(object sender, RoutedEventArgs e)
|
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)
|
private void Button_Click_3(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@ -1,155 +1,132 @@
|
|||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Zerolauncher.Manager
|
namespace Zerolauncher.Manager
|
||||||
{
|
{
|
||||||
internal class AccountManager
|
internal static class AccountManager
|
||||||
{
|
{
|
||||||
static int teamIndex=0;
|
static int _teamId;
|
||||||
|
|
||||||
public static string teamName = "";
|
public static string TeamName = "";
|
||||||
|
|
||||||
public static List<Account> accountsList = new List<Account>();
|
public static List<AccountNew>? AccountsList;
|
||||||
|
|
||||||
public static void initLoadData()
|
public static void InitLoadData()
|
||||||
{
|
{
|
||||||
teamIndex = DataStream.dataStream.teamIndex;
|
_teamId = AccountData.TeamIndex;
|
||||||
var group = DataStream.dataStream.Groups[teamIndex];
|
foreach (var pair in GroupsData.Data)
|
||||||
teamName = group.Name;
|
|
||||||
foreach (var acc in group.Accounts)
|
|
||||||
{
|
{
|
||||||
accountsList.Add(acc);
|
Trace.WriteLine(pair.Key, pair.Value);
|
||||||
}
|
}
|
||||||
|
TeamName = GroupsData.Data[_teamId];
|
||||||
|
AccountsList = AccountData.Data[_teamId];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadData(int index = -1)
|
public static void ChangeTeam(int index)
|
||||||
{
|
{
|
||||||
if (index < 0) index = teamIndex;
|
_teamId = TeamManager.Index2Key(index);
|
||||||
var group = DataStream.dataStream.Groups[index];
|
AccountData.TeamIndex = _teamId;
|
||||||
if (teamIndex!=index)
|
TeamName = GroupsData.Data[_teamId];
|
||||||
{
|
if (!AccountData.Data.ContainsKey(_teamId))
|
||||||
teamIndex = index;
|
AccountData.Data.Add(_teamId, []);
|
||||||
teamName = group.Name;
|
AccountsList = AccountData.Data[_teamId];
|
||||||
DataStream.dataStream.teamIndex = index;
|
DataStreamNew.Save();
|
||||||
DataStream.write();
|
|
||||||
}
|
|
||||||
accountsList.Clear();
|
|
||||||
foreach (var acc in group.Accounts)
|
|
||||||
{
|
|
||||||
accountsList.Add(acc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveEdit()
|
public static void SaveEdit()
|
||||||
{
|
{
|
||||||
DataStream.write();
|
DataStreamNew.Save();
|
||||||
MainWindow.Instance.ReloadBtn();
|
MainWindow.Instance.ReloadBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AddAccount(Account account)
|
public static bool AddAccount(AccountNew account)
|
||||||
{
|
{
|
||||||
if (TeamManager.Nick2Acc(account.nickName) != null)
|
account.GroupId = _teamId;
|
||||||
{
|
AccountData.AddAccount(account);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var group = DataStream.dataStream.Groups[teamIndex];
|
|
||||||
group.Accounts.Add(account);
|
|
||||||
|
|
||||||
accountsList.Add(account);
|
DataStreamNew.Save();
|
||||||
DataStream.write();
|
|
||||||
MainWindow.Instance.ReloadBtn();
|
MainWindow.Instance.ReloadBtn();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AddAccounts(Account account)
|
public static bool AddAccounts(AccountNew account)
|
||||||
{
|
{
|
||||||
if (TeamManager.Nick2Acc(account.nickName) != null)
|
account.GroupId = _teamId;
|
||||||
{
|
AccountData.AddAccount(account);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var group = DataStream.dataStream.Groups[teamIndex];
|
|
||||||
group.Accounts.Add(account);
|
|
||||||
|
|
||||||
accountsList.Add(account);
|
|
||||||
//DataStream.write(); 不写
|
|
||||||
//MainWindow.Instance.ReloadBtn(); 不更新
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MoveAccount(int memberId, int newIndex)
|
public static void MoveAccount(int memberId, int newIndex)
|
||||||
{
|
{
|
||||||
var group1 = DataStream.dataStream.Groups[newIndex];
|
var groupId = TeamManager.Index2Key(newIndex);
|
||||||
group1.Accounts.Add(accountsList[memberId]);
|
if (AccountsList != null)
|
||||||
var group = DataStream.dataStream.Groups[teamIndex];
|
{
|
||||||
group.Accounts.RemoveAt(memberId);
|
var acc = AccountsList[memberId];
|
||||||
DataStream.write();
|
AccountsList.RemoveAt(memberId);
|
||||||
reloadData();
|
if (!AccountData.CheckGroup(groupId)) return;
|
||||||
|
AccountData.Data[groupId].Add(acc);
|
||||||
|
}
|
||||||
|
|
||||||
|
DataStreamNew.Save();
|
||||||
MainWindow.Instance.ReloadBtn();
|
MainWindow.Instance.ReloadBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DeleteAccount(int index) {
|
public static void DeleteAccount(int index) {
|
||||||
var group = DataStream.dataStream.Groups[teamIndex];
|
if (AccountsList != null)
|
||||||
group.Accounts.RemoveAt(index);
|
{
|
||||||
DataStream.write();
|
var nick = AccountsList[index].nickName;
|
||||||
reloadData();
|
AccountsList.RemoveAt(index);
|
||||||
|
AccountData.Dict.Remove(nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
DataStreamNew.Save();
|
||||||
MainWindow.Instance.ReloadBtn();
|
MainWindow.Instance.ReloadBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void editTeamName(string teamName0)
|
public static void EditTeamName(string teamName0)
|
||||||
{
|
{
|
||||||
teamName = teamName0;
|
TeamName = teamName0;
|
||||||
var group = DataStream.dataStream.Groups[teamIndex];
|
GroupsData.Data[_teamId] = TeamName;
|
||||||
group.Name = teamName;
|
DataStreamNew.Save();
|
||||||
DataStream.write();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool DeleteTeam()
|
public static bool DeleteTeam()
|
||||||
{
|
{
|
||||||
if (DataStream.dataStream.Groups.Count == 1)
|
if (GroupsData.Data.Keys.Count == 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DataStream.dataStream.Groups.RemoveAt(teamIndex);
|
AccountData.RemoveGroup();
|
||||||
DataStream.write();
|
ChangeTeam(GroupsData.Data.Keys.First());
|
||||||
reloadData(0);
|
DataStreamNew.Save();
|
||||||
MainWindow.Instance.ReloadBtn();
|
MainWindow.Instance.ReloadBtn();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class TeamManager
|
internal static class TeamManager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static int Index2Key(int index) { return GroupsData.Data.ElementAt(index).Key; }
|
||||||
public static string[] GetAllTeamName()
|
public static string[] GetAllTeamName()
|
||||||
{
|
{
|
||||||
string[] names = new string[DataStream.dataStream.Groups.Count];
|
return GroupsData.Data.Values.ToArray();
|
||||||
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 group = new Group { Name = teamName, Accounts = new List<Account> { } };
|
var key = GroupsData.Data.Keys.LastOrDefault() + 1;
|
||||||
DataStream.dataStream.Groups.Add(group);
|
GroupsData.Data.Add(key, teamName);
|
||||||
DataStream.write();
|
DataStreamNew.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
//运行时才能决定是否执行内联
|
//运行时才能决定是否执行内联
|
||||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||||
public static Account? Nick2Acc(string nickName)
|
public static AccountNew? Nick2Acc(string nickName)
|
||||||
{
|
{
|
||||||
// find and return first take
|
return AccountData.Dict.GetValueOrDefault(nickName);
|
||||||
foreach (var group in DataStream.dataStream.Groups)
|
|
||||||
{
|
|
||||||
foreach (var acc in group.Accounts)
|
|
||||||
{
|
|
||||||
if (acc.nickName.Equals(nickName)) return acc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
12
Manager/BusinessManager.cs
Normal file
12
Manager/BusinessManager.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
namespace Zerolauncher.Manager
|
||||||
|
{
|
||||||
|
static class BusinessManager
|
||||||
|
{
|
||||||
|
public static bool checkIsBuy()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,6 +12,7 @@ namespace Zerolauncher.Manager
|
|||||||
public const string MasterMessage = "54aeb77c47b967d22c2c1396d00d91f0";
|
public const string MasterMessage = "54aeb77c47b967d22c2c1396d00d91f0";
|
||||||
public const string SummerMessage = "037846c482eddc948612b0d0f8ed98d5";
|
public const string SummerMessage = "037846c482eddc948612b0d0f8ed98d5";
|
||||||
public const string LoveMessage = "539e3389078daa765ac0abdcc97eebce";
|
public const string LoveMessage = "539e3389078daa765ac0abdcc97eebce";
|
||||||
|
public const string TWMasterMessage = "3ca068a2cdb1ee85fc1152ff6cabefcd";
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpDateData
|
class UpDateData
|
||||||
@ -37,7 +38,7 @@ namespace Zerolauncher.Manager
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.Timeout = TimeSpan.FromMinutes(3);
|
client.Timeout = TimeSpan.FromMinutes(3);
|
||||||
response = await client.GetAsync($"{StaticUrl.QMessageMain}{StaticUrl.MasterMessage}");
|
response = await client.GetAsync($"{StaticUrl.QMessageMain}{StaticUrl.TWMasterMessage}");
|
||||||
}
|
}
|
||||||
catch (Exception _ex)
|
catch (Exception _ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,90 +0,0 @@
|
|||||||
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;
|
|
||||||
public string userName, userPWD, nickName, serverId;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Group
|
|
||||||
{
|
|
||||||
public string Name;
|
|
||||||
public List<Account> Accounts;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Data
|
|
||||||
{
|
|
||||||
public int teamIndex;
|
|
||||||
public List<Group> Groups;
|
|
||||||
public string ecs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
276
Manager/DataStreamNew.cs
Normal file
276
Manager/DataStreamNew.cs
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
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 = 20250228;
|
||||||
|
|
||||||
|
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)]
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||||
private static string AccToKey(Account account)
|
private static string AccToKey(AccountNew 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(Account account)
|
public static bool CreateGame(AccountNew account)
|
||||||
{
|
{
|
||||||
if (UpDateData.is_check == false)
|
if (UpDateData.is_check == false)
|
||||||
{
|
{
|
||||||
MessageBox.Show("正在更新游戏数据,请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning);
|
MessageBox.Show("正在更新游戏数据,请等待1-3秒喵。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (UpDateManager.state)
|
||||||
|
{
|
||||||
|
UpDateManager.DoUpdate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//if (UpDateManager.state)
|
|
||||||
//{
|
|
||||||
// UpDateManager.DoUpdate();
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
var key = AccToKey(account);
|
var key = AccToKey(account);
|
||||||
if (mGame.ContainsKey(key)) { return false; }
|
if (mGame.ContainsKey(key)) { return false; }
|
||||||
if (CacheSha.errorCode != 0) {
|
if (CacheSha.errorCode != 0) {
|
||||||
switch (CacheSha.errorCode)
|
switch (CacheSha.errorCode)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
MessageBox.Show("发生网络错误==EMS。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show("发生网络错误==EMS。\n 请检查网络喵", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
MessageBox.Show("发生游戏服务错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show("发生游戏服务错误==EMS。\n 请联系管理员喵", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员喵", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -59,17 +59,17 @@ namespace Zerolauncher.Manager
|
|||||||
|
|
||||||
public static bool CreateGame(int memberId)
|
public static bool CreateGame(int memberId)
|
||||||
{
|
{
|
||||||
return CreateGame(AccountManager.accountsList[memberId]);
|
return CreateGame(AccountManager.AccountsList[memberId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int CheckGameState(Account account)
|
public static int CheckGameState(AccountNew account)
|
||||||
{
|
{
|
||||||
var key = AccToKey(account);
|
var key = AccToKey(account);
|
||||||
if (mGame.ContainsKey(key)) { return mGame[key].mHandle; }
|
if (mGame.ContainsKey(key)) { return mGame[key].mHandle; }
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short TurnGameSizeMini(Account account)
|
public static short TurnGameSizeMini(AccountNew account)
|
||||||
{
|
{
|
||||||
var key = AccToKey(account);
|
var key = AccToKey(account);
|
||||||
if (mGame.ContainsKey(key))
|
if (mGame.ContainsKey(key))
|
||||||
@ -85,7 +85,7 @@ namespace Zerolauncher.Manager
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short TurnGameSizeNormal(Account account)
|
public static short TurnGameSizeNormal(AccountNew account)
|
||||||
{
|
{
|
||||||
var key = AccToKey(account);
|
var key = AccToKey(account);
|
||||||
if (mGame.ContainsKey(key))
|
if (mGame.ContainsKey(key))
|
||||||
@ -101,7 +101,7 @@ namespace Zerolauncher.Manager
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ExitGame(Account account)
|
public static bool ExitGame(AccountNew account)
|
||||||
{
|
{
|
||||||
var key = AccToKey(account);
|
var key = AccToKey(account);
|
||||||
if (!mGame.ContainsKey(key)) { return false; }
|
if (!mGame.ContainsKey(key)) { return false; }
|
||||||
@ -109,7 +109,7 @@ namespace Zerolauncher.Manager
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnGameExit(Account account)
|
public static void OnGameExit(AccountNew account)
|
||||||
{
|
{
|
||||||
mGame.Remove(AccToKey(account));
|
mGame.Remove(AccToKey(account));
|
||||||
}
|
}
|
||||||
@ -125,10 +125,10 @@ namespace Zerolauncher.Manager
|
|||||||
Process process;
|
Process process;
|
||||||
string? restartUrl;
|
string? restartUrl;
|
||||||
public int mHandle;
|
public int mHandle;
|
||||||
public Account? account;
|
public AccountNew? account;
|
||||||
string gameMode;
|
string gameMode;
|
||||||
|
|
||||||
public SingleGame(Account? acc, string mod = StaticHandleA.GameMode)
|
public SingleGame(AccountNew? acc, string mod = StaticHandleA.GameMode)
|
||||||
{
|
{
|
||||||
restartUrl = null;
|
restartUrl = null;
|
||||||
account = acc;
|
account = acc;
|
||||||
@ -136,6 +136,7 @@ namespace Zerolauncher.Manager
|
|||||||
mHandle = 0;
|
mHandle = 0;
|
||||||
process = EngineShell.CheckEngineSafe(gameMode);
|
process = EngineShell.CheckEngineSafe(gameMode);
|
||||||
process.OutputDataReceived += Handle;
|
process.OutputDataReceived += Handle;
|
||||||
|
process.ErrorDataReceived += Handle;
|
||||||
process.Exited += Process_Exited;
|
process.Exited += Process_Exited;
|
||||||
|
|
||||||
process.Start();
|
process.Start();
|
||||||
@ -154,11 +155,12 @@ namespace Zerolauncher.Manager
|
|||||||
|
|
||||||
private void Process_Exited(object? sender, EventArgs e)
|
private void Process_Exited(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//Trace.WriteLine(
|
if (account == null) return;
|
||||||
// $"Exit time : {process.ExitTime}\n" +
|
Trace.WriteLine(
|
||||||
// $"Exit code : {process.ExitCode}\n" +
|
$"Exit time : {process.ExitTime}\n" +
|
||||||
// $"Elapsed time : {Math.Round((process.ExitTime - process.StartTime).TotalMilliseconds)}");
|
$"Exit code : {process.ExitCode}\n" +
|
||||||
//Trace.WriteLine($"进程已退出:{account.nickName}");
|
$"Elapsed time : {Math.Round((process.ExitTime - process.StartTime).TotalMilliseconds)}");
|
||||||
|
Trace.WriteLine($"进程已退出:{account.nickName}");
|
||||||
if (gameMode != StaticHandleA.GameMode) return;
|
if (gameMode != StaticHandleA.GameMode) return;
|
||||||
if ( restartUrl == null)
|
if ( restartUrl == null)
|
||||||
{
|
{
|
||||||
@ -170,7 +172,6 @@ namespace Zerolauncher.Manager
|
|||||||
|
|
||||||
private void Handle(object sender, DataReceivedEventArgs e)
|
private void Handle(object sender, DataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
Trace.WriteLine($"from client:{e.Data}");
|
|
||||||
var lines = e.Data == null? [""] : e.Data.Split(" ", 2); // 切成两半
|
var lines = e.Data == null? [""] : e.Data.Split(" ", 2); // 切成两半
|
||||||
switch (lines[0])
|
switch (lines[0])
|
||||||
{
|
{
|
||||||
@ -180,7 +181,7 @@ namespace Zerolauncher.Manager
|
|||||||
UpDateManager.DoUpdate1();
|
UpDateManager.DoUpdate1();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.providerId]}-{account.nickName}");
|
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.ProviderId]}-{account.nickName}");
|
||||||
break;
|
break;
|
||||||
case StaticHandleC.StartDone:
|
case StaticHandleC.StartDone:
|
||||||
if (gameMode == StaticHandleA.UpdateMode)
|
if (gameMode == StaticHandleA.UpdateMode)
|
||||||
@ -193,7 +194,7 @@ namespace Zerolauncher.Manager
|
|||||||
Task.Run(async delegate
|
Task.Run(async delegate
|
||||||
{
|
{
|
||||||
if (lines[1] == "True") await Task.Delay(5000);
|
if (lines[1] == "True") await Task.Delay(5000);
|
||||||
_ = LoginManager.DoLogin(this);
|
LoginManager.DoLogin(this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -206,6 +207,7 @@ namespace Zerolauncher.Manager
|
|||||||
mHandle = int.Parse(lines[1]);
|
mHandle = int.Parse(lines[1]);
|
||||||
break;
|
break;
|
||||||
case StaticHandleC.BrowserDone:
|
case StaticHandleC.BrowserDone:
|
||||||
|
Trace.WriteLine($"尝试让游戏退出:{account.nickName}");
|
||||||
restartUrl = lines[1];
|
restartUrl = lines[1];
|
||||||
Send(StaticHandleS.CloseGame);
|
Send(StaticHandleS.CloseGame);
|
||||||
break;
|
break;
|
||||||
@ -215,6 +217,13 @@ namespace Zerolauncher.Manager
|
|||||||
case StaticHandleC.DownloadDone:
|
case StaticHandleC.DownloadDone:
|
||||||
UpDateManager.OnDownLoadDone(lines[1]);
|
UpDateManager.OnDownLoadDone(lines[1]);
|
||||||
break;
|
break;
|
||||||
|
case StaticHandleC.TakeVerify:
|
||||||
|
var args = lines[1].Split(' ');
|
||||||
|
_ = LoginManager.DoVerify(this, args[0], args[1]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Trace.WriteLine($"from client:{e.Data}");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,47 +251,29 @@ namespace Zerolauncher.Manager
|
|||||||
public static Process CheckEngineSafe(string mod)
|
public static Process CheckEngineSafe(string mod)
|
||||||
{
|
{
|
||||||
bool is_first_luancher = EngineManager.CheckEmpy();
|
bool is_first_luancher = EngineManager.CheckEmpy();
|
||||||
//#region 检测代码
|
#region 检测代码
|
||||||
//if (mod == StaticHandleA.UpdateMode)
|
if (mod == StaticHandleA.UpdateMode)
|
||||||
//{
|
{
|
||||||
// if (DataStream.dataStream.ecs.Length > 10)
|
}
|
||||||
// {
|
else if (!is_check && is_first_luancher)
|
||||||
// string? now_bit;
|
{
|
||||||
// using (SHA256 sha256 = SHA256.Create())
|
string? now_bit;
|
||||||
// {
|
using (SHA256 sha256 = SHA256.Create())
|
||||||
// using (FileStream fileStream = File.OpenRead(engine_file))
|
{
|
||||||
// {
|
using (FileStream fileStream = File.OpenRead(engine_file))
|
||||||
// byte[] hashBytes = sha256.ComputeHash(fileStream);
|
{
|
||||||
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||||
// }
|
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||||
// }
|
}
|
||||||
// if (DataStream.dataStream.ecs != now_bit)
|
}
|
||||||
// {
|
if (CacheSha.GetE() != now_bit)
|
||||||
// Trace.WriteLine("lalalala" + DataStream.dataStream.ecs);
|
{
|
||||||
// throw new FileReadException("error esu1!");
|
Trace.WriteLine("lalalala1");
|
||||||
// }
|
throw new FileReadException("error esu0!");
|
||||||
// }
|
}
|
||||||
//}
|
is_check = true;
|
||||||
//else if (!is_check && is_first_luancher)
|
}
|
||||||
//{
|
#endregion
|
||||||
// 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
|
var process = new Process
|
||||||
{
|
{
|
||||||
@ -293,7 +284,8 @@ namespace Zerolauncher.Manager
|
|||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
RedirectStandardInput = true,
|
RedirectStandardInput = true,
|
||||||
RedirectStandardOutput = true
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true
|
||||||
},
|
},
|
||||||
EnableRaisingEvents = true
|
EnableRaisingEvents = true
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics;
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using Zerolauncher.util;
|
||||||
|
|
||||||
namespace Zerolauncher.Manager
|
namespace Zerolauncher.Manager
|
||||||
{
|
{
|
||||||
@ -60,7 +62,7 @@ namespace Zerolauncher.Manager
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task DoLogin(SingleGame game)
|
public static void DoLogin(SingleGame game)
|
||||||
{
|
{
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
client.DefaultRequestVersion = HttpVersion.Version20;
|
client.DefaultRequestVersion = HttpVersion.Version20;
|
||||||
@ -68,133 +70,51 @@ 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");
|
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;
|
string? need_web = null;
|
||||||
client.Timeout = TimeSpan.FromSeconds(3);
|
client.Timeout = TimeSpan.FromSeconds(3);
|
||||||
game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.providerId]}的{game.account.serverId}服");
|
game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.ProviderId]}的{ServicesStaticInfo.ServerNames[game.account.ServerId]}服");
|
||||||
switch (game.account.providerId)
|
switch (game.account.ProviderId)
|
||||||
{
|
{
|
||||||
case 3:
|
|
||||||
case 0:
|
case 0:
|
||||||
need_web = $"http://web.4399.com/stat/togame.php?target={(game.account.providerId == 3? "ddts":"ddt")}&server_id=S{game.account.serverId}";
|
|
||||||
{
|
|
||||||
var values = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "loginFrom", "uframe" },
|
|
||||||
{ "postLoginHandler", "default" },
|
|
||||||
{ "layoutSelfAdapting", "true" },
|
|
||||||
{ "externalLogin", "qq" },
|
|
||||||
{ "displayMode", "popup" },
|
|
||||||
{ "layout", "vertical" },
|
|
||||||
{ "appId", "www_home" },
|
|
||||||
{ "mainDivId", "popup_login_div" },
|
|
||||||
{ "includeFcmInfo", "false" },
|
|
||||||
{ "userNameLabel", "4399用户名" },
|
|
||||||
{ "userNameTip", "请输入4399用户名" },
|
|
||||||
{ "welcomeTip", "欢迎回到4399" },
|
|
||||||
{ "username", game.account.userName },
|
|
||||||
{ "password", game.account.userPWD }
|
|
||||||
};
|
|
||||||
var responseString = await AssetNet(client, game, "http://ptlogin.4399.com/ptlogin/login.do?v=1", new FormUrlEncodedContent(values));
|
|
||||||
// eventHandles.__errorCallback('密码错误');
|
|
||||||
if (responseString == null) break;
|
|
||||||
if (responseString.Contains("eventHandles.__errorCallback"))
|
|
||||||
{
|
|
||||||
game.Send($"{StaticHandleS.HintText} 登录异常:{responseString.Split("eventHandles.__errorCallback('")[1].Split("'")[0]}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!game.Send($"{StaticHandleS.HintText} 登录成功,开始解析iframe")) return;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
var responseString = await AssetNet(client, game, need_web);
|
|
||||||
if (responseString == null) break;
|
|
||||||
if (!responseString.Contains("name=\"game_box\""))
|
|
||||||
{
|
|
||||||
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确");
|
|
||||||
Trace.WriteLine(responseString);
|
|
||||||
if (responseString.Contains("维护")) game.Send($"{StaticHandleS.HintText} 检测到服务器在维护中,请耐心等候官方开服");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
responseString = responseString.Split("name=\"game_box\"")[1].Split("src=\"")[1].Split("\"")[0];
|
|
||||||
HttpResponseMessage response;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
response = await client.PostAsync(responseString, null);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name.Replace(" ", "_")},消息:{ex.Message.Replace(" ", "_")}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
responseString = await response.Content.ReadAsStringAsync();
|
|
||||||
if (game.account.providerId == 3)
|
|
||||||
{
|
|
||||||
responseString = responseString.Split("\"movie\" value='")[1].Split("'", 2)[0];
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
responseString = "http://" + response.RequestMessage.RequestUri.ToString().Split("/")[2] + "/" + responseString.Split("movie\" value='")[1].Split("'")[0];
|
|
||||||
}
|
|
||||||
game.Send($"{StaticHandleS.GameSa} {responseString}");
|
|
||||||
}
|
|
||||||
need_web = null ;
|
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
need_web = $"http://web.7k7k.com/games/togame.php?target=ddt_7&server_id={game.account.serverId}";
|
need_web = "https://www.917play.com.tw/ddt_webserver";
|
||||||
{
|
|
||||||
var values = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "username", game.account.userName },
|
|
||||||
{ "password", game.account.userPWD },
|
|
||||||
{"auto", "1" },
|
|
||||||
{"formtype", "index_log" }
|
|
||||||
};
|
|
||||||
var responseString = await AssetNet(client, game, "https://web.7k7k.com/source/Post.php", new FormUrlEncodedContent(values));
|
|
||||||
if (responseString == null) break;
|
|
||||||
//game.Send($"{StaticHandleS.HintText} {responseString}");
|
|
||||||
JObject jsonObj = JObject.Parse(responseString);
|
|
||||||
game.Send($"{StaticHandleS.HintText} {jsonObj["info"]}");
|
|
||||||
if ((int)jsonObj["status"] != 1) break;
|
|
||||||
if (!game.Send($"{StaticHandleS.HintText} 登录成功,开始解析iframe")) return;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
HttpResponseMessage response;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
response = await client.GetAsync(need_web);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name.Replace(" ", "_")},消息:{ex.Message.Replace(" ", "_")}");
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
|
||||||
if (!responseString.Contains("movie\" value='"))
|
|
||||||
{
|
|
||||||
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确");
|
|
||||||
if (responseString.Contains("维护")) game.Send($"{StaticHandleS.HintText} 检测到服务器在维护中,请耐心等候官方开服");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
responseString = "http://" + response.RequestMessage.RequestUri.ToString().Split("/")[2] + "/" + responseString.Split("movie\" value='")[1].Split("'")[0];
|
|
||||||
//Trace.WriteLine(responseString);
|
|
||||||
game.Send($"{StaticHandleS.GameSa} {responseString}");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
need_web = $"http://www.wan.com/game/play/id/{game.account.serverId}";
|
|
||||||
break;
|
|
||||||
// case 3:
|
|
||||||
//need_web = $"https://web.4399.com/stat/togame.php?target=ddts&server_id=S{game.account.serverId}";
|
|
||||||
// break;
|
|
||||||
default:
|
default:
|
||||||
game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.serverId}");
|
game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.ServerId}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
client.Dispose();
|
client.Dispose();
|
||||||
if (need_web == null) return;
|
if (need_web == null) return;
|
||||||
for (int i = 6; i > 0; i--)
|
//for (int i = 6; i > 0; i--)
|
||||||
{
|
//{
|
||||||
await Task.Delay(1000);
|
// await Task.Delay(1000);
|
||||||
if (!game.Send($"{StaticHandleS.HintText} 自动登录失败,将在{i}后启用网页登录,关闭窗口取消")) { return; }
|
// 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}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task DoVerify(SingleGame game, string vid, string cookie)
|
||||||
|
{
|
||||||
|
var client = new HttpClient();
|
||||||
|
client.Timeout = TimeSpan.FromSeconds(3);
|
||||||
|
client.DefaultRequestHeaders.Add("Cookie", cookie);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await client.GetAsync($"https://www.917play.com.tw/ddt_webserver/verify?{vid}");
|
||||||
|
var bin = response.Content.ReadAsStream();
|
||||||
|
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}");
|
||||||
|
Trace.WriteLine(verify);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Trace.WriteLine($"{StaticHandleS.HintText} 请求验证码时网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||||
}
|
}
|
||||||
game.Send($"{StaticHandleS.UseBrowser} {need_web} {game.account.providerId + 1} {game.account.serverId} {game.account.userName} {game.account.userPWD}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,29 +58,30 @@ namespace Zerolauncher.Manager
|
|||||||
switch (CacheSha.errorCode)
|
switch (CacheSha.errorCode)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
MessageBox.Show("检查更新出错。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show("检查更新出错喵。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
MessageBox.Show("软件已停止服务或服务错误。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show("软件已停止服务或服务错误喵。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MessageBox.Show("检查更新出错。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show("检查更新出错喵。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageBoxResult result = MessageBox.Show($"大厅组件需要更新\n是否更新?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
|
MessageBoxResult result = MessageBox.Show($"大厅组件需要更新\n是否更新?喵", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
|
||||||
if (result == MessageBoxResult.OK)
|
if (result == MessageBoxResult.OK)
|
||||||
{
|
{
|
||||||
try
|
Process.Start(new ProcessStartInfo(UpDateData.lanzou + UpDateData.user_packet_url) { UseShellExecute = true });
|
||||||
{
|
// try
|
||||||
updateProcess = new SingleGame(null, StaticHandleA.UpdateMode);
|
// {
|
||||||
return;
|
// updateProcess = new SingleGame(null, StaticHandleA.UpdateMode);
|
||||||
}
|
// return;
|
||||||
catch (Exception _ex)
|
// }
|
||||||
{
|
// catch (Exception _ex)
|
||||||
MessageBox.Show("执行自动更新失败!,\n请手动访问链接重新下载大厅文件或联系管理员。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
// {
|
||||||
}
|
// MessageBox.Show("执行自动更新失败!,\n请手动访问链接重新下载大厅文件或联系管理员喵。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,23 +4,23 @@ using System.Net;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
namespace Zerolauncher.Manager
|
namespace Zerolauncher.Manager
|
||||||
{
|
{
|
||||||
internal class WebApiManager
|
internal static class WebApiManager
|
||||||
{
|
{
|
||||||
static HttpListener listener = new HttpListener();
|
static readonly HttpListener Listener = new HttpListener();
|
||||||
static CancellationTokenSource cts = new CancellationTokenSource();
|
static readonly CancellationTokenSource Cts = new CancellationTokenSource();
|
||||||
public static async Task StartListener()
|
public static async Task StartListener()
|
||||||
{
|
{
|
||||||
listener.Prefixes.Add("http://127.0.0.1:7233/");
|
Listener.Prefixes.Add("http://127.0.0.1:7233/");
|
||||||
listener.Start();
|
Listener.Start();
|
||||||
Trace.WriteLine("Listening...");
|
Trace.WriteLine("Listening...");
|
||||||
|
|
||||||
while (!cts.Token.IsCancellationRequested)
|
while (!Cts.Token.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
HttpListenerContext context = await listener.GetContextAsync();
|
var context = await Listener.GetContextAsync();
|
||||||
HttpListenerRequest request = context.Request;
|
var request = context.Request;
|
||||||
HttpListenerResponse response = context.Response;
|
var response = context.Response;
|
||||||
var raw = request.RawUrl;
|
var raw = request.RawUrl;
|
||||||
ResponesBody? rb = null;
|
ResponseBody? rb = null;
|
||||||
if (raw != null && raw.Contains("?"))
|
if (raw != null && raw.Contains("?"))
|
||||||
{
|
{
|
||||||
var lines = raw.Split("?");
|
var lines = raw.Split("?");
|
||||||
@ -35,120 +35,78 @@ namespace Zerolauncher.Manager
|
|||||||
{
|
{
|
||||||
case "/CloseGame":
|
case "/CloseGame":
|
||||||
{
|
{
|
||||||
if (EngineManager.ExitGame(acc))
|
rb = EngineManager.ExitGame(acc) ? new ResponseBody(1, 0, $"Account [{nick}] successful to close.") : new ResponseBody($"Account [{nick}] is unluacher.");
|
||||||
{
|
|
||||||
rb = new ResponesBody(1, 0, $"Account [{nick}] successful to close.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "/ToNormalSize":
|
case "/ToNormalSize":
|
||||||
{
|
{
|
||||||
switch (EngineManager.TurnGameSizeNormal(acc))
|
rb = EngineManager.TurnGameSizeNormal(acc) switch
|
||||||
{
|
{
|
||||||
case 2:
|
2 => new ResponseBody(1, 0, $"Account [{nick}] now is normal size."),
|
||||||
rb = new ResponesBody(1, 0, $"Account [{nick}] now is normal size.");
|
1 => new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait."),
|
||||||
break;
|
0 => new ResponseBody($"Account [{nick}] is unluacher."),
|
||||||
case 1:
|
_ => rb
|
||||||
rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
};
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "/ToMiniSize":
|
case "/ToMiniSize":
|
||||||
{
|
{
|
||||||
switch (EngineManager.TurnGameSizeMini(acc))
|
rb = EngineManager.TurnGameSizeMini(acc) switch
|
||||||
{
|
{
|
||||||
case 2:
|
2 => new ResponseBody(1, 0, $"Account [{nick}] now is mini size."),
|
||||||
rb = new ResponesBody(1, 0, $"Account [{nick}] now is mini size.");
|
1 => new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait."),
|
||||||
break;
|
0 => new ResponseBody($"Account [{nick}] is unluacher."),
|
||||||
case 1:
|
_ => rb
|
||||||
rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
};
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "/LoginGame":
|
case "/LoginGame":
|
||||||
{
|
{
|
||||||
if (EngineManager.CreateGame(acc))
|
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
|
else
|
||||||
{
|
{
|
||||||
int hwnd = EngineManager.CheckGameState(acc);
|
var hwnd = EngineManager.CheckGameState(acc);
|
||||||
if (hwnd <= 0)
|
rb = hwnd <= 0 ? new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait.") : new ResponseBody(1, hwnd, $"Account [{nick}] now is running.");
|
||||||
{
|
|
||||||
rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rb = new ResponesBody(1, hwnd, $"Account [{nick}] now is running.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rb = new ResponesBody($"commad [{lines[0]}] undefind.");
|
rb = new ResponseBody($"commad [{lines[0]}] undefind.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rb = new ResponesBody($"Account [{nick}] undefind.");
|
rb = new ResponseBody($"Account [{nick}] undefind.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rb = new ResponesBody("args is missing.");
|
rb = new ResponseBody("args is missing.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (rb == null)
|
rb ??= new ResponseBody();
|
||||||
{
|
var buffer = Encoding.UTF8.GetBytes(rb.Encode());
|
||||||
rb = new ResponesBody();
|
|
||||||
}
|
|
||||||
byte[] buffer = Encoding.UTF8.GetBytes(rb.Encode());
|
|
||||||
|
|
||||||
response.ContentLength64 = buffer.Length;
|
response.ContentLength64 = buffer.Length;
|
||||||
Stream output = response.OutputStream;
|
var output = response.OutputStream;
|
||||||
await output.WriteAsync(buffer, 0, buffer.Length);
|
await output.WriteAsync(buffer, 0, buffer.Length);
|
||||||
output.Close();
|
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 ResponseBody(string message) : this(-1, 0, message)
|
||||||
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()
|
public string Encode()
|
||||||
|
|||||||
@ -2,7 +2,9 @@
|
|||||||
{
|
{
|
||||||
class ServicesStaticInfo
|
class ServicesStaticInfo
|
||||||
{
|
{
|
||||||
public static string[] ServicesName = ["4399大区", "7k7k大区", "第七大道", "4399经典"];
|
public static string[] ServicesName = ["61平台"];
|
||||||
public static string[] ServicesShortName = ["43", "7k", "7d", "典"];
|
public static string[] ServicesShortName = ["61"];
|
||||||
|
public static string[] ServerNames = ["請選擇伺服器", "星之城", "夢之船(合併)", "謎之峽(合併)", "喵之影(合併)", "龍之吼"];
|
||||||
|
public static int[] ServerIds = [ 0, 1, 2, 34, 38, 44 ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
<ApplicationIcon>res\title.ico</ApplicationIcon>
|
<ApplicationIcon>res\title.ico</ApplicationIcon>
|
||||||
<Obfuscate>true</Obfuscate>
|
<Obfuscate>true</Obfuscate>
|
||||||
<ConfuserReplaceOutput>true</ConfuserReplaceOutput>
|
<ConfuserReplaceOutput>true</ConfuserReplaceOutput>
|
||||||
|
<StartupObject>Zerolauncher.App</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
@ -46,7 +47,10 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Downloader" Version="3.0.6" />
|
<PackageReference Include="Downloader" Version="3.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.17.3" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.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>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -64,6 +68,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Update="plugin\model.bin">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="ZeroEngine.exe">
|
<None Update="ZeroEngine.exe">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
200
clean_up_code.patch
Normal file
200
clean_up_code.patch
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
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,10 +5,9 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="75" d:DesignWidth="65" Margin="5">
|
d:DesignHeight="75" d:DesignWidth="65" Margin="5">
|
||||||
<Grid>
|
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<Image Name="icon" DockPanel.Dock="Top" Source="/res/player_ico1.png" Width="60" Height="60"/>
|
<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"/>
|
<Label Name="text" DockPanel.Dock="Bottom" Content="43-测试账号" FontSize="9" Padding="0" Width="65"/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@ -27,35 +27,17 @@
|
|||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</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"/>
|
<Image Grid.Column="1" Grid.RowSpan="2" Source="/res/player_ico1.png"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<DockPanel Grid.ColumnSpan="1" Margin="2">
|
<DockPanel Grid.ColumnSpan="1" Margin="2">
|
||||||
<Label Content="运营商:" Foreground="White"/>
|
<Label Content="运营商:" Foreground="White"/>
|
||||||
<ComboBox Name="cb_pid"/>
|
<ComboBox Name="cb_pid"/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<TextBox Name="edit_sid" Grid.Row="1" Margin="10,3,50,3" SelectionTextBrush="#4CFFFFFF">
|
<DockPanel Grid.Row="1" Margin="2">
|
||||||
<TextBox.Resources>
|
<Label Content="服务器:" Foreground="White"/>
|
||||||
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.7" Stretch="None" AlignmentX="Left">
|
<ComboBox Name="cb_sid"/>
|
||||||
<VisualBrush.Visual>
|
</DockPanel>
|
||||||
<TextBlock FontStyle="Italic" Text="请输入区服" Foreground="Cyan"/>
|
|
||||||
</VisualBrush.Visual>
|
|
||||||
</VisualBrush>
|
|
||||||
</TextBox.Resources>
|
|
||||||
<TextBox.Style>
|
|
||||||
<Style TargetType="TextBox">
|
|
||||||
<Style.Triggers>
|
|
||||||
<Trigger Property="Text" Value="{x:Null}">
|
|
||||||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/>
|
|
||||||
</Trigger>
|
|
||||||
<Trigger Property="Text" Value="">
|
|
||||||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/>
|
|
||||||
</Trigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
</TextBox.Style>
|
|
||||||
</TextBox>
|
|
||||||
<TextBox Name="edit_acc" Grid.Row="2" Grid.ColumnSpan="2" Margin="10,2,50,2" SelectionTextBrush="#07FFFFFF">
|
<TextBox Name="edit_acc" Grid.Row="2" Grid.ColumnSpan="2" Margin="10,2,50,2" SelectionTextBrush="#07FFFFFF">
|
||||||
<TextBox.Resources>
|
<TextBox.Resources>
|
||||||
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.7" Stretch="None" AlignmentX="Left">
|
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.7" Stretch="None" AlignmentX="Left">
|
||||||
|
|||||||
@ -23,25 +23,22 @@ namespace Zerolauncher.dialog
|
|||||||
}
|
}
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
cb_pid.ItemsSource = _services;
|
cb_pid.ItemsSource = _services;
|
||||||
if(EditMemberDialog.member != null)
|
cb_sid.ItemsSource = ServicesStaticInfo.ServerNames;
|
||||||
|
|
||||||
|
if (EditMemberDialog.member != null)
|
||||||
{
|
{
|
||||||
int index = (int)EditMemberDialog.member;
|
int index = (int)EditMemberDialog.member;
|
||||||
var acc = AccountManager.accountsList[index];
|
var acc = AccountManager.AccountsList[index];
|
||||||
cb_pid.SelectedIndex = acc.providerId;
|
cb_pid.SelectedIndex = acc.ProviderId;
|
||||||
edit_sid.Text = acc.serverId;
|
cb_sid.SelectedIndex = acc.ServerId;
|
||||||
edit_acc.Text = acc.userName;
|
edit_acc.Text = acc.userName;
|
||||||
edit_pwd.Password = acc.userPWD;
|
edit_pwd.Password = acc.userPWD;
|
||||||
edit_nick.Text = acc.nickName;
|
edit_nick.Text = acc.nickName;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
// 私服用
|
|
||||||
if (ServicesStaticInfo.ServicesName.Length == 1)
|
|
||||||
{
|
|
||||||
cb_pid.SelectedIndex = 0;
|
cb_pid.SelectedIndex = 0;
|
||||||
edit_sid.Text = "1";
|
|
||||||
cb_pid.IsEditable = false;
|
cb_pid.IsEditable = false;
|
||||||
edit_sid.IsEnabled = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
||||||
@ -60,30 +57,29 @@ namespace Zerolauncher.dialog
|
|||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(cb_pid.Text) || string.IsNullOrEmpty(edit_sid.Text) || string.IsNullOrEmpty(edit_acc.Text) || string.IsNullOrEmpty(edit_pwd.Password) || string.IsNullOrEmpty(edit_nick.Text))
|
if (string.IsNullOrEmpty(cb_pid.Text) || cb_sid.SelectedIndex == 0 || string.IsNullOrEmpty(edit_acc.Text) || string.IsNullOrEmpty(edit_pwd.Password) || string.IsNullOrEmpty(edit_nick.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("所有选项均不能为空!", "提示");
|
MessageBox.Show("所有选项均不能为空!", "提示");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (EditMemberDialog.member == null)
|
if (EditMemberDialog.member == null)
|
||||||
{
|
{
|
||||||
AccountManager.AddAccount(new Account { providerId = cb_pid.SelectedIndex, serverId = edit_sid.Text, userName = edit_acc.Text, userPWD = edit_pwd.Password, nickName = edit_nick.Text });
|
AccountManager.AddAccount(new AccountNew { ProviderId = cb_pid.SelectedIndex, ServerId = cb_sid.SelectedIndex, userName = edit_acc.Text, userPWD = edit_pwd.Password, nickName = edit_nick.Text });
|
||||||
|
|
||||||
EditMemberDialog.Close();
|
EditMemberDialog.Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int index = (int)EditMemberDialog.member;
|
int index = (int)EditMemberDialog.member;
|
||||||
var acc = AccountManager.accountsList[index];
|
var acc = AccountManager.AccountsList[index];
|
||||||
acc.providerId = cb_pid.SelectedIndex;
|
acc.ProviderId = cb_pid.SelectedIndex;
|
||||||
acc.serverId = edit_sid.Text;
|
acc.ServerId = cb_sid.SelectedIndex;
|
||||||
acc.userName = edit_acc.Text;
|
acc.userName = edit_acc.Text;
|
||||||
acc.userPWD = edit_pwd.Password;
|
acc.userPWD = edit_pwd.Password;
|
||||||
acc.nickName = edit_nick.Text;
|
acc.nickName = edit_nick.Text;
|
||||||
AccountManager.saveEdit();
|
AccountManager.SaveEdit();
|
||||||
EditMemberDialog.Close();
|
EditMemberDialog.Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,19 +22,22 @@ namespace Zerolauncher.dialog
|
|||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(edit_name.Text))
|
if(string.IsNullOrEmpty(edit_name.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("昵称不能为空!", "提示");
|
MessageBox.Show("昵称不能为空喵!", "提示");
|
||||||
return;
|
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();
|
EditTeamDialog.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
MessageBoxResult result = MessageBox.Show("即将放生此队伍以及队伍里所有的账号\n将会为你带来114点功德\n您确定要执行此操作吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
|
MessageBoxResult result = MessageBox.Show("放生此队伍以及队伍里所有的账号\n为你带来114514点功德\n要执行此操作喵?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
|
||||||
if (result == MessageBoxResult.OK)
|
if (result == MessageBoxResult.OK)
|
||||||
{
|
{
|
||||||
if (!AccountManager.DeleteTeam()) MessageBox.Show("少爷这已经是最后一个队伍了!\n请新建一个队伍后再放生这个吧~", "提示");
|
if (!AccountManager.DeleteTeam())
|
||||||
|
{
|
||||||
|
MessageBox.Show("已经是最后一个队伍了喵!\n新建一个队伍后再放生这个~", "提示");
|
||||||
|
}
|
||||||
else EditTeamDialog.Close();
|
else EditTeamDialog.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
60
dialog/RegDialog.xaml
Normal file
60
dialog/RegDialog.xaml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<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>
|
||||||
94
dialog/RegDialog.xaml.cs
Normal file
94
dialog/RegDialog.xaml.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
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"/>
|
<TextBlock DockPanel.Dock="Top" Margin="5" Text="文本格式:一行一个账号,如:
 服务器---区号---账号---密码---备注
服务器填代号:
 如[0, 4399大区]意味着4399大区的代号是0,
 具体查看添加账号时,以列表显示的为准" Foreground="#FFB44242"/>
|
||||||
<DockPanel DockPanel.Dock="Bottom">
|
<DockPanel DockPanel.Dock="Bottom">
|
||||||
<Button DockPanel.Dock="Right" Content="选择文件" Click="Button_Click"/>
|
<Button DockPanel.Dock="Right" Content="选择文件" Click="Button_Click"/>
|
||||||
<TextBox Name="input_split" DockPanel.Dock="Right" Text="---" Width="100"/>
|
<TextBox Name="InputSplit" DockPanel.Dock="Right" Text="---" Width="100"/>
|
||||||
<TextBlock DockPanel.Dock="Right" Text="分隔符:" Foreground="#FFEE9595"/>
|
<TextBlock DockPanel.Dock="Right" Text="分隔符:" Foreground="#FFEE9595"/>
|
||||||
<Label/>
|
<Label/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
|
||||||
using Zerolauncher.Manager;
|
using Zerolauncher.Manager;
|
||||||
|
|
||||||
namespace Zerolauncher.dialog
|
namespace Zerolauncher.dialog
|
||||||
@ -10,7 +9,7 @@ namespace Zerolauncher.dialog
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// UseAccDataTextAdd.xaml 的交互逻辑
|
/// UseAccDataTextAdd.xaml 的交互逻辑
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class UseAccDataTextAdd : UserControl
|
public partial class UseAccDataTextAdd
|
||||||
{
|
{
|
||||||
public UseAccDataTextAdd()
|
public UseAccDataTextAdd()
|
||||||
{
|
{
|
||||||
@ -20,45 +19,55 @@ namespace Zerolauncher.dialog
|
|||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
//创建一个打开文件式的对话框
|
//创建一个打开文件式的对话框
|
||||||
OpenFileDialog ofd = new OpenFileDialog();
|
var ofd = new OpenFileDialog
|
||||||
|
{
|
||||||
//设置这个对话框的起始打开路径
|
//设置这个对话框的起始打开路径
|
||||||
ofd.InitialDirectory = @"C:\";
|
InitialDirectory = @"C:\",
|
||||||
//设置打开的文件的类型,注意过滤器的语法
|
//设置打开的文件的类型,注意过滤器的语法
|
||||||
ofd.Filter = "账号文本|*.txt|其他格式|*.";
|
Filter = "账号文本|*.txt|其他格式|*."
|
||||||
|
};
|
||||||
//调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
|
//调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
|
||||||
if (ofd.ShowDialog() == true)
|
if (ofd.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
string[] lines = File.ReadAllLines(ofd.FileName, Encoding.UTF8);
|
var lines = File.ReadAllLines(ofd.FileName, Encoding.UTF8);
|
||||||
for (int i = 0; i < lines.Length; i++)
|
for (var i = 0; i < lines.Length; i++)
|
||||||
{
|
{
|
||||||
var accTexts = lines[i].Split(input_split.Text);
|
var accTexts = lines[i].Split(InputSplit.Text);
|
||||||
if (accTexts.Length != 5)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
var acc = new Account { };
|
var acc = new AccountNew { };
|
||||||
if (!int.TryParse(accTexts[0], out acc.providerId))
|
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;
|
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);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
acc.serverId = accTexts[1];
|
|
||||||
acc.userName = accTexts[2];
|
acc.userName = accTexts[2];
|
||||||
acc.userPWD = accTexts[3];
|
acc.userPWD = accTexts[3];
|
||||||
acc.nickName = accTexts[4];
|
acc.nickName = accTexts[4];
|
||||||
if (!AccountManager.AddAccounts(acc))
|
if (AccountManager.AddAccounts(acc)) continue;
|
||||||
{
|
MessageBox.Show($"文本在{i}行出错喵!\n警告:[{acc.nickName}]昵称冲突,将跳过添加此账号", "Warring", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
MessageBox.Show($"文本在{i}行出错!\n警告:[{acc.nickName}]昵称冲突,将跳过添加此账号", "Warring", MessageBoxButton.OK, MessageBoxImage.Error);
|
return;
|
||||||
}
|
}
|
||||||
}
|
MessageBox.Show("添加完成喵!", "提示");
|
||||||
MessageBox.Show("添加完成!", "提示");
|
AccountManager.SaveEdit();
|
||||||
AccountManager.saveEdit();
|
|
||||||
AddMemebersDialog.Close();
|
AddMemebersDialog.Close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
BIN
res/captcha.jpg
Normal file
BIN
res/captcha.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
99
util/OnnxManager.cs
Normal file
99
util/OnnxManager.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using Microsoft.ML.OnnxRuntime.Tensors;
|
||||||
|
using Microsoft.ML.OnnxRuntime;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace Zerolauncher.util
|
||||||
|
{
|
||||||
|
public class OnnxManager
|
||||||
|
{
|
||||||
|
public static OnnxVerify? onnxVerify;
|
||||||
|
}
|
||||||
|
public class OnnxVerify
|
||||||
|
{
|
||||||
|
private string _modelPath;
|
||||||
|
private InferenceSession _session;
|
||||||
|
private readonly string _inputName;
|
||||||
|
static string[] labels = [
|
||||||
|
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
||||||
|
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
|
||||||
|
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
||||||
|
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
||||||
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
|
||||||
|
];
|
||||||
|
|
||||||
|
public OnnxVerify(string modelPath = "plugin/model.bin")
|
||||||
|
{
|
||||||
|
_modelPath = modelPath;
|
||||||
|
_session = new InferenceSession(_modelPath);
|
||||||
|
// 获取模型的输入节点名称
|
||||||
|
_inputName = _session.InputMetadata.Keys.First();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string RunInference(Bitmap image)
|
||||||
|
{
|
||||||
|
var tensor = CtcPreprocess(image, (3, 48, 320));
|
||||||
|
var inputs = new List<NamedOnnxValue> { NamedOnnxValue.CreateFromTensor(_inputName, tensor) };
|
||||||
|
using var results = _session.Run(inputs);
|
||||||
|
|
||||||
|
var outputs = results.First().AsTensor<float>();
|
||||||
|
var dimensions = outputs.Dimensions;
|
||||||
|
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
float tmp; int tmp_index, last_index = -1;
|
||||||
|
for (int j = 0; j < dimensions[1]; j++)
|
||||||
|
{
|
||||||
|
tmp = 0; tmp_index = 0;
|
||||||
|
for (int k = 0; k < dimensions[2]; k++)
|
||||||
|
{
|
||||||
|
var tmp1 = outputs[0, j, k];
|
||||||
|
if (tmp < tmp1) { tmp = tmp1; tmp_index = k; }
|
||||||
|
}
|
||||||
|
if (tmp_index == 0 || last_index == tmp_index)
|
||||||
|
{
|
||||||
|
// 试着过滤一下重复的字符,假设最大重复长度为2
|
||||||
|
last_index = -1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
last_index = tmp_index;
|
||||||
|
sb.Append(labels[tmp_index - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static DenseTensor<float> CtcPreprocess(Bitmap image, (int, int, int) recImageShape)
|
||||||
|
{
|
||||||
|
var (imgC, imgH, imgW) = recImageShape;
|
||||||
|
var maxWhRatio = imgW / (float)imgH;
|
||||||
|
var h = image.Height;
|
||||||
|
var w = image.Width;
|
||||||
|
var whRatio = w * 1.0f / h;
|
||||||
|
maxWhRatio = Math.Max(maxWhRatio, whRatio);
|
||||||
|
|
||||||
|
Debug.Assert(imgC == 3); // Assuming the image is in RGB format
|
||||||
|
|
||||||
|
imgW = (int)(imgH * maxWhRatio);
|
||||||
|
var ratio = w / (float)h;
|
||||||
|
var resizedW = Math.Ceiling(imgH * ratio) > imgW ? imgW : (int)Math.Ceiling(imgH * ratio);
|
||||||
|
|
||||||
|
var resizedImage = new Bitmap(image, new Size(resizedW, imgH));
|
||||||
|
var paddingIm = new DenseTensor<float>([1, imgC, imgH, imgW]);
|
||||||
|
for (int i = 0; i < resizedW; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < imgH; j++)
|
||||||
|
{
|
||||||
|
var pixel = resizedImage.GetPixel(i, j);
|
||||||
|
paddingIm[0, 0, j, i] = (pixel.R / 255.0f - 0.5f) / 0.5f;
|
||||||
|
paddingIm[0, 1, j, i] = (pixel.G / 255.0f - 0.5f) / 0.5f;
|
||||||
|
paddingIm[0, 2, j, i] = (pixel.B / 255.0f - 0.5f) / 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return paddingIm;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -83,4 +83,109 @@ namespace Zerolauncher.util
|
|||||||
return sb.ToString();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
util/SyStemExcuteCommand.cs
Normal file
9
util/SyStemExcuteCommand.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
namespace Zerolauncher.util
|
||||||
|
{
|
||||||
|
static class SyStemExcuteCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user