1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-18 17:40:48 +02:00

Few more fixes

This commit is contained in:
nordsoft 2022-09-05 06:18:38 +04:00
parent 5839ba4ce8
commit 3430edba22
5 changed files with 36 additions and 9 deletions

View File

@ -58,7 +58,8 @@ void init()
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::MainWindow) ui(new Ui::MainWindow),
controller(this)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -156,13 +157,22 @@ void MainWindow::reloadMap(int level)
//sceneMini->addPixmap(minimap); //sceneMini->addPixmap(minimap);
} }
void MainWindow::mapChanged()
{
unsaved = true;
setWindowTitle(filename + "* - VCMI Map Editor");
}
void MainWindow::initializeMap(bool isNew) void MainWindow::initializeMap(bool isNew)
{ {
unsaved = isNew; unsaved = isNew;
if(isNew) if(isNew)
{
filename.clear(); filename.clear();
setWindowTitle("* - VCMI Map Editor");
setWindowTitle(filename + "* - VCMI Map Editor"); }
else
setWindowTitle(filename + " - VCMI Map Editor");
mapLevel = 0; mapLevel = 0;
ui->mapView->setScene(controller.scene(mapLevel)); ui->mapView->setScene(controller.scene(mapLevel));
@ -171,6 +181,7 @@ void MainWindow::initializeMap(bool isNew)
//enable settings //enable settings
ui->actionMapSettings->setEnabled(true); ui->actionMapSettings->setEnabled(true);
ui->actionPlayers_settings->setEnabled(true);
} }
void MainWindow::on_actionOpen_triggered() void MainWindow::on_actionOpen_triggered()

View File

@ -83,6 +83,7 @@ public slots:
void treeViewSelected(const QModelIndex &selected, const QModelIndex &deselected); void treeViewSelected(const QModelIndex &selected, const QModelIndex &deselected);
void loadInspector(CGObjectInstance * obj); void loadInspector(CGObjectInstance * obj);
void mapChanged();
private: private:
void preparePreview(const QModelIndex &index, bool createNew); void preparePreview(const QModelIndex &index, bool createNew);

View File

@ -14,7 +14,7 @@
#include "inspector.h" #include "inspector.h"
MapController::MapController() MapController::MapController(MainWindow * m): main(m)
{ {
_scenes[0].reset(new MapScene(0)); _scenes[0].reset(new MapScene(0));
_scenes[1].reset(new MapScene(1)); _scenes[1].reset(new MapScene(1));
@ -42,8 +42,8 @@ MapScene * MapController::scene(int level)
void MapController::setMap(std::unique_ptr<CMap> cmap) void MapController::setMap(std::unique_ptr<CMap> cmap)
{ {
_map = std::move(cmap); _map = std::move(cmap);
//_scenes[0].reset(new MapScene(0)); _scenes[0].reset(new MapScene(0));
//_scenes[1].reset(new MapScene(1)); _scenes[1].reset(new MapScene(1));
resetMapHandler(); resetMapHandler();
sceneForceUpdate(); sceneForceUpdate();
} }
@ -83,6 +83,8 @@ void MapController::commitTerrainChange(int level, const Terrain & terrain)
for(auto & t : v) for(auto & t : v)
_scenes[level]->terrainView.setDirty(t); _scenes[level]->terrainView.setDirty(t);
_scenes[level]->terrainView.draw(); _scenes[level]->terrainView.draw();
main->mapChanged();
} }
void MapController::commitObjectErase(int level) void MapController::commitObjectErase(int level)
@ -95,6 +97,8 @@ void MapController::commitObjectErase(int level)
_scenes[level]->selectionObjectsView.clear(); _scenes[level]->selectionObjectsView.clear();
resetMapHandler(); resetMapHandler();
_scenes[level]->updateViews(); _scenes[level]->updateViews();
main->mapChanged();
} }
bool MapController::discardObject(int level) const bool MapController::discardObject(int level) const
@ -144,6 +148,8 @@ void MapController::commitObstacleFill(int level)
resetMapHandler(); resetMapHandler();
_scenes[level]->updateViews(); _scenes[level]->updateViews();
main->mapChanged();
} }
void MapController::commitObjectChange(int level) void MapController::commitObjectChange(int level)
@ -151,12 +157,15 @@ void MapController::commitObjectChange(int level)
resetMapHandler(); resetMapHandler();
_scenes[level]->objectsView.draw(); _scenes[level]->objectsView.draw();
_scenes[level]->selectionObjectsView.draw(); _scenes[level]->selectionObjectsView.draw();
main->mapChanged();
} }
void MapController::commitChangeWithoutRedraw() void MapController::commitChangeWithoutRedraw()
{ {
//DO NOT REDRAW //DO NOT REDRAW
main->mapChanged();
} }
void MapController::commitObjectShiftOrCreate(int level) void MapController::commitObjectShiftOrCreate(int level)
@ -188,6 +197,8 @@ void MapController::commitObjectShiftOrCreate(int level)
resetMapHandler(); resetMapHandler();
_scenes[level]->updateViews(); _scenes[level]->updateViews();
main->mapChanged();
} }
void MapController::commitObjectCreate(int level) void MapController::commitObjectCreate(int level)
@ -197,4 +208,6 @@ void MapController::commitObjectCreate(int level)
return; return;
_map->getEditManager()->insertObject(newObj); _map->getEditManager()->insertObject(newObj);
Initializer init(newObj); Initializer init(newObj);
main->mapChanged();
} }

View File

@ -10,7 +10,7 @@ class MainWindow;
class MapController class MapController
{ {
public: public:
MapController(); MapController(MainWindow *);
MapController(const MapController &) = delete; MapController(const MapController &) = delete;
MapController(const MapController &&) = delete; MapController(const MapController &&) = delete;
~MapController(); ~MapController();
@ -40,6 +40,7 @@ public:
private: private:
std::unique_ptr<CMap> _map; std::unique_ptr<CMap> _map;
std::unique_ptr<MapHandler> _mapHandler; std::unique_ptr<MapHandler> _mapHandler;
MainWindow * main;
mutable std::array<std::unique_ptr<MapScene>, 2> _scenes; mutable std::array<std::unique_ptr<MapScene>, 2> _scenes;
}; };

View File

@ -2,6 +2,7 @@
#include "playersettings.h" #include "playersettings.h"
#include "ui_playersettings.h" #include "ui_playersettings.h"
#include "playerparams.h" #include "playerparams.h"
#include "mainwindow.h"
PlayerSettings::PlayerSettings(CMapHeader & mapHeader, QWidget *parent) : PlayerSettings::PlayerSettings(CMapHeader & mapHeader, QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -35,8 +36,7 @@ PlayerSettings::~PlayerSettings()
void PlayerSettings::on_playersCount_currentIndexChanged(int index) void PlayerSettings::on_playersCount_currentIndexChanged(int index)
{ {
assert(index + 2 == paramWidgets.size()); assert(index + 2 <= header.players.size());
assert(index + 2 < header.players.size());
for(int i = 0; i < index + 2; ++i) for(int i = 0; i < index + 2; ++i)
{ {
@ -69,6 +69,7 @@ void PlayerSettings::on_pushButton_clicked()
header.players[w->playerColor] = w->playerInfo; header.players[w->playerColor] = w->playerInfo;
} }
static_cast<MainWindow*>(parent())->controller.commitChangeWithoutRedraw();
close(); close();
} }