Browse Source

Fix code review problems

nordsoft 3 years ago
parent
commit
d7de9accee

+ 31 - 35
mapeditor/inspector/rewardswidget.cpp

@@ -33,14 +33,14 @@ RewardsWidget::~RewardsWidget()
 	delete ui;
 }
 
-QList<QString> RewardsWidget::getListForType(int typeId)
+QList<QString> RewardsWidget::getListForType(RewardType typeId)
 {
 	assert(typeId < rewardTypes.size());
 	QList<QString> result;
 	
 	switch (typeId) {
-		case 4: //resources
-				//to convert string to index WOOD = 0, MERCURY, ORE, SULFUR, CRYSTAL, GEMS, GOLD, MITHRIL,
+		case RewardType::RESOURCE:
+			//to convert string to index WOOD = 0, MERCURY, ORE, SULFUR, CRYSTAL, GEMS, GOLD, MITHRIL,
 			result.append("Wood");
 			result.append("Mercury");
 			result.append("Ore");
@@ -50,13 +50,12 @@ QList<QString> RewardsWidget::getListForType(int typeId)
 			result.append("Gold");
 			break;
 			
-		case 5:
+		case RewardType::PRIMARY_SKILL:
 			for(auto s : PrimarySkill::names)
 				result.append(QString::fromStdString(s));
 			break;
 			
-		case 6:
-			//abilities
+		case RewardType::SECONDARY_SKILL:
 			for(int i = 0; i < map.allowedAbilities.size(); ++i)
 			{
 				if(map.allowedAbilities[i])
@@ -64,8 +63,7 @@ QList<QString> RewardsWidget::getListForType(int typeId)
 			}
 			break;
 			
-		case 7:
-			//arts
+		case RewardType::ARTIFACT:
 			for(int i = 0; i < map.allowedArtifact.size(); ++i)
 			{
 				if(map.allowedArtifact[i])
@@ -73,8 +71,7 @@ QList<QString> RewardsWidget::getListForType(int typeId)
 			}
 			break;
 			
-		case 8:
-			//spells
+		case RewardType::SPELL:
 			for(int i = 0; i < map.allowedSpell.size(); ++i)
 			{
 				if(map.allowedSpell[i])
@@ -82,8 +79,7 @@ QList<QString> RewardsWidget::getListForType(int typeId)
 			}
 			break;
 			
-		case 9:
-			//creatures
+		case RewardType::CREATURE:
 			for(auto creature : VLC->creh->objects)
 			{
 				result.append(QString::fromStdString(creature->getName()));
@@ -99,7 +95,7 @@ void RewardsWidget::on_rewardType_activated(int index)
 	ui->rewardList->setEnabled(true);
 	assert(index < rewardTypes.size());
 	
-	auto l = getListForType(index);
+	auto l = getListForType(RewardType(index));
 	if(l.empty())
 		ui->rewardList->setEnabled(false);
 	
@@ -112,40 +108,40 @@ void RewardsWidget::obtainData()
 	if(pandora)
 	{
 		if(pandora->gainedExp > 0)
-			addReward(0, 0, pandora->gainedExp);
+			addReward(RewardType::EXPERIENCE, 0, pandora->gainedExp);
 		if(pandora->manaDiff)
-			addReward(1, 0, pandora->manaDiff);
+			addReward(RewardType::MANA, 0, pandora->manaDiff);
 		if(pandora->moraleDiff)
-			addReward(2, 0, pandora->moraleDiff);
+			addReward(RewardType::MORALE, 0, pandora->moraleDiff);
 		if(pandora->luckDiff)
-			addReward(3, 0, pandora->luckDiff);
+			addReward(RewardType::LUCK, 0, pandora->luckDiff);
 		if(pandora->resources.nonZero())
 		{
 			for(Res::ResourceSet::nziterator resiter(pandora->resources); resiter.valid(); ++resiter)
-				addReward(4, resiter->resType, resiter->resVal);
+				addReward(RewardType::RESOURCE, resiter->resType, resiter->resVal);
 		}
 		for(int idx = 0; idx < pandora->primskills.size(); ++idx)
 		{
 			if(pandora->primskills[idx])
-				addReward(5, idx, pandora->primskills[idx]);
+				addReward(RewardType::PRIMARY_SKILL, idx, pandora->primskills[idx]);
 		}
 		assert(pandora->abilities.size() == pandora->abilityLevels.size());
 		for(int idx = 0; idx < pandora->abilities.size(); ++idx)
 		{
-			addReward(6, pandora->abilities[idx].getNum(), pandora->abilityLevels[idx]);
+			addReward(RewardType::SECONDARY_SKILL, pandora->abilities[idx].getNum(), pandora->abilityLevels[idx]);
 		}
 		for(auto art : pandora->artifacts)
 		{
-			addReward(7, art.getNum(), 1);
+			addReward(RewardType::ARTIFACT, art.getNum(), 1);
 		}
 		for(auto spell : pandora->spells)
 		{
-			addReward(8, spell.getNum(), 1);
+			addReward(RewardType::SPELL, spell.getNum(), 1);
 		}
 		for(int i = 0; i < pandora->creatures.Slots().size(); ++i)
 		{
 			if(auto c = pandora->creatures.getCreature(SlotID(i)))
-				addReward(9, c->getId(), pandora->creatures.getStackCount(SlotID(i)));
+				addReward(RewardType::CREATURE, c->getId(), pandora->creatures.getStackCount(SlotID(i)));
 		}
 	}
 }
@@ -171,44 +167,44 @@ bool RewardsWidget::commitChanges()
 			int amount = ui->rewardsTable->item(row, 2)->data(Qt::UserRole).toInt();
 			switch(typeId)
 			{
-				case 0:
+				case RewardType::EXPERIENCE:
 					pandora->gainedExp = amount;
 					break;
 					
-				case 1:
+				case RewardType::MANA:
 					pandora->manaDiff = amount;
 					break;
 					
-				case 2:
+				case RewardType::MORALE:
 					pandora->moraleDiff = amount;
 					break;
 					
-				case 3:
+				case RewardType::LUCK:
 					pandora->luckDiff = amount;
 					break;
 					
-				case 4:
+				case RewardType::RESOURCE:
 					pandora->resources.at(listId) = amount;
 					break;
 					
-				case 5:
+				case RewardType::PRIMARY_SKILL:
 					pandora->primskills[listId] = amount;
 					break;
 					
-				case 6:
+				case RewardType::SECONDARY_SKILL:
 					pandora->abilities.push_back(SecondarySkill(listId));
 					pandora->abilityLevels.push_back(amount);
 					break;
 					
-				case 7:
+				case RewardType::ARTIFACT:
 					pandora->artifacts.push_back(ArtifactID(listId));
 					break;
 					
-				case 8:
+				case RewardType::SPELL:
 					pandora->spells.push_back(SpellID(listId));
 					break;
 					
-				case 9:
+				case RewardType::CREATURE:
 					auto slot = pandora->creatures.getFreeSlot();
 					if(slot != SlotID() && amount > 0)
 						pandora->creatures.addToSlot(slot, CreatureID(listId), amount);
@@ -224,7 +220,7 @@ void RewardsWidget::on_rewardList_activated(int index)
 	ui->rewardAmount->setText(QStringLiteral("1"));
 }
 
-void RewardsWidget::addReward(int typeId, int listId, int amount)
+void RewardsWidget::addReward(RewardsWidget::RewardType typeId, int listId, int amount)
 {
 	ui->rewardsTable->setRowCount(++rewards);
 	
@@ -266,7 +262,7 @@ void RewardsWidget::addReward(int typeId, int listId, int amount)
 
 void RewardsWidget::on_buttonAdd_clicked()
 {
-	addReward(ui->rewardType->currentIndex(), ui->rewardList->currentIndex(), ui->rewardAmount->text().toInt());
+	addReward(RewardType(ui->rewardType->currentIndex()), ui->rewardList->currentIndex(), ui->rewardAmount->text().toInt());
 }
 
 

+ 7 - 16
mapeditor/inspector/rewardswidget.h

@@ -15,20 +15,6 @@
 namespace Ui {
 class RewardsWidget;
 }
- 
-/*
- ui32 gainedExp;
- si32 manaDiff; //amount of gained / lost mana
- si32 moraleDiff; //morale modifier
- si32 luckDiff; //luck modifier
- TResources resources;//gained / lost resources
- std::vector<si32> primskills;//gained / lost prim skills
- std::vector<SecondarySkill> abilities; //gained abilities
- std::vector<si32> abilityLevels; //levels of gained abilities
- std::vector<ArtifactID> artifacts; //gained artifacts
- std::vector<SpellID> spells; //gained spells
- CCreatureSet creatures; //gained creatures
- */
 
 const std::array<std::string, 10> rewardTypes{"Experience", "Mana", "Morale", "Luck", "Resource", "Primary skill", "Secondary skill", "Artifact", "Spell", "Creature"};
 
@@ -37,6 +23,11 @@ class RewardsWidget : public QDialog
 	Q_OBJECT
 
 public:
+	enum RewardType
+	{
+		EXPERIENCE = 0, MANA, MORALE, LUCK, RESOURCE, PRIMARY_SKILL, SECONDARY_SKILL, ARTIFACT, SPELL, CREATURE
+	};
+	
 	explicit RewardsWidget(const CMap &, CGPandoraBox &, QWidget *parent = nullptr);
 	~RewardsWidget();
 	
@@ -57,8 +48,8 @@ private slots:
 	void on_rewardsTable_itemSelectionChanged();
 
 private:
-	void addReward(int typeId, int listId, int amount);
-	QList<QString> getListForType(int typeId);
+	void addReward(RewardType typeId, int listId, int amount);
+	QList<QString> getListForType(RewardType typeId);
 	
 	Ui::RewardsWidget *ui;
 	CGPandoraBox * pandora;

+ 2 - 8
mapeditor/mainwindow.cpp

@@ -140,12 +140,6 @@ MainWindow::MainWindow(QWidget *parent) :
 	graphics = new Graphics(); // should be before curh->init()
 	graphics->load();//must be after Content loading but should be in main thread
 	
-	
-	if(!testFile("DATA/new-menu/Background.png", "Cannot find file"))
-	{
-		QApplication::quit();
-	}
-	
 	ui->mapView->setScene(controller.scene(0));
 	ui->mapView->setController(&controller);
 	ui->mapView->setOptimizationFlags(QGraphicsView::DontSavePainterState | QGraphicsView::DontAdjustForAntialiasing);
@@ -173,7 +167,7 @@ MainWindow::MainWindow(QWidget *parent) :
 	show();
 	
 	//Load map from command line
-	if(qApp->arguments().size() == 2)
+	if(qApp->arguments().size() >= 2)
 		openMap(qApp->arguments().at(1));
 }
 
@@ -973,7 +967,7 @@ void MainWindow::switchDefaultPlayer(const PlayerColor & player)
 	ui->actionNeutral->blockSignals(true);
 	ui->actionNeutral->setChecked(PlayerColor::NEUTRAL == player);
 	ui->actionNeutral->blockSignals(false);
-	for(int i = 0; i < 8; ++i)
+	for(int i = 0; i < PlayerColor::PLAYER_LIMIT.getNum(); ++i)
 	{
 		getActionPlayer(PlayerColor(i))->blockSignals(true);
 		getActionPlayer(PlayerColor(i))->setChecked(PlayerColor(i) == player);

+ 23 - 24
mapeditor/mapcontroller.cpp

@@ -19,10 +19,11 @@
 
 MapController::MapController(MainWindow * m): main(m)
 {
-	_scenes[0].reset(new MapScene(0));
-	_scenes[1].reset(new MapScene(1));
-	_miniscenes[0].reset(new MinimapScene(0));
-	_miniscenes[1].reset(new MinimapScene(1));
+	for(int i : {0, 1})
+	{
+		_scenes[i].reset(new MapScene(i));
+		_miniscenes[i].reset(new MinimapScene(i));
+	}
 	connectScenes();
 }
 
@@ -72,23 +73,19 @@ void MapController::repairMap()
 	//there might be extra skills, arts and spells not imported from map
 	if(VLC->skillh->getDefaultAllowed().size() > map()->allowedAbilities.size())
 	{
-		for(int i = map()->allowedAbilities.size(); i < VLC->skillh->getDefaultAllowed().size(); ++i)
-			map()->allowedAbilities.push_back(false);
+		map()->allowedAbilities.resize(VLC->skillh->getDefaultAllowed().size());
 	}
 	if(VLC->arth->getDefaultAllowed().size() > map()->allowedArtifact.size())
 	{
-		for(int i = map()->allowedArtifact.size(); i < VLC->arth->getDefaultAllowed().size(); ++i)
-			map()->allowedArtifact.push_back(false);
+		map()->allowedArtifact.resize(VLC->arth->getDefaultAllowed().size());
 	}
 	if(VLC->spellh->getDefaultAllowed().size() > map()->allowedSpell.size())
 	{
-		for(int i = map()->allowedSpell.size(); i < VLC->spellh->getDefaultAllowed().size(); ++i)
-			map()->allowedSpell.push_back(false);
+		map()->allowedSpell.resize(VLC->spellh->getDefaultAllowed().size());
 	}
 	if(VLC->heroh->getDefaultAllowed().size() > map()->allowedHeroes.size())
 	{
-		for(int i = map()->allowedHeroes.size(); i < VLC->heroh->getDefaultAllowed().size(); ++i)
-			map()->allowedHeroes.push_back(false);
+		map()->allowedHeroes.resize(VLC->heroh->getDefaultAllowed().size());
 	}
 	
 	//fix owners for objects
@@ -191,10 +188,11 @@ void MapController::setMap(std::unique_ptr<CMap> cmap)
 	
 	repairMap();
 	
-	_scenes[0].reset(new MapScene(0));
-	_scenes[1].reset(new MapScene(1));
-	_miniscenes[0].reset(new MinimapScene(0));
-	_miniscenes[1].reset(new MinimapScene(1));
+	for(int i : {0, 1})
+	{
+		_scenes[i].reset(new MapScene(i));
+		_miniscenes[i].reset(new MinimapScene(i));
+	}
 	resetMapHandler();
 	sceneForceUpdate();
 
@@ -230,10 +228,11 @@ void MapController::resetMapHandler()
 	if(!_mapHandler)
 		_mapHandler.reset(new MapHandler());
 	_mapHandler->reset(map());
-	_scenes[0]->initialize(*this);
-	_scenes[1]->initialize(*this);
-	_miniscenes[0]->initialize(*this);
-	_miniscenes[1]->initialize(*this);
+	for(int i : {0, 1})
+	{
+		_scenes[i]->initialize(*this);
+		_miniscenes[i]->initialize(*this);
+	}
 }
 
 void MapController::commitTerrainChange(int level, const TerrainId & terrain)
@@ -321,7 +320,7 @@ bool MapController::discardObject(int level) const
 		delete _scenes[level]->selectionObjectsView.newObject;
 		_scenes[level]->selectionObjectsView.newObject = nullptr;
 		_scenes[level]->selectionObjectsView.shift = QPoint(0, 0);
-		_scenes[level]->selectionObjectsView.selectionMode = 0;
+		_scenes[level]->selectionObjectsView.selectionMode = SelectionObjectsLayer::NOTHING;
 		_scenes[level]->selectionObjectsView.draw();
 		return true;
 	}
@@ -331,7 +330,7 @@ bool MapController::discardObject(int level) const
 void MapController::createObject(int level, CGObjectInstance * obj) const
 {
 	_scenes[level]->selectionObjectsView.newObject = obj;
-	_scenes[level]->selectionObjectsView.selectionMode = 2;
+	_scenes[level]->selectionObjectsView.selectionMode = SelectionObjectsLayer::MOVEMENT;
 	_scenes[level]->selectionObjectsView.draw();
 }
 
@@ -410,7 +409,7 @@ void MapController::commitObjectShift(int level)
 	
 	_scenes[level]->selectionObjectsView.newObject = nullptr;
 	_scenes[level]->selectionObjectsView.shift = QPoint(0, 0);
-	_scenes[level]->selectionObjectsView.selectionMode = 0;
+	_scenes[level]->selectionObjectsView.selectionMode = SelectionObjectsLayer::NOTHING;
 	
 	if(makeShift)
 	{
@@ -444,7 +443,7 @@ void MapController::commitObjectCreate(int level)
 	
 	_scenes[level]->selectionObjectsView.newObject = nullptr;
 	_scenes[level]->selectionObjectsView.shift = QPoint(0, 0);
-	_scenes[level]->selectionObjectsView.selectionMode = 0;
+	_scenes[level]->selectionObjectsView.selectionMode = SelectionObjectsLayer::NOTHING;
 	_scenes[level]->objectsView.draw();
 	_scenes[level]->selectionObjectsView.draw();
 	_scenes[level]->passabilityView.update();

+ 8 - 8
mapeditor/mapview.cpp

@@ -155,11 +155,11 @@ void MapView::mouseMoveEvent(QMouseEvent *mouseEvent)
 			{
 				sc->selectionObjectsView.shift = QPoint(tile.x, tile.y);
 				sc->selectionObjectsView.selectObject(sc->selectionObjectsView.newObject);
-				sc->selectionObjectsView.selectionMode = 2;
+				sc->selectionObjectsView.selectionMode = SelectionObjectsLayer::MOVEMENT;
 			}
 			else if(mouseEvent->buttons() & Qt::LeftButton)
 			{
-				if(sc->selectionObjectsView.selectionMode == 1)
+				if(sc->selectionObjectsView.selectionMode == SelectionObjectsLayer::SELECTION)
 				{
 					sc->selectionObjectsView.clear();
 					sc->selectionObjectsView.selectObjects(tileStart.x, tileStart.y, tile.x, tile.y);
@@ -269,23 +269,23 @@ void MapView::mousePressEvent(QMouseEvent *event)
 						if(qApp->keyboardModifiers() & Qt::ControlModifier)
 						{
 							sc->selectionObjectsView.deselectObject(obj);
-							sc->selectionObjectsView.selectionMode = 1;
+							sc->selectionObjectsView.selectionMode = SelectionObjectsLayer::SELECTION;
 						}
 						else
-							sc->selectionObjectsView.selectionMode = 2;
+							sc->selectionObjectsView.selectionMode = SelectionObjectsLayer::MOVEMENT;
 					}
 					else
 					{
 						if(!(qApp->keyboardModifiers() & Qt::ControlModifier))
 							sc->selectionObjectsView.clear();
-						sc->selectionObjectsView.selectionMode = 2;
+						sc->selectionObjectsView.selectionMode = SelectionObjectsLayer::MOVEMENT;
 						sc->selectionObjectsView.selectObject(obj);
 					}
 				}
 				else
 				{
 					sc->selectionObjectsView.clear();
-					sc->selectionObjectsView.selectionMode = 1;
+					sc->selectionObjectsView.selectionMode = SelectionObjectsLayer::SELECTION;
 				}
 			}
 			sc->selectionObjectsView.shift = QPoint(0, 0);
@@ -312,7 +312,7 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
 			break;
 		//switch position
 		bool tab = false;
-		if(sc->selectionObjectsView.selectionMode == 2)
+		if(sc->selectionObjectsView.selectionMode == SelectionObjectsLayer::MOVEMENT)
 		{
 			if(sc->selectionObjectsView.newObject)
 			{
@@ -330,7 +330,7 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
 		}
 		else
 		{
-			sc->selectionObjectsView.selectionMode = 0;
+			sc->selectionObjectsView.selectionMode = SelectionObjectsLayer::NOTHING;
 			sc->selectionObjectsView.shift = QPoint(0, 0);
 			sc->selectionObjectsView.draw();
 			tab = true;

+ 1 - 2
mapeditor/objectbrowser.cpp

@@ -42,8 +42,7 @@ bool ObjectBrowser::filterAcceptsRow(int source_row, const QModelIndex & source_
 
 	result = result & templ->canBePlacedAt(terrain);
 
-	//text filter
-
+	//if we are here, just text filter will be applied
 	return result;
 }
 

+ 7 - 5
mapeditor/playersettings.cpp

@@ -13,6 +13,7 @@ PlayerSettings::PlayerSettings(MapController & ctrl, QWidget *parent) :
 	show();
 
 	int players = 0;
+	const int minAllowedPlayers = 2;
 	for(auto & p : controller.map()->players)
 	{
 		if(p.canAnyonePlay())
@@ -23,10 +24,10 @@ PlayerSettings::PlayerSettings(MapController & ctrl, QWidget *parent) :
 		}
 	}
 
-	if(players < 2)
+	if(players < minAllowedPlayers)
 		ui->playersCount->setCurrentText("");
 	else
-		ui->playersCount->setCurrentIndex(players - 2);
+		ui->playersCount->setCurrentIndex(players - minAllowedPlayers);
 	
 	setAttribute(Qt::WA_DeleteOnClose);
 }
@@ -38,9 +39,10 @@ PlayerSettings::~PlayerSettings()
 
 void PlayerSettings::on_playersCount_currentIndexChanged(int index)
 {
-	assert(index + 2 <= controller.map()->players.size());
+	const auto selectedPlayerCount = index + 2;
+	assert(selectedPlayerCount <= controller.map()->players.size());
 
-	for(int i = 0; i < index + 2; ++i)
+	for(int i = 0; i < selectedPlayerCount; ++i)
 	{
 		if(i < paramWidgets.size())
 			continue;
@@ -52,7 +54,7 @@ void PlayerSettings::on_playersCount_currentIndexChanged(int index)
 	}
 
 	assert(!paramWidgets.empty());
-	for(int i = paramWidgets.size() - 1; i >= index + 2; --i)
+	for(int i = paramWidgets.size() - 1; i >= selectedPlayerCount; --i)
 	{
 		auto & p = controller.map()->players[i];
 		p.canComputerPlay = false;

+ 12 - 18
mapeditor/scenelayer.cpp

@@ -54,7 +54,7 @@ void GridLayer::update()
 		return;
 	
 	pixmap.reset(new QPixmap(map->width * 32, map->height * 32));
-	pixmap->fill(QColor(0, 0, 0, 0));
+	pixmap->fill(QColorConstants::Transparent);
 	QPainter painter(pixmap.get());
 	painter.setPen(QColor(0, 0, 0, 190));
 	
@@ -80,7 +80,7 @@ void PassabilityLayer::update()
 		return;
 	
 	pixmap.reset(new QPixmap(map->width * 32, map->height * 32));
-	pixmap->fill(QColor(0, 0, 0, 0));
+	pixmap->fill(QColorConstants::Transparent);
 	
 	if(scene->level == 0 || map->twoLevel)
 	{
@@ -116,7 +116,7 @@ void SelectionTerrainLayer::update()
 	onSelection();
 	
 	pixmap.reset(new QPixmap(map->width * 32, map->height * 32));
-	pixmap->fill(QColor(0, 0, 0, 0));
+	pixmap->fill(QColorConstants::Transparent);
 	
 	redraw();
 }
@@ -273,7 +273,7 @@ void ObjectsLayer::update()
 		return;
 	
 	pixmap.reset(new QPixmap(map->width * 32, map->height * 32));
-	pixmap->fill(QColor(0, 0, 0, 0));
+	pixmap->fill(QColorConstants::Transparent);
 	draw(false);
 }
 
@@ -285,7 +285,7 @@ void ObjectsLayer::draw(bool onlyDirty)
 	if(!map)
 		return;
 	
-	pixmap->fill(QColor(0, 0, 0, 0));
+	pixmap->fill(QColorConstants::Transparent);
 	QPainter painter(pixmap.get());
 	std::set<const CGObjectInstance *> drawen;
 	
@@ -340,8 +340,7 @@ void SelectionObjectsLayer::update()
 	selectedObjects.clear();
 	onSelection();
 	shift = QPoint();
-	if(newObject)
-		delete newObject;
+	delete newObject;
 	newObject = nullptr;
 	
 	pixmap.reset(new QPixmap(map->width * 32, map->height * 32));
@@ -355,11 +354,11 @@ void SelectionObjectsLayer::draw()
 	if(!pixmap)
 		return;
 	
-	pixmap->fill(QColor(0, 0, 0, 0));
+	pixmap->fill(QColorConstants::Transparent);
 	
 	QPainter painter(pixmap.get());
 	painter.setCompositionMode(QPainter::CompositionMode_Source);
-	painter.setPen(QColor(255, 255, 255));
+	painter.setPen(QColorConstants::White);
 	
 	for(auto * obj : selectedObjects)
 	{
@@ -379,7 +378,7 @@ void SelectionObjectsLayer::draw()
 		}
 		
 		//show translation
-		if(selectionMode == 2 && (shift.x() || shift.y()))
+		if(selectionMode == SelectionMode::MOVEMENT && (shift.x() || shift.y()))
 		{
 			painter.setOpacity(0.5);
 			auto newPos = QPoint(obj->getPosition().x, obj->getPosition().y) + shift;
@@ -530,13 +529,8 @@ void MinimapViewLayer::update()
 		return;
 	
 	pixmap.reset(new QPixmap(map->width, map->height));
-	pixmap->fill(QColor(0, 0, 0, 0));
 	
-	QPainter painter(pixmap.get());
-	painter.setPen(QColor(255, 255, 255));
-	painter.drawRect(x, y, w, h);
-	
-	redraw();
+	draw();
 }
 
 void MinimapViewLayer::draw()
@@ -544,11 +538,11 @@ void MinimapViewLayer::draw()
 	if(!map)
 		return;
 	
-	pixmap->fill(QColor(0, 0, 0, 0));
+	pixmap->fill(QColorConstants::Transparent);
 	
 	//maybe not optimal but ok
 	QPainter painter(pixmap.get());
-	painter.setPen(QColor(255, 255, 255));
+	painter.setPen(QColorConstants::White);
 	painter.drawRect(x, y, w, h);
 	
 	redraw();

+ 6 - 1
mapeditor/scenelayer.h

@@ -117,6 +117,11 @@ class SelectionObjectsLayer: public AbstractLayer
 {
 	Q_OBJECT
 public:
+	enum SelectionMode
+	{
+		NOTHING, SELECTION, MOVEMENT
+	};
+	
 	SelectionObjectsLayer(MapSceneBase* s);
 	
 	void update() override;
@@ -135,7 +140,7 @@ public:
 	QPoint shift;
 	CGObjectInstance * newObject;
 	//FIXME: magic number
-	int selectionMode = 0; //0 - nothing, 1 - selection, 2 - movement
+	SelectionMode selectionMode = SelectionMode::NOTHING;
 
 signals:
 	void selectionMade(bool anythingSlected);