diff --git a/Mods/vcmi/config/vcmi/english.json b/Mods/vcmi/config/vcmi/english.json index 4098fb24f..690e34700 100644 --- a/Mods/vcmi/config/vcmi/english.json +++ b/Mods/vcmi/config/vcmi/english.json @@ -145,6 +145,8 @@ "vcmi.adventureOptions.mapScrollSpeed1.help": "Set the map scrolling speed to very slow.", "vcmi.adventureOptions.mapScrollSpeed5.help": "Set the map scrolling speed to very fast.", "vcmi.adventureOptions.mapScrollSpeed6.help": "Set the map scrolling speed to instantaneous.", + "vcmi.adventureOptions.hideBackground.hover" : "Hide Background", + "vcmi.adventureOptions.hideBackground.help" : "{Hide Background}\n\nHide the adventuremap in the background and show a texture instead.", "vcmi.battleOptions.queueSizeLabel.hover": "Show Turn Order Queue", "vcmi.battleOptions.queueSizeNoneButton.hover": "OFF", diff --git a/Mods/vcmi/config/vcmi/german.json b/Mods/vcmi/config/vcmi/german.json index eb752187d..a8946cebc 100644 --- a/Mods/vcmi/config/vcmi/german.json +++ b/Mods/vcmi/config/vcmi/german.json @@ -145,6 +145,8 @@ "vcmi.adventureOptions.mapScrollSpeed1.help": "Geschwindigkeit des Kartenbildlaufs auf sehr langsam einstellen", "vcmi.adventureOptions.mapScrollSpeed5.help": "Geschwindigkeit des Kartenbildlaufs auf sehr schnell einstellen", "vcmi.adventureOptions.mapScrollSpeed6.help": "Geschwindigkeit des Kartenbildlaufs auf sofort einstellen", + "vcmi.adventureOptions.hideBackground.hover" : "Hintergrund ausblenden", + "vcmi.adventureOptions.hideBackground.help" : "{Hintergrund ausblenden}\n\nDie Abenteuerkarte im Hintergrund ausblenden und stattdessen eine Textur anzeigen.", "vcmi.battleOptions.queueSizeLabel.hover": "Reihenfolge der Kreaturen anzeigen", "vcmi.battleOptions.queueSizeNoneButton.hover": "AUS", diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index d7ba7748a..935d6b999 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -31,6 +31,7 @@ #include "../gui/Shortcut.h" #include "../gui/WindowHandler.h" #include "../render/Canvas.h" +#include "../render/IRenderHandler.h" #include "../CMT.h" #include "../PlayerLocalState.h" #include "../CPlayerInterface.h" @@ -168,6 +169,15 @@ void AdventureMapInterface::show(Canvas & to) void AdventureMapInterface::dim(Canvas & to) { + if(settings["adventure"]["hideBackground"].Bool()) + for (auto window : GH.windows().findWindows()) + { + if(!std::dynamic_pointer_cast(window) && std::dynamic_pointer_cast(window) && std::dynamic_pointer_cast(window)->pos.w >= 800 && std::dynamic_pointer_cast(window)->pos.w >= 600) + { + to.fillTexture(GH.renderHandler().loadImage(ImagePath::builtin("DiBoxBck"))); + return; + } + } for (auto window : GH.windows().findWindows()) { if (!std::dynamic_pointer_cast(window) && !std::dynamic_pointer_cast(window) && !window->isPopupWindow()) diff --git a/client/render/Canvas.cpp b/client/render/Canvas.cpp index 261c7b556..8d8939d76 100644 --- a/client/render/Canvas.cpp +++ b/client/render/Canvas.cpp @@ -182,6 +182,20 @@ void Canvas::drawColorBlended(const Rect & target, const ColorRGBA & color) CSDL_Ext::fillRectBlended(surface, realTarget, CSDL_Ext::toSDL(color)); } +void Canvas::fillTexture(const std::shared_ptr& image) +{ + assert(image); + if (!image) + return; + + Rect imageArea = Rect(Point(0, 0), image->dimensions()); + for (int y=0; y < surface->h; y+= imageArea.h) + { + for (int x=0; x < surface->w; x+= imageArea.w) + image->draw(surface, renderArea.x + x, renderArea.y + y); + } +} + SDL_Surface * Canvas::getInternalSurface() { return surface; diff --git a/client/render/Canvas.h b/client/render/Canvas.h index 8a4abcf67..647c1ddde 100644 --- a/client/render/Canvas.h +++ b/client/render/Canvas.h @@ -99,6 +99,9 @@ public: /// fills selected area with blended color void drawColorBlended(const Rect & target, const ColorRGBA & color); + /// fills canvas with texture + void fillTexture(const std::shared_ptr& image); + /// Compatibility method. AVOID USAGE. To be removed once SDL abstraction layer is finished. SDL_Surface * getInternalSurface(); diff --git a/client/windows/settings/AdventureOptionsTab.cpp b/client/windows/settings/AdventureOptionsTab.cpp index 7fdb9b911..f514f33f1 100644 --- a/client/windows/settings/AdventureOptionsTab.cpp +++ b/client/windows/settings/AdventureOptionsTab.cpp @@ -134,6 +134,10 @@ AdventureOptionsTab::AdventureOptionsTab() { return setBoolSetting("gameTweaks", "skipAdventureMapAnimations", value); }); + addCallback("hideBackgroundChanged", [](bool value) + { + return setBoolSetting("adventure", "hideBackground", value); + }); build(config); std::shared_ptr playerHeroSpeedToggle = widget("heroMovementSpeedPicker"); @@ -179,4 +183,7 @@ AdventureOptionsTab::AdventureOptionsTab() std::shared_ptr skipAdventureMapAnimationsCheckbox = widget("skipAdventureMapAnimationsCheckbox"); skipAdventureMapAnimationsCheckbox->setSelected(settings["gameTweaks"]["skipAdventureMapAnimations"].Bool()); + + std::shared_ptr hideBackgroundCheckbox = widget("hideBackgroundCheckbox"); + hideBackgroundCheckbox->setSelected(settings["adventure"]["hideBackground"].Bool()); } diff --git a/config/schemas/settings.json b/config/schemas/settings.json index be2af9e01..48c3e1211 100644 --- a/config/schemas/settings.json +++ b/config/schemas/settings.json @@ -241,7 +241,7 @@ "type" : "object", "additionalProperties" : false, "default" : {}, - "required" : [ "heroMoveTime", "enemyMoveTime", "scrollSpeedPixels", "heroReminder", "quickCombat", "objectAnimation", "terrainAnimation", "forceQuickCombat", "borderScroll", "leftButtonDrag", "smoothDragging", "backgroundDimLevel" ], + "required" : [ "heroMoveTime", "enemyMoveTime", "scrollSpeedPixels", "heroReminder", "quickCombat", "objectAnimation", "terrainAnimation", "forceQuickCombat", "borderScroll", "leftButtonDrag", "smoothDragging", "backgroundDimLevel", "hideBackground" ], "properties" : { "heroMoveTime" : { "type" : "number", @@ -294,6 +294,10 @@ "type" : "number", "default" : 128 }, + "hideBackground" : { + "type" : "boolean", + "default" : false + } } }, "battle" : { diff --git a/config/widgets/settings/adventureOptionsTab.json b/config/widgets/settings/adventureOptionsTab.json index 02a748960..faa0d01ab 100644 --- a/config/widgets/settings/adventureOptionsTab.json +++ b/config/widgets/settings/adventureOptionsTab.json @@ -297,6 +297,9 @@ }, { "text": "vcmi.adventureOptions.showGrid.hover" + }, + { + "text": "vcmi.adventureOptions.hideBackground.hover" } ] }, @@ -324,6 +327,11 @@ "name": "showGridCheckbox", "help": "vcmi.adventureOptions.showGrid", "callback": "showGridChanged" + }, + { + "name": "hideBackgroundCheckbox", + "help": "vcmi.adventureOptions.hideBackground", + "callback": "hideBackgroundChanged" } ] },