[Change] Everything is now conforming with major toolkit changes.

This commit is contained in:
Allanis 2014-01-19 21:01:49 +00:00
parent f0c8e3d158
commit be74e72b26

View File

@ -53,30 +53,28 @@ int menu_open = 0; /**< Store the opened/closed menus. */
/* Main menu. */ /* Main menu. */
void menu_main_close(void); /**< Externed in save.c */ void menu_main_close(void); /**< Externed in save.c */
static void menu_main_load(char* str); static void menu_main_load(unsigned int wid, char* str);
static void menu_main_new(char* str); static void menu_main_new(unsigned int wid, char* str);
static void menu_main_exit(char* str); static void menu_main_exit(unsigned int wid, char* str);
/* Small menu. */ /* Small menu. */
static void menu_small_close(char* str); static void menu_small_close(unsigned int wid, char* str);
static void menu_small_exit(char* str); static void menu_small_exit(unsigned int wid, char* str);
static void exit_game(void); static void exit_game(void);
/* Information menu. */ /* Information menu. */
static void menu_info_close(char* str); static void menu_info_close(unsigned int wid, char* str);
/* Outfits submenu. */ /* Outfits submenu. */
static void info_outfits_menu(char* str); static void info_outfits_menu(unsigned int parent, char* str);
/* Cargo submenu. */ /* Cargo submenu. */
static void info_cargo_menu(char* str); static void info_cargo_menu(unsigned int parent, char* str);
static void cargo_update(char* str); static void cargo_update(unsigned int wid, char* str);
static void cargo_jettison(char* str); static void cargo_jettison(unsigned int wid, char* str);
/* Mission submenu. */ /* Mission submenu. */
static void info_missions_menu(char* str); static void info_missions_menu(unsigned int parent, char* str);
static void mission_menu_abort(char* str); static void mission_menu_abort(unsigned int wid, char* str);
static void mission_menu_genList(int first); static void mission_menu_genList(unsigned int wid, int first);
static void mission_menu_update(char* str); static void mission_menu_update(unsigned int wid, char* str);
/* Death menu. */ /* Death menu. */
static void menu_death_main(char* str); static void menu_death_main(unsigned int parent, char* str);
/* Generic. */
static void menu_generic_close(char* str);
/** /**
* @fn void menu_main(void) * @fn void menu_main(void)
@ -132,41 +130,38 @@ void menu_main_close(void) {
} }
/** /**
* @fn static void menu_main_load(char* str)
*
* @brief Function to activate the load game menu. * @brief Function to activate the load game menu.
* @param str Unused. * @param str Unused.
*/ */
static void menu_main_load(char* str) { static void menu_main_load(unsigned int wid, char* str) {
(void)str; (void)str;
(void)wid;
load_game_menu(); load_game_menu();
} }
/** /**
* @fn static void menu_main_new(char* str)
*
* @brief Function to activate the new game menu. * @brief Function to activate the new game menu.
* @param str Unused. * @param str Unused.
*/ */
static void menu_main_new(char* str) { static void menu_main_new(unsigned int wid, char* str) {
(void)str; (void)str;
(void)wid;
menu_main_close(); menu_main_close();
player_new(); player_new();
} }
/** /**
* @fn static void menu_main_new(char* str)
*
* @brief Function to exit the main menu and game. * @brief Function to exit the main menu and game.
* @param str Unused. * @param str Unused.
*/ */
static void menu_main_exit(char* str) { static void menu_main_exit(unsigned int wid, char* str) {
(void)str; (void)str;
unsigned int wid; (void)wid;
unsigned int bg;
wid = window_get("BG"); bg = window_get("BG");
/* /*
* Ugly hack to prevent player.c from segfaulting due to the fact * Ugly hack to prevent player.c from segfaulting due to the fact
@ -175,8 +170,8 @@ static void menu_main_exit(char* str) {
* nor anything of the likes (nor toolkit to stop rendering) while not * nor anything of the likes (nor toolkit to stop rendering) while not
* leaking any texture. * leaking any texture.
*/ */
gl_freeTexture(window_getImage(wid, "imgLogo")); gl_freeTexture(window_getImage(bg, "imgLogo"));
window_modifyImage(wid, "imgLogo", NULL); window_modifyImage(bg, "imgLogo", NULL);
exit_game(); exit_game();
} }
@ -218,33 +213,27 @@ void menu_small(void) {
} }
/** /**
* @fn static void menu_small_close(char* str)
*
* @brief Close the small ingame menu. * @brief Close the small ingame menu.
* @param str Unused. * @param str Unused.
*/ */
static void menu_small_close(char* str) { static void menu_small_close(unsigned int wid, char* str) {
(void)str; (void)str;
window_destroy(window_get("Menu")); window_destroy(wid);
menu_Close(MENU_SMALL); menu_Close(MENU_SMALL);
} }
/** /**
* @fn static void menu_small_exit(char* str)
*
* @brief Close the small ingame menu and go back to the main menu. * @brief Close the small ingame menu and go back to the main menu.
* @param str Unused. * @param str Unused.
*/ */
static void menu_small_exit(char* str) { static void menu_small_exit(unsigned int wid, char* str) {
(void)str; (void)str;
window_destroy(window_get("Menu")); window_destroy(wid);
menu_Close(MENU_SMALL); menu_Close(MENU_SMALL);
menu_main(); menu_main();
} }
/** /**
* @fn static void exit_game(void)
*
* @brief Exit the game. * @brief Exit the game.
*/ */
static void exit_game(void) { static void exit_game(void) {
@ -323,26 +312,22 @@ void menu_info(void) {
} }
/** /**
* @fn static void menu_info_close(char* str)
*
* @brief Close the information menu. * @brief Close the information menu.
* @param str Unused. * @param str Unused.
*/ */
static void menu_info_close(char* str) { static void menu_info_close(unsigned int wid, char* str) {
if(strcmp(str, "btnClose")==0) (void)str;
window_destroy(window_get("Info")); window_destroy(wid);
menu_Close(MENU_INFO); menu_Close(MENU_INFO);
} }
/** /**
* @fn static void info_outfits_menu(char* str)
*
* @brief Show the player what outfits she has. * @brief Show the player what outfits she has.
* @param str Unused. * @param str Unused.
*/ */
static void info_outfits_menu(char* str) { static void info_outfits_menu(unsigned int parent, char* str) {
(void) str; (void) str;
(void) parent;
char* buf; char* buf;
unsigned int wid; unsigned int wid;
@ -364,17 +349,16 @@ static void info_outfits_menu(char* str) {
/* Buttons. */ /* Buttons. */
window_addButton(wid, -20, 20, window_addButton(wid, -20, 20,
BUTTON_WIDTH, BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT,
"closeOutfits", "Close", menu_generic_close); "closeOutfits", "Close", window_close);
} }
/** /**
* @fn static void info_cargo_menu(char* str)
*
* @brief Show the player her cargo. * @brief Show the player her cargo.
* @param str Unused. * @param str Unused.
*/ */
static void info_cargo_menu(char* str) { static void info_cargo_menu(unsigned int parent, char* str) {
(void)str; (void)str;
(void)parent;
unsigned int wid; unsigned int wid;
char** buf; char** buf;
int nbuf; int nbuf;
@ -385,7 +369,7 @@ static void info_cargo_menu(char* str) {
/* Buttons. */ /* Buttons. */
window_addButton(wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, window_addButton(wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
"closeCargo", "Back", menu_generic_close); "closeCargo", "Back", window_close);
window_addButton(wid, -40 - BUTTON_WIDTH, 20, window_addButton(wid, -40 - BUTTON_WIDTH, 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnJettisonCargo", "Jettison", BUTTON_WIDTH, BUTTON_HEIGHT, "btnJettisonCargo", "Jettison",
cargo_jettison); cargo_jettison);
@ -414,23 +398,19 @@ static void info_cargo_menu(char* str) {
CARGO_WIDTH - 40, CARGO_HEIGHT - BUTTON_HEIGHT - 80, CARGO_WIDTH - 40, CARGO_HEIGHT - BUTTON_HEIGHT - 80,
"lstCargo", buf, nbuf, 0, cargo_update); "lstCargo", buf, nbuf, 0, cargo_update);
cargo_update(NULL); cargo_update(wid, NULL);
} }
/** /**
* @fn static void cargo_update(char* str)
*
* @brief Update the players cargo in the cargo menu. * @brief Update the players cargo in the cargo menu.
* @param str Unused. * @param str Unused.
*/ */
static void cargo_update(char* str) { static void cargo_update(unsigned int wid, char* str) {
(void)str; (void)str;
unsigned int wid;
int pos; int pos;
if(player->ncommodities == 0) return; /* No cargo. */ if(player->ncommodities == 0) return; /* No cargo. */
wid = window_get("Cargo");
pos = toolkit_getListPos(wid, "lstCargo"); pos = toolkit_getListPos(wid, "lstCargo");
/* Can jettison all but mission cargo when not landed. */ /* Can jettison all but mission cargo when not landed. */
@ -441,19 +421,15 @@ static void cargo_update(char* str) {
} }
/** /**
* @fn static void cargo_jettison(char* str)
*
* @brief Make the player jettison the currently selected cargo. * @brief Make the player jettison the currently selected cargo.
* @param str Unused. * @param str Unused.
*/ */
static void cargo_jettison(char* str) { static void cargo_jettison(unsigned int wid, char* str) {
(void)str; (void)str;
unsigned int wid;
int pos; int pos;
if(player->ncommodities == 0) return; /* No cargo, redundant check. */ if(player->ncommodities == 0) return; /* No cargo, redundant check. */
wid = window_get("Cargo");
pos = toolkit_getListPos(wid, "lstCargo"); pos = toolkit_getListPos(wid, "lstCargo");
/* Remove the cargo. */ /* Remove the cargo. */
@ -463,25 +439,24 @@ static void cargo_jettison(char* str) {
player->commodities[pos].quantity); player->commodities[pos].quantity);
/* We reopen the menu to recreate the list now. */ /* We reopen the menu to recreate the list now. */
menu_generic_close("closeCargo"); window_destroy(wid);
info_cargo_menu(NULL); info_cargo_menu(0, NULL);
} }
/** /**
* @fn static void info_missions_menu(char* str)
*
* @brief Show the players active missions. * @brief Show the players active missions.
* @param str Unused. * @param str Unused.
*/ */
static void info_missions_menu(char* str) { static void info_missions_menu(unsigned int parent, char* str) {
(void)str; (void)str;
(void)parent;
unsigned int wid; unsigned int wid;
wid = window_create("Missions", -1, -1, MISSIONS_WIDTH, MISSIONS_HEIGHT); wid = window_create("Missions", -1, -1, MISSIONS_WIDTH, MISSIONS_HEIGHT);
/* Buttons. */ /* Buttons. */
window_addButton(wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, window_addButton(wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
"closeMissions", "Back", menu_generic_close); "closeMissions", "Back", window_close);
window_addButton(wid, -20, 40+BUTTON_HEIGHT, window_addButton(wid, -20, 40+BUTTON_HEIGHT,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnAbortMission", "Abort", BUTTON_WIDTH, BUTTON_HEIGHT, "btnAbortMission", "Abort",
@ -500,21 +475,16 @@ static void info_missions_menu(char* str) {
"txtDesc", &gl_smallFont, &cBlack, NULL); "txtDesc", &gl_smallFont, &cBlack, NULL);
/* List. */ /* List. */
mission_menu_genList(1); mission_menu_genList(wid, 1);
} }
/** /**
* @fn static void mission_menu_genList(int first)
*
* @brief Create the current mission list for the mission menu. * @brief Create the current mission list for the mission menu.
* @param first 1 if it's the first time run. * @param first 1 if it's the first time run.
*/ */
static void mission_menu_genList(int first) { static void mission_menu_genList(unsigned int wid, int first) {
int i, j; int i, j;
char** misn_names; char** misn_names;
unsigned int wid;
wid = window_get("Missions");
if(!first) if(!first)
window_destroyWidget(wid, "lstMission"); window_destroyWidget(wid, "lstMission");
@ -536,23 +506,17 @@ static void mission_menu_genList(int first) {
300, MISSIONS_HEIGHT-60, 300, MISSIONS_HEIGHT-60,
"lstMission", misn_names, j, 0, mission_menu_update); "lstMission", misn_names, j, 0, mission_menu_update);
mission_menu_update(NULL); mission_menu_update(wid, NULL);
} }
/** /**
* @fn static void mission_menu_update(char* str)
*
* @brief Update the mission menu mission info based on what's selected. * @brief Update the mission menu mission info based on what's selected.
* @param str Unused. * @param str Unused.
*/ */
static void mission_menu_update(char* str) { static void mission_menu_update(unsigned int wid, char* str) {
(void)str;
char* active_misn; char* active_misn;
Mission* misn; Mission* misn;
unsigned int wid;
(void)str;
wid = window_get("Missions");
active_misn = toolkit_getList(wid, "lstMission"); active_misn = toolkit_getList(wid, "lstMission");
if(strcmp(active_misn, "No Missions")==0) { if(strcmp(active_misn, "No Missions")==0) {
@ -568,20 +532,15 @@ static void mission_menu_update(char* str) {
} }
/** /**
* @fn static void mission_menu_abort(char* str)
*
* @brief Abort a mission in the mission menu. * @brief Abort a mission in the mission menu.
* @param str Unused. * @param str Unused.
*/ */
static void mission_menu_abort(char* str) { static void mission_menu_abort(unsigned int wid, char* str) {
(void)str; (void)str;
char* selected_misn; char* selected_misn;
int pos; int pos;
unsigned int wid;
Mission* misn; Mission* misn;
wid = window_get("Missions");
selected_misn = toolkit_getList(wid, "lstMission"); selected_misn = toolkit_getList(wid, "lstMission");
if(dialogue_YesNo("Abort Mission", if(dialogue_YesNo("Abort Mission",
@ -591,7 +550,7 @@ static void mission_menu_abort(char* str) {
mission_cleanup(misn); mission_cleanup(misn);
memmove(misn, &player_missions[pos+1], memmove(misn, &player_missions[pos+1],
sizeof(Mission) * (MISSION_MAX-pos-1)); sizeof(Mission) * (MISSION_MAX-pos-1));
mission_menu_genList(0); mission_menu_genList(wid, 0);
} }
} }
@ -608,7 +567,7 @@ void menu_death(void) {
BUTTON_WIDTH, BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT,
"btnMain", "Main Menu", menu_death_main); "btnMain", "Main Menu", menu_death_main);
window_addButton(wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, window_addButton(wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
"btnExit", "Exit Game", (void(*)(char*)) exit_game); "btnExit", "Exit Game", (void(*)(unsigned int,char*)) exit_game);
menu_Open(MENU_DEATH); menu_Open(MENU_DEATH);
@ -617,12 +576,11 @@ void menu_death(void) {
} }
/** /**
* @fn static void menu_death_main(char* str)
*
* @brief Close the player death menu. * @brief Close the player death menu.
* @param str Unused. * @param str Unused.
*/ */
static void menu_death_main(char* str) { static void menu_death_main(unsigned int parent, char* str) {
(void)parent;
(void)str; (void)str;
unsigned int wid; unsigned int wid;
@ -634,16 +592,3 @@ static void menu_death_main(char* str) {
menu_main(); menu_main();
} }
/**
* @fn static void menu_generic_close(char* str)
*
* @brief Generic function to close the current window.
*
* Only works if the button is labeled "closeFoo", where "Foo" would be the
* window name.
* @param str Used by the button it's assigned to internally.
*/
static void menu_generic_close(char* str) {
window_destroy(window_get(str+5)); /* closeFoo -> Foo. */
}