1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Refactoring map settings

This commit is contained in:
nordsoft 2023-09-05 03:26:38 +04:00
parent 50d89dec24
commit 9665ac3373
25 changed files with 2326 additions and 1554 deletions

View File

@ -12,12 +12,18 @@ set(editor_SRCS
generatorprogress.cpp
mapview.cpp
objectbrowser.cpp
mapsettings.cpp
mapsettings/abstractsettings.cpp
mapsettings/mapsettings.cpp
mapsettings/generalsettings.cpp
mapsettings/modsettings.cpp
mapsettings/victoryconditions.cpp
mapsettings/loseconditions.cpp
playersettings.cpp
playerparams.cpp
scenelayer.cpp
mapcontroller.cpp
validator.cpp
timedevent.cpp
inspector/inspector.cpp
inspector/townbulidingswidget.cpp
inspector/armywidget.cpp
@ -40,12 +46,18 @@ set(editor_HEADERS
generatorprogress.h
mapview.h
objectbrowser.h
mapsettings.h
mapsettings/abstractsettings.h
mapsettings/mapsettings.h
mapsettings/generalsettings.h
mapsettings/modsettings.h
mapsettings/victoryconditions.h
mapsettings/loseconditions.h
playersettings.h
playerparams.h
scenelayer.h
mapcontroller.h
validator.h
timedevent.h
inspector/inspector.h
inspector/townbulidingswidget.h
inspector/armywidget.h
@ -59,10 +71,15 @@ set(editor_FORMS
mainwindow.ui
windownewmap.ui
generatorprogress.ui
mapsettings.ui
mapsettings/mapsettings.ui
mapsettings/generalsettings.ui
mapsettings/modsettings.ui
mapsettings/victoryconditions.ui
mapsettings/loseconditions.ui
playersettings.ui
playerparams.ui
validator.ui
timedevent.ui
inspector/townbulidingswidget.ui
inspector/armywidget.ui
inspector/messagewidget.ui

View File

@ -41,7 +41,7 @@
#include "windownewmap.h"
#include "objectbrowser.h"
#include "inspector/inspector.h"
#include "mapsettings.h"
#include "mapsettings/mapsettings.h"
#include "playersettings.h"
#include "validator.h"

File diff suppressed because it is too large Load Diff

View File

@ -1,84 +0,0 @@
/*
* mapsettings.h, 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
*
*/
#pragma once
#include <QDialog>
#include "mapcontroller.h"
#include "../lib/mapping/CMap.h"
namespace Ui {
class MapSettings;
}
class MapSettings : public QDialog
{
Q_OBJECT
public:
explicit MapSettings(MapController & controller, QWidget *parent = nullptr);
~MapSettings();
private slots:
void on_pushButton_clicked();
void on_victoryComboBox_currentIndexChanged(int index);
void on_loseComboBox_currentIndexChanged(int index);
void on_heroLevelLimitCheck_toggled(bool checked);
void on_modResolution_map_clicked();
void on_modResolution_full_clicked();
void on_treeMods_itemChanged(QTreeWidgetItem *item, int column);
private:
std::string getTownName(int townObjectIdx);
std::string getHeroName(int townObjectIdx);
std::string getMonsterName(int townObjectIdx);
void updateModWidgetBasedOnMods(const ModCompatibilityInfo & mods);
template<class T>
std::vector<int> getObjectIndexes() const
{
std::vector<int> result;
for(int i = 0; i < controller.map()->objects.size(); ++i)
{
if(auto town = dynamic_cast<T*>(controller.map()->objects[i].get()))
result.push_back(i);
}
return result;
}
template<class T>
int getObjectByPos(const int3 & pos)
{
for(int i = 0; i < controller.map()->objects.size(); ++i)
{
if(auto town = dynamic_cast<T*>(controller.map()->objects[i].get()))
{
if(town->pos == pos)
return i;
}
}
return -1;
}
Ui::MapSettings *ui;
MapController & controller;
QComboBox * victoryTypeWidget = nullptr, * loseTypeWidget = nullptr;
QComboBox * victorySelectWidget = nullptr, * loseSelectWidget = nullptr;
QLineEdit * victoryValueWidget = nullptr, * loseValueWidget = nullptr;
};

View File

@ -1,447 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MapSettings</class>
<widget class="QDialog" name="MapSettings">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>543</width>
<height>494</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Map settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Map name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mapNameEdit"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Map description</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="mapDescriptionEdit"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="topMargin">
<number>10</number>
</property>
<item>
<widget class="QSpinBox" name="heroLevelLimit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>48</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="heroLevelLimitCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Limit maximum heroes level</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Difficulty</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="diffRadio1">
<property name="text">
<string notr="true">1</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="diffRadio2">
<property name="text">
<string notr="true">2</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="diffRadio3">
<property name="text">
<string notr="true">3</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="diffRadio4">
<property name="text">
<string notr="true">4</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="diffRadio5">
<property name="text">
<string notr="true">5</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_9">
<attribute name="title">
<string>Mods</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Mandatory mods for playing this map</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="treeMods">
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<attribute name="headerDefaultSectionSize">
<number>320</number>
</attribute>
<column>
<property name="text">
<string>Mod name</string>
</property>
</column>
<column>
<property name="text">
<string>Version</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Automatic assignment</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modResolution_map">
<property name="toolTip">
<string>Set required mods based on objects placed on the map. This method may cause problems if you have customized rewards, garrisons, etc from mods</string>
</property>
<property name="text">
<string>Map objects mods</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modResolution_full">
<property name="toolTip">
<string>Set all mods having a game content as mandatory</string>
</property>
<property name="text">
<string>Full content mods</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>Events</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab_7">
<attribute name="title">
<string>Victory</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Victory message</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="victoryMessageEdit"/>
</item>
</layout>
</item>
<item>
<widget class="QComboBox" name="victoryComboBox"/>
</item>
<item>
<widget class="QCheckBox" name="onlyForHumansCheck">
<property name="text">
<string>Only for human players</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="standardVictoryCheck">
<property name="text">
<string>Allow standard victory</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="victoryParams">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Parameters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="topMargin">
<number>12</number>
</property>
<item>
<layout class="QVBoxLayout" name="victoryParamsLayout"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_8">
<attribute name="title">
<string>Loss</string>
</attribute>
<layout class="QFormLayout" name="formLayout_2">
<item row="1" column="0" colspan="2">
<widget class="QComboBox" name="loseComboBox"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="standardLoseCheck">
<property name="text">
<string>7 days without town</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Defeat message</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="defeatMessageEdit"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="loseParams">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Parameters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<layout class="QVBoxLayout" name="loseParamsLayout"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Abilities</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListWidget" name="listAbilities">
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="batchSize">
<number>30</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Spells</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="listSpells">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="batchSize">
<number>30</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Artifacts</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QListWidget" name="listArts">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="batchSize">
<number>30</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Heroes</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QListWidget" name="listHeroes">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="batchSize">
<number>30</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,138 @@
/*
* abstractsettings.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
*
*/
#include "StdInc.h"
#include "abstractsettings.h"
#include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/mapObjects/CGCreature.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CHeroHandler.h"
#include "../../lib/mapObjects/CGCreature.h"
//parses date for lose condition (1m 1w 1d)
int expiredDate(const QString & date)
{
int result = 0;
for(auto component : date.split(" "))
{
int days = component.left(component.lastIndexOf('d')).toInt();
int weeks = component.left(component.lastIndexOf('w')).toInt();
int months = component.left(component.lastIndexOf('m')).toInt();
result += days > 0 ? days - 1 : 0;
result += (weeks > 0 ? weeks - 1 : 0) * 7;
result += (months > 0 ? months - 1 : 0) * 28;
}
return result;
}
QString expiredDate(int date)
{
QString result;
int m = date / 28;
int w = (date % 28) / 7;
int d = date % 7;
if(m)
result += QString::number(m) + "m";
if(w)
{
if(!result.isEmpty())
result += " ";
result += QString::number(w) + "w";
}
if(d)
{
if(!result.isEmpty())
result += " ";
result += QString::number(d) + "d";
}
return result;
}
int3 posFromJson(const JsonNode & json)
{
return int3(json.Vector()[0].Integer(), json.Vector()[1].Integer(), json.Vector()[2].Integer());
}
std::vector<JsonNode> linearJsonArray(const JsonNode & json)
{
std::vector<JsonNode> result;
if(json.getType() == JsonNode::JsonType::DATA_STRUCT)
result.push_back(json);
if(json.getType() == JsonNode::JsonType::DATA_VECTOR)
{
for(auto & node : json.Vector())
{
auto subvector = linearJsonArray(node);
result.insert(result.end(), subvector.begin(), subvector.end());
}
}
return result;
}
AbstractSettings::AbstractSettings(QWidget *parent)
: QWidget{parent}
{
}
std::string AbstractSettings::getTownName(const CMap & map, int objectIdx)
{
std::string name;
if(auto town = dynamic_cast<const CGTownInstance*>(map.objects[objectIdx].get()))
{
auto * ctown = town->town;
if(!ctown)
ctown = VLC->townh->randomTown;
name = ctown->faction ? town->getObjectName() : town->getNameTranslated() + ", (random)";
}
return name;
}
std::string AbstractSettings::getHeroName(const CMap & map, int objectIdx)
{
std::string name;
if(auto hero = dynamic_cast<const CGHeroInstance*>(map.objects[objectIdx].get()))
{
name = hero->getNameTranslated();
}
return name;
}
std::string AbstractSettings::getMonsterName(const CMap & map, int objectIdx)
{
std::string name;
[[maybe_unused]] auto monster = dynamic_cast<const CGCreature*>(map.objects[objectIdx].get());
if(monster)
{
//TODO: get proper name
//name = hero->name;
}
return name;
}
JsonNode AbstractSettings::conditionToJson(const EventCondition & event)
{
JsonNode result;
result["condition"].Integer() = event.condition;
result["value"].Integer() = event.value;
result["objectType"].Integer() = event.objectType;
result["objectSubytype"].Integer() = event.objectSubtype;
result["objectInstanceName"].String() = event.objectInstanceName;
result["metaType"].Integer() = (ui8)event.metaType;
{
auto & position = result["position"].Vector();
position.resize(3);
position[0].Float() = event.position.x;
position[1].Float() = event.position.y;
position[2].Float() = event.position.z;
}
return result;
};

View File

@ -0,0 +1,61 @@
#ifndef ABSTRACTSETTINGS_H
#define ABSTRACTSETTINGS_H
#include <QWidget>
#include "../../lib/mapping/CMap.h"
#include "../../lib/mapObjects/CGTownInstance.h"
#include "../../lib/mapObjects/CGHeroInstance.h"
//parses date for lose condition (1m 1w 1d)
int expiredDate(const QString & date);
QString expiredDate(int date);
int3 posFromJson(const JsonNode & json);
std::vector<JsonNode> linearJsonArray(const JsonNode & json);
class AbstractSettings : public QWidget
{
Q_OBJECT
public:
explicit AbstractSettings(QWidget *parent = nullptr);
virtual ~AbstractSettings() = default;
virtual void initialize(const CMap & map) = 0;
virtual void update(CMap & map) = 0;
std::string getTownName(const CMap & map, int objectIdx);
std::string getHeroName(const CMap & map, int objectIdx);
std::string getMonsterName(const CMap & map, int objectIdx);
static JsonNode conditionToJson(const EventCondition & event);
template<class T>
std::vector<int> getObjectIndexes(const CMap & map) const
{
std::vector<int> result;
for(int i = 0; i < map.objects.size(); ++i)
{
if(auto obj = dynamic_cast<T*>(map.objects[i].get()))
result.push_back(i);
}
return result;
}
template<class T>
int getObjectByPos(const CMap & map, const int3 & pos)
{
for(int i = 0; i < map.objects.size(); ++i)
{
if(auto obj = dynamic_cast<T*>(map.objects[i].get()))
{
if(obj->pos == pos)
return i;
}
}
return -1;
}
signals:
};
#endif // ABSTRACTSETTINGS_H

View File

@ -0,0 +1,70 @@
#include "StdInc.h"
#include "generalsettings.h"
#include "ui_generalsettings.h"
GeneralSettings::GeneralSettings(QWidget *parent) :
AbstractSettings(parent),
ui(new Ui::GeneralSettings)
{
ui->setupUi(this);
}
GeneralSettings::~GeneralSettings()
{
delete ui;
}
void GeneralSettings::initialize(const CMap & map)
{
ui->mapNameEdit->setText(tr(map.name.c_str()));
ui->mapDescriptionEdit->setPlainText(tr(map.description.c_str()));
ui->heroLevelLimit->setValue(map.levelLimit);
ui->heroLevelLimitCheck->setChecked(map.levelLimit);
//set difficulty
switch(map.difficulty)
{
case 0:
ui->diffRadio1->setChecked(true);
break;
case 1:
ui->diffRadio2->setChecked(true);
break;
case 2:
ui->diffRadio3->setChecked(true);
break;
case 3:
ui->diffRadio4->setChecked(true);
break;
case 4:
ui->diffRadio5->setChecked(true);
break;
};
}
void GeneralSettings::update(CMap & map)
{
map.name = ui->mapNameEdit->text().toStdString();
map.description = ui->mapDescriptionEdit->toPlainText().toStdString();
if(ui->heroLevelLimitCheck->isChecked())
map.levelLimit = ui->heroLevelLimit->value();
else
map.levelLimit = 0;
//set difficulty
if(ui->diffRadio1->isChecked()) map.difficulty = 0;
if(ui->diffRadio2->isChecked()) map.difficulty = 1;
if(ui->diffRadio3->isChecked()) map.difficulty = 2;
if(ui->diffRadio4->isChecked()) map.difficulty = 3;
if(ui->diffRadio5->isChecked()) map.difficulty = 4;
}
void GeneralSettings::on_heroLevelLimitCheck_toggled(bool checked)
{
ui->heroLevelLimit->setEnabled(checked);
}

View File

@ -0,0 +1,28 @@
#ifndef GENERALSETTINGS_H
#define GENERALSETTINGS_H
#include "abstractsettings.h"
namespace Ui {
class GeneralSettings;
}
class GeneralSettings : public AbstractSettings
{
Q_OBJECT
public:
explicit GeneralSettings(QWidget *parent = nullptr);
~GeneralSettings();
void initialize(const CMap & map) override;
void update(CMap & map) override;
private slots:
void on_heroLevelLimitCheck_toggled(bool checked);
private:
Ui::GeneralSettings *ui;
};
#endif // GENERALSETTINGS_H

View File

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralSettings</class>
<widget class="QWidget" name="GeneralSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>651</width>
<height>481</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Map name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mapNameEdit"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Map description</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="mapDescriptionEdit"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QSpinBox" name="heroLevelLimit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>48</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="heroLevelLimitCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Limit maximum heroes level</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Difficulty</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="diffRadio1">
<property name="text">
<string notr="true">1</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="diffRadio2">
<property name="text">
<string notr="true">2</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="diffRadio3">
<property name="text">
<string notr="true">3</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="diffRadio4">
<property name="text">
<string notr="true">4</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="diffRadio5">
<property name="text">
<string notr="true">5</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,262 @@
#include "StdInc.h"
#include "loseconditions.h"
#include "ui_loseconditions.h"
#include "../lib/CGeneralTextHandler.h"
LoseConditions::LoseConditions(QWidget *parent) :
AbstractSettings(parent),
ui(new Ui::LoseConditions)
{
ui->setupUi(this);
}
LoseConditions::~LoseConditions()
{
delete ui;
}
void LoseConditions::initialize(const CMap & map)
{
mapPointer = &map;
//loss messages
ui->defeatMessageEdit->setText(QString::fromStdString(map.defeatMessage.toString()));
//loss conditions
const std::array<std::string, 5> conditionStringsLose = {
QT_TR_NOOP("No special loss"),
QT_TR_NOOP("Lose castle"),
QT_TR_NOOP("Lose hero"),
QT_TR_NOOP("Time expired"),
QT_TR_NOOP("Days without town")
};
for(auto & s : conditionStringsLose)
{
ui->loseComboBox->addItem(QString::fromStdString(s));
}
ui->standardLoseCheck->setChecked(false);
for(auto & ev : map.triggeredEvents)
{
if(ev.effect.type == EventEffect::DEFEAT)
{
if(ev.identifier == "standardDefeat")
ui->standardLoseCheck->setChecked(true);
if(ev.identifier == "specialDefeat")
{
auto readjson = ev.trigger.toJson(AbstractSettings::conditionToJson);
auto linearNodes = linearJsonArray(readjson);
for(auto & json : linearNodes)
{
switch(json["condition"].Integer())
{
case EventCondition::CONTROL: {
if(json["objectType"].Integer() == Obj::TOWN)
{
ui->loseComboBox->setCurrentIndex(1);
assert(loseTypeWidget);
int townIdx = getObjectByPos<const CGTownInstance>(*mapPointer, posFromJson(json["position"]));
if(townIdx >= 0)
{
auto idx = loseTypeWidget->findData(townIdx);
loseTypeWidget->setCurrentIndex(idx);
}
}
if(json["objectType"].Integer() == Obj::HERO)
{
ui->loseComboBox->setCurrentIndex(2);
assert(loseTypeWidget);
int heroIdx = getObjectByPos<const CGHeroInstance>(*mapPointer, posFromJson(json["position"]));
if(heroIdx >= 0)
{
auto idx = loseTypeWidget->findData(heroIdx);
loseTypeWidget->setCurrentIndex(idx);
}
}
break;
}
case EventCondition::DAYS_PASSED: {
ui->loseComboBox->setCurrentIndex(3);
assert(loseValueWidget);
loseValueWidget->setText(expiredDate(json["value"].Integer()));
break;
}
case EventCondition::DAYS_WITHOUT_TOWN: {
ui->loseComboBox->setCurrentIndex(4);
assert(loseValueWidget);
loseValueWidget->setText(QString::number(json["value"].Integer()));
break;
case EventCondition::IS_HUMAN:
break; //ignore because always applicable for defeat conditions
}
};
}
}
}
}
}
void LoseConditions::update(CMap & map)
{
//loss messages
map.defeatMessage = MetaString::createFromRawString(ui->defeatMessageEdit->text().toStdString());
//loss conditions
EventCondition defeatCondition(EventCondition::DAYS_WITHOUT_TOWN);
defeatCondition.value = 7;
//Loss condition - 7 days without town
TriggeredEvent standardDefeat;
standardDefeat.effect.type = EventEffect::DEFEAT;
standardDefeat.effect.toOtherMessage.appendTextID("core.genrltxt.8");
standardDefeat.identifier = "standardDefeat";
standardDefeat.description.clear(); // TODO: display in quest window
standardDefeat.onFulfill.appendTextID("core.genrltxt.7");
standardDefeat.trigger = EventExpression(defeatCondition);
//DEFEAT
if(ui->loseComboBox->currentIndex() == 0)
{
map.triggeredEvents.push_back(standardDefeat);
map.defeatIconIndex = 3;
map.defeatMessage.appendTextID("core.lcdesc.0");
}
else
{
int lossCondition = ui->loseComboBox->currentIndex() - 1;
TriggeredEvent specialDefeat;
specialDefeat.effect.type = EventEffect::DEFEAT;
specialDefeat.identifier = "specialDefeat";
specialDefeat.description.clear(); // TODO: display in quest window
map.defeatIconIndex = lossCondition;
switch(lossCondition)
{
case 0: {
EventExpression::OperatorNone noneOf;
EventCondition cond(EventCondition::CONTROL);
cond.objectType = Obj::TOWN;
assert(loseTypeWidget);
int townIdx = loseTypeWidget->currentData().toInt();
cond.position = map.objects[townIdx]->pos;
noneOf.expressions.push_back(cond);
specialDefeat.onFulfill.appendTextID("core.genrltxt.251");
specialDefeat.trigger = EventExpression(noneOf);
map.defeatMessage.appendTextID("core.lcdesc.1");
break;
}
case 1: {
EventExpression::OperatorNone noneOf;
EventCondition cond(EventCondition::CONTROL);
cond.objectType = Obj::HERO;
assert(loseTypeWidget);
int townIdx = loseTypeWidget->currentData().toInt();
cond.position = map.objects[townIdx]->pos;
noneOf.expressions.push_back(cond);
specialDefeat.onFulfill.appendTextID("core.genrltxt.253");
specialDefeat.trigger = EventExpression(noneOf);
map.defeatMessage.appendTextID("core.lcdesc.2");
break;
}
case 2: {
EventCondition cond(EventCondition::DAYS_PASSED);
assert(loseValueWidget);
cond.value = expiredDate(loseValueWidget->text());
specialDefeat.onFulfill.appendTextID("core.genrltxt.254");
specialDefeat.trigger = EventExpression(cond);
map.defeatMessage.appendTextID("core.lcdesc.3");
break;
}
case 3: {
EventCondition cond(EventCondition::DAYS_WITHOUT_TOWN);
assert(loseValueWidget);
cond.value = loseValueWidget->text().toInt();
specialDefeat.onFulfill.appendTextID("core.genrltxt.7");
specialDefeat.trigger = EventExpression(cond);
break;
}
}
EventExpression::OperatorAll allOf;
EventCondition isHuman(EventCondition::IS_HUMAN);
isHuman.value = 1;
allOf.expressions.push_back(specialDefeat.trigger.get());
allOf.expressions.push_back(isHuman);
specialDefeat.trigger = EventExpression(allOf);
if(ui->standardLoseCheck->isChecked())
{
map.triggeredEvents.push_back(standardDefeat);
}
map.triggeredEvents.push_back(specialDefeat);
}
}
void LoseConditions::on_loseComboBox_currentIndexChanged(int index)
{
delete loseTypeWidget;
delete loseValueWidget;
delete loseSelectWidget;
loseTypeWidget = nullptr;
loseValueWidget = nullptr;
loseSelectWidget = nullptr;
if(index == 0)
{
ui->standardLoseCheck->setChecked(true);
ui->standardLoseCheck->setEnabled(false);
return;
}
ui->standardLoseCheck->setEnabled(true);
int loseCondition = index - 1;
switch(loseCondition)
{
case 0: { //EventCondition::CONTROL (Obj::TOWN)
loseTypeWidget = new QComboBox;
ui->loseParamsLayout->addWidget(loseTypeWidget);
for(int i : getObjectIndexes<const CGTownInstance>(*mapPointer))
loseTypeWidget->addItem(tr(getTownName(*mapPointer, i).c_str()), QVariant::fromValue(i));
break;
}
case 1: { //EventCondition::CONTROL (Obj::HERO)
loseTypeWidget = new QComboBox;
ui->loseParamsLayout->addWidget(loseTypeWidget);
for(int i : getObjectIndexes<const CGHeroInstance>(*mapPointer))
loseTypeWidget->addItem(tr(getHeroName(*mapPointer, i).c_str()), QVariant::fromValue(i));
break;
}
case 2: { //EventCondition::DAYS_PASSED
loseValueWidget = new QLineEdit;
ui->loseParamsLayout->addWidget(loseValueWidget);
loseValueWidget->setText("2m 1w 1d");
break;
}
case 3: { //EventCondition::DAYS_WITHOUT_TOWN
loseValueWidget = new QLineEdit;
ui->loseParamsLayout->addWidget(loseValueWidget);
loseValueWidget->setText("7");
break;
}
}
}

View File

@ -0,0 +1,42 @@
#ifndef LOSECONDITIONS_H
#define LOSECONDITIONS_H
/*
* loseconditions.h, 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
*
*/
#include "abstractsettings.h"
namespace Ui {
class LoseConditions;
}
class LoseConditions : public AbstractSettings
{
Q_OBJECT
public:
explicit LoseConditions(QWidget *parent = nullptr);
~LoseConditions();
void initialize(const CMap & map) override;
void update(CMap & map) override;
private slots:
void on_loseComboBox_currentIndexChanged(int index);
private:
Ui::LoseConditions *ui;
const CMap * mapPointer = nullptr;
QComboBox * loseTypeWidget = nullptr;
QComboBox * loseSelectWidget = nullptr;
QLineEdit * loseValueWidget = nullptr;
};
#endif // LOSECONDITIONS_H

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LoseConditions</class>
<widget class="QWidget" name="LoseConditions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>650</width>
<height>485</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Defeat message</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="defeatMessageEdit"/>
</item>
</layout>
</item>
<item>
<widget class="QComboBox" name="loseComboBox"/>
</item>
<item>
<widget class="QCheckBox" name="standardLoseCheck">
<property name="text">
<string>7 days without town</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="loseParams">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Parameters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<layout class="QVBoxLayout" name="loseParamsLayout"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,119 @@
/*
* mapsettings.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
*
*/
#include "StdInc.h"
#include "mapsettings.h"
#include "ui_mapsettings.h"
#include "mainwindow.h"
#include "../../lib/CSkillHandler.h"
#include "../../lib/spells/CSpellHandler.h"
#include "../../lib/CArtHandler.h"
#include "../../lib/CHeroHandler.h"
MapSettings::MapSettings(MapController & ctrl, QWidget *parent) :
QDialog(parent),
ui(new Ui::MapSettings),
controller(ctrl)
{
ui->setupUi(this);
assert(controller.map());
show();
for(int i = 0; i < controller.map()->allowedAbilities.size(); ++i)
{
auto * item = new QListWidgetItem(QString::fromStdString(VLC->skillh->objects[i]->getNameTranslated()));
item->setData(Qt::UserRole, QVariant::fromValue(i));
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(controller.map()->allowedAbilities[i] ? Qt::Checked : Qt::Unchecked);
ui->listAbilities->addItem(item);
}
for(int i = 0; i < controller.map()->allowedSpells.size(); ++i)
{
auto * item = new QListWidgetItem(QString::fromStdString(VLC->spellh->objects[i]->getNameTranslated()));
item->setData(Qt::UserRole, QVariant::fromValue(i));
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(controller.map()->allowedSpells[i] ? Qt::Checked : Qt::Unchecked);
ui->listSpells->addItem(item);
}
for(int i = 0; i < controller.map()->allowedArtifact.size(); ++i)
{
auto * item = new QListWidgetItem(QString::fromStdString(VLC->arth->objects[i]->getNameTranslated()));
item->setData(Qt::UserRole, QVariant::fromValue(i));
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(controller.map()->allowedArtifact[i] ? Qt::Checked : Qt::Unchecked);
ui->listArts->addItem(item);
}
for(int i = 0; i < controller.map()->allowedHeroes.size(); ++i)
{
auto * item = new QListWidgetItem(QString::fromStdString(VLC->heroh->objects[i]->getNameTranslated()));
item->setData(Qt::UserRole, QVariant::fromValue(i));
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(controller.map()->allowedHeroes[i] ? Qt::Checked : Qt::Unchecked);
ui->listHeroes->addItem(item);
}
ui->general->initialize(*controller.map());
ui->mods->initialize(*controller.map());
ui->victory->initialize(*controller.map());
ui->lose->initialize(*controller.map());
//timed events
for(auto & ev : controller.map()->events)
{
QVariantMap descriptor;
descriptor["message"] = QVariant::fromValue(QString::fromStdString(ev.message));
descriptor["players"] = QVariant::fromValue(ev.players);
descriptor["humanAffected"] = QVariant::fromValue(ev.humanAffected);
descriptor["computerAffected"] = QVariant::fromValue(ev.computerAffected);
descriptor["firstOccurence"] = QVariant::fromValue(ev.firstOccurence);
descriptor["nextOccurence"] = QVariant::fromValue(ev.nextOccurence);
auto * item = new QListWidgetItem(QString::fromStdString(ev.name));
item->setData(Qt::UserRole, descriptor);
ui->eventsList->addItem(item);
}
}
MapSettings::~MapSettings()
{
delete ui;
}
void MapSettings::on_pushButton_clicked()
{
auto updateMapArray = [](const QListWidget * widget, std::vector<bool> & arr)
{
for(int i = 0; i < arr.size(); ++i)
{
auto * item = widget->item(i);
arr[i] = item->checkState() == Qt::Checked;
}
};
updateMapArray(ui->listAbilities, controller.map()->allowedAbilities);
updateMapArray(ui->listSpells, controller.map()->allowedSpells);
updateMapArray(ui->listArts, controller.map()->allowedArtifact);
updateMapArray(ui->listHeroes, controller.map()->allowedHeroes);
controller.map()->triggeredEvents.clear();
ui->general->update(*controller.map());
ui->mods->update(*controller.map());
ui->victory->update(*controller.map());
ui->lose->update(*controller.map());
controller.commitChangeWithoutRedraw();
close();
}

View File

@ -0,0 +1,36 @@
/*
* mapsettings.h, 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
*
*/
#pragma once
#include <QDialog>
#include "mapcontroller.h"
#include "../lib/mapping/CMap.h"
namespace Ui {
class MapSettings;
}
class MapSettings : public QDialog
{
Q_OBJECT
public:
explicit MapSettings(MapController & controller, QWidget *parent = nullptr);
~MapSettings();
private slots:
void on_pushButton_clicked();
private:
Ui::MapSettings *ui;
MapController & controller;
};

View File

@ -0,0 +1,362 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MapSettings</class>
<widget class="QDialog" name="MapSettings">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>543</width>
<height>494</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Map settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="GeneralSettings" name="general" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_9">
<attribute name="title">
<string>Mods</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="leftMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="ModSettings" name="mods" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>Events</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_7">
<attribute name="title">
<string>Victory</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="leftMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="VictoryConditions" name="victory" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_8">
<attribute name="title">
<string>Loss</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="leftMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="LoseConditions" name="lose" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_10">
<attribute name="title">
<string>Timed</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_15">
<property name="leftMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Timed events</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="timedEventAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="timedEventRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="eventsList"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Abilities</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="QListWidget" name="listAbilities">
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="batchSize">
<number>30</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Spells</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="QListWidget" name="listSpells">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="batchSize">
<number>30</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Artifacts</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="QListWidget" name="listArts">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="batchSize">
<number>30</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Heroes</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="QListWidget" name="listHeroes">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="batchSize">
<number>30</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GeneralSettings</class>
<extends>QWidget</extends>
<header>mapsettings/generalsettings.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ModSettings</class>
<extends>QWidget</extends>
<header>mapsettings/modsettings.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>VictoryConditions</class>
<extends>QWidget</extends>
<header>mapsettings/victoryconditions.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LoseConditions</class>
<extends>QWidget</extends>
<header>mapsettings/loseconditions.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,154 @@
#include "StdInc.h"
#include "modsettings.h"
#include "ui_modsettings.h"
#include "../mapcontroller.h"
#include "../../lib/modding/CModHandler.h"
#include "../../lib/mapping/CMapService.h"
#include "../../lib/modding/CModInfo.h"
void traverseNode(QTreeWidgetItem * item, std::function<void(QTreeWidgetItem*)> action)
{
// Do something with item
action(item);
for (int i = 0; i < item->childCount(); ++i)
traverseNode(item->child(i), action);
}
ModSettings::ModSettings(QWidget *parent) :
AbstractSettings(parent),
ui(new Ui::ModSettings)
{
ui->setupUi(this);
}
ModSettings::~ModSettings()
{
delete ui;
}
void ModSettings::initialize(const CMap & map)
{
mapPointer = &map;
//mods management
//collect all active mods
QMap<QString, QTreeWidgetItem*> addedMods;
QSet<QString> modsToProcess;
ui->treeMods->blockSignals(true);
auto createModTreeWidgetItem = [&](QTreeWidgetItem * parent, const CModInfo & modInfo)
{
auto item = new QTreeWidgetItem(parent, {QString::fromStdString(modInfo.name), QString::fromStdString(modInfo.version.toString())});
item->setData(0, Qt::UserRole, QVariant(QString::fromStdString(modInfo.identifier)));
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(0, map.mods.count(modInfo.identifier) ? Qt::Checked : Qt::Unchecked);
//set parent check
if(parent && item->checkState(0) == Qt::Checked)
parent->setCheckState(0, Qt::Checked);
return item;
};
for(const auto & modName : VLC->modh->getActiveMods())
{
QString qmodName = QString::fromStdString(modName);
if(qmodName.split(".").size() == 1)
{
const auto & modInfo = VLC->modh->getModInfo(modName);
addedMods[qmodName] = createModTreeWidgetItem(nullptr, modInfo);
ui->treeMods->addTopLevelItem(addedMods[qmodName]);
}
else
{
modsToProcess.insert(qmodName);
}
}
for(auto qmodIter = modsToProcess.begin(); qmodIter != modsToProcess.end();)
{
auto qmodName = *qmodIter;
auto pieces = qmodName.split(".");
assert(pieces.size() > 1);
QString qs;
for(int i = 0; i < pieces.size() - 1; ++i)
qs += pieces[i];
if(addedMods.count(qs))
{
const auto & modInfo = VLC->modh->getModInfo(qmodName.toStdString());
addedMods[qmodName] = createModTreeWidgetItem(addedMods[qs], modInfo);
modsToProcess.erase(qmodIter);
qmodIter = modsToProcess.begin();
}
else
++qmodIter;
}
ui->treeMods->blockSignals(false);
}
void ModSettings::update(CMap & map)
{
//Mod management
auto widgetAction = [&](QTreeWidgetItem * item)
{
if(item->checkState(0) == Qt::Checked)
{
auto modName = item->data(0, Qt::UserRole).toString().toStdString();
map.mods[modName] = VLC->modh->getModInfo(modName).version;
}
};
map.mods.clear();
for (int i = 0; i < ui->treeMods->topLevelItemCount(); ++i)
{
QTreeWidgetItem *item = ui->treeMods->topLevelItem(i);
traverseNode(item, widgetAction);
}
}
void ModSettings::updateModWidgetBasedOnMods(const ModCompatibilityInfo & mods)
{
//Mod management
auto widgetAction = [&](QTreeWidgetItem * item)
{
auto modName = item->data(0, Qt::UserRole).toString().toStdString();
item->setCheckState(0, mods.count(modName) ? Qt::Checked : Qt::Unchecked);
};
for (int i = 0; i < ui->treeMods->topLevelItemCount(); ++i)
{
QTreeWidgetItem *item = ui->treeMods->topLevelItem(i);
traverseNode(item, widgetAction);
}
}
void ModSettings::on_modResolution_map_clicked()
{
updateModWidgetBasedOnMods(MapController::modAssessmentMap(*mapPointer));
}
void ModSettings::on_modResolution_full_clicked()
{
updateModWidgetBasedOnMods(MapController::modAssessmentAll());
}
void ModSettings::on_treeMods_itemChanged(QTreeWidgetItem *item, int column)
{
//set state for children
for (int i = 0; i < item->childCount(); ++i)
item->child(i)->setCheckState(0, item->checkState(0));
//set state for parent
ui->treeMods->blockSignals(true);
if(item->checkState(0) == Qt::Checked)
{
while(item->parent())
{
item->parent()->setCheckState(0, Qt::Checked);
item = item->parent();
}
}
ui->treeMods->blockSignals(false);
}

View File

@ -0,0 +1,36 @@
#ifndef MODSETTINGS_H
#define MODSETTINGS_H
#include "abstractsettings.h"
namespace Ui {
class ModSettings;
}
class ModSettings : public AbstractSettings
{
Q_OBJECT
public:
explicit ModSettings(QWidget *parent = nullptr);
~ModSettings();
void initialize(const CMap & map) override;
void update(CMap & map) override;
private slots:
void on_modResolution_map_clicked();
void on_modResolution_full_clicked();
void on_treeMods_itemChanged(QTreeWidgetItem *item, int column);
private:
void updateModWidgetBasedOnMods(const ModCompatibilityInfo & mods);
private:
Ui::ModSettings *ui;
const CMap * mapPointer = nullptr;
};
#endif // MODSETTINGS_H

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ModSettings</class>
<widget class="QWidget" name="ModSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>599</width>
<height>451</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Mandatory mods to play this map</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="treeMods">
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<attribute name="headerDefaultSectionSize">
<number>320</number>
</attribute>
<column>
<property name="text">
<string>Mod name</string>
</property>
</column>
<column>
<property name="text">
<string>Version</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Automatic assignment</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modResolution_map">
<property name="toolTip">
<string>Set required mods based on objects placed on the map. This method may cause problems if you have customized rewards, garrisons, etc from mods</string>
</property>
<property name="text">
<string>Map objects mods</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modResolution_full">
<property name="toolTip">
<string>Set all mods having a game content as mandatory</string>
</property>
<property name="text">
<string>Full content mods</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,426 @@
#include "StdInc.h"
#include "victoryconditions.h"
#include "ui_victoryconditions.h"
#include "../lib/CGeneralTextHandler.h"
#include "../lib/constants/StringConstants.h"
#include "../inspector/townbulidingswidget.h" //to convert BuildingID to string
VictoryConditions::VictoryConditions(QWidget *parent) :
AbstractSettings(parent),
ui(new Ui::VictoryConditions)
{
ui->setupUi(this);
}
void VictoryConditions::initialize(const CMap & map)
{
mapPointer = &map;
//victory message
ui->victoryMessageEdit->setText(QString::fromStdString(map.victoryMessage.toString()));
//victory conditions
const std::array<std::string, 8> conditionStringsWin = {
QT_TR_NOOP("No special victory"),
QT_TR_NOOP("Capture artifact"),
QT_TR_NOOP("Hire creatures"),
QT_TR_NOOP("Accumulate resources"),
QT_TR_NOOP("Construct building"),
QT_TR_NOOP("Capture town"),
QT_TR_NOOP("Defeat hero"),
QT_TR_NOOP("Transport artifact")
};
for(auto & s : conditionStringsWin)
{
ui->victoryComboBox->addItem(QString::fromStdString(s));
}
ui->standardVictoryCheck->setChecked(false);
ui->onlyForHumansCheck->setChecked(false);
for(auto & ev : map.triggeredEvents)
{
if(ev.effect.type == EventEffect::VICTORY)
{
if(ev.identifier == "standardVictory")
ui->standardVictoryCheck->setChecked(true);
if(ev.identifier == "specialVictory")
{
auto readjson = ev.trigger.toJson(AbstractSettings::conditionToJson);
auto linearNodes = linearJsonArray(readjson);
for(auto & json : linearNodes)
{
switch(json["condition"].Integer())
{
case EventCondition::HAVE_ARTIFACT: {
ui->victoryComboBox->setCurrentIndex(1);
assert(victoryTypeWidget);
victoryTypeWidget->setCurrentIndex(json["objectType"].Integer());
break;
}
case EventCondition::HAVE_CREATURES: {
ui->victoryComboBox->setCurrentIndex(2);
assert(victoryTypeWidget);
assert(victoryValueWidget);
auto idx = victoryTypeWidget->findData(int(json["objectType"].Integer()));
victoryTypeWidget->setCurrentIndex(idx);
victoryValueWidget->setText(QString::number(json["value"].Integer()));
break;
}
case EventCondition::HAVE_RESOURCES: {
ui->victoryComboBox->setCurrentIndex(3);
assert(victoryTypeWidget);
assert(victoryValueWidget);
auto idx = victoryTypeWidget->findData(int(json["objectType"].Integer()));
victoryTypeWidget->setCurrentIndex(idx);
victoryValueWidget->setText(QString::number(json["value"].Integer()));
break;
}
case EventCondition::HAVE_BUILDING: {
ui->victoryComboBox->setCurrentIndex(4);
assert(victoryTypeWidget);
assert(victorySelectWidget);
auto idx = victoryTypeWidget->findData(int(json["objectType"].Integer()));
victoryTypeWidget->setCurrentIndex(idx);
int townIdx = getObjectByPos<const CGTownInstance>(*mapPointer, posFromJson(json["position"]));
if(townIdx >= 0)
{
auto idx = victorySelectWidget->findData(townIdx);
victorySelectWidget->setCurrentIndex(idx);
}
break;
}
case EventCondition::CONTROL: {
ui->victoryComboBox->setCurrentIndex(5);
assert(victoryTypeWidget);
if(json["objectType"].Integer() == Obj::TOWN)
{
int townIdx = getObjectByPos<const CGTownInstance>(*mapPointer, posFromJson(json["position"]));
if(townIdx >= 0)
{
auto idx = victoryTypeWidget->findData(townIdx);
victoryTypeWidget->setCurrentIndex(idx);
}
}
//TODO: support control other objects (dwellings, mines)
break;
}
case EventCondition::DESTROY: {
ui->victoryComboBox->setCurrentIndex(6);
assert(victoryTypeWidget);
if(json["objectType"].Integer() == Obj::HERO)
{
int heroIdx = getObjectByPos<const CGHeroInstance>(*mapPointer, posFromJson(json["position"]));
if(heroIdx >= 0)
{
auto idx = victoryTypeWidget->findData(heroIdx);
victoryTypeWidget->setCurrentIndex(idx);
}
}
//TODO: support control other objects (monsters)
break;
}
case EventCondition::TRANSPORT: {
ui->victoryComboBox->setCurrentIndex(7);
assert(victoryTypeWidget);
assert(victorySelectWidget);
victoryTypeWidget->setCurrentIndex(json["objectType"].Integer());
int townIdx = getObjectByPos<const CGTownInstance>(*mapPointer, posFromJson(json["position"]));
if(townIdx >= 0)
{
auto idx = victorySelectWidget->findData(townIdx);
victorySelectWidget->setCurrentIndex(idx);
}
break;
}
case EventCondition::IS_HUMAN: {
ui->onlyForHumansCheck->setChecked(true);
break;
}
};
}
}
}
}
}
void VictoryConditions::update(CMap & map)
{
//victory messages
map.victoryMessage = MetaString::createFromRawString(ui->victoryMessageEdit->text().toStdString());
//victory conditions
EventCondition victoryCondition(EventCondition::STANDARD_WIN);
//Victory condition - defeat all
TriggeredEvent standardVictory;
standardVictory.effect.type = EventEffect::VICTORY;
standardVictory.effect.toOtherMessage.appendTextID("core.genrltxt.5");
standardVictory.identifier = "standardVictory";
standardVictory.description.clear(); // TODO: display in quest window
standardVictory.onFulfill.appendTextID("core.genrltxt.659");
standardVictory.trigger = EventExpression(victoryCondition);
//VICTORY
if(ui->victoryComboBox->currentIndex() == 0)
{
map.triggeredEvents.push_back(standardVictory);
map.victoryIconIndex = 11;
map.victoryMessage.appendTextID(VLC->generaltexth->victoryConditions[0]);
}
else
{
int vicCondition = ui->victoryComboBox->currentIndex() - 1;
TriggeredEvent specialVictory;
specialVictory.effect.type = EventEffect::VICTORY;
specialVictory.identifier = "specialVictory";
specialVictory.description.clear(); // TODO: display in quest window
map.victoryIconIndex = vicCondition;
map.victoryMessage.appendTextID(VLC->generaltexth->victoryConditions[size_t(vicCondition) + 1]);
switch(vicCondition)
{
case 0: {
EventCondition cond(EventCondition::HAVE_ARTIFACT);
assert(victoryTypeWidget);
cond.objectType = victoryTypeWidget->currentData().toInt();
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.281");
specialVictory.onFulfill.appendTextID("core.genrltxt.280");
specialVictory.trigger = EventExpression(cond);
break;
}
case 1: {
EventCondition cond(EventCondition::HAVE_CREATURES);
assert(victoryTypeWidget);
cond.objectType = victoryTypeWidget->currentData().toInt();
cond.value = victoryValueWidget->text().toInt();
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.277");
specialVictory.onFulfill.appendTextID("core.genrltxt.276");
specialVictory.trigger = EventExpression(cond);
break;
}
case 2: {
EventCondition cond(EventCondition::HAVE_RESOURCES);
assert(victoryTypeWidget);
cond.objectType = victoryTypeWidget->currentData().toInt();
cond.value = victoryValueWidget->text().toInt();
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.279");
specialVictory.onFulfill.appendTextID("core.genrltxt.278");
specialVictory.trigger = EventExpression(cond);
break;
}
case 3: {
EventCondition cond(EventCondition::HAVE_BUILDING);
assert(victoryTypeWidget);
cond.objectType = victoryTypeWidget->currentData().toInt();
int townIdx = victorySelectWidget->currentData().toInt();
if(townIdx > -1)
cond.position = map.objects[townIdx]->pos;
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.283");
specialVictory.onFulfill.appendTextID("core.genrltxt.282");
specialVictory.trigger = EventExpression(cond);
break;
}
case 4: {
EventCondition cond(EventCondition::CONTROL);
assert(victoryTypeWidget);
cond.objectType = Obj::TOWN;
int townIdx = victoryTypeWidget->currentData().toInt();
cond.position = map.objects[townIdx]->pos;
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.250");
specialVictory.onFulfill.appendTextID("core.genrltxt.249");
specialVictory.trigger = EventExpression(cond);
break;
}
case 5: {
EventCondition cond(EventCondition::DESTROY);
assert(victoryTypeWidget);
cond.objectType = Obj::HERO;
int heroIdx = victoryTypeWidget->currentData().toInt();
cond.position = map.objects[heroIdx]->pos;
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.253");
specialVictory.onFulfill.appendTextID("core.genrltxt.252");
specialVictory.trigger = EventExpression(cond);
break;
}
case 6: {
EventCondition cond(EventCondition::TRANSPORT);
assert(victoryTypeWidget);
cond.objectType = victoryTypeWidget->currentData().toInt();
int townIdx = victorySelectWidget->currentData().toInt();
if(townIdx > -1)
cond.position = map.objects[townIdx]->pos;
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.293");
specialVictory.onFulfill.appendTextID("core.genrltxt.292");
specialVictory.trigger = EventExpression(cond);
break;
}
}
// if condition is human-only turn it into following construction: AllOf(human, condition)
if(ui->onlyForHumansCheck->isChecked())
{
EventExpression::OperatorAll oper;
EventCondition notAI(EventCondition::IS_HUMAN);
notAI.value = 1;
oper.expressions.push_back(notAI);
oper.expressions.push_back(specialVictory.trigger.get());
specialVictory.trigger = EventExpression(oper);
}
// if normal victory allowed - add one more quest
if(ui->standardVictoryCheck->isChecked())
{
map.victoryMessage.appendRawString(" / ");
map.victoryMessage.appendTextID(VLC->generaltexth->victoryConditions[0]);
map.triggeredEvents.push_back(standardVictory);
}
map.triggeredEvents.push_back(specialVictory);
}
}
VictoryConditions::~VictoryConditions()
{
delete ui;
}
void VictoryConditions::on_victoryComboBox_currentIndexChanged(int index)
{
delete victoryTypeWidget;
delete victoryValueWidget;
delete victorySelectWidget;
victoryTypeWidget = nullptr;
victoryValueWidget = nullptr;
victorySelectWidget = nullptr;
if(index == 0)
{
ui->standardVictoryCheck->setChecked(true);
ui->standardVictoryCheck->setEnabled(false);
ui->onlyForHumansCheck->setChecked(false);
ui->onlyForHumansCheck->setEnabled(false);
return;
}
ui->onlyForHumansCheck->setEnabled(true);
ui->standardVictoryCheck->setEnabled(true);
int vicCondition = index - 1;
switch(vicCondition)
{
case 0: { //EventCondition::HAVE_ARTIFACT
victoryTypeWidget = new QComboBox;
ui->victoryParamsLayout->addWidget(victoryTypeWidget);
for(int i = 0; i < mapPointer->allowedArtifact.size(); ++i)
victoryTypeWidget->addItem(QString::fromStdString(VLC->arth->objects[i]->getNameTranslated()), QVariant::fromValue(i));
break;
}
case 1: { //EventCondition::HAVE_CREATURES
victoryTypeWidget = new QComboBox;
ui->victoryParamsLayout->addWidget(victoryTypeWidget);
for(int i = 0; i < VLC->creh->objects.size(); ++i)
victoryTypeWidget->addItem(QString::fromStdString(VLC->creh->objects[i]->getNamePluralTranslated()), QVariant::fromValue(i));
victoryValueWidget = new QLineEdit;
ui->victoryParamsLayout->addWidget(victoryValueWidget);
victoryValueWidget->setText("1");
break;
}
case 2: { //EventCondition::HAVE_RESOURCES
victoryTypeWidget = new QComboBox;
ui->victoryParamsLayout->addWidget(victoryTypeWidget);
{
for(int resType = 0; resType < GameConstants::RESOURCE_QUANTITY; ++resType)
{
auto resName = QString::fromStdString(GameConstants::RESOURCE_NAMES[resType]);
victoryTypeWidget->addItem(resName, QVariant::fromValue(resType));
}
}
victoryValueWidget = new QLineEdit;
ui->victoryParamsLayout->addWidget(victoryValueWidget);
victoryValueWidget->setText("1");
break;
}
case 3: { //EventCondition::HAVE_BUILDING
victoryTypeWidget = new QComboBox;
ui->victoryParamsLayout->addWidget(victoryTypeWidget);
auto * ctown = VLC->townh->randomTown;
for(int bId : ctown->getAllBuildings())
victoryTypeWidget->addItem(QString::fromStdString(defaultBuildingIdConversion(BuildingID(bId))), QVariant::fromValue(bId));
victorySelectWidget = new QComboBox;
ui->victoryParamsLayout->addWidget(victorySelectWidget);
victorySelectWidget->addItem("Any town", QVariant::fromValue(-1));
for(int i : getObjectIndexes<const CGTownInstance>(*mapPointer))
victorySelectWidget->addItem(getTownName(*mapPointer, i).c_str(), QVariant::fromValue(i));
break;
}
case 4: { //EventCondition::CONTROL (Obj::TOWN)
victoryTypeWidget = new QComboBox;
ui->victoryParamsLayout->addWidget(victoryTypeWidget);
for(int i : getObjectIndexes<const CGTownInstance>(*mapPointer))
victoryTypeWidget->addItem(tr(getTownName(*mapPointer, i).c_str()), QVariant::fromValue(i));
break;
}
case 5: { //EventCondition::DESTROY (Obj::HERO)
victoryTypeWidget = new QComboBox;
ui->victoryParamsLayout->addWidget(victoryTypeWidget);
for(int i : getObjectIndexes<const CGHeroInstance>(*mapPointer))
victoryTypeWidget->addItem(tr(getHeroName(*mapPointer, i).c_str()), QVariant::fromValue(i));
break;
}
case 6: { //EventCondition::TRANSPORT (Obj::ARTEFACT)
victoryTypeWidget = new QComboBox;
ui->victoryParamsLayout->addWidget(victoryTypeWidget);
for(int i = 0; i < mapPointer->allowedArtifact.size(); ++i)
victoryTypeWidget->addItem(QString::fromStdString(VLC->arth->objects[i]->getNameTranslated()), QVariant::fromValue(i));
victorySelectWidget = new QComboBox;
ui->victoryParamsLayout->addWidget(victorySelectWidget);
for(int i : getObjectIndexes<const CGTownInstance>(*mapPointer))
victorySelectWidget->addItem(tr(getTownName(*mapPointer, i).c_str()), QVariant::fromValue(i));
break;
}
//TODO: support this vectory type
// in order to do that, need to implement finding creature by position
// selecting from map would be the best user experience
/*case 7: { //EventCondition::DESTROY (Obj::MONSTER)
victoryTypeWidget = new QComboBox;
ui->loseParamsLayout->addWidget(victoryTypeWidget);
for(int i : getObjectIndexes<const CGCreature>(*mapPointer))
victoryTypeWidget->addItem(tr(getMonsterName(i).c_str()), QVariant::fromValue(i));
break;
}*/
}
}

View File

@ -0,0 +1,33 @@
#ifndef VICTORYCONDITIONS_H
#define VICTORYCONDITIONS_H
#include "abstractsettings.h"
namespace Ui {
class VictoryConditions;
}
class VictoryConditions : public AbstractSettings
{
Q_OBJECT
public:
explicit VictoryConditions(QWidget *parent = nullptr);
~VictoryConditions();
void initialize(const CMap & map) override;
void update(CMap & map) override;
private slots:
void on_victoryComboBox_currentIndexChanged(int index);
private:
Ui::VictoryConditions *ui;
const CMap * mapPointer = nullptr;
QComboBox * victoryTypeWidget = nullptr;
QComboBox * victorySelectWidget = nullptr;
QLineEdit * victoryValueWidget = nullptr;
};
#endif // VICTORYCONDITIONS_H

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VictoryConditions</class>
<widget class="QWidget" name="VictoryConditions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>622</width>
<height>503</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Victory message</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="victoryMessageEdit"/>
</item>
</layout>
</item>
<item>
<widget class="QComboBox" name="victoryComboBox"/>
</item>
<item>
<widget class="QCheckBox" name="onlyForHumansCheck">
<property name="text">
<string>Only for human players</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="standardVictoryCheck">
<property name="text">
<string>Allow standard victory</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="victoryParams">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Parameters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="topMargin">
<number>12</number>
</property>
<item>
<layout class="QVBoxLayout" name="victoryParamsLayout"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

26
mapeditor/timedevent.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "timedevent.h"
#include "ui_timedevent.h"
TimedEvent::TimedEvent(QWidget *parent) :
QDialog(parent),
ui(new Ui::TimedEvent)
{
ui->setupUi(this);
}
TimedEvent::~TimedEvent()
{
delete ui;
}
void TimedEvent::on_eventResources_clicked()
{
}
void TimedEvent::on_TimedEvent_finished(int result)
{
}

27
mapeditor/timedevent.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef TIMEDEVENT_H
#define TIMEDEVENT_H
#include <QDialog>
namespace Ui {
class TimedEvent;
}
class TimedEvent : public QDialog
{
Q_OBJECT
public:
explicit TimedEvent(QWidget *parent = nullptr);
~TimedEvent();
private slots:
void on_eventResources_clicked();
void on_TimedEvent_finished(int result);
private:
Ui::TimedEvent *ui;
};
#endif // TIMEDEVENT_H

134
mapeditor/timedevent.ui Normal file
View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TimedEvent</class>
<widget class="QDialog" name="TimedEvent">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>620</width>
<height>371</height>
</rect>
</property>
<property name="windowTitle">
<string>Timed event</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="placeholderText">
<string>Event name</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="eventMessageText">
<property name="placeholderText">
<string>Type event message text</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="eventAffectsHuman">
<property name="text">
<string>affects human</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="eventAffectsCpu">
<property name="text">
<string>affects AI</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="topMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Day of first occurance</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="eventFirstOccurance"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_13">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Repeat after (0 = no repeat)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="eventRepeatAfter"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_18">
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QListWidget" name="listWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="eventResources">
<property name="text">
<string>Resources</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>