Correct reloadmenus command.

This commit is contained in:
momo5502 2015-12-24 12:30:52 +01:00
parent 85f0ebdc5d
commit 375014b55b
3 changed files with 34 additions and 1 deletions

View File

@ -397,8 +397,23 @@ namespace Components
Command::Add("reloadmenus", [] (Command::Params params)
{
if (Game::CL_IsCgameInitialized())
{
Logger::Print("Realoading menus in-game is not allowed!\n");
return;
}
// Close all menus
Game::Menus_CloseAll(0x62E2858);
// Free custom menus
Menus::FreeEverything();
// TODO: Refresh ui context?
// Reinitialize ui context
((void(*)())0x401700)();
// Reopen main menu
Game::Menus_OpenByName(0x62E2858, "main_text");
});
}

View File

@ -2,7 +2,12 @@
namespace Game
{
Cbuf_AddText_t Cbuf_AddText = (Cbuf_AddText_t)0x404B20;
CL_IsCgameInitialized_t CL_IsCgameInitialized = (CL_IsCgameInitialized_t)0x43EB20;
Cmd_AddCommand_t Cmd_AddCommand = (Cmd_AddCommand_t)0x470090;
Cmd_ExecuteSingleCommand_t Cmd_ExecuteSingleCommand = (Cmd_ExecuteSingleCommand_t)0x609540;
Com_Error_t Com_Error = (Com_Error_t)0x4B22D0;
Com_Printf_t Com_Printf = (Com_Printf_t)0x402500;
@ -32,6 +37,7 @@ namespace Game
FS_FreeFile_t FS_FreeFile = (FS_FreeFile_t)0x4416B0;
FS_ReadFile_t FS_ReadFile = (FS_ReadFile_t)0x4F4B90;
Menus_CloseAll_t Menus_CloseAll = (Menus_CloseAll_t)0x4BA5B0;
Menus_OpenByName_t Menus_OpenByName = (Menus_OpenByName_t)0x4CCE60;
LoadModdableRawfile_t LoadModdableRawfile = (LoadModdableRawfile_t)0x61ABC0;

View File

@ -1,8 +1,17 @@
namespace Game
{
typedef void(__cdecl * Cbuf_AddText_t)(int a1, const char* cmd);
extern Cbuf_AddText_t Cbuf_AddText;
typedef int(__cdecl * CL_IsCgameInitialized_t)();
extern CL_IsCgameInitialized_t CL_IsCgameInitialized;
typedef void(__cdecl * Cmd_AddCommand_t)(const char* name, void(*callback), cmd_function_t* data, char);
extern Cmd_AddCommand_t Cmd_AddCommand;
typedef void(__cdecl * Cmd_ExecuteSingleCommand_t)(int controller, int a2, const char* cmd);
extern Cmd_ExecuteSingleCommand_t Cmd_ExecuteSingleCommand;
typedef void(__cdecl * Com_Error_t)(int type, char* message, ...);
extern Com_Error_t Com_Error;
@ -66,6 +75,9 @@ namespace Game
typedef int(__cdecl * FS_ReadFile_t)(const char* path, char** buffer);
extern FS_ReadFile_t FS_ReadFile;
typedef void(__cdecl * Menus_CloseAll_t)(/*UiContext **/int dc);
extern Menus_CloseAll_t Menus_CloseAll;
typedef int(__cdecl * Menus_OpenByName_t)(/*UiContext **/int dc, const char *p);
extern Menus_OpenByName_t Menus_OpenByName;