Fix Options Button On Classic UI

This commit is contained in:
TheBrokenRail 2022-04-11 18:48:43 -04:00
parent 623cf06516
commit 0150879d2b
3 changed files with 50 additions and 3 deletions

View File

@ -48,6 +48,10 @@ static void Options_initDefaultValue_injection(unsigned char *options) {
// Render Distance
*(int32_t *) (options + Options_render_distance_property_offset) = render_distance;
// Default Graphics Settings
*(options + Options_fancy_graphics_property_offset) = 1;
*(options + Options_ambient_occlusion_property_offset) = 1;
// Store
stored_options = options;
}

View File

@ -127,6 +127,19 @@ static bool Options_getBooleanValue_injection(unsigned char *options, unsigned c
}
}
// Add Options Button Back To Classic Start Screen
static void StartMenuScreen_init_injection(unsigned char *screen) {
// Call Original Method
(*StartMenuScreen_init)(screen);
// 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 *options_button = screen + StartMenuScreen_options_button_property_offset;
rendered_buttons->push_back(options_button);
selectable_buttons->push_back(options_button);
}
// Init C++
void _init_options_cpp() {
// NOP
@ -151,6 +164,26 @@ void _init_options_cpp() {
// Add Missing Options To Options::getBooleanValue
overwrite_calls((void *) Options_getBooleanValue, (void *) Options_getBooleanValue_injection);
// Add Options Button Back To Classic Start Screen
patch_address(StartMenuScreen_init_vtable_addr, (void *) StartMenuScreen_init_injection);
// Fix Classic UI Options Button Size
unsigned char classic_options_button_width_patch[4] = {0xa0, 0x00, 0xa0, 0xe3}; // "mov r0, #0xa0"
patch((void *) 0x39a98, classic_options_button_width_patch);
unsigned char classic_options_button_height_patch[4] = {0x18, 0x30, 0xa0, 0xe3}; // "mov r3, #0x18"
patch((void *) 0x39a9c, classic_options_button_height_patch);
// Fix Classic UI Buttons Spacing
{
// Join Button
unsigned char classic_join_button_spacing_patch[4] = {0x12, 0x20, 0x83, 0xe2}; // "add r2, r3, #0x12"
patch((void *) 0x39894, classic_join_button_spacing_patch);
// Start Button
unsigned char classic_start_button_spacing_patch[4] = {0x08, 0x20, 0x43, 0xe2}; // "sub r2, r3, #0x08"
patch((void *) 0x3988c, classic_start_button_spacing_patch);
// Options Button
unsigned char classic_options_button_spacing_patch[4] = {0x2c, 0x30, 0x83, 0xe2}; // "add r3, r3, #0x2c"
patch((void *) 0x39898, classic_options_button_spacing_patch);
}
}
// Actually Save options.txt
@ -170,9 +203,8 @@ void _init_options_cpp() {
{
// Replace String
static const char *new_feedback_vibration_options_txt_nam = "gfx_ao";
static const char **new_feedback_vibration_options_txt_nam_ptr = &new_feedback_vibration_options_txt_nam;
patch_address((void *) feedback_vibration_options_txt_name_1, (void *) new_feedback_vibration_options_txt_nam_ptr);
patch_address((void *) feedback_vibration_options_txt_name_2, (void *) new_feedback_vibration_options_txt_nam_ptr);
patch_address((void *) feedback_vibration_options_txt_name_1, (void *) &new_feedback_vibration_options_txt_nam);
patch_address((void *) feedback_vibration_options_txt_name_2, (void *) &new_feedback_vibration_options_txt_nam);
// Loading
unsigned char gfx_ao_loading_patch[4] = {(unsigned char) Options_ambient_occlusion_property_offset, 0x10, 0x84, 0xe2}; // "add param_2, r4, #OFFSET"
patch((void *) 0x193b8, gfx_ao_loading_patch);

View File

@ -478,11 +478,22 @@ static uint32_t Screen_keyboardNewChar_vtable_offset = 0x70;
typedef void (*Screen_keyPressed_t)(unsigned char *screen, int32_t key);
static uint32_t Screen_keyPressed_vtable_offset = 0x6c;
typedef void (*Screen_init_t)(unsigned char *screen);
typedef void (*Screen_tick_t)(unsigned char *screen);
typedef int32_t (*Screen_handleBackEvent_t)(unsigned char *screen, bool param_1);
static uint32_t Screen_minecraft_property_offset = 0x14; // Minecraft *
static uint32_t Screen_rendered_buttons_property_offset = 0x18; // std::vector<Button *>
static uint32_t Screen_selectable_buttons_property_offset = 0x30; // std::vector<Button *>
// StartMenuScreen
static Screen_init_t StartMenuScreen_init = (Screen_init_t) 0x39cc0;
static void *StartMenuScreen_init_vtable_addr = (void *) 0x105194;
static uint32_t StartMenuScreen_options_button_property_offset = 0x98; // Button
// SelectWorldScreen