Better Handling For Missing Sound
This commit is contained in:
parent
d6b289be27
commit
73739554c9
@ -16,7 +16,7 @@
|
||||
#cmakedefine MCPI_REPO "@MCPI_REPO@"
|
||||
|
||||
// Documentation
|
||||
#cmakedefine MCPI_DOCS "@MCPI_DOCUMENTATION@"
|
||||
#cmakedefine MCPI_DOCS "@MCPI_DOCS@"
|
||||
#define MCPI_DOCS_CHANGELOG MCPI_DOCS "CHANGELOG.md"
|
||||
#define MCPI_DOCS_GETTING_STARTED MCPI_DOCS "GETTING_STARTED.md"
|
||||
|
||||
|
6
mods/include/mods/options/options.h
Normal file
6
mods/include/mods/options/options.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
static constexpr const char *info_sound_data_loaded = "Loaded";
|
||||
extern std::string info_sound_data_state;
|
@ -8,6 +8,7 @@
|
||||
#include <mods/touch/touch.h>
|
||||
#include <mods/input/input.h>
|
||||
|
||||
// Store History
|
||||
static std::vector<std::string> &get_history() {
|
||||
static std::vector<std::string> history = {};
|
||||
return history;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <libreborn/util/exec.h>
|
||||
#include <libreborn/config.h>
|
||||
#include <libreborn/util/util.h>
|
||||
|
||||
#include <symbols/minecraft.h>
|
||||
@ -64,7 +63,7 @@ static info_line info[] = {
|
||||
.get_text = []() {
|
||||
return std::string("Sound Data: ") + info_sound_data_state;
|
||||
},
|
||||
.button_url = MCPI_DOCS_GETTING_STARTED "#sound",
|
||||
.button_url = SOUND_DOC_URL,
|
||||
.button_text = "More Info"
|
||||
},
|
||||
};
|
||||
|
@ -1,7 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <libreborn/config.h>
|
||||
#include <symbols/minecraft.h>
|
||||
|
||||
#define SOUND_DOC_URL MCPI_DOCS_GETTING_STARTED "#sound"
|
||||
|
||||
__attribute__((visibility("internal"))) void _init_options_ui();
|
||||
__attribute__((visibility("internal"))) extern Options *stored_options;
|
||||
__attribute__((visibility("internal"))) Screen *_create_options_info_screen();
|
@ -5,7 +5,6 @@
|
||||
#include <fstream>
|
||||
|
||||
#include <libreborn/patch.h>
|
||||
#include <libreborn/config.h>
|
||||
#include <libreborn/env/env.h>
|
||||
#include <libreborn/util/string.h>
|
||||
#include <libreborn/util/util.h>
|
||||
@ -14,6 +13,7 @@
|
||||
|
||||
#include <mods/feature/feature.h>
|
||||
#include <mods/init/init.h>
|
||||
#include <mods/options/options.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@ -51,6 +51,10 @@ static void Options_initDefaultValue_injection(Options_initDefaultValue_t origin
|
||||
// Default Graphics Settings
|
||||
options->fancy_graphics = true;
|
||||
options->ambient_occlusion = true;
|
||||
// Mute If Sound Data Is Missing
|
||||
if (info_sound_data_state != info_sound_data_loaded) {
|
||||
options->sound = 0;
|
||||
}
|
||||
}
|
||||
static void Minecraft_init_injection(Minecraft_init_t original, Minecraft *minecraft) {
|
||||
// Call Original Method
|
||||
|
@ -2,10 +2,12 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include <libreborn/patch.h>
|
||||
#include <libreborn/util/exec.h>
|
||||
|
||||
#include <symbols/minecraft.h>
|
||||
|
||||
#include <mods/feature/feature.h>
|
||||
#include <mods/options/options.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@ -156,6 +158,17 @@ static void OptionsScreen_removed_injection(OptionsScreen_removed_t original, Op
|
||||
original(self);
|
||||
}
|
||||
|
||||
// Show Documentation About Sound Data
|
||||
static void OptionButton_toggle_injection(OptionButton_toggle_t original, OptionButton *self, Options *options) {
|
||||
if (self->option == &Options_Option::SOUND && info_sound_data_state != info_sound_data_loaded) {
|
||||
// Open
|
||||
open_url(SOUND_DOC_URL);
|
||||
} else {
|
||||
// Call Original Method
|
||||
original(self, options);
|
||||
}
|
||||
}
|
||||
|
||||
// Init
|
||||
void _init_options_ui() {
|
||||
// Fix Options Screen
|
||||
@ -181,6 +194,9 @@ void _init_options_ui() {
|
||||
|
||||
// Fix Difficulty When Toggling
|
||||
overwrite_call((void *) 0x1cd00, Options_save, OptionButton_toggle_Options_save_injection);
|
||||
|
||||
// Show Documentation When User Attempts To Enable Sound Despite Missing Data
|
||||
overwrite_calls(OptionButton_toggle, OptionButton_toggle_injection);
|
||||
}
|
||||
|
||||
// Info Button
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include <mods/feature/feature.h>
|
||||
#include <mods/override/override.h>
|
||||
#include <mods/init/init.h>
|
||||
#include <mods/options/options.h>
|
||||
|
||||
// Resolve Source File Path
|
||||
#define SOURCE_FILE_BASE "data/libminecraftpe.so"
|
||||
extern std::string info_sound_data_state;
|
||||
std::string _sound_get_source_file() {
|
||||
static bool source_loaded = false;
|
||||
static std::string source;
|
||||
@ -36,7 +36,7 @@ std::string _sound_get_source_file() {
|
||||
} else {
|
||||
// Set
|
||||
source = full_path;
|
||||
info_sound_data_state = "Loaded";
|
||||
info_sound_data_state = info_sound_data_loaded;
|
||||
}
|
||||
|
||||
// Mark As Loaded
|
||||
|
@ -3,3 +3,4 @@ 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;
|
||||
static-property Options_Option SOUND = 0x136bcc;
|
@ -3,5 +3,6 @@ extends ImageButton;
|
||||
constructor (const Options_Option *option) = 0x1c968;
|
||||
|
||||
method void updateImage(Options *options) = 0x1ca58;
|
||||
method void toggle(Options *options) = 0x1cb08;
|
||||
|
||||
property Options_Option *option = 0x54;
|
||||
|
Loading…
x
Reference in New Issue
Block a user