diff --git a/mapeditor/Animation.cpp b/mapeditor/Animation.cpp index f21e33b10..ec0567086 100644 --- a/mapeditor/Animation.cpp +++ b/mapeditor/Animation.cpp @@ -1,5 +1,5 @@ /* - * CAnimation.cpp, part of VCMI engine + * Animation.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * @@ -19,8 +19,6 @@ typedef std::map> source_map; -//typedef std::map image_map; -//typedef std::map group_map; /// Class for def loading /// After loading will store general info (palette and frame offsets) and pointer to file itself @@ -102,11 +100,11 @@ public: { for(auto & file : cache) { - if (file.name == rid) + if(file.name == rid) return file.getCopy(); } // Still here? Cache miss - if (cache.size() > cacheSize) + if(cache.size() > cacheSize) cache.pop_front(); auto data = CResourceHandler::get()->load(rid)->readAll(); @@ -173,12 +171,12 @@ DefFile::DefFile(std::string Name): int it = 0; ui32 type = read_le_u32(data.get() + it); - it+=4; + it += 4; //int width = read_le_u32(data + it); it+=4;//not used //int height = read_le_u32(data + it); it+=4; - it+=8; + it += 8; ui32 totalBlocks = read_le_u32(data.get() + it); - it+=4; + it += 4; for (ui32 i= 0; i<256; i++) { @@ -467,7 +465,7 @@ inline void ImageLoader::Load(size_t size, const ui8 * data) inline void ImageLoader::Load(size_t size, ui8 color) { - if (size) + if(size) { memset((void *)position, color, size); position += size; @@ -482,9 +480,6 @@ inline void ImageLoader::EndLine() ImageLoader::~ImageLoader() { - //SDL_UnlockSurface(image->surf); - //SDL_SetColorKey(image->surf, SDL_TRUE, 0); - //TODO: RLE if compressed and bpp>1 } /************************************************************************* @@ -494,14 +489,14 @@ ImageLoader::~ImageLoader() std::shared_ptr Animation::getFromExtraDef(std::string filename) { size_t pos = filename.find(':'); - if (pos == -1) + if(pos == -1) return nullptr; Animation anim(filename.substr(0, pos)); pos++; size_t frame = atoi(filename.c_str()+pos); size_t group = 0; pos = filename.find(':', pos); - if (pos != -1) + if(pos != -1) { pos++; group = frame; @@ -548,12 +543,7 @@ bool Animation::loadFrame(size_t frame, size_t group) } else //load from separate file { - auto img = getFromExtraDef(source[group][frame]["file"].String()); - //if(!img) - - //img = std::make_shared(source[group][frame]); - - images[group][frame] = img; + images[group][frame] = getFromExtraDef(source[group][frame]["file"].String());; return true; } return false; @@ -583,6 +573,7 @@ void Animation::init() source[defEntry.first].resize(defEntry.second); } +#if 0 //this code is not used but maybe requred if there will be configurable sprites ResourceID resID(std::string("SPRITES/") + name, EResType::TEXT); //if(vstd::contains(graphics->imageLists, resID.getName())) @@ -600,6 +591,7 @@ void Animation::init() //initFromJson(config); } +#endif } void Animation::printError(size_t frame, size_t group, std::string type) const @@ -613,7 +605,7 @@ Animation::Animation(std::string Name): defFile() { size_t dotPos = name.find_last_of('.'); - if ( dotPos!=-1 ) + if( dotPos!=-1 ) name.erase(dotPos); std::transform(name.begin(), name.end(), name.begin(), toupper); @@ -671,7 +663,7 @@ void Animation::duplicateImage(const size_t sourceGroup, const size_t sourceFram void Animation::setCustom(std::string filename, size_t frame, size_t group) { - if (source[group].size() <= frame) + if(source[group].size() <= frame) source[group].resize(frame+1); source[group][frame]["file"].String() = filename; //FIXME: update image if already loaded @@ -680,13 +672,13 @@ void Animation::setCustom(std::string filename, size_t frame, size_t group) std::shared_ptr Animation::getImage(size_t frame, size_t group, bool verbose) const { auto groupIter = images.find(group); - if (groupIter != images.end()) + if(groupIter != images.end()) { auto imageIter = groupIter->second.find(frame); - if (imageIter != groupIter->second.end()) + if(imageIter != groupIter->second.end()) return imageIter->second; } - if (verbose) + if(verbose) printError(frame, group, "GetImage"); return nullptr; } @@ -717,14 +709,14 @@ void Animation::preload() void Animation::loadGroup(size_t group) { - if (vstd::contains(source, group)) + if(vstd::contains(source, group)) for (size_t image=0; image < source[group].size(); image++) loadFrame(image, group); } void Animation::unloadGroup(size_t group) { - if (vstd::contains(source, group)) + if(vstd::contains(source, group)) for (size_t image=0; image < source[group].size(); image++) unloadFrame(image, group); } @@ -742,7 +734,7 @@ void Animation::unload(size_t frame, size_t group) size_t Animation::size(size_t group) const { auto iter = source.find(group); - if (iter != source.end()) + if(iter != source.end()) return iter->second.size(); return 0; } @@ -763,9 +755,11 @@ void Animation::verticalFlip() void Animation::playerColored(PlayerColor player) { - //for(auto & group : images) - //for(auto & image : group.second) - //image.second->playerColored(player); +#if 0 //can be required in image preview? + for(auto & group : images) + for(auto & image : group.second) + image.second->playerColored(player); +#endif } void Animation::createFlippedGroup(const size_t sourceGroup, const size_t targetGroup) diff --git a/mapeditor/Animation.h b/mapeditor/Animation.h index cc5c84a3f..e4212e67c 100644 --- a/mapeditor/Animation.h +++ b/mapeditor/Animation.h @@ -1,5 +1,13 @@ -#ifndef ANIMATION_H -#define ANIMATION_H +/* + * Animation.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 "../lib/JsonNode.h" #include "../lib/GameConstants.h" @@ -57,12 +65,12 @@ public: // adjust the color of the animation, used in battle spell effects, e.g. Cloned objects //add custom surface to the selected position. - void setCustom(std::string filename, size_t frame, size_t group=0); + void setCustom(std::string filename, size_t frame, size_t group = 0); - std::shared_ptr getImage(size_t frame, size_t group=0, bool verbose=true) const; + std::shared_ptr getImage(size_t frame, size_t group = 0, bool verbose = true) const; //all available frames - void load (); + void load(); void unload(); void preload(); @@ -71,11 +79,11 @@ public: void unloadGroup(size_t group); //single image - void load (size_t frame, size_t group=0); - void unload(size_t frame, size_t group=0); + void load (size_t frame, size_t group = 0); + void unload(size_t frame, size_t group = 0); //total count of frames in group (including not loaded) - size_t size(size_t group=0) const; + size_t size(size_t group = 0) const; void horizontalFlip(); void verticalFlip(); @@ -83,5 +91,3 @@ public: void createFlippedGroup(const size_t sourceGroup, const size_t targetGroup); }; - -#endif // ANIMATION_H diff --git a/mapeditor/BitmapHandler.cpp b/mapeditor/BitmapHandler.cpp index e3c1eed37..c91ff0e93 100644 --- a/mapeditor/BitmapHandler.cpp +++ b/mapeditor/BitmapHandler.cpp @@ -1,9 +1,12 @@ -// -// BitmapHandler.cpp -// vcmieditor -// -// Created by nordsoft on 29.08.2022. -// +/* + * BitmapHandler.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 "BitmapHandler.h" @@ -17,14 +20,14 @@ namespace BitmapHandler { QImage loadH3PCX(ui8 * data, size_t size); - QImage loadBitmapFromDir(std::string path, std::string fname, bool setKey=true); + QImage loadBitmapFromDir(const std::string & path, const std::string & fname, bool setKey=true); - bool isPCX(const ui8 *header)//check whether file can be PCX according to header + bool isPCX(const ui8 * header)//check whether file can be PCX according to header { ui32 fSize = read_le_u32(header + 0); ui32 width = read_le_u32(header + 4); ui32 height = read_le_u32(header + 8); - return fSize == width*height || fSize == width*height*3; + return fSize == width * height || fSize == width * height * 3; } enum Epcxformat @@ -38,22 +41,22 @@ namespace BitmapHandler //SDL_Surface * ret; Epcxformat format; - int it=0; + int it = 0; - ui32 fSize = read_le_u32(pcx + it); it+=4; - ui32 width = read_le_u32(pcx + it); it+=4; - ui32 height = read_le_u32(pcx + it); it+=4; + ui32 fSize = read_le_u32(pcx + it); it += 4; + ui32 width = read_le_u32(pcx + it); it += 4; + ui32 height = read_le_u32(pcx + it); it += 4; - if (fSize==width*height*3) + if(fSize==width*height*3) format=PCX24B; - else if (fSize==width*height) + else if(fSize==width*height) format=PCX8B; else return QImage(); QSize qsize(width, height); - if (format==PCX8B) + if(format==PCX8B) { it = 0xC; //auto bitmap = QBitmap::fromData(qsize, pcx + it); @@ -61,8 +64,8 @@ namespace BitmapHandler //palette - last 256*3 bytes QVector colorTable; - it = (int)size-256*3; - for (int i=0;i<256;i++) + it = (int)size - 256 * 3; + for(int i = 0; i < 256; i++) { char bytes[3]; bytes[0] = pcx[it++]; @@ -80,14 +83,14 @@ namespace BitmapHandler } } - QImage loadBitmapFromDir(std::string path, std::string fname, bool setKey) + QImage loadBitmapFromDir(const std::string & path, const std::string & fname, bool setKey) { if(!fname.size()) { logGlobal->warn("Call to loadBitmap with void fname!"); return QImage(); } - if (!CResourceHandler::get()->existsResource(ResourceID(path + fname, EResType::IMAGE))) + if(!CResourceHandler::get()->existsResource(ResourceID(path + fname, EResType::IMAGE))) { return QImage(); } @@ -95,7 +98,7 @@ namespace BitmapHandler auto fullpath = CResourceHandler::get()->getResourceName(ResourceID(path + fname, EResType::IMAGE)); auto readFile = CResourceHandler::get()->load(ResourceID(path + fname, EResType::IMAGE))->readAll(); - if (isPCX(readFile.first.get())) + if(isPCX(readFile.first.get())) {//H3-style PCX auto image = BitmapHandler::loadH3PCX(readFile.first.get(), readFile.second); if(!image.isNull()) @@ -134,26 +137,13 @@ namespace BitmapHandler } } return QImage(); - // When modifying anything here please check two use cases: + // When modifying anything here please check use cases: // 1) Vampire mansion in Necropolis (not 1st color is transparent) // 2) Battle background when fighting on grass/dirt, topmost sky part (NO transparent color) // 3) New objects that may use 24-bit images for icons (e.g. witchking arts) - /*if (ret->format->palette) - { - CSDL_Ext::setDefaultColorKeyPresize(ret); - } - else if (ret->format->Amask) - { - SDL_SetSurfaceBlendMode(ret, SDL_BLENDMODE_BLEND); - } - else // always set - { - CSDL_Ext::setDefaultColorKey(ret); - } - return ret;*/ } - QImage loadBitmap(std::string fname, bool setKey) + QImage loadBitmap(const std::string & fname, bool setKey) { QImage image = loadBitmapFromDir("DATA/", fname, setKey); if(image.isNull()) diff --git a/mapeditor/BitmapHandler.h b/mapeditor/BitmapHandler.h index bd8c307ff..1351e5d01 100644 --- a/mapeditor/BitmapHandler.h +++ b/mapeditor/BitmapHandler.h @@ -1,10 +1,12 @@ -// -// BitmapHandler.hpp -// vcmieditor -// -// Created by nordsoft on 29.08.2022. -// - +/* + * BitmapHandler.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 #define read_le_u16(p) (* reinterpret_cast(p)) @@ -15,6 +17,6 @@ namespace BitmapHandler { //Load file from /DATA or /SPRITES - QImage loadBitmap(std::string fname, bool setKey=true); + QImage loadBitmap(const std::string & fname, bool setKey = true); } diff --git a/mapeditor/CMakeLists.txt b/mapeditor/CMakeLists.txt index bd9cda0e5..27fbe7b28 100644 --- a/mapeditor/CMakeLists.txt +++ b/mapeditor/CMakeLists.txt @@ -4,16 +4,13 @@ set(editor_SRCS launcherdirs.cpp jsonutils.cpp mainwindow.cpp - CGameInfo.cpp BitmapHandler.cpp maphandler.cpp Animation.cpp graphics.cpp - spoiler.cpp windownewmap.cpp generatorprogress.cpp mapview.cpp - radiopushbutton.cpp objectbrowser.cpp mapsettings.cpp playersettings.cpp @@ -33,16 +30,13 @@ set(editor_HEADERS launcherdirs.h jsonutils.h mainwindow.h - CGameInfo.h BitmapHandler.h maphandler.h Animation.h graphics.h - spoiler.h windownewmap.h generatorprogress.h mapview.h - radiopushbutton.h objectbrowser.h mapsettings.h playersettings.h diff --git a/mapeditor/generatorprogress.cpp b/mapeditor/generatorprogress.cpp index e482220a3..659f655b8 100644 --- a/mapeditor/generatorprogress.cpp +++ b/mapeditor/generatorprogress.cpp @@ -1,3 +1,12 @@ +/* + * generatorprogress.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 "generatorprogress.h" #include "ui_generatorprogress.h" diff --git a/mapeditor/generatorprogress.h b/mapeditor/generatorprogress.h index b693509a9..c38cf8229 100644 --- a/mapeditor/generatorprogress.h +++ b/mapeditor/generatorprogress.h @@ -1,5 +1,13 @@ -#ifndef GENERATORPROGRESS_H -#define GENERATORPROGRESS_H +/* + * generatorprogress.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 #include "../lib/LoadProgress.h" @@ -22,5 +30,3 @@ private: Ui::GeneratorProgress *ui; Load::Progress & source; }; - -#endif // GENERATORPROGRESS_H diff --git a/mapeditor/graphics.cpp b/mapeditor/graphics.cpp index 71e462547..8cf1e47da 100644 --- a/mapeditor/graphics.cpp +++ b/mapeditor/graphics.cpp @@ -33,7 +33,6 @@ #include "../lib/mapObjects/CObjectClassesHandler.h" #include "../lib/mapObjects/CObjectHandler.h" #include "../lib/CHeroHandler.h" -#include "CGameInfo.h" Graphics * graphics = nullptr; @@ -45,7 +44,7 @@ void Graphics::loadPaletteAndColors() playerColorPalette.resize(256); playerColors.resize(PlayerColor::PLAYER_LIMIT_I); int startPoint = 24; //beginning byte; used to read - for(int i=0; i<256; ++i) + for(int i = 0; i < 256; ++i) { QColor col; col.setRed(pals[startPoint++]); @@ -61,7 +60,7 @@ void Graphics::loadPaletteAndColors() auto stream = CResourceHandler::get()->load(ResourceID("config/NEUTRAL.PAL")); CBinaryReader reader(stream.get()); - for(int i=0; i<32; ++i) + for(int i = 0; i < 32; ++i) { QColor col; col.setRed(reader.readUInt8()); @@ -95,7 +94,6 @@ void Graphics::loadPaletteAndColors() Graphics::Graphics() { #if 0 - std::vector tasks; //preparing list of graphics to load tasks += std::bind(&Graphics::loadFonts,this); tasks += std::bind(&Graphics::loadPaletteAndColors,this); @@ -125,11 +123,11 @@ void Graphics::load() void Graphics::loadHeroAnimations() { - for(auto & elem : CGI->heroh->classes.objects) + for(auto & elem : VLC->heroh->classes.objects) { - for (auto templ : VLC->objtypeh->getHandlerFor(Obj::HERO, elem->getIndex())->getTemplates()) + for(auto templ : VLC->objtypeh->getHandlerFor(Obj::HERO, elem->getIndex())->getTemplates()) { - if (!heroAnimations.count(templ->animationFile)) + if(!heroAnimations.count(templ->animationFile)) heroAnimations[templ->animationFile] = loadHeroAnimation(templ->animationFile); } } @@ -244,39 +242,6 @@ void Graphics::blueToPlayersAdv(QImage * sur, PlayerColor player) //FIXME: not all player colored images have player palette at last 32 indexes //NOTE: following code is much more correct but still not perfect (bugged with status bar) sur->setColorTable(palette); - -#if 0 - - SDL_Color * bluePalette = playerColorPalette + 32; - - SDL_Palette * oldPalette = sur->format->palette; - - SDL_Palette * newPalette = SDL_AllocPalette(256); - - for(size_t destIndex = 0; destIndex < 256; destIndex++) - { - SDL_Color old = oldPalette->colors[destIndex]; - - bool found = false; - - for(size_t srcIndex = 0; srcIndex < 32; srcIndex++) - { - if(old.b == bluePalette[srcIndex].b && old.g == bluePalette[srcIndex].g && old.r == bluePalette[srcIndex].r) - { - found = true; - newPalette->colors[destIndex] = palette[srcIndex]; - break; - } - } - if(!found) - newPalette->colors[destIndex] = old; - } - - SDL_SetSurfacePalette(sur, newPalette); - - SDL_FreePalette(newPalette); - -#endif // 0 } else { @@ -369,10 +334,10 @@ void Graphics::addImageListEntries(const EntityService * service) void Graphics::initializeImageLists() { - addImageListEntries(CGI->creatures()); - addImageListEntries(CGI->heroTypes()); - addImageListEntries(CGI->artifacts()); - addImageListEntries(CGI->factions()); - addImageListEntries(CGI->spells()); - addImageListEntries(CGI->skills()); + addImageListEntries(VLC->creatures()); + addImageListEntries(VLC->heroTypes()); + addImageListEntries(VLC->artifacts()); + addImageListEntries(VLC->factions()); + addImageListEntries(VLC->spells()); + addImageListEntries(VLC->skills()); } diff --git a/mapeditor/inspector/armywidget.cpp b/mapeditor/inspector/armywidget.cpp index e171a009d..8027356dc 100644 --- a/mapeditor/inspector/armywidget.cpp +++ b/mapeditor/inspector/armywidget.cpp @@ -20,7 +20,6 @@ ArmyWidget::ArmyWidget(CArmedInstance & a, QWidget *parent) : for(int i = 0; i < TOTAL_SLOTS; ++i) { - uiCounts[i]->setInputMask("d0000"); uiCounts[i]->setText("1"); uiSlots[i]->addItem(""); uiSlots[i]->setItemData(0, -1); diff --git a/mapeditor/inspector/inspector.cpp b/mapeditor/inspector/inspector.cpp index 2084d97e1..6819bcd03 100644 --- a/mapeditor/inspector/inspector.cpp +++ b/mapeditor/inspector/inspector.cpp @@ -100,6 +100,9 @@ void Initializer::initialize(CGHeroInstance * o) if(!o) return; o->tempOwner = defaultPlayer; + if(o->ID == Obj::PRISON) + o->tempOwner = PlayerColor::NEUTRAL; + if(o->ID == Obj::HERO) { for(auto t : VLC->heroh->objects) @@ -437,13 +440,13 @@ void Inspector::setProperty(CGEvent * o, const QString & key, const QVariant & v { if(!o) return; - if("Remove after") + if(key == "Remove after") o->removeAfterVisit = stringToBool(value.toString()); - if("Human trigger") + if(key == "Human trigger") o->humanActivate = stringToBool(value.toString()); - if("Cpu trigger") + if(key == "Cpu trigger") o->computerActivate = stringToBool(value.toString()); } diff --git a/mapeditor/mainwindow.cpp b/mapeditor/mainwindow.cpp index 9c8ae91a5..4f2ae37a1 100644 --- a/mapeditor/mainwindow.cpp +++ b/mapeditor/mainwindow.cpp @@ -1,3 +1,13 @@ +/* + * mainwindow.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 "mainwindow.h" #include "ui_mainwindow.h" @@ -20,8 +30,6 @@ #include "../lib/mapObjects/CObjectClassesHandler.h" #include "../lib/filesystem/CFilesystemLoader.h" - -#include "CGameInfo.h" #include "maphandler.h" #include "graphics.h" #include "windownewmap.h" @@ -52,9 +60,7 @@ QPixmap pixmapFromJson(const QJsonValue &val) void init() { - loadDLLClasses(); - const_cast(CGI)->setFromLib(); logGlobal->info("Initializing VCMI_Lib"); } @@ -129,7 +135,6 @@ MainWindow::MainWindow(QWidget *parent) : conf.init(); logGlobal->info("Loading settings"); - CGI = new CGameInfo(); //contains all global informations about game (texts, lodHandlers, map handler etc.) init(); graphics = new Graphics(); // should be before curh->init() @@ -141,9 +146,6 @@ MainWindow::MainWindow(QWidget *parent) : QApplication::quit(); } - //now let's try to draw - //auto resPath = *CResourceHandler::get()->getResourceName(ResourceID("DATA/new-menu/Background.png")); - ui->mapView->setScene(controller.scene(0)); ui->mapView->setController(&controller); ui->mapView->setOptimizationFlags(QGraphicsView::DontSavePainterState | QGraphicsView::DontAdjustForAntialiasing); @@ -156,14 +158,12 @@ MainWindow::MainWindow(QWidget *parent) : scenePreview = new QGraphicsScene(this); ui->objectPreview->setScene(scenePreview); - //scenes[0]->addPixmap(QPixmap(QString::fromStdString(resPath.native()))); - //loading objects loadObjectsTree(); ui->tabWidget->setCurrentIndex(0); - for(int i = 0; i < 8; ++i) + for(int i = 0; i < PlayerColor::PLAYER_LIMIT.getNum(); ++i) { connect(getActionPlayer(PlayerColor(i)), &QAction::toggled, this, [&, i](){switchDefaultPlayer(PlayerColor(i));}); } @@ -733,7 +733,7 @@ void MainWindow::on_actionGrid_triggered(bool checked) if(controller.map()) { controller.scene(0)->gridView.show(checked); - controller.scene(0)->gridView.show(checked); + controller.scene(1)->gridView.show(checked); } } diff --git a/mapeditor/mainwindow.h b/mapeditor/mainwindow.h index 143c91555..e12b163fb 100644 --- a/mapeditor/mainwindow.h +++ b/mapeditor/mainwindow.h @@ -1,5 +1,4 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H +#pragma once #include #include @@ -131,7 +130,7 @@ private: void saveUserSettings(); private: - Ui::MainWindow *ui; + Ui::MainWindow * ui; ObjectBrowser * objectBrowser = nullptr; QGraphicsScene * scenePreview; @@ -144,5 +143,3 @@ private: std::set catalog; }; - -#endif // MAINWINDOW_H diff --git a/mapeditor/mapcontroller.cpp b/mapeditor/mapcontroller.cpp index 00a47c315..9b3a30b30 100644 --- a/mapeditor/mapcontroller.cpp +++ b/mapeditor/mapcontroller.cpp @@ -109,6 +109,7 @@ void MapController::repairMap() dynamic_cast(obj.get()) || dynamic_cast(obj.get()) || dynamic_cast(obj.get()) || + dynamic_cast(obj.get()) || dynamic_cast(obj.get())) obj->tempOwner = PlayerColor::NEUTRAL; } @@ -454,9 +455,6 @@ void MapController::commitObjectCreate(int level) bool MapController::canPlaceObject(int level, CGObjectInstance * newObj, QString & error) const { - //need this because of possible limits - auto rmgInfo = VLC->objtypeh->getHandlerFor(newObj->ID, newObj->subID)->getRMGInfo(); - //find all objects of such type int objCounter = 0; for(auto o : _map->objects) @@ -467,30 +465,20 @@ bool MapController::canPlaceObject(int level, CGObjectInstance * newObj, QString } } - if((rmgInfo.mapLimit && objCounter >= rmgInfo.mapLimit) - || (newObj->ID == Obj::GRAIL && objCounter >= 1)) //special case for grail + if(newObj->ID == Obj::GRAIL && objCounter >= 1) //special case for grail { auto typeName = QString::fromStdString(newObj->typeName); auto subTypeName = QString::fromStdString(newObj->subTypeName); - error = QString("Reached map limit for object %1 - %2").arg(typeName, subTypeName); + error = QString("There can be only one grail object on the map"); return false; //maplimit reached } + if(defaultPlayer == PlayerColor::NEUTRAL && (newObj->ID == Obj::HERO || newObj->ID == Obj::RANDOM_HERO)) { error = "Hero cannot be created as NEUTRAL"; return false; } - if(defaultPlayer != PlayerColor::NEUTRAL && newObj->ID == Obj::PRISON) - { - error = "Prison must be a NEUTRAL"; - return false; - } - if(newObj->ID == Obj::ARTIFACT && !_map->allowedArtifact.at(newObj->subID)) - { - error = "Artifact is not allowed. Check map settings."; - return false; - } return true; } diff --git a/mapeditor/mapcontroller.h b/mapeditor/mapcontroller.h index 09fbc5d6c..f394cb483 100644 --- a/mapeditor/mapcontroller.h +++ b/mapeditor/mapcontroller.h @@ -1,5 +1,4 @@ -#ifndef MAPCONTROLLER_H -#define MAPCONTROLLER_H +#pragma once #include "maphandler.h" #include "mapview.h" @@ -58,5 +57,3 @@ private: void connectScenes(); }; - -#endif // MAPCONTROLLER_H diff --git a/mapeditor/maphandler.cpp b/mapeditor/maphandler.cpp index c14286a75..2e57b921c 100644 --- a/mapeditor/maphandler.cpp +++ b/mapeditor/maphandler.cpp @@ -382,7 +382,6 @@ void MapHandler::drawObjectAt(QPainter & painter, const CGObjectInstance * obj, uint8_t animationFrame = 0; auto objData = findObjectBitmap(obj, animationFrame, obj->ID == Obj::HERO ? 2 : 0); - std::vector> debugFlagImages; if(obj->ID == Obj::HERO && obj->tempOwner.isValidPlayer()) objData.flagBitmap = findFlagBitmap(dynamic_cast(obj), 0, obj->tempOwner, 4); diff --git a/mapeditor/maphandler.h b/mapeditor/maphandler.h index 39423df02..3887e0278 100644 --- a/mapeditor/maphandler.h +++ b/mapeditor/maphandler.h @@ -1,5 +1,4 @@ -#ifndef MAPHANDLER_H -#define MAPHANDLER_H +#pragma once #include "StdInc.h" #include "../lib/mapping/CMap.h" @@ -103,5 +102,3 @@ public: static bool compareObjectBlitOrder(const CGObjectInstance * a, const CGObjectInstance * b); }; - -#endif // MAPHANDLER_H diff --git a/mapeditor/mapsettings.h b/mapeditor/mapsettings.h index 07e1119ac..fd5b996a5 100644 --- a/mapeditor/mapsettings.h +++ b/mapeditor/mapsettings.h @@ -1,5 +1,4 @@ -#ifndef MAPSETTINGS_H -#define MAPSETTINGS_H +#pragma once #include #include "mapcontroller.h" @@ -23,5 +22,3 @@ private: Ui::MapSettings *ui; MapController & controller; }; - -#endif // MAPSETTINGS_H diff --git a/mapeditor/mapview.cpp b/mapeditor/mapview.cpp index ef5c4e9b9..2881ac000 100644 --- a/mapeditor/mapview.cpp +++ b/mapeditor/mapview.cpp @@ -81,7 +81,8 @@ void MapView::mouseMoveEvent(QMouseEvent *mouseEvent) tilePrev = tile; - //main->setStatusMessage(QString("x: %1 y: %2").arg(QString::number(pos.x()), QString::number(pos.y()))); + //TODO: cast parent->parent to MainWindow in order to show coordinates or another way to do it? + //main->setStatusMessage(QString("x: %1 y: %2").arg(tile.x, tile.y)); switch(selectionTool) { diff --git a/mapeditor/mapview.h b/mapeditor/mapview.h index 3262f0f42..e146eb627 100644 --- a/mapeditor/mapview.h +++ b/mapeditor/mapview.h @@ -1,5 +1,4 @@ -#ifndef MAPVIEW_H -#define MAPVIEW_H +#pragma once #include #include @@ -129,5 +128,3 @@ private: int displayWidth = 192; int displayHeight = 192; }; - -#endif // MAPVIEW_H diff --git a/mapeditor/objectbrowser.h b/mapeditor/objectbrowser.h index 87ac744b8..748407e7d 100644 --- a/mapeditor/objectbrowser.h +++ b/mapeditor/objectbrowser.h @@ -1,5 +1,4 @@ -#ifndef OBJECTBROWSER_H -#define OBJECTBROWSER_H +#pragma once #include #include "../lib/Terrain.h" @@ -16,5 +15,3 @@ protected: bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override; bool filterAcceptsRowText(int source_row, const QModelIndex &source_parent) const; }; - -#endif // OBJECTBROWSER_H diff --git a/mapeditor/playerparams.h b/mapeditor/playerparams.h index 4219bdafb..cf6d9e4f2 100644 --- a/mapeditor/playerparams.h +++ b/mapeditor/playerparams.h @@ -1,5 +1,4 @@ -#ifndef PLAYERPARAMS_H -#define PLAYERPARAMS_H +#pragma once #include #include "../lib/mapping/CMap.h" @@ -38,5 +37,3 @@ private: MapController & controller; }; - -#endif // PLAYERPARAMS_H diff --git a/mapeditor/playersettings.h b/mapeditor/playersettings.h index d6fab335f..14236daf4 100644 --- a/mapeditor/playersettings.h +++ b/mapeditor/playersettings.h @@ -1,5 +1,4 @@ -#ifndef PLAYERSETTINGS_H -#define PLAYERSETTINGS_H +#pragma once #include "StdInc.h" #include @@ -30,5 +29,3 @@ private: MapController & controller; }; - -#endif // PLAYERSETTINGS_H diff --git a/mapeditor/scenelayer.h b/mapeditor/scenelayer.h index fc1b236ea..70bcd7748 100644 --- a/mapeditor/scenelayer.h +++ b/mapeditor/scenelayer.h @@ -1,5 +1,4 @@ -#ifndef SCENELAYER_H -#define SCENELAYER_H +#pragma once #include "../lib/int3.h" @@ -174,5 +173,3 @@ private: int x = 0, y = 0, w = 1, h = 1; }; - -#endif // SCENELAYER_H diff --git a/mapeditor/validator.h b/mapeditor/validator.h index 26955c1b2..df9357c59 100644 --- a/mapeditor/validator.h +++ b/mapeditor/validator.h @@ -1,5 +1,4 @@ -#ifndef VALIDATOR_H -#define VALIDATOR_H +#pragma once #include #include "../lib/mapping/CMap.h" @@ -29,5 +28,3 @@ public: private: Ui::Validator *ui; }; - -#endif // VALIDATOR_H diff --git a/mapeditor/windownewmap.h b/mapeditor/windownewmap.h index db1f5de4a..bd780727d 100644 --- a/mapeditor/windownewmap.h +++ b/mapeditor/windownewmap.h @@ -1,5 +1,4 @@ -#ifndef WINDOWNEWMAP_H -#define WINDOWNEWMAP_H +#pragma once #include #include "../lib/rmg/CMapGenOptions.h" @@ -91,5 +90,3 @@ private: CMapGenOptions mapGenOptions; bool randomMap = false; }; - -#endif // WINDOWNEWMAP_H