diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index abe715362..2d52a4c46 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -2823,10 +2823,10 @@ void VCAI::requestSent(const CPackForServer *pack, int requestID) std::string VCAI::getBattleAIName() const { - if(settings["server"]["neutralAI"].getType() == JsonNode::DATA_STRING) - return settings["server"]["neutralAI"].String(); + if(settings["server"]["enemyAI"].getType() == JsonNode::DATA_STRING) + return settings["server"]["enemyAI"].String(); else - return "StupidAI"; + return "BattleAI"; } void VCAI::validateObject(const CGObjectInstance *obj) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index ce58067e9..7b809ec40 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -659,7 +659,7 @@ void CPlayerInterface::battleStart(const CCreatureSet *army1, const CCreatureSet EVENT_HANDLER_CALLED_BY_CLIENT; if (settings["adventure"]["quickCombat"].Bool()) { - autofightingAI = CDynLibHandler::getNewBattleAI(settings["server"]["neutralAI"].String()); + autofightingAI = CDynLibHandler::getNewBattleAI(settings["server"]["friendlyAI"].String()); autofightingAI->init(cb); autofightingAI->battleStart(army1, army2, int3(0,0,0), hero1, hero2, side); isAutoFightOn = true; diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index b23ea88b5..b93c57ee4 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -879,7 +879,7 @@ void CBattleInterface::bAutofightf() curInt->isAutoFightOn = true; blockUI(true); - auto ai = CDynLibHandler::getNewBattleAI(settings["server"]["neutralAI"].String()); + auto ai = CDynLibHandler::getNewBattleAI(settings["server"]["friendlyAI"].String()); ai->init(curInt->cb); ai->battleStart(army1, army2, int3(0,0,0), attackingHeroInstance, defendingHeroInstance, curInt->cb->battleGetMySide()); curInt->autofightingAI = ai; diff --git a/config/schemas/settings.json b/config/schemas/settings.json index 78ad824ed..816a00210 100644 --- a/config/schemas/settings.json +++ b/config/schemas/settings.json @@ -212,7 +212,7 @@ "type" : "object", "additionalProperties" : false, "default": {}, - "required" : [ "server", "port", "localInformation", "playerAI", "neutralAI" ], + "required" : [ "server", "port", "localInformation", "playerAI", "friendlyAI","neutralAI", "enemyAI" ], "properties" : { "server" : { "type":"string", @@ -230,9 +230,17 @@ "type" : "string", "default" : "VCAI" }, + "friendlyAI" : { + "type" : "string", + "default" : "BattleAI" + }, "neutralAI" : { "type" : "string", "default" : "StupidAI" + }, + "enemyAI" : { + "type" : "string", + "default" : "BattleAI" } } }, diff --git a/launcher/main.cpp b/launcher/main.cpp index cb3ed80bb..157ac083e 100644 --- a/launcher/main.cpp +++ b/launcher/main.cpp @@ -1,14 +1,13 @@ +#include #include "StdInc.h" #include "mainwindow_moc.h" -#include #include "sdldisplayquery.h" int main(int argc, char *argv[]) { + QApplication vcmilauncher(argc, argv); auto displayList = getDisplays(); - QApplication a(argc, argv); - MainWindow w(displayList); - w.show(); - - return a.exec(); + MainWindow mainWindow(displayList); + mainWindow.show(); + return vcmilauncher.exec(); } diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp index 5943a1f1a..8ce3d99fa 100644 --- a/launcher/mainwindow_moc.cpp +++ b/launcher/mainwindow_moc.cpp @@ -84,5 +84,4 @@ void MainWindow::startExecutable(QString name) QMessageBox::Ok); return; } - } diff --git a/launcher/mainwindow_moc.h b/launcher/mainwindow_moc.h index c4ae5a1b2..f27b0ac2f 100644 --- a/launcher/mainwindow_moc.h +++ b/launcher/mainwindow_moc.h @@ -11,7 +11,8 @@ class QTableWidgetItem; class MainWindow : public QMainWindow { Q_OBJECT - +private: + Ui::MainWindow *ui; void load(); void startExecutable(QString name); public: @@ -20,7 +21,4 @@ public: private slots: void on_startGameButton_clicked(); - -private: - Ui::MainWindow *ui; }; diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index bdfc967c3..ab6fb4572 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -45,10 +45,14 @@ void CSettingsView::loadSettings() ui->comboBoxFullScreen->setCurrentIndex(settings["video"]["fullscreen"].Bool()); ui->comboBoxShowIntro->setCurrentIndex(settings["video"]["showIntro"].Bool()); + int friendlyAIIndex = ui->comboBoxFriendlyAI->findText(QString::fromUtf8(settings["server"]["friendlyAI"].String().c_str())); int neutralAIIndex = ui->comboBoxNeutralAI->findText(QString::fromUtf8(settings["server"]["neutralAI"].String().c_str())); + int enemyAIIndex = ui->comboBoxEnemyAI->findText(QString::fromUtf8(settings["server"]["enemyAI"].String().c_str())); int playerAIIndex = ui->comboBoxPlayerAI->findText(QString::fromUtf8(settings["server"]["playerAI"].String().c_str())); + ui->comboBoxFriendlyAI->setCurrentIndex(friendlyAIIndex); ui->comboBoxNeutralAI->setCurrentIndex(neutralAIIndex); + ui->comboBoxEnemyAI->setCurrentIndex(enemyAIIndex); ui->comboBoxPlayerAI->setCurrentIndex(playerAIIndex); ui->spinBoxNetworkPort->setValue(settings["server"]["port"].Float()); @@ -118,12 +122,24 @@ void CSettingsView::on_comboBoxPlayerAI_currentIndexChanged(const QString &arg1) node->String() = arg1.toUtf8().data(); } +void CSettingsView::on_comboBoxFriendlyAI_currentIndexChanged(const QString & arg1) +{ + Settings node = settings.write["server"]["friendlyAI"]; + node->String() = arg1.toUtf8().data(); +} + void CSettingsView::on_comboBoxNeutralAI_currentIndexChanged(const QString &arg1) { Settings node = settings.write["server"]["neutralAI"]; node->String() = arg1.toUtf8().data(); } +void CSettingsView::on_comboBoxEnemyAI_currentIndexChanged(const QString & arg1) +{ + Settings node = settings.write["server"]["enemyAI"]; + node->String() = arg1.toUtf8().data(); +} + void CSettingsView::on_spinBoxNetworkPort_valueChanged(int arg1) { Settings node = settings.write["server"]["port"]; diff --git a/launcher/settingsView/csettingsview_moc.h b/launcher/settingsView/csettingsview_moc.h index 5ee782c96..e26f5364a 100644 --- a/launcher/settingsView/csettingsview_moc.h +++ b/launcher/settingsView/csettingsview_moc.h @@ -1,5 +1,4 @@ #pragma once - #include "../StdInc.h" namespace Ui { @@ -9,7 +8,6 @@ namespace Ui { class CSettingsView : public QWidget { Q_OBJECT - public: explicit CSettingsView(QWidget *parent = 0); ~CSettingsView(); @@ -24,8 +22,12 @@ private slots: void on_comboBoxPlayerAI_currentIndexChanged(const QString &arg1); + void on_comboBoxFriendlyAI_currentIndexChanged(const QString &arg1); + void on_comboBoxNeutralAI_currentIndexChanged(const QString &arg1); + void on_comboBoxEnemyAI_currentIndexChanged(const QString &arg1); + void on_spinBoxNetworkPort_valueChanged(int arg1); void on_plainTextEditRepos_textChanged(); diff --git a/launcher/settingsView/csettingsview_moc.ui b/launcher/settingsView/csettingsview_moc.ui index bf9d73c65..c4bcea049 100644 --- a/launcher/settingsView/csettingsview_moc.ui +++ b/launcher/settingsView/csettingsview_moc.ui @@ -6,8 +6,8 @@ 0 0 - 714 - 429 + 738 + 459 @@ -26,8 +26,8 @@ 0 - - + + 75 @@ -35,7 +35,89 @@ - Launcher Settings + Data Directories + + + + + + + + 75 + true + + + + Video + + + + + + + Resolution + + + + + + + Open + + + + + + + + BattleAI + + + + + StupidAI + + + + + + + + User data directory + + + + + + + + 0 + 22 + + + + Enemy AI + + + + + + + Check repositories on startup + + + + + + + Display index + + + + + + + Show intro @@ -52,10 +134,94 @@ - - + + + + + 0 + + + + + + + + false + - User data directory + Change + + + + + + + + VCAI + + + + + + + + false + + + + 150 + 0 + + + + /home/user/.vcmi + + + true + + + + + + + Log files directory + + + + + + + 1 + + + + Off + + + + + On + + + + + + + + + 75 + true + + + + Repositories + + + + + + + Open @@ -72,13 +238,122 @@ - - + + + + QPlainTextEdit::NoWrap + + + http://downloads.vcmi.eu/Mods/repository.json + + + + + + + Open + + + + + + + + 0 + 22 + + + + Friendly AI + + + + + + + Player AI + + + + + + + false + + + BattleAI + + + + BattleAI + + + + + StupidAI + + + + + + + + Fullscreen + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 56 + 8 + + + + + + + + + 150 + 0 + + + + /usr/share/vcmi + + + + + + + Extra data directory + + + + + false + + + 150 + 0 + + - Change + /home/user/.vcmi + + + true @@ -100,7 +375,7 @@ - + 75 @@ -108,21 +383,44 @@ - AI Settings + AI on the map - - + + + + 1 + + + + Off + + + + + On + + + + + + + + + 75 + true + + - Open + Launcher Settings - - + + - Extra data directory + Network port @@ -185,101 +483,42 @@ - - - - Fullscreen + + + + Qt::Vertical - - - - - - QPlainTextEdit::NoWrap + + QSizePolicy::Fixed - - http://downloads.vcmi.eu/Mods/repository.json - - - - - - - Open - - - - - - + - 150 - 0 + 20 + 8 - - /usr/share/vcmi - - + - - - - - StupidAI - - + + + + false + + + BattleAI + BattleAI - - - - - - Open - - - - - - - Resolution - - - - - - - Neutral AI - - - - - - - Heroes III character set - - - - - - VCAI + StupidAI - - - - Player AI - - - @@ -309,154 +548,22 @@ - - - - Network port - - - - - + + 75 + true true + false - Video + AI in the battlefield - - - - - 75 - true - - - - Repositories - - - - - - - Log files directory - - - - - - - false - - - - 150 - 0 - - - - /home/user/.vcmi - - - true - - - - - - - false - - - - 150 - 0 - - - - /home/user/.vcmi - - - true - - - - - - - Show intro - - - - - - - 1 - - - - Off - - - - - On - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 56 - 8 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - - - - - 75 - true - - - - Data Directories - - - - + Qt::Horizontal @@ -472,46 +579,20 @@ - - - - 1 - - - - Off - - - - - On - - - - - - + + - Check repositories on startup + Heroes III character set - - + + - Display index + Neutral AI - - - - - 0 - - - -