Skip to content

Commit

Permalink
Merge pull request #1 from Chrezm/variant
Browse files Browse the repository at this point in the history
Variant
  • Loading branch information
Chrezm authored Feb 1, 2020
2 parents abe2336 + a7096e5 commit 9bf7dd9
Show file tree
Hide file tree
Showing 17 changed files with 427 additions and 424 deletions.
5 changes: 5 additions & 0 deletions aoapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ void AOApplication::reload_theme()
current_theme = read_theme();
}

void AOApplication::set_theme_variant(QString theme_variant)
{
this->theme_variant = theme_variant;
}

void AOApplication::set_favorite_list()
{
favorite_list = read_serverlist_txt();
Expand Down
10 changes: 10 additions & 0 deletions aoapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class AOApplication : public QApplication
QString get_base_path();
QString get_data_path();
QString get_theme_path();
QString get_theme_variant_path();
QString get_default_theme_path();
QString get_character_path(QString p_character);
QString get_demothings_path();
Expand Down Expand Up @@ -149,13 +150,18 @@ class AOApplication : public QApplication
//Overwrites config.ini with new theme
void write_theme(QString theme);

//Set the theme variant
void set_theme_variant(QString theme_variant);

//Returns the contents of serverlist.txt
QVector<server_type> read_serverlist_txt();

//Returns the value of p_identifier in the design.ini file in p_design_path
QString read_design_ini(QString p_identifier, QString p_design_path);

//Returns the value of p_identifier from p_file in either a theme variant subfolder, a theme folder, or default theme folder
QString read_theme_ini(QString p_identifier, QString p_file);

//Helper function for returning an int in a file inside of the theme folder
int get_design_ini_value(QString p_identifier, QString p_design_file);

Expand Down Expand Up @@ -255,12 +261,16 @@ class AOApplication : public QApplication
//Returns p_char's gender
QString get_gender(QString p_char);

//Get the location of p_image, which is either in a theme variant subfolder, a theme folder, or default theme folder
QString get_image_path(QString p_image);

private:
const int RELEASE = 2;
const int MAJOR_VERSION = 4;
const int MINOR_VERSION = 8;

QString current_theme = "default";
QString theme_variant = "";

QVector<server_type> server_list;
QVector<server_type> favorite_list;
Expand Down
31 changes: 17 additions & 14 deletions aobutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ AOButton::~AOButton()
void AOButton::set_image(QString p_image)
{
QString f_image_name = p_image.left(p_image.lastIndexOf(QChar('.')));
QString image_path = ao_app->get_theme_path() + p_image;
QString hover_image_path = ao_app->get_theme_path() + f_image_name + "_hover.png";
QString default_image_path = ao_app->get_default_theme_path() + p_image;

if (file_exists(image_path))
{
if(file_exists(hover_image_path))
this->setStyleSheet("QPushButton {border-image:url(\"" + image_path + "\");}"
"QPushButton:hover {border-image:url(\"" + hover_image_path + "\");}");
else
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
}

QString some_image_path = ao_app->get_image_path(p_image);
QString some_hover_image_path = ao_app->get_image_path(p_image + "_hover.png");

if (file_exists(some_image_path))
{
image_path = some_image_path;

if (file_exists(some_hover_image_path))
this->setStyleSheet("QPushButton {border-image:url(\"" + some_image_path + "\");}"
"QPushButton:hover {border-image:url(\"" + some_hover_image_path + "\");}");
else
this->setStyleSheet("border-image:url(\"" + some_image_path + "\")");
}
else
this->setStyleSheet("border-image:url(\"" + default_image_path + "\")");
{
image_path = "";
this->setStyleSheet("border-image:url(\"" + some_image_path + "\")");
}
}
2 changes: 2 additions & 0 deletions aobutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class AOButton : public QPushButton
AOApplication *ao_app = nullptr;

void set_image(QString p_image);

QString image_path = "";
};

#endif // AOBUTTON_H
32 changes: 10 additions & 22 deletions aocharmovie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,17 @@ AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_

void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix, bool show)
{
QStringList f_vec;

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
// gif_path = placeholder_default_path;

f_vec.push_back(original_path);
f_vec.push_back(alt_path);
f_vec.push_back(placeholder_path);
f_vec.push_back(placeholder_default_path);

for(auto &f_file : f_vec)
QStringList f_vec;
QStringList f_paths{
ao_app->get_character_path(p_char) + emote_prefix + p_emote.toLower(), // .gif
ao_app->get_character_path(p_char) + p_emote.toLower(), // .png
ao_app->get_theme_variant_path() + "placeholder", // .gif
ao_app->get_theme_path() + "placeholder", // .gif
ao_app->get_default_theme_path() + "placeholder" // .gif
};

for(auto &f_file : f_paths)
{
bool found = false;
for (auto &ext : decltype(f_vec){".apng", ".gif", ".png"})
Expand Down
13 changes: 2 additions & 11 deletions aoevidencebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,9 @@ void AOEvidenceButton::set_image(QString p_image)

void AOEvidenceButton::set_theme_image(QString p_image)
{
QString theme_image_path = ao_app->get_theme_path() + p_image;
QString default_image_path = ao_app->get_default_theme_path() + p_image;

QString final_image_path;

if (file_exists(theme_image_path))
final_image_path = theme_image_path;
else
final_image_path = default_image_path;

QString path = ao_app->get_image_path(p_image);
this->setText("");
this->setStyleSheet("border-image:url(\"" + final_image_path + "\")");
this->setStyleSheet("border-image:url(\"" + path + "\")");
}

void AOEvidenceButton::set_selected(bool p_selected)
Expand Down
13 changes: 2 additions & 11 deletions aoevidencedisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,10 @@ void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_sid

evidence_icon->move(icon_dimensions.x, icon_dimensions.y);
evidence_icon->resize(icon_dimensions.width, icon_dimensions.height);

evidence_icon->setPixmap(f_pixmap.scaled(evidence_icon->width(), evidence_icon->height(), Qt::IgnoreAspectRatio));

QString f_default_gif_path = ao_app->get_default_theme_path() + gif_name;
QString f_gif_path = ao_app->get_theme_path() + gif_name;

if (file_exists(f_gif_path))
final_gif_path = f_gif_path;
else
final_gif_path = f_default_gif_path;

evidence_movie->setFileName(final_gif_path);

QString f_path = ao_app->get_image_path(gif_name);
evidence_movie->setFileName(f_path);
if(evidence_movie->frameCount() < 1)
return;

Expand Down
24 changes: 13 additions & 11 deletions aoimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ AOImage::~AOImage()

void AOImage::set_image(QString p_image)
{
QString theme_image_path = ao_app->get_theme_path() + p_image;
QString default_image_path = ao_app->get_default_theme_path() + p_image;
QString f_path = ao_app->get_image_path(p_image);
QPixmap f_pixmap(f_path);

QString final_image_path;
this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));

if (file_exists(theme_image_path))
final_image_path = theme_image_path;
// Store final path if the path exists
if (file_exists(f_path))
image_path = f_path;
else
final_image_path = default_image_path;

QPixmap f_pixmap(final_image_path);

this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
image_path = "";
}

void AOImage::set_image_from_path(QString p_path)
Expand All @@ -43,6 +40,11 @@ void AOImage::set_image_from_path(QString p_path)
final_path = default_path;

QPixmap f_pixmap(final_path);

this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));

// Store final path if the path exists
if (file_exists(final_path))
image_path = final_path;
else
image_path = "";
}
3 changes: 3 additions & 0 deletions aoimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ class AOImage : public QLabel
AOApplication *ao_app = nullptr;

void set_image(QString p_image);
void set_image_variant(QString p_image, QString p_variant);
void set_image_from_path(QString p_path);
void set_size_and_pos(QString identifier);

QString image_path = "";
};

#endif // AOIMAGE_H
11 changes: 2 additions & 9 deletions aolabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ AOLabel::AOLabel(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)

void AOLabel::set_image(QString p_image)
{
QString image_path = ao_app->get_theme_path() + p_image;
QString default_image_path = ao_app->get_default_theme_path() + p_image;

if (file_exists(image_path))
{
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
}
else
this->setStyleSheet("border-image:url(\"" + default_image_path + "\")");
QString f_path = ao_app->get_image_path(p_image);
setStyleSheet("border-image:url(\"" + f_path + "\")");
}
28 changes: 13 additions & 15 deletions aomovie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,18 @@ void AOMovie::play(QString p_file, QString p_char, QString p_custom_theme)

f_vec.push_back(custom_path);

QString overlay_path = ao_app->get_character_path(p_char) + "overlay/" + p_file;
QString custom_theme_path = ao_app->get_base_path() + "themes/" + p_custom_theme + "/" + p_file;
QString theme_path = ao_app->get_theme_path() + p_file;
QString default_theme_path = ao_app->get_default_theme_path() + p_file;
QString placeholder_path = ao_app->get_theme_path() + "placeholder";
QString default_placeholder_path = ao_app->get_default_theme_path() + "placeholder";

f_vec.push_back(overlay_path);
f_vec.push_back(custom_theme_path);
f_vec.push_back(theme_path);
f_vec.push_back(default_theme_path);
f_vec.push_back(placeholder_path);
f_vec.push_back(default_placeholder_path);

for(auto &f_file : f_vec)
QStringList f_paths{
ao_app->get_character_path(p_char) + "overlay/" + p_file,
ao_app->get_base_path() + "themes/" + p_custom_theme + "/" + p_file,
ao_app->get_theme_variant_path() + p_file,
ao_app->get_theme_path() + p_file,
ao_app->get_default_theme_path() + p_file,
ao_app->get_theme_variant_path() + "placeholder",
ao_app->get_theme_path() + "placeholder",
ao_app->get_default_theme_path() + "placeholder"
};

for(auto &f_file : f_paths)
{
bool found = false;
for (auto &ext : decltype(f_vec){".apng", ".gif", ".png"})
Expand All @@ -68,6 +65,7 @@ void AOMovie::play(QString p_file, QString p_char, QString p_custom_theme)
break;
}

qDebug() << file_path;
m_movie->setFileName(file_path);

this->show();
Expand Down
6 changes: 1 addition & 5 deletions aoshoutplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ void AOShoutPlayer::play(QString p_name, QString p_char)
QString f_file;

QString char_path = ao_app->get_character_path(p_char) + p_name.toLower();
QString theme_path = ao_app->get_theme_path() + p_name.toLower();
QString default_theme_path = ao_app->get_default_theme_path() + p_name.toLower();
QString theme_path = ao_app->get_image_path(p_name.toLower());

qDebug() << char_path;
qDebug() << theme_path;
qDebug() << default_theme_path;

if(file_exists(char_path))
f_file = char_path;
else if (file_exists(theme_path))
f_file = theme_path;
else if (file_exists(default_theme_path))
f_file = default_theme_path;
else
f_file = "";

Expand Down
Loading

0 comments on commit 9bf7dd9

Please sign in to comment.