Skip to content

Commit

Permalink
Finish implementing sprites in textboxes
Browse files Browse the repository at this point in the history
This commit adjusts the Y position for flip-mode, and makes the main
game use this new system.
  • Loading branch information
AllyTally committed Aug 13, 2023
1 parent a34aff2 commit b055758
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 45 deletions.
15 changes: 8 additions & 7 deletions desktop_version/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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)
Expand Down Expand Up @@ -2493,7 +2494,7 @@ void Game::updatestate(void)
incstate();
setstatedelay(45);

crewmate_textbox(175, 174, 174);
crewmate_textbox(13);
break;
case 3008:
incstate();
Expand Down Expand Up @@ -2535,7 +2536,7 @@ void Game::updatestate(void)
incstate();
setstatedelay(45);

crewmate_textbox(174, 175, 174);
crewmate_textbox(14);
break;
case 3022:
incstate();
Expand Down Expand Up @@ -2576,7 +2577,7 @@ void Game::updatestate(void)
incstate();
setstatedelay(45);

crewmate_textbox(174, 174, 175);
crewmate_textbox(16);
break;
case 3042:
incstate();
Expand Down Expand Up @@ -2618,7 +2619,7 @@ void Game::updatestate(void)
incstate();
setstatedelay(45);

crewmate_textbox(175, 175, 174);
crewmate_textbox(20);
break;
case 3052:
incstate();
Expand Down Expand Up @@ -2684,7 +2685,7 @@ void Game::updatestate(void)
incstate();
setstatedelay(45);

crewmate_textbox(175, 174, 175);
crewmate_textbox(15);
break;
case 3062:
incstate();
Expand Down
2 changes: 1 addition & 1 deletion desktop_version/src/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
54 changes: 17 additions & 37 deletions desktop_version/src/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
);
}
}
Expand Down

0 comments on commit b055758

Please sign in to comment.