aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aoapplication.cpp22
-rw-r--r--aoapplication.h11
-rw-r--r--courtroom.cpp2
-rw-r--r--text_file_functions.cpp72
4 files changed, 64 insertions, 43 deletions
diff --git a/aoapplication.cpp b/aoapplication.cpp
index 6e95a522..cfa96488 100644
--- a/aoapplication.cpp
+++ b/aoapplication.cpp
@@ -15,6 +15,9 @@ AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
discord = new AttorneyOnline::Discord();
QObject::connect(net_manager, SIGNAL(ms_connect_finished(bool, bool)),
SLOT(ms_connect_finished(bool, bool)));
+
+ // Create the QSettings class that points to the config.ini.
+ configini = new QSettings(get_base_path() + "config.ini", QSettings::IniFormat);
}
AOApplication::~AOApplication()
@@ -43,6 +46,25 @@ void AOApplication::construct_lobby()
discord->state_lobby();
w_lobby->show();
+
+ // Change the default audio output device to be the one the user has given
+ // in his config.ini file for now.
+ int a = 0;
+ BASS_DEVICEINFO info;
+
+ for (a = 1; BASS_GetDeviceInfo(a, &info); a++)
+ {
+ if (get_audio_output_device() == info.name)
+ {
+ BASS_SetDevice(a);
+ qDebug() << info.name << "was set as the default audio output device.";
+ break;
+ }
+ qDebug() << info.name;
+ }
+
+ //AOOptionsDialog* test = new AOOptionsDialog(nullptr, this);
+ //test->exec();
}
void AOApplication::destruct_lobby()
diff --git a/aoapplication.h b/aoapplication.h
index 9252cdd6..a01ef812 100644
--- a/aoapplication.h
+++ b/aoapplication.h
@@ -8,6 +8,7 @@
#include <QApplication>
#include <QVector>
#include <QFile>
+#include <QSettings>
class NetworkManager;
class Lobby;
@@ -113,8 +114,13 @@ public:
////// Functions for reading and writing files //////
// Implementations file_functions.cpp
+ // Instead of reinventing the wheel, we'll use a QSettings class.
+ QSettings *configini;
+
//Returns the config value for the passed searchline from a properly formatted config ini file
- QString read_config(QString searchline);
+ //QString read_config(QString searchline);
+
+ // No longer necessary.
//Reads the theme from config.ini and loads it into the current_theme variable
QString read_theme();
@@ -145,6 +151,9 @@ public:
// Returns the username the user may have set in config.ini.
QString get_default_username();
+ // Returns the audio device used for the client.
+ QString get_audio_output_device();
+
// Returns whether the user would like to have custom shownames on by default.
bool get_showname_enabled_by_default();
diff --git a/courtroom.cpp b/courtroom.cpp
index 3a5173c8..b275b1fc 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -1222,6 +1222,7 @@ void Courtroom::handle_chatmessage_3()
break;
default:
qDebug() << "W: invalid anim_state: " << f_anim_state;
+ // fall through
case 3:
ui_vp_player_char->play_idle(f_char, f_emote);
anim_state = 3;
@@ -1988,6 +1989,7 @@ void Courtroom::set_text_color()
break;
default:
qDebug() << "W: undefined text color: " << m_chatmessage[TEXT_COLOR];
+ // fall through
case WHITE:
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
"color: white");
diff --git a/text_file_functions.cpp b/text_file_functions.cpp
index 8ddeb6cb..bacbe69c 100644
--- a/text_file_functions.cpp
+++ b/text_file_functions.cpp
@@ -8,6 +8,9 @@
#include <QDebug>
#include <QColor>
+/*
+ * This may no longer be necessary, if we use the QSettings class.
+ *
QString AOApplication::read_config(QString searchline)
{
QString return_value = "";
@@ -41,80 +44,66 @@ QString AOApplication::read_config(QString searchline)
return return_value;
}
+*/
QString AOApplication::read_theme()
{
- QString result = read_config("theme");
-
- if (result == "")
- return "default";
- else
- return result;
+ QString result = configini->value("theme", "default").value<QString>();
+ return result;
}
int AOApplication::read_blip_rate()
{
- QString result = read_config("blip_rate");
-
- //note: the empty string converted to int will return 0
- if (result.toInt() <= 0)
- return 1;
- else
- return result.toInt();
+ int result = configini->value("blip_rate", 1).toInt();
+ return result;
}
int AOApplication::get_default_music()
{
- QString f_result = read_config("default_music");
-
- if (f_result == "")
- return 50;
- else return f_result.toInt();
+ int result = configini->value("default_music", 50).toInt();
+ return result;
}
int AOApplication::get_default_sfx()
{
- QString f_result = read_config("default_sfx");
-
- if (f_result == "")
- return 50;
- else return f_result.toInt();
+ int result = configini->value("default_sfx", 50).toInt();
+ return result;
}
int AOApplication::get_default_blip()
{
- QString f_result = read_config("default_blip");
-
- if (f_result == "")
- return 50;
- else return f_result.toInt();
+ int result = configini->value("default_blip", 50).toInt();
+ return result;
}
int AOApplication::get_max_log_size()
{
- QString f_result = read_config("log_maximum");
-
- if (f_result == "")
- return 200;
- else return f_result.toInt();
+ int result = configini->value("log_maximum", 200).toInt();
+ return result;
}
bool AOApplication::get_log_goes_downwards()
{
- QString f_result = read_config("log_goes_downwards");
- return f_result.startsWith("true");
+ QString result = configini->value("log_goes_downwards", "false").value<QString>();
+ return result.startsWith("true");
}
bool AOApplication::get_showname_enabled_by_default()
{
- QString f_result = read_config("show_custom_shownames");
- return f_result.startsWith("true");
+ QString result = configini->value("show_custom_shownames", "false").value<QString>();
+ return result.startsWith("true");
}
QString AOApplication::get_default_username()
{
- QString f_result = read_config("default_username");
- return f_result;
+ QString result = configini->value("default_username", "").value<QString>();
+ return result;
+}
+
+QString AOApplication::get_audio_output_device()
+{
+ QString result = configini->value("default_username", "default").value<QString>();
+ return result;
}
QStringList AOApplication::get_call_words()
@@ -593,9 +582,8 @@ int AOApplication::get_text_delay(QString p_char, QString p_emote)
bool AOApplication::get_blank_blip()
{
- QString f_result = read_config("blank_blip");
-
- return f_result.startsWith("true");
+ QString result = configini->value("blank_blip", "false").value<QString>();
+ return result.startsWith("true");
}