mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Increase network precision of cinematic bar size
This commit is contained in:
parent
e19ca19e34
commit
5ba6d841e1
16
src/Gui.c
16
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--)
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user