1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Fix remaining graphical artifacts on switching from world view

This commit is contained in:
Ivan Savenko
2023-05-06 16:52:43 +03:00
parent c24ccf663b
commit 342ea138f9
7 changed files with 64 additions and 53 deletions

View File

@@ -788,6 +788,8 @@ void CAdventureMapInterface::onScreenResize()
widget = std::make_shared<CAdventureMapWidget>(shortcuts); widget = std::make_shared<CAdventureMapWidget>(shortcuts);
widget->getMapView()->onViewMapActivated(); widget->getMapView()->onViewMapActivated();
widget->setPlayer(currentPlayerID); widget->setPlayer(currentPlayerID);
widget->updateActiveState();
widget->getMinimap()->update();
if (isActive()) if (isActive())
widget->activate(); widget->activate();

View File

@@ -238,7 +238,7 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapHeroList(const JsonNode
Point itemOffset(input["itemsOffset"]["x"].Integer(), input["itemsOffset"]["y"].Integer()); Point itemOffset(input["itemsOffset"]["x"].Integer(), input["itemsOffset"]["y"].Integer());
int itemsCount = input["itemsCount"].Integer(); int itemsCount = input["itemsCount"].Integer();
auto result = std::make_shared<CHeroList>(itemsCount, item.topLeft(), itemOffset, LOCPLINT->localState->getWanderingHeroes().size()); auto result = std::make_shared<CHeroList>(itemsCount, area, item.topLeft() - area.topLeft(), itemOffset, LOCPLINT->localState->getWanderingHeroes().size());
if(!input["scrollUp"].isNull()) if(!input["scrollUp"].isNull())
@@ -272,7 +272,8 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapTownList(const JsonNode
Point itemOffset(input["itemsOffset"]["x"].Integer(), input["itemsOffset"]["y"].Integer()); Point itemOffset(input["itemsOffset"]["x"].Integer(), input["itemsOffset"]["y"].Integer());
int itemsCount = input["itemsCount"].Integer(); int itemsCount = input["itemsCount"].Integer();
auto result = std::make_shared<CTownList>(itemsCount, item.topLeft(), itemOffset, LOCPLINT->localState->getOwnedTowns().size()); auto result = std::make_shared<CTownList>(itemsCount, area, item.topLeft() - area.topLeft(), itemOffset, LOCPLINT->localState->getOwnedTowns().size());
if(!input["scrollUp"].isNull()) if(!input["scrollUp"].isNull())
result->setScrollUpButton(std::dynamic_pointer_cast<CButton>(buildMapButton(input["scrollUp"]))); result->setScrollUpButton(std::dynamic_pointer_cast<CButton>(buildMapButton(input["scrollUp"])));
@@ -427,7 +428,6 @@ void CAdventureMapWidget::updateActiveStateChildden(CIntObject * widget)
if (container->disableCondition == "worldViewMode") if (container->disableCondition == "worldViewMode")
container->setEnabled(!shortcuts->optionInWorldView()); container->setEnabled(!shortcuts->optionInWorldView());
updateActiveStateChildden(container); updateActiveStateChildden(container);
} }
} }
@@ -439,4 +439,6 @@ void CAdventureMapWidget::updateActiveState()
for (auto entry: shortcuts->getShortcuts()) for (auto entry: shortcuts->getShortcuts())
setShortcutBlocked(entry.shortcut, !entry.isEnabled); setShortcutBlocked(entry.shortcut, !entry.isEnabled);
//GH.totalRedraw(); // FIXME: required to eliminate graphical artifacts on leaving world view mode
} }

View File

@@ -20,6 +20,7 @@
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../PlayerLocalState.h" #include "../PlayerLocalState.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../renderSDL/SDL_Extensions.h"
#include "../../lib/CGeneralTextHandler.h" #include "../../lib/CGeneralTextHandler.h"
#include "../../lib/CHeroHandler.h" #include "../../lib/CHeroHandler.h"
@@ -81,22 +82,31 @@ void CList::CListItem::onSelect(bool on)
redraw(); redraw();
} }
CList::CList(int Size, Point position) CList::CList(int Size, Rect widgetDimensions)
: CIntObject(0, position), : CIntObject(0, widgetDimensions.topLeft()),
size(Size), size(Size),
selected(nullptr) selected(nullptr)
{ {
pos.w = widgetDimensions.w;
pos.h = widgetDimensions.h;
} }
void CList::createList(Point itemOffset, size_t listAmount) void CList::showAll(SDL_Surface * to)
{
CSDL_Ext::fillRect(to, pos, Colors::BLACK);
CIntObject::showAll(to);
}
void CList::createList(Point firstItemPosition, Point itemPositionDelta, size_t listAmount)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
listBox = std::make_shared<CListBox>(std::bind(&CList::createItem, this, _1), Point(0, 0), itemOffset, size, listAmount); listBox = std::make_shared<CListBox>(std::bind(&CList::createItem, this, _1), firstItemPosition, itemPositionDelta, size, listAmount);
} }
void CList::setScrollUpButton(std::shared_ptr<CButton> button) void CList::setScrollUpButton(std::shared_ptr<CButton> button)
{ {
addChild(button.get());
scrollUp = button; scrollUp = button;
scrollUp->addCallback(std::bind(&CListBox::moveToPrev, listBox)); scrollUp->addCallback(std::bind(&CListBox::moveToPrev, listBox));
scrollUp->addCallback(std::bind(&CList::update, this)); scrollUp->addCallback(std::bind(&CList::update, this));
@@ -105,6 +115,8 @@ void CList::setScrollUpButton(std::shared_ptr<CButton> button)
void CList::setScrollDownButton(std::shared_ptr<CButton> button) void CList::setScrollDownButton(std::shared_ptr<CButton> button)
{ {
addChild(button.get());
scrollDown = button; scrollDown = button;
scrollDown->addCallback(std::bind(&CList::update, this)); scrollDown->addCallback(std::bind(&CList::update, this));
scrollDown->addCallback(std::bind(&CListBox::moveToNext, listBox)); scrollDown->addCallback(std::bind(&CListBox::moveToNext, listBox));
@@ -242,10 +254,10 @@ std::shared_ptr<CIntObject> CHeroList::createItem(size_t index)
return std::make_shared<CEmptyHeroItem>(); return std::make_shared<CEmptyHeroItem>();
} }
CHeroList::CHeroList(int size, Point position, Point itemOffset, size_t listAmount) CHeroList::CHeroList(int visibleItemsCount, Rect widgetPosition, Point firstItemOffset, Point itemOffsetDelta, size_t initialItemsCount)
: CList(size, position) : CList(visibleItemsCount, widgetPosition)
{ {
createList(itemOffset, listAmount); createList(firstItemOffset, itemOffsetDelta, initialItemsCount);
} }
void CHeroList::select(const CGHeroInstance * hero) void CHeroList::select(const CGHeroInstance * hero)
@@ -325,10 +337,10 @@ std::string CTownList::CTownItem::getHoverText()
return town->getObjectName(); return town->getObjectName();
} }
CTownList::CTownList(int size, Point position, Point itemOffset, size_t listAmount) CTownList::CTownList(int visibleItemsCount, Rect widgetPosition, Point firstItemOffset, Point itemOffsetDelta, size_t initialItemsCount)
: CList(size, position) : CList(visibleItemsCount, widgetPosition)
{ {
createList(itemOffset, listAmount); createList(firstItemOffset, itemOffsetDelta, initialItemsCount);
} }
void CTownList::select(const CGTownInstance * town) void CTownList::select(const CGTownInstance * town)

View File

@@ -67,9 +67,9 @@ private:
protected: protected:
std::shared_ptr<CListBox> listBox; std::shared_ptr<CListBox> listBox;
CList(int size, Point position); CList(int size, Rect widgetDimensions);
void createList(Point itemOffset, size_t listAmount); void createList(Point firstItemPosition, Point itemPositionDelta, size_t listAmount);
virtual std::shared_ptr<CIntObject> createItem(size_t index) = 0; virtual std::shared_ptr<CIntObject> createItem(size_t index) = 0;
@@ -90,6 +90,8 @@ public:
void selectIndex(int which); void selectIndex(int which);
void selectNext(); void selectNext();
void selectPrev(); void selectPrev();
void showAll(SDL_Surface * to) override;
}; };
/// List of heroes which is shown at the right of the adventure map screen /// List of heroes which is shown at the right of the adventure map screen
@@ -125,7 +127,7 @@ class CHeroList : public CList
std::shared_ptr<CIntObject> createItem(size_t index); std::shared_ptr<CIntObject> createItem(size_t index);
public: public:
CHeroList(int size, Point position, Point itemOffset, size_t listAmount); CHeroList(int visibleItemsCount, Rect widgetPosition, Point firstItemOffset, Point itemOffsetDelta, size_t initialItemsCount);
/// Select specific hero and scroll if needed /// Select specific hero and scroll if needed
void select(const CGHeroInstance * hero = nullptr); void select(const CGHeroInstance * hero = nullptr);
@@ -155,7 +157,7 @@ class CTownList : public CList
std::shared_ptr<CIntObject> createItem(size_t index) override; std::shared_ptr<CIntObject> createItem(size_t index) override;
public: public:
CTownList(int size, Point position, Point itemOffset, size_t listAmount); CTownList(int visibleItemsCount, Rect widgetPosition, Point firstItemOffset, Point itemOffsetDelta, size_t initialItemsCount);
/// Select specific town and scroll if needed /// Select specific town and scroll if needed
void select(const CGTownInstance * town = nullptr); void select(const CGTownInstance * town = nullptr);

View File

@@ -72,7 +72,6 @@ BattleWindow::BattleWindow(BattleInterface & owner):
console = widget<BattleConsole>("console"); console = widget<BattleConsole>("console");
GH.statusbar = console;
owner.console = console; owner.console = console;
owner.fieldController.reset( new BattleFieldController(owner)); owner.fieldController.reset( new BattleFieldController(owner));

View File

@@ -1200,7 +1200,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
statusbar = CGStatusBar::create(statusbarBackground); statusbar = CGStatusBar::create(statusbarBackground);
resdatabar = std::make_shared<CResDataBar>("ARESBAR", 3, 575, 32, 2, 85, 85); resdatabar = std::make_shared<CResDataBar>("ARESBAR", 3, 575, 32, 2, 85, 85);
townlist = std::make_shared<CTownList>(3, Point(745, 430), Point(0, 32), LOCPLINT->localState->getOwnedTowns().size() ); townlist = std::make_shared<CTownList>(3, Rect(Point(745, 430), Point(48, 32*4)), Point(0,0), Point(0, 32), LOCPLINT->localState->getOwnedTowns().size() );
townlist->setScrollUpButton( std::make_shared<CButton>( Point(744, 414), "IAM014", CButton::tooltipLocalized("core.help.306"))); townlist->setScrollUpButton( std::make_shared<CButton>( Point(744, 414), "IAM014", CButton::tooltipLocalized("core.help.306")));
townlist->setScrollDownButton( std::make_shared<CButton>( Point(744, 526), "IAM015", CButton::tooltipLocalized("core.help.307"))); townlist->setScrollDownButton( std::make_shared<CButton>( Point(744, 526), "IAM015", CButton::tooltipLocalized("core.help.307")));

View File

@@ -1,14 +1,7 @@
{ {
"options" : { "options" : {
// player-colored images used for background // player-colored images used for background
"imagesPlayerColored" : [ "AdvMap.pcx" ], "imagesPlayerColored" : [ "AdvMap.pcx" ],
// widgets that are only visible in world view mode
"worldViewWidgets" : [ "worldViewContainer" ],
// widgets that are only visible in game view mode
"gameViewWidgets" : [ "townListContainer", "heroListContainer", "buttonsContainer", "infobox" ],
}, },
"items": "items":
@@ -77,12 +70,6 @@
"image" : "AdvMap.pcx", "image" : "AdvMap.pcx",
"area" : { "right": 0, "top" : 0, "width" : 199, "height" : 196 } "area" : { "right": 0, "top" : 0, "width" : 199, "height" : 196 }
}, },
{
"type": "adventureMapImage",
"name" : "backgroundRightInfobar",
"image" : "AdvMap.pcx",
"area" : { "bottom": 0, "right" : 0, "width" : 199, "height" : 211 }
},
{ {
"type": "adventureMapImage", "type": "adventureMapImage",
"name": "backgroundHeroListBorderLeft", "name": "backgroundHeroListBorderLeft",
@@ -280,29 +267,29 @@
"type": "adventureMapImage", "type": "adventureMapImage",
"name" : "backgroundBelowHeroTownList", "name" : "backgroundBelowHeroTownList",
"image" : "AdvMap.pcx", "image" : "AdvMap.pcx",
"area" : { "right": 0, "left" : 0, "bottom" : 0, "height" : 3 }, "area" : { "right": 0, "left" : 0, "bottom" : 0, "height" : 4 },
"sourceArea": { "bottom" : 208, "height" : 3, "right" : 0, "width" : 193 } "sourceArea": { "bottom" : 208, "height" : 4, "right" : 0, "width" : 193 }
}, },
// Hero List // Hero List
{ {
"type": "adventureMapHeroList", "type": "adventureMapHeroList",
"name" : "heroList", "name" : "heroList",
"area": { "top": 0, "right" : 127, "width" : 64, "height" : 192 }, "area": { "top": 0, "right" : 125, "width" : 68, "height" : 193 },
"scrollUp" : { "scrollUp" : {
"type": "adventureMapButton", "type": "adventureMapButton",
"name": "heroListScrollUp", "name": "heroListScrollUp",
"image" : "IAM012.DEF", "image" : "IAM012.DEF",
"help" : "core.help.303", "help" : "core.help.303",
"area": { "top" : 0, "left": 0, "width" : 64, "height" : 16 } "area": { "top" : 0, "left": 2, "width" : 64, "height" : 16 }
}, },
"scrollDown" : { "scrollDown" : {
"type": "adventureMapButton", "type": "adventureMapButton",
"name": "heroListScrollDown", "name": "heroListScrollDown",
"image" : "IAM013.DEF", "image" : "IAM013.DEF",
"help" : "core.help.304", "help" : "core.help.304",
"area": { "bottom" : 0, "left": 0, "width" : 64, "height" : 16 } "area": { "bottom" : 0, "left": 2, "width" : 64, "height" : 16 }
}, },
"item" : { "top" : 16, "left": 1, "width" : 62, "height" : 32 }, "item" : { "top" : 16, "left": 3, "width" : 62, "height" : 32 },
"itemsOffset" : { "x" : 0, "y" : 32 }, "itemsOffset" : { "x" : 0, "y" : 32 },
"itemsCount" : 5 "itemsCount" : 5
}, },
@@ -310,22 +297,22 @@
{ {
"type": "adventureMapTownList", "type": "adventureMapTownList",
"name" : "townList", "name" : "townList",
"area": { "top": 0, "right" : 5, "width" : 48, "height" : 192 }, "area": { "top": 0, "right" : 3, "width" : 51, "height" : 193 },
"scrollUp" : { "scrollUp" : {
"type": "adventureMapButton", "type": "adventureMapButton",
"name": "townListScrollUp", "name": "townListScrollUp",
"image" : "IAM014.DEF", "image" : "IAM014.DEF",
"help" : "core.help.306", "help" : "core.help.306",
"area": { "top" : 0, "left": 0, "width" : 48, "height" : 16 } "area": { "top" : 0, "left": 1, "width" : 48, "height" : 16 }
}, },
"scrollDown" : { "scrollDown" : {
"type": "adventureMapButton", "type": "adventureMapButton",
"name": "townListScrollDown", "name": "townListScrollDown",
"image" : "IAM015.DEF", "image" : "IAM015.DEF",
"help" : "core.help.307", "help" : "core.help.307",
"area": { "bottom" : 0, "left": 0, "width" : 48, "height" : 16 } "area": { "bottom" : 0, "left": 1, "width" : 48, "height" : 16 }
}, },
"item" : { "top" : 16, "left": 0, "width" : 48, "height" : 32 }, "item" : { "top" : 16, "left": 2, "width" : 48, "height" : 32 },
"itemsOffset" : { "x" : 0, "y" : 32 }, "itemsOffset" : { "x" : 0, "y" : 32 },
"itemsCount" : 5 "itemsCount" : 5
}, },
@@ -373,15 +360,15 @@
"type": "adventureMapImage", "type": "adventureMapImage",
"name" : "backgroundBelowHeroTownList", "name" : "backgroundBelowHeroTownList",
"image" : "AdvMap.pcx", "image" : "AdvMap.pcx",
"area" : { "right": 0, "left" : 0, "bottom" : 0, "height" : 3 }, "area" : { "right": 0, "left" : 0, "bottom" : 0, "height" : 4 },
"sourceArea": { "bottom" : 208, "height" : 3, "right" : 0, "width" : 193 } "sourceArea": { "bottom" : 208, "height" : 4, "right" : 0, "width" : 193 }
}, },
// Hero List // Hero List
{ {
"type": "adventureMapHeroList", "type": "adventureMapHeroList",
"name" : "heroList", "name" : "heroList",
"area": { "top": 0, "right" : 127, "width" : 64, "height" : 256 }, "area": { "top": 0, "right" : 125, "width" : 68, "height" : 257 },
"item" : { "top" : 0, "left": 1, "width" : 62, "height" : 32 }, "item" : { "top" : 1, "left": 3, "width" : 62, "height" : 32 },
"itemsOffset" : { "x" : 0, "y" : 32 }, "itemsOffset" : { "x" : 0, "y" : 32 },
"itemsCount" : 8 "itemsCount" : 8
}, },
@@ -389,22 +376,22 @@
{ {
"type": "adventureMapTownList", "type": "adventureMapTownList",
"name" : "townList", "name" : "townList",
"area": { "top": 0, "right" : 5, "width" : 48, "height" : 256 }, "area": { "top": 0, "right" : 3, "width" : 51, "height" : 257 },
"scrollUp" : { "scrollUp" : {
"type": "adventureMapButton", "type": "adventureMapButton",
"name": "townListScrollUp", "name": "townListScrollUp",
"image" : "IAM014.DEF", "image" : "IAM014.DEF",
"help" : "core.help.306", "help" : "core.help.306",
"area": { "top" : 0, "left": 0, "width" : 48, "height" : 16 } "area": { "top" : 0, "left": 1, "width" : 48, "height" : 16 }
}, },
"scrollDown" : { "scrollDown" : {
"type": "adventureMapButton", "type": "adventureMapButton",
"name": "townListScrollDown", "name": "townListScrollDown",
"image" : "IAM015.DEF", "image" : "IAM015.DEF",
"help" : "core.help.307", "help" : "core.help.307",
"area": { "bottom" : 0, "left": 0, "width" : 48, "height" : 16 } "area": { "bottom" : 0, "left": 1, "width" : 48, "height" : 16 }
}, },
"item" : { "top" : 16, "left": 0, "width" : 48, "height" : 32 }, "item" : { "top" : 16, "left": 1, "width" : 48, "height" : 32 },
"itemsOffset" : { "x" : 0, "y" : 32 }, "itemsOffset" : { "x" : 0, "y" : 32 },
"itemsCount" : 7 "itemsCount" : 7
}, },
@@ -438,13 +425,20 @@
"type": "adventureMapContainer", "type": "adventureMapContainer",
"name" : "adventureInfobarContainer", "name" : "adventureInfobarContainer",
"hideWhen" : "worldViewMode", "hideWhen" : "worldViewMode",
"area": { "bottom": 44, "right" : 19, "width" : 175, "height" : 168 } "area" : { "bottom": 0, "right" : 0, "width" : 199, "height" : 211 }
"items" : [ "items" : [
// Infobar // Infobar
{
"type": "adventureMapImage",
"name" : "backgroundRightInfobar",
"image" : "AdvMap.pcx",
"area": { "top": 0, "bottom" : 0, "left" : 0, "right" : 0 },
"sourceArea" : { "bottom": 0, "right" : 0, "width" : 199, "height" : 211 }
},
{ {
"type": "adventureInfobar", "type": "adventureInfobar",
"name": "infoBar", "name": "infoBar",
"area": { "bottom": 0, "top" : 0, "left" : 0, "right" : 0 } "area": { "bottom": 44, "right" : 19, "width" : 175, "height" : 168 }
} }
] ]
}, },