Add Translucent Toolbar

This commit is contained in:
TheBrokenRail 2022-07-14 19:52:51 -04:00
parent 93eb7807aa
commit ce168c1c16
4 changed files with 39 additions and 7 deletions

View File

@ -40,3 +40,4 @@ TRUE Implement Create World Dialog
FALSE Remove Forced GUI Lag (Can Break Joining Servers) FALSE Remove Forced GUI Lag (Can Break Joining Servers)
TRUE Add Buckets TRUE Add Buckets
TRUE Classic HUD TRUE Classic HUD
TRUE Translucent Toolbar

View File

@ -39,6 +39,7 @@ extern "C" {
#define GL_FOG_END 0xb64 #define GL_FOG_END 0xb64
#define GL_FOG_MODE 0xb65 #define GL_FOG_MODE 0xb65
#define GL_FOG_COLOR 0xb66 #define GL_FOG_COLOR 0xb66
#define GL_BLEND 0xbe2
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>

View File

@ -17,17 +17,22 @@
// Classic HUD // Classic HUD
#define DEFAULT_HUD_PADDING 2 #define DEFAULT_HUD_PADDING 2
#define NEW_HUD_PADDING 1
#define HUD_ELEMENT_WIDTH 82 #define HUD_ELEMENT_WIDTH 82
#define HUD_ELEMENT_HEIGHT 9 #define HUD_ELEMENT_HEIGHT 9
#define TOOLBAR_HEIGHT 22
#define SLOT_WIDTH 20
#define DEFAULT_BUBBLES_PADDING 1 #define DEFAULT_BUBBLES_PADDING 1
#define NUMBER_OF_SLOTS 9 #define NUMBER_OF_SLOTS 9
static int use_classic_hud = 0; static int use_classic_hud = 0;
static void Gui_renderHearts_GuiComponent_blit_hearts_injection(unsigned char *component, int32_t x_dest, int32_t y_dest, int32_t x_src, int32_t y_src, int32_t width_dest, int32_t height_dest, int32_t width_src, int32_t height_src) { static void Gui_renderHearts_GuiComponent_blit_hearts_injection(unsigned char *component, int32_t x_dest, int32_t y_dest, int32_t x_src, int32_t y_src, int32_t width_dest, int32_t height_dest, int32_t width_src, int32_t height_src) {
unsigned char *minecraft = *(unsigned char **) (component + Gui_minecraft_property_offset); unsigned char *minecraft = *(unsigned char **) (component + Gui_minecraft_property_offset);
x_dest -= DEFAULT_HUD_PADDING; x_dest -= DEFAULT_HUD_PADDING;
x_dest += NUMBER_OF_SLOTS * -10 + ((((float) *(int32_t *) (minecraft + Minecraft_screen_width_property_offset)) * *InvGuiScale) / 2); float width = ((float) *(int32_t *) (minecraft + Minecraft_screen_width_property_offset)) * *InvGuiScale;
float height = ((float) *(int32_t *) (minecraft + Minecraft_screen_width_property_offset)) * *InvGuiScale;
x_dest += (width + (NUMBER_OF_SLOTS * SLOT_WIDTH)) / 2;
y_dest -= DEFAULT_HUD_PADDING; y_dest -= DEFAULT_HUD_PADDING;
y_dest += (((float) *(int32_t *) (minecraft + Minecraft_screen_height_property_offset)) * *InvGuiScale) - 31; y_dest += height - HUD_ELEMENT_HEIGHT - TOOLBAR_HEIGHT - NEW_HUD_PADDING;
// Call Original Method // Call Original Method
(*GuiComponent_blit)(component, x_dest, y_dest, x_src, y_src, width_dest, height_dest, width_src, height_src); (*GuiComponent_blit)(component, x_dest, y_dest, x_src, y_src, width_dest, height_dest, width_src, height_src);
} }
@ -35,18 +40,21 @@ static void Gui_renderHearts_GuiComponent_blit_armor_injection(unsigned char *co
unsigned char *minecraft = *(unsigned char **) (component + Gui_minecraft_property_offset); unsigned char *minecraft = *(unsigned char **) (component + Gui_minecraft_property_offset);
x_dest -= DEFAULT_HUD_PADDING + HUD_ELEMENT_WIDTH; x_dest -= DEFAULT_HUD_PADDING + HUD_ELEMENT_WIDTH;
float width = ((float) *(int32_t *) (minecraft + Minecraft_screen_width_property_offset)) * *InvGuiScale; float width = ((float) *(int32_t *) (minecraft + Minecraft_screen_width_property_offset)) * *InvGuiScale;
x_dest += width - (NUMBER_OF_SLOTS * -10 + (width / 2)) - HUD_ELEMENT_WIDTH; float height = ((float) *(int32_t *) (minecraft + Minecraft_screen_width_property_offset)) * *InvGuiScale;
x_dest += width - ((width + (NUMBER_OF_SLOTS * SLOT_WIDTH)) / 2) - HUD_ELEMENT_WIDTH;
y_dest -= DEFAULT_HUD_PADDING; y_dest -= DEFAULT_HUD_PADDING;
y_dest += (((float) *(int32_t *) (minecraft + Minecraft_screen_height_property_offset)) * *InvGuiScale) - 31; y_dest += height - HUD_ELEMENT_HEIGHT - TOOLBAR_HEIGHT - NEW_HUD_PADDING;
// Call Original Method // Call Original Method
(*GuiComponent_blit)(component, x_dest, y_dest, x_src, y_src, width_dest, height_dest, width_src, height_src); (*GuiComponent_blit)(component, x_dest, y_dest, x_src, y_src, width_dest, height_dest, width_src, height_src);
} }
static void Gui_renderBubbles_GuiComponent_blit_injection(unsigned char *component, int32_t x_dest, int32_t y_dest, int32_t x_src, int32_t y_src, int32_t width_dest, int32_t height_dest, int32_t width_src, int32_t height_src) { static void Gui_renderBubbles_GuiComponent_blit_injection(unsigned char *component, int32_t x_dest, int32_t y_dest, int32_t x_src, int32_t y_src, int32_t width_dest, int32_t height_dest, int32_t width_src, int32_t height_src) {
unsigned char *minecraft = *(unsigned char **) (component + Gui_minecraft_property_offset); unsigned char *minecraft = *(unsigned char **) (component + Gui_minecraft_property_offset);
x_dest -= DEFAULT_HUD_PADDING; x_dest -= DEFAULT_HUD_PADDING;
x_dest += NUMBER_OF_SLOTS * -10 + ((((float) *(int32_t *) (minecraft + Minecraft_screen_width_property_offset)) * *InvGuiScale) / 2); float width = ((float) *(int32_t *) (minecraft + Minecraft_screen_width_property_offset)) * *InvGuiScale;
float height = ((float) *(int32_t *) (minecraft + Minecraft_screen_width_property_offset)) * *InvGuiScale;
x_dest += (width + (NUMBER_OF_SLOTS * SLOT_WIDTH)) / 2;
y_dest -= DEFAULT_HUD_PADDING + DEFAULT_BUBBLES_PADDING + HUD_ELEMENT_HEIGHT; y_dest -= DEFAULT_HUD_PADDING + DEFAULT_BUBBLES_PADDING + HUD_ELEMENT_HEIGHT;
y_dest += (((float) *(int32_t *) (minecraft + Minecraft_screen_height_property_offset)) * *InvGuiScale) - 31 - HUD_ELEMENT_HEIGHT; y_dest += height - HUD_ELEMENT_HEIGHT - TOOLBAR_HEIGHT - HUD_ELEMENT_HEIGHT - NEW_HUD_PADDING;
// Call Original Method // Call Original Method
(*GuiComponent_blit)(component, x_dest, y_dest, x_src, y_src, width_dest, height_dest, width_src, height_src); (*GuiComponent_blit)(component, x_dest, y_dest, x_src, y_src, width_dest, height_dest, width_src, height_src);
} }
@ -59,7 +67,7 @@ static void Gui_renderChatMessages_injection(unsigned char *gui, int32_t y_offse
if (use_classic_hud) { if (use_classic_hud) {
unsigned char *minecraft = *(unsigned char **) (gui + Gui_minecraft_property_offset); unsigned char *minecraft = *(unsigned char **) (gui + Gui_minecraft_property_offset);
if (!(*Minecraft_isCreativeMode)(minecraft)) { if (!(*Minecraft_isCreativeMode)(minecraft)) {
y_offset -= HUD_ELEMENT_HEIGHT * 2; y_offset -= (HUD_ELEMENT_HEIGHT * 2) + NEW_HUD_PADDING;
} }
} }
@ -107,6 +115,19 @@ static void Inventory_selectSlot_injection(unsigned char *inventory, int32_t slo
} }
} }
// Translucent Toolbar
static void Gui_renderToolBar_injection(unsigned char *gui, float param_1, int32_t param_2, int32_t param_3) {
// Call Original Method
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
(*Gui_renderToolBar)(gui, param_1, param_2, param_3);
glDisable(GL_BLEND);
}
static void Gui_renderToolBar_glColor4f_injection(GLfloat red, GLfloat green, GLfloat blue, __attribute__((unused)) GLfloat alpha) {
// Fix Alpha
glColor4f(red, green, blue, 1.0f);
}
// Sanitize Username // Sanitize Username
#define MAX_USERNAME_LENGTH 16 #define MAX_USERNAME_LENGTH 16
static void LoginPacket_read_injection(unsigned char *packet, unsigned char *bit_stream) { static void LoginPacket_read_injection(unsigned char *packet, unsigned char *bit_stream) {
@ -290,6 +311,12 @@ void init_misc() {
overwrite_calls((void *) Gui_tick, (void *) Gui_tick_injection); overwrite_calls((void *) Gui_tick, (void *) Gui_tick_injection);
overwrite_calls((void *) Inventory_selectSlot, (void *) Inventory_selectSlot_injection); overwrite_calls((void *) Inventory_selectSlot, (void *) Inventory_selectSlot_injection);
// Translucent Toolbar
if (feature_has("Translucent Toolbar", server_disabled)) {
overwrite_calls((void *) Gui_renderToolBar, (void *) Gui_renderToolBar_injection);
overwrite_call((void *) 0x26c5c, (void *) Gui_renderToolBar_glColor4f_injection);
}
// Sanitize Username // Sanitize Username
patch_address(LoginPacket_read_vtable_addr, (void *) LoginPacket_read_injection); patch_address(LoginPacket_read_vtable_addr, (void *) LoginPacket_read_injection);

View File

@ -427,6 +427,9 @@ static Gui_handleClick_t Gui_handleClick = (Gui_handleClick_t) 0x2599c;
typedef void (*Gui_renderOnSelectItemNameText_t)(unsigned char *gui, int32_t param_1, unsigned char *font, int32_t param_2); typedef void (*Gui_renderOnSelectItemNameText_t)(unsigned char *gui, int32_t param_1, unsigned char *font, int32_t param_2);
static Gui_renderOnSelectItemNameText_t Gui_renderOnSelectItemNameText = (Gui_renderOnSelectItemNameText_t) 0x26aec; static Gui_renderOnSelectItemNameText_t Gui_renderOnSelectItemNameText = (Gui_renderOnSelectItemNameText_t) 0x26aec;
typedef void (*Gui_renderToolBar_t)(unsigned char *gui, float param_1, int32_t param_2, int32_t param_3);
static Gui_renderToolBar_t Gui_renderToolBar = (Gui_renderToolBar_t) 0x26c30;
typedef void (*Gui_renderChatMessages_t)(unsigned char *gui, int32_t y_offset, uint32_t max_messages, bool disable_fading, unsigned char *font); typedef void (*Gui_renderChatMessages_t)(unsigned char *gui, int32_t y_offset, uint32_t max_messages, bool disable_fading, unsigned char *font);
static Gui_renderChatMessages_t Gui_renderChatMessages = (Gui_renderChatMessages_t) 0x273d8; static Gui_renderChatMessages_t Gui_renderChatMessages = (Gui_renderChatMessages_t) 0x273d8;