From e49fe348e3dc448553cc07663b0a9c8628f3c4aa Mon Sep 17 00:00:00 2001 From: Kolyah35 Date: Sat, 14 Mar 2026 14:51:42 +0300 Subject: [PATCH] FIX: override warnings --- src/AppPlatform_glfw.h | 4 ++-- src/client/Minecraft.cpp | 18 +++++++------- src/client/Options.cpp | 9 +++++++ src/client/Options.h | 3 +++ .../gui/screens/IngameBlockSelectionScreen.h | 14 +++++------ src/client/gui/screens/JoinByIPScreen.cpp | 21 ---------------- src/client/gui/screens/JoinByIPScreen.h | 2 -- src/client/gui/screens/StartMenuScreen.cpp | 8 +++++-- src/client/gui/screens/StartMenuScreen.h | 2 ++ .../touch/TouchIngameBlockSelectionScreen.h | 24 +++++++++---------- .../screens/touch/TouchStartMenuScreen.cpp | 8 +++++-- .../gui/screens/touch/TouchStartMenuScreen.h | 2 ++ src/client/player/LocalPlayer.cpp | 4 ++-- src/client/renderer/GameRenderer.cpp | 2 +- src/platform/input/Keyboard.cpp | 2 +- 15 files changed, 62 insertions(+), 61 deletions(-) diff --git a/src/AppPlatform_glfw.h b/src/AppPlatform_glfw.h index 265af68..ee22a3b 100755 --- a/src/AppPlatform_glfw.h +++ b/src/AppPlatform_glfw.h @@ -137,9 +137,9 @@ public: virtual float getPixelsPerMillimeter(); - virtual bool supportsTouchscreen() { return true; } + virtual bool supportsTouchscreen() override { return true; } - virtual void openURL(const std::string& url) { + virtual void openURL(const std::string& url) override { #ifdef _WIN32 ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); #elif __linux__ diff --git a/src/client/Minecraft.cpp b/src/client/Minecraft.cpp index 46820f7..7609540 100755 --- a/src/client/Minecraft.cpp +++ b/src/client/Minecraft.cpp @@ -746,11 +746,8 @@ void Minecraft::tickInput() { releaseMouse(); } - if (key == Keyboard::KEY_F) - options.viewDistance = (options.viewDistance + 1) % 4; - if (key == Keyboard::KEY_F3) { - options.renderDebug = !options.renderDebug; + options.toggle(OPTIONS_RENDER_DEBUG); } if (key == Keyboard::KEY_F5) { @@ -763,8 +760,10 @@ void Minecraft::tickInput() { } - if (key == Keyboard::KEY_L) - options.viewDistance = (options.viewDistance + 1) % 4; + if (key == Keyboard::KEY_L) { + int dst = options.getIntValue(OPTIONS_VIEW_DISTANCE); + options.set(OPTIONS_VIEW_DISTANCE, (dst + 1) % 4); + } if (key == Keyboard::KEY_U) { onGraphicsReset(); @@ -835,12 +834,13 @@ void Minecraft::tickInput() { player->inventory->dropSlot(i, false); } if (key == Keyboard::KEY_M) { - options.difficulty = (options.difficulty == Difficulty::PEACEFUL)? - Difficulty::NORMAL : Difficulty::PEACEFUL; + Difficulty difficulty = (Difficulty)options.getIntValue(OPTIONS_DIFFICULTY); + options.set(OPTIONS_DIFFICULTY, (difficulty == Difficulty::PEACEFUL)? + Difficulty::NORMAL : Difficulty::PEACEFUL); //setIsCreativeMode( !isCreativeMode() ); } - if (options.renderDebug) { + if (options.getBooleanValue(OPTIONS_RENDER_DEBUG)) { if (key >= '0' && key <= '9') { _perfRenderer->debugFpsMeterKeyPress(key - '0'); } diff --git a/src/client/Options.cpp b/src/client/Options.cpp index 029df47..1598fbe 100755 --- a/src/client/Options.cpp +++ b/src/client/Options.cpp @@ -18,6 +18,10 @@ OptionBool renderDebug("renderDebug", false); OptionBool smoothCamera("smoothCamera", false); OptionBool fixedCamera("fixedCamera", false); OptionBool isFlying("isflying", false); +OptionBool barOnTop("barOnTop", false); +OptionBool allowSprint("allowSprint", true); +OptionBool autoJump("autoJump", true); + OptionFloat flySpeed("flySpeed", 1.f); OptionFloat cameraSpeed("cameraSpeed", 1.f); @@ -149,6 +153,11 @@ void Options::initTable() { m_options[OPTIONS_KEY_MENU_CANCEL] = &keyMenuCancel; m_options[OPTIONS_FIRST_LAUNCH] = &firstLaunch; + + m_options[OPTIONS_BAR_ON_TOP] = &barOnTop; + m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint; + + m_options[OPTIONS_AUTOJUMP] = &autoJump; } void Options::set(OptionId key, const std::string& value) { diff --git a/src/client/Options.h b/src/client/Options.h index dae75dd..fdbdbe0 100755 --- a/src/client/Options.h +++ b/src/client/Options.h @@ -34,6 +34,9 @@ enum OptionId { OPTIONS_SKIN, OPTIONS_USERNAME, OPTIONS_SERVER_VISIBLE, + OPTIONS_BAR_ON_TOP, + OPTIONS_ALLOW_SPRINT, + OPTIONS_AUTOJUMP, // Graphics OPTIONS_RENDER_DEBUG, diff --git a/src/client/gui/screens/IngameBlockSelectionScreen.h b/src/client/gui/screens/IngameBlockSelectionScreen.h index 8c3c82b..affd6af 100755 --- a/src/client/gui/screens/IngameBlockSelectionScreen.h +++ b/src/client/gui/screens/IngameBlockSelectionScreen.h @@ -12,21 +12,21 @@ public: IngameBlockSelectionScreen(); virtual ~IngameBlockSelectionScreen() {} - virtual void init(); - virtual void removed(); + virtual void init() override; + virtual void removed() override; - void render(int xm, int ym, float a); + void render(int xm, int ym, float a) override; protected: - virtual void mouseClicked(int x, int y, int buttonNum); - virtual void mouseReleased(int x, int y, int buttonNum); + virtual void mouseClicked(int x, int y, int buttonNum) override; + virtual void mouseReleased(int x, int y, int buttonNum) override; - virtual void buttonClicked(Button* button); + virtual void buttonClicked(Button* button) override; // wheel input for creative inventory scrolling virtual void mouseWheel(int dx, int dy, int xm, int ym) override; - virtual void keyPressed(int eventKey); + virtual void keyPressed(int eventKey) override; private: void renderSlots(); void renderSlot(int slot, int x, int y, float a); diff --git a/src/client/gui/screens/JoinByIPScreen.cpp b/src/client/gui/screens/JoinByIPScreen.cpp index 7044d77..d449ac9 100644 --- a/src/client/gui/screens/JoinByIPScreen.cpp +++ b/src/client/gui/screens/JoinByIPScreen.cpp @@ -102,21 +102,6 @@ void JoinByIPScreen::setupPositions() { tIP.y = ((height - bJoin.height) / 2) - tIP.height - 4; } -void JoinByIPScreen::mouseClicked(int x, int y, int buttonNum) { - int lvlTop = tIP.y - (Font::DefaultLineHeight + 4); - int lvlBottom = tIP.y + tIP.height; - int lvlLeft = tIP.x; - int lvlRight = tIP.x + tIP.width; - bool clickedIP = x >= lvlLeft && x < lvlRight && y >= lvlTop && y < lvlBottom; - - if (clickedIP) { - tIP.setFocus(minecraft); - } else { - tIP.loseFocus(minecraft); - } - - Screen::mouseClicked(x, y, buttonNum); -} void JoinByIPScreen::render( int xm, int ym, float a ) { renderBackground(); @@ -131,10 +116,4 @@ void JoinByIPScreen::keyPressed(int eventKey) } // let base class handle navigation and text box keys Screen::keyPressed(eventKey); -} - -void JoinByIPScreen::keyboardNewChar(char inputChar) -{ - // forward character input to focused textbox(s) - for (auto* tb : textBoxes) tb->handleChar(inputChar); } \ No newline at end of file diff --git a/src/client/gui/screens/JoinByIPScreen.h b/src/client/gui/screens/JoinByIPScreen.h index 288ada9..5ee2b16 100644 --- a/src/client/gui/screens/JoinByIPScreen.h +++ b/src/client/gui/screens/JoinByIPScreen.h @@ -18,9 +18,7 @@ public: void render(int xm, int ym, float a); virtual void keyPressed(int eventKey); - virtual void keyboardNewChar(char inputChar); void buttonClicked(Button* button); - virtual void mouseClicked(int x, int y, int buttonNum); virtual bool handleBackEvent(bool isDown); private: TextBox tIP; diff --git a/src/client/gui/screens/StartMenuScreen.cpp b/src/client/gui/screens/StartMenuScreen.cpp index 83ecacf..fd67bd0 100755 --- a/src/client/gui/screens/StartMenuScreen.cpp +++ b/src/client/gui/screens/StartMenuScreen.cpp @@ -73,6 +73,11 @@ void StartMenuScreen::init() // always show base version string, suffix was previously added for Android builds std::string versionString = Common::getGameVersionString(); + std::string _username = minecraft->options.getStringValue(OPTIONS_USERNAME); + if (_username.empty()) _username = "unknown"; + + username = "Username: " + _username; + #ifdef DEMO_MODE #ifdef __APPLE__ version = versionString + " (Lite)"; @@ -153,8 +158,7 @@ void StartMenuScreen::render( int xm, int ym, float a ) renderBackground(); // Show current username in the top-left corner - std::string username = minecraft->options.username.empty() ? "unknown" : minecraft->options.username; - drawString(font, std::string("Username: ") + username, 2, 2, 0xffffffff); + drawString(font, username, 2, 2, 0xffffffff); #if defined(RPI) TextureId id = minecraft->textures->loadTexture("gui/pi_title.png"); diff --git a/src/client/gui/screens/StartMenuScreen.h b/src/client/gui/screens/StartMenuScreen.h index dd0ccb3..e2801fe 100755 --- a/src/client/gui/screens/StartMenuScreen.h +++ b/src/client/gui/screens/StartMenuScreen.h @@ -33,6 +33,8 @@ private: std::string version; int versionPosX; + + std::string username; }; #endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__StartMenuScreen_H__*/ diff --git a/src/client/gui/screens/touch/TouchIngameBlockSelectionScreen.h b/src/client/gui/screens/touch/TouchIngameBlockSelectionScreen.h index ed05c0b..ee8cbb1 100755 --- a/src/client/gui/screens/touch/TouchIngameBlockSelectionScreen.h +++ b/src/client/gui/screens/touch/TouchIngameBlockSelectionScreen.h @@ -21,24 +21,24 @@ public: IngameBlockSelectionScreen(); virtual ~IngameBlockSelectionScreen(); - virtual void init(); - virtual void setupPositions(); - virtual void removed(); + virtual void init() override; + virtual void setupPositions() override; + virtual void removed() override; - void tick(); - void render(int xm, int ym, float a); + void tick() override; + void render(int xm, int ym, float a) override; - bool hasClippingArea(IntRectangle& out); + bool hasClippingArea(IntRectangle& out) override; // IInventoryPaneCallback - bool addItem(const InventoryPane* pane, int itemId); - bool isAllowed(int slot); - std::vector getItems(const InventoryPane* forPane); + bool addItem(const InventoryPane* pane, int itemId) override; + bool isAllowed(int slot) override; + std::vector getItems(const InventoryPane* forPane) override; - void buttonClicked(Button* button); + void buttonClicked(Button* button) override; protected: - virtual void mouseClicked(int x, int y, int buttonNum); - virtual void mouseReleased(int x, int y, int buttonNum); + virtual void mouseClicked(int x, int y, int buttonNum) override; + virtual void mouseReleased(int x, int y, int buttonNum) override; // also support wheel scrolling virtual void mouseWheel(int dx, int dy, int xm, int ym) override; diff --git a/src/client/gui/screens/touch/TouchStartMenuScreen.cpp b/src/client/gui/screens/touch/TouchStartMenuScreen.cpp index e4c8d0f..c80300e 100755 --- a/src/client/gui/screens/touch/TouchStartMenuScreen.cpp +++ b/src/client/gui/screens/touch/TouchStartMenuScreen.cpp @@ -85,6 +85,11 @@ void StartMenuScreen::init() // always show base version string std::string versionString = Common::getGameVersionString(); + std::string _username = minecraft->options.getStringValue(OPTIONS_USERNAME); + if (_username.empty()) _username = "unknown"; + + username = "Username: " + _username; + #ifdef DEMO_MODE #ifdef __APPLE__ version = versionString + " (Lite)"; @@ -162,8 +167,7 @@ void StartMenuScreen::render( int xm, int ym, float a ) renderBackground(); // Show current username in the top-left corner - std::string username = minecraft->options.username.empty() ? "unknown" : minecraft->options.username; - drawString(font, std::string("Username: ") + username, 2, 2, 0xffffffff); + drawString(font, username, 2, 2, 0xffffffff); glEnable2(GL_BLEND); diff --git a/src/client/gui/screens/touch/TouchStartMenuScreen.h b/src/client/gui/screens/touch/TouchStartMenuScreen.h index b9bcb5b..b4c8755 100755 --- a/src/client/gui/screens/touch/TouchStartMenuScreen.h +++ b/src/client/gui/screens/touch/TouchStartMenuScreen.h @@ -35,6 +35,8 @@ private: std::string version; int versionPosX; + + std::string username; }; }; diff --git a/src/client/player/LocalPlayer.cpp b/src/client/player/LocalPlayer.cpp index f0b5b3c..ebd8296 100755 --- a/src/client/player/LocalPlayer.cpp +++ b/src/client/player/LocalPlayer.cpp @@ -445,7 +445,7 @@ void LocalPlayer::aiStep() { // Sprint: detect W double-tap { bool forwardHeld = (input->ya > 0); - if (forwardHeld && !prevForwardHeld && minecraft->options.useSprinting) { + if (forwardHeld && !prevForwardHeld && minecraft->options.getBooleanValue(OPTIONS_ALLOW_SPRINT)) { // leading edge of W press if (sprintDoubleTapTimer > 0) sprinting = true; @@ -534,7 +534,7 @@ void LocalPlayer::move(float xa, float ya, float za) { float newX = x, newZ = z; - if (autoJumpTime <= 0 && minecraft->options.autoJump) + if (autoJumpTime <= 0 && minecraft->options.getBooleanValue(OPTIONS_AUTOJUMP)) { // auto-jump when crossing the middle of a tile, and the tile in the front is blocked bool jump = false; diff --git a/src/client/renderer/GameRenderer.cpp b/src/client/renderer/GameRenderer.cpp index be75b88..c1bc872 100755 --- a/src/client/renderer/GameRenderer.cpp +++ b/src/client/renderer/GameRenderer.cpp @@ -373,7 +373,7 @@ void GameRenderer::renderLevel(float a) { // glDisable2(GL_FOG); setupFog(1); - if (zoom == 1 && !mc->options.F1) { + if (zoom == 1 && !mc->options.getBooleanValue(OPTIONS_HIDEGUI)) { TIMER_POP_PUSH("hand"); glClear(GL_DEPTH_BUFFER_BIT); renderItemInHand(a, i); diff --git a/src/platform/input/Keyboard.cpp b/src/platform/input/Keyboard.cpp index 4baf5d5..3f9f0df 100755 --- a/src/platform/input/Keyboard.cpp +++ b/src/platform/input/Keyboard.cpp @@ -54,6 +54,6 @@ const char* Keyboard::getKeyName(int key) { case KEY_ESCAPE: return "Esc"; case KEY_SPACE: return "Space"; case KEY_LSHIFT: return "Left Shift"; - default: "Unknown"; + default: return "Unknown"; } } \ No newline at end of file