1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Allow selecting driver in Launcher

This commit is contained in:
Ivan Savenko 2024-01-05 21:47:03 +02:00
parent 3383221f0b
commit 77d54e1f79
3 changed files with 418 additions and 353 deletions

View File

@ -117,6 +117,7 @@ void CSettingsView::loadSettings()
ui->lineEditAutoSavePrefix->setEnabled(settings["general"]["useSavePrefix"].Bool());
Languages::fillLanguages(ui->comboBoxLanguage, false);
fillValidRenderers();
std::string cursorType = settings["video"]["cursor"].String();
size_t cursorTypeIndex = boost::range::find(cursorTypesList, cursorType) - cursorTypesList;
@ -163,6 +164,24 @@ void CSettingsView::fillValidScalingRange()
#ifndef VCMI_MOBILE
static QStringList getAvailableRenderingDrivers()
{
SDL_Init(SDL_INIT_VIDEO);
QStringList result;
int driversCount = SDL_GetNumRenderDrivers();
for(int it = 0; it < driversCount; it++)
{
SDL_RendererInfo info;
if (SDL_GetRenderDriverInfo(it, &info) == 0)
result += QString::fromLatin1(info.name);
}
SDL_Quit();
return result;
}
static QVector<QSize> findAvailableResolutions(int displayIndex)
{
// Ugly workaround since we don't actually need SDL in Launcher
@ -203,7 +222,6 @@ void CSettingsView::fillValidResolutionsForScreen(int screenIndex)
bool fullscreen = settings["video"]["fullscreen"].Bool();
bool realFullscreen = settings["video"]["realFullscreen"].Bool();
if (!fullscreen || realFullscreen)
{
QVector<QSize> resolutions = findAvailableResolutions(screenIndex);
@ -228,6 +246,22 @@ void CSettingsView::fillValidResolutionsForScreen(int screenIndex)
ui->comboBoxResolution->blockSignals(false);
}
void CSettingsView::fillValidRenderers()
{
ui->comboBoxRendererType->blockSignals(true); // avoid saving wrong resolution after adding first item from the list
ui->comboBoxRendererType->clear();
auto driversList = getAvailableRenderingDrivers();
ui->comboBoxRendererType->addItems(driversList);
std::string rendererName = settings["video"]["driver"].String();
int index = ui->comboBoxRendererType->findText(QString::fromStdString(rendererName));
ui->comboBoxRendererType->setCurrentIndex(index);
ui->comboBoxRendererType->blockSignals(false);
}
#else
void CSettingsView::fillValidResolutionsForScreen(int screenIndex)
{
@ -235,6 +269,13 @@ void CSettingsView::fillValidResolutionsForScreen(int screenIndex)
ui->comboBoxResolution->hide();
ui->labelResolution->hide();
}
void CSettingsView::fillValidRenderers()
{
// untested on mobile platforms
ui->comboBoxRendererType-hide();
ui->labelRendererType-hide();
}
#endif
CSettingsView::CSettingsView(QWidget * parent)
@ -542,3 +583,10 @@ void CSettingsView::on_spinBoxReservedArea_valueChanged(int arg1)
node->Float() = float(arg1) / 100; // percentage -> ratio
}
void CSettingsView::on_comboBoxRendererType_currentTextChanged(const QString &arg1)
{
Settings node = settings.write["video"]["driver"];
node->String() = arg1.toStdString();
}

View File

@ -76,9 +76,12 @@ private slots:
void on_spinBoxReservedArea_valueChanged(int arg1);
void on_comboBoxRendererType_currentTextChanged(const QString &arg1);
private:
Ui::CSettingsView * ui;
void fillValidRenderers();
void fillValidResolutionsForScreen(int screenIndex);
void fillValidScalingRange();
QSize getPreferredRenderingResolution();

View File

@ -48,27 +48,104 @@
<rect>
<x>0</x>
<y>0</y>
<width>970</width>
<height>895</height>
<width>969</width>
<height>818</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="2,0,1,1,1">
<item row="5" column="0">
<widget class="QLabel" name="labelTranslation">
<item row="20" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxDisplayIndex"/>
</item>
<item row="5" column="1" colspan="3">
<widget class="QLabel" name="labelTranslationStatus">
<property name="text">
<string>Heroes III Translation</string>
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelGeneral">
<item row="27" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxFriendlyAI">
<property name="editable">
<bool>false</bool>
</property>
<property name="currentText">
<string notr="true">BattleAI</string>
</property>
<item>
<property name="text">
<string notr="true">BattleAI</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">StupidAI</string>
</property>
</item>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="labelVideo">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>General</string>
<string>Video</string>
</property>
</widget>
</item>
<item row="23" column="0">
<widget class="QLabel" name="labelArtificialIntelligence">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Artificial Intelligence</string>
</property>
</widget>
</item>
<item row="22" column="0">
<widget class="QLabel" name="labelCursorType">
<property name="text">
<string>Cursor</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxLanguageBase"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelLanguageBase">
<property name="text">
<string>Heroes III Data Language</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="4">
<widget class="QSpinBox" name="spinBoxAutoSaveLimit"/>
</item>
<item row="20" column="0">
<widget class="QLabel" name="labelDisplayIndex">
<property name="text">
<string>Display index</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxLanguage"/>
</item>
<item row="31" column="2" colspan="3">
<widget class="QLineEdit" name="lineEditRepositoryDefault">
<property name="text">
<string notr="true"/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
@ -79,72 +156,62 @@
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="labelInterfaceScaling">
<item row="5" column="0">
<widget class="QLabel" name="labelTranslation">
<property name="text">
<string>Interface Scaling</string>
<string>Heroes III Translation</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="labelAutoSavePrefix">
<item row="28" column="0">
<widget class="QLabel" name="labelEnemyAI">
<property name="text">
<string>Autosave prefix</string>
<string>Enemy AI in battles</string>
</property>
</widget>
</item>
<item row="23" column="0">
<item row="32" column="0">
<widget class="QLabel" name="labelRepositoryExtra">
<property name="text">
<string>Additional repository</string>
</property>
</widget>
</item>
<item row="32" column="2" colspan="3">
<widget class="QLineEdit" name="lineEditRepositoryExtra">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="labelShowIntro">
<property name="text">
<string>Show intro</string>
</property>
</widget>
</item>
<item row="29" column="0">
<widget class="QLabel" name="labelRepositories">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Mod Repositories</string>
</property>
</widget>
</item>
<item row="25" column="0">
<widget class="QLabel" name="labelAlliedPlayerAI">
<property name="text">
<string>Adventure Map Allies</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="labelVideo">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Video</string>
</property>
</widget>
</item>
<item row="16" column="1" colspan="4">
<widget class="QSpinBox" name="spinBoxFramerateLimit">
<property name="minimum">
<number>20</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="QLabel" name="labelArtificialIntelligence">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Artificial Intelligence</string>
</property>
</widget>
</item>
<item row="9" column="2" colspan="3">
<widget class="QLineEdit" name="lineEditAutoSavePrefix">
<property name="placeholderText">
<string>empty = map name prefix</string>
</property>
</widget>
</item>
<item row="29" column="1">
<item row="31" column="1">
<widget class="QCheckBox" name="checkBoxRepositoryDefault">
<property name="enabled">
<bool>true</bool>
@ -157,27 +224,40 @@
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="checkBoxAutoSavePrefix">
<item row="14" column="0">
<widget class="QLabel" name="labelInterfaceScaling">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelAutoSaveLimit">
<property name="text">
<string>Autosave limit (0 = off)</string>
<string>Interface Scaling</string>
</property>
</widget>
</item>
<item row="19" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxDisplayIndex"/>
<widget class="QComboBox" name="comboBoxShowIntro">
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<item>
<property name="text">
<string>On</string>
</property>
</item>
</widget>
</item>
<item row="30" column="0">
<widget class="QLabel" name="labelRepositoryExtra">
<property name="text">
<string>Additional repository</string>
<item row="14" column="1" colspan="4">
<widget class="QSpinBox" name="spinBoxInterfaceScaling">
<property name="minimum">
<number>50</number>
</property>
<property name="maximum">
<number>400</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
@ -200,56 +280,21 @@
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QLabel" name="labelShowIntro">
<property name="text">
<string>Show intro</string>
<item row="6" column="1" colspan="4">
<widget class="QSpinBox" name="spinBoxNetworkPort">
<property name="minimum">
<number>1024</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>3030</number>
</property>
</widget>
</item>
<item row="18" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxShowIntro">
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<item>
<property name="text">
<string>On</string>
</property>
</item>
</widget>
</item>
<item row="26" column="0">
<widget class="QLabel" name="labelEnemyAI">
<property name="text">
<string>Enemy AI in battles</string>
</property>
</widget>
</item>
<item row="23" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxAlliedPlayerAI">
<property name="currentText">
<string notr="true">VCAI</string>
</property>
<item>
<property name="text">
<string notr="true">VCAI</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Nullkiller</string>
</property>
</item>
</widget>
</item>
<item row="25" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxFriendlyAI">
<item row="28" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxEnemyAI">
<property name="editable">
<bool>false</bool>
</property>
@ -268,10 +313,99 @@
</item>
</widget>
</item>
<item row="30" column="2" colspan="3">
<widget class="QLineEdit" name="lineEditRepositoryExtra">
<item row="9" column="1">
<widget class="QCheckBox" name="checkBoxAutoSavePrefix">
<property name="text">
<string notr="true"/>
<string/>
</property>
</widget>
</item>
<item row="16" column="1" colspan="4">
<widget class="QSpinBox" name="spinBoxFramerateLimit">
<property name="minimum">
<number>20</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
<item row="32" column="1">
<widget class="QCheckBox" name="checkBoxRepositoryExtra">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="labelReservedArea">
<property name="text">
<string>Reserved screen area</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="labelResolution">
<property name="text">
<string>Resolution</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelLanguage">
<property name="text">
<string>VCMI Language</string>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="labelFramerateLimit">
<property name="text">
<string>Framerate Limit</string>
</property>
</widget>
</item>
<item row="25" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxAlliedPlayerAI">
<property name="currentText">
<string notr="true">VCAI</string>
</property>
<item>
<property name="text">
<string notr="true">VCAI</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Nullkiller</string>
</property>
</item>
</widget>
</item>
<item row="26" column="0">
<widget class="QLabel" name="labelNeutralAI">
<property name="text">
<string>Neutral AI in battles</string>
</property>
</widget>
</item>
<item row="27" column="0">
<widget class="QLabel" name="labelFriendlyAI">
<property name="text">
<string>Friendly AI in battles</string>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QCheckBox" name="checkBoxVSync">
<property name="text">
<string/>
</property>
</widget>
</item>
@ -306,123 +440,10 @@ Fullscreen Exclusive Mode - game will cover entirety of your screen and will use
</item>
</widget>
</item>
<item row="11" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxResolution"/>
</item>
<item row="19" column="0">
<widget class="QLabel" name="labelDisplayIndex">
<item row="7" column="0">
<widget class="QLabel" name="labelAutoSave">
<property name="text">
<string>Display index</string>
</property>
</widget>
</item>
<item row="22" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxEnemyPlayerAI">
<property name="currentText">
<string notr="true">VCAI</string>
</property>
<item>
<property name="text">
<string notr="true">VCAI</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Nullkiller</string>
</property>
</item>
</widget>
</item>
<item row="5" column="1" colspan="3">
<widget class="QLabel" name="labelTranslationStatus">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="29" column="0">
<widget class="QLabel" name="labelRepositoryDefault">
<property name="text">
<string>Default repository</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelLanguageBase">
<property name="text">
<string>Heroes III Data Language</string>
</property>
</widget>
</item>
<item row="30" column="1">
<widget class="QCheckBox" name="checkBoxRepositoryExtra">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="labelFramerateLimit">
<property name="text">
<string>Framerate Limit</string>
</property>
</widget>
</item>
<item row="25" column="0">
<widget class="QLabel" name="labelFriendlyAI">
<property name="text">
<string>Friendly AI in battles</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelLanguage">
<property name="text">
<string>VCMI Language</string>
</property>
</widget>
</item>
<item row="29" column="2" colspan="3">
<widget class="QLineEdit" name="lineEditRepositoryDefault">
<property name="text">
<string notr="true"/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxLanguageBase"/>
</item>
<item row="14" column="1" colspan="4">
<widget class="QSpinBox" name="spinBoxInterfaceScaling">
<property name="minimum">
<number>50</number>
</property>
<property name="maximum">
<number>400</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
<item row="8" column="1" colspan="4">
<widget class="QSpinBox" name="spinBoxAutoSaveLimit"/>
</item>
<item row="27" column="0">
<widget class="QLabel" name="labelRepositories">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Mod Repositories</string>
<string>Autosave</string>
</property>
</widget>
</item>
@ -433,84 +454,13 @@ Fullscreen Exclusive Mode - game will cover entirety of your screen and will use
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="labelResolution">
<item row="9" column="0">
<widget class="QLabel" name="labelAutoSavePrefix">
<property name="text">
<string>Resolution</string>
<string>Autosave prefix</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="4">
<widget class="QSpinBox" name="spinBoxNetworkPort">
<property name="minimum">
<number>1024</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>3030</number>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelAutoSave">
<property name="text">
<string>Autosave</string>
</property>
</widget>
</item>
<item row="20" column="0">
<widget class="QLabel" name="labelCursorType">
<property name="text">
<string>Cursor</string>
</property>
</widget>
</item>
<item row="20" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxCursorType">
<item>
<property name="text">
<string>Hardware</string>
</property>
</item>
<item>
<property name="text">
<string>Software</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxLanguage"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelNetworkPort">
<property name="text">
<string>Network port</string>
</property>
</widget>
</item>
<item row="26" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxEnemyAI">
<property name="editable">
<bool>false</bool>
</property>
<property name="currentText">
<string notr="true">BattleAI</string>
</property>
<item>
<property name="text">
<string notr="true">BattleAI</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">StupidAI</string>
</property>
</item>
</widget>
</item>
<item row="7" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxAutoSave">
<property name="currentIndex">
@ -528,59 +478,58 @@ Fullscreen Exclusive Mode - game will cover entirety of your screen and will use
</item>
</widget>
</item>
<item row="28" column="3" colspan="2">
<widget class="QPushButton" name="refreshRepositoriesButton">
<item row="9" column="2" colspan="3">
<widget class="QLineEdit" name="lineEditAutoSavePrefix">
<property name="placeholderText">
<string>empty = map name prefix</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelGeneral">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Refresh now</string>
<string>General</string>
</property>
</widget>
</item>
<item row="24" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxNeutralAI">
<widget class="QComboBox" name="comboBoxEnemyPlayerAI">
<property name="currentText">
<string notr="true">BattleAI</string>
<string notr="true">VCAI</string>
</property>
<item>
<property name="text">
<string notr="true">BattleAI</string>
<string notr="true">VCAI</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">StupidAI</string>
<string notr="true">Nullkiller</string>
</property>
</item>
</widget>
</item>
<item row="28" column="0">
<widget class="QLabel" name="labelAutoCheck">
<property name="text">
<string>Check on startup</string>
</property>
<item row="22" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxCursorType">
<item>
<property name="text">
<string>Hardware</string>
</property>
</item>
<item>
<property name="text">
<string>Software</string>
</property>
</item>
</widget>
</item>
<item row="24" column="0">
<widget class="QLabel" name="labelNeutralAI">
<property name="text">
<string>Neutral AI in battles</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="labelReservedArea">
<property name="text">
<string>Reserved screen area</string>
</property>
</widget>
</item>
<item row="22" column="0">
<widget class="QLabel" name="labelEnemyPlayerAI">
<property name="text">
<string>Adventure Map Enemies</string>
</property>
</widget>
</item>
<item row="28" column="1" colspan="2">
<item row="30" column="1" colspan="2">
<widget class="QComboBox" name="comboBoxAutoCheck">
<property name="currentIndex">
<number>1</number>
@ -597,6 +546,16 @@ Fullscreen Exclusive Mode - game will cover entirety of your screen and will use
</item>
</widget>
</item>
<item row="24" column="0">
<widget class="QLabel" name="labelEnemyPlayerAI">
<property name="text">
<string>Adventure Map Enemies</string>
</property>
</widget>
</item>
<item row="11" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxResolution"/>
</item>
<item row="17" column="0">
<widget class="QLabel" name="labelVSync">
<property name="text">
@ -604,10 +563,65 @@ Fullscreen Exclusive Mode - game will cover entirety of your screen and will use
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QCheckBox" name="checkBoxVSync">
<item row="26" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxNeutralAI">
<property name="currentText">
<string notr="true">BattleAI</string>
</property>
<item>
<property name="text">
<string notr="true">BattleAI</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">StupidAI</string>
</property>
</item>
</widget>
</item>
<item row="30" column="0">
<widget class="QLabel" name="labelAutoCheck">
<property name="text">
<string/>
<string>Check on startup</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelAutoSaveLimit">
<property name="text">
<string>Autosave limit (0 = off)</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelNetworkPort">
<property name="text">
<string>Network port</string>
</property>
</widget>
</item>
<item row="30" column="3" colspan="2">
<widget class="QPushButton" name="refreshRepositoriesButton">
<property name="text">
<string>Refresh now</string>
</property>
</widget>
</item>
<item row="31" column="0">
<widget class="QLabel" name="labelRepositoryDefault">
<property name="text">
<string>Default repository</string>
</property>
</widget>
</item>
<item row="21" column="1" colspan="4">
<widget class="QComboBox" name="comboBoxRendererType"/>
</item>
<item row="21" column="0">
<widget class="QLabel" name="labelRendererType">
<property name="text">
<string>Renderer</string>
</property>
</widget>
</item>