|
@@ -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)
|
|
|
{
|