NOISSUE add an option to show console on error and default other options to false

This commit is contained in:
Petr Mrázek 2016-11-04 00:19:32 +01:00
parent 6ebf6e7785
commit 3780a25d27
8 changed files with 33 additions and 11 deletions

View File

@ -49,6 +49,7 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
auto consoleSetting = m_settings->registerSetting("OverrideConsole", false); auto consoleSetting = m_settings->registerSetting("OverrideConsole", false);
m_settings->registerOverride(globalSettings->getSetting("ShowConsole"), consoleSetting); m_settings->registerOverride(globalSettings->getSetting("ShowConsole"), consoleSetting);
m_settings->registerOverride(globalSettings->getSetting("AutoCloseConsole"), consoleSetting); m_settings->registerOverride(globalSettings->getSetting("AutoCloseConsole"), consoleSetting);
m_settings->registerOverride(globalSettings->getSetting("ShowConsoleOnError"), consoleSetting);
m_settings->registerOverride(globalSettings->getSetting("LogPrePostOutput"), consoleSetting); m_settings->registerOverride(globalSettings->getSetting("LogPrePostOutput"), consoleSetting);
} }

View File

@ -206,7 +206,8 @@ void LaunchController::launchInstance()
} }
auto console = qobject_cast<InstanceWindow *>(m_parentWidget); auto console = qobject_cast<InstanceWindow *>(m_parentWidget);
if(!console && m_showConsole) auto showConsole = m_instance->settings()->get("ShowConsole").toBool();
if(!console && showConsole)
{ {
MMC->showInstanceWindow(m_instance); MMC->showInstanceWindow(m_instance);
} }
@ -273,6 +274,10 @@ void LaunchController::onSucceeded()
void LaunchController::onFailed(QString reason) void LaunchController::onFailed(QString reason)
{ {
if(m_instance->settings()->get("ShowConsoleOnError").toBool())
{
MMC->showInstanceWindow(m_instance, "console");
}
emitFailed(reason); emitFailed(reason);
} }

View File

@ -33,10 +33,6 @@ public:
{ {
m_parentWidget = widget; m_parentWidget = widget;
} }
void setShowConsole(bool showConsole)
{
m_showConsole = showConsole;
}
QString id() QString id()
{ {
return m_instance->id(); return m_instance->id();
@ -56,7 +52,6 @@ private slots:
private: private:
BaseProfilerFactory *m_profiler = nullptr; BaseProfilerFactory *m_profiler = nullptr;
bool m_online = true; bool m_online = true;
bool m_showConsole = false;
InstancePtr m_instance; InstancePtr m_instance;
QWidget * m_parentWidget = nullptr; QWidget * m_parentWidget = nullptr;
InstanceWindow *m_console = nullptr; InstanceWindow *m_console = nullptr;

View File

@ -542,8 +542,9 @@ void MultiMC::initGlobalSettings()
m_settings->registerSetting("Language", QLocale(QLocale::system().language()).bcp47Name()); m_settings->registerSetting("Language", QLocale(QLocale::system().language()).bcp47Name());
// Console // Console
m_settings->registerSetting("ShowConsole", true); m_settings->registerSetting("ShowConsole", false);
m_settings->registerSetting("AutoCloseConsole", true); m_settings->registerSetting("AutoCloseConsole", false);
m_settings->registerSetting("ShowConsoleOnError", true);
m_settings->registerSetting("LogPrePostOutput", true); m_settings->registerSetting("LogPrePostOutput", true);
// Console Colors // Console Colors
@ -1087,7 +1088,6 @@ void MultiMC::launch(InstancePtr instance, bool online, BaseProfilerFactory *pro
controller->setInstance(instance); controller->setInstance(instance);
controller->setOnline(online); controller->setOnline(online);
controller->setProfiler(profiler); controller->setProfiler(profiler);
controller->setShowConsole(instance->settings()->get("ShowConsole").toBool());
if(window) if(window)
{ {
controller->setParentWidget(window); controller->setParentWidget(window);

View File

@ -47,11 +47,13 @@ void InstanceSettingsPage::applySettings()
{ {
m_settings->set("ShowConsole", ui->showConsoleCheck->isChecked()); m_settings->set("ShowConsole", ui->showConsoleCheck->isChecked());
m_settings->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); m_settings->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked());
m_settings->set("ShowConsoleOnError", ui->showConsoleErrorCheck->isChecked());
} }
else else
{ {
m_settings->reset("ShowConsole"); m_settings->reset("ShowConsole");
m_settings->reset("AutoCloseConsole"); m_settings->reset("AutoCloseConsole");
m_settings->reset("ShowConsoleOnError");
} }
// Window Size // Window Size
@ -137,6 +139,7 @@ void InstanceSettingsPage::loadSettings()
ui->consoleSettingsBox->setChecked(m_settings->get("OverrideConsole").toBool()); ui->consoleSettingsBox->setChecked(m_settings->get("OverrideConsole").toBool());
ui->showConsoleCheck->setChecked(m_settings->get("ShowConsole").toBool()); ui->showConsoleCheck->setChecked(m_settings->get("ShowConsole").toBool());
ui->autoCloseConsoleCheck->setChecked(m_settings->get("AutoCloseConsole").toBool()); ui->autoCloseConsoleCheck->setChecked(m_settings->get("AutoCloseConsole").toBool());
ui->showConsoleErrorCheck->setChecked(m_settings->get("ShowConsoleOnError").toBool());
// Window Size // Window Size
ui->windowSizeGroupBox->setChecked(m_settings->get("OverrideWindow").toBool()); ui->windowSizeGroupBox->setChecked(m_settings->get("OverrideWindow").toBool());

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>458</width> <width>458</width>
<height>426</height> <height>508</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -332,6 +332,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="showConsoleErrorCheck">
<property name="text">
<string>Show console when the game crashes?</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -458,6 +465,7 @@
<tabstop>consoleSettingsBox</tabstop> <tabstop>consoleSettingsBox</tabstop>
<tabstop>showConsoleCheck</tabstop> <tabstop>showConsoleCheck</tabstop>
<tabstop>autoCloseConsoleCheck</tabstop> <tabstop>autoCloseConsoleCheck</tabstop>
<tabstop>showConsoleErrorCheck</tabstop>
<tabstop>customCommandsGroupBox</tabstop> <tabstop>customCommandsGroupBox</tabstop>
<tabstop>preLaunchCmdTextBox</tabstop> <tabstop>preLaunchCmdTextBox</tabstop>
<tabstop>wrapperCmdTextBox</tabstop> <tabstop>wrapperCmdTextBox</tabstop>

View File

@ -317,6 +317,7 @@ void MultiMCPage::applySettings()
// Console settings // Console settings
s->set("ShowConsole", ui->showConsoleCheck->isChecked()); s->set("ShowConsole", ui->showConsoleCheck->isChecked());
s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked());
s->set("ShowConsoleOnError", ui->showConsoleErrorCheck->isChecked());
QString consoleFontFamily = ui->consoleFont->currentFont().family(); QString consoleFontFamily = ui->consoleFont->currentFont().family();
s->set("ConsoleFont", consoleFontFamily); s->set("ConsoleFont", consoleFontFamily);
s->set("ConsoleFontSize", ui->fontSizeBox->value()); s->set("ConsoleFontSize", ui->fontSizeBox->value());
@ -413,6 +414,7 @@ void MultiMCPage::loadSettings()
// Console settings // Console settings
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool()); ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool());
ui->showConsoleErrorCheck->setChecked(s->get("ShowConsoleOnError").toBool());
QString fontFamily = MMC->settings()->get("ConsoleFont").toString(); QString fontFamily = MMC->settings()->get("ConsoleFont").toString();
QFont consoleFont(fontFamily); QFont consoleFont(fontFamily);
ui->consoleFont->setCurrentFont(consoleFont); ui->consoleFont->setCurrentFont(consoleFont);

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>487</width> <width>487</width>
<height>557</height> <height>614</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -456,6 +456,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="showConsoleErrorCheck">
<property name="text">
<string>Show console when the game crashes?</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -588,6 +595,7 @@
<tabstop>themeComboBoxColors</tabstop> <tabstop>themeComboBoxColors</tabstop>
<tabstop>showConsoleCheck</tabstop> <tabstop>showConsoleCheck</tabstop>
<tabstop>autoCloseConsoleCheck</tabstop> <tabstop>autoCloseConsoleCheck</tabstop>
<tabstop>showConsoleErrorCheck</tabstop>
<tabstop>lineLimitSpinBox</tabstop> <tabstop>lineLimitSpinBox</tabstop>
<tabstop>checkStopLogging</tabstop> <tabstop>checkStopLogging</tabstop>
<tabstop>consoleFont</tabstop> <tabstop>consoleFont</tabstop>