2012-07-19 22:47:05 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// This file is part of Remere's Map Editor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2020-07-30 11:42:28 -03:00
|
|
|
// Remere's Map Editor is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// Remere's Map Editor is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2012-07-19 22:47:05 +02:00
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
|
|
#include "extension.h"
|
|
|
|
|
|
|
|
|
|
MaterialsExtension::MaterialsExtension(std::string name, std::string author, std::string description) :
|
|
|
|
|
name(name),
|
|
|
|
|
author(author),
|
|
|
|
|
description(description),
|
2023-10-09 19:12:16 -07:00
|
|
|
for_all_versions(false) {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-07-19 22:47:05 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
MaterialsExtension::~MaterialsExtension() {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-07-19 22:47:05 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
void MaterialsExtension::addVersion(const std::string &versionString) {
|
|
|
|
|
if (versionString == "all") {
|
2012-07-19 22:47:05 +02:00
|
|
|
for_all_versions = true;
|
2014-01-25 22:01:11 +01:00
|
|
|
} else {
|
|
|
|
|
ClientVersion* client = ClientVersion::get(versionString);
|
2023-10-09 19:12:16 -07:00
|
|
|
if (client) {
|
2012-07-19 22:47:05 +02:00
|
|
|
ClientVersionList supported_versions = ClientVersion::getAllVersionsSupportedForClientVersion(client);
|
|
|
|
|
version_list.insert(version_list.end(), supported_versions.begin(), supported_versions.end());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
bool MaterialsExtension::isForVersion(uint16_t versionId) {
|
|
|
|
|
if (for_all_versions) {
|
2012-07-19 22:47:05 +02:00
|
|
|
return true;
|
2014-01-25 22:01:11 +01:00
|
|
|
}
|
2012-07-19 22:47:05 +02:00
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
for (ClientVersion* version : version_list) {
|
|
|
|
|
if (version->getID() == versionId) {
|
2012-07-19 22:47:05 +02:00
|
|
|
return true;
|
2014-01-25 22:01:11 +01:00
|
|
|
}
|
2012-07-19 22:47:05 +02:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
std::string MaterialsExtension::getVersionString() {
|
|
|
|
|
if (for_all_versions) {
|
2012-07-19 22:47:05 +02:00
|
|
|
return "All";
|
2014-01-25 22:01:11 +01:00
|
|
|
}
|
2012-07-19 22:47:05 +02:00
|
|
|
|
|
|
|
|
std::string versions;
|
|
|
|
|
std::string last;
|
2023-10-09 19:12:16 -07:00
|
|
|
for (ClientVersion* version : version_list) {
|
|
|
|
|
if (!last.empty()) {
|
|
|
|
|
if (!versions.empty()) {
|
2012-07-19 22:47:05 +02:00
|
|
|
versions += ", " + last;
|
2014-01-25 22:01:11 +01:00
|
|
|
} else {
|
2012-07-19 22:47:05 +02:00
|
|
|
versions = last;
|
2014-01-25 22:01:11 +01:00
|
|
|
}
|
2012-07-19 22:47:05 +02:00
|
|
|
}
|
2014-01-25 22:01:11 +01:00
|
|
|
last = version->getName();
|
2012-07-19 22:47:05 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
if (!last.empty()) {
|
|
|
|
|
if (!versions.empty()) {
|
2012-07-19 22:47:05 +02:00
|
|
|
versions += " and " + last;
|
2014-01-25 22:01:11 +01:00
|
|
|
} else {
|
2012-07-19 22:47:05 +02:00
|
|
|
versions = last;
|
2014-01-25 22:01:11 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
2012-07-19 22:47:05 +02:00
|
|
|
return "None";
|
2014-01-25 22:01:11 +01:00
|
|
|
}
|
2012-07-19 22:47:05 +02:00
|
|
|
return versions;
|
|
|
|
|
}
|