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

Minor fixes

This commit is contained in:
nordsoft 2022-09-05 05:50:21 +04:00
parent eb501f2222
commit 5839ba4ce8
7 changed files with 38 additions and 37 deletions

View File

@ -124,7 +124,7 @@ void CMapGenerator::initQuestArtsRemaining()
}
}
std::unique_ptr<CMap> CMapGenerator::generate(bool empty)
std::unique_ptr<CMap> CMapGenerator::generate()
{
Load::Progress::reset();
Load::Progress::stepsTill(5, 30);
@ -132,11 +132,6 @@ std::unique_ptr<CMap> CMapGenerator::generate(bool empty)
{
addHeaderInfo();
map->initTiles(*this);
if(empty)
{
Progress::Progress::finish();
return std::move(map->mapInstance);
}
Load::Progress::step();
initPrisonsRemaining();
initQuestArtsRemaining();

View File

@ -57,7 +57,7 @@ public:
const CMapGenOptions& getMapGenOptions() const;
std::unique_ptr<CMap> generate(bool emptyMap = false);
std::unique_ptr<CMap> generate();
void disableModificator(const std::string & modificator);
void findZonesForQuestArts();

View File

@ -58,8 +58,7 @@ void init()
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
controller(this)
ui(new Ui::MainWindow)
{
ui->setupUi(this);
@ -132,8 +131,6 @@ MainWindow::MainWindow(QWidget *parent) :
loadObjectsTree();
show();
setStatusMessage("privet");
}
MainWindow::~MainWindow()
@ -166,14 +163,11 @@ void MainWindow::initializeMap(bool isNew)
filename.clear();
setWindowTitle(filename + "* - VCMI Map Editor");
// reloadMap();
//if(map->twoLevel)
//reloadMap(1);
mapLevel = 0;
ui->mapView->setScene(controller.scene(mapLevel));
setStatusMessage(QString("Scene objects: %1").arg(ui->mapView->scene()->items().size()));
//enable settings
ui->actionMapSettings->setEnabled(true);
@ -754,11 +748,13 @@ void MainWindow::on_inspectorWidget_itemChanged(QTableWidgetItem *item)
void MainWindow::on_actionMapSettings_triggered()
{
auto mapSettingsDialog = new MapSettings(controller, this);
mapSettingsDialog->setModal(true);
}
void MainWindow::on_actionPlayers_settings_triggered()
{
auto mapSettingsDialog = new PlayerSettings(*controller.map(), this);
mapSettingsDialog->setModal(true);
}

View File

@ -14,16 +14,14 @@
#include "inspector.h"
MapController::MapController(MainWindow * m) : _main(m)
MapController::MapController()
{
_scenes[0] = new MapScene(0);
_scenes[1] = new MapScene(1);
_scenes[0].reset(new MapScene(0));
_scenes[1].reset(new MapScene(1));
}
MapController::~MapController()
{
delete _scenes[0];
delete _scenes[1];
}
CMap * MapController::map()
@ -38,12 +36,14 @@ MapHandler * MapController::mapHandler()
MapScene * MapController::scene(int level)
{
return _scenes[level];
return _scenes[level].get();
}
void MapController::setMap(std::unique_ptr<CMap> cmap)
{
_map = std::move(cmap);
//_scenes[0].reset(new MapScene(0));
//_scenes[1].reset(new MapScene(1));
resetMapHandler();
sceneForceUpdate();
}
@ -149,7 +149,8 @@ void MapController::commitObstacleFill(int level)
void MapController::commitObjectChange(int level)
{
resetMapHandler();
_scenes[level]->updateViews();
_scenes[level]->objectsView.draw();
_scenes[level]->selectionObjectsView.draw();
}

View File

@ -10,7 +10,7 @@ class MainWindow;
class MapController
{
public:
MapController(MainWindow *);
MapController();
MapController(const MapController &) = delete;
MapController(const MapController &&) = delete;
~MapController();
@ -38,10 +38,9 @@ public:
void createObject(int level, CGObjectInstance * obj) const;
private:
MainWindow * _main;
std::unique_ptr<CMap> _map;
std::unique_ptr<MapHandler> _mapHandler;
mutable std::array<MapScene *, 2> _scenes;
mutable std::array<std::unique_ptr<MapScene>, 2> _scenes;
};
#endif // MAPCONTROLLER_H

View File

@ -35,7 +35,7 @@ PlayerSettings::~PlayerSettings()
void PlayerSettings::on_playersCount_currentIndexChanged(int index)
{
assert(index + 2 != paramWidgets.size());
assert(index + 2 == paramWidgets.size());
assert(index + 2 < header.players.size());
for(int i = 0; i < index + 2; ++i)

View File

@ -45,10 +45,9 @@ void WindowNewMap::on_cancelButton_clicked()
void generateRandomMap(CMapGenerator & gen, MainWindow * window)
{
window->controller.setMap(gen.generate());
//window->setMapRaw();
}
void generateEmptyMap(CMapGenOptions & options, MainWindow * window)
std::unique_ptr<CMap> generateEmptyMap(CMapGenOptions & options)
{
std::unique_ptr<CMap> map(new CMap);
map->version = EMapFormat::VCMI;
@ -61,7 +60,8 @@ void generateEmptyMap(CMapGenOptions & options, MainWindow * window)
map->getEditManager()->getTerrainSelection().selectRange(MapRect(int3(0, 0, 0), options.getWidth(), options.getHeight()));
map->getEditManager()->drawTerrain(Terrain("grass"), &CRandomGenerator::getDefault());
window->controller.setMap(std::move(map));
//window->controller.setMap(std::move(map));
return std::move(map);
}
void WindowNewMap::on_okButtong_clicked()
@ -87,7 +87,8 @@ void WindowNewMap::on_okButtong_clicked()
mapGenOptions.setWaterContent(water);
mapGenOptions.setMonsterStrength(monster);
std::unique_ptr<CMap> nmap;
if(ui->randomMapCheck->isChecked())
{
CMapGenerator generator(mapGenOptions);
@ -97,17 +98,26 @@ void WindowNewMap::on_okButtong_clicked()
auto progressBarWnd = new GeneratorProgress(generator, this);
progressBarWnd->show();
{
std::thread generate(&::generateRandomMap, std::ref(generator), static_cast<MainWindow*>(parent()));
progressBarWnd->update();
generate.join();
}
//std::thread generate(&::generateRandomMap, std::ref(generator), static_cast<MainWindow*>(parent()));
//progressBarWnd->update();
//generate.join();
//generateRandomMap(generator, static_cast<MainWindow*>(parent()));
auto f = std::async(std::launch::async, &CMapGenerator::generate, &generator);
progressBarWnd->update();
nmap = f.get();
}
else
{
generateEmptyMap(mapGenOptions, static_cast<MainWindow*>(parent()));
auto f = std::async(std::launch::async, &::generateEmptyMap, std::ref(mapGenOptions));
nmap = f.get();
//nmap = generateEmptyMap(mapGenOptions, static_cast<MainWindow*>(parent()));
}
static_cast<MainWindow*>(parent())->controller.setMap(std::move(nmap));
static_cast<MainWindow*>(parent())->initializeMap(true);
close();
}