Add Peaceful Mode To Options Screen

This commit is contained in:
TheBrokenRail 2024-02-02 14:49:47 -05:00
parent 99b43ddb5a
commit eaf6dd2fe2
3 changed files with 28 additions and 0 deletions

View File

@ -127,6 +127,12 @@ static void OptionsPane_unknown_toggle_creating_function_injection(OptionsPane *
std::string cpp_string = "3D Anaglyph";
OptionsPane_unknown_toggle_creating_function(options_pane, group_id, &cpp_string, &Options_Option_ANAGLYPH);
}
// Add Peaceful Mode
if (option == &Options_Option_SERVER_VISIBLE) {
std::string cpp_string = "Peaceful mode";
OptionsPane_unknown_toggle_creating_function(options_pane, group_id, &cpp_string, &Options_Option_DIFFICULTY);
}
}
// Add Missing Options To Options::getBooleanValue
@ -134,12 +140,28 @@ static bool Options_getBooleanValue_injection(Options *options, Options_Option *
// Check
if (option == &Options_Option_GRAPHICS) {
return options->fancy_graphics;
} else if (option == &Options_Option_DIFFICULTY) {
return options->game_difficulty == 0;
} else {
// Call Original Method
return Options_getBooleanValue(options, option);
}
}
// Fix Difficulty When Toggling
static void OptionButton_toggle_Options_save_injection(Options *self) {
// Fix Value
if (self->game_difficulty == 1) {
// Disable Peaceful
self->game_difficulty = 2;
} else if (self->game_difficulty == 3) {
// Switch To Peaceful
self->game_difficulty = 0;
}
// Call Original Method
Options_save(self);
}
// Init C++
void _init_options_cpp() {
// NOP
@ -164,6 +186,9 @@ void _init_options_cpp() {
// Add Missing Options To Options::getBooleanValue
overwrite_calls((void *) Options_getBooleanValue, (void *) Options_getBooleanValue_injection);
// Fix Difficulty When Toggling
overwrite_call((void *) 0x1cd00, (void *) OptionButton_toggle_Options_save_injection);
}
// Actually Save options.txt

View File

@ -3,6 +3,7 @@ size 0x110;
method void initDefaultValue() = 0x18a54;
method bool getBooleanValue(Options_Option *option) = 0x1cd74;
method void addOptionToSaveOutput(std::vector<std::string> *data, std::string option, int value) = 0x195e4;
method void save() = 0x1966c;
property OptionsFile options_file = 0x10c;
property bool fancy_graphics = 0x17;

View File

@ -1,3 +1,5 @@
static-property Options_Option GRAPHICS = 0x136c2c;
static-property Options_Option AMBIENT_OCCLUSION = 0x136c38;
static-property Options_Option ANAGLYPH = 0x136c08;
static-property Options_Option DIFFICULTY = 0x136c20;
static-property Options_Option SERVER_VISIBLE = 0x136c68;