Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-07 20:58:14 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-07 20:58:14 +0300
commite27869a38e7f1d310c5615220839e0c7f1414b6a (patch)
treeaa2b1a34c5c354c7f4c465899ce9d57892548a47
parentef067b9227b095b8a564ff09fe2c960363e9cac8 (diff)
Box art downloading
-rw-r--r--Apps/NesMiniApplication.cs1
-rw-r--r--Apps/SnesGame.cs55
-rw-r--r--MainForm.cs1
-rw-r--r--Properties/Resources.resx6
-rw-r--r--WorkerForm.cs7
5 files changed, 59 insertions, 11 deletions
diff --git a/Apps/NesMiniApplication.cs b/Apps/NesMiniApplication.cs
index 153629f9..24d953f4 100644
--- a/Apps/NesMiniApplication.cs
+++ b/Apps/NesMiniApplication.cs
@@ -21,6 +21,7 @@ namespace com.clusterrr.hakchi_gui
public static Image DefaultCover = Resources.blank_app;
public static Form ParentForm;
public static bool? NeedPatch;
+ public static bool? NeedAutoDownloadCover;
public static string GamesDirectory
{
diff --git a/Apps/SnesGame.cs b/Apps/SnesGame.cs
index 9980498f..4eac1e42 100644
--- a/Apps/SnesGame.cs
+++ b/Apps/SnesGame.cs
@@ -86,6 +86,14 @@ namespace com.clusterrr.hakchi_gui
public static bool Patch(string inputFileName, ref byte[] rawRomData, ref char prefix, ref string application, ref string outputFileName, ref string args, ref Image cover, ref byte saveCount, ref uint crc32)
{
+ var ext = Path.GetExtension(inputFileName);
+ if ((ext.ToLower() == ".smc") && ((rawRomData.Length % 1024) != 0))
+ {
+ var stripped = new byte[rawRomData.Length - 512];
+ Array.Copy(rawRomData, 512, stripped, 0, stripped.Length);
+ rawRomData = stripped;
+ crc32 = CRC32(rawRomData);
+ }
FindPatch(ref rawRomData, inputFileName, crc32);
if (inputFileName.Contains("(E)") || inputFileName.Contains("(J)"))
cover = Resources.blank_snes_eu_jp;
@@ -93,16 +101,8 @@ namespace com.clusterrr.hakchi_gui
{
application = "/bin/clover-canoe-shvc-wr -rom";
args = DefaultArgs;
- var ext = Path.GetExtension(inputFileName);
if (ext.ToLower() != ".sfrom") // Need to patch for canoe
{
- if ((ext.ToLower() == ".smc") && ((rawRomData.Length % 1024) != 0))
- {
- var stripped = new byte[rawRomData.Length - 512];
- Array.Copy(rawRomData, 512, stripped, 0, stripped.Length);
- rawRomData = stripped;
- crc32 = CRC32(rawRomData);
- }
Debug.WriteLine($"Trying to convert {inputFileName}");
MakeSfrom(ref rawRomData, ref saveCount);
outputFileName = Path.GetFileNameWithoutExtension(outputFileName) + ".sfrom";
@@ -439,6 +439,7 @@ namespace com.clusterrr.hakchi_gui
public string ReleaseDate;
public string Publisher;
public string Region;
+ public string CoverUrl;
}
public static void LoadCache()
@@ -484,6 +485,12 @@ namespace com.clusterrr.hakchi_gui
v = cartridge.Select("publisher");
if (v.MoveNext() && !string.IsNullOrEmpty(v.Current.Value))
info.Publisher = v.Current.Value;
+ v = cartridge.Select("region");
+ if (v.MoveNext() && !string.IsNullOrEmpty(v.Current.Value))
+ info.Region = v.Current.Value;
+ v = cartridge.Select("cover");
+ if (v.MoveNext() && !string.IsNullOrEmpty(v.Current.Value))
+ info.CoverUrl = v.Current.Value;
}
catch
{
@@ -514,6 +521,38 @@ namespace com.clusterrr.hakchi_gui
if (ReleaseDate.Length == 4) ReleaseDate += "-01";
if (ReleaseDate.Length == 7) ReleaseDate += "-01";
Publisher = gameinfo.Publisher.ToUpper();
+
+ if (!string.IsNullOrEmpty(gameinfo.CoverUrl))
+ {
+ if (NeedAutoDownloadCover != true)
+ {
+ if (NeedAutoDownloadCover != false)
+ {
+ var r = WorkerForm.MessageBoxFromThread(ParentForm,
+ string.Format(Resources.DownloadCoverQ, Name),
+ Resources.Cover,
+ MessageBoxButtons.AbortRetryIgnore,
+ MessageBoxIcon.Question,
+ MessageBoxDefaultButton.Button2, true);
+ if (r == DialogResult.Abort)
+ NeedPatch = true;
+ if (r == DialogResult.Ignore)
+ return true;
+ }
+ else return true;
+ }
+
+ try
+ {
+ var cover = ImageGooglerForm.DownloadImage(gameinfo.CoverUrl);
+ Image = cover;
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.Message + ex.StackTrace);
+ }
+ }
+
return true;
}
return false;
diff --git a/MainForm.cs b/MainForm.cs
index 5f949f77..a10b69f0 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -28,6 +28,7 @@ namespace com.clusterrr.hakchi_gui
public static IEnumerable<string> InternalMods;
public static ClovershellConnection Clovershell;
mooftpserv.Server ftpServer;
+ public static bool? DownloadCover;
static NesDefaultGame[] defaultNesGames = new NesDefaultGame[] {
new NesDefaultGame { Code = "CLV-P-NAAAE", Name = "Super Mario Bros.", Size = 571031 },
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
index c7d196bc..89643453 100644
--- a/Properties/Resources.resx
+++ b/Properties/Resources.resx
@@ -685,4 +685,10 @@
<data name="gamepad_SNES" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\images\gamepad_snes.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
+ <data name="Cover" xml:space="preserve">
+ <value>Box art</value>
+ </data>
+ <data name="DownloadCoverQ" xml:space="preserve">
+ <value>Do you want to try to download box art for "{0}"?</value>
+ </data>
</root> \ No newline at end of file
diff --git a/WorkerForm.cs b/WorkerForm.cs
index 81056349..b2b1d44a 100644
--- a/WorkerForm.cs
+++ b/WorkerForm.cs
@@ -845,7 +845,7 @@ namespace com.clusterrr.hakchi_gui
case MainForm.ConsoleType.SNES:
case MainForm.ConsoleType.SuperFamicom:
originalSyncCode = $"mkdir -p \"{rootFsPath}{gamesPath}/{originalGames[originalCode]}/{originalCode}/\" && " +
- $"rsync -ac \"{gamesPath}/{originalCode}/\" \"{rootFsPath}{gamesPath}/{originalGames[originalCode]}/{originalCode}/\" &&" +
+ $"rsync -ac \"{gamesPath}/{originalCode}/\" \"{rootFsPath}{gamesPath}/{originalGames[originalCode]}/{originalCode}/\" && " +
$"sed -i -e 's/\\/usr\\/bin\\/clover-canoe-shvc/\\/bin\\/clover-canoe-shvc-wr/g' \"{rootFsPath}{gamesPath}/{originalGames[originalCode]}/{originalCode}/{originalCode}.desktop\"";
/*
// With compression but very slow
@@ -1259,9 +1259,10 @@ namespace com.clusterrr.hakchi_gui
{
var apps = new List<NesMiniApplication>();
addedApplications = null;
- NesGame.ParentForm = this;
- NesGame.NeedPatch = null;
+ NesMiniApplication.ParentForm = this;
+ NesMiniApplication.NeedPatch = null;
NesGame.IgnoreMapper = null;
+ SnesGame.NeedAutoDownloadCover = null;
int count = 0;
SetStatus(Resources.AddingGames);
foreach (var sourceFileName in files)