Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace WheelWizard.CustomCharacters;

public static class CustomCharactersExtensions
{
public static IServiceCollection AddCustomCharacters(this IServiceCollection services)
{
services.AddSingleton<ICustomCharactersService, CustomCharactersService>();

return services;
}
}
215 changes: 215 additions & 0 deletions WheelWizard/Features/CustomCharacters/CustomCharactersService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
namespace WheelWizard.CustomCharacters;

public interface ICustomCharactersService
{
/// <summary>
/// Gets the custom characters.
/// </summary>
List<char> GetCustomCharacters();

/// <summary>
/// To clear the given string from all the custom characters, and map them to their ascii closest representation.
/// </summary>
string NormalizeToAscii(string str);
}

public class CustomCharactersService : ICustomCharactersService
{
public List<char> GetCustomCharacters()
{
var charRanges = new List<(char, char)>
{
((char)0x2460, (char)0x246e),
((char)0xe000, (char)0xe01c),
((char)0xf061, (char)0xf06d),
((char)0xf074, (char)0xf07c),
((char)0xf107, (char)0xf10f), // it actually goes up to 0xf12f, but for some reason it repeats the same 8 icons 6 times over
};

var chars = new List<char>();
foreach (var (start, end) in charRanges)
{
for (var i = start; i <= end; i++)
{
chars.Add(i);
}
}

// All the left-over chars that we cant make easy groups out of
chars.AddRange(
[
(char)0xe028,
(char)0xe068,
(char)0xe067,
(char)0xe06a,
(char)0xe06b,
(char)0xf030,
(char)0xf031,
(char)0xf034,
(char)0xf035,
(char)0xf038,
(char)0xf039,
(char)0xf041,
(char)0xf043,
(char)0xf044,
(char)0xf047,
(char)0xf050,
(char)0xf058,
(char)0xf05e,
(char)0xf05f,
(char)0xf103,
]
);

return chars;
}

public string NormalizeToAscii(string str)
{
var charRanges = new List<(char, char, string[])>
{
((char)0x2460, (char)0x246e, SArr("0123456789:,/-+")),
(
(char)0xe000,
(char)0xe01c,
[
"(A)",
"(B)",
"(X)",
"(Y)",
"[L]",
"[R]",
"⁜",
"◷",
":)",
">:(",
"<:o",
":|",
"⁕",
"@",
"◜|◝",
"{}",
"[!]",
"[?]",
"[v]",
"[x]",
"[+]",
"\u2660",
"\u2666",
"\u2665",
"\u2663",
"▶",
"◀",
"▲",
"▼",
]
),
((char)0xf061, (char)0xf06d, SArr("⁎⁑⁂⨁⨁⨁⨁⨀⩉ŲŲŲ₩")),
((char)0xf074, (char)0xf07c, SArr("⨁⨁⨁⨁ABCDE")),
(
(char)0xf107,
(char)0xf12f,
[
"[⁇]",
"▢▣▣▣",
"▣▢▣▣",
"▣▣▢▣",
"▣▣▣▢",
"○●●●",
"●○●●",
"●●○●",
"●●●○",
"▢▣▣▣",
"▣▢▣▣",
"▣▣▢▣",
"▣▣▣▢",
"○●●●",
"●○●●",
"●●○●",
"●●●○",
"▢▣▣▣",
"▣▢▣▣",
"▣▣▢▣",
"▣▣▣▢",
"○●●●",
"●○●●",
"●●○●",
"●●●○",
"▢▣▣▣",
"▣▢▣▣",
"▣▣▢▣",
"▣▣▣▢",
"○●●●",
"●○●●",
"●●○●",
"●●●○",
"▢▣▣▣",
"▣▢▣▣",
"▣▣▢▣",
"▣▣▣▢",
"○●●●",
"●○●●",
"●●○●",
"●●●○",
"▢▣▣▣",
"▣▢▣▣",
"▣▣▢▣",
"▣▣▣▢",
"○●●●",
"●○●●",
"●●○●",
"●●●○",
]
),
};

foreach (var (start, end, replacements) in charRanges)
{
for (var i = start; i <= end; i++)
{
var replacementIndex = i - start;
if (replacements.Length < replacementIndex)
continue; // If its here we did not account for 1 of the replacements
str = str.Replace($"{i}", replacements[replacementIndex]);
}
}

(char, string)[] individualReplacements =
[
((char)0xe028, "✕"),
((char)0xe068, "er"),
((char)0xe067, "re"),
((char)0xe06a, "e"),
((char)0xe06b, "[?]"),
((char)0xf030, "②"),
((char)0xf031, "②"),
((char)0xf034, "(A)"),
((char)0xf035, "(A)"),
((char)0xf038, "(a)"),
((char)0xf039, "(a)"),
((char)0xf041, "[B]"),
((char)0xf043, "(1)"),
((char)0xf044, "(+)"),
((char)0xf047, "(+)"),
((char)0xf050, "(b)"),
((char)0xf058, "(B)"),
((char)0xf05e, "(S)"),
((char)0xf05f, "(s)"),
((char)0xf103, "▣▣▣▣"),
// The once below are also not in teh actual app but should still be exported correctly
((char)0xf03c, "(A)"),
((char)0xf03d, "(A)"),
((char)0xf102, " "),
((char)0xf060, " "),
];

foreach (var (c, replacement) in individualReplacements)
{
str = str.Replace($"{c}", replacement);
}

return str;
}

private static string[] SArr(string input) => input.ToCharArray().Select(c => $"{c}").ToArray();
}
2 changes: 0 additions & 2 deletions WheelWizard/Features/WiiManagement/Domain/Mii/Mii.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class Mii
public MiiScale Height { get; set; } = new(1);
public MiiScale Weight { get; set; } = new(1);

public bool IsForeign => (MiiId1 >> 5) == 0b110; // checks if the top 3 bits are set to 110, if so it got blue pants
Comment thread
patchzyy marked this conversation as resolved.

//Mii ID is also refered as Avatar ID
public byte MiiId1 { get; set; }
public byte MiiId2 { get; set; }
Expand Down
20 changes: 19 additions & 1 deletion WheelWizard/Features/WiiManagement/MiiFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,27 @@ public static Mii CreateRandomMii(IRandom random)
var hairColor = (MiiHairColor)(random.Next() % 8);

baseMii.IsGirl = random.Next() % 2 == 0;
baseMii.MiiHair = new(random.Next() % 71, hairColor, random.Next() % 2 == 0);
baseMii.MiiHair = new(random.Next() % 71, hairColor, random.Next() % 3 == 0);
baseMii.MiiEyebrows = new(random.Next() % 23, 6, hairColor, 4, 10, 2);
baseMii.MiiEyes = new(random.Next() % 47, 4, 12, (MiiEyeColor)(random.Next() % 6), 4, 2);
baseMii.MiiFavoriteColor = (MiiFavoriteColor)(random.Next() % 12);
baseMii.MiiFacialFeatures = new(
(MiiFaceShape)(random.Next() % 8),
(MiiSkinColor)(random.Next() % 6),
(MiiFacialFeature)(random.Next() % 12),
false,
false
);
baseMii.MiiNose = new((MiiNoseType)(random.Next() % 12), 4, 9);
baseMii.MiiLips = new(random.Next() % 23, (MiiLipColor)(random.Next() % 3), 4, 13);
baseMii.MiiMole = new(random.Next() % 4 == 0, 4, 20, 2);
if (random.Next() % 4 == 0)
baseMii.MiiGlasses = new((MiiGlassesType)(random.Next() % 9), (MiiGlassesColor)(random.Next() % 6), 4, 10);
else
baseMii.MiiGlasses = new(MiiGlassesType.None, MiiGlassesColor.Grey, 4, 10);

if (random.Next() % 4 == 0)
baseMii.MiiFacialHair = new((MiiMustacheType)(random.Next() % 4), (MiiBeardType)(random.Next() % 4), hairColor, 4, 10);
return baseMii;
}
}
18 changes: 18 additions & 0 deletions WheelWizard/Resources/Languages/Common.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions WheelWizard/Resources/Languages/Common.nl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,10 @@
<data name="Action_Back" xml:space="preserve">
<value>Terug</value>
</data>
<data name="Action_Favorite" xml:space="preserve">
<value>Voeg toe aan Favorieten</value>
</data>
<data name="Action_Unfavorite" xml:space="preserve">
<value>Haal uit favorieten</value>
</data>
</root>
6 changes: 6 additions & 0 deletions WheelWizard/Resources/Languages/Common.resx
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,10 @@
<data name="Action_Back" xml:space="preserve">
<value>Back</value>
</data>
<data name="Action_Unfavorite" xml:space="preserve">
<value>Unfavorite</value>
</data>
<data name="Action_Favorite" xml:space="preserve">
<value>Favorite</value>
</data>
</root>
2 changes: 2 additions & 0 deletions WheelWizard/SetupExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Testably.Abstractions;
using WheelWizard.AutoUpdating;
using WheelWizard.Branding;
using WheelWizard.CustomCharacters;
using WheelWizard.GameBanana;
using WheelWizard.GitHub;
using WheelWizard.MiiImages;
Expand All @@ -22,6 +23,7 @@ public static class SetupExtensions
public static void AddWheelWizardServices(this IServiceCollection services)
{
// Features
services.AddCustomCharacters();
services.AddAutoUpdating();
services.AddBranding();
services.AddGitHub();
Expand Down
14 changes: 14 additions & 0 deletions WheelWizard/Views/Pages/MiiListPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
<Grid Grid.Row="0" Margin="10,0">
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal"
Spacing="6">
<components:Button Text="" Click="FavMii_OnClick" x:Name="FavoriteMiiButton"
Variant="Default" Padding="10"
ToolTip.ShowDelay="0" ToolTip.Placement="Top">
<components:Button.Styles>
<Style Selector="components|Button">
<Setter Property="IconData" Value="{StaticResource StarIcon}"/>
<Setter Property="ToolTip.Tip" Value="{x:Static lang:Common.Action_Favorite}"/>
</Style>
<Style Selector="components|Button.UnFav">
<Setter Property="IconData" Value="{StaticResource EmptyStarIcon}"/>
<Setter Property="ToolTip.Tip" Value="{x:Static lang:Common.Action_Unfavorite}"/>
</Style>
</components:Button.Styles>
</components:Button>
<components:Button Text="" Click="EditMii_OnClick" x:Name="EditMiisButton"
IconData="{StaticResource Pen}"
Variant="Default" Padding="10" IsVisible="False"
Expand Down
Loading
Loading