| 1 |
#ifdef HAVE_CONFIG_H |
| 2 |
#include <config.h> |
| 3 |
#endif |
| 4 |
|
| 5 |
#include "game_choice_renderer.h" |
| 6 |
|
| 7 |
#include "game_choice.h" |
| 8 |
#include "SDL.h" |
| 9 |
#include "dinkini.h" |
| 10 |
#include "gfx.h" |
| 11 |
#include "gfx_fonts.h" |
| 12 |
#include "gfx_sprites.h" |
| 13 |
#include "log.h" |
| 14 |
#include "game_engine.h" |
| 15 |
|
| 16 |
void game_choice_renderer_render() { |
| 17 |
if (!game_choice.active) |
| 18 |
return; |
| 19 |
|
| 20 |
int sx = 184; |
| 21 |
int x_depth = 335; |
| 22 |
|
| 23 |
int px = 48, py = 44; |
| 24 |
int curxl = 126; |
| 25 |
int curxr = 462; |
| 26 |
int curyr = 200; |
| 27 |
int curyl = 200; |
| 28 |
int y_last = 0; |
| 29 |
|
| 30 |
check_seq_status(30); |
| 31 |
|
| 32 |
// Draw background |
| 33 |
{ |
| 34 |
SDL_Rect dst; |
| 35 |
dst.x = px; dst.y = py; |
| 36 |
IOGFX_backbuffer->blit(GFX_k[seq[30].frame[2]].k, NULL, &dst); |
| 37 |
} |
| 38 |
{ |
| 39 |
SDL_Rect dst; |
| 40 |
dst.x = px + 169; dst.y = py + 42; |
| 41 |
IOGFX_backbuffer->blit(GFX_k[seq[30].frame[3]].k, NULL, &dst); |
| 42 |
} |
| 43 |
{ |
| 44 |
SDL_Rect dst; |
| 45 |
dst.x = px+169+180; dst.y = py+1; |
| 46 |
if (IOGFX_backbuffer->blit(GFX_k[seq[30].frame[4]].k, NULL, &dst) < 0) |
| 47 |
log_error("Could not draw sprite %d: %s", seq[30].frame[4], SDL_GetError()); |
| 48 |
} |
| 49 |
|
| 50 |
// Draw dialog title, if any |
| 51 |
if (strlen(game_choice.buffer) > 0) |
| 52 |
{ |
| 53 |
rect rcRect; |
| 54 |
rect_set(&rcRect, sx, 94, 463, 400); |
| 55 |
/* if using an explicit "set_y" after "choice_start()": */ |
| 56 |
if (game_choice.newy != -5000) |
| 57 |
rcRect.bottom = game_choice.newy + 15; |
| 58 |
|
| 59 |
/* Same of in text_draw, except for #1 and default */ |
| 60 |
// support for custom colors |
| 61 |
SDL_Color fg; |
| 62 |
if (game_choice.color >= 1 && game_choice.color <= 15) { |
| 63 |
fg = font_colors[game_choice.color]; |
| 64 |
} else { |
| 65 |
if (dversion >= 108) |
| 66 |
fg = {255,255,255}; |
| 67 |
else |
| 68 |
fg = {255,255,2}; |
| 69 |
} |
| 70 |
|
| 71 |
std::vector<TextCommand> cmds; |
| 72 |
|
| 73 |
SDL_Color bg = {8,14,21}; |
| 74 |
FONTS_SetTextColor(bg.r, bg.g, bg.b); |
| 75 |
print_text_wrap(game_choice.buffer, &rcRect, 1, 0, FONT_DIALOG); |
| 76 |
|
| 77 |
FONTS_SetTextColor(fg.r, fg.g, fg.b); |
| 78 |
rect_offset(&rcRect, 1, 1); |
| 79 |
print_text_wrap(game_choice.buffer, &rcRect, 1, 0, FONT_DIALOG); |
| 80 |
} |
| 81 |
|
| 82 |
// Draw choices |
| 83 |
for (int i = game_choice.cur_view; i <= game_choice.cur_view_end; i++) |
| 84 |
{ |
| 85 |
//lets figure out where to draw this line |
| 86 |
rect rcRect; |
| 87 |
rect_set(&rcRect, sx, game_choice.choices_y, 463, x_depth + 100); |
| 88 |
|
| 89 |
SDL_Color fg; |
| 90 |
if (i == game_choice.cur) |
| 91 |
fg = {255,255,255}; |
| 92 |
else |
| 93 |
fg = {255,255,2}; |
| 94 |
|
| 95 |
std::vector<TextCommand> cmds; |
| 96 |
|
| 97 |
SDL_Color bg = {8,14,21}; |
| 98 |
FONTS_SetTextColor(bg.r, bg.g, bg.b); |
| 99 |
print_text_wrap(game_choice.line[i], &rcRect, 1, 0, FONT_DIALOG); |
| 100 |
rect_offset(&rcRect, -2, -2); |
| 101 |
print_text_wrap(game_choice.line[i], &rcRect, 1, 0, FONT_DIALOG); |
| 102 |
|
| 103 |
FONTS_SetTextColor(fg.r, fg.g, fg.b); |
| 104 |
rect_offset(&rcRect, 1, 1); |
| 105 |
y_last = print_text_wrap(game_choice.line[i], &rcRect, 1, 0, FONT_DIALOG); |
| 106 |
|
| 107 |
if (i == game_choice.cur) { |
| 108 |
curyl = game_choice.choices_y-4; |
| 109 |
curyr = game_choice.choices_y-4; |
| 110 |
} |
| 111 |
game_choice.choices_y += y_last; |
| 112 |
} |
| 113 |
|
| 114 |
// Draw arrows |
| 115 |
{ |
| 116 |
SDL_Rect dst; |
| 117 |
dst.x = curxl; dst.y = curyl; |
| 118 |
IOGFX_backbuffer->blit(GFX_k[seq[456].frame[game_choice.curf]].k, NULL, &dst); |
| 119 |
dst.x = curxr; dst.y = curyr; |
| 120 |
IOGFX_backbuffer->blit(GFX_k[seq[457].frame[game_choice.curf]].k, NULL, &dst); |
| 121 |
} |
| 122 |
} |