aboutsummaryrefslogtreecommitdiff
path: root/src/text_file_functions.cpp
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2021-06-06 23:23:33 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2021-06-06 23:23:33 -0500
commit9ecd7c453c3b34a976869e517f9414a4b91fdb0f (patch)
tree8a901493f6ebf1dee5792bfa2d24b60fb90cdfba /src/text_file_functions.cpp
parent2ef7b206e24d9af112c8b466c006aa98e072e235 (diff)
parent97f3d7a8bc43ee78691153bb60993ba734dbefde (diff)
Merge branch 'master' into feature/mounting
Diffstat (limited to 'src/text_file_functions.cpp')
-rw-r--r--src/text_file_functions.cpp83
1 files changed, 47 insertions, 36 deletions
diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp
index 9c463417..fbe8279f 100644
--- a/src/text_file_functions.cpp
+++ b/src/text_file_functions.cpp
@@ -112,6 +112,12 @@ QString AOApplication::get_default_username()
return result;
}
+QString AOApplication::get_default_showname()
+{
+ QString result = configini->value("default_showname", "").value<QString>();
+ return result;
+}
+
QString AOApplication::get_audio_output_device()
{
QString result =
@@ -248,33 +254,31 @@ QVector<server_type> AOApplication::read_serverlist_txt()
serverlist_txt.setFileName(serverlist_txt_path);
- if (!serverlist_txt.open(QIODevice::ReadOnly)) {
- return f_server_list;
- }
+ if (serverlist_txt.open(QIODevice::ReadOnly)) {
+ QTextStream in(&serverlist_txt);
- QTextStream in(&serverlist_txt);
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ server_type f_server;
+ QStringList line_contents = line.split(":");
- while (!in.atEnd()) {
- QString line = in.readLine();
- server_type f_server;
- QStringList line_contents = line.split(":");
-
- if (line_contents.size() < 3)
- continue;
+ if (line_contents.size() < 3)
+ continue;
- f_server.ip = line_contents.at(0);
- f_server.port = line_contents.at(1).toInt();
- f_server.name = line_contents.at(2);
- f_server.desc = "";
+ f_server.ip = line_contents.at(0);
+ f_server.port = line_contents.at(1).toInt();
+ f_server.name = line_contents.at(2);
+ f_server.desc = "";
- f_server_list.append(f_server);
+ f_server_list.append(f_server);
+ }
}
server_type demo_server;
demo_server.ip = "127.0.0.1";
demo_server.port = 99999;
- demo_server.name = "Demo playback";
- demo_server.desc = "Play back demos you have previously recorded";
+ demo_server.name = tr("Demo playback");
+ demo_server.desc = tr("Play back demos you have previously recorded");
f_server_list.append(demo_server);
return f_server_list;
@@ -290,6 +294,7 @@ QString AOApplication::read_design_ini(QString p_identifier,
QString p_design_path)
{
QSettings settings(p_design_path, QSettings::IniFormat);
+ settings.setIniCodec("UTF-8");
QVariant value = settings.value(p_identifier);
if (value.type() == QVariant::StringList) {
return value.toStringList().join(",");
@@ -302,6 +307,9 @@ QString AOApplication::read_design_ini(QString p_identifier,
Qt::TransformationMode AOApplication::get_scaling(QString p_scaling)
{
+ if (p_scaling.isEmpty())
+ p_scaling = get_default_scaling();
+
if (p_scaling == "smooth")
return Qt::SmoothTransformation;
return Qt::FastTransformation;
@@ -448,20 +456,20 @@ QString AOApplication::get_chat_markup(QString p_identifier, QString p_chat)
// New Chadly method
QString value = get_config_value(p_identifier, "chat_config.ini", current_theme, get_subtheme(), default_theme, p_chat);
if (!value.isEmpty())
- return value.toLatin1();
+ return value.toUtf8();
// Backwards ass compatibility
QVector<VPath> backwards_paths {
get_theme_path("misc/" + p_chat + "/config.ini"),
VPath("misc/" + p_chat + "/config.ini"),
- VPath("misc/default/config.ini"),
- get_theme_path("misc/default/config.ini")
+ get_theme_path("misc/default/config.ini"),
+ VPath("misc/default/config.ini")
};
for (const VPath &p : backwards_paths) {
QString value = read_design_ini(p_identifier, p);
if (!value.isEmpty()) {
- return value.toLatin1();
+ return value.toUtf8();
}
}
@@ -491,7 +499,7 @@ QString AOApplication::get_court_sfx(QString p_identifier, QString p_misc)
{
QString value = get_config_value(p_identifier, "courtroom_sounds.ini", current_theme, get_subtheme(), default_theme, p_misc);
if (!value.isEmpty())
- return value.toLatin1();
+ return value.toUtf8();
return "";
}
@@ -521,6 +529,7 @@ QString AOApplication::read_char_ini(QString p_char, QString p_search_line,
QSettings settings(get_real_path(get_character_path(p_char, "char.ini")),
QSettings::IniFormat);
settings.beginGroup(target_tag);
+ settings.setIniCodec("UTF-8");
QString value = settings.value(p_search_line).value<QString>();
settings.endGroup();
return value;
@@ -541,6 +550,7 @@ QStringList AOApplication::read_ini_tags(VPath p_path, QString target_tag)
{
QStringList r_values;
QSettings settings(get_real_path(p_path), QSettings::IniFormat);
+ settings.setIniCodec("UTF-8");
if (!target_tag.isEmpty())
settings.beginGroup(target_tag);
QStringList keys = settings.allKeys();
@@ -666,15 +676,6 @@ int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
return f_result.toInt();
}
-int AOApplication::get_ao2_preanim_duration(QString p_char, QString p_emote)
-{
- QString f_result = read_char_ini(p_char, "%" + p_emote, "Time");
-
- if (f_result == "")
- return -1;
- return f_result.toInt();
-}
-
int AOApplication::get_emote_number(QString p_char)
{
QString f_result = read_char_ini(p_char, "number", "Emotions");
@@ -842,7 +843,7 @@ QStringList AOApplication::get_effects(QString p_char)
{
QString p_misc = read_char_ini(p_char, "effects", "Options");
QString p_path = get_asset("effects/effects.ini", current_theme, get_subtheme(), default_theme, "");
- QString p_misc_path = get_asset("effects/effects.ini", current_theme, get_subtheme(), default_theme, p_misc);
+ QString p_misc_path = get_asset("effects.ini", current_theme, get_subtheme(), default_theme, p_misc);
QStringList effects;
QStringList lines = read_file(p_path).split("\n");
@@ -865,10 +866,13 @@ QString AOApplication::get_effect(QString effect, QString p_char,
if (p_folder == "")
p_folder = read_char_ini(p_char, "effects", "Options");
- QString p_path = get_image("effects/" + effect, current_theme, get_subtheme(), default_theme, p_folder);
+ QString p_path = get_image("effects/" + effect, current_theme, get_subtheme(), default_theme, "");
+ QString p_misc_path = get_image(effect, current_theme, get_subtheme(), default_theme, p_folder);
- if (!file_exists(p_path))
+ if (!file_exists(p_misc_path) && !file_exists(p_path))
return "";
+ else if (file_exists(p_misc_path))
+ return p_misc_path;
return p_path;
}
@@ -881,7 +885,9 @@ QString AOApplication::get_effect_property(QString fx_name, QString p_char,
else
f_property = fx_name + "_" + p_property;
- QString f_result = get_config_value(f_property, "effects/effects.ini", current_theme, get_subtheme(), default_theme, read_char_ini(p_char, "effects", "Options"));
+ QString f_result = get_config_value(f_property, "effects.ini", current_theme, get_subtheme(), default_theme, read_char_ini(p_char, "effects", "Options"));
+ if (f_result == "")
+ f_result = get_config_value(f_property, "effects/effects.ini", current_theme, get_subtheme(), default_theme, "");
if (fx_name == "realization" && p_property == "sound") {
f_result = get_custom_realization(p_char);
}
@@ -1083,6 +1089,11 @@ bool AOApplication::get_animated_theme()
return result.startsWith("true");
}
+QString AOApplication::get_default_scaling()
+{
+ return configini->value("default_scaling", "fast").value<QString>();
+}
+
QStringList AOApplication::get_mount_paths()
{
return configini->value("mount_paths").value<QStringList>();