From 4c888e9b2ac2c5b9c3f3d85cad84ee7cf626f3ea Mon Sep 17 00:00:00 2001 From: Oen44 Date: Thu, 18 Jan 2024 16:34:17 +0100 Subject: [PATCH] Draw floor shadow underground --- modules/client_options/graphics.otui | 4 ++++ modules/client_options/options.lua | 9 ++++++++- modules/gamelib/const.lua | 1 + src/client/const.h | 1 + src/client/mapview.cpp | 5 +++++ src/client/mapview.h | 2 ++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/client_options/graphics.otui b/modules/client_options/graphics.otui index 730bf26..e05f2cb 100644 --- a/modules/client_options/graphics.otui +++ b/modules/client_options/graphics.otui @@ -35,6 +35,10 @@ OptionPanel id: antialiasing !text: tr('Antialiasing') + OptionCheckBox + id: floorShadow + !text: tr('Floor Shadow') + Label margin-top: 12 id: optimizationLevelLabel diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 0060d57..4f2cbd8 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -66,7 +66,8 @@ local defaultOptions = { profile = 1, - antialiasing = true + antialiasing = true, + floorShadow = true } local optionsWindow @@ -350,6 +351,12 @@ function setOption(key, value, force) generalPanel:getChildById('walkCtrlTurnDelayLabel'):setText(tr('Walk delay after ctrl turn: %s ms', value)) elseif key == "antialiasing" then g_app.setSmooth(value) + elseif key == "floorShadow" then + if value then + g_game.enableFeature(GameDrawFloorShadow) + else + g_game.disableFeature(GameDrawFloorShadow) + end end -- change value for keybind updates diff --git a/modules/gamelib/const.lua b/modules/gamelib/const.lua index e7a0486..92f9e4f 100644 --- a/modules/gamelib/const.lua +++ b/modules/gamelib/const.lua @@ -213,6 +213,7 @@ GameDontMergeAnimatedText = 124 GameMissionId = 125 GameItemCustomAttributes = 126 GameAnimatedTextCustomFont = 127 +GameDrawFloorShadow = 128 LastGameFeature = 130 diff --git a/src/client/const.h b/src/client/const.h index bb23e1b..da9d92d 100644 --- a/src/client/const.h +++ b/src/client/const.h @@ -488,6 +488,7 @@ namespace Otc GameMissionId = 125, GameItemCustomAttributes = 126, GameAnimatedTextCustomFont = 127, + GameDrawFloorShadow = 128, LastGameFeature = 130 }; diff --git a/src/client/mapview.cpp b/src/client/mapview.cpp index 31d766f..402044e 100644 --- a/src/client/mapview.cpp +++ b/src/client/mapview.cpp @@ -143,6 +143,11 @@ void MapView::drawMapBackground(const Rect& rect, const TilePtr& crosshairTile) if (fading == 0) break; } + if (g_game.getFeature(Otc::GameDrawFloorShadow)) { + if (cameraPosition.z >= Otc::UNDERGROUND_FLOOR && cameraPosition.z == z) { + g_drawQueue->addFilledRect(srcRect, m_floorShadow); + } + } size_t floorStart = g_drawQueue->size(); drawFloor(z, cameraPosition, crosshairTile); diff --git a/src/client/mapview.h b/src/client/mapview.h index 8cd91c7..55c7386 100644 --- a/src/client/mapview.h +++ b/src/client/mapview.h @@ -166,6 +166,8 @@ class MapView : public LuaObject float m_minimumAmbientLight; std::unique_ptr m_lightView; TexturePtr m_lightTexture; + + Color m_floorShadow = Color(0.0f, 0.0f, 0.0f, 0.5f); }; #endif