Commit c1c93074 authored by Amyn Bennamane's avatar Amyn Bennamane
Browse files

Use GameTDB for game name instead of internal game name

parent f4f04a45
......@@ -813,7 +813,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)
......@@ -851,6 +852,7 @@ namespace TeconMoon_s_WiiVC_Injector
}
EndOfGameSelection:;
}
private void IconSourceButton_Click(object sender, EventArgs e)
{
if (FlagRepo)
......
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;
}
}
}
}
......@@ -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
This diff is collapsed.
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);
}
}
}
......@@ -155,6 +155,8 @@
<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>
......@@ -206,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