mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
fixes & code review
This commit is contained in:
parent
772224e46c
commit
661c374bf2
@ -390,14 +390,28 @@ void SelectionTab::showPopupWindow(const Point & cursorPosition)
|
||||
|
||||
if(!curItems[py]->isFolder)
|
||||
{
|
||||
auto creationDateTime = tabType == ESelectionScreen::newGame && curItems[py]->mapHeader->creationDateTime ? TextOperations::getFormattedDateTimeLocal(curItems[py]->mapHeader->creationDateTime) : curItems[py]->date;
|
||||
auto author = curItems[py]->mapHeader->author.toString() + (!curItems[py]->mapHeader->authorContact.toString().empty() ? (" <" + curItems[py]->mapHeader->authorContact.toString() + ">") : "");
|
||||
std::string creationDateTime;
|
||||
std::string author;
|
||||
std::string mapVersion;
|
||||
if(tabType != ESelectionScreen::campaignList)
|
||||
{
|
||||
author = curItems[py]->mapHeader->author.toString() + (!curItems[py]->mapHeader->authorContact.toString().empty() ? (" <" + curItems[py]->mapHeader->authorContact.toString() + ">") : "");
|
||||
mapVersion = curItems[py]->mapHeader->mapVersion.toString();
|
||||
creationDateTime = tabType == ESelectionScreen::newGame && curItems[py]->mapHeader->creationDateTime ? TextOperations::getFormattedDateTimeLocal(curItems[py]->mapHeader->creationDateTime) : curItems[py]->date;
|
||||
}
|
||||
else
|
||||
{
|
||||
author = curItems[py]->campaign->getAuthor() + (!curItems[py]->campaign->getAuthorContact().empty() ? (" <" + curItems[py]->campaign->getAuthorContact() + ">") : "");
|
||||
mapVersion = curItems[py]->campaign->getCampaignVersion();
|
||||
creationDateTime = curItems[py]->campaign->getCreationDateTime() ? TextOperations::getFormattedDateTimeLocal(curItems[py]->campaign->getCreationDateTime()) : curItems[py]->date;
|
||||
}
|
||||
|
||||
GH.windows().createAndPushWindow<CMapOverview>(
|
||||
curItems[py]->getNameTranslated(),
|
||||
curItems[py]->fullFileURI,
|
||||
creationDateTime,
|
||||
author,
|
||||
curItems[py]->mapHeader->mapVersion.toString(),
|
||||
mapVersion,
|
||||
ResourcePath(curItems[py]->fileURI),
|
||||
tabType
|
||||
);
|
||||
|
@ -156,7 +156,7 @@ void CampaignHandler::readHeaderFromJson(CampaignHeader & ret, JsonNode & reader
|
||||
ret.campaignRegions = CampaignRegions::fromJson(reader["regions"]);
|
||||
ret.numberOfScenarios = reader["scenarios"].Vector().size();
|
||||
ret.name.appendTextID(readLocalizedString(ret, reader["name"].String(), filename, modName, "name"));
|
||||
ret.description.appendTextID(readLocalizedString(ret, reader["description"].String(), filename, modName, "name"));
|
||||
ret.description.appendTextID(readLocalizedString(ret, reader["description"].String(), filename, modName, "description"));
|
||||
ret.author.appendRawString(reader["author"].String());
|
||||
ret.authorContact.appendRawString(reader["authorContact"].String());
|
||||
ret.campaignVersion.appendRawString(reader["campaignVersion"].String());
|
||||
@ -594,13 +594,14 @@ CampaignTravel CampaignHandler::readScenarioTravelFromMemory(CBinaryReader & rea
|
||||
|
||||
std::vector< std::vector<ui8> > CampaignHandler::getFile(std::unique_ptr<CInputStream> file, const std::string & filename, bool headerOnly)
|
||||
{
|
||||
std::vector<ui8> magic(2);
|
||||
std::array<ui8, 2> magic;
|
||||
file->read(magic.data(), magic.size());
|
||||
file->seek(0);
|
||||
|
||||
std::vector< std::vector<ui8> > ret;
|
||||
|
||||
if (magic == std::vector<ui8>{0x50, 0x4B}) // VCMP (ZIP)
|
||||
static const std::array<ui8, 2> zipHeaderMagic{0x50, 0x4B};
|
||||
if (magic == zipHeaderMagic) // ZIP archive - assume VCMP format
|
||||
{
|
||||
CInputStream * buffer(file.get());
|
||||
std::shared_ptr<CIOApi> ioApi(new CProxyROIOApi(buffer));
|
||||
@ -629,7 +630,7 @@ std::vector< std::vector<ui8> > CampaignHandler::getFile(std::unique_ptr<CInputS
|
||||
|
||||
return ret;
|
||||
}
|
||||
else // H3M
|
||||
else // H3C
|
||||
{
|
||||
CCompressedStream stream(std::move(file), true);
|
||||
|
||||
|
@ -144,6 +144,26 @@ std::string CampaignHeader::getNameTranslated() const
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
std::string CampaignHeader::getAuthor() const
|
||||
{
|
||||
return authorContact.toString();
|
||||
}
|
||||
|
||||
std::string CampaignHeader::getAuthorContact() const
|
||||
{
|
||||
return authorContact.toString();
|
||||
}
|
||||
|
||||
std::string CampaignHeader::getCampaignVersion() const
|
||||
{
|
||||
return campaignVersion.toString();
|
||||
}
|
||||
|
||||
time_t CampaignHeader::getCreationDateTime() const
|
||||
{
|
||||
return creationDateTime;
|
||||
}
|
||||
|
||||
std::string CampaignHeader::getFilename() const
|
||||
{
|
||||
return filename;
|
||||
|
@ -103,6 +103,10 @@ public:
|
||||
|
||||
std::string getDescriptionTranslated() const;
|
||||
std::string getNameTranslated() const;
|
||||
std::string getAuthor() const;
|
||||
std::string getAuthorContact() const;
|
||||
std::string getCampaignVersion() const;
|
||||
time_t getCreationDateTime() const;
|
||||
std::string getFilename() const;
|
||||
std::string getModName() const;
|
||||
std::string getEncoding() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user