Skip to content

Commit

Permalink
Add support for client command /variant+"VA" packets force variant ch…
Browse files Browse the repository at this point in the history
…ange
  • Loading branch information
Chrezm committed Feb 1, 2020
1 parent 4da2f5d commit a7096e5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
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
4 changes: 3 additions & 1 deletion aoapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ 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();
Expand Down Expand Up @@ -268,7 +270,7 @@ class AOApplication : public QApplication
const int MINOR_VERSION = 8;

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

QVector<server_type> server_list;
QVector<server_type> favorite_list;
Expand Down
19 changes: 19 additions & 0 deletions courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,12 @@ void Courtroom::handle_clock(QString time)
ui_vp_clock->play(string);
}

void Courtroom::handle_theme_variant(QString theme_variant)
{
ao_app->set_theme_variant(theme_variant);
on_reload_theme_clicked();
}

void Courtroom::set_window_title(QString p_title)
{
this->setWindowTitle(p_title);
Expand Down Expand Up @@ -2968,6 +2974,19 @@ void Courtroom::on_ooc_return_pressed()
{
m_sfx_player->play(ao_app->get_sfx("coinflip"));
}
else if (ooc_message.startsWith("/variant"))
{
int space_location = ooc_message.indexOf(" ");
QString variant;

if (space_location == -1)
variant = "";
else
variant = ooc_message.mid(space_location+1);

handle_theme_variant(variant);
}

QStringList packet_contents;
packet_contents.append(ui_ooc_chat_name->text());
packet_contents.append(ooc_message);
Expand Down
3 changes: 3 additions & 0 deletions courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ class Courtroom : public QMainWindow
//handle server-side clock animation and display
void handle_clock(QString time);

//handle request to change theme variant
void handle_theme_variant(QString theme_variant);

void play_preanim();

QString parse_message(QString message);
Expand Down
7 changes: 7 additions & 0 deletions packet_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,13 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
{
w_courtroom->handle_clock(f_contents.at(1));
}
else if (header == "VA")
{
if (courtroom_constructed)
{
w_courtroom->handle_theme_variant(f_contents.at(0));
}
}

end:

Expand Down

0 comments on commit a7096e5

Please sign in to comment.