1 #pragma once 2 3 //******************************************************************************************** 4 //* 5 //* This file is part of Egoboo. 6 //* 7 //* Egoboo is free software: you can redistribute it and/or modify it 8 //* under the terms of the GNU General Public License as published by 9 //* the Free Software Foundation, either version 3 of the License, or 10 //* (at your option) any later version. 11 //* 12 //* Egoboo is distributed in the hope that it will be useful, but 13 //* WITHOUT ANY WARRANTY; without even the implied warranty of 14 //* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 //* General Public License for more details. 16 //* 17 //* You should have received a copy of the GNU General Public License 18 //* along with Egoboo. If not, see <http://www.gnu.org/licenses/>. 19 //* 20 //******************************************************************************************** 21 22 /// @file menu.h 23 /// @details Implements the main menu tree, using the code in Ui.*. 24 25 #include "network.h" 26 #include "profile.h" 27 28 #include "egoboo_process.h" 29 #include "egoboo.h" 30 31 //-------------------------------------------------------------------------------------------- 32 //-------------------------------------------------------------------------------------------- 33 struct s_mod_file; 34 struct s_gfx_config; 35 36 //-------------------------------------------------------------------------------------------- 37 //-------------------------------------------------------------------------------------------- 38 39 /// a process that controls the menu system 40 struct s_menu_process 41 { 42 process_t base; 43 44 bool_t was_active; 45 bool_t escape_requested, escape_latch; 46 47 int ticks_next, ticks_now; 48 }; 49 typedef struct s_menu_process menu_process_t; 50 51 //-------------------------------------------------------------------------------------------- 52 //-------------------------------------------------------------------------------------------- 53 54 /// All the possible Egoboo menus. yay! 55 enum e_which_menu 56 { 57 emnu_Main, 58 emnu_SinglePlayer, 59 emnu_MultiPlayer, 60 emnu_ChooseModule, 61 emnu_ChoosePlayer, 62 emnu_ShowMenuResults, 63 emnu_Options, 64 emnu_GameOptions, 65 emnu_VideoOptions, 66 emnu_AudioOptions, 67 emnu_InputOptions, 68 emnu_NewPlayer, 69 emnu_LoadPlayer, 70 emnu_HostGame, 71 emnu_JoinGame, 72 emnu_GamePaused, 73 emnu_ShowEndgame, 74 emnu_NotImplemented 75 }; 76 typedef enum e_which_menu which_menu_t; 77 78 enum e_menu_retvals 79 { 80 MENU_SELECT = 1, 81 MENU_NOTHING = 0, 82 MENU_END = -1, 83 MENU_QUIT = -2 84 }; 85 86 //-------------------------------------------------------------------------------------------- 87 //-------------------------------------------------------------------------------------------- 88 // Input player control 89 #define MAX_LOADPLAYER 100 90 91 /// data for caching the which players may be loaded 92 struct s_LoadPlayer_element 93 { 94 STRING name; ///< the object's name 95 STRING dir; ///< the object's full path 96 97 CAP_REF cap_ref; ///< the character profile index 98 int skin_ref; ///< the index of the object's skin 99 TX_REF tx_ref; ///< the index of the texture 100 101 IDSZ_node_t quest_log[MAX_IDSZ_MAP_SIZE]; ///< all the quests this player has 102 chop_definition_t chop; ///< put this here so we can generate a name without loading an entire profile 103 }; 104 typedef struct s_LoadPlayer_element LoadPlayer_element_t; 105 106 LoadPlayer_element_t * LoadPlayer_element_ctor( LoadPlayer_element_t * ); 107 LoadPlayer_element_t * LoadPlayer_element_dtor( LoadPlayer_element_t * ); 108 109 bool_t LoadPlayer_element_dealloc( LoadPlayer_element_t * ); 110 bool_t LoadPlayer_element_init( LoadPlayer_element_t * ); 111 112 //-------------------------------------------------------------------------------------------- 113 struct s_LoadPlayer_list 114 { 115 int count; 116 LoadPlayer_element_t lst[MAX_LOADPLAYER]; 117 }; 118 typedef struct s_LoadPlayer_list LoadPlayer_list_t; 119 120 egoboo_rv LoadPlayer_list_init( LoadPlayer_list_t * lst ); 121 egoboo_rv LoadPlayer_list_import_one( LoadPlayer_list_t * lst, const char * foundfile ); 122 LoadPlayer_element_t * LoadPlayer_list_get_ptr( LoadPlayer_list_t * lst, int idx ); 123 egoboo_rv LoadPlayer_list_dealloc( LoadPlayer_list_t * lst ); 124 int LoadPlayer_list_get_free( LoadPlayer_list_t * lst ); 125 egoboo_rv LoadPlayer_list_import_all( LoadPlayer_list_t * lst, const char *dirname, bool_t initialize ); 126 egoboo_rv LoadPlayer_list_from_players( LoadPlayer_list_t * lst ); 127 128 #define LOADPLAYER_LIST_INIT { 0 } 129 #define VALID_LOADPLAYER_IDX(LST, IDX) ( ((IDX) > 0) && ((IDX)<(LST).count) && ((IDX)<MAX_LOADPLAYER) ) 130 131 //-------------------------------------------------------------------------------------------- 132 //-------------------------------------------------------------------------------------------- 133 extern bool_t mnu_draw_background; 134 135 extern menu_process_t * MProc; 136 137 extern bool_t module_list_valid; 138 139 //-------------------------------------------------------------------------------------------- 140 //-------------------------------------------------------------------------------------------- 141 142 // code for initializing and deinitializing the menu system 143 int menu_system_begin(); 144 void menu_system_end(); 145 146 // global function to control navigation of the game menus 147 int doMenu( float deltaTime ); 148 149 // code to start and stop menus 150 bool_t mnu_begin_menu( which_menu_t which ); 151 void mnu_end_menu(); 152 int mnu_get_menu_depth(); 153 154 // "public" implmentation of the TxTitleImage array 155 void TxTitleImage_reload_all(); 156 TX_REF TxTitleImage_load_one_vfs( const char *szLoadName ); 157 158 extern bool_t start_new_player; 159 160 // "public" implementation of mnu_ModList 161 struct s_mod_file * mnu_ModList_get_base( int imod ); 162 const char * mnu_ModList_get_vfs_path( int imod ); 163 const char * mnu_ModList_get_dest_path( int imod ); 164 const char * mnu_ModList_get_name( int imod ); 165 166 // "public" module utilities 167 int mnu_get_mod_number( const char *szModName ); 168 bool_t mnu_test_module_by_name( LoadPlayer_list_t * lp_lst, const char *szModName ); 169 bool_t mnu_test_module_by_index( LoadPlayer_list_t * lp_lst, const MOD_REF modnumber, size_t buffer_len, char * buffer ); 170 171 // "public" menu process hooks 172 int do_menu_proc_run( menu_process_t * mproc, double frameDuration ); 173 menu_process_t * menu_process_init( menu_process_t * mproc ); 174 175 // "public" reset of the autoformatting 176 void autoformat_init( struct s_gfx_config * pgfx ); 177 178 #define egoboo_Menu_h