From b5c9508dd471a6bac2c683cdca7a7b492ce2efde 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 3f41372f..1c82f568 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -671,10 +671,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. */ @@ -697,6 +697,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) @@ -2453,7 +2454,7 @@ void Game::updatestate(void) incstate(); setstatedelay(45); - crewmate_textbox(175, 174, 174); + crewmate_textbox(13); break; case 3008: incstate(); @@ -2495,7 +2496,7 @@ void Game::updatestate(void) incstate(); setstatedelay(45); - crewmate_textbox(174, 175, 174); + crewmate_textbox(14); break; case 3022: incstate(); @@ -2536,7 +2537,7 @@ void Game::updatestate(void) incstate(); setstatedelay(45); - crewmate_textbox(174, 174, 175); + crewmate_textbox(16); break; case 3042: incstate(); @@ -2578,7 +2579,7 @@ void Game::updatestate(void) incstate(); setstatedelay(45); - crewmate_textbox(175, 175, 174); + crewmate_textbox(20); break; case 3052: incstate(); @@ -2644,7 +2645,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 d81c7762..188422eb 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -222,7 +222,7 @@ public: 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 85f1ff0e..0d0b8ff9 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -838,20 +838,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 @@ -1023,41 +1017,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) ); } }