Commit 2dedd3a8 authored by 九江月's avatar 九江月

ocg filefetch pug

parent 6d65f5e9
No preview for this file type
This diff is collapsed.
......@@ -158,7 +158,7 @@ namespace cardvisa
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(75, 23);
this.button8.TabIndex = 11;
this.button8.Text = "拼图小游戏";
this.button8.Text = "更新器";
this.button8.UseVisualStyleBackColor = true;
this.button8.Click += new System.EventHandler(this.button8_Click);
//
......
......@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.Linq;
using System.Data.Linq.Mapping;
......@@ -14,6 +15,7 @@ using System.Dynamic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
......@@ -384,10 +386,46 @@ namespace cardvisa
//
*/
}
private void button8_Click(object sender, EventArgs e)
private async void button8_Click(object sender, EventArgs e)
{
PuzzleGame pzg = GenericSingleton<PuzzleGame>.CreateInstrance();
pzg.Show();
//PuzzleGame pzg = GenericSingleton<PuzzleGame>.CreateInstrance();
//pzg.Show();
string ygoroot = Path.GetDirectoryName(settings.ygopath);
string remoteroot = settings.url; //"https://cdn02.moecube.com:444/koishipro/contents/";
string filelistpath = ygoroot + "\\update-hakune\\filelist.txt";
if (!File.Exists(filelistpath)) {
CommonHandler.FetchFile(remoteroot, ygoroot, "filelist.txt");
CommonHandler.FetchFile(remoteroot, ygoroot, "cards.cdb");
}
else
{
string[] filesets = File.ReadAllLines(filelistpath);
for (int i = 0;i< filesets.Length; i++) {
string[] xxx = filesets[i].Split('\t');
string md5 = CommonHandler.GetMD5(ygoroot + "\\" + xxx[0].Replace('/', '\\'));
if (md5 != xxx[1] && (xxx[0].IndexOf("pics") >= 0 || xxx[0].IndexOf("script") >= 0))
{
using (var client = new HttpClient())
{
var res = await client.GetAsync(remoteroot + xxx[0]);
if (res.IsSuccessStatusCode)
{
using (var fs = File.Create(ygoroot + "\\update-hakune\\" + xxx[0].Replace('/', '\\')))
{
await res.Content.CopyToAsync(fs);
}
Console.WriteLine("File downloaded successfully.");
richTextBox1.Text += "\r\n" + xxx[0];
}
else
{
Console.WriteLine("Failed to download file.");
}
}
}
}
richTextBox1.Text += "\r\nMission complete.";
}
}
public void refreshlist()
{
......@@ -1483,6 +1521,9 @@ namespace cardvisa
{
try
{
if (!File.Exists(path)) {
return "#null-file-not-found";
}
using (FileStream fStream = new FileStream(path,System.IO.FileMode.Open))
{
MD5 md5 = new MD5CryptoServiceProvider();
......@@ -1492,7 +1533,7 @@ namespace cardvisa
{
sb.Append(retVal[i].ToString("X2"));
}
return sb.ToString();
return sb.ToString().ToLower();
}
}
catch (Exception ex)
......@@ -1545,6 +1586,29 @@ namespace cardvisa
}
}
}
public static async void FetchFile(string remoteroot, string ygoroot, string filename)
{
string filepath = ygoroot + "\\update-hakune\\" + filename.Replace('/','\\');
if (!File.Exists(filepath))
{
using (var client = new HttpClient())
{
var res = await client.GetAsync(remoteroot + (filename == "filelist.txt" ? "/update/filelist.txt" : filename));
if (res.IsSuccessStatusCode)
{
using (var fs = File.Create(filepath))
{
await res.Content.CopyToAsync(fs);
}
Console.WriteLine("File downloaded successfully.");
}
else
{
Console.WriteLine("Failed to download file.");
}
}
}
}
}
public class SqliteDataContext : DataContext
{
......@@ -1568,6 +1632,7 @@ namespace cardvisa
public class SettingData
{
public string ygopath { get; set; } = "";
public string url { get; set; } = "";
public bool pathcheck { get; set; } = false;
public bool packDIY { get; set; } = true;
public bool checkfiles { get; set; } = false;
......
This diff is collapsed.
{"ygopath":"D:\\MyCardLibrary\\ygopro\\ygopro.exe","pathcheck":false,"packDIY":true,"regs":null,"checkfiles": false}
\ No newline at end of file
{"ygopath":"C:\\MyCardLibrary\\ygopro\\ygopro.exe","pathcheck":false,"packDIY":true,"regs":null,"checkfiles": false,"url":"https://cdn02.moecube.com:444/koishipro/contents/"}
\ No newline at end of file
......@@ -122,12 +122,14 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FileHandle.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Moecraft.cs" />
<Compile Include="MyListBox.cs">
<SubType>Form</SubType>
</Compile>
......
82ee7007c2ed7a5765c90a144ea7ebd66d6b4faf830bf39b7baeaf603aeb3916
7ed4376bae93b6b0798a952a02914c98205c6b638f23432bf10b540a3b79d477
......@@ -57,3 +57,19 @@ E:\project\visa\cardvisa\cardvisa\obj\Debug\cardvisa.PuzzleGame.resources
E:\project\visa\cardvisa\cardvisa\obj\Debug\cardvisa.MyListBox.resources
C:\Users\Administrator\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.MyListBox.resources
C:\Users\Administrator\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.PuzzleGame.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.csproj.AssemblyReference.cache
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.Form1.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.MyListBox.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.PicViewer.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.Properties.Resources.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.PuzzleGame.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.csproj.GenerateResource.cache
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.csproj.CoreCompileInputs.cache
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.exe
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.pdb
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\lua54.dll
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\liblua54.dylib
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\liblua54.so
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\cardvisa.exe.config
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\cardvisa.exe
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\cardvisa.pdb
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment