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)
|
||||
{
|
||||
MessageBox.Show("已拷贝到粘贴板", "提示");
|
||||
MessageBox.Show("已拷贝到粘贴板呢喵", "提示");
|
||||
Clipboard.SetDataObject("ddfgame@foxmail.com", true);
|
||||
}
|
||||
|
||||
|
||||
@ -82,9 +82,9 @@ namespace Zerolauncher
|
||||
for (int i = 0; i < 3 && !TryDeleteDirectory(@"./cache", true); i++) await Task.Delay(3000);
|
||||
}
|
||||
});
|
||||
DataStream.Load();
|
||||
DataStreamNew.Load();
|
||||
_ = WebApiManager.StartListener();
|
||||
AccountManager.initLoadData();
|
||||
AccountManager.InitLoadData();
|
||||
}
|
||||
|
||||
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();
|
||||
int i = 0;
|
||||
foreach (var account in AccountManager.accountsList)
|
||||
foreach (var account in AccountManager.AccountsList)
|
||||
{
|
||||
var member = new MemberControl();
|
||||
member.memberId = i++;
|
||||
member.text.Content = ServicesStaticInfo.ServicesShortName[account.providerId] + "-" + account.nickName;
|
||||
member.text.Content = ServicesStaticInfo.ServicesShortName[account.ProviderId] + "-" + account.nickName;
|
||||
mLayout.Children.Add(member);
|
||||
}
|
||||
if (i ==0)
|
||||
{
|
||||
EditMemberDialog.CreateDailog(null);
|
||||
MessageBox.Show("下次右键账号和窗口空白处可以打菜单喵", "小提示");
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadBtn()
|
||||
@ -43,11 +48,11 @@ namespace Zerolauncher
|
||||
//foreach (var btn in mLayout.Children.)
|
||||
mLayout.Children.Clear();
|
||||
int i = 0;
|
||||
foreach (var account in AccountManager.accountsList)
|
||||
foreach (var account in AccountManager.AccountsList)
|
||||
{
|
||||
var member = new MemberControl();
|
||||
member.memberId = i++;
|
||||
member.text.Content = ServicesStaticInfo.ServicesShortName[account.providerId] + "-" + account.nickName;
|
||||
member.text.Content = ServicesStaticInfo.ServicesShortName[account.ProviderId] + "-" + account.nickName;
|
||||
mLayout.Children.Add(member);
|
||||
}
|
||||
}
|
||||
@ -92,7 +97,7 @@ namespace Zerolauncher
|
||||
MenuItem menuItem = sender as MenuItem;
|
||||
int i = (int)menuItem.Tag;
|
||||
Trace.WriteLine("Clicked item index: " + i);
|
||||
AccountManager.reloadData(i);
|
||||
AccountManager.ChangeTeam(i);
|
||||
ReloadBtn();
|
||||
};
|
||||
changeTeamItem.Items.Add(menuItem);
|
||||
@ -119,7 +124,7 @@ namespace Zerolauncher
|
||||
|
||||
private void editTeamItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EditTeamDialog.CreateDailog(AccountManager.teamName);
|
||||
EditTeamDialog.CreateDailog(AccountManager.TeamName);
|
||||
}
|
||||
|
||||
private void Button_Click_3(object sender, RoutedEventArgs e)
|
||||
|
||||
@ -1,155 +1,132 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Input;
|
||||
|
||||
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;
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
teamName = group.Name;
|
||||
foreach (var acc in group.Accounts)
|
||||
_teamId = AccountData.TeamIndex;
|
||||
foreach (var pair in GroupsData.Data)
|
||||
{
|
||||
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;
|
||||
var group = DataStream.dataStream.Groups[index];
|
||||
if (teamIndex!=index)
|
||||
{
|
||||
teamIndex = index;
|
||||
teamName = group.Name;
|
||||
DataStream.dataStream.teamIndex = index;
|
||||
DataStream.write();
|
||||
}
|
||||
accountsList.Clear();
|
||||
foreach (var acc in group.Accounts)
|
||||
{
|
||||
accountsList.Add(acc);
|
||||
}
|
||||
_teamId = TeamManager.Index2Key(index);
|
||||
AccountData.TeamIndex = _teamId;
|
||||
TeamName = GroupsData.Data[_teamId];
|
||||
if (!AccountData.Data.ContainsKey(_teamId))
|
||||
AccountData.Data.Add(_teamId, []);
|
||||
AccountsList = AccountData.Data[_teamId];
|
||||
DataStreamNew.Save();
|
||||
}
|
||||
|
||||
public static void saveEdit()
|
||||
public static void SaveEdit()
|
||||
{
|
||||
DataStream.write();
|
||||
DataStreamNew.Save();
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
}
|
||||
|
||||
public static bool AddAccount(Account account)
|
||||
public static bool AddAccount(AccountNew account)
|
||||
{
|
||||
if (TeamManager.Nick2Acc(account.nickName) != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Accounts.Add(account);
|
||||
account.GroupId = _teamId;
|
||||
AccountData.AddAccount(account);
|
||||
|
||||
accountsList.Add(account);
|
||||
DataStream.write();
|
||||
DataStreamNew.Save();
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool AddAccounts(Account account)
|
||||
public static bool AddAccounts(AccountNew account)
|
||||
{
|
||||
if (TeamManager.Nick2Acc(account.nickName) != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Accounts.Add(account);
|
||||
|
||||
accountsList.Add(account);
|
||||
//DataStream.write(); 不写
|
||||
//MainWindow.Instance.ReloadBtn(); 不更新
|
||||
account.GroupId = _teamId;
|
||||
AccountData.AddAccount(account);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void MoveAccount(int memberId, int newIndex)
|
||||
{
|
||||
var group1 = DataStream.dataStream.Groups[newIndex];
|
||||
group1.Accounts.Add(accountsList[memberId]);
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Accounts.RemoveAt(memberId);
|
||||
DataStream.write();
|
||||
reloadData();
|
||||
var groupId = TeamManager.Index2Key(newIndex);
|
||||
if (AccountsList != null)
|
||||
{
|
||||
var acc = AccountsList[memberId];
|
||||
AccountsList.RemoveAt(memberId);
|
||||
if (!AccountData.CheckGroup(groupId)) return;
|
||||
AccountData.Data[groupId].Add(acc);
|
||||
}
|
||||
|
||||
DataStreamNew.Save();
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
}
|
||||
|
||||
public static void DeleteAccount(int index) {
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Accounts.RemoveAt(index);
|
||||
DataStream.write();
|
||||
reloadData();
|
||||
if (AccountsList != null)
|
||||
{
|
||||
var nick = AccountsList[index].nickName;
|
||||
AccountsList.RemoveAt(index);
|
||||
AccountData.Dict.Remove(nick);
|
||||
}
|
||||
|
||||
DataStreamNew.Save();
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
}
|
||||
|
||||
public static void editTeamName(string teamName0)
|
||||
public static void EditTeamName(string teamName0)
|
||||
{
|
||||
teamName = teamName0;
|
||||
var group = DataStream.dataStream.Groups[teamIndex];
|
||||
group.Name = teamName;
|
||||
DataStream.write();
|
||||
TeamName = teamName0;
|
||||
GroupsData.Data[_teamId] = TeamName;
|
||||
DataStreamNew.Save();
|
||||
}
|
||||
|
||||
public static bool DeleteTeam()
|
||||
{
|
||||
if (DataStream.dataStream.Groups.Count == 1)
|
||||
if (GroupsData.Data.Keys.Count == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
DataStream.dataStream.Groups.RemoveAt(teamIndex);
|
||||
DataStream.write();
|
||||
reloadData(0);
|
||||
AccountData.RemoveGroup();
|
||||
ChangeTeam(GroupsData.Data.Keys.First());
|
||||
DataStreamNew.Save();
|
||||
MainWindow.Instance.ReloadBtn();
|
||||
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()
|
||||
{
|
||||
string[] names = new string[DataStream.dataStream.Groups.Count];
|
||||
int i = 0;
|
||||
foreach (var group in DataStream.dataStream.Groups)
|
||||
{
|
||||
names[i++] = group.Name;
|
||||
}
|
||||
return names;
|
||||
return GroupsData.Data.Values.ToArray();
|
||||
}
|
||||
|
||||
public static void addTeam(string teamName)
|
||||
public static void AddTeam(string teamName)
|
||||
{
|
||||
var group = new Group { Name = teamName, Accounts = new List<Account> { } };
|
||||
DataStream.dataStream.Groups.Add(group);
|
||||
DataStream.write();
|
||||
var key = GroupsData.Data.Keys.LastOrDefault() + 1;
|
||||
GroupsData.Data.Add(key, teamName);
|
||||
DataStreamNew.Save();
|
||||
}
|
||||
|
||||
//运行时才能决定是否执行内联
|
||||
[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
|
||||
foreach (var group in DataStream.dataStream.Groups)
|
||||
{
|
||||
foreach (var acc in group.Accounts)
|
||||
{
|
||||
if (acc.nickName.Equals(nickName)) return acc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return AccountData.Dict.GetValueOrDefault(nickName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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 SummerMessage = "037846c482eddc948612b0d0f8ed98d5";
|
||||
public const string LoveMessage = "539e3389078daa765ac0abdcc97eebce";
|
||||
public const string TWMasterMessage = "3ca068a2cdb1ee85fc1152ff6cabefcd";
|
||||
}
|
||||
|
||||
class UpDateData
|
||||
@ -37,7 +38,7 @@ namespace Zerolauncher.Manager
|
||||
try
|
||||
{
|
||||
client.Timeout = TimeSpan.FromMinutes(3);
|
||||
response = await client.GetAsync($"{StaticUrl.QMessageMain}{StaticUrl.MasterMessage}");
|
||||
response = await client.GetAsync($"{StaticUrl.QMessageMain}{StaticUrl.TWMasterMessage}");
|
||||
}
|
||||
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)]
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
//if (UpDateManager.state)
|
||||
//{
|
||||
// UpDateManager.DoUpdate();
|
||||
// return true;
|
||||
//}
|
||||
var key = AccToKey(account);
|
||||
if (mGame.ContainsKey(key)) { return false; }
|
||||
if (CacheSha.errorCode != 0) {
|
||||
switch (CacheSha.errorCode)
|
||||
{
|
||||
case 1:
|
||||
MessageBox.Show("发生网络错误==EMS。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("发生网络错误==EMS。\n 请检查网络喵", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
case 2:
|
||||
MessageBox.Show("发生游戏服务错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("发生游戏服务错误==EMS。\n 请联系管理员喵", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
default:
|
||||
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员喵", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@ -59,17 +59,17 @@ namespace Zerolauncher.Manager
|
||||
|
||||
public static bool CreateGame(int memberId)
|
||||
{
|
||||
return CreateGame(AccountManager.accountsList[memberId]);
|
||||
return CreateGame(AccountManager.AccountsList[memberId]);
|
||||
}
|
||||
|
||||
public static int CheckGameState(Account account)
|
||||
public static int CheckGameState(AccountNew account)
|
||||
{
|
||||
var key = AccToKey(account);
|
||||
if (mGame.ContainsKey(key)) { return mGame[key].mHandle; }
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static short TurnGameSizeMini(Account account)
|
||||
public static short TurnGameSizeMini(AccountNew account)
|
||||
{
|
||||
var key = AccToKey(account);
|
||||
if (mGame.ContainsKey(key))
|
||||
@ -85,7 +85,7 @@ namespace Zerolauncher.Manager
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static short TurnGameSizeNormal(Account account)
|
||||
public static short TurnGameSizeNormal(AccountNew account)
|
||||
{
|
||||
var key = AccToKey(account);
|
||||
if (mGame.ContainsKey(key))
|
||||
@ -101,7 +101,7 @@ namespace Zerolauncher.Manager
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static bool ExitGame(Account account)
|
||||
public static bool ExitGame(AccountNew account)
|
||||
{
|
||||
var key = AccToKey(account);
|
||||
if (!mGame.ContainsKey(key)) { return false; }
|
||||
@ -109,7 +109,7 @@ namespace Zerolauncher.Manager
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void OnGameExit(Account account)
|
||||
public static void OnGameExit(AccountNew account)
|
||||
{
|
||||
mGame.Remove(AccToKey(account));
|
||||
}
|
||||
@ -125,10 +125,10 @@ namespace Zerolauncher.Manager
|
||||
Process process;
|
||||
string? restartUrl;
|
||||
public int mHandle;
|
||||
public Account? account;
|
||||
public AccountNew? account;
|
||||
string gameMode;
|
||||
|
||||
public SingleGame(Account? acc, string mod = StaticHandleA.GameMode)
|
||||
public SingleGame(AccountNew? acc, string mod = StaticHandleA.GameMode)
|
||||
{
|
||||
restartUrl = null;
|
||||
account = acc;
|
||||
@ -136,6 +136,7 @@ namespace Zerolauncher.Manager
|
||||
mHandle = 0;
|
||||
process = EngineShell.CheckEngineSafe(gameMode);
|
||||
process.OutputDataReceived += Handle;
|
||||
process.ErrorDataReceived += Handle;
|
||||
process.Exited += Process_Exited;
|
||||
|
||||
process.Start();
|
||||
@ -154,11 +155,12 @@ namespace Zerolauncher.Manager
|
||||
|
||||
private void Process_Exited(object? sender, EventArgs e)
|
||||
{
|
||||
//Trace.WriteLine(
|
||||
// $"Exit time : {process.ExitTime}\n" +
|
||||
// $"Exit code : {process.ExitCode}\n" +
|
||||
// $"Elapsed time : {Math.Round((process.ExitTime - process.StartTime).TotalMilliseconds)}");
|
||||
//Trace.WriteLine($"进程已退出:{account.nickName}");
|
||||
if (account == null) return;
|
||||
Trace.WriteLine(
|
||||
$"Exit time : {process.ExitTime}\n" +
|
||||
$"Exit code : {process.ExitCode}\n" +
|
||||
$"Elapsed time : {Math.Round((process.ExitTime - process.StartTime).TotalMilliseconds)}");
|
||||
Trace.WriteLine($"进程已退出:{account.nickName}");
|
||||
if (gameMode != StaticHandleA.GameMode) return;
|
||||
if ( restartUrl == null)
|
||||
{
|
||||
@ -179,7 +181,7 @@ namespace Zerolauncher.Manager
|
||||
UpDateManager.DoUpdate1();
|
||||
return;
|
||||
}
|
||||
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.providerId]}-{account.nickName}");
|
||||
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.ProviderId]}-{account.nickName}");
|
||||
break;
|
||||
case StaticHandleC.StartDone:
|
||||
if (gameMode == StaticHandleA.UpdateMode)
|
||||
@ -192,7 +194,7 @@ namespace Zerolauncher.Manager
|
||||
Task.Run(async delegate
|
||||
{
|
||||
if (lines[1] == "True") await Task.Delay(5000);
|
||||
_ = LoginManager.DoLogin(this);
|
||||
LoginManager.DoLogin(this);
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -205,6 +207,7 @@ namespace Zerolauncher.Manager
|
||||
mHandle = int.Parse(lines[1]);
|
||||
break;
|
||||
case StaticHandleC.BrowserDone:
|
||||
Trace.WriteLine($"尝试让游戏退出:{account.nickName}");
|
||||
restartUrl = lines[1];
|
||||
Send(StaticHandleS.CloseGame);
|
||||
break;
|
||||
@ -214,6 +217,13 @@ namespace Zerolauncher.Manager
|
||||
case StaticHandleC.DownloadDone:
|
||||
UpDateManager.OnDownLoadDone(lines[1]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,47 +251,29 @@ namespace Zerolauncher.Manager
|
||||
public static Process CheckEngineSafe(string mod)
|
||||
{
|
||||
bool is_first_luancher = EngineManager.CheckEmpy();
|
||||
//#region 检测代码
|
||||
//if (mod == StaticHandleA.UpdateMode)
|
||||
//{
|
||||
// if (DataStream.dataStream.ecs.Length > 10)
|
||||
// {
|
||||
// string? now_bit;
|
||||
// using (SHA256 sha256 = SHA256.Create())
|
||||
// {
|
||||
// using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
// {
|
||||
// byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
// }
|
||||
// }
|
||||
// if (DataStream.dataStream.ecs != now_bit)
|
||||
// {
|
||||
// Trace.WriteLine("lalalala" + DataStream.dataStream.ecs);
|
||||
// throw new FileReadException("error esu1!");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//else if (!is_check && is_first_luancher)
|
||||
//{
|
||||
// string? now_bit;
|
||||
// using (SHA256 sha256 = SHA256.Create())
|
||||
// {
|
||||
// using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
// {
|
||||
// byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
// }
|
||||
// }
|
||||
// if (CacheSha.GetE() != now_bit)
|
||||
// {
|
||||
// Trace.WriteLine("lalalala1");
|
||||
// throw new FileReadException("error esu0!");
|
||||
// }
|
||||
// if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); }
|
||||
// is_check = true;
|
||||
//}
|
||||
//#endregion
|
||||
#region 检测代码
|
||||
if (mod == StaticHandleA.UpdateMode)
|
||||
{
|
||||
}
|
||||
else if (!is_check && is_first_luancher)
|
||||
{
|
||||
string? now_bit;
|
||||
using (SHA256 sha256 = SHA256.Create())
|
||||
{
|
||||
using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
{
|
||||
byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
}
|
||||
}
|
||||
if (CacheSha.GetE() != now_bit)
|
||||
{
|
||||
Trace.WriteLine("lalalala1");
|
||||
throw new FileReadException("error esu0!");
|
||||
}
|
||||
is_check = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
var process = new Process
|
||||
{
|
||||
@ -292,7 +284,8 @@ namespace Zerolauncher.Manager
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true
|
||||
},
|
||||
EnableRaisingEvents = true
|
||||
};
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Zerolauncher.util;
|
||||
|
||||
namespace Zerolauncher.Manager
|
||||
{
|
||||
@ -59,7 +62,7 @@ namespace Zerolauncher.Manager
|
||||
|
||||
}
|
||||
|
||||
public static async Task DoLogin(SingleGame game)
|
||||
public static void DoLogin(SingleGame game)
|
||||
{
|
||||
var client = new HttpClient();
|
||||
client.DefaultRequestVersion = HttpVersion.Version20;
|
||||
@ -67,122 +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");
|
||||
string? need_web = null;
|
||||
client.Timeout = TimeSpan.FromSeconds(3);
|
||||
game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.providerId]}的{game.account.serverId}服");
|
||||
switch (game.account.providerId)
|
||||
game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.ProviderId]}的{ServicesStaticInfo.ServerNames[game.account.ServerId]}服");
|
||||
switch (game.account.ProviderId)
|
||||
{
|
||||
case 0:
|
||||
need_web = $"http://web.4399.com/stat/togame.php?target=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, $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}");
|
||||
if (responseString == null) break;
|
||||
if (!responseString.Contains("name=\"game_box\""))
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确");
|
||||
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();
|
||||
responseString = "http://" + response.RequestMessage.RequestUri.ToString().Split("/")[2] + "/" + responseString.Split("movie\" value='")[1].Split("'")[0];
|
||||
//Trace.WriteLine(responseString);
|
||||
game.Send($"{StaticHandleS.GameSa} {responseString}");
|
||||
}
|
||||
need_web = null ;
|
||||
break;
|
||||
case 1:
|
||||
need_web = $"http://web.7k7k.com/games/togame.php?target=ddt_7&server_id={game.account.serverId}";
|
||||
{
|
||||
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;
|
||||
}
|
||||
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}";
|
||||
need_web = "https://www.917play.com.tw/ddt_webserver";
|
||||
break;
|
||||
default:
|
||||
game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.serverId}");
|
||||
game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.ServerId}");
|
||||
break;
|
||||
}
|
||||
client.Dispose();
|
||||
if (need_web == null) return;
|
||||
for (int i = 6; i > 0; i--)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
if (!game.Send($"{StaticHandleS.HintText} 自动登录失败,将在{i}后启用网页登录,关闭窗口取消")) { return; }
|
||||
//for (int i = 6; i > 0; i--)
|
||||
//{
|
||||
// await Task.Delay(1000);
|
||||
// if (!game.Send($"{StaticHandleS.HintText} 自动登录失败,将在{i}后启用网页登录,关闭窗口取消")) { return; }
|
||||
//}
|
||||
game.Send($"{StaticHandleS.UseBrowser} {need_web} {game.account.ProviderId + 4} {ServicesStaticInfo.ServerIds[game.account.ServerId]} {game.account.userName} {game.account.userPWD}");
|
||||
}
|
||||
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,29 +58,30 @@ namespace Zerolauncher.Manager
|
||||
switch (CacheSha.errorCode)
|
||||
{
|
||||
case 1:
|
||||
MessageBox.Show("检查更新出错。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("检查更新出错喵。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
case 2:
|
||||
MessageBox.Show("软件已停止服务或服务错误。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("软件已停止服务或服务错误喵。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
default:
|
||||
MessageBox.Show("检查更新出错。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("检查更新出错喵。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
MessageBoxResult result = MessageBox.Show($"大厅组件需要更新\n是否更新?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
|
||||
MessageBoxResult result = MessageBox.Show($"大厅组件需要更新\n是否更新?喵", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
updateProcess = new SingleGame(null, StaticHandleA.UpdateMode);
|
||||
return;
|
||||
}
|
||||
catch (Exception _ex)
|
||||
{
|
||||
MessageBox.Show("执行自动更新失败!,\n请手动访问链接重新下载大厅文件或联系管理员。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
Process.Start(new ProcessStartInfo(UpDateData.lanzou + UpDateData.user_packet_url) { UseShellExecute = true });
|
||||
// try
|
||||
// {
|
||||
// updateProcess = new SingleGame(null, StaticHandleA.UpdateMode);
|
||||
// return;
|
||||
// }
|
||||
// catch (Exception _ex)
|
||||
// {
|
||||
// MessageBox.Show("执行自动更新失败!,\n请手动访问链接重新下载大厅文件或联系管理员喵。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,23 +4,23 @@ using System.Net;
|
||||
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("?");
|
||||
@ -35,120 +35,78 @@ namespace Zerolauncher.Manager
|
||||
{
|
||||
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))
|
||||
rb = EngineManager.TurnGameSizeNormal(acc) switch
|
||||
{
|
||||
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;
|
||||
}
|
||||
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))
|
||||
rb = EngineManager.TurnGameSizeMini(acc) switch
|
||||
{
|
||||
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;
|
||||
}
|
||||
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()
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
{
|
||||
class ServicesStaticInfo
|
||||
{
|
||||
public static string[] ServicesName = ["4399大区", "7k7k大区", "第七大道"];
|
||||
public static string[] ServicesShortName = ["43", "7k", "7d"];
|
||||
public static string[] ServicesName = ["61平台"];
|
||||
public static string[] ServicesShortName = ["61"];
|
||||
public static string[] ServerNames = ["請選擇伺服器", "星之城", "夢之船(合併)", "謎之峽(合併)", "喵之影(合併)", "龍之吼"];
|
||||
public static int[] ServerIds = [ 0, 1, 2, 34, 38, 44 ];
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
public const string GameSa = "f0";
|
||||
public const string CloseGame = "g0";
|
||||
public const string UpdateInfo = "h0";
|
||||
public const string VerifyDone = "i0";
|
||||
}
|
||||
|
||||
class StaticHandleC
|
||||
@ -21,6 +22,7 @@
|
||||
public const string GameDone = "0e";
|
||||
public const string Version = "0f";
|
||||
public const string DownloadDone = "0g";
|
||||
public const string TakeVerify = "0i";
|
||||
}
|
||||
|
||||
class StaticHandleA
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
<ApplicationIcon>res\title.ico</ApplicationIcon>
|
||||
<Obfuscate>true</Obfuscate>
|
||||
<ConfuserReplaceOutput>true</ConfuserReplaceOutput>
|
||||
<StartupObject>Zerolauncher.App</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@ -46,7 +47,10 @@
|
||||
|
||||
<ItemGroup>
|
||||
<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="System.Drawing.Common" Version="8.0.4" />
|
||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -64,6 +68,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="plugin\model.bin">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ZeroEngine.exe">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="75" d:DesignWidth="65" Margin="5">
|
||||
<Grid>
|
||||
|
||||
<DockPanel>
|
||||
<Image Name="icon" DockPanel.Dock="Top" Source="/res/player_ico1.png" Width="60" Height="60"/>
|
||||
<Label Name="text" DockPanel.Dock="Bottom" Content="43-测试账号" FontSize="9" Padding="0" Width="65"/>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@ -27,35 +27,17 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="btn_diy" Content="自定义图片"/>
|
||||
<Button x:Name="btn_clut" Content="截取游戏" Grid.Row="1"/>
|
||||
<!--<Button x:Name="btn_diy" Content="自定义图片"/>-->
|
||||
<Image Grid.Column="1" Grid.RowSpan="2" Source="/res/player_ico1.png"/>
|
||||
</Grid>
|
||||
<DockPanel Grid.ColumnSpan="1" Margin="2">
|
||||
<Label Content="运营商:" Foreground="White"/>
|
||||
<ComboBox Name="cb_pid"/>
|
||||
</DockPanel>
|
||||
<TextBox Name="edit_sid" Grid.Row="1" Margin="10,3,50,3" SelectionTextBrush="#4CFFFFFF">
|
||||
<TextBox.Resources>
|
||||
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.7" Stretch="None" AlignmentX="Left">
|
||||
<VisualBrush.Visual>
|
||||
<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>
|
||||
<DockPanel Grid.Row="1" Margin="2">
|
||||
<Label Content="服务器:" Foreground="White"/>
|
||||
<ComboBox Name="cb_sid"/>
|
||||
</DockPanel>
|
||||
<TextBox Name="edit_acc" Grid.Row="2" Grid.ColumnSpan="2" Margin="10,2,50,2" SelectionTextBrush="#07FFFFFF">
|
||||
<TextBox.Resources>
|
||||
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.7" Stretch="None" AlignmentX="Left">
|
||||
|
||||
@ -23,25 +23,22 @@ namespace Zerolauncher.dialog
|
||||
}
|
||||
InitializeComponent();
|
||||
cb_pid.ItemsSource = _services;
|
||||
if(EditMemberDialog.member != null)
|
||||
cb_sid.ItemsSource = ServicesStaticInfo.ServerNames;
|
||||
|
||||
if (EditMemberDialog.member != null)
|
||||
{
|
||||
int index = (int)EditMemberDialog.member;
|
||||
var acc = AccountManager.accountsList[index];
|
||||
cb_pid.SelectedIndex = acc.providerId;
|
||||
edit_sid.Text = acc.serverId;
|
||||
var acc = AccountManager.AccountsList[index];
|
||||
cb_pid.SelectedIndex = acc.ProviderId;
|
||||
cb_sid.SelectedIndex = acc.ServerId;
|
||||
edit_acc.Text = acc.userName;
|
||||
edit_pwd.Password = acc.userPWD;
|
||||
edit_nick.Text = acc.nickName;
|
||||
}
|
||||
return;
|
||||
// 私服用
|
||||
if (ServicesStaticInfo.ServicesName.Length == 1)
|
||||
{
|
||||
|
||||
cb_pid.SelectedIndex = 0;
|
||||
edit_sid.Text = "1";
|
||||
cb_pid.IsEditable = false;
|
||||
edit_sid.IsEnabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
||||
@ -60,30 +57,29 @@ namespace Zerolauncher.dialog
|
||||
|
||||
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("所有选项均不能为空!", "提示");
|
||||
return;
|
||||
}
|
||||
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();
|
||||
return;
|
||||
}
|
||||
int index = (int)EditMemberDialog.member;
|
||||
var acc = AccountManager.accountsList[index];
|
||||
acc.providerId = cb_pid.SelectedIndex;
|
||||
acc.serverId = edit_sid.Text;
|
||||
var acc = AccountManager.AccountsList[index];
|
||||
acc.ProviderId = cb_pid.SelectedIndex;
|
||||
acc.ServerId = cb_sid.SelectedIndex;
|
||||
acc.userName = edit_acc.Text;
|
||||
acc.userPWD = edit_pwd.Password;
|
||||
acc.nickName = edit_nick.Text;
|
||||
AccountManager.saveEdit();
|
||||
AccountManager.SaveEdit();
|
||||
EditMemberDialog.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,19 +22,22 @@ namespace Zerolauncher.dialog
|
||||
{
|
||||
if(string.IsNullOrEmpty(edit_name.Text))
|
||||
{
|
||||
MessageBox.Show("昵称不能为空!", "提示");
|
||||
MessageBox.Show("昵称不能为空喵!", "提示");
|
||||
return;
|
||||
}
|
||||
if (isEditModle) AccountManager.editTeamName(edit_name.Text); else TeamManager.addTeam(edit_name.Text);
|
||||
if (isEditModle) AccountManager.EditTeamName(edit_name.Text); else TeamManager.AddTeam(edit_name.Text);
|
||||
EditTeamDialog.Close();
|
||||
}
|
||||
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBoxResult result = MessageBox.Show("即将放生此队伍以及队伍里所有的账号\n将会为你带来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 (!AccountManager.DeleteTeam()) MessageBox.Show("少爷这已经是最后一个队伍了!\n请新建一个队伍后再放生这个吧~", "提示");
|
||||
if (!AccountManager.DeleteTeam())
|
||||
{
|
||||
MessageBox.Show("已经是最后一个队伍了喵!\n新建一个队伍后再放生这个~", "提示");
|
||||
}
|
||||
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"/>
|
||||
<DockPanel DockPanel.Dock="Bottom">
|
||||
<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"/>
|
||||
<Label/>
|
||||
</DockPanel>
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Zerolauncher.Manager;
|
||||
|
||||
namespace Zerolauncher.dialog
|
||||
@ -10,7 +9,7 @@ namespace Zerolauncher.dialog
|
||||
/// <summary>
|
||||
/// UseAccDataTextAdd.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class UseAccDataTextAdd : UserControl
|
||||
public partial class UseAccDataTextAdd
|
||||
{
|
||||
public UseAccDataTextAdd()
|
||||
{
|
||||
@ -20,45 +19,55 @@ namespace Zerolauncher.dialog
|
||||
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()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
|
||||
if (ofd.ShowDialog() == true)
|
||||
{
|
||||
string[] lines = File.ReadAllLines(ofd.FileName, Encoding.UTF8);
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
var lines = File.ReadAllLines(ofd.FileName, Encoding.UTF8);
|
||||
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)
|
||||
{
|
||||
MessageBox.Show($"文本在{i}行非法!\n{lines[i]}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show($"文本在{i}行非法喵!\n{lines[i]}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
var acc = new Account { };
|
||||
if (!int.TryParse(accTexts[0], out acc.providerId))
|
||||
var acc = new AccountNew { };
|
||||
if (!int.TryParse(accTexts[0], out acc.ProviderId))
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误!在{i}行\n错误:[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show($"输入的服务器代号错误喵!在{i}行\n错误:[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
if(0 < acc.providerId || acc.providerId > ServicesStaticInfo.ServicesName.Length)
|
||||
if(0 < acc.ProviderId || acc.ProviderId > ServicesStaticInfo.ServicesName.Length)
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误!在{i}行\n错误:[{acc.providerId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show($"输入的服务器代号错误喵!在{i}行\n错误:[{acc.ProviderId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
if (!int.TryParse(accTexts[1], out acc.ServerId))
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误喵!在{i}行\n错误:[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
if (0 < acc.ProviderId || acc.ProviderId > ServicesStaticInfo.ServerIds.Length)
|
||||
{
|
||||
MessageBox.Show($"输入的服务器代号错误喵!在{i}行\n错误:[{acc.ProviderId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
acc.serverId = accTexts[1];
|
||||
acc.userName = accTexts[2];
|
||||
acc.userPWD = accTexts[3];
|
||||
acc.nickName = accTexts[4];
|
||||
if (!AccountManager.AddAccounts(acc))
|
||||
{
|
||||
MessageBox.Show($"文本在{i}行出错!\n警告:[{acc.nickName}]昵称冲突,将跳过添加此账号", "Warring", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
if (AccountManager.AddAccounts(acc)) continue;
|
||||
MessageBox.Show($"文本在{i}行出错喵!\n警告:[{acc.nickName}]昵称冲突,将跳过添加此账号", "Warring", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
MessageBox.Show("添加完成!", "提示");
|
||||
AccountManager.saveEdit();
|
||||
MessageBox.Show("添加完成喵!", "提示");
|
||||
AccountManager.SaveEdit();
|
||||
AddMemebersDialog.Close();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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