Fix GimConv downloader
This commit is contained in:
parent
308edb6c3c
commit
6d72f4b5b0
|
@ -1,20 +1,20 @@
|
|||
using Ionic.Zip;
|
||||
using System;
|
||||
using Ionic.Zip;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
||||
namespace CXMLDecompiler
|
||||
{
|
||||
class GimConv
|
||||
namespace CXMLDecompiler
|
||||
{
|
||||
class GimConv
|
||||
{
|
||||
|
||||
public static string GIMCONV_FOLDER = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "GimConv");
|
||||
|
||||
static WebClient wc = new WebClient();
|
||||
static bool DownloadCompleted = true;
|
||||
|
||||
public static string GIMCONV_FOLDER = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "GimConv");
|
||||
|
||||
static WebClient wc = new WebClient();
|
||||
static bool DownloadCompleted = true;
|
||||
|
||||
public static void ConvertGimToPng(string inputGim, string outputGim)
|
||||
{
|
||||
if (HasGimConv())
|
||||
|
@ -36,63 +36,65 @@ namespace CXMLDecompiler
|
|||
Proc.WaitForExit();
|
||||
Console.Write(Proc.StandardOutput.ReadToEnd());
|
||||
}
|
||||
}
|
||||
}
|
||||
public static bool HasGimConv()
|
||||
{
|
||||
return File.Exists(Path.Combine(GIMCONV_FOLDER, "GimConv.exe"));
|
||||
}
|
||||
public static void DownloadGimConv()
|
||||
{
|
||||
wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
|
||||
wc.DownloadDataCompleted += Wc_DownloadDataCompleted;
|
||||
wc.DownloadDataAsync(new Uri("http://e1.dl.playstation.net/e1/downloads/ps3/themes/370/PS3_Custom_Theme_v200.zip")); // Thanks Sony :3
|
||||
while (wc.IsBusy || !DownloadCompleted) { };
|
||||
}
|
||||
|
||||
private static void Wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
|
||||
{
|
||||
if (e.Error != null)
|
||||
return;
|
||||
Console.Write("\r\n");
|
||||
MemoryStream zipStream = new MemoryStream(e.Result);
|
||||
ZipFile zip = ZipFile.Read(zipStream);
|
||||
foreach(ZipEntry zEntry in zip.Entries) // Read downloaded zip and extract stuff relating to GimConv .
|
||||
{
|
||||
string filename = Path.GetFileName(zEntry.FileName);
|
||||
if (filename == "msvcp71.dll" || filename == "msvcr71.dll" || zEntry.FileName.Contains("GimConv")) // if it is a required DLL or inside the GimConv folder
|
||||
{
|
||||
string outputFilename = zEntry.FileName;
|
||||
if (outputFilename.Contains("GimConv")) // if the filename is inside the GimConv folder
|
||||
outputFilename = outputFilename.Substring(outputFilename.IndexOf("GimConv") + "GimConv".Length); // Extract filename after the "GimConv/" part
|
||||
|
||||
outputFilename = outputFilename.Replace("/", "\\");
|
||||
outputFilename = Path.Combine(GIMCONV_FOLDER, outputFilename); // set output path to GimConv folder
|
||||
Console.WriteLine("Extracting: " + outputFilename);
|
||||
|
||||
// If folder is directory, create it
|
||||
if (zEntry.IsDirectory)
|
||||
{
|
||||
Directory.CreateDirectory(outputFilename);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Extract the file to output path
|
||||
FileStream fs = File.Open(outputFilename, FileMode.CreateNew, FileAccess.ReadWrite);
|
||||
zEntry.Extract(fs);
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
zip.Dispose();
|
||||
zipStream.Dispose();
|
||||
|
||||
File.AppendAllText(Path.Combine(GIMCONV_FOLDER, "GimConv.cfg"), "option -psvrgba8888 {\r\n format_endian = little\r\n format_style = psp\r\n image_format = rgba8888\r\n pixel_order = normal\r\n pixel_channel = rgba\r\n limit_image_width = 4096\r\n limit_image_height = 4096\r\n}\r\noption -psvindex4 {\r\n format_endian = little\r\n format_style = psp\r\n image_format = index4\r\n pixel_order = normal\r\n pixel_channel = rgba\r\n limit_image_width = 4096\r\n limit_image_height = 4096\r\n}\r\noption -psvindex8 {\r\n format_endian = little\r\n format_style = psp\r\n image_format = index8\r\n pixel_order = normal\r\n pixel_channel = rgba\r\n limit_image_width = 4096\r\n limit_image_height = 4096\r\n}");
|
||||
DownloadCompleted = true;
|
||||
}
|
||||
|
||||
private static void Wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
|
||||
{
|
||||
DownloadCompleted = false;
|
||||
Console.Write("\rDownloading GimConv Directly from Sony " + e.BytesReceived + "/" + e.TotalBytesToReceive + " - " + e.ProgressPercentage.ToString() + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void DownloadGimConv()
|
||||
{
|
||||
wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
|
||||
wc.DownloadDataCompleted += Wc_DownloadDataCompleted;
|
||||
wc.DownloadDataAsync(new Uri("http://e1.dl.playstation.net/e1/downloads/ps3/themes/370/PS3_Custom_Theme_v200.zip")); // Thanks Sony :3
|
||||
while (wc.IsBusy || !DownloadCompleted) { };
|
||||
}
|
||||
|
||||
private static void Wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
|
||||
{
|
||||
if (e.Error != null)
|
||||
return;
|
||||
Console.Write("\r\n");
|
||||
MemoryStream zipStream = new MemoryStream(e.Result);
|
||||
ZipFile zip = ZipFile.Read(zipStream);
|
||||
foreach(ZipEntry zEntry in zip.Entries) // Read downloaded zip and extract stuff relating to GimConv .
|
||||
{
|
||||
string filename = Path.GetFileName(zEntry.FileName);
|
||||
if (filename == "msvcp71.dll" || filename == "msvcr71.dll" || zEntry.FileName.Contains("GimConv")) // if it is a required DLL or inside the GimConv folder
|
||||
{
|
||||
string outputFilename = zEntry.FileName;
|
||||
if (outputFilename.Contains("GimConv")) // if the filename is inside the GimConv folder
|
||||
outputFilename = outputFilename.Substring(outputFilename.IndexOf("GimConv") + "GimConv".Length + 1); // Extract filename after the "GimConv/" part
|
||||
else
|
||||
outputFilename = Path.GetFileName(outputFilename);
|
||||
|
||||
outputFilename = outputFilename.Replace("/", "\\");
|
||||
outputFilename = Path.Combine(GIMCONV_FOLDER, outputFilename); // set output path to GimConv folder
|
||||
Console.WriteLine("Extracting: " + outputFilename);
|
||||
|
||||
// If folder is directory, create it
|
||||
if (zEntry.IsDirectory)
|
||||
{
|
||||
Directory.CreateDirectory(outputFilename);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Extract the file to output path
|
||||
FileStream fs = File.Open(outputFilename, FileMode.CreateNew, FileAccess.ReadWrite);
|
||||
zEntry.Extract(fs);
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
zip.Dispose();
|
||||
zipStream.Dispose();
|
||||
|
||||
File.AppendAllText(Path.Combine(GIMCONV_FOLDER, "GimConv.cfg"), "option -psvrgba8888 {\r\n format_endian = little\r\n format_style = psp\r\n image_format = rgba8888\r\n pixel_order = normal\r\n pixel_channel = rgba\r\n limit_image_width = 4096\r\n limit_image_height = 4096\r\n}\r\noption -psvindex4 {\r\n format_endian = little\r\n format_style = psp\r\n image_format = index4\r\n pixel_order = normal\r\n pixel_channel = rgba\r\n limit_image_width = 4096\r\n limit_image_height = 4096\r\n}\r\noption -psvindex8 {\r\n format_endian = little\r\n format_style = psp\r\n image_format = index8\r\n pixel_order = normal\r\n pixel_channel = rgba\r\n limit_image_width = 4096\r\n limit_image_height = 4096\r\n}");
|
||||
DownloadCompleted = true;
|
||||
}
|
||||
|
||||
private static void Wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
|
||||
{
|
||||
DownloadCompleted = false;
|
||||
Console.Write("\rDownloading GimConv Directly from Sony " + e.BytesReceived + "/" + e.TotalBytesToReceive + " - " + e.ProgressPercentage.ToString() + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyTitle("CXML Decompiler")]
|
||||
[assembly: AssemblyDescription("CXML Decompiler & Compiler")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("SilicaAndPina Inc")]
|
||||
[assembly: AssemblyCompany("Li")]
|
||||
[assembly: AssemblyProduct("CXML Decompiler")]
|
||||
[assembly: AssemblyCopyright("Public Domain © 2021")]
|
||||
[assembly: AssemblyTrademark("CXML Decompiler is not a trademark of SilicaAndPina Inc")]
|
||||
[assembly: AssemblyCopyright("Public Domain © 2022")]
|
||||
[assembly: AssemblyTrademark("CXML Decompiler is not a trademark of Li Inc")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
|
|
Loading…
Reference in New Issue