diff --git a/mapeditor/CMakeLists.txt b/mapeditor/CMakeLists.txt
index e329c3103..bd9cda0e5 100644
--- a/mapeditor/CMakeLists.txt
+++ b/mapeditor/CMakeLists.txt
@@ -15,16 +15,17 @@ set(editor_SRCS
mapview.cpp
radiopushbutton.cpp
objectbrowser.cpp
- inspector.cpp
mapsettings.cpp
playersettings.cpp
playerparams.cpp
scenelayer.cpp
mapcontroller.cpp
validator.cpp
- townbulidingswidget.cpp
- armywidget.cpp
- messagewidget.cpp
+ inspector/inspector.cpp
+ inspector/townbulidingswidget.cpp
+ inspector/armywidget.cpp
+ inspector/messagewidget.cpp
+ inspector/rewardswidget.cpp
)
set(editor_HEADERS
@@ -43,16 +44,17 @@ set(editor_HEADERS
mapview.h
radiopushbutton.h
objectbrowser.h
- inspector.h
mapsettings.h
playersettings.h
playerparams.h
scenelayer.h
mapcontroller.h
validator.h
- townbulidingswidget.h
- armywidget.h
- messagewidget.h
+ inspector/inspector.h
+ inspector/townbulidingswidget.h
+ inspector/armywidget.h
+ inspector/messagewidget.h
+ inspector/rewardswidget.h
)
set(editor_FORMS
@@ -63,12 +65,13 @@ set(editor_FORMS
playersettings.ui
playerparams.ui
validator.ui
- townbulidingswidget.ui
- armywidget.ui
- messagewidget.ui
+ inspector/townbulidingswidget.ui
+ inspector/armywidget.ui
+ inspector/messagewidget.ui
+ inspector/rewardswidget.ui
)
-assign_source_group(${editor_SRCS} ${editor_HEADERS} VCMI_launcher.rc)
+assign_source_group(${editor_SRCS} ${editor_HEADERS} mapeditor.rc)
# Tell CMake to run moc when necessary:
set(CMAKE_AUTOMOC ON)
@@ -88,7 +91,7 @@ else()
endif()
if(WIN32)
- set(editor_ICON VCMI_launcher.rc)
+ set(editor_ICON mapeditor.rc)
endif()
add_executable(vcmieditor WIN32 ${editor_SRCS} ${editor_HEADERS} ${editor_UI_HEADERS} ${editor_ICON})
diff --git a/mapeditor/VCMI_launcher.cbp b/mapeditor/VCMI_launcher.cbp
deleted file mode 100644
index b7c1bedf3..000000000
--- a/mapeditor/VCMI_launcher.cbp
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/mapeditor/VCMI_launcher.ico b/mapeditor/VCMI_launcher.ico
deleted file mode 100644
index 40818c464..000000000
Binary files a/mapeditor/VCMI_launcher.ico and /dev/null differ
diff --git a/mapeditor/VCMI_launcher.rc b/mapeditor/VCMI_launcher.rc
deleted file mode 100644
index 9fb0b7833..000000000
--- a/mapeditor/VCMI_launcher.rc
+++ /dev/null
@@ -1 +0,0 @@
-IDI_ICON1 ICON "VCMI_launcher.ico"
\ No newline at end of file
diff --git a/mapeditor/armywidget.cpp b/mapeditor/inspector/armywidget.cpp
similarity index 100%
rename from mapeditor/armywidget.cpp
rename to mapeditor/inspector/armywidget.cpp
diff --git a/mapeditor/armywidget.h b/mapeditor/inspector/armywidget.h
similarity index 100%
rename from mapeditor/armywidget.h
rename to mapeditor/inspector/armywidget.h
diff --git a/mapeditor/armywidget.ui b/mapeditor/inspector/armywidget.ui
similarity index 100%
rename from mapeditor/armywidget.ui
rename to mapeditor/inspector/armywidget.ui
diff --git a/mapeditor/inspector.cpp b/mapeditor/inspector/inspector.cpp
similarity index 98%
rename from mapeditor/inspector.cpp
rename to mapeditor/inspector/inspector.cpp
index 99b6ebc62..51902dc01 100644
--- a/mapeditor/inspector.cpp
+++ b/mapeditor/inspector/inspector.cpp
@@ -11,7 +11,7 @@
#include "messagewidget.h"
//===============IMPLEMENT OBJECT INITIALIZATION FUNCTIONS================
-Initializer::Initializer(CMap * m, CGObjectInstance * o) : map(m)
+Initializer::Initializer(CMap * m, CGObjectInstance * o, const PlayerColor & pl) : map(m), defaultPlayer(pl)
{
///IMPORTANT! initialize order should be from base objects to derived objects
INIT_OBJ_TYPE(CGResource);
@@ -58,7 +58,7 @@ void Initializer::initialize(CGDwelling * o)
{
if(!o) return;
- o->tempOwner = PlayerColor::NEUTRAL;
+ o->tempOwner = defaultPlayer;
switch(o->ID)
{
@@ -73,7 +73,7 @@ void Initializer::initialize(CGGarrison * o)
{
if(!o) return;
- o->tempOwner = PlayerColor::NEUTRAL;
+ o->tempOwner = defaultPlayer;
o->removableUnits = true;
}
@@ -81,21 +81,21 @@ void Initializer::initialize(CGShipyard * o)
{
if(!o) return;
- o->tempOwner = PlayerColor::NEUTRAL;
+ o->tempOwner = defaultPlayer;
}
void Initializer::initialize(CGLighthouse * o)
{
if(!o) return;
- o->tempOwner = PlayerColor::NEUTRAL;
+ o->tempOwner = defaultPlayer;
}
void Initializer::initialize(CGHeroInstance * o)
{
if(!o) return;
- o->tempOwner = PlayerColor::NEUTRAL;
+ o->tempOwner = defaultPlayer;
}
void Initializer::initialize(CGTownInstance * o)
@@ -141,7 +141,7 @@ void Initializer::initialize(CGMine * o)
{
if(!o) return;
- o->tempOwner = PlayerColor::NEUTRAL;
+ o->tempOwner = defaultPlayer;
o->producedResource = Res::ERes(o->subID);
o->producedQuantity = o->defaultResProduction();
}
diff --git a/mapeditor/inspector.h b/mapeditor/inspector/inspector.h
similarity index 97%
rename from mapeditor/inspector.h
rename to mapeditor/inspector/inspector.h
index 31b74039a..cde565564 100644
--- a/mapeditor/inspector.h
+++ b/mapeditor/inspector/inspector.h
@@ -37,10 +37,11 @@ public:
DECLARE_OBJ_TYPE(CGLighthouse);
- Initializer(CMap *, CGObjectInstance *);
+ Initializer(CMap *, CGObjectInstance *, const PlayerColor &);
private:
CMap * map;
+ PlayerColor defaultPlayer;
};
class Inspector
diff --git a/mapeditor/messagewidget.cpp b/mapeditor/inspector/messagewidget.cpp
similarity index 100%
rename from mapeditor/messagewidget.cpp
rename to mapeditor/inspector/messagewidget.cpp
diff --git a/mapeditor/messagewidget.h b/mapeditor/inspector/messagewidget.h
similarity index 100%
rename from mapeditor/messagewidget.h
rename to mapeditor/inspector/messagewidget.h
diff --git a/mapeditor/messagewidget.ui b/mapeditor/inspector/messagewidget.ui
similarity index 100%
rename from mapeditor/messagewidget.ui
rename to mapeditor/inspector/messagewidget.ui
diff --git a/mapeditor/inspector/rewardswidget.cpp b/mapeditor/inspector/rewardswidget.cpp
new file mode 100644
index 000000000..ccb37d2d6
--- /dev/null
+++ b/mapeditor/inspector/rewardswidget.cpp
@@ -0,0 +1,14 @@
+#include "rewardswidget.h"
+#include "ui_rewardswidget.h"
+
+RewardsWidget::RewardsWidget(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::RewardsWidget)
+{
+ ui->setupUi(this);
+}
+
+RewardsWidget::~RewardsWidget()
+{
+ delete ui;
+}
diff --git a/mapeditor/inspector/rewardswidget.h b/mapeditor/inspector/rewardswidget.h
new file mode 100644
index 000000000..7a0ce5124
--- /dev/null
+++ b/mapeditor/inspector/rewardswidget.h
@@ -0,0 +1,22 @@
+#ifndef REWARDSWIDGET_H
+#define REWARDSWIDGET_H
+
+#include
+
+namespace Ui {
+class RewardsWidget;
+}
+
+class RewardsWidget : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit RewardsWidget(QWidget *parent = nullptr);
+ ~RewardsWidget();
+
+private:
+ Ui::RewardsWidget *ui;
+};
+
+#endif // REWARDSWIDGET_H
diff --git a/mapeditor/inspector/rewardswidget.ui b/mapeditor/inspector/rewardswidget.ui
new file mode 100644
index 000000000..4180052c3
--- /dev/null
+++ b/mapeditor/inspector/rewardswidget.ui
@@ -0,0 +1,18 @@
+
+ RewardsWidget
+
+
+
+ 0
+ 0
+ 400
+ 300
+
+
+
+ Dialog
+
+
+
+
+
diff --git a/mapeditor/townbulidingswidget.cpp b/mapeditor/inspector/townbulidingswidget.cpp
similarity index 100%
rename from mapeditor/townbulidingswidget.cpp
rename to mapeditor/inspector/townbulidingswidget.cpp
diff --git a/mapeditor/townbulidingswidget.h b/mapeditor/inspector/townbulidingswidget.h
similarity index 100%
rename from mapeditor/townbulidingswidget.h
rename to mapeditor/inspector/townbulidingswidget.h
diff --git a/mapeditor/townbulidingswidget.ui b/mapeditor/inspector/townbulidingswidget.ui
similarity index 100%
rename from mapeditor/townbulidingswidget.ui
rename to mapeditor/inspector/townbulidingswidget.ui
diff --git a/mapeditor/mainwindow.cpp b/mapeditor/mainwindow.cpp
index 2d382d1bc..ef0d8d1f5 100644
--- a/mapeditor/mainwindow.cpp
+++ b/mapeditor/mainwindow.cpp
@@ -26,7 +26,7 @@
#include "graphics.h"
#include "windownewmap.h"
#include "objectbrowser.h"
-#include "inspector.h"
+#include "inspector/inspector.h"
#include "mapsettings.h"
#include "playersettings.h"
#include "validator.h"
@@ -136,7 +136,14 @@ MainWindow::MainWindow(QWidget *parent) :
loadObjectsTree();
ui->tabWidget->setCurrentIndex(0);
-
+
+ for(int i = 0; i < 8; ++i)
+ {
+ connect(getActionPlayer(PlayerColor(i)), &QAction::toggled, this, [&, i](){switchDefaultPlayer(PlayerColor(i));});
+ }
+ connect(getActionPlayer(PlayerColor::NEUTRAL), &QAction::toggled, this, [&](){switchDefaultPlayer(PlayerColor::NEUTRAL);});
+ onPlayersChanged();
+
show();
}
@@ -200,6 +207,8 @@ void MainWindow::initializeMap(bool isNew)
//enable settings
ui->actionMapSettings->setEnabled(true);
ui->actionPlayers_settings->setEnabled(true);
+
+ onPlayersChanged();
}
void MainWindow::on_actionOpen_triggered()
@@ -869,8 +878,60 @@ void MainWindow::on_actionPlayers_settings_triggered()
auto settingsDialog = new PlayerSettings(controller, this);
settingsDialog->setWindowModality(Qt::WindowModal);
settingsDialog->setModal(true);
+ connect(settingsDialog, &QDialog::finished, this, &MainWindow::onPlayersChanged);
}
+QAction * MainWindow::getActionPlayer(const PlayerColor & player)
+{
+ if(player.getNum() == 0) return ui->actionPlayer_1;
+ if(player.getNum() == 1) return ui->actionPlayer_2;
+ if(player.getNum() == 2) return ui->actionPlayer_3;
+ if(player.getNum() == 3) return ui->actionPlayer_4;
+ if(player.getNum() == 4) return ui->actionPlayer_5;
+ if(player.getNum() == 5) return ui->actionPlayer_6;
+ if(player.getNum() == 6) return ui->actionPlayer_7;
+ if(player.getNum() == 7) return ui->actionPlayer_8;
+ return ui->actionNeutral;
+}
+
+void MainWindow::switchDefaultPlayer(const PlayerColor & player)
+{
+ if(controller.defaultPlayer == player)
+ return;
+
+ ui->actionNeutral->blockSignals(true);
+ ui->actionNeutral->setChecked(PlayerColor::NEUTRAL == player);
+ ui->actionNeutral->blockSignals(false);
+ for(int i = 0; i < 8; ++i)
+ {
+ getActionPlayer(PlayerColor(i))->blockSignals(true);
+ getActionPlayer(PlayerColor(i))->setChecked(PlayerColor(i) == player);
+ getActionPlayer(PlayerColor(i))->blockSignals(false);
+ }
+ controller.defaultPlayer = player;
+}
+
+void MainWindow::onPlayersChanged()
+{
+ if(controller.map())
+ {
+ getActionPlayer(PlayerColor::NEUTRAL)->setEnabled(true);
+ for(int i = 0; i < controller.map()->players.size(); ++i)
+ getActionPlayer(PlayerColor(i))->setEnabled(controller.map()->players.at(i).canAnyonePlay());
+ if(!getActionPlayer(controller.defaultPlayer)->isEnabled() || controller.defaultPlayer == PlayerColor::NEUTRAL)
+ switchDefaultPlayer(PlayerColor::NEUTRAL);
+ }
+ else
+ {
+ for(int i = 0; i < PlayerColor::PLAYER_LIMIT.getNum(); ++i)
+ getActionPlayer(PlayerColor(i))->setEnabled(false);
+ getActionPlayer(PlayerColor::NEUTRAL)->setEnabled(false);
+ }
+
+}
+
+
+
void MainWindow::enableUndo(bool enable)
{
ui->actionUndo->setEnabled(enable);
diff --git a/mapeditor/mainwindow.h b/mapeditor/mainwindow.h
index 1d154a69a..0934546c0 100644
--- a/mapeditor/mainwindow.h
+++ b/mapeditor/mainwindow.h
@@ -90,6 +90,8 @@ private slots:
void on_actionUpdate_appearance_triggered();
void on_actionRecreate_obstacles_triggered();
+
+ void switchDefaultPlayer(const PlayerColor &);
public slots:
@@ -99,11 +101,14 @@ public slots:
void enableUndo(bool enable);
void enableRedo(bool enable);
void onSelectionMade(int level, bool anythingSelected);
+ void onPlayersChanged();
private:
void preparePreview(const QModelIndex &index, bool createNew);
void addGroupIntoCatalog(const std::string & groupName, bool staticOnly);
void addGroupIntoCatalog(const std::string & groupName, bool useCustomName, bool staticOnly, int ID);
+
+ QAction * getActionPlayer(const PlayerColor &);
void changeBrushState(int idx);
void setTitle();
diff --git a/mapeditor/mainwindow.ui b/mapeditor/mainwindow.ui
index 8f786a1ba..ffa27c837 100644
--- a/mapeditor/mainwindow.ui
+++ b/mapeditor/mainwindow.ui
@@ -81,9 +81,24 @@
+
+
@@ -902,7 +917,7 @@
Erase
- Del
+ Backspace, Del
@@ -912,6 +927,9 @@
Neutral
+
+ Ctrl+0
+
@@ -934,6 +952,94 @@
Recreate obstacles
+
+
+ true
+
+
+ Player 1
+
+
+ Ctrl+1
+
+
+
+
+ true
+
+
+ Player 2
+
+
+ Ctrl+2
+
+
+
+
+ true
+
+
+ Player 3
+
+
+ Ctrl+3
+
+
+
+
+ true
+
+
+ Player 4
+
+
+ Ctrl+4
+
+
+
+
+ true
+
+
+ Player 5
+
+
+ Ctrl+5
+
+
+
+
+ true
+
+
+ Player 6
+
+
+ Ctrl+6
+
+
+
+
+ true
+
+
+ Player 7
+
+
+ Ctrl+7
+
+
+
+
+ true
+
+
+ Player 8
+
+
+ Ctrl+8
+
+
diff --git a/mapeditor/mapcontroller.cpp b/mapeditor/mapcontroller.cpp
index be86b0156..c82893e37 100644
--- a/mapeditor/mapcontroller.cpp
+++ b/mapeditor/mapcontroller.cpp
@@ -13,7 +13,7 @@
#include "scenelayer.h"
#include "maphandler.h"
#include "mainwindow.h"
-#include "inspector.h"
+#include "inspector/inspector.h"
MapController::MapController(MainWindow * m): main(m)
@@ -342,7 +342,7 @@ void MapController::commitObjectCreate(int level)
return; //maplimit reached
}
- Initializer init(map(), newObj);
+ Initializer init(map(), newObj, defaultPlayer);
_map->getEditManager()->insertObject(newObj);
_mapHandler->invalidate(newObj);
diff --git a/mapeditor/mapcontroller.h b/mapeditor/mapcontroller.h
index e9470677d..0ebdb1451 100644
--- a/mapeditor/mapcontroller.h
+++ b/mapeditor/mapcontroller.h
@@ -45,6 +45,8 @@ public:
void undo();
void redo();
+ PlayerColor defaultPlayer;
+
private:
std::unique_ptr _map;
std::unique_ptr _mapHandler;
diff --git a/mapeditor/mapeditor.ico b/mapeditor/mapeditor.ico
new file mode 100644
index 000000000..544c420fa
Binary files /dev/null and b/mapeditor/mapeditor.ico differ
diff --git a/mapeditor/mapeditor.rc b/mapeditor/mapeditor.rc
new file mode 100644
index 000000000..ac6469878
--- /dev/null
+++ b/mapeditor/mapeditor.rc
@@ -0,0 +1 @@
+IDI_ICON1 ICON "mapeditor.ico"
diff --git a/mapeditor/scenelayer.cpp b/mapeditor/scenelayer.cpp
index a0e79ac5b..864bf78db 100644
--- a/mapeditor/scenelayer.cpp
+++ b/mapeditor/scenelayer.cpp
@@ -2,7 +2,7 @@
#include "scenelayer.h"
#include "mainwindow.h"
#include "../lib/mapping/CMapEditManager.h"
-#include "inspector.h"
+#include "inspector/inspector.h"
#include "mapview.h"
#include "mapcontroller.h"