From d1f6c1adf297b959212a0cccca7fdc287faec073 Mon Sep 17 00:00:00 2001 From: Dav999-v Date: Tue, 31 Jan 2023 00:41:46 +0100 Subject: [PATCH] Replace "by" for level authors with happy face "by {author}" is a string that will cause a lot of localization-related problems, which then become much worse when different languages and levels can also need different fonts: - If the author name is set to something in English instead of a name, then it'll come out a bit weird if your VVVVVV is set to a different language: "de various people", "por various people", etc. It's the same problem with Discord bots completing "playing" or "watching" in their statuses. - Translators can't always fit "by" in two letters, and level creators have understandably always assumed, and will continue to assume, that "by" is two letters. So if you have your VVVVVV set to a language that translates "by" as something long, then: | by Various People and Others | ...may suddenly show up as something like: |thorer Various People and Othe| - "by" and author may need mutually incompatible fonts. For example, a Japanese level in a Korean VVVVVV needs to be displayed with "by" in Korean characters and the author name with Japanese characters, which would need some very special code since languages may want to add text both before and after the name. - It's very possible that some languages can't translate "by" without knowing the gender of the name, and I know some languages even inflect names in really interesting ways (adding and even replacing letters in first names, surnames, and anything in between, depending on gender and what else is in the sentence). So to solve all of this, the "by" is now replaced by a 10x10 face from sprites.png, like a :viridian: emote. See it as a kind of avatar next to a username, to clarify and assert that this line is for the author's name. It should be a fairly obvious/recognizable icon, it fixes all the above problems, and it's a bonus that we now have more happy faces in VVVVVV. --- desktop_version/lang/ca/strings.xml | 1 - desktop_version/lang/en/strings.xml | 1 - desktop_version/lang/eo/strings.xml | 1 - desktop_version/lang/es/strings.xml | 1 - desktop_version/lang/nl/strings.xml | 1 - desktop_version/src/Editor.cpp | 9 +-------- desktop_version/src/Graphics.cpp | 24 ++++++++++++++++++++++++ desktop_version/src/Graphics.h | 9 +++++++++ desktop_version/src/Render.cpp | 19 +++---------------- 9 files changed, 37 insertions(+), 29 deletions(-) diff --git a/desktop_version/lang/ca/strings.xml b/desktop_version/lang/ca/strings.xml index ae9df606..d3ad13b9 100644 --- a/desktop_version/lang/ca/strings.xml +++ b/desktop_version/lang/ca/strings.xml @@ -35,7 +35,6 @@ - diff --git a/desktop_version/lang/en/strings.xml b/desktop_version/lang/en/strings.xml index 6e2611f0..546d4770 100644 --- a/desktop_version/lang/en/strings.xml +++ b/desktop_version/lang/en/strings.xml @@ -35,7 +35,6 @@ - diff --git a/desktop_version/lang/eo/strings.xml b/desktop_version/lang/eo/strings.xml index 81f0e0d8..9cf3e318 100644 --- a/desktop_version/lang/eo/strings.xml +++ b/desktop_version/lang/eo/strings.xml @@ -35,7 +35,6 @@ - diff --git a/desktop_version/lang/es/strings.xml b/desktop_version/lang/es/strings.xml index e5806044..0d98ae0d 100644 --- a/desktop_version/lang/es/strings.xml +++ b/desktop_version/lang/es/strings.xml @@ -35,7 +35,6 @@ - diff --git a/desktop_version/lang/nl/strings.xml b/desktop_version/lang/nl/strings.xml index f4e6891b..ce4337fa 100644 --- a/desktop_version/lang/nl/strings.xml +++ b/desktop_version/lang/nl/strings.xml @@ -35,7 +35,6 @@ - diff --git a/desktop_version/src/Editor.cpp b/desktop_version/src/Editor.cpp index fe3c2dba..4bd700c5 100644 --- a/desktop_version/src/Editor.cpp +++ b/desktop_version/src/Editor.cpp @@ -360,15 +360,8 @@ static void editormenurender(int tr, int tg, int tb) { creator = translate_creator(cl.creator, &creator_is_gettext); } - char creatorline[SCREEN_WIDTH_CHARS + 1]; - vformat_buf( - creatorline, sizeof(creatorline), - loc::gettext("by {author}"), - "author:str", - creator.c_str() - ); int sp = SDL_max(10, font::height(PR_FONT_LEVEL)); - font::print(PR_CEN | (creator_is_gettext ? PR_FONT_INTERFACE : PR_FONT_LEVEL), -1, 60, creatorline, tr, tg, tb); + graphics.print_level_creator((creator_is_gettext ? PR_FONT_INTERFACE : PR_FONT_LEVEL), 60, creator, tr, tg, tb); if(ed.websitemod) { diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 7a9b80ca..f896d96f 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -444,6 +444,30 @@ void Graphics::printcrewnamestatus( int x, int y, int t, bool rescued ) font::print(0, x, y, status_text, r, g, b); } +void Graphics::print_level_creator( + const uint32_t print_flags, + const int y, + const std::string& creator, + const uint8_t r, + const uint8_t g, + const uint8_t b +) { + /* We now display a face instead of "by {author}" for several reasons: + * - "by" may be in a different language than the author and look weird ("por various people") + * - "by" will be longer in different languages and break the limit that levels assume + * - "by" and author may need mutually incompatible fonts, e.g. Japanese level in Korean VVVVVV + * - avoids likely grammar problems: male/female difference, name inflection in user-written text... + * - it makes sense to make it a face + * - if anyone is sad about this decision, the happy face will cheer them up anyway :D */ + int width_for_face = 17; + int total_width = width_for_face + font::len(print_flags, creator); + int face_x = (SCREEN_WIDTH_PIXELS-total_width)/2; + set_texture_color_mod(grphx.im_sprites, r, g, b); + draw_texture_part(grphx.im_sprites, face_x, y-1, 7, 2, 10, 10, 1, 1); + set_texture_color_mod(grphx.im_sprites, 255, 255, 255); + font::print(print_flags, face_x+width_for_face, y, creator, r, g, b); +} + int Graphics::set_render_target(SDL_Texture* texture) { const int result = SDL_SetRenderTarget(gameScreen.m_renderer, texture); diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index 45ff7ad9..0725fe97 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -167,6 +167,15 @@ public: void printcrewnamestatus(int x, int y, int t, bool rescued); + void print_level_creator( + uint32_t print_flags, + int y, + const std::string& creator, + uint8_t r, + uint8_t g, + uint8_t b + ); + int set_render_target(SDL_Texture* texture); int set_texture_color_mod(SDL_Texture* texture, Uint8 r, Uint8 g, Uint8 b); diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 0752c541..373d5d76 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -207,15 +207,8 @@ static void menurender(void) uint32_t creator_flags = cl.ListOfMetaData[tmp].creator_is_gettext ? PR_FONT_INTERFACE : level_flags; font::print(title_flags | PR_2X | PR_CEN, -1, 15, cl.ListOfMetaData[tmp].title, tr, tg, tb); - char creatorline[SCREEN_WIDTH_CHARS + 1]; - vformat_buf( - creatorline, sizeof(creatorline), - loc::gettext("by {author}"), - "author:str", - cl.ListOfMetaData[tmp].creator.c_str() - ); int sp = SDL_max(10, font::height(level_flags)); - font::print(creator_flags | PR_CEN, -1, 40, creatorline, tr, tg, tb); + graphics.print_level_creator(creator_flags, 40, cl.ListOfMetaData[tmp].creator, tr, tg, tb); font::print(level_flags | PR_CEN, -1, 40+sp, cl.ListOfMetaData[tmp].website, tr, tg, tb); font::print(level_flags | PR_CEN, -1, 40+sp*3, cl.ListOfMetaData[tmp].Desc1, tr, tg, tb); font::print(level_flags | PR_CEN, -1, 40+sp*4, cl.ListOfMetaData[tmp].Desc2, tr, tg, tb); @@ -2604,15 +2597,8 @@ void maprender(void) uint32_t creator_flags = meta.creator_is_gettext ? PR_FONT_INTERFACE : PR_FONT_LEVEL; font::print(title_flags | PR_2X | PR_CEN, -1, FLIP(45, 8), meta.title, 196, 196, 255 - help.glow); - char buffer[SCREEN_WIDTH_CHARS + 1]; - vformat_buf( - buffer, sizeof(buffer), - loc::gettext("by {author}"), - "author:str", - meta.creator.c_str() - ); int sp = SDL_max(10, font::height(PR_FONT_LEVEL)); - font::print(creator_flags | PR_CEN, -1, FLIP(70, 8), buffer, 196, 196, 255 - help.glow); + graphics.print_level_creator(creator_flags, FLIP(70, 8), meta.creator, 196, 196, 255 - help.glow); font::print(PR_FONT_LEVEL | PR_CEN, -1, FLIP(70+sp, 8), meta.website, 196, 196, 255 - help.glow); font::print(PR_FONT_LEVEL | PR_CEN, -1, FLIP(70+sp*3, 8), meta.Desc1, 196, 196, 255 - help.glow); font::print(PR_FONT_LEVEL | PR_CEN, -1, FLIP(70+sp*4, 8), meta.Desc2, 196, 196, 255 - help.glow); @@ -2623,6 +2609,7 @@ void maprender(void) int remaining = cl.numcrewmates() - game.crewmates(); + char buffer[SCREEN_WIDTH_CHARS + 1]; loc::gettext_plural_fill( buffer, sizeof(buffer), "{n_crew|wordy} crewmates remain",