1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Allow single player on map and fix player params initialization

This commit is contained in:
nordsoft 2023-04-02 14:31:57 +04:00
parent 4d6b88f10d
commit eedd7979aa
3 changed files with 17 additions and 5 deletions

View File

@ -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();
}

View File

@ -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)

View File

@ -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>