|
@@ -27,11 +27,10 @@
|
|
|
#include "../widgets/TextControls.h"
|
|
#include "../widgets/TextControls.h"
|
|
|
#include "../windows/GUIClasses.h"
|
|
#include "../windows/GUIClasses.h"
|
|
|
#include "../windows/InfoWindows.h"
|
|
#include "../windows/InfoWindows.h"
|
|
|
|
|
+#include "../windows/CMapOverview.h"
|
|
|
#include "../render/CAnimation.h"
|
|
#include "../render/CAnimation.h"
|
|
|
-#include "../render/Canvas.h"
|
|
|
|
|
#include "../render/IImage.h"
|
|
#include "../render/IImage.h"
|
|
|
#include "../render/IRenderHandler.h"
|
|
#include "../render/IRenderHandler.h"
|
|
|
-#include "../render/Graphics.h"
|
|
|
|
|
|
|
|
|
|
#include "../../CCallback.h"
|
|
#include "../../CCallback.h"
|
|
|
|
|
|
|
@@ -41,8 +40,6 @@
|
|
|
#include "../../lib/GameSettings.h"
|
|
#include "../../lib/GameSettings.h"
|
|
|
#include "../../lib/filesystem/Filesystem.h"
|
|
#include "../../lib/filesystem/Filesystem.h"
|
|
|
#include "../../lib/campaign/CampaignState.h"
|
|
#include "../../lib/campaign/CampaignState.h"
|
|
|
-#include "../../lib/mapping/CMap.h"
|
|
|
|
|
-#include "../../lib/mapping/CMapService.h"
|
|
|
|
|
#include "../../lib/mapping/CMapInfo.h"
|
|
#include "../../lib/mapping/CMapInfo.h"
|
|
|
#include "../../lib/mapping/CMapHeader.h"
|
|
#include "../../lib/mapping/CMapHeader.h"
|
|
|
#include "../../lib/mapping/MapFormat.h"
|
|
#include "../../lib/mapping/MapFormat.h"
|
|
@@ -366,13 +363,7 @@ void SelectionTab::showPopupWindow(const Point & cursorPosition)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
if(!curItems[py]->isFolder)
|
|
if(!curItems[py]->isFolder)
|
|
|
- {
|
|
|
|
|
- std::string text = boost::str(boost::format("{%1%}\r\n\r\n%2%:\r\n%3%") % curItems[py]->getNameTranslated() % CGI->generaltexth->translate("vcmi.lobby.filename") % curItems[py]->fullFileURI);
|
|
|
|
|
- if(curItems[py]->date != "")
|
|
|
|
|
- text += boost::str(boost::format("\r\n\r\n%1%:\r\n%2%") % CGI->generaltexth->translate("vcmi.lobby.creationDate") % curItems[py]->date);
|
|
|
|
|
-
|
|
|
|
|
- GH.windows().createAndPushWindow<CMapInfoTooltipBox>(text, ResourcePath(curItems[py]->fileURI), tabType);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ GH.windows().createAndPushWindow<CMapOverview>(curItems[py]->getNameTranslated(), curItems[py]->fullFileURI, curItems[py]->date, ResourcePath(curItems[py]->fileURI), tabType);
|
|
|
else
|
|
else
|
|
|
CRClickPopup::createAndPush(curItems[py]->folderName);
|
|
CRClickPopup::createAndPush(curItems[py]->folderName);
|
|
|
}
|
|
}
|
|
@@ -822,121 +813,6 @@ std::unordered_set<ResourcePath> SelectionTab::getFiles(std::string dirURI, ERes
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-SelectionTab::CMapInfoTooltipBox::CMapInfoTooltipBox(std::string text, ResourcePath resource, ESelectionScreen tabType)
|
|
|
|
|
- : CWindowObject(BORDERED | RCLICK_POPUP)
|
|
|
|
|
-{
|
|
|
|
|
- drawPlayerElements = tabType == ESelectionScreen::newGame;
|
|
|
|
|
- renderImage = tabType == ESelectionScreen::newGame && settings["lobby"]["mapPreview"].Bool();
|
|
|
|
|
-
|
|
|
|
|
- OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
|
|
|
|
-
|
|
|
|
|
- std::vector<std::shared_ptr<IImage>> mapLayerImages;
|
|
|
|
|
- if(renderImage)
|
|
|
|
|
- mapLayerImages = createMinimaps(ResourcePath(resource.getName(), EResType::MAP), IMAGE_SIZE);
|
|
|
|
|
-
|
|
|
|
|
- if(mapLayerImages.size() == 0)
|
|
|
|
|
- renderImage = false;
|
|
|
|
|
-
|
|
|
|
|
- pos = Rect(0, 0, 3 * BORDER + 2 * IMAGE_SIZE, 2000);
|
|
|
|
|
-
|
|
|
|
|
- auto drawLabel = [&]() {
|
|
|
|
|
- label = std::make_shared<CTextBox>(text, Rect(BORDER, BORDER, BORDER + 2 * IMAGE_SIZE, 350), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
|
|
|
|
|
- if(!label->slider)
|
|
|
|
|
- label->resize(Point(BORDER + 2 * IMAGE_SIZE, label->label->textSize.y));
|
|
|
|
|
- };
|
|
|
|
|
- drawLabel();
|
|
|
|
|
-
|
|
|
|
|
- int textHeight = std::min(350, label->label->textSize.y);
|
|
|
|
|
- pos.h = BORDER + textHeight + BORDER;
|
|
|
|
|
- if(renderImage)
|
|
|
|
|
- pos.h += IMAGE_SIZE + BORDER;
|
|
|
|
|
- backgroundTexture = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), pos);
|
|
|
|
|
- updateShadow();
|
|
|
|
|
-
|
|
|
|
|
- drawLabel();
|
|
|
|
|
-
|
|
|
|
|
- if(renderImage)
|
|
|
|
|
- {
|
|
|
|
|
- if(mapLayerImages.size() == 1)
|
|
|
|
|
- image1 = std::make_shared<CPicture>(mapLayerImages[0], Point(BORDER + (BORDER + IMAGE_SIZE) / 2, textHeight + 2 * BORDER));
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- image1 = std::make_shared<CPicture>(mapLayerImages[0], Point(BORDER, textHeight + 2 * BORDER));
|
|
|
|
|
- image2 = std::make_shared<CPicture>(mapLayerImages[1], Point(BORDER + IMAGE_SIZE + BORDER, textHeight + 2 * BORDER));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- center(GH.getCursorPosition()); //center on mouse
|
|
|
|
|
-#ifdef VCMI_MOBILE
|
|
|
|
|
- moveBy({0, -pos.h / 2});
|
|
|
|
|
-#endif
|
|
|
|
|
- fitToScreen(10);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-Canvas SelectionTab::CMapInfoTooltipBox::createMinimapForLayer(std::unique_ptr<CMap> & map, int layer)
|
|
|
|
|
-{
|
|
|
|
|
- Canvas canvas = Canvas(Point(map->width, map->height));
|
|
|
|
|
-
|
|
|
|
|
- for (int y = 0; y < map->height; ++y)
|
|
|
|
|
- for (int x = 0; x < map->width; ++x)
|
|
|
|
|
- {
|
|
|
|
|
- TerrainTile & tile = map->getTile(int3(x, y, layer));
|
|
|
|
|
-
|
|
|
|
|
- ColorRGBA color = tile.terType->minimapUnblocked;
|
|
|
|
|
- if (tile.blocked && (!tile.visitable))
|
|
|
|
|
- color = tile.terType->minimapBlocked;
|
|
|
|
|
-
|
|
|
|
|
- if(drawPlayerElements)
|
|
|
|
|
- // if object at tile is owned - it will be colored as its owner
|
|
|
|
|
- for (const CGObjectInstance *obj : tile.blockingObjects)
|
|
|
|
|
- {
|
|
|
|
|
- PlayerColor player = obj->getOwner();
|
|
|
|
|
- if(player == PlayerColor::NEUTRAL)
|
|
|
|
|
- {
|
|
|
|
|
- color = graphics->neutralColor;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (player.isValidPlayer())
|
|
|
|
|
- {
|
|
|
|
|
- color = graphics->playerColors[player.getNum()];
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- canvas.drawPoint(Point(x, y), color);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return canvas;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-std::vector<std::shared_ptr<IImage>> SelectionTab::CMapInfoTooltipBox::createMinimaps(ResourcePath resource, int size)
|
|
|
|
|
-{
|
|
|
|
|
- std::vector<std::shared_ptr<IImage>> ret = std::vector<std::shared_ptr<IImage>>();
|
|
|
|
|
-
|
|
|
|
|
- CMapService mapService;
|
|
|
|
|
- std::unique_ptr<CMap> map;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- map = mapService.loadMap(resource);
|
|
|
|
|
- }
|
|
|
|
|
- catch (...)
|
|
|
|
|
- {
|
|
|
|
|
- return ret;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- for(int i = 0; i < (map->twoLevel ? 2 : 1); i++)
|
|
|
|
|
- {
|
|
|
|
|
- Canvas canvas = createMinimapForLayer(map, i);
|
|
|
|
|
- Canvas canvasScaled = Canvas(Point(size, size));
|
|
|
|
|
- canvasScaled.drawScaled(canvas, Point(0, 0), Point(size, size));
|
|
|
|
|
- std::shared_ptr<IImage> img = GH.renderHandler().createImage(canvasScaled.getInternalSurface());
|
|
|
|
|
-
|
|
|
|
|
- ret.push_back(img);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return ret;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
SelectionTab::ListItem::ListItem(Point position, std::shared_ptr<CAnimation> iconsFormats, std::shared_ptr<CAnimation> iconsVictory, std::shared_ptr<CAnimation> iconsLoss)
|
|
SelectionTab::ListItem::ListItem(Point position, std::shared_ptr<CAnimation> iconsFormats, std::shared_ptr<CAnimation> iconsVictory, std::shared_ptr<CAnimation> iconsLoss)
|
|
|
: CIntObject(LCLICK, position)
|
|
: CIntObject(LCLICK, position)
|
|
|
{
|
|
{
|