Browse Source

Merge pull request #1849 from Nordsoft91/editor-1537

Allow single player on map and fix player params initialization
Ivan Savenko 2 years ago
parent
commit
6518e04cd6
3 changed files with 17 additions and 5 deletions
  1. 7 0
      mapeditor/mainwindow.cpp
  2. 2 2
      mapeditor/playersettings.cpp
  3. 8 3
      mapeditor/playersettings.ui

+ 7 - 0
mapeditor/mainwindow.cpp

@@ -301,6 +301,13 @@ void MainWindow::initializeMap(bool isNew)
 	ui->actionMapSettings->setEnabled(true);
 	ui->actionPlayers_settings->setEnabled(true);
 	
+	//set minimal players count
+	if(isNew)
+	{
+		controller.map()->players[0].canComputerPlay = true;
+		controller.map()->players[0].canHumanPlay = true;
+	}
+	
 	onPlayersChanged();
 }
 

+ 2 - 2
mapeditor/playersettings.cpp

@@ -23,7 +23,7 @@ PlayerSettings::PlayerSettings(MapController & ctrl, QWidget *parent) :
 	show();
 
 	int players = 0;
-	const int minAllowedPlayers = 2;
+	const int minAllowedPlayers = 1;
 	for(auto & p : controller.map()->players)
 	{
 		if(p.canAnyonePlay())
@@ -49,7 +49,7 @@ PlayerSettings::~PlayerSettings()
 
 void PlayerSettings::on_playersCount_currentIndexChanged(int index)
 {
-	const auto selectedPlayerCount = index + 2;
+	const auto selectedPlayerCount = index + 1;
 	assert(selectedPlayerCount <= controller.map()->players.size());
 
 	for(int i = 0; i < selectedPlayerCount; ++i)

+ 8 - 3
mapeditor/playersettings.ui

@@ -33,8 +33,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>634</width>
-        <height>201</height>
+        <width>628</width>
+        <height>187</height>
        </rect>
       </property>
       <layout class="QVBoxLayout" name="verticalLayout_2">
@@ -67,8 +67,13 @@
    <item row="0" column="1">
     <widget class="QComboBox" name="playersCount">
      <property name="currentText">
-      <string notr="true">2</string>
+      <string notr="true">1</string>
      </property>
+     <item>
+      <property name="text">
+       <string>1</string>
+      </property>
+     </item>
      <item>
       <property name="text">
        <string notr="true">2</string>