More Feature Flags!
This commit is contained in:
parent
8ef6e0885a
commit
f1fe1c140c
@ -53,6 +53,11 @@
|
|||||||
* `Always Save Chest Tile Entities`
|
* `Always Save Chest Tile Entities`
|
||||||
* `Fix Transferring Durability When Using Items`
|
* `Fix Transferring Durability When Using Items`
|
||||||
* `Fix Switching Perspective While Sneaking`
|
* `Fix Switching Perspective While Sneaking`
|
||||||
|
* `Log Chat Messages`
|
||||||
|
* `Log Game Status`
|
||||||
|
* `Screenshot Support`
|
||||||
|
* `Fix Camera Functionality`
|
||||||
|
* `Property Scale Animated Textures`
|
||||||
* Split Up `Remove Creative Mode Restrictions` Feature Flag
|
* Split Up `Remove Creative Mode Restrictions` Feature Flag
|
||||||
* `Remove Creative Mode Restrictions` (Disabled By Default)
|
* `Remove Creative Mode Restrictions` (Disabled By Default)
|
||||||
* `Display Slot Count In Creative Mode` (Disabled By Default)
|
* `Display Slot Count In Creative Mode` (Disabled By Default)
|
||||||
|
@ -98,3 +98,8 @@ TRUE Fullscreen Support
|
|||||||
TRUE Always Save Chest Tile Entities
|
TRUE Always Save Chest Tile Entities
|
||||||
TRUE Fix Transferring Durability When Using Items
|
TRUE Fix Transferring Durability When Using Items
|
||||||
TRUE Fix Switching Perspective While Sneaking
|
TRUE Fix Switching Perspective While Sneaking
|
||||||
|
TRUE Log Chat Messages
|
||||||
|
TRUE Log Game Status
|
||||||
|
TRUE Screenshot Support
|
||||||
|
TRUE Fix Camera Functionality
|
||||||
|
TRUE Property Scale Animated Textures
|
@ -16,10 +16,10 @@ struct TextInputBox {
|
|||||||
void tick();
|
void tick();
|
||||||
void setFocused(bool b);
|
void setFocused(bool b);
|
||||||
void onClick(int x, int y);
|
void onClick(int x, int y);
|
||||||
bool clicked(int x, int y);
|
[[nodiscard]] bool clicked(int x, int y) const;
|
||||||
std::string getText();
|
[[nodiscard]] std::string getText() const;
|
||||||
void setText(std::string text);
|
void setText(std::string text);
|
||||||
bool isFocused();
|
[[nodiscard]] bool isFocused() const;
|
||||||
void setMaxLength(int max_length);
|
void setMaxLength(int max_length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -50,7 +50,9 @@ static void TripodCameraRenderer_render_TileRenderer_tesselateCrossTexture_injec
|
|||||||
// Init
|
// Init
|
||||||
void init_camera() {
|
void init_camera() {
|
||||||
// Implement AppPlatform_linux::saveScreenshot So Cameras Work
|
// Implement AppPlatform_linux::saveScreenshot So Cameras Work
|
||||||
|
if (feature_has("Fix Camera Functionality", server_disabled)) {
|
||||||
overwrite_calls(AppPlatform_saveScreenshot, AppPlatform_saveScreenshot_injection);
|
overwrite_calls(AppPlatform_saveScreenshot, AppPlatform_saveScreenshot_injection);
|
||||||
|
}
|
||||||
|
|
||||||
// Fix Camera Rendering
|
// Fix Camera Rendering
|
||||||
if (feature_has("Fix Camera Rendering", server_disabled)) {
|
if (feature_has("Fix Camera Rendering", server_disabled)) {
|
||||||
|
@ -13,9 +13,9 @@ std::string get_death_message(Player *player, Entity *cause, const bool was_shot
|
|||||||
std::string message = player->username;
|
std::string message = player->username;
|
||||||
if (cause) {
|
if (cause) {
|
||||||
// Entity cause
|
// Entity cause
|
||||||
int type_id = cause->getEntityTypeId();
|
const int type_id = cause->getEntityTypeId();
|
||||||
int aux = cause->getAuxData();
|
int aux = cause->getAuxData();
|
||||||
bool is_player = cause->isPlayer();
|
const bool is_player = cause->isPlayer();
|
||||||
if (cause->getCreatureBaseType() != 0 || is_player) {
|
if (cause->getCreatureBaseType() != 0 || is_player) {
|
||||||
// Killed by a creature
|
// Killed by a creature
|
||||||
if (was_shot) {
|
if (was_shot) {
|
||||||
@ -134,7 +134,6 @@ void init_death() {
|
|||||||
overwrite_calls(LocalPlayer_actuallyHurt, LocalPlayer_actuallyHurt_injection);
|
overwrite_calls(LocalPlayer_actuallyHurt, LocalPlayer_actuallyHurt_injection);
|
||||||
patch_vtable(ServerPlayer_actuallyHurt, ServerPlayer_actuallyHurt_injection);
|
patch_vtable(ServerPlayer_actuallyHurt, ServerPlayer_actuallyHurt_injection);
|
||||||
overwrite_calls(Mob_hurt, Mob_hurt_injection);
|
overwrite_calls(Mob_hurt, Mob_hurt_injection);
|
||||||
}
|
|
||||||
|
|
||||||
// Fix TNT
|
// Fix TNT
|
||||||
// This changes PrimedTnt_explode from Level::explode(nullptr, x, y, z, 3.1f) to Level::explode(this, x, y, z, 3.1f)
|
// This changes PrimedTnt_explode from Level::explode(nullptr, x, y, z, 3.1f) to Level::explode(this, x, y, z, 3.1f)
|
||||||
@ -142,4 +141,5 @@ void init_death() {
|
|||||||
patch((void *) 0x87998, cpy_r1_r0_patch);
|
patch((void *) 0x87998, cpy_r1_r0_patch);
|
||||||
unsigned char ldr_r0_24_patch[4] = {0x24, 0x00, 0x90, 0xe5}; // "ldr r0, [r0, #0x24]"
|
unsigned char ldr_r0_24_patch[4] = {0x24, 0x00, 0x90, 0xe5}; // "ldr r0, [r0, #0x24]"
|
||||||
patch((void *) 0x8799c, ldr_r0_24_patch);
|
patch((void *) 0x8799c, ldr_r0_24_patch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ void init_game_mode() {
|
|||||||
overwrite_call((void *) 0x16f84, (void *) ServerLevel_constructor->get(true));
|
overwrite_call((void *) 0x16f84, (void *) ServerLevel_constructor->get(true));
|
||||||
|
|
||||||
// Allocate Correct Size For ServerLevel
|
// Allocate Correct Size For ServerLevel
|
||||||
uint32_t level_size = sizeof(ServerLevel);
|
constexpr uint32_t level_size = sizeof(ServerLevel);
|
||||||
patch_address((void *) 0x17004, (void *) level_size);
|
patch_address((void *) 0x17004, (void *) level_size);
|
||||||
|
|
||||||
// Disable CreatorMode-Specific API Features (Polling Block Hits) In SurvivalMode, This Is Preferable To Crashing
|
// Disable CreatorMode-Specific API Features (Polling Block Hits) In SurvivalMode, This Is Preferable To Crashing
|
||||||
|
@ -12,9 +12,8 @@ __attribute__((constructor)) static void init() {
|
|||||||
init_compat();
|
init_compat();
|
||||||
if (reborn_is_server()) {
|
if (reborn_is_server()) {
|
||||||
init_server();
|
init_server();
|
||||||
} else {
|
|
||||||
init_multiplayer();
|
|
||||||
}
|
}
|
||||||
|
init_multiplayer();
|
||||||
if (!reborn_is_headless()) {
|
if (!reborn_is_headless()) {
|
||||||
init_sound();
|
init_sound();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ static bool MouseBuildInput_tickBuild_injection(MouseBuildInput_tickBuild_t orig
|
|||||||
const bool ret = original(mouse_build_input, local_player, build_action_intention_return);
|
const bool ret = original(mouse_build_input, local_player, build_action_intention_return);
|
||||||
// Convert Remove/Attack Into Attack If A Tile Is Not Selected
|
// Convert Remove/Attack Into Attack If A Tile Is Not Selected
|
||||||
if (ret && *build_action_intention_return == REMOVE_ATTACK_BAI) {
|
if (ret && *build_action_intention_return == REMOVE_ATTACK_BAI) {
|
||||||
Minecraft *minecraft = ((LocalPlayer *) local_player)->minecraft;
|
const Minecraft *minecraft = ((LocalPlayer *) local_player)->minecraft;
|
||||||
if (minecraft->hit_result.type != 0) {
|
if (minecraft->hit_result.type != 0) {
|
||||||
*build_action_intention_return = ATTACK_BAI;
|
*build_action_intention_return = ATTACK_BAI;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
// Store Right-Click Status
|
// Store Right-Click Status
|
||||||
static int is_right_click = 0;
|
static int is_right_click = 0;
|
||||||
void input_set_is_right_click(int val) {
|
void input_set_is_right_click(const int val) {
|
||||||
is_right_click = val;
|
is_right_click = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ static void _handle_drop(Minecraft *minecraft) {
|
|||||||
inventory_item->count = 0;
|
inventory_item->count = 0;
|
||||||
} else {
|
} else {
|
||||||
// Drop Item
|
// Drop Item
|
||||||
const int drop_count = 1;
|
constexpr int drop_count = 1;
|
||||||
dropped_item->count = drop_count;
|
dropped_item->count = drop_count;
|
||||||
inventory_item->count -= drop_count;
|
inventory_item->count -= drop_count;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ static void _handle_drop(Minecraft *minecraft) {
|
|||||||
// Init
|
// Init
|
||||||
void _init_drop() {
|
void _init_drop() {
|
||||||
if (feature_has("Bind \"Q\" Key To Item Dropping", server_disabled)) {
|
if (feature_has("Bind \"Q\" Key To Item Dropping", server_disabled)) {
|
||||||
misc_run_on_game_key_press([](Minecraft *mc, int key) {
|
misc_run_on_game_key_press([](Minecraft *mc, const int key) {
|
||||||
if (key == MC_KEY_q) {
|
if (key == MC_KEY_q) {
|
||||||
_handle_drop(mc);
|
_handle_drop(mc);
|
||||||
return true;
|
return true;
|
||||||
|
@ -32,7 +32,7 @@ static bool OptionsScreen_handleBackEvent_injection(OptionsScreen *screen, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fix "Sleeping Beauty" Bug
|
// Fix "Sleeping Beauty" Bug
|
||||||
static bool InBedScreen_handleBackEvent_injection(InBedScreen *screen, bool do_nothing) {
|
static bool InBedScreen_handleBackEvent_injection(InBedScreen *screen, const bool do_nothing) {
|
||||||
if (!do_nothing) {
|
if (!do_nothing) {
|
||||||
// Close Screen
|
// Close Screen
|
||||||
Minecraft *minecraft = screen->minecraft;
|
Minecraft *minecraft = screen->minecraft;
|
||||||
@ -48,7 +48,7 @@ static bool InBedScreen_handleBackEvent_injection(InBedScreen *screen, bool do_n
|
|||||||
|
|
||||||
// Block UI Interaction When Mouse Is Locked
|
// Block UI Interaction When Mouse Is Locked
|
||||||
static bool Gui_tickItemDrop_Minecraft_isCreativeMode_call_injection(Minecraft *minecraft) {
|
static bool Gui_tickItemDrop_Minecraft_isCreativeMode_call_injection(Minecraft *minecraft) {
|
||||||
bool is_in_game = minecraft->screen == nullptr || minecraft->screen->vtable == (Screen_vtable *) Touch_IngameBlockSelectionScreen_vtable_base;
|
const bool is_in_game = minecraft->screen == nullptr || minecraft->screen->vtable == (Screen_vtable *) Touch_IngameBlockSelectionScreen_vtable_base;
|
||||||
if (!enable_misc || (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF && is_in_game)) {
|
if (!enable_misc || (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF && is_in_game)) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
return creative_is_restricted() && minecraft->isCreativeMode();
|
return creative_is_restricted() && minecraft->isCreativeMode();
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "misc-internal.h"
|
#include "misc-internal.h"
|
||||||
#include <mods/misc/misc.h>
|
#include <mods/misc/misc.h>
|
||||||
|
#include <mods/feature/feature.h>
|
||||||
|
|
||||||
// Print Chat To Log
|
// Print Chat To Log
|
||||||
static bool Gui_addMessage_recursing = false;
|
static bool Gui_addMessage_recursing = false;
|
||||||
@ -13,7 +14,7 @@ static void Gui_addMessage_injection(Gui_addMessage_t original, Gui *gui, const
|
|||||||
char *new_message = strdup(text.c_str());
|
char *new_message = strdup(text.c_str());
|
||||||
ALLOC_CHECK(new_message);
|
ALLOC_CHECK(new_message);
|
||||||
sanitize_string(new_message, -1, 1);
|
sanitize_string(new_message, -1, 1);
|
||||||
std::string cpp_str = new_message;
|
const std::string cpp_str = new_message;
|
||||||
|
|
||||||
// Process Message
|
// Process Message
|
||||||
if (!Gui_addMessage_recursing) {
|
if (!Gui_addMessage_recursing) {
|
||||||
@ -50,8 +51,8 @@ static void print_progress(Minecraft *minecraft) {
|
|||||||
progress = -1;
|
progress = -1;
|
||||||
}
|
}
|
||||||
if (message != nullptr) {
|
if (message != nullptr) {
|
||||||
bool message_different = message != last_message;
|
const bool message_different = message != last_message;
|
||||||
bool progress_significant = is_progress_difference_significant(progress, last_progress);
|
const bool progress_significant = is_progress_difference_significant(progress, last_progress);
|
||||||
if (message_different || progress_significant) {
|
if (message_different || progress_significant) {
|
||||||
if (progress != -1) {
|
if (progress != -1) {
|
||||||
INFO("Status: %s: %i%%", message, progress);
|
INFO("Status: %s: %i%%", message, progress);
|
||||||
@ -86,13 +87,18 @@ static void Level_saveLevelData_injection(Level_saveLevelData_t original, Level
|
|||||||
// Init
|
// Init
|
||||||
void _init_misc_logging() {
|
void _init_misc_logging() {
|
||||||
// Print Chat To Log
|
// Print Chat To Log
|
||||||
|
if (feature_has("Log Chat Messages", server_enabled)) {
|
||||||
overwrite_calls(Gui_addMessage, Gui_addMessage_injection);
|
overwrite_calls(Gui_addMessage, Gui_addMessage_injection);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Game Status
|
||||||
|
if (feature_has("Log Game Status", server_enabled)) {
|
||||||
// Print Progress Reports
|
// Print Progress Reports
|
||||||
misc_run_on_update(Minecraft_update_injection);
|
misc_run_on_update(Minecraft_update_injection);
|
||||||
|
|
||||||
// Print Log On Game Save
|
// Print Log On Game Save
|
||||||
overwrite_calls(Level_saveLevelData, Level_saveLevelData_injection);
|
overwrite_calls(Level_saveLevelData, Level_saveLevelData_injection);
|
||||||
|
}
|
||||||
|
|
||||||
// Disable stdout Buffering
|
// Disable stdout Buffering
|
||||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||||
|
@ -81,16 +81,6 @@ static RakNet_StartupResult RakNetInstance_host_RakNet_RakPeer_Startup_injection
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix Bug Where RakNetInstance Starts Pinging Potential Servers Before The "Join Game" Screen Is Opened
|
|
||||||
static RakNetInstance *RakNetInstance_injection(RakNetInstance_constructor_t original, RakNetInstance *rak_net_instance) {
|
|
||||||
// Call Original Method
|
|
||||||
RakNetInstance *result = original(rak_net_instance);
|
|
||||||
// Fix
|
|
||||||
rak_net_instance->pinging_for_hosts = 0;
|
|
||||||
// Return
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix Furnace Not Checking Item Auxiliary When Inserting New Item
|
// Fix Furnace Not Checking Item Auxiliary When Inserting New Item
|
||||||
static int32_t FurnaceScreen_handleAddItem_injection(FurnaceScreen_handleAddItem_t original, FurnaceScreen *furnace_screen, int32_t slot, const ItemInstance *item) {
|
static int32_t FurnaceScreen_handleAddItem_injection(FurnaceScreen_handleAddItem_t original, FurnaceScreen *furnace_screen, int32_t slot, const ItemInstance *item) {
|
||||||
// Get Existing Item
|
// Get Existing Item
|
||||||
@ -461,11 +451,6 @@ void init_misc() {
|
|||||||
overwrite_call((void *) 0x73778, (void *) RakNetInstance_host_RakNet_RakPeer_Startup_injection);
|
overwrite_call((void *) 0x73778, (void *) RakNetInstance_host_RakNet_RakPeer_Startup_injection);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix Bug Where RakNetInstance Starts Pinging Potential Servers Before The "Join Game" Screen Is Opened
|
|
||||||
if (feature_has("Prevent Unnecessary Server Pinging", server_enabled)) {
|
|
||||||
overwrite_calls(RakNetInstance_constructor, RakNetInstance_injection);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix Furnace Not Checking Item Auxiliary When Inserting New Item
|
// Fix Furnace Not Checking Item Auxiliary When Inserting New Item
|
||||||
if (feature_has("Fix Furnace Not Checking Item Auxiliary", server_disabled)) {
|
if (feature_has("Fix Furnace Not Checking Item Auxiliary", server_disabled)) {
|
||||||
overwrite_calls(FurnaceScreen_handleAddItem, FurnaceScreen_handleAddItem_injection);
|
overwrite_calls(FurnaceScreen_handleAddItem, FurnaceScreen_handleAddItem_injection);
|
||||||
|
@ -113,10 +113,25 @@ static void RakNetInstance_pingForHosts_injection(RakNetInstance_pingForHosts_t
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix Bug Where RakNetInstance Starts Pinging Potential Servers Before The "Join Game" Screen Is Opened
|
||||||
|
static RakNetInstance *RakNetInstance_injection(RakNetInstance_constructor_t original, RakNetInstance *rak_net_instance) {
|
||||||
|
// Call Original Method
|
||||||
|
RakNetInstance *result = original(rak_net_instance);
|
||||||
|
// Fix
|
||||||
|
rak_net_instance->pinging_for_hosts = false;
|
||||||
|
// Return
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
void init_multiplayer() {
|
void init_multiplayer() {
|
||||||
// Inject Code
|
// Inject Code
|
||||||
if (feature_has("External Server Support", server_disabled)) {
|
if (feature_has("External Server Support", server_disabled)) {
|
||||||
overwrite_calls(RakNetInstance_pingForHosts, RakNetInstance_pingForHosts_injection);
|
overwrite_calls(RakNetInstance_pingForHosts, RakNetInstance_pingForHosts_injection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix Bug Where RakNetInstance Starts Pinging Potential Servers Before The "Join Game" Screen Is Opened
|
||||||
|
if (feature_has("Prevent Unnecessary Server Pinging", server_enabled)) {
|
||||||
|
overwrite_calls(RakNetInstance_constructor, RakNetInstance_injection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <mods/misc/misc.h>
|
#include <mods/misc/misc.h>
|
||||||
#include <mods/input/input.h>
|
#include <mods/input/input.h>
|
||||||
#include <mods/init/init.h>
|
#include <mods/init/init.h>
|
||||||
|
#include <mods/feature/feature.h>
|
||||||
|
|
||||||
// Ensure Screenshots Folder Exists
|
// Ensure Screenshots Folder Exists
|
||||||
static std::string get_screenshot_dir() {
|
static std::string get_screenshot_dir() {
|
||||||
@ -46,7 +47,7 @@ void screenshot_take(Gui *gui) {
|
|||||||
// Get Timestamp
|
// Get Timestamp
|
||||||
time_t raw_time;
|
time_t raw_time;
|
||||||
time(&raw_time);
|
time(&raw_time);
|
||||||
tm *time_info = localtime(&raw_time);
|
const tm *time_info = localtime(&raw_time);
|
||||||
char time[512];
|
char time[512];
|
||||||
strftime(time, 512, "%Y-%m-%d_%H.%M.%S", time_info);
|
strftime(time, 512, "%Y-%m-%d_%H.%M.%S", time_info);
|
||||||
|
|
||||||
@ -66,10 +67,10 @@ void screenshot_take(Gui *gui) {
|
|||||||
// Get Image Size
|
// Get Image Size
|
||||||
GLint viewport[4];
|
GLint viewport[4];
|
||||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||||
int x = viewport[0];
|
const int x = viewport[0];
|
||||||
int y = viewport[1];
|
const int y = viewport[1];
|
||||||
int width = viewport[2];
|
const int width = viewport[2];
|
||||||
int height = viewport[3];
|
const int height = viewport[3];
|
||||||
|
|
||||||
// Get Line Size
|
// Get Line Size
|
||||||
int line_size = width * 4;
|
int line_size = width * 4;
|
||||||
@ -80,7 +81,7 @@ void screenshot_take(Gui *gui) {
|
|||||||
// Round
|
// Round
|
||||||
line_size = ALIGN_UP(line_size, alignment);
|
line_size = ALIGN_UP(line_size, alignment);
|
||||||
}
|
}
|
||||||
int size = height * line_size;
|
const int size = height * line_size;
|
||||||
|
|
||||||
// Read Pixels
|
// Read Pixels
|
||||||
unsigned char *pixels = (unsigned char *) malloc(size);
|
unsigned char *pixels = (unsigned char *) malloc(size);
|
||||||
@ -105,6 +106,7 @@ void screenshot_take(Gui *gui) {
|
|||||||
|
|
||||||
// Init
|
// Init
|
||||||
void init_screenshot() {
|
void init_screenshot() {
|
||||||
|
if (feature_has("Screenshot Support", server_disabled)) {
|
||||||
// Create Directory
|
// Create Directory
|
||||||
get_screenshot_dir();
|
get_screenshot_dir();
|
||||||
// Take Screenshot On F2
|
// Take Screenshot On F2
|
||||||
@ -116,4 +118,5 @@ void init_screenshot() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -69,7 +69,7 @@ static int32_t Textures_loadAndBindTexture_injection(Textures *textures, __attri
|
|||||||
// Change Texture
|
// Change Texture
|
||||||
static std::string new_texture;
|
static std::string new_texture;
|
||||||
if (new_texture.length() == 0) {
|
if (new_texture.length() == 0) {
|
||||||
std::string username = base64_encode(Strings::default_username);
|
const std::string username = base64_encode(Strings::default_username);
|
||||||
new_texture = '$' + username;
|
new_texture = '$' + username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ std::string _sound_get_source_file() {
|
|||||||
|
|
||||||
// Play Sound
|
// Play Sound
|
||||||
// The pitch value is unsued because it causes glitchy sounds, it is seemingly unused in MCPE as well.
|
// The pitch value is unsued because it causes glitchy sounds, it is seemingly unused in MCPE as well.
|
||||||
static void play(std::string name, float x, float y, float z, float volume, float pitch, bool is_ui) {
|
static void play(const std::string &name, const float x, const float y, const float z, const float volume, float pitch, const bool is_ui) {
|
||||||
std::string source = _sound_get_source_file();
|
const std::string source = _sound_get_source_file();
|
||||||
std::string resolved_name = _sound_pick(name);
|
const std::string resolved_name = _sound_pick(name);
|
||||||
if (pitch < 0.01f) {
|
if (pitch < 0.01f) {
|
||||||
pitch = 1;
|
pitch = 1;
|
||||||
}
|
}
|
||||||
@ -69,10 +69,10 @@ static void play(std::string name, float x, float y, float z, float volume, floa
|
|||||||
media_audio_play(source.c_str(), resolved_name.c_str(), x, y, z, pitch, volume, is_ui);
|
media_audio_play(source.c_str(), resolved_name.c_str(), x, y, z, pitch, volume, is_ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void SoundEngine_playUI_injection(__attribute__((unused)) SoundEngine_playUI_t original, __attribute__((unused)) SoundEngine *sound_engine, const std::string &name, float volume, float pitch) {
|
static void SoundEngine_playUI_injection(__attribute__((unused)) SoundEngine_playUI_t original, __attribute__((unused)) SoundEngine *sound_engine, const std::string &name, const float volume, const float pitch) {
|
||||||
play(name, 0, 0, 0, volume, pitch, true);
|
play(name, 0, 0, 0, volume, pitch, true);
|
||||||
}
|
}
|
||||||
static void SoundEngine_play_injection(__attribute__((unused)) SoundEngine_play_t original, __attribute__((unused)) SoundEngine *sound_engine, const std::string &name, float x, float y, float z, float volume, float pitch) {
|
static void SoundEngine_play_injection(__attribute__((unused)) SoundEngine_play_t original, __attribute__((unused)) SoundEngine *sound_engine, const std::string &name, const float x, const float y, const float z, const float volume, const float pitch) {
|
||||||
play(name, x, y, z, volume, pitch, false);
|
play(name, x, y, z, volume, pitch, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ static void SoundEngine_update_injection(__attribute__((unused)) SoundEngine_upd
|
|||||||
Options *options = sound_engine->options;
|
Options *options = sound_engine->options;
|
||||||
|
|
||||||
// Volume
|
// Volume
|
||||||
int32_t sound_enabled = options->sound;
|
const int32_t sound_enabled = options->sound;
|
||||||
volume = sound_enabled ? 1 : 0;
|
volume = sound_enabled ? 1 : 0;
|
||||||
|
|
||||||
// Position And Rotation
|
// Position And Rotation
|
||||||
|
@ -28,7 +28,7 @@ TextInputBox *TextInputBox::create(const std::string &placeholder, const std::st
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextInputBox::setSize(int x, int y, int width, int height) {
|
void TextInputBox::setSize(const int x, const int y, const int width, const int height) {
|
||||||
m_xPos = x;
|
m_xPos = x;
|
||||||
m_yPos = y;
|
m_yPos = y;
|
||||||
m_width = width;
|
m_width = width;
|
||||||
@ -40,11 +40,11 @@ void TextInputBox::init(Font *pFont) {
|
|||||||
m_pFont = pFont;
|
m_pFont = pFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextInputBox::setEnabled(bool bEnabled) {
|
void TextInputBox::setEnabled(const bool bEnabled) {
|
||||||
m_bEnabled = bEnabled;
|
m_bEnabled = bEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextInputBox::keyPressed(int key) {
|
void TextInputBox::keyPressed(const int key) {
|
||||||
if (!m_bFocused) {
|
if (!m_bFocused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ void TextInputBox::tick() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextInputBox::setFocused(bool b) {
|
void TextInputBox::setFocused(const bool b) {
|
||||||
if (m_bFocused == b) {
|
if (m_bFocused == b) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ void TextInputBox::onClick(int x, int y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int PADDING = 5;
|
static int PADDING = 5;
|
||||||
void TextInputBox::charPressed(int k) {
|
void TextInputBox::charPressed(const int k) {
|
||||||
if (!m_bFocused) {
|
if (!m_bFocused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -165,9 +165,9 @@ void TextInputBox::charPressed(int k) {
|
|||||||
recalculateScroll();
|
recalculateScroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string get_rendered_text(Font *font, int width, int scroll_pos, std::string text) {
|
static std::string get_rendered_text(Font *font, const int width, const int scroll_pos, std::string text) {
|
||||||
std::string rendered_text = text.substr(scroll_pos);
|
std::string rendered_text = text.substr(scroll_pos);
|
||||||
int max_width = width - (PADDING * 2);
|
const int max_width = width - (PADDING * 2);
|
||||||
while (font->width(rendered_text) > max_width) {
|
while (font->width(rendered_text) > max_width) {
|
||||||
rendered_text.pop_back();
|
rendered_text.pop_back();
|
||||||
}
|
}
|
||||||
@ -194,14 +194,14 @@ void TextInputBox::render() {
|
|||||||
}
|
}
|
||||||
rendered_text = get_rendered_text(m_pFont, m_width, scroll_pos, rendered_text);
|
rendered_text = get_rendered_text(m_pFont, m_width, scroll_pos, rendered_text);
|
||||||
|
|
||||||
int textYPos = (m_height - 8) / 2;
|
const int textYPos = (m_height - 8) / 2;
|
||||||
super.drawString(m_pFont, rendered_text, m_xPos + PADDING, m_yPos + textYPos, text_color);
|
super.drawString(m_pFont, rendered_text, m_xPos + PADDING, m_yPos + textYPos, text_color);
|
||||||
|
|
||||||
if (m_bCursorOn) {
|
if (m_bCursorOn) {
|
||||||
int cursor_pos = m_insertHead - m_scrollPos;
|
const int cursor_pos = m_insertHead - m_scrollPos;
|
||||||
if (cursor_pos >= 0 && cursor_pos <= int(rendered_text.length())) {
|
if (cursor_pos >= 0 && cursor_pos <= int(rendered_text.length())) {
|
||||||
std::string substr = rendered_text.substr(0, cursor_pos);
|
std::string substr = rendered_text.substr(0, cursor_pos);
|
||||||
int xPos = PADDING + m_pFont->width(substr);
|
const int xPos = PADDING + m_pFont->width(substr);
|
||||||
|
|
||||||
std::string str;
|
std::string str;
|
||||||
str += CURSOR_CHAR;
|
str += CURSOR_CHAR;
|
||||||
@ -210,7 +210,7 @@ void TextInputBox::render() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextInputBox::clicked(int xPos, int yPos) {
|
bool TextInputBox::clicked(const int xPos, const int yPos) const {
|
||||||
if (!m_bEnabled) {
|
if (!m_bEnabled) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -237,18 +237,18 @@ void TextInputBox::recalculateScroll() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Ensure Cursor Is Visible
|
// Ensure Cursor Is Visible
|
||||||
bool is_cursor_at_end = m_insertHead == int(m_text.length());
|
const bool is_cursor_at_end = m_insertHead == int(m_text.length());
|
||||||
if (m_scrollPos >= m_insertHead && m_scrollPos > 0) {
|
if (m_scrollPos >= m_insertHead && m_scrollPos > 0) {
|
||||||
// Cursor Is At Scroll Position
|
// Cursor Is At Scroll Position
|
||||||
// Move Back Scroll As Far As Possible
|
// Move Back Scroll As Far As Possible
|
||||||
while (true) {
|
while (true) {
|
||||||
int test_scroll_pos = m_scrollPos - 1;
|
const int test_scroll_pos = m_scrollPos - 1;
|
||||||
std::string rendered_text = m_text;
|
std::string rendered_text = m_text;
|
||||||
if (is_cursor_at_end) {
|
if (is_cursor_at_end) {
|
||||||
rendered_text += CURSOR_CHAR;
|
rendered_text += CURSOR_CHAR;
|
||||||
}
|
}
|
||||||
rendered_text = get_rendered_text(m_pFont, m_width, test_scroll_pos, rendered_text);
|
rendered_text = get_rendered_text(m_pFont, m_width, test_scroll_pos, rendered_text);
|
||||||
int cursor_pos = m_insertHead - test_scroll_pos;
|
const int cursor_pos = m_insertHead - test_scroll_pos;
|
||||||
if (cursor_pos >= int(rendered_text.length())) {
|
if (cursor_pos >= int(rendered_text.length())) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -267,7 +267,7 @@ void TextInputBox::recalculateScroll() {
|
|||||||
rendered_text += CURSOR_CHAR;
|
rendered_text += CURSOR_CHAR;
|
||||||
}
|
}
|
||||||
rendered_text = get_rendered_text(m_pFont, m_width, m_scrollPos, rendered_text);
|
rendered_text = get_rendered_text(m_pFont, m_width, m_scrollPos, rendered_text);
|
||||||
int cursor_pos = m_insertHead - m_scrollPos;
|
const int cursor_pos = m_insertHead - m_scrollPos;
|
||||||
if (cursor_pos < int(rendered_text.length())) {
|
if (cursor_pos < int(rendered_text.length())) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -282,7 +282,7 @@ void TextInputBox::recalculateScroll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TextInputBox::getText() {
|
std::string TextInputBox::getText() const {
|
||||||
return m_text;
|
return m_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,10 +291,10 @@ void TextInputBox::setText(std::string str) {
|
|||||||
m_insertHead = int(m_text.size());
|
m_insertHead = int(m_text.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextInputBox::isFocused() {
|
bool TextInputBox::isFocused() const {
|
||||||
return m_bFocused;
|
return m_bFocused;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextInputBox::setMaxLength(int max_length) {
|
void TextInputBox::setMaxLength(const int max_length) {
|
||||||
m_maxLength = max_length;
|
m_maxLength = max_length;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
#include <libreborn/libreborn.h>
|
|
||||||
|
|
||||||
#include <mods/text-input-box/TextInputScreen.h>
|
#include <mods/text-input-box/TextInputScreen.h>
|
||||||
|
|
||||||
// VTable
|
// VTable
|
||||||
void TextInputScreen::setup(Screen_vtable *vtable) {
|
void TextInputScreen::setup(Screen_vtable *vtable) {
|
||||||
static Screen_keyPressed_t original_keyPressed = vtable->keyPressed;
|
static Screen_keyPressed_t original_keyPressed = vtable->keyPressed;
|
||||||
vtable->keyPressed = [](Screen *super2, int key) {
|
vtable->keyPressed = [](Screen *super2, const int key) {
|
||||||
original_keyPressed(super2, key);
|
original_keyPressed(super2, key);
|
||||||
TextInputScreen *self = (TextInputScreen *) super2;
|
TextInputScreen *self = (TextInputScreen *) super2;
|
||||||
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
||||||
@ -14,7 +12,7 @@ void TextInputScreen::setup(Screen_vtable *vtable) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
static Screen_keyboardNewChar_t original_keyboardNewChar = vtable->keyboardNewChar;
|
static Screen_keyboardNewChar_t original_keyboardNewChar = vtable->keyboardNewChar;
|
||||||
vtable->keyboardNewChar = [](Screen *super2, char key) {
|
vtable->keyboardNewChar = [](Screen *super2, const char key) {
|
||||||
original_keyboardNewChar(super2, key);
|
original_keyboardNewChar(super2, key);
|
||||||
TextInputScreen *self = (TextInputScreen *) super2;
|
TextInputScreen *self = (TextInputScreen *) super2;
|
||||||
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
||||||
@ -23,7 +21,7 @@ void TextInputScreen::setup(Screen_vtable *vtable) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
static Screen_mouseClicked_t original_mouseClicked = vtable->mouseClicked;
|
static Screen_mouseClicked_t original_mouseClicked = vtable->mouseClicked;
|
||||||
vtable->mouseClicked = [](Screen *super2, int x, int y, int param_1) {
|
vtable->mouseClicked = [](Screen *super2, const int x, const int y, const int param_1) {
|
||||||
original_mouseClicked(super2, x, y, param_1);
|
original_mouseClicked(super2, x, y, param_1);
|
||||||
TextInputScreen *self = (TextInputScreen *) super2;
|
TextInputScreen *self = (TextInputScreen *) super2;
|
||||||
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
||||||
@ -32,7 +30,7 @@ void TextInputScreen::setup(Screen_vtable *vtable) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
static Screen_render_t original_render = vtable->render;
|
static Screen_render_t original_render = vtable->render;
|
||||||
vtable->render = [](Screen *super2, int x, int y, float param_1) {
|
vtable->render = [](Screen *super2, const int x, const int y, const float param_1) {
|
||||||
original_render(super2, x, y, param_1);
|
original_render(super2, x, y, param_1);
|
||||||
TextInputScreen *self = (TextInputScreen *) super2;
|
TextInputScreen *self = (TextInputScreen *) super2;
|
||||||
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
@ -49,7 +49,7 @@ HOOK(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsi
|
|||||||
HOOK(glDeleteTextures, void, (GLsizei n, const GLuint *textures)) {
|
HOOK(glDeleteTextures, void, (GLsizei n, const GLuint *textures)) {
|
||||||
// Remove Old Data
|
// Remove Old Data
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
GLint id = textures[i];
|
const GLint id = textures[i];
|
||||||
std::vector<texture_data>::iterator it = get_texture_data().begin();
|
std::vector<texture_data>::iterator it = get_texture_data().begin();
|
||||||
while (it != get_texture_data().end()) {
|
while (it != get_texture_data().end()) {
|
||||||
texture_data data = *it;
|
texture_data data = *it;
|
||||||
@ -65,7 +65,7 @@ HOOK(glDeleteTextures, void, (GLsizei n, const GLuint *textures)) {
|
|||||||
ensure_glDeleteTextures();
|
ensure_glDeleteTextures();
|
||||||
real_glDeleteTextures(n, textures);
|
real_glDeleteTextures(n, textures);
|
||||||
}
|
}
|
||||||
static void get_texture_size(GLint id, GLsizei *width, GLsizei *height) {
|
static void get_texture_size(const GLint id, GLsizei *width, GLsizei *height) {
|
||||||
// Iterate
|
// Iterate
|
||||||
std::vector<texture_data>::iterator it = get_texture_data().begin();
|
std::vector<texture_data>::iterator it = get_texture_data().begin();
|
||||||
while (it != get_texture_data().end()) {
|
while (it != get_texture_data().end()) {
|
||||||
@ -85,7 +85,7 @@ static void get_texture_size(GLint id, GLsizei *width, GLsizei *height) {
|
|||||||
|
|
||||||
// Scale Texture (Remember To Free)
|
// Scale Texture (Remember To Free)
|
||||||
#define PIXEL_SIZE 4
|
#define PIXEL_SIZE 4
|
||||||
static int get_line_size(int width) {
|
static int get_line_size(const int width) {
|
||||||
int line_size = width * PIXEL_SIZE;
|
int line_size = width * PIXEL_SIZE;
|
||||||
{
|
{
|
||||||
// Handle Alignment
|
// Handle Alignment
|
||||||
@ -96,9 +96,9 @@ static int get_line_size(int width) {
|
|||||||
}
|
}
|
||||||
return line_size;
|
return line_size;
|
||||||
}
|
}
|
||||||
static void *scale_texture(const unsigned char *src, GLsizei old_width, GLsizei old_height, GLsizei new_width, GLsizei new_height) {
|
static void *scale_texture(const unsigned char *src, const GLsizei old_width, const GLsizei old_height, const GLsizei new_width, const GLsizei new_height) {
|
||||||
int old_line_size = get_line_size(old_width);
|
const int old_line_size = get_line_size(old_width);
|
||||||
int new_line_size = get_line_size(new_width);
|
const int new_line_size = get_line_size(new_width);
|
||||||
|
|
||||||
// Allocate
|
// Allocate
|
||||||
unsigned char *dst = (unsigned char *) malloc(new_height * new_line_size);
|
unsigned char *dst = (unsigned char *) malloc(new_height * new_line_size);
|
||||||
@ -106,13 +106,13 @@ static void *scale_texture(const unsigned char *src, GLsizei old_width, GLsizei
|
|||||||
|
|
||||||
// Scale
|
// Scale
|
||||||
for (int new_x = 0; new_x < new_width; new_x++) {
|
for (int new_x = 0; new_x < new_width; new_x++) {
|
||||||
int old_x = (int) (((float) new_x / (float) new_width) * (float) old_width);
|
const int old_x = (int) (((float) new_x / (float) new_width) * (float) old_width);
|
||||||
for (int new_y = 0; new_y < new_height; new_y++) {
|
for (int new_y = 0; new_y < new_height; new_y++) {
|
||||||
int old_y = (int) (((float) new_y / (float) new_height) * (float) old_height);
|
const int old_y = (int) (((float) new_y / (float) new_height) * (float) old_height);
|
||||||
|
|
||||||
// Find Position
|
// Find Position
|
||||||
int new_position = (new_y * new_line_size) + (new_x * PIXEL_SIZE);
|
const int new_position = (new_y * new_line_size) + (new_x * PIXEL_SIZE);
|
||||||
int old_position = (old_y * old_line_size) + (old_x * PIXEL_SIZE);
|
const int old_position = (old_y * old_line_size) + (old_x * PIXEL_SIZE);
|
||||||
|
|
||||||
// Copy
|
// Copy
|
||||||
static_assert(sizeof (int32_t) == PIXEL_SIZE, "Pixel Size Doesn't Match 32-Bit Integer Size");
|
static_assert(sizeof (int32_t) == PIXEL_SIZE, "Pixel Size Doesn't Match 32-Bit Integer Size");
|
||||||
@ -125,7 +125,7 @@ static void *scale_texture(const unsigned char *src, GLsizei old_width, GLsizei
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scale Animated Textures
|
// Scale Animated Textures
|
||||||
void glTexSubImage2D_with_scaling(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLsizei normal_texture_width, GLsizei normal_texture_height, GLenum format, GLenum type, const void *pixels) {
|
void glTexSubImage2D_with_scaling(const GLenum target, const GLint level, const GLint xoffset, const GLint yoffset, const GLsizei width, const GLsizei height, const GLsizei normal_texture_width, const GLsizei normal_texture_height, const GLenum format, const GLenum type, const void *pixels) {
|
||||||
// Get Current Texture Size
|
// Get Current Texture Size
|
||||||
GLint current_texture;
|
GLint current_texture;
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
||||||
@ -134,8 +134,8 @@ void glTexSubImage2D_with_scaling(GLenum target, GLint level, GLint xoffset, GLi
|
|||||||
get_texture_size(current_texture, &texture_width, &texture_height);
|
get_texture_size(current_texture, &texture_width, &texture_height);
|
||||||
|
|
||||||
// Calculate Factor
|
// Calculate Factor
|
||||||
float width_factor = ((float) texture_width) / ((float) normal_texture_width);
|
const float width_factor = ((float) texture_width) / ((float) normal_texture_width);
|
||||||
float height_factor = ((float) texture_height) / ((float) normal_texture_height);
|
const float height_factor = ((float) texture_height) / ((float) normal_texture_height);
|
||||||
|
|
||||||
// Only Scale If Needed
|
// Only Scale If Needed
|
||||||
if (width_factor == 1.0f && height_factor == 1.0f) {
|
if (width_factor == 1.0f && height_factor == 1.0f) {
|
||||||
@ -149,25 +149,25 @@ void glTexSubImage2D_with_scaling(GLenum target, GLint level, GLint xoffset, GLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scale
|
// Scale
|
||||||
GLsizei new_width = width * width_factor;
|
const GLsizei new_width = width * width_factor;
|
||||||
GLsizei new_height = height * height_factor;
|
const GLsizei new_height = height * height_factor;
|
||||||
void *new_pixels = scale_texture((const unsigned char *) pixels, width, height, new_width, new_height);
|
void *new_pixels = scale_texture((const unsigned char *) pixels, width, height, new_width, new_height);
|
||||||
|
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
GLint new_xoffset = xoffset * width_factor;
|
const GLint new_xoffset = xoffset * width_factor;
|
||||||
GLint new_yoffset = yoffset * height_factor;
|
const GLint new_yoffset = yoffset * height_factor;
|
||||||
glTexSubImage2D(target, level, new_xoffset, new_yoffset, new_width, new_height, format, type, new_pixels);
|
glTexSubImage2D(target, level, new_xoffset, new_yoffset, new_width, new_height, format, type, new_pixels);
|
||||||
|
|
||||||
// Free
|
// Free
|
||||||
free(new_pixels);
|
free(new_pixels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void Textures_tick_glTexSubImage2D_injection(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) {
|
static void Textures_tick_glTexSubImage2D_injection(const GLenum target, const GLint level, const GLint xoffset, const GLint yoffset, const GLsizei width, const GLsizei height, const GLenum format, const GLenum type, const void *pixels) {
|
||||||
glTexSubImage2D_with_scaling(target, level, xoffset, yoffset, width, height, 256, 256, format, type, pixels);
|
glTexSubImage2D_with_scaling(target, level, xoffset, yoffset, width, height, 256, 256, format, type, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Textures
|
// Load Textures
|
||||||
static Texture AppPlatform_linux_loadTexture_injection(__attribute__((unused)) AppPlatform_linux_loadTexture_t original, __attribute__((unused)) AppPlatform_linux *app_platform, const std::string &path, bool b) {
|
static Texture AppPlatform_linux_loadTexture_injection(__attribute__((unused)) AppPlatform_linux_loadTexture_t original, __attribute__((unused)) AppPlatform_linux *app_platform, const std::string &path, const bool b) {
|
||||||
Texture out;
|
Texture out;
|
||||||
std::string real_path = path;
|
std::string real_path = path;
|
||||||
if (b) {
|
if (b) {
|
||||||
@ -217,9 +217,9 @@ void init_textures() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tick Dynamic Textures (Animated Water)
|
// Tick Dynamic Textures (Animated Water)
|
||||||
bool animated_water = feature_has("Animated Water", server_disabled);
|
const bool animated_water = feature_has("Animated Water", server_disabled);
|
||||||
bool animated_lava = feature_has("Animated Lava", server_disabled);
|
const bool animated_lava = feature_has("Animated Lava", server_disabled);
|
||||||
bool animated_fire = feature_has("Animated Fire", server_disabled);
|
const bool animated_fire = feature_has("Animated Fire", server_disabled);
|
||||||
if (animated_water || animated_lava || animated_fire) {
|
if (animated_water || animated_lava || animated_fire) {
|
||||||
// Tick Dynamic Textures
|
// Tick Dynamic Textures
|
||||||
misc_run_on_tick(Minecraft_tick_injection);
|
misc_run_on_tick(Minecraft_tick_injection);
|
||||||
@ -234,7 +234,9 @@ void init_textures() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scale Animated Textures
|
// Scale Animated Textures
|
||||||
|
if (feature_has("Property Scale Animated Textures", server_disabled)) {
|
||||||
overwrite_call((void *) 0x53274, (void *) Textures_tick_glTexSubImage2D_injection);
|
overwrite_call((void *) 0x53274, (void *) Textures_tick_glTexSubImage2D_injection);
|
||||||
|
}
|
||||||
|
|
||||||
// Load Textures
|
// Load Textures
|
||||||
overwrite_calls(AppPlatform_linux_loadTexture, AppPlatform_linux_loadTexture_injection);
|
overwrite_calls(AppPlatform_linux_loadTexture, AppPlatform_linux_loadTexture_injection);
|
||||||
|
@ -19,14 +19,14 @@ static unsigned char *operator_new_IngameBlockSelectionScreen_injection(__attrib
|
|||||||
// Improved Button Hover Behavior
|
// Improved Button Hover Behavior
|
||||||
static int32_t Button_hovered_injection(__attribute__((unused)) Button_hovered_t original, __attribute__((unused)) Button *button, __attribute__((unused)) Minecraft *minecraft, __attribute__((unused)) int32_t click_x, __attribute__((unused)) int32_t click_y) {
|
static int32_t Button_hovered_injection(__attribute__((unused)) Button_hovered_t original, __attribute__((unused)) Button *button, __attribute__((unused)) Minecraft *minecraft, __attribute__((unused)) int32_t click_x, __attribute__((unused)) int32_t click_y) {
|
||||||
// Get Mouse Position
|
// Get Mouse Position
|
||||||
int32_t x = Mouse::getX() * Gui::InvGuiScale;
|
const int32_t x = Mouse::getX() * Gui::InvGuiScale;
|
||||||
int32_t y = Mouse::getY() * Gui::InvGuiScale;
|
const int32_t y = Mouse::getY() * Gui::InvGuiScale;
|
||||||
|
|
||||||
// Get Button Position
|
// Get Button Position
|
||||||
int32_t button_x1 = button->x;
|
const int32_t button_x1 = button->x;
|
||||||
int32_t button_y1 = button->y;
|
const int32_t button_y1 = button->y;
|
||||||
int32_t button_x2 = button_x1 + button->width;
|
const int32_t button_x2 = button_x1 + button->width;
|
||||||
int32_t button_y2 = button_y1 + button->height;
|
const int32_t button_y2 = button_y1 + button->height;
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
return x >= button_x1 && x < button_x2 && y >= button_y1 && y < button_y2;
|
return x >= button_x1 && x < button_x2 && y >= button_y1 && y < button_y2;
|
||||||
@ -50,7 +50,7 @@ static Button *create_button(int id, std::string text) {
|
|||||||
button->constructor(id, text);
|
button->constructor(id, text);
|
||||||
return (Button *) button;
|
return (Button *) button;
|
||||||
}
|
}
|
||||||
Button *touch_create_button(int id, std::string text) {
|
Button *touch_create_button(const int id, std::string text) {
|
||||||
if (touch_gui) {
|
if (touch_gui) {
|
||||||
return create_button<Touch_TButton>(id, text);
|
return create_button<Touch_TButton>(id, text);
|
||||||
} else {
|
} else {
|
||||||
@ -102,7 +102,7 @@ void init_touch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show Block Outlines
|
// Show Block Outlines
|
||||||
int block_outlines = feature_has("Show Block Outlines", server_disabled);
|
const bool block_outlines = feature_has("Show Block Outlines", server_disabled);
|
||||||
unsigned char outline_patch[4] = {(unsigned char) (block_outlines ? !touch_gui : touch_gui), 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" or "cmp r0, #0x0"
|
unsigned char outline_patch[4] = {(unsigned char) (block_outlines ? !touch_gui : touch_gui), 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" or "cmp r0, #0x0"
|
||||||
patch((void *) 0x4a210, outline_patch);
|
patch((void *) 0x4a210, outline_patch);
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,4 @@ virtual-method uint isServer() = 0x48;
|
|||||||
virtual-method void pingForHosts(int base_port) = 0x14;
|
virtual-method void pingForHosts(int base_port) = 0x14;
|
||||||
|
|
||||||
property RakNet_RakPeer *peer = 0x4;
|
property RakNet_RakPeer *peer = 0x4;
|
||||||
property uchar pinging_for_hosts = 0x24;
|
property bool pinging_for_hosts = 0x24;
|
||||||
|
Loading…
Reference in New Issue
Block a user