From f4fe5a9457b67d66c468023334950b5f8e602f34 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 27 Mar 2023 18:35:39 -0700 Subject: [PATCH] =?UTF-8?q?Added=20=C3=B1=20and=20=C3=91=20to=20coop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/segment2.c | 14 ++++++- src/pc/djui/djui_font.c | 8 ++-- src/pc/djui/djui_font.h | 6 +++ src/pc/djui/djui_inputbox.c | 39 +++++++++++++++++- .../custom_font_normal_char_scn.ia4.png | Bin 0 -> 534 bytes .../custom_font_normal_char_scn.ia4.png~ | Bin 0 -> 543 bytes .../custom_font_normal_char_sn.ia4.png | Bin 0 -> 498 bytes 7 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 textures/segment2/custom_font_normal_char_scn.ia4.png create mode 100644 textures/segment2/custom_font_normal_char_scn.ia4.png~ create mode 100644 textures/segment2/custom_font_normal_char_sn.ia4.png diff --git a/bin/segment2.c b/bin/segment2.c index 7cc07beb..7592a7a5 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -3591,6 +3591,14 @@ ALIGNED8 static const u8 texture_font_normal_char_93[] = { #include "textures/segment2/custom_font_normal_char_93.ia4.inc.c" }; +ALIGNED8 static const u8 texture_font_normal_char_sn[] = { +#include "textures/segment2/custom_font_normal_char_sn.ia4.inc.c" +}; + +ALIGNED8 static const u8 texture_font_normal_char_scn[] = { +#include "textures/segment2/custom_font_normal_char_scn.ia4.inc.c" +}; + const u8* const font_normal_chars[] = { texture_font_char_us_exclamation, // ! texture_font_char_us_double_quote_open, // " @@ -3687,6 +3695,8 @@ const u8* const font_normal_chars[] = { texture_font_normal_char_93, // } texture_font_char_us_tilde, // ~ texture_font_char_us_star_filled, // DEL + texture_font_normal_char_sn, // ñ + texture_font_normal_char_scn, // Ñ }; const f32 font_normal_widths[] = { @@ -3703,7 +3713,9 @@ const f32 font_normal_widths[] = { /* a b c d e f g h i j k l m n o p q r s t u v w x y z */ 0.3750f, 0.3125f, 0.3125f, 0.3750f, 0.3125f, 0.3125f, 0.3750f, 0.3125f, 0.2500f, 0.3125f, 0.3125f, 0.1875f, 0.4375f, 0.3125f, 0.3125f, 0.3125f, 0.3750f, 0.3125f, 0.3125f, 0.3125f, 0.3125f, 0.3125f, 0.4375f, 0.4375f, 0.3125f, 0.3125f, /* { | } ~ DEL */ - 0.3125f, 0.2500f, 0.3125f, 0.5000f, 0.5000f + 0.3125f, 0.2500f, 0.3125f, 0.5000f, 0.5000f, +/* ñ Ñ */ + 0.3125f, 0.5000f, }; diff --git a/src/pc/djui/djui_font.c b/src/pc/djui/djui_font.c index 82de7989..a11d6d30 100644 --- a/src/pc/djui/djui_font.c +++ b/src/pc/djui/djui_font.c @@ -35,9 +35,9 @@ const Gfx dl_font_normal_display_list[] = { static void djui_font_normal_render_char(char c) { extern const u8* const font_normal_chars[]; // replace undisplayable characters - if (c < ' ' || (u8)c > ('~' + 1)) { c = '?'; } + if ((u8)c < ' ' || (u8)c > ('~' + 3)) { c = '?'; } if (c == ' ') { return; } - void* fontChar = (void*)font_normal_chars[c - '!']; + void* fontChar = (void*)font_normal_chars[(u8)c - '!']; if (fontChar == NULL) { fontChar = (void*)font_normal_chars[94]; } gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, (void*)fontChar); @@ -47,7 +47,7 @@ static void djui_font_normal_render_char(char c) { static f32 djui_font_normal_char_width(char c) { if (c == ' ') { return 0.30f; } extern const f32 font_normal_widths[]; - return font_normal_widths[c - '!']; + return font_normal_widths[(u8)c - '!']; } static const struct DjuiFont sDjuiFontNormal = { @@ -76,7 +76,7 @@ static void djui_font_title_render_char(char c) { static f32 djui_font_title_char_width(char c) { if (c == ' ') { return 0.30f; } extern const f32 font_title_widths[]; - return font_title_widths[c - '!']; + return font_title_widths[(u8)c - '!']; } static const struct DjuiFont sDjuiFontTitle = { diff --git a/src/pc/djui/djui_font.h b/src/pc/djui/djui_font.h index 589c98df..685a6729 100644 --- a/src/pc/djui/djui_font.h +++ b/src/pc/djui/djui_font.h @@ -1,6 +1,12 @@ #pragma once #include "djui.h" +#define SPANISH_UNICODE_START -61 +#define SPANISH_UNICODE_LOWER_N -79 // ñ +#define SPANISH_UNICODE_UPPER_N -111 // Ñ +#define SPANISH_SMCODE_LOWER_N ((s8)('~' + 2)) +#define SPANISH_SMCODE_UPPER_N ((s8)('~' + 3)) + struct DjuiFont { f32 charWidth; f32 charHeight; diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c index 27ebf85c..3f960769 100644 --- a/src/pc/djui/djui_inputbox.c +++ b/src/pc/djui/djui_inputbox.c @@ -291,15 +291,44 @@ static void djui_inputbox_on_focus_end(UNUSED struct DjuiBase* base) { wm_api->stop_text_input(); } +#define SPANISH_UNICODE_START -61 +#define SPANISH_UNICODE_LOWER_N -79 // ñ +#define SPANISH_UNICODE_UPPER_N -111 // Ñ +#define SPANISH_SMCODE_LOWER_N ((s8)('~' + 2)) +#define SPANISH_SMCODE_UPPER_N ((s8)('~' + 3)) + static void djui_inputbox_on_text_input(struct DjuiBase *base, char* text) { struct DjuiInputbox *inputbox = (struct DjuiInputbox *) base; char* msg = inputbox->buffer; int msgLen = strlen(msg); int textLen = strlen(text); + // special case ñ and Ñ + char* tinput = text; + while (*tinput != '\0') { + if (tinput[0] == SPANISH_UNICODE_START) { + if ((tinput[1] == SPANISH_UNICODE_LOWER_N || tinput[1] == SPANISH_UNICODE_UPPER_N)) { + // consume SPANISH_UNICODE_START + char* t2 = tinput; + while (*t2 != '\0') { + t2[0] = t2[1]; + t2++; + } + + // translate + if (tinput[0] == SPANISH_UNICODE_LOWER_N) { + tinput[0] = SPANISH_SMCODE_LOWER_N; + } else if (tinput[0] == SPANISH_UNICODE_UPPER_N) { + tinput[0] = SPANISH_SMCODE_UPPER_N; + } + } + } + tinput++; + } + // make sure we're not just printing garbage characters bool containsValidAscii = false; - char* tinput = text; + tinput = text; while (*tinput != '\0') { if (*tinput >= '!' && *tinput <= '~') { containsValidAscii = true; @@ -307,6 +336,12 @@ static void djui_inputbox_on_text_input(struct DjuiBase *base, char* text) { } else if (*tinput == ' ') { containsValidAscii = true; break; + } else if (*tinput == SPANISH_SMCODE_LOWER_N) { + containsValidAscii = true; + break; + } else if (*tinput == SPANISH_SMCODE_UPPER_N) { + containsValidAscii = true; + break; } tinput++; } @@ -333,6 +368,8 @@ static void djui_inputbox_on_text_input(struct DjuiBase *base, char* text) { if (*t == '\n') { *t = ' '; } else if (*t == '\r') { *t = ' '; } else if (*t == ' ') { ; } + else if (*t == SPANISH_SMCODE_LOWER_N) { ; } + else if (*t == SPANISH_SMCODE_UPPER_N) { ; } else if (*t < '!' || *t > '~') { *t = '?'; } t++; } diff --git a/textures/segment2/custom_font_normal_char_scn.ia4.png b/textures/segment2/custom_font_normal_char_scn.ia4.png new file mode 100644 index 0000000000000000000000000000000000000000..c434ca6dbb0dda0f98264fbdbdc7b331c73251cc GIT binary patch literal 534 zcmV+x0_pvUP) z?ULDpOPmN{Lg*A&AxEBJsg`6`-8WM5&9EvSL;g1FIO52V74ML!1?ifSnif4JUygN^ z`~N)M^w?;*dms!APoDSI4~;wUUG%)KBhULj2LB^mSQY=OZ;PA-#b3RBMuUBw|0kVO_dKYXKx|fhOqj&+AsrZ}= Y0P=l1bvs!#$p8QV07*qoM6N<$g8HZK00000 literal 0 HcmV?d00001 diff --git a/textures/segment2/custom_font_normal_char_scn.ia4.png~ b/textures/segment2/custom_font_normal_char_scn.ia4.png~ new file mode 100644 index 0000000000000000000000000000000000000000..8c1804c426e80ed380eeb5d9971cbcd6fa62679f GIT binary patch literal 543 zcmV+)0^t3LP) z?ULDpOPmN{Lg*A&AxEBJsg`6`-8WM5&9EvSL;g1FIO52V74ML!1?ifSnif4JUygN^ z`~N)M^w?;*dms!APoDSI4~;wUUG%)KBhULj2LB^mSQY=OZ;L_t(2Q>Br?3IHGoLks->FBS?TV`}E1 zPD0P=W^13X`+jB~nI;h}UKp(n`)XFuGlUAFiokV>TQ69^|1hnxQ00k&S{n z?ULDpOPmN{Lg*A&AxEBJsg`6`-8WM5&9EvSL;g1FIO52V74ML!1?ifSnif4JUygN^ z`~N)M^w?;*dms!APoDSI4~;wUUG%)KBhULj2LB^mSQY=OZ;V!Z literal 0 HcmV?d00001