Add "Fix Pause Menu"

This commit is contained in:
TheBrokenRail 2022-04-11 22:52:38 -04:00
parent f455780833
commit a3eef9fc3b
4 changed files with 47 additions and 0 deletions

View File

@ -32,3 +32,4 @@ TRUE Improved Cursor Rendering
FALSE Disable V-Sync
TRUE Fix Options Screen
FALSE Force Touch Inventory
TRUE Fix Pause Menu

View File

@ -45,6 +45,31 @@ static void Minecraft_update_injection(unsigned char *minecraft) {
}
}
// Add Missing Buttons To Pause Menu
static void PauseScreen_init_injection(unsigned char *screen) {
// Call Original Method
(*PauseScreen_init)(screen);
// Check If Server
unsigned char *minecraft = *(unsigned char **) (screen + Screen_minecraft_property_offset);
unsigned char *rak_net_instance = *(unsigned char **) (minecraft + Minecraft_rak_net_instance_property_offset);
if (rak_net_instance != NULL) {
unsigned char *rak_net_instance_vtable = *(unsigned char**) rak_net_instance;
RakNetInstance_isServer_t RakNetInstance_isServer = *(RakNetInstance_isServer_t *) (rak_net_instance_vtable + RakNetInstance_isServer_vtable_offset);
if ((*RakNetInstance_isServer)(rak_net_instance)) {
// Add Button
std::vector<unsigned char *> *rendered_buttons = (std::vector<unsigned char *> *) (screen + Screen_rendered_buttons_property_offset);
std::vector<unsigned char *> *selectable_buttons = (std::vector<unsigned char *> *) (screen + Screen_selectable_buttons_property_offset);
unsigned char *button = *(unsigned char **) (screen + PauseScreen_server_visibility_button_property_offset);
rendered_buttons->push_back(button);
selectable_buttons->push_back(button);
// Update Button Text
(*PauseScreen_updateServerVisibilityText)(screen);
}
}
}
// Init
void _init_misc_cpp() {
// Implement AppPlatform::readAssetFile So Translations Work
@ -54,4 +79,10 @@ void _init_misc_cpp() {
// Handle Custom Update Behavior
overwrite_calls((void *) Minecraft_update, (void *) Minecraft_update_injection);
// Fix Pause Menu
if (feature_has("Fix Pause Menu", server_disabled)) {
// Add Missing Buttons To Pause Menu
patch_address(PauseScreen_init_vtable_addr, (void *) PauseScreen_init_injection);
}
}

View File

@ -199,6 +199,11 @@ void _init_options_cpp() {
patch((void *) 0x1931c, nop_patch);
patch((void *) 0x1973c, nop_patch);
// Unsplit Touch Controls Breaks Things, Never Load/Save It
unsigned char cmp_r0_r0_patch[4] = {0x00, 0x00, 0x50, 0xe1}; // "cmp r0, r0"
patch((void *) 0x19378, cmp_r0_r0_patch);
patch((void *) 0x197cc, nop_patch);
// Replace "feedback_vibration" Loading/Saving With "gfx_ao"
{
// Replace String

View File

@ -495,6 +495,16 @@ static void *StartMenuScreen_init_vtable_addr = (void *) 0x105194;
static uint32_t StartMenuScreen_options_button_property_offset = 0x98; // Button
// PauseScreen
static Screen_init_t PauseScreen_init = (Screen_init_t) 0x36810;
static void *PauseScreen_init_vtable_addr = (void *) 0x104b2c;
typedef void (*PauseScreen_updateServerVisibilityText_t)(unsigned char *screen);
static PauseScreen_updateServerVisibilityText_t PauseScreen_updateServerVisibilityText = (PauseScreen_updateServerVisibilityText_t) 0x366b8;
static uint32_t PauseScreen_server_visibility_button_property_offset = 0x60; // Button *
// Touch::IngameBlockSelectionScreen
#define TOUCH_INGAME_BLOCK_SELECTION_SCREEN_SIZE 0x16c