syanc
This commit is contained in:
parent
d09249272c
commit
c43da86364
14
App.xaml.cs
14
App.xaml.cs
@ -11,20 +11,18 @@ namespace Zerolauncher
|
|||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnStartup(e);
|
base.OnStartup(e);
|
||||||
|
Task.Run(async () =>
|
||||||
var a = CloundMananger.TakeQMessage();
|
{
|
||||||
a.Wait();
|
await CloundMananger.TakeQMessage();
|
||||||
UpDateManager.DoCheckUpdate();
|
UpDateManager.DoCheckUpdate();
|
||||||
if (DownloadTask.state)
|
if (DownloadTask.state)
|
||||||
{
|
{
|
||||||
|
|
||||||
}else
|
}
|
||||||
{
|
});
|
||||||
DataStream.Load();
|
DataStream.Load();
|
||||||
_ = WebApiManager.StartListener();
|
_ = WebApiManager.StartListener();
|
||||||
AccountManager.initLoadData();
|
AccountManager.initLoadData(); }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnExit(ExitEventArgs e)
|
protected override void OnExit(ExitEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -104,22 +104,22 @@ namespace Zerolauncher
|
|||||||
|
|
||||||
private void addMemberItem_Click(object sender, RoutedEventArgs e)
|
private void addMemberItem_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
EditMemberDialog.CreateDailog(this, null);
|
EditMemberDialog.CreateDailog(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMembersItem_Click(object sender, RoutedEventArgs e)
|
private void addMembersItem_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
AddMemebersDialog.CreateDailog(this);
|
AddMemebersDialog.CreateDailog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTeamItem_Click(object sender, RoutedEventArgs e)
|
private void addTeamItem_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
EditTeamDialog.CreateDailog(this);
|
EditTeamDialog.CreateDailog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editTeamItem_Click(object sender, RoutedEventArgs e)
|
private void editTeamItem_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
EditTeamDialog.CreateDailog(this, AccountManager.teamName);
|
EditTeamDialog.CreateDailog(AccountManager.teamName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@ -15,6 +15,7 @@ namespace Zerolauncher.Manager
|
|||||||
|
|
||||||
class UpDateData
|
class UpDateData
|
||||||
{
|
{
|
||||||
|
public static bool is_check = false;
|
||||||
public static bool state = false;
|
public static bool state = false;
|
||||||
public static string version = "";
|
public static string version = "";
|
||||||
public static string tis = "";
|
public static string tis = "";
|
||||||
@ -46,6 +47,7 @@ namespace Zerolauncher.Manager
|
|||||||
{
|
{
|
||||||
CacheSha.errorCode = 2;
|
CacheSha.errorCode = 2;
|
||||||
}
|
}
|
||||||
|
UpDateData.is_check = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool FormatMessage(string message)
|
static bool FormatMessage(string message)
|
||||||
@ -68,8 +70,8 @@ namespace Zerolauncher.Manager
|
|||||||
{
|
{
|
||||||
if (sha0.Length < 90) return false;
|
if (sha0.Length < 90) return false;
|
||||||
int count;
|
int count;
|
||||||
var sha = SpaceEncoder.Decode(sha0[..86], out count);
|
var sha = SpaceEncoder.Decode(sha0, out count);
|
||||||
if (sha == null)
|
if (sha == null || sha.Length < 64)
|
||||||
{
|
{
|
||||||
//Console.WriteLine($"faile: {count}");
|
//Console.WriteLine($"faile: {count}");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Zerolauncher.Defender;
|
using Zerolauncher.Defender;
|
||||||
|
|
||||||
@ -17,9 +15,19 @@ namespace Zerolauncher.Manager
|
|||||||
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(Account account, out bool showDialog)
|
||||||
{
|
{
|
||||||
|
showDialog = false;
|
||||||
|
if (UpDateData.is_check == false)
|
||||||
|
{
|
||||||
|
MessageBox.Show("正在更新数据,请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (UpDateData.state)
|
||||||
|
{
|
||||||
|
showDialog = true;
|
||||||
|
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) {
|
||||||
@ -35,22 +43,21 @@ namespace Zerolauncher.Manager
|
|||||||
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
|
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mGame[key] = new SingleGame(account);
|
mGame[key] = new SingleGame(account);
|
||||||
}catch (Exception _ex)
|
}catch (Exception _ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("发生错误!\n如重复发生此错误,\n请重新下载登陆器文件或联系管理员。", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
|
MessageBox.Show("发生错误!\n如重复发生此错误,\n请重新下载大厅文件或联系管理员。", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CreateGame(int memberId)
|
public static bool CreateGame(int memberId, out bool showDialog)
|
||||||
{
|
{
|
||||||
return CreateGame(AccountManager.accountsList[memberId]);
|
return CreateGame(AccountManager.accountsList[memberId], out showDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int CheckGameState(Account account)
|
public static int CheckGameState(Account account)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.IO.Compression;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using Zerolauncher.Defender;
|
using Zerolauncher.Defender;
|
||||||
|
|
||||||
@ -15,7 +15,8 @@ namespace Zerolauncher.Manager
|
|||||||
|
|
||||||
class UpDateManager
|
class UpDateManager
|
||||||
{
|
{
|
||||||
public static bool isCheeking = false;
|
const string cache_file = "cache.zip";
|
||||||
|
static bool isCheeking = false;
|
||||||
|
|
||||||
public static void DoCheckUpdate(bool checkMain=true, bool needEngine = false)
|
public static void DoCheckUpdate(bool checkMain=true, bool needEngine = false)
|
||||||
{
|
{
|
||||||
@ -56,62 +57,10 @@ namespace Zerolauncher.Manager
|
|||||||
isCheeking = false;
|
isCheeking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DownLoad(string Url, string FileName, bool has)
|
public static void OnDownLoadDone()
|
||||||
{
|
{
|
||||||
bool Value = false;
|
ZipFile.ExtractToDirectory(cache_file, ".");
|
||||||
WebResponse response = null;
|
Process.Start("./upacket.bin");
|
||||||
Stream stream = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
|
|
||||||
|
|
||||||
response = request.GetResponse();
|
|
||||||
stream = response.GetResponseStream();
|
|
||||||
|
|
||||||
if (!response.ContentType.ToLower().StartsWith("text/"))
|
|
||||||
{
|
|
||||||
Value = SaveBinaryFile(response, FileName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception err)
|
|
||||||
{
|
|
||||||
string aa = err.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool SaveBinaryFile(WebResponse response, string FileName)
|
|
||||||
{
|
|
||||||
bool Value = true;
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (File.Exists(FileName))
|
|
||||||
File.Delete(FileName);
|
|
||||||
Stream outStream = File.Create(FileName);
|
|
||||||
Stream inStream = response.GetResponseStream();
|
|
||||||
|
|
||||||
int l;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
l = inStream.Read(buffer, 0, buffer.Length);
|
|
||||||
if (l > 0)
|
|
||||||
outStream.Write(buffer, 0, l);
|
|
||||||
}
|
|
||||||
while (l > 0);
|
|
||||||
|
|
||||||
outStream.Close();
|
|
||||||
inStream.Close();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Value = false;
|
|
||||||
}
|
|
||||||
return Value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,7 @@ namespace Zerolauncher.Manager
|
|||||||
break;
|
break;
|
||||||
case "/LoginGame":
|
case "/LoginGame":
|
||||||
{
|
{
|
||||||
if (EngineManager.CreateGame(acc))
|
if (EngineManager.CreateGame(acc, out _))
|
||||||
{
|
{
|
||||||
rb = new ResponesBody(0, 0, $"Account [{nick}] successful to start.");
|
rb = new ResponesBody(0, 0, $"Account [{nick}] successful to start.");
|
||||||
}
|
}
|
||||||
|
|||||||
9
StaticUpdatePath.cs
Normal file
9
StaticUpdatePath.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Zerolauncher
|
||||||
|
{
|
||||||
|
class StaticUpdatePath
|
||||||
|
{
|
||||||
|
public const string cache_patch = "./.cache/";
|
||||||
|
public const string cache_file = "cache.zip";
|
||||||
|
public const string extract_file = "./.cache/un/";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -35,8 +35,9 @@ namespace Zerolauncher.controls
|
|||||||
if (!isMouseDown) return;
|
if (!isMouseDown) return;
|
||||||
RenderTransform = new TranslateTransform(0, 0);
|
RenderTransform = new TranslateTransform(0, 0);
|
||||||
if (e.ChangedButton == MouseButton.Right) return;
|
if (e.ChangedButton == MouseButton.Right) return;
|
||||||
if (!EngineManager.CreateGame(memberId)) MessageBox.Show("账号已启动!请勿重复启动", "提示");
|
bool needDialog;
|
||||||
|
if (!EngineManager.CreateGame(memberId, out needDialog)) MessageBox.Show("账号已启动!请勿重复启动", "提示");
|
||||||
|
if (needDialog) UpdateDialog.CreateDailog();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 鼠标离开事件
|
// 鼠标离开事件
|
||||||
@ -107,8 +108,8 @@ namespace Zerolauncher.controls
|
|||||||
|
|
||||||
private void editItem_Click(object sender, RoutedEventArgs e)
|
private void editItem_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Trace.WriteLine("edit member " + memberId.ToString());
|
//Trace.WriteLine("edit member " + memberId.ToString());
|
||||||
EditMemberDialog.CreateDailog(MainWindow.Instance, memberId);
|
EditMemberDialog.CreateDailog(memberId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ namespace Zerolauncher.dialog
|
|||||||
|
|
||||||
public static int? member;
|
public static int? member;
|
||||||
|
|
||||||
public static void CreateDailog(Window p, int? memberId)
|
public static void CreateDailog(int? memberId)
|
||||||
{
|
{
|
||||||
if (editControl != null || baseDialog != null)
|
if (editControl != null || baseDialog != null)
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ namespace Zerolauncher.dialog
|
|||||||
static EditTeamControl? editControl;
|
static EditTeamControl? editControl;
|
||||||
|
|
||||||
|
|
||||||
public static bool CreateDailog(Window p, string? oldTeamName=null)
|
public static bool CreateDailog(string? oldTeamName=null)
|
||||||
{
|
{
|
||||||
if (editControl != null || baseDialog != null)
|
if (editControl != null || baseDialog != null)
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ namespace Zerolauncher.dialog
|
|||||||
static BaseDialog? baseDialog;
|
static BaseDialog? baseDialog;
|
||||||
static UseAccDataTextAdd? editControl;
|
static UseAccDataTextAdd? editControl;
|
||||||
|
|
||||||
public static void CreateDailog(Window p)
|
public static void CreateDailog()
|
||||||
{
|
{
|
||||||
if (editControl != null || baseDialog != null)
|
if (editControl != null || baseDialog != null)
|
||||||
{
|
{
|
||||||
@ -106,7 +106,7 @@ namespace Zerolauncher.dialog
|
|||||||
public static DownloadControl1? editControl;
|
public static DownloadControl1? editControl;
|
||||||
public static bool ui_enale = false;
|
public static bool ui_enale = false;
|
||||||
|
|
||||||
public static void CreateDailog(Window p)
|
public static void CreateDailog()
|
||||||
{
|
{
|
||||||
if (editControl != null || baseDialog != null)
|
if (editControl != null || baseDialog != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -44,7 +44,10 @@ namespace Zerolauncher.dialog
|
|||||||
|
|
||||||
private static void OnDownloadFileCompleted(object? sender, AsyncCompletedEventArgs e)
|
private static void OnDownloadFileCompleted(object? sender, AsyncCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (UpdateDialog.ui_enale)
|
||||||
|
{
|
||||||
|
UpdateDialog.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnDownloadProgressChanged(object? sender, DownloadProgressChangedEventArgs e)
|
private static void OnDownloadProgressChanged(object? sender, DownloadProgressChangedEventArgs e)
|
||||||
@ -54,7 +57,6 @@ namespace Zerolauncher.dialog
|
|||||||
UpdateDialog.editControl.pbDown.Value = e.ProgressPercentage;
|
UpdateDialog.editControl.pbDown.Value = e.ProgressPercentage;
|
||||||
UpdateDialog.editControl.text2.Text = $"{e.AverageBytesPerSecondSpeed}";
|
UpdateDialog.editControl.text2.Text = $"{e.AverageBytesPerSecondSpeed}";
|
||||||
}
|
}
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnDownloadStarted(object? sender, DownloadStartedEventArgs e)
|
private static void OnDownloadStarted(object? sender, DownloadStartedEventArgs e)
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace Zerolauncher.util
|
|
||||||
{
|
|
||||||
class Download
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -51,6 +51,7 @@ namespace Zerolauncher.util
|
|||||||
counter = 0;
|
counter = 0;
|
||||||
foreach (char c in hex)
|
foreach (char c in hex)
|
||||||
{
|
{
|
||||||
|
if (sb.Length == 64) break;
|
||||||
counter++;
|
counter++;
|
||||||
if (!map.Contains(c)) return null;
|
if (!map.Contains(c)) return null;
|
||||||
if (c != map[11])
|
if (c != map[11])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user