From 00cda400a10495d7d2d183344c6b0883fe4b0bfc Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 4 Aug 2014 14:03:57 +0300 Subject: [PATCH] Miscellaneous improvements for Launcher UI: - Implemented "show intro" toggle in settings - Install/Update/Enable buttons are now visible even when mod info is hidden - Fixed behaviour of show mod info switch, added more obvious button to enable it - Removed no longer used "Enable mods on install" switch - Added buttons to open data, user data and temporary directories --- client/CMT.cpp | 2 +- config/schemas/settings.json | 6 +- launcher/modManager/cmodlistview_moc.cpp | 22 +- launcher/modManager/cmodlistview_moc.h | 2 + launcher/modManager/cmodlistview_moc.ui | 330 ++++++------ launcher/settingsView/csettingsview_moc.cpp | 43 +- launcher/settingsView/csettingsview_moc.h | 12 +- launcher/settingsView/csettingsview_moc.ui | 557 +++++++++++--------- 8 files changed, 562 insertions(+), 412 deletions(-) diff --git a/client/CMT.cpp b/client/CMT.cpp index 11beac7bb..605519639 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -413,7 +413,7 @@ int main(int argc, char** argv) if(!gNoGUI ) { - if(!vm.count("battle") && !vm.count("nointro")) + if(!vm.count("battle") && !vm.count("nointro") && settings["video"]["showIntro"].Bool()) playIntro(); SDL_FillRect(screen,nullptr,0); } diff --git a/config/schemas/settings.json b/config/schemas/settings.json index 5bde69253..40e327f9d 100644 --- a/config/schemas/settings.json +++ b/config/schemas/settings.json @@ -49,7 +49,7 @@ "type" : "object", "additionalProperties" : false, "default": {}, - "required" : [ "screenRes", "bitsPerPixel", "fullscreen", "spellbookAnimation","driver"], + "required" : [ "screenRes", "bitsPerPixel", "fullscreen", "spellbookAnimation","driver", "showIntro" ], "properties" : { "screenRes" : { "type" : "object", @@ -69,6 +69,10 @@ "type" : "boolean", "default" : false }, + "showIntro" : { + "type" : "boolean", + "default" : true + }, "spellbookAnimation" : { "type" : "boolean", "default" : true diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index ba8a7ef8a..5b53f2e8e 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -69,8 +69,8 @@ CModListView::CModListView(QWidget *parent) : ui->progressWidget->setVisible(false); dlManager = nullptr; + disableModInfo(); loadRepositories(); - hideModInfo(); } void CModListView::loadRepositories() @@ -105,8 +105,10 @@ void CModListView::showEvent(QShowEvent * event) void CModListView::showModInfo() { + enableModInfo(); ui->modInfoWidget->show(); ui->hideModInfoButton->setArrowType(Qt::RightArrow); + ui->showInfoButton->setVisible(false); loadScreenshots(); } @@ -114,6 +116,8 @@ void CModListView::hideModInfo() { ui->modInfoWidget->hide(); ui->hideModInfoButton->setArrowType(Qt::LeftArrow); + ui->hideModInfoButton->setEnabled(true); + ui->showInfoButton->setVisible(true); } static QString replaceIfNotEmpty(QVariant value, QString pattern) @@ -223,14 +227,21 @@ QString CModListView::genModInfoText(CModEntry &mod) void CModListView::enableModInfo() { - showModInfo(); ui->hideModInfoButton->setEnabled(true); + ui->showInfoButton->setVisible(true); } void CModListView::disableModInfo() { hideModInfo(); ui->hideModInfoButton->setEnabled(false); + ui->showInfoButton->setVisible(false); + + ui->disableButton->setVisible(false); + ui->enableButton->setVisible(false); + ui->installButton->setVisible(false); + ui->uninstallButton->setVisible(false); + ui->updateButton->setVisible(false); } void CModListView::dataChanged(const QModelIndex & topleft, const QModelIndex & bottomRight) @@ -255,6 +266,8 @@ void CModListView::selectMod(const QModelIndex & index) bool hasBlockingMods = !findBlockingMods(index.data(ModRoles::ModNameRole).toString()).empty(); bool hasDependentMods = !findDependentMods(index.data(ModRoles::ModNameRole).toString(), true).empty(); + ui->hideModInfoButton->setEnabled(true); + ui->showInfoButton->setVisible(!ui->modInfoWidget->isVisible()); ui->disableButton->setVisible(mod.isEnabled()); ui->enableButton->setVisible(mod.isDisabled()); ui->installButton->setVisible(mod.isAvailable() && !mod.getName().contains('.')); @@ -677,3 +690,8 @@ void CModListView::on_screenshotsList_clicked(const QModelIndex &index) ImageViewer::showPixmap(pixmap, this); } } + +void CModListView::on_showInfoButton_clicked() +{ + showModInfo(); +} diff --git a/launcher/modManager/cmodlistview_moc.h b/launcher/modManager/cmodlistview_moc.h index 7803fc4d9..6c90214b5 100644 --- a/launcher/modManager/cmodlistview_moc.h +++ b/launcher/modManager/cmodlistview_moc.h @@ -97,6 +97,8 @@ private slots: void on_screenshotsList_clicked(const QModelIndex &index); + void on_showInfoButton_clicked(); + private: Ui::CModListView *ui; }; diff --git a/launcher/modManager/cmodlistview_moc.ui b/launcher/modManager/cmodlistview_moc.ui index d46cebe1b..dd99712d5 100644 --- a/launcher/modManager/cmodlistview_moc.ui +++ b/launcher/modManager/cmodlistview_moc.ui @@ -26,6 +26,9 @@ 0 + + 3 + @@ -166,7 +169,7 @@ - + 0 0 @@ -202,147 +205,6 @@ 0 - - - - - 0 - 0 - - - - - 51 - 0 - - - - - 100 - 16777215 - - - - Uninstall - - - - - - - - 0 - 0 - - - - - 51 - 0 - - - - - 100 - 16777215 - - - - Disable - - - - - - - - 0 - 0 - - - - - 51 - 0 - - - - - 100 - 16777215 - - - - Update - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 0 - 20 - - - - - - - - - 0 - 0 - - - - - 51 - 0 - - - - - 100 - 16777215 - - - - Install - - - - - - - - 0 - 0 - - - - - 51 - 0 - - - - - 100 - 16777215 - - - - Enable - - - @@ -464,6 +326,179 @@ p, li { white-space: pre-wrap; } + + + + 6 + + + + + + 0 + 0 + + + + + 51 + 0 + + + + + 100 + 16777215 + + + + Show details + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 51 + 0 + + + + + 100 + 16777215 + + + + Enable + + + + + + + + 0 + 0 + + + + + 51 + 0 + + + + + 100 + 16777215 + + + + Disable + + + + + + + + 0 + 0 + + + + + 51 + 0 + + + + + 100 + 16777215 + + + + Update + + + + + + + + 0 + 0 + + + + + 51 + 0 + + + + + 100 + 16777215 + + + + Uninstall + + + + + + + + 0 + 0 + + + + + 51 + 0 + + + + + 100 + 16777215 + + + + Install + + + + + @@ -485,6 +520,12 @@ p, li { white-space: pre-wrap; } 9 + + 6 + + + 6 + @@ -533,11 +574,6 @@ p, li { white-space: pre-wrap; } comboBox allModsView hideModInfoButton - enableButton - disableButton - updateButton - uninstallButton - installButton diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index f4acb8c0b..9013d836e 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -2,6 +2,8 @@ #include "csettingsview_moc.h" #include "ui_csettingsview_moc.h" +#include + #include "../../lib/CConfigHandler.h" #include "../../lib/VCMIDirs.h" @@ -27,6 +29,7 @@ void CSettingsView::loadSettings() ui->comboBoxResolution->setCurrentIndex(resIndex); ui->comboBoxFullScreen->setCurrentIndex(settings["video"]["fullscreen"].Bool()); + ui->comboBoxShowIntro->setCurrentIndex(settings["video"]["showIntro"].Bool()); int neutralAIIndex = ui->comboBoxNeutralAI->findText(QString::fromUtf8(settings["server"]["neutralAI"].String().c_str())); int playerAIIndex = ui->comboBoxPlayerAI->findText(QString::fromUtf8(settings["server"]["playerAI"].String().c_str())); @@ -36,8 +39,6 @@ void CSettingsView::loadSettings() ui->spinBoxNetworkPort->setValue(settings["server"]["port"].Float()); - ui->comboBoxEnableMods->setCurrentIndex(settings["launcher"]["enableInstalledMods"].Bool()); - // all calls to plainText will trigger textChanged() signal overwriting config. Create backup before editing widget JsonNode urls = settings["launcher"]["repositoryURL"]; @@ -46,10 +47,8 @@ void CSettingsView::loadSettings() ui->plainTextEditRepos->appendPlainText(QString::fromUtf8(entry.String().c_str())); ui->lineEditUserDataDir->setText(QString::fromUtf8(VCMIDirs::get().userDataPath().c_str())); - QStringList dataDirs; - for (auto string : VCMIDirs::get().dataPaths()) - dataDirs += QString::fromUtf8(string.c_str()); - ui->lineEditGameDir->setText(dataDirs.join(':')); + ui->lineEditGameDir->setText(QString::fromUtf8(M_DATA_DIR)); + ui->lineEditTempDir->setText(QString::fromUtf8(VCMIDirs::get().userCachePath().c_str())); std::string encoding = settings["general"]["encoding"].String(); size_t encodingIndex = boost::range::find(knownEncodingsList, encoding) - knownEncodingsList; @@ -98,12 +97,6 @@ void CSettingsView::on_comboBoxNeutralAI_currentIndexChanged(const QString &arg1 node->String() = arg1.toUtf8().data(); } -void CSettingsView::on_comboBoxEnableMods_currentIndexChanged(int index) -{ - Settings node = settings.write["launcher"]["enableInstalledMods"]; - node->Bool() = index; -} - void CSettingsView::on_spinBoxNetworkPort_valueChanged(int arg1) { Settings node = settings.write["server"]["port"]; @@ -133,3 +126,29 @@ void CSettingsView::on_comboBoxEncoding_currentIndexChanged(int index) Settings node = settings.write["general"]["encoding"]; node->String() = knownEncodingsList[index]; } + +void CSettingsView::on_openTempDir_clicked() +{ + QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(ui->lineEditTempDir->text()).absoluteFilePath())); +} + +void CSettingsView::on_openUserDataDir_clicked() +{ + QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(ui->lineEditUserDataDir->text()).absoluteFilePath())); +} + +void CSettingsView::on_openGameDataDir_clicked() +{ + QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(ui->lineEditGameDir->text()).absoluteFilePath())); +} + +void CSettingsView::on_comboBoxShowIntro_currentIndexChanged(int index) +{ + Settings node = settings.write["video"]["showIntro"]; + node->Bool() = index; +} + +void CSettingsView::on_changeGameDataDir_clicked() +{ + +} diff --git a/launcher/settingsView/csettingsview_moc.h b/launcher/settingsView/csettingsview_moc.h index fc81c9f46..af4f657d6 100644 --- a/launcher/settingsView/csettingsview_moc.h +++ b/launcher/settingsView/csettingsview_moc.h @@ -23,14 +23,22 @@ private slots: void on_comboBoxNeutralAI_currentIndexChanged(const QString &arg1); - void on_comboBoxEnableMods_currentIndexChanged(int index); - void on_spinBoxNetworkPort_valueChanged(int arg1); void on_plainTextEditRepos_textChanged(); void on_comboBoxEncoding_currentIndexChanged(int index); + void on_openTempDir_clicked(); + + void on_openUserDataDir_clicked(); + + void on_openGameDataDir_clicked(); + + void on_comboBoxShowIntro_currentIndexChanged(int index); + + void on_changeGameDataDir_clicked(); + private: Ui::CSettingsView *ui; }; diff --git a/launcher/settingsView/csettingsview_moc.ui b/launcher/settingsView/csettingsview_moc.ui index e3e9b5ae9..7b085d94e 100644 --- a/launcher/settingsView/csettingsview_moc.ui +++ b/launcher/settingsView/csettingsview_moc.ui @@ -7,13 +7,68 @@ 0 0 700 - 308 + 420 Form + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 75 + true + + + + General + + + + + + + User data directory + + + + + + + 1024 + + + 65535 + + + 3030 + + + + + + + false + + + Change + + + @@ -31,112 +86,7 @@ - - - - QPlainTextEdit::NoWrap - - - http://downloads.vcmi.eu/Mods/repository.json - - - - - - - false - - - - 150 - 0 - - - - /home/user/.vcmi - - - true - - - - - - - Player AI - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 8 - 20 - - - - - - - - false - - - - 150 - 0 - - - - /usr/share/vcmi - - - true - - - - - - - Enable mods on install - - - - - - - 1024 - - - 65535 - - - 3030 - - - - - - - User data directory - - - - - - - Game directory - - - - + @@ -149,94 +99,17 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - - + + - Resolution + Open - - - - - 75 - true - - + + - Video - - - - - - - - 75 - true - - - - Data Directories (unchangeable) - - - - - - - - 75 - true - - - - Repositories - - - - - - - - 75 - true - - - - General - - - - - - - - VCAI - - - - - - - - Network port + Extra data directory @@ -299,39 +172,6 @@ - - - - 1 - - - - Off - - - - - On - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 56 - 8 - - - - @@ -339,7 +179,95 @@ - + + + + QPlainTextEdit::NoWrap + + + http://downloads.vcmi.eu/Mods/repository.json + + + + + + + Open + + + + + + + + 150 + 0 + + + + /usr/share/vcmi + + + + + + + + StupidAI + + + + + BattleAI + + + + + + + + Open + + + + + + + Resolution + + + + + + + Neutral AI + + + + + + + Heroes III character set + + + + + + + + VCAI + + + + + + + + Player AI + + + + @@ -368,34 +296,169 @@ - - - - - StupidAI - - - - - BattleAI - - - - - - - - Neutral AI - - - - + - Heroes III character set + Network port + + + + + 75 + true + + + + Video + + + + + + + + 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 + + + QSizePolicy::Fixed + + + + 8 + 20 + + + +