Unverified Commit bee128e7 authored by piratesephiroth's avatar piratesephiroth Committed by GitHub
Browse files

Merge pull request #30 from amynbe/try-more-alternative-images

Try more alternative images
parents e6a2b08a e5e351ee
......@@ -16,6 +16,12 @@
<setting name="GameFilePath" serializeAs="String">
<value />
</setting>
<setting name="OutputPathFixed" serializeAs="String">
<value />
</setting>
<setting name="BannersRepository" serializeAs="String">
<value>https://raw.githubusercontent.com/cucholix/wiivc-bis/master/</value>
</setting>
</TeconMoon_s_WiiVC_Injector.Properties.Settings>
</userSettings>
<runtime>
......@@ -24,6 +30,10 @@
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
......@@ -116,7 +116,8 @@
this.TitleKey = new System.Windows.Forms.TextBox();
this.RHFKeyLabel = new System.Windows.Forms.Label();
this.CommonLabel = new System.Windows.Forms.Label();
this.WiiUCommonKey = new System.Windows.Forms.TextBox();
this.WiiUCommonKey = new System.Windows.Forms.TextBox();
this.SettingsButton = new System.Windows.Forms.Button();
this.SDCardStuff = new System.Windows.Forms.Button();
this.GCRetail = new System.Windows.Forms.RadioButton();
this.WiiNAND = new System.Windows.Forms.RadioButton();
......@@ -151,6 +152,7 @@
this.MainTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.MainTableLayout.Controls.Add(this.WiiRetail, 0, 0);
this.MainTableLayout.Controls.Add(this.MainTabs, 0, 2);
this.MainTableLayout.Controls.Add(this.SettingsButton, 1, 1);
this.MainTableLayout.Controls.Add(this.SDCardStuff, 2, 1);
this.MainTableLayout.Controls.Add(this.GCRetail, 2, 0);
this.MainTableLayout.Controls.Add(this.WiiNAND, 0, 1);
......@@ -1196,6 +1198,16 @@
this.WiiUCommonKey.Size = new System.Drawing.Size(288, 20);
this.WiiUCommonKey.TabIndex = 0;
//
// SettingsButton
//
this.SettingsButton.Location = new System.Drawing.Point(164, 28);
this.SettingsButton.Name = "SettingsButton";
this.SettingsButton.Size = new System.Drawing.Size(157, 19);
this.SettingsButton.TabIndex = 5;
this.SettingsButton.Text = "Settings";
this.SettingsButton.UseVisualStyleBackColor = true;
this.SettingsButton.Click += new System.EventHandler(this.SettingsButton_Click);
//
// SDCardStuff
//
this.SDCardStuff.Location = new System.Drawing.Point(325, 28);
......@@ -1414,6 +1426,7 @@
private System.Windows.Forms.ProgressBar BuildProgress;
private System.Windows.Forms.Label BuildStatus;
private System.Windows.Forms.Label AdvanceCheck;
private System.Windows.Forms.Button SettingsButton;
private System.Windows.Forms.Button SDCardStuff;
private System.Windows.Forms.Label GC2SourceDirectory;
private System.Windows.Forms.Button GC2SourceButton;
......
......@@ -174,16 +174,17 @@ namespace TeconMoon_s_WiiVC_Injector
IconSourceDirectory.Text = "Icon file has not been specified";
BannerSourceDirectory.Text = "Banner file has not been specified";
}
public void DownloadFromRepo()
public void DownloadFromRepo(string cucholixRepoID)
{
var client = new WebClient();
IconPreviewBox.Load("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID + "/iconTex.png");
IconPreviewBox.Load(Properties.Settings.Default.BannersRepository + SystemType + "/image/" + cucholixRepoID + "/iconTex.png");
if (File.Exists(Path.GetTempPath() + "WiiVCInjector\\SOURCETEMP\\iconTex.png")) { File.Delete(Path.GetTempPath() + "WiiVCInjector\\SOURCETEMP\\iconTex.png"); }
client.DownloadFile(IconPreviewBox.ImageLocation, Path.GetTempPath() + "WiiVCInjector\\SOURCETEMP\\iconTex.png");
IconSourceDirectory.Text = "iconTex.png downloaded from Cucholix's Repo";
IconSourceDirectory.ForeColor = Color.Black;
FlagIconSpecified = true;
BannerPreviewBox.Load("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID + "/bootTvTex.png");
BannerPreviewBox.Load(Properties.Settings.Default.BannersRepository + SystemType + "/image/" + cucholixRepoID + "/bootTvTex.png");
if (File.Exists(Path.GetTempPath() + "WiiVCInjector\\SOURCETEMP\\bootTvTex.png")) { File.Delete(Path.GetTempPath() + "WiiVCInjector\\SOURCETEMP\\bootTvTex.png"); }
client.DownloadFile(BannerPreviewBox.ImageLocation, Path.GetTempPath() + "WiiVCInjector\\SOURCETEMP\\bootTvTex.png");
BannerSourceDirectory.Text = "bootTvTex.png downloaded from Cucholix's Repo";
......@@ -493,6 +494,13 @@ namespace TeconMoon_s_WiiVC_Injector
Force43NAND.Enabled = false;
}
}
private void SettingsButton_Click(object sender, EventArgs e)
{
using (var settingsForm = new SettingsForm())
{
settingsForm.ShowDialog(this);
}
}
private void SDCardStuff_Click(object sender, EventArgs e)
{
new SDCardMenu().Show();
......@@ -806,7 +814,8 @@ namespace TeconMoon_s_WiiVC_Injector
goto EndOfGameSelection;
}
GameNameLabel.Text = InternalGameName;
PackedTitleLine1.Text = InternalGameName;
var GameTitle = StringUtil.RemoveSpecialChars(GameTdb.GetName(CucholixRepoID));
PackedTitleLine1.Text = !string.IsNullOrEmpty(GameTitle) ? GameTitle : InternalGameName;
//Convert pulled Title ID Int to Hex for use with Wii U Title ID
idBytes = BitConverter.GetBytes(TitleIDInt);
if (!BitConverter.IsLittleEndian)
......@@ -844,6 +853,7 @@ namespace TeconMoon_s_WiiVC_Injector
}
EndOfGameSelection:;
}
private void IconSourceButton_Click(object sender, EventArgs e)
{
if (FlagRepo)
......@@ -964,78 +974,36 @@ namespace TeconMoon_s_WiiVC_Injector
}
else
{
if (SystemType == "wiiware")
if (!TryDownloadImages(CucholixRepoID))
{
if (RemoteFileExists("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID + "/iconTex.png") == true)
{
DownloadFromRepo();
}
else if (RemoteFileExists("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID.Substring(0, 3) + "E" + "/iconTex.png") == true)
FlagRepo = false;
if (MessageBox.Show("Cucholix's Repo does not have assets for your game. You will need to provide your own. Would you like to visit the GBAtemp request thread?"
, "Game not found on Repo"
, MessageBoxButtons.YesNo
, MessageBoxIcon.Asterisk
, MessageBoxDefaultButton.Button1,
(MessageBoxOptions)0x40000) == DialogResult.Yes)
{
CucholixRepoID = CucholixRepoID.Substring(0, 3) + "E";
DownloadFromRepo();
}
else if (RemoteFileExists("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID.Substring(0, 3) + "P" + "/iconTex.png") == true)
{
CucholixRepoID = CucholixRepoID.Substring(0, 3) + "P";
DownloadFromRepo();
}
else if (RemoteFileExists("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID.Substring(0, 3) + "J" + "/iconTex.png") == true)
{
CucholixRepoID = CucholixRepoID.Substring(0, 3) + "J";
DownloadFromRepo();
}
else
{
FlagRepo = false;
if (MessageBox.Show("Cucholix's Repo does not have assets for your game. You will need to provide your own. Would you like to visit the GBAtemp request thread?"
, "Game not found on Repo"
, MessageBoxButtons.YesNo
, MessageBoxIcon.Asterisk
, MessageBoxDefaultButton.Button1,
(MessageBoxOptions)0x40000) == DialogResult.Yes)
{
System.Diagnostics.Process.Start("https://gbatemp.net/threads/483080/");
}
Process.Start("https://gbatemp.net/threads/483080/");
}
}
else
}
}
private bool TryDownloadImages(string cucholixRepoID)
{
IEnumerable<string> ids = GameTdb.GetAlternativeIds(cucholixRepoID);
foreach (var id in ids)
{
if (RemoteFileExists(Properties.Settings.Default.BannersRepository + SystemType + "/image/" + id + "/iconTex.png"))
{
if (RemoteFileExists("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID + "/iconTex.png") == true)
{
DownloadFromRepo();
}
else if (RemoteFileExists("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID.Substring(0, 3) + "E" + CucholixRepoID.Substring(4, 2) + "/iconTex.png") == true)
{
CucholixRepoID = CucholixRepoID.Substring(0, 3) + "E" + CucholixRepoID.Substring(4, 2);
DownloadFromRepo();
}
else if (RemoteFileExists("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID.Substring(0, 3) + "P" + CucholixRepoID.Substring(4, 2) + "/iconTex.png") == true)
{
CucholixRepoID = CucholixRepoID.Substring(0, 3) + "P" + CucholixRepoID.Substring(4, 2);
DownloadFromRepo();
}
else if (RemoteFileExists("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/" + SystemType + "/image/" + CucholixRepoID.Substring(0, 3) + "J" + CucholixRepoID.Substring(4, 2) + "/iconTex.png") == true)
{
CucholixRepoID = CucholixRepoID.Substring(0, 3) + "J" + CucholixRepoID.Substring(4, 2);
DownloadFromRepo();
}
else
{
FlagRepo = false;
if (MessageBox.Show("Cucholix's Repo does not have assets for your game. You will need to provide your own. Would you like to visit the GBAtemp request thread?"
, "Game not found on Repo"
, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk
, MessageBoxDefaultButton.Button1
, (MessageBoxOptions)0x40000) == DialogResult.Yes)
{
System.Diagnostics.Process.Start("https://gbatemp.net/threads/483080/");
}
}
DownloadFromRepo(id);
return true;
}
}
return false;
}
//Events for the "Optional Source Files" Tab
private void GC2SourceButton_Click(object sender, EventArgs e)
......@@ -1691,29 +1659,36 @@ namespace TeconMoon_s_WiiVC_Injector
}
}
var outputFolderSelect = new CommonOpenFileDialog("Specify your output folder")
if (!string.IsNullOrEmpty(Properties.Settings.Default.OutputPathFixed))
{
InitialDirectory = Properties.Settings.Default.OutputPath,
IsFolderPicker = true,
EnsurePathExists = true
};
//Specify Path Variables to be called later
if (outputFolderSelect.ShowDialog() == CommonFileDialogResult.Cancel)
selectedOutputPath = Properties.Settings.Default.OutputPathFixed;
}
else
{
MessageBox.Show("Output folder selection has been cancelled, conversion will not continue."
, "Cancelled"
, MessageBoxButtons.OK
, MessageBoxIcon.Warning
, MessageBoxDefaultButton.Button1
, (MessageBoxOptions)0x40000);
MainTabs.Enabled = true;
goto BuildProcessFin;
var outputFolderSelect = new CommonOpenFileDialog("Specify your output folder")
{
InitialDirectory = Properties.Settings.Default.OutputPath,
IsFolderPicker = true,
EnsurePathExists = true
};
//Specify Path Variables to be called later
if (outputFolderSelect.ShowDialog() == CommonFileDialogResult.Cancel)
{
MessageBox.Show("Output folder selection has been cancelled, conversion will not continue."
, "Cancelled"
, MessageBoxButtons.OK
, MessageBoxIcon.Warning
, MessageBoxDefaultButton.Button1
, (MessageBoxOptions)0x40000);
MainTabs.Enabled = true;
goto BuildProcessFin;
}
selectedOutputPath = outputFolderSelect.FileName;
Properties.Settings.Default.OutputPath = selectedOutputPath;
Properties.Settings.Default.Save();
}
BuildProgress.Value = 2;
selectedOutputPath = outputFolderSelect.FileName;
Properties.Settings.Default.OutputPath = selectedOutputPath;
Properties.Settings.Default.Save();
//////////////////////////
//Download base files with JNUSTool, store them for future use
......@@ -2197,7 +2172,8 @@ namespace TeconMoon_s_WiiVC_Injector
BuildStatus.Text = "Encrypting contents into installable WUP Package...";
BuildStatus.Refresh();
Directory.SetCurrentDirectory(TempRootPath);
string outputPath = selectedOutputPath + "\\WUP-N-" + TitleIDText + "_" + PackedTitleIDLine.Text;
string sanitizedGameName = SanitizeFilename(PackedTitleLine1.Text);
string outputPath = selectedOutputPath + "\\" + sanitizedGameName + " WUP-N-" + TitleIDText + "_" + PackedTitleIDLine.Text;
LauncherExeFile = TempToolsPath + "JAR\\NUSPacker.exe";
LauncherExeArgs = "-in BUILDDIR -out \"" + outputPath + "\" -encryptKeyWith " + WiiUCommonKey.Text;
LaunchProgram();
......@@ -2240,6 +2216,12 @@ namespace TeconMoon_s_WiiVC_Injector
/////
}
private string SanitizeFilename(string str)
{
var invalids = Path.GetInvalidFileNameChars();
return string.Join("_", str.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
}
private static string GetMD5Checksum(string file)
{
using (FileStream stream = File.OpenRead(file))
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TeconMoon_s_WiiVC_Injector.Properties;
using static TeconMoon_s_WiiVC_Injector.StringUtil;
namespace TeconMoon_s_WiiVC_Injector
{
public class GameTdb
{
public static string GetName(string id)
{
var assembly = Assembly.GetExecutingAssembly();
var wiitdb = "TeconMoon_s_WiiVC_Injector.Resources.wiitdb.txt";
using (var stream = assembly.GetManifestResourceStream(wiitdb))
using (var reader = new StreamReader(stream))
{
string line;
while ((line = reader.ReadLine()) != null)
{
var split = line.Split(new[] { " = " }, 2, StringSplitOptions.None);
if (split[0] == id)
return split[1];
}
return null;
}
}
public static List<string> GetIds(string name)
{
var assembly = Assembly.GetExecutingAssembly();
var wiitdb = "TeconMoon_s_WiiVC_Injector.Resources.wiitdb.txt";
using (var stream = assembly.GetManifestResourceStream(wiitdb))
using (var reader = new StreamReader(stream))
{
var ids = new List<string>();
string line;
while ((line = reader.ReadLine()) != null)
{
var split = line.Split(new[] { " = " }, 2, StringSplitOptions.None);
if (split[1] == name)
ids.Add(split[0]);
}
return ids;
}
}
public static List<string> GetIdsStartingWith(string idStart)
{
var assembly = Assembly.GetExecutingAssembly();
var wiitdb = "TeconMoon_s_WiiVC_Injector.Resources.wiitdb.txt";
using (var stream = assembly.GetManifestResourceStream(wiitdb))
using (var reader = new StreamReader(stream))
{
var ids = new List<string>();
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.StartsWith("TITLES ="))
continue;
var split = line.Split(new[] { " = " }, 2, StringSplitOptions.None);
if (split[0].StartsWith(idStart))
ids.Add(split[0]);
// Gametdb titles are ordered alphabetically by id, so stop searching
if (string.Compare(idStart, split[0].Substring(0, idStart.Length)) < 0)
break;
}
return ids;
}
}
internal static IEnumerable<string> GetAlternativeIds(string initialId)
{
var tried = new HashSet<string>
{
initialId,
initialId.ReplaceAt(3, 'E'),
initialId.ReplaceAt(3, 'P'),
// don't try Japanese just yet
// (e.g. don't want Pandora's Tower SX3J01 before SX3EXJ)
};
foreach(var id in tried)
{
yield return id;
}
var gameName = GetName(initialId);
var ids = GetIds(gameName)
.Where(id => !tried.Contains(id));
foreach(var id in ids)
{
yield return id;
}
tried.UnionWith(ids);
// as last resort, try a match on only the 3 first characters of
// the key (e.g. for Obscure 2)
var moreIds = GetIdsStartingWith(initialId.Substring(0, 3))
.Where(id => !tried.Contains(id));
foreach (var id in moreIds)
{
yield return id;
}
}
}
}
......@@ -19,7 +19,7 @@ namespace TeconMoon_s_WiiVC_Injector.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
......@@ -69,5 +69,26 @@ namespace TeconMoon_s_WiiVC_Injector.Properties {
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized string similar to TITLES = https://www.gametdb.com (type: Wii language: ORIG version: 20230426014834)
///007E01 = Wii Auto Erase Disc
///091E00 = Movie-Ch Install Disc Ver. A
///23EE41 = Just Dance 2023 Wii Edition
///410E01 = Wii Backup Disc v1.31
///413E01 = DiscUpdate Disc
///D2AJAF = みんなで冒険!ファミリートレーナー 体験版
///D2SE18 = Deca Sports 2 (Demo)
///D3DE18 = Deca Sports 3 (Demo)
///DASE4Q = Disney Epic Mickey (Demo)
///DAUEPZ = Country Dance (Demo)
///DAVE01 = Mystery Case Files: The Malgrave Incident (Demo)
///DAXE01 = The Legend of Zelda: Skyward Swor [rest of string was truncated]&quot;;.
/// </summary>
internal static string wiitdb {
get {
return ResourceManager.GetString("wiitdb", resourceCulture);
}
}
}
}
......@@ -121,4 +121,7 @@
<data name="TOOLDIR" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\TOOLDIR.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="wiitdb" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\wiitdb.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
\ No newline at end of file
......@@ -12,7 +12,7 @@ namespace TeconMoon_s_WiiVC_Injector.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
......@@ -46,5 +46,29 @@ namespace TeconMoon_s_WiiVC_Injector.Properties {
this["GameFilePath"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string OutputPathFixed {
get {
return ((string)(this["OutputPathFixed"]));
}
set {
this["OutputPathFixed"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://raw.githubusercontent.com/cucholix/wiivc-bis/master/")]
public string BannersRepository {
get {
return ((string)(this["BannersRepository"]));
}
set {
this["BannersRepository"] = value;
}
}
}
}
......@@ -8,5 +8,11 @@
<Setting Name="GameFilePath" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="OutputPathFixed" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="BannersRepository" Type="System.String" Scope="User">
<Value Profile="(Default)">https://raw.githubusercontent.com/cucholix/wiivc-bis/master/</Value>
</Setting>
</Settings>
</SettingsFile>
\ No newline at end of file
This diff is collapsed.
using TeconMoon_s_WiiVC_Injector.Properties;
namespace TeconMoon_s_WiiVC_Injector
{
partial class SettingsForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.BannersRepositoryLabel = new System.Windows.Forms.Label();
this.BannersRepository = new System.Windows.Forms.TextBox();
this.OutputDirLabel = new System.Windows.Forms.Label();
this.OutputDir = new System.Windows.Forms.TextBox();
this.OutputDirButton = new System.Windows.Forms.Button();
this.OkButton = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// BannersRepositoryLabel
//
this.BannersRepositoryLabel.Location = new System.Drawing.Point(12, 9);
this.BannersRepositoryLabel.Name = "BannersRepositoryLabel";
this.BannersRepositoryLabel.Size = new System.Drawing.Size(118, 16);
this.BannersRepositoryLabel.TabIndex = 0;
this.BannersRepositoryLabel.Text = "Banners Repository";
//
// BannersRepository
//
this.BannersRepository.Location = new System.Drawing.Point(12, 28);
this.BannersRepository.Name = "BannersRepository";
this.BannersRepository.Size = new System.Drawing.Size(345, 20);
this.BannersRepository.TabIndex = 1;
this.BannersRepository.Text = global::TeconMoon_s_WiiVC_Injector.Properties.Settings.Default.BannersRepository;
//
// OutputDirLabel
//
this.OutputDirLabel.Location = new System.Drawing.Point(12, 60);
this.OutputDirLabel.Name = "OutputDirLabel";
this.OutputDirLabel.Size = new System.Drawing.Size(262, 15);
this.OutputDirLabel.TabIndex = 2;
this.OutputDirLabel.Text = "Output Directory (leave empty to always ask)";
//
// OutputDir
//
this.OutputDir.Location = new System.Drawing.Point(12, 78);
this.OutputDir.Name = "OutputDir";
this.OutputDir.Size = new System.Drawing.Size(255, 20);
this.OutputDir.TabIndex = 3;
this.OutputDir.Text = global::TeconMoon_s_WiiVC_Injector.Properties.Settings.Default.OutputPathFixed;
//
// OutputDirButton
//
this.OutputDirButton.Location = new System.Drawing.Point(273, 74);
this.OutputDirButton.Name = "OutputDirButton";
this.OutputDirButton.Size = new System.Drawing.Size(84, 26);
this.OutputDirButton.TabIndex = 4;
this.OutputDirButton.Text = "Browse...";
this.OutputDirButton.UseVisualStyleBackColor = false;
this.OutputDirButton.Click += new System.EventHandler(this.OutputDirButton_Click);
//
// OkButton
//
this.OkButton.Location = new System.Drawing.Point(183, 257);
this.OkButton.Name = "OkButton";
this.OkButton.Size = new System.Drawing.Size(84, 26);
this.OkButton.TabIndex = 5;
this.OkButton.Text = "OK";
this.OkButton.UseVisualStyleBackColor = false;
this.OkButton.Click += new System.EventHandler(this.OkButton_Click);
//
// Cancel
//
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(273, 257);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(84, 26);
this.Cancel.TabIndex = 6;
this.Cancel.Text = "Cancel";
this.Cancel.UseVisualStyleBackColor = false;
//
// SettingsForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(369, 295);
this.Controls.Add(this.OutputDirLabel);
this.Controls.Add(this.OutputDir);
this.Controls.Add(this.BannersRepositoryLabel);
this.Controls.Add(this.BannersRepository);
this.Controls.Add(this.OutputDirButton);
this.Controls.Add(this.OkButton);
this.Controls.Add(this.Cancel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Margin = new System.Windows.Forms.Padding(4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SettingsForm";
this.ShowInTaskbar = false;
this.Text = "Application Settings";
this.Load += new System.EventHandler(this.SettingsForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label BannersRepositoryLabel;
private System.Windows.Forms.TextBox BannersRepository;
private System.Windows.Forms.Label OutputDirLabel;
private System.Windows.Forms.TextBox OutputDir;
private System.Windows.Forms.Button OutputDirButton;
private System.Windows.Forms.Button OkButton;
private System.Windows.Forms.Button Cancel;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Diagnostics;
using TeconMoon_s_WiiVC_Injector.Properties;
using Microsoft.WindowsAPICodePack.Dialogs;
namespace TeconMoon_s_WiiVC_Injector
{
public partial class SettingsForm : Form
{
public SettingsForm()
{
InitializeComponent();
}
//Load Drives and set drive variable on load
private void SettingsForm_Load(object sender, EventArgs e)
{
BannersRepository.Text = Settings.Default.BannersRepository;
}
private void OkButton_Click(object sender, EventArgs e)
{
Settings.Default.BannersRepository = BannersRepository.Text;
Settings.Default.OutputPathFixed = OutputDir.Text;
Settings.Default.Save();
Close();
}
private void OutputDirButton_Click(object sender, EventArgs e)
{
var outputFolderSelect = new CommonOpenFileDialog("Specify your output folder")
{
InitialDirectory = Settings.Default.OutputPath,
IsFolderPicker = true,
EnsurePathExists = true
};
//Specify Path Variables to be called later
if (outputFolderSelect.ShowDialog() == CommonFileDialogResult.Ok)
{
OutputDir.Text = outputFolderSelect.FileName;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TeconMoon_s_WiiVC_Injector.Properties;
namespace TeconMoon_s_WiiVC_Injector
{
public static class StringUtil
{
public static string RemoveSpecialChars(string v)
{
if (string.IsNullOrEmpty(v))
return v;
string s = RemoveDiacritics(v);
string stripped = new string(s.Where(c => c < 128).ToArray());
return stripped;
}
public static string RemoveDiacritics(string text)
{
var normalizedString = text.Normalize(NormalizationForm.FormD);
var stringBuilder = new StringBuilder(capacity: normalizedString.Length);
for (int i = 0; i < normalizedString.Length; i++)
{
char c = normalizedString[i];
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
{
stringBuilder.Append(c);
}
}
return stringBuilder
.ToString()
.Normalize(NormalizationForm.FormC);
}
public static string ReplaceAt(this string input, int index, char newChar)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
char[] chars = input.ToCharArray();
chars[index] = newChar;
return new string(chars);
}
}
}
......@@ -155,6 +155,14 @@
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="StringUtil.cs" />
<Compile Include="GameTdb.cs" />
<Compile Include="SettingsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
</Compile>
<Compile Include="Form2.cs">
<SubType>Form</SubType>
</Compile>
......@@ -166,6 +174,9 @@
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form2.resx">
<DependentUpon>Form2.cs</DependentUpon>
</EmbeddedResource>
......@@ -197,6 +208,9 @@
</ItemGroup>
<ItemGroup>
<Content Include="favicon.ico" />
<EmbeddedResource Include="Resources\wiitdb.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<Content Include="WiiU.ico" />
</ItemGroup>
<ItemGroup>
......
Supports Markdown
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