From 0d23a455ed8d28cbdf3195bef8a4465773120c1e Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Sun, 5 Nov 2023 18:47:38 +0200 Subject: [PATCH] * Add option to split controls --- source/client/app/Minecraft.cpp | 5 +++++ source/client/app/Minecraft.hpp | 1 + source/client/gui/Gui.cpp | 5 ++++- source/client/gui/components/OptionList.cpp | 17 ++++++++++------- source/client/options/Options.cpp | 1 + source/client/options/Options.hpp | 1 + source/client/renderer/GameRenderer.cpp | 2 +- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 0fd68f6..19f9238 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -221,6 +221,11 @@ bool Minecraft::isTouchscreen() return m_bIsTouchscreen; } +bool Minecraft::useSplitControls() +{ + return !m_bIsTouchscreen || m_options->m_bSplitControls; +} + void Minecraft::setGuiScaleMultiplier(float f) { guiScaleMultiplier = f; diff --git a/source/client/app/Minecraft.hpp b/source/client/app/Minecraft.hpp index 826ef42..886e2e4 100644 --- a/source/client/app/Minecraft.hpp +++ b/source/client/app/Minecraft.hpp @@ -62,6 +62,7 @@ public: void respawnPlayer(Player* player); std::string getVersionString(); bool isTouchscreen(); + bool useSplitControls(); virtual void update() override; virtual void init() override; diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index c7eac13..b6c577d 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -170,13 +170,16 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) m->m_pTextures->loadAndBindTexture("gui/icons.png"); - if (!isTouchscreen) + if (m->useSplitControls()) { #ifndef ENH_TRANSPARENT_HOTBAR glEnable(GL_BLEND); #endif + + // draw crosshair glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR); blit(cenX - 8, height / 2 - 8, 0, 0, 16, 16, 0, 0); + #ifndef ENH_TRANSPARENT_HOTBAR glDisable(GL_BLEND); #endif diff --git a/source/client/gui/components/OptionList.cpp b/source/client/gui/components/OptionList.cpp index f67003b..707d21f 100644 --- a/source/client/gui/components/OptionList.cpp +++ b/source/client/gui/components/OptionList.cpp @@ -306,28 +306,28 @@ void OptionList::initDefaultMenu() #define HEADER(text) do { m_items.push_back(new HeaderOptionItem(text)); currentIndex++; } while (0) #define OPTION(type, name, text) do { m_items.push_back(new type ## OptionItem(&pOptions->name, text)); currentIndex++; } while (0) - int idxLM = -1; - int idxGrass = -1, idxBiome = -1; + int idxLM = -1, idxGrass = -1, idxBiome = -1, idxSplit = -1; HEADER("Video"); { OPTION(Distance, m_iViewDistance, "View distance"); OPTION(AORender, m_bAmbientOcclusion, "Smooth lighting"); OPTION(Render, m_bFancyGraphics, "Fancy graphics"); - OPTION(Boolean, m_bAnaglyphs, "3d Anaglyphs"); - OPTION(Boolean, m_bDebugText, "Debug text"); - OPTION(Boolean, m_bFlyCheat, "Flight hax"); - OPTION(Boolean, m_bDontRenderGui, "Hide GUI"); - OPTION(Boolean, m_bBlockOutlines, "Block outlines"); OPTION(Boolean, m_bViewBobbing, "View bobbing"); + OPTION(Boolean, m_bAnaglyphs, "3d Anaglyphs"); + OPTION(Boolean, m_bBlockOutlines, "Block outlines"); OPTION(Render, m_bFancyGrass, "Fancy grass"); idxGrass = currentIndex; // renders colored grass side overlay OPTION(Render, m_bBiomeColors, "Biome colors"); idxBiome = currentIndex; // colors the grass based on the current biome + OPTION(Boolean, m_bDontRenderGui, "Hide GUI"); + OPTION(Boolean, m_bDebugText, "Debug text"); } HEADER("Controls"); { OPTION(Boolean, m_bAutoJump, "Auto jump"); OPTION(Boolean, m_bInvertMouse, "Invert Y-axis"); + OPTION(Boolean, m_bSplitControls, "Split controls"); idxSplit = currentIndex; + OPTION(Boolean, m_bFlyCheat, "Flight hax"); } HEADER("Multiplayer"); @@ -344,4 +344,7 @@ void OptionList::initDefaultMenu() if (!GrassColor::isAvailable() || !FoliageColor::isAvailable()) m_items[idxBiome]->setDisabled(true); + + if (!m_pMinecraft->isTouchscreen()) + m_items[idxSplit]->setDisabled(true); } diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp index 41af512..e81cde5 100644 --- a/source/client/options/Options.cpp +++ b/source/client/options/Options.cpp @@ -61,6 +61,7 @@ void Options::_initDefaultValues() m_bBlockOutlines = false; m_bFancyGrass = false; m_bBiomeColors = false; + m_bSplitControls = false; field_19 = 1; // Win32 key codes are being used by default diff --git a/source/client/options/Options.hpp b/source/client/options/Options.hpp index d79785d..8f5d4f3 100644 --- a/source/client/options/Options.hpp +++ b/source/client/options/Options.hpp @@ -128,6 +128,7 @@ public: bool m_bBlockOutlines; bool m_bFancyGrass; bool m_bBiomeColors; + bool m_bSplitControls; public: struct Option diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index d730914..4642294 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -824,7 +824,7 @@ void GameRenderer::pick(float f) float dist = m_pMinecraft->m_pGameMode->getPickRange(); bool isFirstPerson = !m_pMinecraft->getOptions()->m_bThirdPerson; - if (m_pMinecraft->isTouchscreen()) + if (!m_pMinecraft->useSplitControls()) { Vec3 mobPos = pMob->getPos(f); Vec3 foundPosNear, foundPosFar;