2023-12-20 00:07:54 -05:00
|
|
|
#include "core.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "menu.h"
|
|
|
|
|
2023-12-20 06:52:13 -05:00
|
|
|
int define_menu (char * title,
|
|
|
|
int x,
|
|
|
|
int y) {
|
|
|
|
menu_title [menu_count] = title;
|
|
|
|
menu_items [menu_count] = 0;
|
|
|
|
menu_x [menu_count] = x;
|
|
|
|
menu_y [menu_count] = y;
|
|
|
|
menu_show [menu_count] = 0;
|
2023-12-20 00:07:54 -05:00
|
|
|
|
|
|
|
return (menu_count++);
|
|
|
|
}
|
|
|
|
|
2023-12-20 06:52:13 -05:00
|
|
|
int define_menu_item (int menu,
|
|
|
|
char * text,
|
|
|
|
int icon,
|
|
|
|
void (* action) (void)) {
|
|
|
|
menu_text [menu] [menu_items [menu]] = text;
|
|
|
|
menu_icon [menu] [menu_items [menu]] = icon;
|
|
|
|
menu_action [menu] [menu_items [menu]] = action;
|
|
|
|
|
|
|
|
return (menu_items [menu]++);
|
|
|
|
}
|
|
|
|
|
2023-12-20 00:07:54 -05:00
|
|
|
void menu_configure (void) {
|
|
|
|
int index;
|
|
|
|
|
2023-12-20 06:52:13 -05:00
|
|
|
menu_traits = define_menu ("Traits", 0, 0);
|
|
|
|
|
2023-12-20 00:07:54 -05:00
|
|
|
for (index = 0; index < chad_trait_count; ++index) {
|
2023-12-20 06:52:13 -05:00
|
|
|
(void) define_menu_item (menu_traits, chad_trait_name [index], index, 0);
|
2023-12-20 00:07:54 -05:00
|
|
|
}
|
|
|
|
|
2023-12-20 06:52:13 -05:00
|
|
|
menu_skills = define_menu ("Skills", 200, 0);
|
|
|
|
|
2023-12-20 00:07:54 -05:00
|
|
|
for (index = 0; index < chad_skill_count; ++index) {
|
2023-12-20 06:52:13 -05:00
|
|
|
(void) define_menu_item (menu_skills, chad_skill_name [index], 3 + index, 0);
|
2023-12-20 00:07:54 -05:00
|
|
|
}
|
|
|
|
|
2023-12-20 06:52:13 -05:00
|
|
|
menu_values = define_menu ("Values", 400, 0);
|
|
|
|
|
2023-12-20 00:07:54 -05:00
|
|
|
for (index = 0; index < chad_value_count; ++index) {
|
2023-12-20 06:52:13 -05:00
|
|
|
(void) define_menu_item (menu_values, chad_value_name [index], 27 + index, 0);
|
2023-12-20 00:07:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-20 06:52:13 -05:00
|
|
|
void render_menu (int menu) {
|
2023-12-20 00:07:54 -05:00
|
|
|
int index;
|
|
|
|
|
2023-12-20 06:52:13 -05:00
|
|
|
for (index = 0; index < menu_items [menu]; ++index) {
|
|
|
|
int x = (menu_icon [menu] [index] / 10) * ICON_SIZE;
|
|
|
|
int y = (menu_icon [menu] [index] % 10) * ICON_SIZE;
|
|
|
|
render_icon (x, y, ICON_SIZE, ICON_SIZE, menu_x [menu], menu_y [menu] + index * ICON_SIZE);
|
|
|
|
render_text (menu_text [menu] [index], menu_x [menu] + ICON_SIZE, menu_y [menu] + index * ICON_SIZE);
|
2023-12-20 00:07:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int menu_count = 0;
|
|
|
|
|
2023-12-20 06:52:13 -05:00
|
|
|
char * menu_title [24];
|
|
|
|
int menu_items [24];
|
|
|
|
int menu_x [24];
|
|
|
|
int menu_y [24];
|
|
|
|
int menu_show [24];
|
|
|
|
|
|
|
|
char * menu_text [24] [24];
|
|
|
|
int menu_icon [24] [24];
|
|
|
|
void (* menu_action [24] [24]) (void);
|
|
|
|
|
|
|
|
int menu_traits, menu_skills, menu_values;
|