From b055758155e7ed522e78a9cc56a0b5410510205c Mon Sep 17 00:00:00 2001 From: AllyTally Date: Thu, 10 Aug 2023 21:41:39 -0300 Subject: [PATCH] Finish implementing sprites in textboxes This commit adjusts the Y position for flip-mode, and makes the main game use this new system. --- desktop_version/src/Game.cpp | 15 ++++----- desktop_version/src/Game.h | 2 +- desktop_version/src/Graphics.cpp | 54 ++++++++++---------------------- 3 files changed, 26 insertions(+), 45 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 1ee7db4510..9aea960387 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -703,10 +703,10 @@ void Game::levelcomplete_textbox(void) graphics.textboxcenterx(); } -void Game::crewmate_textbox(const int r, const int g, const int b) +void Game::crewmate_textbox(const int color) { const int extra_cjk_height = (font::height(PR_FONT_INTERFACE) * 4) - 32; - graphics.createtextboxflipme("", -1, 64 + 8 + 16 - extra_cjk_height/2, r, g, b); + graphics.createtextboxflipme("", -1, 64 + 8 + 16 - extra_cjk_height/2, TEXT_COLOUR("gray")); /* This is a special case for wrapping, we MUST have two lines. * So just make sure it can't fit in one line. */ @@ -729,6 +729,7 @@ void Game::crewmate_textbox(const int r, const int g, const int b) float spaces_per_8 = font::len(PR_FONT_INTERFACE, " ")/8.0f; graphics.textboxpad(SDL_ceilf(5/spaces_per_8), SDL_ceilf(2/spaces_per_8)); graphics.textboxcenterx(); + graphics.addsprite(14, 12, 0, color); } void Game::remaining_textbox(void) @@ -2493,7 +2494,7 @@ void Game::updatestate(void) incstate(); setstatedelay(45); - crewmate_textbox(175, 174, 174); + crewmate_textbox(13); break; case 3008: incstate(); @@ -2535,7 +2536,7 @@ void Game::updatestate(void) incstate(); setstatedelay(45); - crewmate_textbox(174, 175, 174); + crewmate_textbox(14); break; case 3022: incstate(); @@ -2576,7 +2577,7 @@ void Game::updatestate(void) incstate(); setstatedelay(45); - crewmate_textbox(174, 174, 175); + crewmate_textbox(16); break; case 3042: incstate(); @@ -2618,7 +2619,7 @@ void Game::updatestate(void) incstate(); setstatedelay(45); - crewmate_textbox(175, 175, 174); + crewmate_textbox(20); break; case 3052: incstate(); @@ -2684,7 +2685,7 @@ void Game::updatestate(void) incstate(); setstatedelay(45); - crewmate_textbox(175, 174, 175); + crewmate_textbox(15); break; case 3062: incstate(); diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index e2d2d714f0..fb89c7199b 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -222,7 +222,7 @@ class Game void gethardestroom(void); void levelcomplete_textbox(void); - void crewmate_textbox(const int r, const int g, const int b); + void crewmate_textbox(const int color); void remaining_textbox(void); void actionprompt_textbox(void); void savetele_textbox(void); diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 894df52ced..0bbf2520a3 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -777,20 +777,14 @@ const char* Graphics::textbox_line( void Graphics::drawgui(void) { int text_sign; - int crew_yp; - int crew_sprite; if (flipmode) { text_sign = -1; - crew_yp = 64 + 48 + 4; - crew_sprite = 6; } else { text_sign = 1; - crew_yp = 64 + 32 + 4; - crew_sprite = 0; } //Draw all the textboxes to the screen @@ -962,41 +956,27 @@ void Graphics::drawgui(void) } } } - int crew_xp = textboxes[i].xp+20 - 6; - if (textboxes[i].r == 175 && textboxes[i].g == 175) - { - //purple guy - draw_sprite(crew_xp, crew_yp, crew_sprite, 220 - help.glow / 4 - textboxes[i].rand, 120 - help.glow / 4, 210 - help.glow / 4); - } - else if (textboxes[i].r == 175 && textboxes[i].b == 175) - { - //red guy - draw_sprite(crew_xp, crew_yp, crew_sprite, 255 - help.glow / 8, 70 - help.glow / 4, 70 - help.glow / 4); - } - else if (textboxes[i].r == 175) - { - //green guy - draw_sprite(crew_xp, crew_yp, crew_sprite, 120 - help.glow / 4 - textboxes[i].rand, 220 - help.glow / 4, 120 - help.glow / 4); - } - else if (textboxes[i].g == 175) - { - //yellow guy - draw_sprite(crew_xp, crew_yp, crew_sprite, 220 - help.glow / 4 - textboxes[i].rand, 210 - help.glow / 4, 120 - help.glow / 4); - } - else if (textboxes[i].b == 175) - { - //blue guy - draw_sprite(crew_xp, crew_yp, crew_sprite, 75, 75, 255 - help.glow / 4 - textboxes[i].rand); - } - for (int index = 0; index < (int) textboxes[i].sprites.size(); index++) + for (size_t index = 0; index < textboxes[i].sprites.size(); index++) { TextboxSprite* sprite = &textboxes[i].sprites[index]; - draw_sprite( - sprite->x + textboxes[i].xp, - sprite->y + textboxes[i].yp, + int y = sprite->y + yp; + + if (flipmode) + { + y = yp + textboxes[i].h - sprite->y - sprites_rect.h; + } + + draw_grid_tile( + grphx.im_sprites, sprite->tile, - getcol(sprite->col) + sprite->x + textboxes[i].xp, + y, + sprites_rect.w, + sprites_rect.h, + getcol(sprite->col), + 1, + (flipmode ? -1 : 1) ); } }