umorna/source/menu.c

48 lines
1.1 KiB
C
Raw Normal View History

#include "core.h"
#include "game.h"
#include "engine.h"
#include "menu.h"
int menu (char * text,
int icon,
void (* action) (void)) {
menu_text [menu_count] = text;
menu_icon [menu_count] = icon;
menu_action [menu_count] = action;
return (menu_count++);
}
void menu_configure (void) {
int index;
for (index = 0; index < chad_trait_count; ++index) {
(void) menu (chad_trait_name [index], menu_count, 0);
}
for (index = 0; index < chad_skill_count; ++index) {
(void) menu (chad_skill_name [index], menu_count, 0);
}
for (index = 0; index < chad_value_count; ++index) {
(void) menu (chad_value_name [index], menu_count, 0);
}
}
void render_menu (void) {
int index;
for (index = 0; index < 27; ++index) {
int x = (menu_icon [index] / 10) * ICON_SIZE;
int y = (menu_icon [index] % 10) * ICON_SIZE;
render_icon (x, y, ICON_SIZE, ICON_SIZE, 1600, index * ICON_SIZE);
render_text (menu_text [index], 1600 + ICON_SIZE, index * ICON_SIZE);
}
}
int menu_count = 0;
char * menu_text [144];
int menu_icon [144];
void (* menu_action [144]) (void);