mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Revert "Load template name from user settings"
This reverts commit 73cc606ee2
.
# Conflicts:
# lib/rmg/CRmgTemplateStorage.cpp
# lib/rmg/CRmgTemplateStorage.h
# mapeditor/windownewmap.cpp
This commit is contained in:
parent
3aa19f92a0
commit
c348c1a053
@ -32,8 +32,6 @@ void CRmgTemplateStorage::loadObject(std::string scope, std::string name, const
|
||||
templates[fullKey].setId(name);
|
||||
templates[fullKey].serializeJson(handler);
|
||||
templates[fullKey].validate();
|
||||
|
||||
templatesByName[name] = templates[fullKey];
|
||||
}
|
||||
catch(const std::exception & e)
|
||||
{
|
||||
@ -53,22 +51,14 @@ std::vector<JsonNode> CRmgTemplateStorage::loadLegacyData(size_t dataSize)
|
||||
//it would be cool to load old rmg.txt files
|
||||
}
|
||||
|
||||
const CRmgTemplate * CRmgTemplateStorage::getTemplate(const std::string & templateFullId) const
|
||||
const CRmgTemplate * CRmgTemplateStorage::getTemplate(const std::string & templateName) const
|
||||
{
|
||||
auto iter = templates.find(templateFullId);
|
||||
auto iter = templates.find(templateName);
|
||||
if(iter==templates.end())
|
||||
return nullptr;
|
||||
return &iter->second;
|
||||
}
|
||||
|
||||
const CRmgTemplate * CRmgTemplateStorage::getTemplateByName(const std::string & templateName) const
|
||||
{
|
||||
auto iter = templatesByName.find(templateName);
|
||||
if(iter == templatesByName.end())
|
||||
return nullptr;
|
||||
return &iter->second;
|
||||
}
|
||||
|
||||
std::vector<const CRmgTemplate *> CRmgTemplateStorage::getTemplates() const
|
||||
{
|
||||
std::vector<const CRmgTemplate *> result;
|
||||
|
@ -29,12 +29,10 @@ public:
|
||||
virtual void loadObject(std::string scope, std::string name, const JsonNode & data) override;
|
||||
virtual void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
|
||||
|
||||
const CRmgTemplate * getTemplate(const std::string & templateFullId) const;
|
||||
const CRmgTemplate * getTemplateByName(const std::string & templateName) const;
|
||||
const CRmgTemplate* getTemplate(const std::string & templateName) const;
|
||||
std::vector<const CRmgTemplate *> getTemplates() const;
|
||||
|
||||
private:
|
||||
std::map<std::string, CRmgTemplate> templates; //FIXME: doesn't IHandlerBase cover this?
|
||||
std::map<std::string, CRmgTemplate> templatesByName;
|
||||
std::map<std::string, CRmgTemplate> templates;
|
||||
};
|
||||
|
||||
|
@ -24,19 +24,14 @@ WindowNewMap::WindowNewMap(QWidget *parent) :
|
||||
|
||||
loadUserSettings();
|
||||
|
||||
ui->widthTxt->setInputMask("d00");
|
||||
ui->heightTxt->setInputMask("d00");
|
||||
show();
|
||||
|
||||
//setup initial parameters - can depend on loaded settings
|
||||
//setup initial parameters
|
||||
mapGenOptions.setWidth(ui->widthTxt->text().toInt());
|
||||
mapGenOptions.setHeight(ui->heightTxt->text().toInt());
|
||||
bool twoLevel = ui->twoLevelCheck->isChecked();
|
||||
mapGenOptions.setHasTwoLevels(twoLevel);
|
||||
updateTemplateList();
|
||||
|
||||
loadLastTemplate();
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
WindowNewMap::~WindowNewMap()
|
||||
@ -47,7 +42,7 @@ WindowNewMap::~WindowNewMap()
|
||||
|
||||
void WindowNewMap::loadUserSettings()
|
||||
{
|
||||
//load last saved settings
|
||||
//load window settings
|
||||
QSettings s(Ui::teamName, Ui::appName);
|
||||
|
||||
auto width = s.value(newMapWidth);
|
||||
@ -113,22 +108,23 @@ void WindowNewMap::loadUserSettings()
|
||||
ui->monsterOpt4->setChecked(true); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowNewMap::loadLastTemplate()
|
||||
{
|
||||
//this requires already loaded template list
|
||||
|
||||
QSettings s(Ui::teamName, Ui::appName);
|
||||
auto templateName = s.value(newMapTemplate);
|
||||
if (templateName.isValid())
|
||||
{
|
||||
auto qstr = templateName.toString();
|
||||
updateTemplateList();
|
||||
|
||||
//Template might have been removed, then silently comboBox will be set to empty string
|
||||
auto index = ui->templateCombo->findText(qstr);
|
||||
ui->templateCombo->setCurrentIndex(index);
|
||||
on_templateCombo_activated(index);
|
||||
auto* templ = VLC->tplh->getTemplate(templateName.toString().toStdString());
|
||||
if (templ)
|
||||
{
|
||||
ui->templateCombo->setCurrentText(templateName.toString());
|
||||
//TODO: validate inside this method
|
||||
mapGenOptions.setMapTemplate(templ);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Display problem on status bar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,14 +163,10 @@ void WindowNewMap::saveUserSettings()
|
||||
s.setValue(newMapMonsterStrength, static_cast<int>(monster));
|
||||
|
||||
auto templateName = ui->templateCombo->currentText();
|
||||
if (templateName.size() && templateName != defaultTemplate)
|
||||
if (templateName.size())
|
||||
{
|
||||
s.setValue(newMapTemplate, templateName);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.setValue(newMapTemplate, "");
|
||||
}
|
||||
}
|
||||
|
||||
void WindowNewMap::on_cancelButton_clicked()
|
||||
@ -359,7 +351,7 @@ void WindowNewMap::on_templateCombo_activated(int index)
|
||||
return;
|
||||
}
|
||||
|
||||
auto * templ = VLC->tplh->getTemplateByName(ui->templateCombo->currentText().toStdString());
|
||||
auto * templ = VLC->tplh->getTemplate(ui->templateCombo->currentText().toStdString());
|
||||
mapGenOptions.setMapTemplate(templ);
|
||||
}
|
||||
|
||||
@ -398,7 +390,7 @@ void WindowNewMap::updateTemplateList()
|
||||
if(templates.empty())
|
||||
return;
|
||||
|
||||
ui->templateCombo->addItem(defaultTemplate);
|
||||
ui->templateCombo->addItem("[default]");
|
||||
|
||||
for(auto * templ : templates)
|
||||
{
|
||||
|
@ -23,8 +23,6 @@ class WindowNewMap : public QDialog
|
||||
const QString newMapMonsterStrength = "NewMapWindow/MonsterStrength";
|
||||
const QString newMapTemplate = "NewMapWindow/Template";
|
||||
|
||||
const QString defaultTemplate = "[default]";
|
||||
|
||||
const int playerLimit = 8;
|
||||
|
||||
const std::map<int, int> players
|
||||
@ -85,7 +83,6 @@ private:
|
||||
void updateTemplateList();
|
||||
|
||||
void loadUserSettings();
|
||||
void loadLastTemplate();
|
||||
void saveUserSettings();
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user