From 5ba6d841e135eb534fc2be87fc8ca252b9666d3e Mon Sep 17 00:00:00 2001 From: Goodlyay Date: Fri, 23 Aug 2024 20:42:27 -0700 Subject: [PATCH] Increase network precision of cinematic bar size --- src/Gui.c | 16 ++++++++-------- src/Gui.h | 4 ++-- src/Protocol.c | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Gui.c b/src/Gui.c index 27b6e140e..958d72083 100644 --- a/src/Gui.c +++ b/src/Gui.c @@ -313,16 +313,16 @@ void Gui_ShowCinematicBars() { int screenWidth = Window_Main.Width; int screenHeight = Window_Main.Height; - // Ensure aperture size is clamped between 0 and 1 - if (Gui.ApertureSize < 0.0f) Gui.ApertureSize = 0.0f; - if (Gui.ApertureSize > 1.0f) Gui.ApertureSize = 1.0f; + // Ensure bar size is clamped between 0 and 1 + if (Gui.BarSize < 0.0f) Gui.BarSize = 0.0f; + if (Gui.BarSize > 1.0f) Gui.BarSize = 1.0f; - // If aperture size is 1, just draw 1 rectangle instead of 2 - if (Gui.ApertureSize == 1.0f) { + // If bar size is 1, just draw 1 rectangle instead of 2 + if (Gui.BarSize == 1.0f) { Gfx_Draw2DGradient(0, 0, screenWidth, screenHeight, Gui.CinematicBarColor, Gui.CinematicBarColor); } else { - // Calculate the height of each bar based on the aperture size - int barHeight = (int)(screenHeight * Gui.ApertureSize / 2.0f); + // Calculate the height of each bar based on the bar size + int barHeight = (int)(screenHeight * Gui.BarSize / 2.0f); Gfx_Draw2DGradient(0, 0, screenWidth, barHeight, Gui.CinematicBarColor, Gui.CinematicBarColor); Gfx_Draw2DGradient(0, screenHeight - barHeight, screenWidth, barHeight, Gui.CinematicBarColor, Gui.CinematicBarColor); @@ -338,7 +338,7 @@ void Gui_RenderGui(float delta) { Texture_Render(&touchBgTex); #endif - if (Gui.ApertureSize > 0) Gui_ShowCinematicBars(); + if (Gui.BarSize > 0) Gui_ShowCinematicBars(); /* Draw back to front so highest priority screen is on top */ for (i = Gui.ScreensCount - 1; i >= 0; i--) diff --git a/src/Gui.h b/src/Gui.h index b18cd053a..5ecbde231 100644 --- a/src/Gui.h +++ b/src/Gui.h @@ -62,8 +62,8 @@ CC_VAR extern struct _GuiData { cc_bool HideHand; /* Whether the hotbar should be hidden. */ cc_bool HideHotbar; - /* The height of the cinematic black bars. */ - float ApertureSize; + /* The height of the cinematic bars, where 0 = no bars visible and 1 = bars completely cover the screen. */ + float BarSize; /* The color of the cinematic bars, if enabled. */ PackedCol CinematicBarColor; } Gui; diff --git a/src/Protocol.c b/src/Protocol.c index 7acfe2631..743f7f105 100644 --- a/src/Protocol.c +++ b/src/Protocol.c @@ -1562,12 +1562,12 @@ static void CPE_LightingMode(cc_uint8* data) { static void CPE_CinematicGui(cc_uint8* data) { cc_bool hideHand = data[0]; cc_bool hideHotbar = data[1]; - cc_uint8 apertureSize = data[6]; + cc_uint16 barSize = Stream_GetU16_BE(data + 6); HeldBlockRenderer_Show = !hideHand && Options_GetBool(OPT_SHOW_BLOCK_IN_HAND, true); Gui.HideHotbar = hideHotbar; Gui.CinematicBarColor = PackedCol_Make(data[2], data[3], data[4], data[5]); - Gui.ApertureSize = (float)apertureSize / 255.0; + Gui.BarSize = (float)barSize / UInt16_MaxValue; } static void CPE_Reset(void) { @@ -1613,7 +1613,7 @@ static void CPE_Reset(void) { Net_Set(OPCODE_PLUGIN_MESSAGE, CPE_PluginMessage, 66); Net_Set(OPCODE_ENTITY_TELEPORT_EXT, CPE_ExtEntityTeleport, 11); Net_Set(OPCODE_LIGHTING_MODE, CPE_LightingMode, 3); - Net_Set(OPCODE_CINEMATIC_GUI, CPE_CinematicGui, 8); + Net_Set(OPCODE_CINEMATIC_GUI, CPE_CinematicGui, 9); } static cc_uint8* CPE_Tick(cc_uint8* data) {