add update test
This commit is contained in:
parent
670a2de102
commit
e18a94cca3
@ -4,13 +4,38 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="About" Height="384" Width="700">
|
AllowsTransparency="True" WindowStyle="None" Background="Transparent"
|
||||||
|
Title="About" Height="384" Width="700" MouseLeftButtonDown="Window_MouseLeftButtonDown">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Image Source="/res/about1.png" Stretch="Fill"/>
|
<Image Source="/res/about1.png" Stretch="Fill"/>
|
||||||
<DockPanel>
|
<DockPanel Margin="145,100,150,45">
|
||||||
<TextBlock Text="关 于" Margin="20" FontSize="50" Foreground="OrangeRed"/>
|
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
|
||||||
<StackPanel>
|
<Button Background="Transparent" Height="30" Width="35" Click="Button_Click">
|
||||||
<TextBlock x:Name="info" Text=" 灵依游戏大厅 The best luancher Power by DDF" Margin="30,150,30,30" HorizontalAlignment="Center" Foreground="#2e4e7e" FontSize="16"/>
|
<Button.Style>
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border Name="border" BorderThickness="0" BorderBrush="Black" Background="{TemplateBinding Background}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Opacity" Value="0.55" />
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
<Image Source="/res/close.png" Height="25"/>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel VerticalAlignment="Bottom">
|
||||||
|
<TextBlock Text="关于" FontSize="35" Foreground="OrangeRed" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,0,0,30"/>
|
||||||
|
<TextBlock x:Name="info" Text=" 灵依游戏大厅 The best luancher Power by DDF" HorizontalAlignment="Center" Foreground="#2e4e7e" FontSize="16"/>
|
||||||
<TextBlock Text="Contact me" HorizontalAlignment="Center" Foreground="#FF81EB78"/>
|
<TextBlock Text="Contact me" HorizontalAlignment="Center" Foreground="#FF81EB78"/>
|
||||||
<TextBlock HorizontalAlignment="Center">
|
<TextBlock HorizontalAlignment="Center">
|
||||||
<Hyperlink NavigateUri="https://github.com/1415ddfer/ZeroHelper" Click="Hyperlink_Click">
|
<Hyperlink NavigateUri="https://github.com/1415ddfer/ZeroHelper" Click="Hyperlink_Click">
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Zerolauncher.AboutDialog
|
namespace Zerolauncher.AboutDialog
|
||||||
{
|
{
|
||||||
@ -14,6 +15,12 @@ namespace Zerolauncher.AboutDialog
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
// 实现窗口的拖动
|
||||||
|
DragMove();
|
||||||
|
}
|
||||||
|
|
||||||
private void Hyperlink_Click(object sender, RoutedEventArgs e)
|
private void Hyperlink_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Process.Start(new ProcessStartInfo("http://github.com/1415ddfer/ZeroHelper") { UseShellExecute = true });
|
Process.Start(new ProcessStartInfo("http://github.com/1415ddfer/ZeroHelper") { UseShellExecute = true });
|
||||||
@ -24,5 +31,10 @@ namespace Zerolauncher.AboutDialog
|
|||||||
MessageBox.Show("已拷贝到粘贴板", "提示");
|
MessageBox.Show("已拷贝到粘贴板", "提示");
|
||||||
Clipboard.SetDataObject("ddfgame@foxmail.com", true);
|
Clipboard.SetDataObject("ddfgame@foxmail.com", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
37
App.xaml.cs
37
App.xaml.cs
@ -1,4 +1,6 @@
|
|||||||
using System.Windows;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows;
|
||||||
using Zerolauncher.Manager;
|
using Zerolauncher.Manager;
|
||||||
|
|
||||||
namespace Zerolauncher
|
namespace Zerolauncher
|
||||||
@ -8,16 +10,44 @@ namespace Zerolauncher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
|
public static bool needUpdate = false;
|
||||||
|
|
||||||
|
static bool TryDeleteDirectory(string path, bool recursive)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.Delete(path, recursive);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnStartup(e);
|
base.OnStartup(e);
|
||||||
|
if (e.Args.Length == 1)
|
||||||
|
{
|
||||||
|
switch (e.Args[0])
|
||||||
|
{
|
||||||
|
case "updateDone":
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 3 && !TryDeleteDirectory(@"./cache", true); i++)
|
||||||
|
Thread.Sleep(3000);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await CloundMananger.TakeQMessage();
|
await CloundMananger.TakeQMessage();
|
||||||
UpDateManager.DoCheckUpdate();
|
UpDateManager.DoCheckUpdate();
|
||||||
if (DownloadTask.state)
|
if (UpDateManager.state)
|
||||||
{
|
{
|
||||||
|
UpDateManager.DoUpdate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
DataStream.Load();
|
DataStream.Load();
|
||||||
@ -28,6 +58,7 @@ namespace Zerolauncher
|
|||||||
{
|
{
|
||||||
base.OnExit(e);
|
base.OnExit(e);
|
||||||
WebApiManager.StopListener();
|
WebApiManager.StopListener();
|
||||||
|
if (needUpdate) Process.Start("./cache/upacket.bin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,6 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
<ScrollViewer x:Name="memberBG" VerticalScrollBarVisibility="Auto" Margin="10,3,10,10">
|
<ScrollViewer x:Name="memberBG" VerticalScrollBarVisibility="Auto" Margin="10,3,10,10">
|
||||||
<WrapPanel Name="mLayout">
|
<WrapPanel Name="mLayout">
|
||||||
|
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|||||||
@ -122,27 +122,6 @@ namespace Zerolauncher
|
|||||||
EditTeamDialog.CreateDailog(AccountManager.teamName);
|
EditTeamDialog.CreateDailog(AccountManager.teamName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
// 创建新的按钮
|
|
||||||
Button newButton = new Button();
|
|
||||||
newButton.Content = "新按钮";
|
|
||||||
|
|
||||||
// 将新按钮添加到布局中
|
|
||||||
// 假设你的布局是一个名为"myLayout"的StackPanel
|
|
||||||
mLayout.Children.Add(newButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
LoginManager.LoginTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_Click_2(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
LoginManager.GameTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_Click_3(object sender, RoutedEventArgs e)
|
private void Button_Click_3(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
@ -153,5 +132,6 @@ namespace Zerolauncher
|
|||||||
var ab = new About1();
|
var ab = new About1();
|
||||||
ab.ShowDialog();
|
ab.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using Zerolauncher.Defender;
|
using Zerolauncher.Defender;
|
||||||
using Zerolauncher.util;
|
using Zerolauncher.util;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Zerolauncher.Manager
|
namespace Zerolauncher.Manager
|
||||||
{
|
{
|
||||||
@ -10,7 +11,7 @@ namespace Zerolauncher.Manager
|
|||||||
public const string QMessageMain = "https://sharechain.qq.com/";
|
public const string QMessageMain = "https://sharechain.qq.com/";
|
||||||
public const string MasterMessage = "54aeb77c47b967d22c2c1396d00d91f0";
|
public const string MasterMessage = "54aeb77c47b967d22c2c1396d00d91f0";
|
||||||
public const string SummerMessage = "037846c482eddc948612b0d0f8ed98d5";
|
public const string SummerMessage = "037846c482eddc948612b0d0f8ed98d5";
|
||||||
public const string LoveMessage = "";
|
public const string LoveMessage = "539e3389078daa765ac0abdcc97eebce";
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpDateData
|
class UpDateData
|
||||||
@ -19,8 +20,9 @@ namespace Zerolauncher.Manager
|
|||||||
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 = "";
|
||||||
public static string mini_packet_url = "";
|
public static string auto_packet_url = "";
|
||||||
public static string full_packet_url = "";
|
public static string user_packet_url = "";
|
||||||
|
public const string lanzou = "https://www.lanzoub.com/";
|
||||||
}
|
}
|
||||||
|
|
||||||
class CloundMananger
|
class CloundMananger
|
||||||
@ -35,7 +37,7 @@ namespace Zerolauncher.Manager
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.Timeout = TimeSpan.FromMinutes(3);
|
client.Timeout = TimeSpan.FromMinutes(3);
|
||||||
response = await client.GetAsync($"{StaticUrl.QMessageMain}{StaticUrl.MasterMessage}");
|
response = await client.GetAsync($"{StaticUrl.QMessageMain}{StaticUrl.LoveMessage}");
|
||||||
}
|
}
|
||||||
catch (Exception _ex)
|
catch (Exception _ex)
|
||||||
{
|
{
|
||||||
@ -54,12 +56,15 @@ namespace Zerolauncher.Manager
|
|||||||
{
|
{
|
||||||
message = message.Split("<div class=\"note-content\">")[1].Split("</article>")[0].Replace("</div>", "").Replace("\n", "").Replace("\t", "").Replace("\r", "").Replace("'", "");
|
message = message.Split("<div class=\"note-content\">")[1].Split("</article>")[0].Replace("</div>", "").Replace("\n", "").Replace("\t", "").Replace("\r", "").Replace("'", "");
|
||||||
var arr = message.Split("<div>");
|
var arr = message.Split("<div>");
|
||||||
if (arr.Length >= 7 && FormatSha(arr[6], false) && FormatSha(arr[5], true))
|
Trace.WriteLine("bababababa" + arr.Length.ToString());
|
||||||
|
Trace.WriteLine(message);
|
||||||
|
if (arr.Length == 7 && FormatSha(arr[6], false) && FormatSha(arr[5], true))
|
||||||
{
|
{
|
||||||
|
Trace.WriteLine("bababababa" + arr.Length.ToString());
|
||||||
UpDateData.version = arr[1];
|
UpDateData.version = arr[1];
|
||||||
UpDateData.tis = arr[2];
|
UpDateData.tis = arr[2];
|
||||||
UpDateData.mini_packet_url = arr[3];
|
UpDateData.auto_packet_url = arr[3];
|
||||||
UpDateData.full_packet_url = arr[4];
|
UpDateData.user_packet_url = arr[4];
|
||||||
UpDateData.state = true;
|
UpDateData.state = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -68,12 +73,12 @@ namespace Zerolauncher.Manager
|
|||||||
|
|
||||||
static bool FormatSha(string sha0, bool e)
|
static bool FormatSha(string sha0, bool e)
|
||||||
{
|
{
|
||||||
if (sha0.Length < 90) return false;
|
//if (sha0.Length < 80) return false;
|
||||||
int count;
|
int count;
|
||||||
var sha = SpaceEncoder.Decode(sha0, out count);
|
var sha = SpaceEncoder.Decode(sha0, out count);
|
||||||
if (sha == null || sha.Length < 64)
|
if (sha == null || sha.Length < 64)
|
||||||
{
|
{
|
||||||
//Console.WriteLine($"faile: {count}");
|
Trace.WriteLine($"faile: {count}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (e) CacheSha.PutE(sha);
|
if (e) CacheSha.PutE(sha);
|
||||||
|
|||||||
@ -20,7 +20,7 @@ namespace Zerolauncher.Manager
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dataStream = JsonConvert.DeserializeObject<Data>(
|
dataStream = JsonConvert.DeserializeObject<Data>(
|
||||||
"{\"teamIndex\":0,\"Groups\":[{\"Name\":\"队伍1\", \"Accounts\": [{\"providerId\":0,\"userName\":\"test\",\"userPWD\":\"test\",\"nickName\":\"测试账号\",\"serverId\":\"1\"}]}], \"engine_cache_ver\": 0}");
|
"{\"teamIndex\":0,\"Groups\":[{\"Name\":\"队伍1\", \"Accounts\": [{\"providerId\":0,\"userName\":\"test\",\"userPWD\":\"test\",\"nickName\":\"测试账号\",\"serverId\":\"1\"}]}], \"ecs\": \"\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ namespace Zerolauncher.Manager
|
|||||||
public static void write()
|
public static void write()
|
||||||
{
|
{
|
||||||
string? data = JsonConvert.SerializeObject(dataStream);
|
string? data = JsonConvert.SerializeObject(dataStream);
|
||||||
Trace.WriteLine(data);
|
//Trace.WriteLine(data);
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
File.WriteAllBytes(path, CompressBytes(Encoding.UTF8.GetBytes(data)));
|
File.WriteAllBytes(path, CompressBytes(Encoding.UTF8.GetBytes(data)));
|
||||||
}
|
}
|
||||||
@ -85,6 +85,6 @@ namespace Zerolauncher.Manager
|
|||||||
{
|
{
|
||||||
public int teamIndex;
|
public int teamIndex;
|
||||||
public List<Group> Groups;
|
public List<Group> Groups;
|
||||||
public int engine_cache_ver;
|
public string ecs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,6 @@
|
|||||||
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;
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ namespace Zerolauncher.Manager
|
|||||||
showDialog = false;
|
showDialog = false;
|
||||||
if (UpDateData.is_check == false)
|
if (UpDateData.is_check == false)
|
||||||
{
|
{
|
||||||
MessageBox.Show("正在更新数据,请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
|
MessageBox.Show("正在更新游戏数据,请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (UpDateData.state)
|
if (UpDateData.state)
|
||||||
@ -34,13 +36,13 @@ namespace Zerolauncher.Manager
|
|||||||
switch (CacheSha.errorCode)
|
switch (CacheSha.errorCode)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
MessageBox.Show("发生网络错误==EMS。\n 请检查网络", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
|
MessageBox.Show("发生网络错误==EMS。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
MessageBox.Show("发生游戏服务错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
|
MessageBox.Show("发生游戏服务错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
|
MessageBox.Show("发生未知错误==EMS。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -50,7 +52,7 @@ namespace Zerolauncher.Manager
|
|||||||
mGame[key] = new SingleGame(account);
|
mGame[key] = new SingleGame(account);
|
||||||
}catch (Exception _ex)
|
}catch (Exception _ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("发生错误!\n如重复发生此错误,\n请重新下载大厅文件或联系管理员。", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
|
UpDateManager.DoUpdate();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -121,11 +123,8 @@ namespace Zerolauncher.Manager
|
|||||||
class SingleGame
|
class SingleGame
|
||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
|
|
||||||
string? restartUrl;
|
string? restartUrl;
|
||||||
|
|
||||||
public int mHandle;
|
public int mHandle;
|
||||||
|
|
||||||
public Account? account;
|
public Account? account;
|
||||||
string gameMode;
|
string gameMode;
|
||||||
|
|
||||||
@ -136,21 +135,12 @@ namespace Zerolauncher.Manager
|
|||||||
gameMode = mod;
|
gameMode = mod;
|
||||||
mHandle = 0;
|
mHandle = 0;
|
||||||
process = EngineShell.CheckEngineSafe(gameMode);
|
process = EngineShell.CheckEngineSafe(gameMode);
|
||||||
if (gameMode != StaticHandleA.UpdateMode)
|
|
||||||
{
|
|
||||||
process.OutputDataReceived += Handle;
|
process.OutputDataReceived += Handle;
|
||||||
process.Exited += Process_Exited;
|
process.Exited += Process_Exited;
|
||||||
}
|
|
||||||
process.Start();
|
|
||||||
if (gameMode != StaticHandleA.UpdateMode)
|
|
||||||
{
|
|
||||||
process.BeginOutputReadLine(); // 开始异步读取
|
|
||||||
if (gameMode == StaticHandleA.Version)
|
|
||||||
{
|
|
||||||
process.WaitForExit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
process.Start();
|
||||||
|
|
||||||
|
process.BeginOutputReadLine(); // 开始异步读取
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateProcess()
|
private void CreateProcess()
|
||||||
@ -180,10 +170,15 @@ namespace Zerolauncher.Manager
|
|||||||
|
|
||||||
private void Handle(object sender, DataReceivedEventArgs e)
|
private void Handle(object sender, DataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
var lines = e.Data == null? [""] : e.Data.Split(" ");
|
var lines = e.Data == null? [""] : e.Data.Split(" ", 2); // 切成两半
|
||||||
switch (lines[0])
|
switch (lines[0])
|
||||||
{
|
{
|
||||||
case StaticHandleC.StartDone:
|
case StaticHandleC.StartDone:
|
||||||
|
if (gameMode == StaticHandleA.UpdateMode)
|
||||||
|
{
|
||||||
|
UpDateManager.DoUpdate1();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(restartUrl == null)
|
if(restartUrl == null)
|
||||||
{
|
{
|
||||||
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.providerId]}-{account.nickName}");
|
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.providerId]}-{account.nickName}");
|
||||||
@ -210,6 +205,9 @@ namespace Zerolauncher.Manager
|
|||||||
case StaticHandleC.Version:
|
case StaticHandleC.Version:
|
||||||
mHandle = int.Parse(lines[1]);
|
mHandle = int.Parse(lines[1]);
|
||||||
break;
|
break;
|
||||||
|
case StaticHandleC.DownloadDone:
|
||||||
|
UpDateManager.OnDownLoadDone(lines[1]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,35 +229,57 @@ namespace Zerolauncher.Manager
|
|||||||
|
|
||||||
class EngineShell
|
class EngineShell
|
||||||
{
|
{
|
||||||
|
static bool needShowTis = true;
|
||||||
static bool is_check = false;
|
static bool is_check = false;
|
||||||
const string engine_file = @"ZeroEngine.exe";
|
const string engine_file = @"ZeroEngine.exe";
|
||||||
public static Process CheckEngineSafe(string mod)
|
public static Process CheckEngineSafe(string mod)
|
||||||
{
|
{
|
||||||
bool is_first_luancher = EngineManager.CheckEmpy();
|
bool is_first_luancher = EngineManager.CheckEmpy();
|
||||||
//if (!is_check && is_first_luancher)
|
if (mod == StaticHandleA.UpdateMode)
|
||||||
//{
|
{
|
||||||
// string? now_bit;
|
if (DataStream.dataStream.ecs != "")
|
||||||
// using (SHA256 sha256 = SHA256.Create())
|
{
|
||||||
// {
|
string? now_bit;
|
||||||
// using (FileStream fileStream = File.OpenRead(engine_file))
|
using (SHA256 sha256 = SHA256.Create())
|
||||||
// {
|
{
|
||||||
// byte[] hashBytes = sha256.ComputeHash(fileStream);
|
using (FileStream fileStream = File.OpenRead(engine_file))
|
||||||
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
{
|
||||||
// }
|
byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||||
// }
|
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||||
// if (EngineCacheSha.Get() != now_bit)
|
}
|
||||||
// {
|
}
|
||||||
// throw new FileReadException("无法读取文件内容");
|
if (DataStream.dataStream.ecs != now_bit)
|
||||||
// }
|
{
|
||||||
// is_check = true;
|
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)
|
||||||
|
{
|
||||||
|
throw new FileReadException("error esu0!");
|
||||||
|
}
|
||||||
|
if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); }
|
||||||
|
is_check = true;
|
||||||
|
}
|
||||||
|
|
||||||
var process = new Process
|
var process = new Process
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo
|
StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = engine_file,
|
FileName = engine_file,
|
||||||
Arguments = $"{mod} {is_first_luancher}",
|
Arguments = $"{StaticHandleA.GameMode} {needShowTis}",
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
RedirectStandardInput = true,
|
RedirectStandardInput = true,
|
||||||
@ -267,6 +287,7 @@ namespace Zerolauncher.Manager
|
|||||||
},
|
},
|
||||||
EnableRaisingEvents = true
|
EnableRaisingEvents = true
|
||||||
};
|
};
|
||||||
|
if (needShowTis) needShowTis = false;
|
||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,21 +2,17 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using System.Windows;
|
||||||
using Zerolauncher.Defender;
|
using Zerolauncher.Defender;
|
||||||
|
|
||||||
namespace Zerolauncher.Manager
|
namespace Zerolauncher.Manager
|
||||||
{
|
{
|
||||||
|
|
||||||
class DownloadTask
|
|
||||||
{
|
|
||||||
public static bool state = false;
|
|
||||||
public static string url = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
class UpDateManager
|
class UpDateManager
|
||||||
{
|
{
|
||||||
const string cache_file = "cache.zip";
|
public static bool state = false;
|
||||||
static bool isCheeking = false;
|
static bool isCheeking = false;
|
||||||
|
static SingleGame? updateProcess;
|
||||||
|
|
||||||
public static void DoCheckUpdate(bool checkMain=true, bool needEngine = false)
|
public static void DoCheckUpdate(bool checkMain=true, bool needEngine = false)
|
||||||
{
|
{
|
||||||
@ -50,17 +46,64 @@ namespace Zerolauncher.Manager
|
|||||||
}
|
}
|
||||||
needEngine = now_bit == CacheSha.GetE() && now_bit != null;
|
needEngine = now_bit == CacheSha.GetE() && now_bit != null;
|
||||||
}
|
}
|
||||||
if(needEngine && needMian) { isCheeking = false; return; }
|
state = !(needEngine && needMian);
|
||||||
DownloadTask.state = true;
|
|
||||||
if(needEngine == needMian) DownloadTask.url = UpDateData.full_packet_url;
|
|
||||||
else DownloadTask.url = UpDateData.mini_packet_url;
|
|
||||||
isCheeking = false;
|
isCheeking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnDownLoadDone()
|
public static void DoUpdate()
|
||||||
{
|
{
|
||||||
ZipFile.ExtractToDirectory(cache_file, ".");
|
if (CacheSha.errorCode != 0)
|
||||||
Process.Start("./upacket.bin");
|
{
|
||||||
|
switch (CacheSha.errorCode)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
MessageBox.Show("检查更新出错。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
MessageBox.Show("软件已停止服务或服务错误。\n 请联系管理员", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
MessageBox.Show("检查更新出错。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DoUpdate1()
|
||||||
|
{
|
||||||
|
updateProcess.Send($"{StaticHandleS.ShowWindow} 自助更新");
|
||||||
|
updateProcess.Send($"{StaticHandleS.UseBrowser} {UpDateData.lanzou + UpDateData.auto_packet_url}");
|
||||||
|
updateProcess.Send($"{StaticHandleS.UpdateInfo} {UpDateData.tis}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnDownLoadDone(string path)
|
||||||
|
{
|
||||||
|
updateProcess.Send(StaticHandleS.CloseGame);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ZipFile.ExtractToDirectory(path, "./cache/");
|
||||||
|
File.Delete(path);
|
||||||
|
}catch(Exception e)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"尝试更新文件时发生错误\n{e.Message}", "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
App.needUpdate = true;
|
||||||
|
MainWindow.Instance.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
public const string UseBrowser = "e0";
|
public const string UseBrowser = "e0";
|
||||||
public const string GameSa = "f0";
|
public const string GameSa = "f0";
|
||||||
public const string CloseGame = "g0";
|
public const string CloseGame = "g0";
|
||||||
|
public const string UpdateInfo = "h0";
|
||||||
}
|
}
|
||||||
|
|
||||||
class StaticHandleC
|
class StaticHandleC
|
||||||
@ -18,12 +19,13 @@
|
|||||||
public const string StartGame = "0c";
|
public const string StartGame = "0c";
|
||||||
public const string GameDone = "0d";
|
public const string GameDone = "0d";
|
||||||
public const string Version = "0e";
|
public const string Version = "0e";
|
||||||
|
public const string DownloadDone = "0f";
|
||||||
}
|
}
|
||||||
|
|
||||||
class StaticHandleA
|
class StaticHandleA
|
||||||
{
|
{
|
||||||
public const string GameMode = "0a";
|
public const string GameMode = "0a";
|
||||||
public const string UpdateMode = "0b";
|
public const string UpdateMode = "0b";
|
||||||
public const string Version = "0c";
|
public const string VersionMode = "0c";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
<None Remove="res\about1.png" />
|
<None Remove="res\about1.png" />
|
||||||
<None Remove="res\btn_close1.png" />
|
<None Remove="res\btn_close1.png" />
|
||||||
<None Remove="res\btn_mini1.png" />
|
<None Remove="res\btn_mini1.png" />
|
||||||
|
<None Remove="res\close.png" />
|
||||||
<None Remove="res\config.png" />
|
<None Remove="res\config.png" />
|
||||||
<None Remove="res\del.png" />
|
<None Remove="res\del.png" />
|
||||||
<None Remove="res\player_ico1.png" />
|
<None Remove="res\player_ico1.png" />
|
||||||
@ -49,9 +50,16 @@
|
|||||||
<Resource Include="res\about1.png" />
|
<Resource Include="res\about1.png" />
|
||||||
<Resource Include="res\btn_close1.png" />
|
<Resource Include="res\btn_close1.png" />
|
||||||
<Resource Include="res\btn_mini1.png" />
|
<Resource Include="res\btn_mini1.png" />
|
||||||
|
<Resource Include="res\close.png" />
|
||||||
<Resource Include="res\config.png" />
|
<Resource Include="res\config.png" />
|
||||||
<Resource Include="res\del.png" />
|
<Resource Include="res\del.png" />
|
||||||
<Resource Include="res\player_ico1.png" />
|
<Resource Include="res\player_ico1.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="ZeroEngine.exe">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -97,14 +97,17 @@ namespace Zerolauncher.controls
|
|||||||
changeTeamItem.Items.Add(menuItem);
|
changeTeamItem.Items.Add(menuItem);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return contextMenu;
|
return contextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void delItem_Click(object sender, RoutedEventArgs e)
|
private void delItem_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
MessageBoxResult result = MessageBox.Show($"即将删除账号{text.Content}", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
|
||||||
|
if (result == MessageBoxResult.OK)
|
||||||
{
|
{
|
||||||
AccountManager.DeleteAccount(memberId);
|
AccountManager.DeleteAccount(memberId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void editItem_Click(object sender, RoutedEventArgs e)
|
private void editItem_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,17 +5,8 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="169" d:DesignWidth="290">
|
d:DesignHeight="169" d:DesignWidth="290">
|
||||||
<Grid>
|
<DockPanel>
|
||||||
<Grid.RowDefinitions>
|
<TextBox Name="edit_name" Margin="60" DockPanel.Dock="Top" Height="20">
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBox Name="edit_name" Grid.Row="2" Margin="10,2,50,2" >
|
|
||||||
<TextBox.Resources>
|
<TextBox.Resources>
|
||||||
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.3" Stretch="None" AlignmentX="Left">
|
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.3" Stretch="None" AlignmentX="Left">
|
||||||
<VisualBrush.Visual>
|
<VisualBrush.Visual>
|
||||||
@ -45,5 +36,5 @@
|
|||||||
</Button>
|
</Button>
|
||||||
<Label/>
|
<Label/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</Grid>
|
</DockPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
BIN
res/about1.png
BIN
res/about1.png
Binary file not shown.
|
Before Width: | Height: | Size: 903 KiB After Width: | Height: | Size: 846 KiB |
BIN
res/about2.png
Normal file
BIN
res/about2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 903 KiB |
BIN
res/close.png
Normal file
BIN
res/close.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 704 B |
Loading…
Reference in New Issue
Block a user