diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-02-27 21:47:58 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-02-27 21:47:58 +0300 |
commit | 3990def525e77466768a87436dfe5cb7c2dbf634 (patch) | |
tree | 01f6407cc425c9e2398ddd26e61ea58c3e6781e0 /Apps | |
parent | b471b9e755119e7495b62f82701e10c37cedcd02 (diff) |
Minor fixes
Diffstat (limited to 'Apps')
-rw-r--r-- | Apps/FdsGame.cs | 4 | ||||
-rw-r--r-- | Apps/NesGame.cs | 6 | ||||
-rw-r--r-- | Apps/NesMiniApplication.cs | 40 | ||||
-rw-r--r-- | Apps/SnesGame.cs | 2 |
4 files changed, 38 insertions, 14 deletions
diff --git a/Apps/FdsGame.cs b/Apps/FdsGame.cs index 1a32ed39..acb656c1 100644 --- a/Apps/FdsGame.cs +++ b/Apps/FdsGame.cs @@ -41,7 +41,7 @@ namespace com.clusterrr.hakchi_gui Args = Args; // To update exec path if need
}
- public static FdsGame Import(string fdsFileName, byte[] rawRomData = null)
+ public static FdsGame Import(string fdsFileName, string sourceFileName, byte[] rawRomData = null)
{
if (rawRomData == null)
rawRomData = File.ReadAllBytes(fdsFileName);
@@ -63,7 +63,7 @@ namespace com.clusterrr.hakchi_gui game.Name = Regex.Replace(game.Name, @" ?\(.*?\)", string.Empty).Trim();
game.Name = Regex.Replace(game.Name, @" ?\[.*?\]", string.Empty).Trim();
game.Name = game.Name.Replace("_", " ").Replace(" ", " ").Trim();
- game.FindCover(fdsFileName, Resources.blank_fds, crc32);
+ game.FindCover(fdsFileName, sourceFileName, Resources.blank_fds, crc32);
game.Args = DefaultArgs;
game.Save();
return game;
diff --git a/Apps/NesGame.cs b/Apps/NesGame.cs index 187cc89c..cebcbd28 100644 --- a/Apps/NesGame.cs +++ b/Apps/NesGame.cs @@ -76,7 +76,7 @@ namespace com.clusterrr.hakchi_gui Args = Args; // To update exec path if need
}
- public static NesMiniApplication Import(string nesFileName, bool? ignoreMapper, ref bool? needPatch, NeedPatchDelegate needPatchCallback = null, Form parentForm = null, byte[] rawRomData = null)
+ public static NesMiniApplication Import(string nesFileName, string sourceFileName, bool? ignoreMapper, ref bool? needPatch, NeedPatchDelegate needPatchCallback = null, Form parentForm = null, byte[] rawRomData = null)
{
NesFile nesFile;
try
@@ -88,7 +88,7 @@ namespace com.clusterrr.hakchi_gui }
catch
{
- return NesMiniApplication.Import(nesFileName, rawRomData);
+ return NesMiniApplication.Import(nesFileName, sourceFileName, rawRomData);
}
nesFile.CorrectRom();
var crc32 = nesFile.CRC32;
@@ -151,7 +151,7 @@ namespace com.clusterrr.hakchi_gui game.Name = Regex.Replace(game.Name, @" ?\(.*?\)", string.Empty).Trim();
game.Name = Regex.Replace(game.Name, @" ?\[.*?\]", string.Empty).Trim();
game.Name = game.Name.Replace("_", " ").Replace(" ", " ");
- game.FindCover(nesFileName, (game.region == "Japan") ? Resources.blank_jp : Resources.blank_nes, crc32);
+ game.FindCover(nesFileName, sourceFileName, (game.region == "Japan") ? Resources.blank_jp : Resources.blank_nes, crc32);
game.Args = DefaultArgs;
game.Save();
return game;
diff --git a/Apps/NesMiniApplication.cs b/Apps/NesMiniApplication.cs index 2f2f9c8f..f80ff69e 100644 --- a/Apps/NesMiniApplication.cs +++ b/Apps/NesMiniApplication.cs @@ -1,6 +1,8 @@ using com.clusterrr.hakchi_gui.Properties;
using SevenZip;
using System;
+using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
@@ -126,7 +128,7 @@ namespace com.clusterrr.hakchi_gui return new NesMiniApplication(path, ignoreEmptyConfig);
}
- public static NesMiniApplication Import(string fileName, byte[] rawRomData = null)
+ public static NesMiniApplication Import(string fileName, string sourceFile = null, byte[] rawRomData = null)
{
var extension = Path.GetExtension(fileName).ToLower();
if (extension == ".desktop")
@@ -136,17 +138,17 @@ namespace com.clusterrr.hakchi_gui var appinfo = AppTypeCollection.GetAppByExtension(extension);
if (appinfo != null)
{
- var import = appinfo.Class.GetMethod("Import", new Type[] { typeof(string), typeof(byte[]) });
+ var import = appinfo.Class.GetMethod("Import", new Type[] { typeof(string), typeof(string), typeof(byte[]) });
if (import != null)
- return (NesMiniApplication)import.Invoke(null, new object[] { fileName, rawRomData });
+ return (NesMiniApplication)import.Invoke(null, new object[] { fileName, sourceFile, rawRomData });
else
- return Import(fileName, rawRomData, appinfo.Prefix, appinfo.DefaultApp, appinfo.DefaultCover, ConfigIni.Compress);
+ return Import(fileName, sourceFile, rawRomData, appinfo.Prefix, appinfo.DefaultApp, appinfo.DefaultCover, ConfigIni.Compress);
}
string application = extension.Length > 2 ? ("/bin/" + extension.Substring(1)) : DefaultApp;
- return Import(fileName, rawRomData, DefaultPrefix, application, DefaultCover);
+ return Import(fileName, sourceFile, rawRomData, DefaultPrefix, application, DefaultCover);
}
- private static NesMiniApplication Import(string fileName, byte[] rawRomData, char prefixCode, string application, Image defaultCover, bool compress = false)
+ private static NesMiniApplication Import(string fileName, string sourceFile, byte[] rawRomData, char prefixCode, string application, Image defaultCover, bool compress = false)
{
var crc32 = CRC32(rawRomData);
var code = GenerateCode(crc32, prefixCode);
@@ -191,7 +193,7 @@ namespace com.clusterrr.hakchi_gui game.Name = Regex.Replace(game.Name, @" ?\(.*?\)", string.Empty).Trim();
game.Name = Regex.Replace(game.Name, @" ?\[.*?\]", string.Empty).Trim();
game.Name = game.Name.Replace("_", " ").Replace(" ", " ").Trim();
- game.FindCover(fileName, defaultCover, crc32);
+ game.FindCover(fileName, sourceFile, defaultCover, crc32);
game.Command = string.Format("{0} /usr/share/games/nes/kachikachi/{1}/{2}", application, code, romName);
game.Save();
return NesMiniApplication.FromDirectory(gamePath);
@@ -353,12 +355,21 @@ namespace com.clusterrr.hakchi_gui outImageSmall.Save(SmallIconPath, ImageFormat.Png);
}
- internal bool FindCover(string romFileName, Image defaultCover, uint crc32 = 0)
+ internal bool FindCover(string romFileName, string sourceFileName, Image defaultCover, uint crc32 = 0)
{
// Trying to find cover file
Image cover = null;
if (!string.IsNullOrEmpty(romFileName))
{
+ if (!string.IsNullOrEmpty(sourceFileName) && sourceFileName != romFileName)
+ {
+ var archImagePath = Path.Combine(Path.GetDirectoryName(sourceFileName), Path.GetFileNameWithoutExtension(romFileName) + ".png");
+ if (File.Exists(archImagePath))
+ cover = LoadBitmap(archImagePath);
+ archImagePath = Path.Combine(Path.GetDirectoryName(sourceFileName), Path.GetFileNameWithoutExtension(romFileName) + ".jpg");
+ if (File.Exists(archImagePath))
+ cover = LoadBitmap(archImagePath);
+ }
var imagePath = Path.Combine(Path.GetDirectoryName(romFileName), Path.GetFileNameWithoutExtension(romFileName) + ".png");
if (File.Exists(imagePath))
cover = LoadBitmap(imagePath);
@@ -531,6 +542,19 @@ namespace com.clusterrr.hakchi_gui arch.Read(result, 0, result.Length);
return result;
}
+
+ public class NesMiniAppEqualityComparer : IEqualityComparer<NesMiniApplication>
+ {
+ public bool Equals(NesMiniApplication x, NesMiniApplication y)
+ {
+ return x.Code == y.Code;
+ }
+
+ public int GetHashCode(NesMiniApplication obj)
+ {
+ return obj.Code.GetHashCode();
+ }
+ }
}
}
diff --git a/Apps/SnesGame.cs b/Apps/SnesGame.cs index c5048786..2ff7cb99 100644 --- a/Apps/SnesGame.cs +++ b/Apps/SnesGame.cs @@ -10,7 +10,7 @@ namespace com.clusterrr.hakchi_gui {
get
{
- return "(snes | super famicom)";
+ return "(snes | super nintendo)";
}
}
|