From 4c33b6da9aa2535261f3dea1e82f180e88e6356d Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Mon, 14 Mar 2022 21:51:38 -0400 Subject: [PATCH] 2.3.1 Final --- docs/CHANGELOG.md | 2 ++ .../available-feature-flags | 1 + launcher/src/bootstrap.c | 5 ++++ mods/CMakeLists.txt | 2 +- mods/src/misc/misc.c | 29 +++++++++++++++++++ mods/src/touch/touch.c | 25 ---------------- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7956afa7a..cbd886e0f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,8 @@ * Internal Refactor Of ``libreborn`` * Remove Use Of ``/bin/sh`` * Load Custom Mods First +* Use Zenity Dark Mode +* Add ``Improved Cursor Rendering`` Feature Flag (Enabled By Default) **2.3.0** * Switch To AppImage For Packaging diff --git a/launcher/client-data/lib/minecraft-pi-reborn-client/available-feature-flags b/launcher/client-data/lib/minecraft-pi-reborn-client/available-feature-flags index 6faabd65a..e75d45613 100644 --- a/launcher/client-data/lib/minecraft-pi-reborn-client/available-feature-flags +++ b/launcher/client-data/lib/minecraft-pi-reborn-client/available-feature-flags @@ -32,3 +32,4 @@ TRUE Close Current Screen On Death FALSE Disable Raw Mouse Motion (Not Recommended) TRUE Fix Furnace Not Checking Item Auxiliary FALSE Disable Hosting LAN Worlds +TRUE Improved Cursor Rendering diff --git a/launcher/src/bootstrap.c b/launcher/src/bootstrap.c index 57ea68a1d..76b60df18 100644 --- a/launcher/src/bootstrap.c +++ b/launcher/src/bootstrap.c @@ -141,6 +141,11 @@ static void load(char **ld_preload, char *folder) { // Pre-Bootstrap void pre_bootstrap() { + // GTK Dark Mode +#ifndef MCPI_HEADLESS_MODE + set_and_print_env("GTK_THEME", "Adwaita:dark"); +#endif + // AppImage #ifdef MCPI_IS_APPIMAGE_BUILD char *owd = getenv("OWD"); diff --git a/mods/CMakeLists.txt b/mods/CMakeLists.txt index b45452825..1c3673117 100644 --- a/mods/CMakeLists.txt +++ b/mods/CMakeLists.txt @@ -72,7 +72,7 @@ add_library(death SHARED src/death/death.cpp) target_link_libraries(death reborn-patch symbols feature) add_library(misc SHARED src/misc/misc.c src/misc/misc.cpp src/misc/logging.cpp) -target_link_libraries(misc reborn-patch symbols feature GLESv1_CM) +target_link_libraries(misc reborn-patch symbols media-layer-core feature GLESv1_CM) add_library(options SHARED src/options/options.c) target_link_libraries(options reborn-patch symbols feature) diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index b8092e75c..858e49c53 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -6,6 +6,7 @@ #include #include +#include #include "../init/init.h" #include "../feature/feature.h" @@ -179,6 +180,25 @@ static int32_t FurnaceScreen_handleAddItem_injection(unsigned char *furnace_scre } } +// Custom Cursor Rendering +// +// The default behavior for Touch GUI is to only render the cursor when the mouse is clicking, this fixes that. +// This also makes the cursor always render if the mouse is unlocked, instead of just when there is a Screen showing. +static void GameRenderer_render_injection(unsigned char *game_renderer, float param_1) { + // Call Original Method + (*GameRenderer_render)(game_renderer, param_1); + + // Check If Cursor Should Render + if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) { + // Get X And Y + float x = (*Mouse_getX)() * (*InvGuiScale); + float y = (*Mouse_getY)() * (*InvGuiScale); + // Render Cursor + unsigned char *minecraft = *(unsigned char **) (game_renderer + GameRenderer_minecraft_property_offset); + (*renderCursor)(x, y, minecraft); + } +} + // Init void init_misc() { // Remove Invalid Item Background (A Red Background That Appears For Items That Are Not Included In The gui_blocks Atlas) @@ -216,6 +236,15 @@ void init_misc() { overwrite_calls((void *) FurnaceScreen_handleAddItem, (void *) FurnaceScreen_handleAddItem_injection); } + // Improved Cursor Rendering + if (feature_has("Improved Cursor Rendering", 0)) { + // Disable Normal Cursor Rendering + unsigned char disable_cursor_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" + patch((void *) 0x4a6c0, disable_cursor_patch); + // Add Custom Cursor Rendering + overwrite_calls((void *) GameRenderer_render, (void *) GameRenderer_render_injection); + } + // Init C++ And Logging _init_misc_cpp(); _init_misc_logging(); diff --git a/mods/src/touch/touch.c b/mods/src/touch/touch.c index dae8d7d73..fb47db0b1 100644 --- a/mods/src/touch/touch.c +++ b/mods/src/touch/touch.c @@ -10,25 +10,6 @@ static int32_t Minecraft_isTouchscreen_injection(__attribute__((unused)) unsigne return 1; } -// Custom Cursor Rendering -// The Default Behavior For Touch GUI Is To Only Render The Cursor When The Mouse Is Clicking, This Fixes That -static void GameRenderer_render_injection(unsigned char *game_renderer, float param_1) { - // Call Real Method - (*GameRenderer_render)(game_renderer, param_1); - - // Render Cursor - unsigned char *minecraft = *(unsigned char **) (game_renderer + GameRenderer_minecraft_property_offset); - unsigned char *current_screen = *(unsigned char **) (minecraft + Minecraft_screen_property_offset); - // Check If Cursor Should Render - if (current_screen != NULL) { - // Get X And Y - float x = (*Mouse_getX)() * (*InvGuiScale); - float y = (*Mouse_getY)() * (*InvGuiScale); - // Render - (*renderCursor)(x, y, minecraft); - } -} - // Init void init_touch() { int touch_gui = feature_has("Touch GUI", 0); @@ -36,12 +17,6 @@ void init_touch() { // Main UI overwrite((void *) Minecraft_isTouchscreen, (void *) Minecraft_isTouchscreen_injection); - // Disable Normal Cursor Rendering - unsigned char disable_cursor_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" - patch((void *) 0x4a6c0, disable_cursor_patch); - // Add Custom Cursor Rendering - overwrite_calls((void *) GameRenderer_render, (void *) GameRenderer_render_injection); - // Force Correct Toolbar Size unsigned char toolbar_patch[4] = {0x01, 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" patch((void *) 0x257b0, toolbar_patch);