summaryrefslogtreecommitdiffstats
path: root/src/help.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/help.c')
-rw-r--r--src/help.c78
1 files changed, 72 insertions, 6 deletions
diff --git a/src/help.c b/src/help.c
index 0399c36..eed28c6 100644
--- a/src/help.c
+++ b/src/help.c
@@ -20,6 +20,7 @@
#include <SDL.h>
#include <SDL_ttf.h>
#include <config.h>
+#include "collision.h"
#include "help.h"
#include "main.h"
#include "output.h"
@@ -96,6 +97,10 @@ db_help(void)
SDL_Texture *texture;
SDL_Rect text_src_rect;
SDL_Rect text_dst_rect;
+ SDL_Rect up_rect;
+ SDL_Rect dn_rect;
+ int up_over;
+ int dn_over;
SDL_Event event;
font_path = db_strcat(db_get_fonts_dir(), "/UbuntuTitling-Bold.ttf");
@@ -139,6 +144,18 @@ db_help(void)
text_dst_rect.w = 592;
text_dst_rect.h = 448;
+ up_rect.x = 608;
+ up_rect.y = 16;
+ up_rect.w = 16;
+ up_rect.h = 8;
+
+ dn_rect.x = 608;
+ dn_rect.y = 456;
+ dn_rect.w = 16;
+ dn_rect.h = 8;
+
+ up_over = 0;
+ dn_over = 0;
_db_help_quit = 0;
while (SDL_WaitEvent(&event)) {
switch (event.type) {
@@ -180,6 +197,49 @@ db_help(void)
break;
}
break;
+ case SDL_MOUSEMOTION:
+ if (event.motion.state != 0) {
+ break;
+ }
+ if (db_pt_in_rect(event.motion.x,
+ event.motion.y,
+ &up_rect)) {
+ up_over = 1;
+ break;
+ } else {
+ up_over = 0;
+ }
+ if (db_pt_in_rect(event.motion.x,
+ event.motion.y,
+ &dn_rect)) {
+ dn_over = 1;
+ break;
+ } else {
+ dn_over = 0;
+ }
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ if (event.button.button != SDL_BUTTON_LEFT) {
+ break;
+ }
+ if (db_pt_in_rect(event.button.x,
+ event.button.y,
+ &up_rect)) {
+ text_src_rect.y -= 16;
+ if (text_src_rect.y < 0) {
+ text_src_rect.y = 0;
+ }
+ } else if (db_pt_in_rect(event.button.x,
+ event.button.y,
+ &dn_rect)) {
+ text_src_rect.y += 16;
+ if (text_src_rect.y > surface->h -
+ text_src_rect.h) {
+ text_src_rect.y = surface->h -
+ text_src_rect.h;
+ }
+ }
+ break;
default:
break;
}
@@ -190,19 +250,25 @@ db_help(void)
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture,
&text_src_rect, &text_dst_rect);
- if (text_src_rect.y > 0) {
+ if (text_src_rect.y <= 0) {
_db_help_triangle(renderer,
- 0x00, 0x00, 0xFF, 0xFF, 608, 16, -1);
+ 0x3F, 0x3F, 0x7F, 0xFF, 608, 16, -1);
+ } else if (up_over == 1) {
+ _db_help_triangle(renderer,
+ 0xFF, 0xFF, 0xFF, 0xFF, 608, 16, -1);
} else {
_db_help_triangle(renderer,
- 0x3F, 0x3F, 0x7F, 0xFF, 608, 16, -1);
+ 0x00, 0x00, 0xFF, 0xFF, 608, 16, -1);
}
- if (text_src_rect.y < surface->h - text_src_rect.h) {
+ if (text_src_rect.y >= surface->h - text_src_rect.h) {
_db_help_triangle(renderer,
- 0x00, 0x00, 0xFF, 0xFF, 608, 456, 1);
+ 0x3F, 0x3F, 0x7F, 0xFF, 608, 456, 1);
+ } else if (dn_over == 1) {
+ _db_help_triangle(renderer,
+ 0xFF, 0xFF, 0xFF, 0xFF, 608, 456, 1);
} else {
_db_help_triangle(renderer,
- 0x3F, 0x3F, 0x7F, 0xFF, 608, 456, 1);
+ 0x00, 0x00, 0xFF, 0xFF, 608, 456, 1);
}
SDL_RenderPresent(renderer);
}