mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
code review
This commit is contained in:
parent
7f4361eb10
commit
cbd014ac88
@ -63,7 +63,7 @@ CMapOverview::CMapOverview(std::string mapName, std::string fileName, std::strin
|
|||||||
fitToScreen(10);
|
fitToScreen(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas CMapOverview::CMapOverviewWidget::createMinimapForLayer(std::unique_ptr<CMap> & map, int layer) const
|
Canvas CMapOverviewWidget::createMinimapForLayer(std::unique_ptr<CMap> & map, int layer) const
|
||||||
{
|
{
|
||||||
Canvas canvas = Canvas(Point(map->width, map->height));
|
Canvas canvas = Canvas(Point(map->width, map->height));
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ Canvas CMapOverview::CMapOverviewWidget::createMinimapForLayer(std::unique_ptr<C
|
|||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Canvas> CMapOverview::CMapOverviewWidget::createMinimaps(ResourcePath resource) const
|
std::vector<Canvas> CMapOverviewWidget::createMinimaps(ResourcePath resource) const
|
||||||
{
|
{
|
||||||
std::vector<Canvas> ret = std::vector<Canvas>();
|
std::vector<Canvas> ret = std::vector<Canvas>();
|
||||||
|
|
||||||
@ -109,15 +109,16 @@ std::vector<Canvas> CMapOverview::CMapOverviewWidget::createMinimaps(ResourcePat
|
|||||||
{
|
{
|
||||||
map = mapService.loadMap(resource);
|
map = mapService.loadMap(resource);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (const std::exception & e)
|
||||||
{
|
{
|
||||||
|
logGlobal->warn("Failed to generate map preview! %s", e.what());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return createMinimaps(map);
|
return createMinimaps(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Canvas> CMapOverview::CMapOverviewWidget::createMinimaps(std::unique_ptr<CMap> & map) const
|
std::vector<Canvas> CMapOverviewWidget::createMinimaps(std::unique_ptr<CMap> & map) const
|
||||||
{
|
{
|
||||||
std::vector<Canvas> ret = std::vector<Canvas>();
|
std::vector<Canvas> ret = std::vector<Canvas>();
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ std::vector<Canvas> CMapOverview::CMapOverviewWidget::createMinimaps(std::unique
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CPicture> CMapOverview::CMapOverviewWidget::buildDrawMinimap(const JsonNode & config) const
|
std::shared_ptr<CPicture> CMapOverviewWidget::buildDrawMinimap(const JsonNode & config) const
|
||||||
{
|
{
|
||||||
logGlobal->debug("Building widget drawMinimap");
|
logGlobal->debug("Building widget drawMinimap");
|
||||||
|
|
||||||
@ -144,7 +145,7 @@ std::shared_ptr<CPicture> CMapOverview::CMapOverviewWidget::buildDrawMinimap(con
|
|||||||
return std::make_shared<CPicture>(img, Point(rect.x, rect.y));
|
return std::make_shared<CPicture>(img, Point(rect.x, rect.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
CMapOverview::CMapOverviewWidget::CMapOverviewWidget(CMapOverview& parent):
|
CMapOverviewWidget::CMapOverviewWidget(CMapOverview& parent):
|
||||||
InterfaceObjectConfigurable(), p(parent)
|
InterfaceObjectConfigurable(), p(parent)
|
||||||
{
|
{
|
||||||
drawPlayerElements = p.tabType == ESelectionScreen::newGame;
|
drawPlayerElements = p.tabType == ESelectionScreen::newGame;
|
||||||
@ -174,7 +175,7 @@ CMapOverview::CMapOverviewWidget::CMapOverviewWidget(CMapOverview& parent):
|
|||||||
minimaps = createMinimaps(campaignMap);
|
minimaps = createMinimaps(campaignMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_BUILDER("drawMinimap", &CMapOverview::CMapOverviewWidget::buildDrawMinimap);
|
REGISTER_BUILDER("drawMinimap", &CMapOverviewWidget::buildDrawMinimap);
|
||||||
|
|
||||||
build(config);
|
build(config);
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ class Canvas;
|
|||||||
class TransparentFilledRectangle;
|
class TransparentFilledRectangle;
|
||||||
enum ESelectionScreen : ui8;
|
enum ESelectionScreen : ui8;
|
||||||
|
|
||||||
class CMapOverview : public CWindowObject
|
class CMapOverview;
|
||||||
|
|
||||||
|
class CMapOverviewWidget : public InterfaceObjectConfigurable
|
||||||
{
|
{
|
||||||
class CMapOverviewWidget : public InterfaceObjectConfigurable
|
|
||||||
{
|
|
||||||
CMapOverview& p;
|
CMapOverview& p;
|
||||||
|
|
||||||
bool drawPlayerElements;
|
bool drawPlayerElements;
|
||||||
@ -40,10 +40,12 @@ class CMapOverview : public CWindowObject
|
|||||||
std::vector<Canvas> createMinimaps(std::unique_ptr<CMap> & map) const;
|
std::vector<Canvas> createMinimaps(std::unique_ptr<CMap> & map) const;
|
||||||
|
|
||||||
std::shared_ptr<CPicture> buildDrawMinimap(const JsonNode & config) const;
|
std::shared_ptr<CPicture> buildDrawMinimap(const JsonNode & config) const;
|
||||||
public:
|
public:
|
||||||
CMapOverviewWidget(CMapOverview& p);
|
CMapOverviewWidget(CMapOverview& p);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CMapOverview : public CWindowObject
|
||||||
|
{
|
||||||
std::shared_ptr<CMapOverviewWidget> widget;
|
std::shared_ptr<CMapOverviewWidget> widget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user