2023-09-07 20:19:31 +02:00
|
|
|
/*
|
|
|
|
* generalsettings.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2023-09-05 01:26:38 +02:00
|
|
|
#include "StdInc.h"
|
|
|
|
#include "generalsettings.h"
|
|
|
|
#include "ui_generalsettings.h"
|
2023-09-11 19:16:24 +02:00
|
|
|
#include "../mapcontroller.h"
|
2023-09-05 01:26:38 +02:00
|
|
|
|
|
|
|
GeneralSettings::GeneralSettings(QWidget *parent) :
|
|
|
|
AbstractSettings(parent),
|
|
|
|
ui(new Ui::GeneralSettings)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
GeneralSettings::~GeneralSettings()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2023-09-11 19:16:24 +02:00
|
|
|
void GeneralSettings::initialize(MapController & c)
|
2023-09-05 01:26:38 +02:00
|
|
|
{
|
2023-09-11 19:16:24 +02:00
|
|
|
AbstractSettings::initialize(c);
|
2023-09-28 13:28:37 +02:00
|
|
|
ui->mapNameEdit->setText(QString::fromStdString(controller->map()->name.toString()));
|
|
|
|
ui->mapDescriptionEdit->setPlainText(QString::fromStdString(controller->map()->description.toString()));
|
2024-06-29 13:13:59 +02:00
|
|
|
ui->authorEdit->setText(QString::fromStdString(controller->map()->author.toString()));
|
|
|
|
ui->authorContactEdit->setText(QString::fromStdString(controller->map()->authorContact.toString()));
|
2024-06-29 14:55:56 +02:00
|
|
|
ui->mapCreationDateTimeEdit->setDateTime(QDateTime::fromSecsSinceEpoch(controller->map()->creationDateTime));
|
2024-06-29 13:13:59 +02:00
|
|
|
ui->mapVersionEdit->setText(QString::fromStdString(controller->map()->mapVersion.toString()));
|
2023-09-11 19:16:24 +02:00
|
|
|
ui->heroLevelLimit->setValue(controller->map()->levelLimit);
|
|
|
|
ui->heroLevelLimitCheck->setChecked(controller->map()->levelLimit);
|
2023-09-05 01:26:38 +02:00
|
|
|
|
|
|
|
//set difficulty
|
2023-09-11 19:16:24 +02:00
|
|
|
switch(controller->map()->difficulty)
|
2023-09-05 01:26:38 +02:00
|
|
|
{
|
2024-02-06 00:39:05 +02:00
|
|
|
case EMapDifficulty::EASY:
|
2023-09-05 01:26:38 +02:00
|
|
|
ui->diffRadio1->setChecked(true);
|
|
|
|
break;
|
|
|
|
|
2024-02-06 00:39:05 +02:00
|
|
|
case EMapDifficulty::NORMAL:
|
2023-09-05 01:26:38 +02:00
|
|
|
ui->diffRadio2->setChecked(true);
|
|
|
|
break;
|
|
|
|
|
2024-02-06 00:39:05 +02:00
|
|
|
case EMapDifficulty::HARD:
|
2023-09-05 01:26:38 +02:00
|
|
|
ui->diffRadio3->setChecked(true);
|
|
|
|
break;
|
|
|
|
|
2024-02-06 00:39:05 +02:00
|
|
|
case EMapDifficulty::EXPERT:
|
2023-09-05 01:26:38 +02:00
|
|
|
ui->diffRadio4->setChecked(true);
|
|
|
|
break;
|
|
|
|
|
2024-02-06 00:39:05 +02:00
|
|
|
case EMapDifficulty::IMPOSSIBLE:
|
2023-09-05 01:26:38 +02:00
|
|
|
ui->diffRadio5->setChecked(true);
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-09-11 19:16:24 +02:00
|
|
|
void GeneralSettings::update()
|
2023-09-05 01:26:38 +02:00
|
|
|
{
|
2023-10-01 14:04:46 +02:00
|
|
|
controller->map()->name = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller->map(), TextIdentifier("header", "name"), ui->mapNameEdit->text().toStdString()));
|
|
|
|
controller->map()->description = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller->map(), TextIdentifier("header", "description"), ui->mapDescriptionEdit->toPlainText().toStdString()));
|
2024-06-29 14:14:21 +02:00
|
|
|
controller->map()->author = MetaString::createFromRawString(ui->authorEdit->text().toStdString());
|
|
|
|
controller->map()->authorContact = MetaString::createFromRawString(ui->authorContactEdit->text().toStdString());
|
2024-06-29 14:55:56 +02:00
|
|
|
controller->map()->creationDateTime = ui->mapCreationDateTimeEdit->dateTime().toSecsSinceEpoch();
|
2024-06-29 14:14:21 +02:00
|
|
|
controller->map()->mapVersion = MetaString::createFromRawString(ui->mapVersionEdit->text().toStdString());
|
2023-09-05 01:26:38 +02:00
|
|
|
if(ui->heroLevelLimitCheck->isChecked())
|
2023-09-11 19:16:24 +02:00
|
|
|
controller->map()->levelLimit = ui->heroLevelLimit->value();
|
2023-09-05 01:26:38 +02:00
|
|
|
else
|
2023-09-11 19:16:24 +02:00
|
|
|
controller->map()->levelLimit = 0;
|
2023-09-05 01:26:38 +02:00
|
|
|
|
|
|
|
//set difficulty
|
2024-02-06 00:39:05 +02:00
|
|
|
if(ui->diffRadio1->isChecked()) controller->map()->difficulty = EMapDifficulty::EASY;
|
|
|
|
if(ui->diffRadio2->isChecked()) controller->map()->difficulty = EMapDifficulty::NORMAL;
|
|
|
|
if(ui->diffRadio3->isChecked()) controller->map()->difficulty = EMapDifficulty::HARD;
|
|
|
|
if(ui->diffRadio4->isChecked()) controller->map()->difficulty = EMapDifficulty::EXPERT;
|
|
|
|
if(ui->diffRadio5->isChecked()) controller->map()->difficulty = EMapDifficulty::IMPOSSIBLE;
|
2023-09-05 01:26:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralSettings::on_heroLevelLimitCheck_toggled(bool checked)
|
|
|
|
{
|
|
|
|
ui->heroLevelLimit->setEnabled(checked);
|
|
|
|
}
|
|
|
|
|