Browse Source

add date; cleanup

Laserlicht 2 years ago
parent
commit
c6adcc40f5

+ 2 - 0
Mods/vcmi/config/vcmi/english.json

@@ -51,6 +51,8 @@
 	
 	"vcmi.lobby.filename" : "Filename",
 	"vcmi.lobby.creationDate" : "Creation date",
+	"vcmi.lobby.scenarioName" : "Scenario name",
+	"vcmi.lobby.mapPreview" : "Map preview",
 
 	"vcmi.server.errors.existingProcess" : "Another VCMI server process is running. Please terminate it before starting a new game.",
 	"vcmi.server.errors.modsToEnable"    : "{Following mods are required}",

+ 3 - 1
Mods/vcmi/config/vcmi/german.json

@@ -50,6 +50,8 @@
 	
 	"vcmi.lobby.filename" : "Dateiname",
 	"vcmi.lobby.creationDate" : "Erstellungsdatum",
+	"vcmi.lobby.scenarioName" : "Szenario-Name",
+	"vcmi.lobby.mapPreview" : "Kartenvorschau",
 
 	"vcmi.server.errors.existingProcess" : "Es läuft ein weiterer vcmiserver-Prozess, bitte beendet diesen zuerst",
 	"vcmi.server.errors.modsToEnable"    : "{Erforderliche Mods um das Spiel zu laden}",
@@ -361,4 +363,4 @@
 	"core.bonus.WATER_IMMUNITY.description": "Immun gegen alle Zauber der Wasserschule",
 	"core.bonus.WIDE_BREATH.name": "Breiter Atem",
 	"core.bonus.WIDE_BREATH.description": "Breiter Atem-Angriff (mehrere Felder)"
-}
+}

+ 7 - 1
client/windows/CMapOverview.cpp

@@ -13,6 +13,8 @@
 
 #include "../lobby/SelectionTab.h"
 
+#include <vstd/DateUtils.h>
+
 #include "../gui/CGuiHandler.h"
 #include "../gui/WindowHandler.h"
 #include "../widgets/CComponent.h"
@@ -35,6 +37,7 @@
 #include "../../lib/mapping/CMapHeader.h"
 #include "../../lib/mapping/MapFormat.h"
 #include "../../lib/TerrainHandler.h"
+#include "../../lib/filesystem/Filesystem.h"
 
 CMapOverview::CMapOverview(std::string mapName, std::string fileName, std::string date, ResourcePath resource, ESelectionScreen tabType)
 	: CWindowObject(BORDERED | RCLICK_POPUP), resource(resource), mapName(mapName), fileName(fileName), date(date), tabType(tabType)
@@ -175,12 +178,15 @@ std::shared_ptr<CLabel> CMapOverview::CMapOverviewWidget::buildDrawString(const
 	if("mapname" == config["text"].String())
 		text = parent.mapName;
 	if("date" == config["text"].String())
+	{
 		if(parent.date.empty())
 		{
-			//std::time_t time =
+			std::time_t time = boost::filesystem::last_write_time(*CResourceHandler::get()->getResourceName(ResourcePath(parent.resource.getName(), EResType::MAP)));
+			text = vstd::getFormattedDateTime(time);
 		}
 		else
 			text = parent.date;
+	}
 	auto position = readPosition(config["position"]);
 	return std::make_shared<CLabel>(position.x, position.y, font, alignment, color, text);
 }

+ 5 - 5
client/windows/CMapOverview.h

@@ -48,11 +48,11 @@ class CMapOverview : public CWindowObject
 	std::shared_ptr<CMapOverviewWidget> widget;
 
 public:
-	ResourcePath resource;
-	std::string mapName;
-	std::string fileName;
-	std::string date;
-	ESelectionScreen tabType;
+	const ResourcePath resource;
+	const std::string mapName;
+	const std::string fileName;
+	const std::string date;
+	const ESelectionScreen tabType;
 
 	CMapOverview(std::string mapName, std::string fileName, std::string date, ResourcePath resource, ESelectionScreen tabType);
 };

+ 3 - 3
config/widgets/mapOverview.json

@@ -5,7 +5,7 @@
 			"name": "background",
 			"type": "texture",
 			"image": "DIBOXBCK",
-			"rect": {"w": 428, "h": 500}
+			"rect": {"w": 428, "h": 384}
 		},
 		{
 			"type": "drawTransparentRect",
@@ -18,7 +18,7 @@
 			"font": "medium",
 			"alignment": "center",
 			"color": "yellow",
-			"text": "vcmi.lobby.filename",
+			"text": "vcmi.lobby.scenarioName",
 			"position": {"x": 214, "y": 15}
 		},
 		{
@@ -46,7 +46,7 @@
 			"font": "medium",
 			"alignment": "center",
 			"color": "yellow",
-			"text": "vcmi.lobby.filename",
+			"text": "vcmi.lobby.mapPreview",
 			"position": {"x": 214, "y": 65}
 		},
 		{