Branch
Hash :
36df94af
Author :
Thomas de Grivel
Date :
2025-03-02T16:13:53
Change copyright wording and extend to 2025
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
/* kc3
* Copyright from 2022 to 2025 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#include "../gl_font.h"
#include "../gl_ortho.h"
#include "../gl_text.h"
#include "../mat4.h"
#include "help.h"
#include "kubz.h"
#define HELP_TEXT_LINES 7
static const s_rgba help_color = {0.8f, 1.0f, 0.8f, 0.4f};
static s_gl_text help_gl_text[HELP_TEXT_LINES] = {0};
static const char * help_text[HELP_TEXT_LINES] = {
"Help",
"",
"ESC Main menu",
"F1 Help",
"F3 Toggle info",
"F4 Toggle console",
"F11 Toggle fullscreen"
};
static const s_rgb help_text_color[2] = {
{0.7f, 0.9f, 0.7f},
{0.0f, 0.0f, 0.0f}
};
bool help_render (s_window_sdl2 *window)
{
sw i;
if (! help_gl_text->font) {
i = 0;
while (i < HELP_TEXT_LINES) {
if (! gl_text_init_1(help_gl_text + i,
&g_font_courier_new,
help_text[i]))
return false;
if (! gl_text_update(help_gl_text + i))
return false;
i++;
}
}
gl_ortho_color(&g_ortho, help_color.r, help_color.g, help_color.b,
help_color.a);
gl_ortho_rect(&g_ortho, 20.0f, 20.0f,
window->w - 40.0f, window->h - 40.0f);
i = 0;
while (i < HELP_TEXT_LINES) {
gl_ortho_text_render_outline(&g_ortho, help_gl_text + i,
40, window->h - 60 - i * 20,
help_text_color, help_text_color + 1);
i++;
}
return true;
}