mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Merge pull request #2782 from Nordsoft91/editor-improvements-1.4
Map editor: events, rumors
This commit is contained in:
@@ -56,9 +56,37 @@ bool CMapEvent::earlierThanOrEqual(const CMapEvent & other) const
|
||||
return firstOccurence <= other.firstOccurence;
|
||||
}
|
||||
|
||||
CCastleEvent::CCastleEvent() : town(nullptr)
|
||||
void CMapEvent::serializeJson(JsonSerializeFormat & handler)
|
||||
{
|
||||
handler.serializeString("name", name);
|
||||
handler.serializeString("message", message);
|
||||
handler.serializeInt("players", players);
|
||||
handler.serializeInt("humanAffected", humanAffected);
|
||||
handler.serializeInt("computerAffected", computerAffected);
|
||||
handler.serializeInt("firstOccurence", firstOccurence);
|
||||
handler.serializeInt("nextOccurence", nextOccurence);
|
||||
resources.serializeJson(handler, "resources");
|
||||
}
|
||||
|
||||
void CCastleEvent::serializeJson(JsonSerializeFormat & handler)
|
||||
{
|
||||
CMapEvent::serializeJson(handler);
|
||||
{
|
||||
std::vector<BuildingID> temp(buildings.begin(), buildings.end());
|
||||
auto a = handler.enterArray("buildings");
|
||||
a.syncSize(temp);
|
||||
for(int i = 0; i < temp.size(); ++i)
|
||||
{
|
||||
a.serializeInt(i, temp[i]);
|
||||
buildings.insert(temp[i]);
|
||||
}
|
||||
}
|
||||
{
|
||||
auto a = handler.enterArray("creatures");
|
||||
a.syncSize(creatures);
|
||||
for(int i = 0; i < creatures.size(); ++i)
|
||||
a.serializeInt(i, creatures[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TerrainTile::TerrainTile():
|
||||
|
@@ -19,6 +19,7 @@ class RiverType;
|
||||
class RoadType;
|
||||
class CGObjectInstance;
|
||||
class CGTownInstance;
|
||||
class JsonSerializeFormat;
|
||||
|
||||
/// The map event is an event which e.g. gives or takes resources of a specific
|
||||
/// amount to/from players and can appear regularly or once a time.
|
||||
@@ -26,6 +27,7 @@ class DLL_LINKAGE CMapEvent
|
||||
{
|
||||
public:
|
||||
CMapEvent();
|
||||
virtual ~CMapEvent() = default;
|
||||
|
||||
bool earlierThan(const CMapEvent & other) const;
|
||||
bool earlierThanOrEqual(const CMapEvent & other) const;
|
||||
@@ -51,17 +53,18 @@ public:
|
||||
h & firstOccurence;
|
||||
h & nextOccurence;
|
||||
}
|
||||
|
||||
virtual void serializeJson(JsonSerializeFormat & handler);
|
||||
};
|
||||
|
||||
/// The castle event builds/adds buildings/creatures for a specific town.
|
||||
class DLL_LINKAGE CCastleEvent: public CMapEvent
|
||||
{
|
||||
public:
|
||||
CCastleEvent();
|
||||
CCastleEvent() = default;
|
||||
|
||||
std::set<BuildingID> buildings;
|
||||
std::vector<si32> creatures;
|
||||
CGTownInstance * town;
|
||||
|
||||
template <typename Handler>
|
||||
void serialize(Handler & h, const int version)
|
||||
@@ -70,6 +73,8 @@ public:
|
||||
h & buildings;
|
||||
h & creatures;
|
||||
}
|
||||
|
||||
void serializeJson(JsonSerializeFormat & handler) override;
|
||||
};
|
||||
|
||||
/// The terrain tile describes the terrain type and the visual representation of the terrain.
|
||||
|
@@ -2097,7 +2097,6 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
|
||||
for(int eventID = 0; eventID < eventsCount; ++eventID)
|
||||
{
|
||||
CCastleEvent event;
|
||||
event.town = object;
|
||||
event.name = readBasicString();
|
||||
event.message = readLocalizedString(TextIdentifier("town", position.x, position.y, position.z, "event", eventID, "description"));
|
||||
|
||||
|
@@ -342,7 +342,7 @@ namespace TerrainDetail
|
||||
|
||||
///CMapFormatJson
|
||||
const int CMapFormatJson::VERSION_MAJOR = 1;
|
||||
const int CMapFormatJson::VERSION_MINOR = 1;
|
||||
const int CMapFormatJson::VERSION_MINOR = 2;
|
||||
|
||||
const std::string CMapFormatJson::HEADER_FILE_NAME = "header.json";
|
||||
const std::string CMapFormatJson::OBJECTS_FILE_NAME = "objects.json";
|
||||
@@ -775,6 +775,14 @@ void CMapFormatJson::serializeRumors(JsonSerializeFormat & handler)
|
||||
rumors.serializeStruct(map->rumors);
|
||||
}
|
||||
|
||||
void CMapFormatJson::serializeTimedEvents(JsonSerializeFormat & handler)
|
||||
{
|
||||
auto events = handler.enterArray("events");
|
||||
std::vector<CMapEvent> temp(map->events.begin(), map->events.end());
|
||||
events.serializeStruct(temp);
|
||||
map->events.assign(temp.begin(), temp.end());
|
||||
}
|
||||
|
||||
void CMapFormatJson::serializePredefinedHeroes(JsonSerializeFormat & handler)
|
||||
{
|
||||
//todo:serializePredefinedHeroes
|
||||
@@ -816,6 +824,8 @@ void CMapFormatJson::serializePredefinedHeroes(JsonSerializeFormat & handler)
|
||||
void CMapFormatJson::serializeOptions(JsonSerializeFormat & handler)
|
||||
{
|
||||
serializeRumors(handler);
|
||||
|
||||
serializeTimedEvents(handler);
|
||||
|
||||
serializePredefinedHeroes(handler);
|
||||
|
||||
|
@@ -109,6 +109,8 @@ protected:
|
||||
void serializePredefinedHeroes(JsonSerializeFormat & handler);
|
||||
|
||||
void serializeRumors(JsonSerializeFormat & handler);
|
||||
|
||||
void serializeTimedEvents(JsonSerializeFormat & handler);
|
||||
|
||||
///common part of map attributes saving/loading
|
||||
void serializeOptions(JsonSerializeFormat & handler);
|
||||
|
@@ -12,7 +12,15 @@ set(editor_SRCS
|
||||
generatorprogress.cpp
|
||||
mapview.cpp
|
||||
objectbrowser.cpp
|
||||
mapsettings.cpp
|
||||
mapsettings/abstractsettings.cpp
|
||||
mapsettings/mapsettings.cpp
|
||||
mapsettings/generalsettings.cpp
|
||||
mapsettings/modsettings.cpp
|
||||
mapsettings/timedevent.cpp
|
||||
mapsettings/victoryconditions.cpp
|
||||
mapsettings/loseconditions.cpp
|
||||
mapsettings/eventsettings.cpp
|
||||
mapsettings/rumorsettings.cpp
|
||||
playersettings.cpp
|
||||
playerparams.cpp
|
||||
scenelayer.cpp
|
||||
@@ -40,7 +48,15 @@ set(editor_HEADERS
|
||||
generatorprogress.h
|
||||
mapview.h
|
||||
objectbrowser.h
|
||||
mapsettings.h
|
||||
mapsettings/abstractsettings.h
|
||||
mapsettings/mapsettings.h
|
||||
mapsettings/generalsettings.h
|
||||
mapsettings/modsettings.h
|
||||
mapsettings/timedevent.h
|
||||
mapsettings/victoryconditions.h
|
||||
mapsettings/loseconditions.h
|
||||
mapsettings/eventsettings.h
|
||||
mapsettings/rumorsettings.h
|
||||
playersettings.h
|
||||
playerparams.h
|
||||
scenelayer.h
|
||||
@@ -59,7 +75,14 @@ set(editor_FORMS
|
||||
mainwindow.ui
|
||||
windownewmap.ui
|
||||
generatorprogress.ui
|
||||
mapsettings.ui
|
||||
mapsettings/mapsettings.ui
|
||||
mapsettings/generalsettings.ui
|
||||
mapsettings/modsettings.ui
|
||||
mapsettings/timedevent.ui
|
||||
mapsettings/victoryconditions.ui
|
||||
mapsettings/loseconditions.ui
|
||||
mapsettings/eventsettings.ui
|
||||
mapsettings/rumorsettings.ui
|
||||
playersettings.ui
|
||||
playerparams.ui
|
||||
validator.ui
|
||||
|
@@ -172,7 +172,7 @@ void Initializer::initialize(CGArtifact * o)
|
||||
std::vector<SpellID> out;
|
||||
for(auto spell : VLC->spellh->objects) //spellh size appears to be greater (?)
|
||||
{
|
||||
//if(map->isAllowedSpell(spell->id))
|
||||
if(VLC->spellh->getDefaultAllowed().at(spell->id))
|
||||
{
|
||||
out.push_back(spell->id);
|
||||
}
|
||||
@@ -189,8 +189,8 @@ void Initializer::initialize(CGMine * o)
|
||||
o->tempOwner = defaultPlayer;
|
||||
if(o->isAbandoned())
|
||||
{
|
||||
for(auto r = 0; r < GameConstants::RESOURCE_QUANTITY - 1; ++r)
|
||||
o->abandonedMineResources.insert(GameResID(r));
|
||||
for(auto r = GameResID(0); r < GameResID::COUNT; ++r)
|
||||
o->abandonedMineResources.insert(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -300,10 +300,10 @@ void Inspector::updateProperties(CGArtifact * o)
|
||||
auto * delegate = new InspectorDelegate;
|
||||
for(auto spell : VLC->spellh->objects)
|
||||
{
|
||||
//if(map->isAllowedSpell(spell->id))
|
||||
delegate->options << QObject::tr(spell->getJsonKey().c_str());
|
||||
if(map->allowedSpells.at(spell->id))
|
||||
delegate->options << QObject::tr(spell->getNameTranslated().c_str());
|
||||
}
|
||||
addProperty("Spell", VLC->spellh->getById(spellId)->getJsonKey(), delegate, false);
|
||||
addProperty("Spell", VLC->spellh->getById(spellId)->getNameTranslated(), delegate, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -540,7 +540,7 @@ void Inspector::setProperty(CGArtifact * o, const QString & key, const QVariant
|
||||
{
|
||||
for(auto spell : VLC->spellh->objects)
|
||||
{
|
||||
if(spell->getJsonKey() == value.toString().toStdString())
|
||||
if(spell->getNameTranslated() == value.toString().toStdString())
|
||||
{
|
||||
o->storedArtifact = ArtifactUtils::createScroll(spell->getId());
|
||||
break;
|
||||
|
@@ -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
@@ -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;
|
||||
};
|
@@ -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>
|
138
mapeditor/mapsettings/abstractsettings.cpp
Normal file
138
mapeditor/mapsettings/abstractsettings.cpp
Normal 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;
|
||||
};
|
67
mapeditor/mapsettings/abstractsettings.h
Normal file
67
mapeditor/mapsettings/abstractsettings.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* abstractsettings.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 <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:
|
||||
|
||||
};
|
118
mapeditor/mapsettings/eventsettings.cpp
Normal file
118
mapeditor/mapsettings/eventsettings.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* eventsettings.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 "eventsettings.h"
|
||||
#include "timedevent.h"
|
||||
#include "ui_eventsettings.h"
|
||||
#include "../../lib/mapping/CMapDefines.h"
|
||||
#include "../../lib/constants/NumericConstants.h"
|
||||
#include "../../lib/constants/StringConstants.h"
|
||||
|
||||
QVariant toVariant(const TResources & resources)
|
||||
{
|
||||
QVariantMap result;
|
||||
for(int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i)
|
||||
result[QString::fromStdString(GameConstants::RESOURCE_NAMES[i])] = QVariant::fromValue(resources[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
TResources resourcesFromVariant(const QVariant & v)
|
||||
{
|
||||
JsonNode vJson;
|
||||
for(auto r : v.toMap().keys())
|
||||
vJson[r.toStdString()].Integer() = v.toMap().value(r).toInt();
|
||||
return TResources(vJson);
|
||||
|
||||
}
|
||||
|
||||
QVariant toVariant(const CMapEvent & event)
|
||||
{
|
||||
QVariantMap result;
|
||||
result["name"] = QString::fromStdString(event.name);
|
||||
result["message"] = QString::fromStdString(event.message);
|
||||
result["players"] = QVariant::fromValue(event.players);
|
||||
result["humanAffected"] = QVariant::fromValue(event.humanAffected);
|
||||
result["computerAffected"] = QVariant::fromValue(event.computerAffected);
|
||||
result["firstOccurence"] = QVariant::fromValue(event.firstOccurence);
|
||||
result["nextOccurence"] = QVariant::fromValue(event.nextOccurence);
|
||||
result["resources"] = toVariant(event.resources);
|
||||
return QVariant(result);
|
||||
}
|
||||
|
||||
CMapEvent eventFromVariant(const QVariant & variant)
|
||||
{
|
||||
CMapEvent result;
|
||||
auto v = variant.toMap();
|
||||
result.name = v.value("name").toString().toStdString();
|
||||
result.message = v.value("message").toString().toStdString();
|
||||
result.players = v.value("players").toInt();
|
||||
result.humanAffected = v.value("humanAffected").toInt();
|
||||
result.computerAffected = v.value("computerAffected").toInt();
|
||||
result.firstOccurence = v.value("firstOccurence").toInt();
|
||||
result.nextOccurence = v.value("nextOccurence").toInt();
|
||||
result.resources = resourcesFromVariant(v.value("resources"));
|
||||
return result;
|
||||
}
|
||||
|
||||
EventSettings::EventSettings(QWidget *parent) :
|
||||
AbstractSettings(parent),
|
||||
ui(new Ui::EventSettings)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
EventSettings::~EventSettings()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EventSettings::initialize(const CMap & map)
|
||||
{
|
||||
for(const auto & event : map.events)
|
||||
{
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(event.name));
|
||||
item->setData(Qt::UserRole, toVariant(event));
|
||||
ui->eventsList->addItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void EventSettings::update(CMap & map)
|
||||
{
|
||||
map.events.clear();
|
||||
for(int i = 0; i < ui->eventsList->count(); ++i)
|
||||
{
|
||||
const auto * item = ui->eventsList->item(i);
|
||||
map.events.push_back(eventFromVariant(item->data(Qt::UserRole)));
|
||||
}
|
||||
}
|
||||
|
||||
void EventSettings::on_timedEventAdd_clicked()
|
||||
{
|
||||
CMapEvent event;
|
||||
event.name = tr("New event").toStdString();
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(event.name));
|
||||
item->setData(Qt::UserRole, toVariant(event));
|
||||
ui->eventsList->addItem(item);
|
||||
on_eventsList_itemActivated(item);
|
||||
}
|
||||
|
||||
|
||||
void EventSettings::on_timedEventRemove_clicked()
|
||||
{
|
||||
if(auto * item = ui->eventsList->currentItem())
|
||||
ui->eventsList->takeItem(ui->eventsList->row(item));
|
||||
}
|
||||
|
||||
|
||||
void EventSettings::on_eventsList_itemActivated(QListWidgetItem *item)
|
||||
{
|
||||
new TimedEvent(item, parentWidget());
|
||||
}
|
||||
|
39
mapeditor/mapsettings/eventsettings.h
Normal file
39
mapeditor/mapsettings/eventsettings.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* eventsettings.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 "abstractsettings.h"
|
||||
|
||||
namespace Ui {
|
||||
class EventSettings;
|
||||
}
|
||||
|
||||
class EventSettings : public AbstractSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EventSettings(QWidget *parent = nullptr);
|
||||
~EventSettings();
|
||||
|
||||
void initialize(const CMap & map) override;
|
||||
void update(CMap & map) override;
|
||||
|
||||
private slots:
|
||||
void on_timedEventAdd_clicked();
|
||||
|
||||
void on_timedEventRemove_clicked();
|
||||
|
||||
void on_eventsList_itemActivated(QListWidgetItem *item);
|
||||
|
||||
private:
|
||||
Ui::EventSettings *ui;
|
||||
};
|
||||
|
86
mapeditor/mapsettings/eventsettings.ui
Normal file
86
mapeditor/mapsettings/eventsettings.ui
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EventSettings</class>
|
||||
<widget class="QWidget" name="EventSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>672</width>
|
||||
<height>456</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</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>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="timedEventAdd">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="timedEventRemove">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="eventsList"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
79
mapeditor/mapsettings/generalsettings.cpp
Normal file
79
mapeditor/mapsettings/generalsettings.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
#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);
|
||||
}
|
||||
|
34
mapeditor/mapsettings/generalsettings.h
Normal file
34
mapeditor/mapsettings/generalsettings.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* generalsettings.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 "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;
|
||||
};
|
130
mapeditor/mapsettings/generalsettings.ui
Normal file
130
mapeditor/mapsettings/generalsettings.ui
Normal file
@@ -0,0 +1,130 @@
|
||||
<?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">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
271
mapeditor/mapsettings/loseconditions.cpp
Normal file
271
mapeditor/mapsettings/loseconditions.cpp
Normal file
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* loseconditions.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 "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 = ↦
|
||||
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
40
mapeditor/mapsettings/loseconditions.h
Normal file
40
mapeditor/mapsettings/loseconditions.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#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;
|
||||
};
|
||||
|
81
mapeditor/mapsettings/loseconditions.ui
Normal file
81
mapeditor/mapsettings/loseconditions.ui
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
107
mapeditor/mapsettings/mapsettings.cpp
Normal file
107
mapeditor/mapsettings/mapsettings.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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());
|
||||
ui->events->initialize(*controller.map());
|
||||
ui->rumors->initialize(*controller.map());
|
||||
}
|
||||
|
||||
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());
|
||||
ui->events->update(*controller.map());
|
||||
ui->rumors->update(*controller.map());
|
||||
|
||||
controller.commitChangeWithoutRedraw();
|
||||
|
||||
close();
|
||||
}
|
36
mapeditor/mapsettings/mapsettings.h
Normal file
36
mapeditor/mapsettings/mapsettings.h
Normal 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;
|
||||
};
|
368
mapeditor/mapsettings/mapsettings.ui
Normal file
368
mapeditor/mapsettings/mapsettings.ui
Normal file
@@ -0,0 +1,368 @@
|
||||
<?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>3</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>
|
||||
<widget class="EventSettings" name="events" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_11">
|
||||
<attribute name="title">
|
||||
<string>Rumors</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<property name="leftMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="RumorSettings" name="rumors" native="true"/>
|
||||
</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>
|
||||
<customwidget>
|
||||
<class>EventSettings</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>mapsettings/eventsettings.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>RumorSettings</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>mapsettings/rumorsettings.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
163
mapeditor/mapsettings/modsettings.cpp
Normal file
163
mapeditor/mapsettings/modsettings.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* modsettings.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 "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 = ↦
|
||||
|
||||
//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);
|
||||
}
|
42
mapeditor/mapsettings/modsettings.h
Normal file
42
mapeditor/mapsettings/modsettings.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* modsettings.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 "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;
|
||||
};
|
97
mapeditor/mapsettings/modsettings.ui
Normal file
97
mapeditor/mapsettings/modsettings.ui
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
81
mapeditor/mapsettings/rumorsettings.cpp
Normal file
81
mapeditor/mapsettings/rumorsettings.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* rumorsettings.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 "rumorsettings.h"
|
||||
#include "ui_rumorsettings.h"
|
||||
|
||||
RumorSettings::RumorSettings(QWidget *parent) :
|
||||
AbstractSettings(parent),
|
||||
ui(new Ui::RumorSettings)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
RumorSettings::~RumorSettings()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void RumorSettings::initialize(const CMap & map)
|
||||
{
|
||||
for(auto & rumor : map.rumors)
|
||||
{
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(rumor.name));
|
||||
item->setData(Qt::UserRole, QVariant(QString::fromStdString(rumor.text)));
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
ui->rumors->addItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void RumorSettings::update(CMap & map)
|
||||
{
|
||||
map.rumors.clear();
|
||||
for(int i = 0; i < ui->rumors->count(); ++i)
|
||||
{
|
||||
Rumor rumor;
|
||||
rumor.name = ui->rumors->item(i)->text().toStdString();
|
||||
rumor.text = ui->rumors->item(i)->data(Qt::UserRole).toString().toStdString();
|
||||
map.rumors.push_back(rumor);
|
||||
}
|
||||
}
|
||||
|
||||
void RumorSettings::on_message_textChanged()
|
||||
{
|
||||
if(auto item = ui->rumors->currentItem())
|
||||
item->setData(Qt::UserRole, QVariant(ui->message->toPlainText()));
|
||||
}
|
||||
|
||||
void RumorSettings::on_add_clicked()
|
||||
{
|
||||
auto * item = new QListWidgetItem(tr("New rumor"));
|
||||
item->setData(Qt::UserRole, QVariant(""));
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
ui->rumors->addItem(item);
|
||||
emit ui->rumors->itemActivated(item);
|
||||
}
|
||||
|
||||
void RumorSettings::on_remove_clicked()
|
||||
{
|
||||
if(auto item = ui->rumors->currentItem())
|
||||
{
|
||||
ui->message->setPlainText("");
|
||||
ui->rumors->takeItem(ui->rumors->row(item));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RumorSettings::on_rumors_itemSelectionChanged()
|
||||
{
|
||||
if(auto item = ui->rumors->currentItem())
|
||||
ui->message->setPlainText(item->data(Qt::UserRole).toString());
|
||||
}
|
||||
|
||||
|
||||
|
40
mapeditor/mapsettings/rumorsettings.h
Normal file
40
mapeditor/mapsettings/rumorsettings.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* rumorsettings.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 "abstractsettings.h"
|
||||
|
||||
namespace Ui {
|
||||
class RumorSettings;
|
||||
}
|
||||
|
||||
class RumorSettings : public AbstractSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RumorSettings(QWidget *parent = nullptr);
|
||||
~RumorSettings();
|
||||
|
||||
void initialize(const CMap & map) override;
|
||||
void update(CMap & map) override;
|
||||
|
||||
private slots:
|
||||
void on_message_textChanged();
|
||||
|
||||
void on_add_clicked();
|
||||
|
||||
void on_remove_clicked();
|
||||
|
||||
void on_rumors_itemSelectionChanged();
|
||||
|
||||
private:
|
||||
Ui::RumorSettings *ui;
|
||||
};
|
105
mapeditor/mapsettings/rumorsettings.ui
Normal file
105
mapeditor/mapsettings/rumorsettings.ui
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RumorSettings</class>
|
||||
<widget class="QWidget" name="RumorSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>538</width>
|
||||
<height>470</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Tavern rumors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="add">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="remove">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="rumors">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="message"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
108
mapeditor/mapsettings/timedevent.cpp
Normal file
108
mapeditor/mapsettings/timedevent.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* timedevent.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 "timedevent.h"
|
||||
#include "ui_timedevent.h"
|
||||
#include "../../lib/constants/EntityIdentifiers.h"
|
||||
#include "../../lib/constants/StringConstants.h"
|
||||
|
||||
TimedEvent::TimedEvent(QListWidgetItem * t, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
target(t),
|
||||
ui(new Ui::TimedEvent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
|
||||
const auto params = t->data(Qt::UserRole).toMap();
|
||||
ui->eventNameText->setText(params.value("name").toString());
|
||||
ui->eventMessageText->setPlainText(params.value("message").toString());
|
||||
ui->eventAffectsCpu->setChecked(params.value("computerAffected").toBool());
|
||||
ui->eventAffectsHuman->setChecked(params.value("humanAffected").toBool());
|
||||
ui->eventFirstOccurance->setValue(params.value("firstOccurence").toInt());
|
||||
ui->eventRepeatAfter->setValue(params.value("nextOccurence").toInt());
|
||||
|
||||
for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
|
||||
{
|
||||
bool isAffected = (1 << i) & params.value("players").toInt();
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[i]));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(i));
|
||||
item->setCheckState(isAffected ? Qt::Checked : Qt::Unchecked);
|
||||
ui->playersAffected->addItem(item);
|
||||
}
|
||||
|
||||
ui->resources->setRowCount(GameConstants::RESOURCE_QUANTITY);
|
||||
for(int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i)
|
||||
{
|
||||
auto name = QString::fromStdString(GameConstants::RESOURCE_NAMES[i]);
|
||||
int val = params.value("resources").toMap().value(name).toInt();
|
||||
ui->resources->setItem(i, 0, new QTableWidgetItem(name));
|
||||
auto nval = new QTableWidgetItem(QString::number(val));
|
||||
nval->setFlags(nval->flags() | Qt::ItemIsEditable);
|
||||
ui->resources->setItem(i, 1, nval);
|
||||
}
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
TimedEvent::~TimedEvent()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void TimedEvent::on_TimedEvent_finished(int result)
|
||||
{
|
||||
QVariantMap descriptor;
|
||||
descriptor["name"] = ui->eventNameText->text();
|
||||
descriptor["message"] = ui->eventMessageText->toPlainText();
|
||||
descriptor["humanAffected"] = QVariant::fromValue(ui->eventAffectsHuman->isChecked());
|
||||
descriptor["computerAffected"] = QVariant::fromValue(ui->eventAffectsCpu->isChecked());
|
||||
descriptor["firstOccurence"] = QVariant::fromValue(ui->eventFirstOccurance->value());
|
||||
descriptor["nextOccurence"] = QVariant::fromValue(ui->eventRepeatAfter->value());
|
||||
|
||||
int players = 0;
|
||||
for(int i = 0; i < ui->playersAffected->count(); ++i)
|
||||
{
|
||||
auto * item = ui->playersAffected->item(i);
|
||||
if(item->checkState() == Qt::Checked)
|
||||
players |= 1 << i;
|
||||
}
|
||||
descriptor["players"] = QVariant::fromValue(players);
|
||||
|
||||
auto res = target->data(Qt::UserRole).toMap().value("resources").toMap();
|
||||
for(int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i)
|
||||
{
|
||||
auto * itemType = ui->resources->item(i, 0);
|
||||
auto * itemQty = ui->resources->item(i, 1);
|
||||
res[itemType->text()] = QVariant::fromValue(itemQty->text().toInt());
|
||||
}
|
||||
descriptor["resources"] = res;
|
||||
|
||||
target->setData(Qt::UserRole, descriptor);
|
||||
target->setText(ui->eventNameText->text());
|
||||
}
|
||||
|
||||
|
||||
void TimedEvent::on_pushButton_clicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void TimedEvent::on_resources_itemDoubleClicked(QTableWidgetItem *item)
|
||||
{
|
||||
if(item && item->column() == 1)
|
||||
{
|
||||
ui->resources->editItem(item);
|
||||
}
|
||||
}
|
||||
|
37
mapeditor/mapsettings/timedevent.h
Normal file
37
mapeditor/mapsettings/timedevent.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* timedevent.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>
|
||||
|
||||
namespace Ui {
|
||||
class TimedEvent;
|
||||
}
|
||||
|
||||
class TimedEvent : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TimedEvent(QListWidgetItem *, QWidget *parent = nullptr);
|
||||
~TimedEvent();
|
||||
|
||||
private slots:
|
||||
|
||||
void on_TimedEvent_finished(int result);
|
||||
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_resources_itemDoubleClicked(QTableWidgetItem *item);
|
||||
|
||||
private:
|
||||
Ui::TimedEvent *ui;
|
||||
QListWidgetItem * target;
|
||||
};
|
213
mapeditor/mapsettings/timedevent.ui
Normal file
213
mapeditor/mapsettings/timedevent.ui
Normal file
@@ -0,0 +1,213 @@
|
||||
<?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="eventNameText">
|
||||
<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="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Affected players</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="playersAffected">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Resources</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="resources">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>20</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>60</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderMinimumSectionSize">
|
||||
<number>16</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>16</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>type</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>qty</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
435
mapeditor/mapsettings/victoryconditions.cpp
Normal file
435
mapeditor/mapsettings/victoryconditions.cpp
Normal file
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
* victoryconditions.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 "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 = ↦
|
||||
|
||||
//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;
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
39
mapeditor/mapsettings/victoryconditions.h
Normal file
39
mapeditor/mapsettings/victoryconditions.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* victoryconditions.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 "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;
|
||||
};
|
91
mapeditor/mapsettings/victoryconditions.ui
Normal file
91
mapeditor/mapsettings/victoryconditions.ui
Normal file
@@ -0,0 +1,91 @@
|
||||
<?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">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
@@ -16,6 +16,7 @@
|
||||
#include "../lib/mapObjects/MapObjects.h"
|
||||
#include "../lib/modding/CModHandler.h"
|
||||
#include "../lib/modding/CModInfo.h"
|
||||
#include "../lib/spells/CSpellHandler.h"
|
||||
#include "../lib/CHeroHandler.h"
|
||||
|
||||
Validator::Validator(const CMap * map, QWidget *parent) :
|
||||
@@ -141,8 +142,8 @@ std::list<Validator::Issue> Validator::validate(const CMap * map)
|
||||
{
|
||||
if(ins->storedArtifact)
|
||||
{
|
||||
if(!map->allowedSpells[ins->storedArtifact->getId().getNum()])
|
||||
issues.emplace_back(QString(tr("Spell scroll %1 is prohibited by map settings")).arg(ins->getObjectName().c_str()), false);
|
||||
if(!map->allowedSpells[ins->storedArtifact->getScrollSpellID()])
|
||||
issues.emplace_back(QString(tr("Spell scroll %1 is prohibited by map settings")).arg(ins->storedArtifact->getScrollSpellID().toSpell(VLC->spells())->getNameTranslated().c_str()), false);
|
||||
}
|
||||
else
|
||||
issues.emplace_back(QString(tr("Spell scroll %1 doesn't have instance assigned and must be removed")).arg(ins->instanceName.c_str()), true);
|
||||
|
Reference in New Issue
Block a user