config.ini functioning changed.
- Now the program uses the QSettings class to manipulate the `config.ini`. - Support for multiple audio devices and options menu started.
This commit is contained in:
parent
1524b88423
commit
c85244e38c
@ -15,6 +15,9 @@ AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
discord = new AttorneyOnline::Discord();
|
discord = new AttorneyOnline::Discord();
|
||||||
QObject::connect(net_manager, SIGNAL(ms_connect_finished(bool, bool)),
|
QObject::connect(net_manager, SIGNAL(ms_connect_finished(bool, bool)),
|
||||||
SLOT(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()
|
AOApplication::~AOApplication()
|
||||||
@ -43,6 +46,25 @@ void AOApplication::construct_lobby()
|
|||||||
discord->state_lobby();
|
discord->state_lobby();
|
||||||
|
|
||||||
w_lobby->show();
|
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()
|
void AOApplication::destruct_lobby()
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
class NetworkManager;
|
class NetworkManager;
|
||||||
class Lobby;
|
class Lobby;
|
||||||
@ -113,8 +114,13 @@ public:
|
|||||||
////// Functions for reading and writing files //////
|
////// Functions for reading and writing files //////
|
||||||
// Implementations file_functions.cpp
|
// 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
|
//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
|
//Reads the theme from config.ini and loads it into the current_theme variable
|
||||||
QString read_theme();
|
QString read_theme();
|
||||||
@ -145,6 +151,9 @@ public:
|
|||||||
// Returns the username the user may have set in config.ini.
|
// Returns the username the user may have set in config.ini.
|
||||||
QString get_default_username();
|
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.
|
// Returns whether the user would like to have custom shownames on by default.
|
||||||
bool get_showname_enabled_by_default();
|
bool get_showname_enabled_by_default();
|
||||||
|
|
||||||
|
@ -1222,6 +1222,7 @@ void Courtroom::handle_chatmessage_3()
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug() << "W: invalid anim_state: " << f_anim_state;
|
qDebug() << "W: invalid anim_state: " << f_anim_state;
|
||||||
|
// fall through
|
||||||
case 3:
|
case 3:
|
||||||
ui_vp_player_char->play_idle(f_char, f_emote);
|
ui_vp_player_char->play_idle(f_char, f_emote);
|
||||||
anim_state = 3;
|
anim_state = 3;
|
||||||
@ -1988,6 +1989,7 @@ void Courtroom::set_text_color()
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug() << "W: undefined text color: " << m_chatmessage[TEXT_COLOR];
|
qDebug() << "W: undefined text color: " << m_chatmessage[TEXT_COLOR];
|
||||||
|
// fall through
|
||||||
case WHITE:
|
case WHITE:
|
||||||
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
||||||
"color: white");
|
"color: white");
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This may no longer be necessary, if we use the QSettings class.
|
||||||
|
*
|
||||||
QString AOApplication::read_config(QString searchline)
|
QString AOApplication::read_config(QString searchline)
|
||||||
{
|
{
|
||||||
QString return_value = "";
|
QString return_value = "";
|
||||||
@ -41,80 +44,66 @@ QString AOApplication::read_config(QString searchline)
|
|||||||
|
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
QString AOApplication::read_theme()
|
QString AOApplication::read_theme()
|
||||||
{
|
{
|
||||||
QString result = read_config("theme");
|
QString result = configini->value("theme", "default").value<QString>();
|
||||||
|
return result;
|
||||||
if (result == "")
|
|
||||||
return "default";
|
|
||||||
else
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AOApplication::read_blip_rate()
|
int AOApplication::read_blip_rate()
|
||||||
{
|
{
|
||||||
QString result = read_config("blip_rate");
|
int result = configini->value("blip_rate", 1).toInt();
|
||||||
|
return result;
|
||||||
//note: the empty string converted to int will return 0
|
|
||||||
if (result.toInt() <= 0)
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return result.toInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AOApplication::get_default_music()
|
int AOApplication::get_default_music()
|
||||||
{
|
{
|
||||||
QString f_result = read_config("default_music");
|
int result = configini->value("default_music", 50).toInt();
|
||||||
|
return result;
|
||||||
if (f_result == "")
|
|
||||||
return 50;
|
|
||||||
else return f_result.toInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AOApplication::get_default_sfx()
|
int AOApplication::get_default_sfx()
|
||||||
{
|
{
|
||||||
QString f_result = read_config("default_sfx");
|
int result = configini->value("default_sfx", 50).toInt();
|
||||||
|
return result;
|
||||||
if (f_result == "")
|
|
||||||
return 50;
|
|
||||||
else return f_result.toInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AOApplication::get_default_blip()
|
int AOApplication::get_default_blip()
|
||||||
{
|
{
|
||||||
QString f_result = read_config("default_blip");
|
int result = configini->value("default_blip", 50).toInt();
|
||||||
|
return result;
|
||||||
if (f_result == "")
|
|
||||||
return 50;
|
|
||||||
else return f_result.toInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AOApplication::get_max_log_size()
|
int AOApplication::get_max_log_size()
|
||||||
{
|
{
|
||||||
QString f_result = read_config("log_maximum");
|
int result = configini->value("log_maximum", 200).toInt();
|
||||||
|
return result;
|
||||||
if (f_result == "")
|
|
||||||
return 200;
|
|
||||||
else return f_result.toInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AOApplication::get_log_goes_downwards()
|
bool AOApplication::get_log_goes_downwards()
|
||||||
{
|
{
|
||||||
QString f_result = read_config("log_goes_downwards");
|
QString result = configini->value("log_goes_downwards", "false").value<QString>();
|
||||||
return f_result.startsWith("true");
|
return result.startsWith("true");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AOApplication::get_showname_enabled_by_default()
|
bool AOApplication::get_showname_enabled_by_default()
|
||||||
{
|
{
|
||||||
QString f_result = read_config("show_custom_shownames");
|
QString result = configini->value("show_custom_shownames", "false").value<QString>();
|
||||||
return f_result.startsWith("true");
|
return result.startsWith("true");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AOApplication::get_default_username()
|
QString AOApplication::get_default_username()
|
||||||
{
|
{
|
||||||
QString f_result = read_config("default_username");
|
QString result = configini->value("default_username", "").value<QString>();
|
||||||
return f_result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AOApplication::get_audio_output_device()
|
||||||
|
{
|
||||||
|
QString result = configini->value("default_username", "default").value<QString>();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AOApplication::get_call_words()
|
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()
|
bool AOApplication::get_blank_blip()
|
||||||
{
|
{
|
||||||
QString f_result = read_config("blank_blip");
|
QString result = configini->value("blank_blip", "false").value<QString>();
|
||||||
|
return result.startsWith("true");
|
||||||
return f_result.startsWith("true");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user