#include "core.h" #include "game.h" #include "engine.h" #include "menu.h" 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; return (menu_count++); } 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]++); } void menu_configure (void) { int index; menu_traits = define_menu ("Traits", 0, 0); for (index = 0; index < chad_trait_count; ++index) { (void) define_menu_item (menu_traits, chad_trait_name [index], index, 0); } menu_skills = define_menu ("Skills", 200, 0); for (index = 0; index < chad_skill_count; ++index) { (void) define_menu_item (menu_skills, chad_skill_name [index], 3 + index, 0); } menu_values = define_menu ("Values", 400, 0); for (index = 0; index < chad_value_count; ++index) { (void) define_menu_item (menu_values, chad_value_name [index], 27 + index, 0); } } void render_menu (int menu) { int index; 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); } } int menu_count = 0; 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;