new function tags and fallback paths

This commit is contained in:
stonedDiscord 2017-03-18 14:04:14 +01:00
parent c2db480d68
commit 146ef97311
7 changed files with 48 additions and 20 deletions

View File

@ -54,6 +54,7 @@ void AOCharButton::set_image(QString p_character)
{
QString image_path = ao_app->get_character_path(p_character) + "char_icon.png";
QString legacy_path = ao_app->get_demothings_path() + p_character.toLower() + "_char_icon.png";
QString alt_path = ao_app->get_demothings_path() + p_character.toLower() + "_off.png";
this->setText("");

View File

@ -25,12 +25,15 @@ AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_
void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
{
QString original_path = ao_app->get_character_path(p_char) + emote_prefix + p_emote.toLower() + ".gif";
QString alt_path = ao_app->get_character_path(p_char) + p_emote.toLower() + ".png";
QString placeholder_path = ao_app->get_theme_path() + "placeholder.gif";
QString placeholder_default_path = ao_app->get_default_theme_path() + "placeholder.gif";
QString gif_path;
if (file_exists(original_path))
gif_path = original_path;
else if (file_exists(alt_path))
gif_path = alt_path;
else if (file_exists(placeholder_path))
gif_path = placeholder_path;
else

View File

@ -27,6 +27,7 @@ void AOMovie::play(QString p_gif, QString p_char)
QString gif_path;
QString custom_path = ao_app->get_character_path(p_char) + p_gif + ".gif";
QString alt_path = ao_app->get_character_path(p_char) + p_gif + ".png";
QString theme_path = ao_app->get_theme_path() + p_gif + ".gif";
QString default_theme_path = ao_app->get_default_theme_path() + p_gif + ".gif";
QString placeholder_path = ao_app->get_theme_path() + "placeholder.gif";
@ -34,6 +35,8 @@ void AOMovie::play(QString p_gif, QString p_char)
if (file_exists(custom_path))
gif_path = custom_path;
else if (file_exists(alt_path))
gif_path = alt_path;
else if (file_exists(theme_path))
gif_path = theme_path;
else if (file_exists(default_theme_path))

View File

@ -1,4 +1,5 @@
#include <QFileInfo>
#include <QDir>
#include "file_functions.h"
@ -8,3 +9,10 @@ bool file_exists(QString file_path)
return check_file.exists() && check_file.isFile();
}
bool dir_exists(QString dir_path)
{
QDir check_dir(dir_path);
return check_dir.exists();
}

View File

@ -4,5 +4,6 @@
#include <QString>
bool file_exists(QString file_path);
bool dir_exists(QString file_path);
#endif // FILE_FUNCTIONS_H

View File

@ -165,23 +165,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
server_minor = version_list.at(2).toInt();
}
}
if (server_software == "v1312.150")
{
encryption_needed = false;
custom_objection_enabled = true;
}
else if (server_software == "tsuserver3")
{
if (server_release >= 3)
{
yellow_text_enabled = true;
flipping_enabled = true;
custom_objection_enabled = true;
improved_loading_enabled = true;
}
}
send_server_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%"));
}
else if (header == "CT")
@ -192,6 +175,19 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (courtroom_constructed)
w_courtroom->append_server_chatmessage(f_contents.at(0), f_contents.at(1));
}
else if (header == "FL")
{
if (f_packet.contains("yellowtext",Qt::CaseInsensitive))
yellow_text_enabled = true;
if (f_packet.contains("flipping",Qt::CaseInsensitive))
flipping_enabled = true;
if (f_packet.contains("customobjections",Qt::CaseInsensitive))
custom_objection_enabled = true;
if (f_packet.contains("fastloading",Qt::CaseInsensitive))
improved_loading_enabled = true;
if (f_packet.contains("noencryption",Qt::CaseInsensitive))
encryption_needed = false;
}
else if (header == "PN")
{
if (f_contents.size() < 2)

View File

@ -1,6 +1,6 @@
#include "aoapplication.h"
#include "courtroom.h"
#include "file_functions.h"
#include <QDir>
#include <QDebug>
@ -16,7 +16,16 @@ QString AOApplication::get_base_path()
#elif defined(ANDROID)
return "/storage/extSdCard/AO2/";
#else
return (QDir::currentPath() + "/base/");
QString default_path = "/base/";
QString alt_path = "/data/";
if (dir_exists(default_path))
return QDir::currentPath() + default_path;
else if (dir_exists(alt_path))
return QDir::currentPath() + alt_path;
else
return QDir::currentPath() + default_path;
#endif
}
@ -37,7 +46,14 @@ QString AOApplication::get_character_path(QString p_character)
QString AOApplication::get_demothings_path()
{
return get_base_path() + "misc/demothings/";
QString default_path = "misc/demothings/";
QString alt_path = "misc/RosterImages";
if (dir_exists(default_path))
return get_base_path() + default_path;
else if (dir_exists(alt_path))
return get_base_path() + alt_path;
else
return get_base_path() + default_path;
}
QString AOApplication::get_sounds_path()
{