aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmniTroid <davidskoland@gmail.com>2017-03-16 02:05:44 +0100
committerOmniTroid <davidskoland@gmail.com>2017-03-16 02:05:44 +0100
commit3b97f88db4b2e976dbca0f53c7620bc3b819bfcc (patch)
treebf90bbf49e8bfa6751cd5bb08cd44cdf6b0a44f6
parent939f6cc3fd937660f2c3bdf328fdf7fff219a0cc (diff)
fixed the charselect and added some features, ready for 2.2.5 release
-rw-r--r--aoapplication.h5
-rw-r--r--charselect.cpp64
-rw-r--r--courtroom.cpp87
-rw-r--r--courtroom.h10
-rw-r--r--datatypes.h1
-rw-r--r--emotes.cpp1
-rw-r--r--packet_distribution.cpp1
-rw-r--r--text_file_functions.cpp30
8 files changed, 142 insertions, 57 deletions
diff --git a/aoapplication.h b/aoapplication.h
index de6a5614..c52d8246 100644
--- a/aoapplication.h
+++ b/aoapplication.h
@@ -105,6 +105,8 @@ public:
int get_default_blip();
void write_to_serverlist_txt(QString p_line);
QVector<server_type> read_serverlist_txt();
+ QString read_design_ini(QString p_identifier, QString p_design_path);
+ QPoint get_button_spacing(QString p_identifier, QString p_file);
pos_size_type get_element_dimensions(QString p_identifier, QString p_file);
int get_font_size(QString p_identifier, QString p_file);
QString read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag);
@@ -123,9 +125,6 @@ public:
int get_sfx_delay(QString p_char, int p_emote);
int get_emote_mod(QString p_char, int p_emote);
QString get_gender(QString p_char);
- QString read_design_ini(QString p_identifier, QString p_design_path);
-
-
private:
const int RELEASE = 2;
diff --git a/charselect.cpp b/charselect.cpp
index 6465565e..1f18217b 100644
--- a/charselect.cpp
+++ b/charselect.cpp
@@ -1,5 +1,9 @@
#include "courtroom.h"
+#include "file_functions.h"
+#include "debug_functions.h"
+#include "hardware_functions.h"
+
#include <QDebug>
void Courtroom::construct_char_select()
@@ -21,18 +25,27 @@ void Courtroom::construct_char_select()
ui_spectator = new AOButton(ui_char_select_background, ao_app);
- //constructing character button grid
+ QPoint f_spacing = ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini");
+
+ const int button_width = 60;
+ int x_spacing = f_spacing.x();
+ int x_mod_count = 0;
+
+ const int button_height = 60;
+ int y_spacing = f_spacing.y();
+ int y_mod_count = 0;
+
+ set_size_and_pos(ui_char_buttons, "char_buttons");
- const int x_modifier{67};
- int x_mod_count{0};
+ char_columns = ((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) + 1;
+ char_rows = ((ui_char_buttons->height() - button_height) / (y_spacing + button_height)) + 1;
- const int y_modifier{67};
- int y_mod_count{0};
+ max_chars_on_page = char_columns * char_rows;
- for (int n = 0 ; n < 90 ; ++n)
+ for (int n = 0 ; n < max_chars_on_page ; ++n)
{
- int x_pos = (x_modifier * x_mod_count);
- int y_pos = (y_modifier * y_mod_count);
+ int x_pos = (button_width + x_spacing) * x_mod_count;
+ int y_pos = (button_height + y_spacing) * y_mod_count;
ui_char_button_list.append(new AOCharButton(ui_char_buttons, ao_app, x_pos, y_pos));
@@ -42,7 +55,8 @@ void Courtroom::construct_char_select()
++x_mod_count;
//if char number is divisible by ten with rest 9 then the next charicon should start on a new line
- if (n % 10 == 9 && n != 0)
+ //if (n % 10 == 9 && n != 0)
+ if (x_mod_count == char_columns)
{
++y_mod_count;
x_mod_count = 0;
@@ -86,21 +100,21 @@ void Courtroom::set_char_select_page()
for (AOCharButton *i_button : ui_char_button_list)
i_button->hide();
- int total_pages = char_list.size() / 90;
+ int total_pages = char_list.size() / max_chars_on_page;
int chars_on_page = 0;
- if (char_list.size() % 90 != 0)
+ if (char_list.size() % max_chars_on_page != 0)
{
++total_pages;
//i. e. not on the last page
if (total_pages > current_char_page + 1)
- chars_on_page = 90;
+ chars_on_page = max_chars_on_page;
else
- chars_on_page = char_list.size() % 90;
+ chars_on_page = char_list.size() % max_chars_on_page;
}
else
- chars_on_page = 90;
+ chars_on_page = max_chars_on_page;
if (total_pages > current_char_page + 1)
ui_char_select_right->show();
@@ -110,7 +124,7 @@ void Courtroom::set_char_select_page()
for (int n_button = 0 ; n_button < chars_on_page ; ++n_button)
{
- int n_real_char = n_button + current_char_page * 90;
+ int n_real_char = n_button + current_char_page * max_chars_on_page;
AOCharButton *f_button = ui_char_button_list.at(n_button);
f_button->reset();
@@ -123,3 +137,23 @@ void Courtroom::set_char_select_page()
}
+void Courtroom::char_clicked(int n_char)
+{
+ int n_real_char = n_char + current_char_page * max_chars_on_page;
+
+ QString char_ini_path = ao_app->get_character_path(char_list.at(n_real_char).name) + "char.ini";
+ qDebug() << "char_ini_path" << char_ini_path;
+
+ if (!file_exists(char_ini_path))
+ {
+ qDebug() << "did not find " << char_ini_path;
+ call_notice("Could not find " + char_ini_path);
+ return;
+ }
+
+ if (n_real_char == m_cid)
+ enter_courtroom(m_cid);
+ else
+ ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_real_char) + "#" + get_hdid() + "#%"));
+}
+
diff --git a/courtroom.cpp b/courtroom.cpp
index 0eb9d5d2..72574472 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -64,7 +64,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_chatbox = new AOImage(this, ao_app);
ui_vp_showname = new QLabel(ui_vp_chatbox);
- ui_vp_message = new QPlainTextEdit(ui_vp_chatbox);
+ ui_vp_message = new QTextEdit(ui_vp_chatbox);
ui_vp_message->setFrameStyle(QFrame::NoFrame);
ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -167,6 +167,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
if (ao_app->yellow_text_enabled)
ui_text_color->addItem("Yellow");
+
ui_music_slider = new QSlider(Qt::Horizontal, this);
ui_music_slider->setRange(0, 100);
ui_music_slider->setValue(ao_app->get_default_music());
@@ -1177,6 +1178,9 @@ void Courtroom::realization_done()
void Courtroom::start_chat_ticking()
{
+ ui_vp_message->clear();
+ set_text_color();
+ rainbow_counter = 0;
//we need to ensure that the text isn't already ticking because this function can be called by two logic paths
if (text_state != 0)
return;
@@ -1219,11 +1223,42 @@ void Courtroom::chat_tick()
else
{
- ui_vp_message->insertPlainText(f_message.at(tick_pos));
+ QString f_character = f_message.at(tick_pos);
+
+ if (f_character == " ")
+ ui_vp_message->insertPlainText(" ");
+ else if (m_chatmessage[TEXT_COLOR].toInt() == RAINBOW)
+ {
+ QString html_color;
+
+ switch (rainbow_counter)
+ {
+ case 0:
+ html_color = "#FF0000";
+ break;
+ case 1:
+ html_color = "#FF7F00";
+ break;
+ case 2:
+ html_color = "#FFFF00";
+ break;
+ case 3:
+ html_color = "#00FF00";
+ break;
+ default:
+ html_color = "#2d96ff";
+ rainbow_counter = -1;
+ }
+
+ ++rainbow_counter;
+
+ ui_vp_message->insertHtml("<font color=\"" + html_color + "\">" + f_character + "</font>");
+ }
+ else
+ ui_vp_message->insertHtml(f_character);
QScrollBar *scroll = ui_vp_message->verticalScrollBar();
scroll->setValue(scroll->maximum());
- //scroll->hide();
if(blank_blip)
qDebug() << "blank_blip found true";
@@ -1370,10 +1405,6 @@ void Courtroom::set_text_color()
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
"color: yellow");
break;
- case BLACK:
- ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
- "color: black");
- break;
default:
qDebug() << "W: undefined text color: " << m_chatmessage[TEXT_COLOR];
case WHITE:
@@ -1492,12 +1523,16 @@ void Courtroom::mod_called(QString p_ip)
void Courtroom::on_ooc_return_pressed()
{
- if (ui_ooc_chat_message->text() == "" || ui_ooc_chat_name->text() == "")
+ static bool rainbow_appended = false;
+
+ QString ooc_message = ui_ooc_chat_message->text();
+
+ if (ooc_message == "" || ui_ooc_chat_name->text() == "")
return;
- if (ui_ooc_chat_message->text().startsWith("/pos"))
+ if (ooc_message.startsWith("/pos"))
{
- if (ui_ooc_chat_message->text().startsWith("/pos jud"))
+ if (ooc_message.startsWith("/pos jud"))
{
ui_witness_testimony->show();
ui_cross_examination->show();
@@ -1516,14 +1551,19 @@ void Courtroom::on_ooc_return_pressed()
ui_prosecution_plus->hide();
}
}
-
- //cheap, but it works
- if (ui_ooc_chat_message->text().startsWith("/login"))
+ else if (ooc_message.startsWith("/login"))
ui_guard->show();
+ else if (ooc_message.startsWith("/rainbow") && ao_app->yellow_text_enabled && !rainbow_appended)
+ {
+ ui_text_color->addItem("Rainbow");
+ ui_ooc_chat_message->clear();
+ rainbow_appended = true;
+ return;
+ }
QStringList packet_contents;
packet_contents.append(ui_ooc_chat_name->text());
- packet_contents.append(ui_ooc_chat_message->text());
+ packet_contents.append(ooc_message);
AOPacket *f_packet = new AOPacket("CT", packet_contents);
@@ -1873,25 +1913,6 @@ void Courtroom::on_evidence_button_clicked()
}
}
-void Courtroom::char_clicked(int n_char)
-{
- int n_real_char = n_char + current_char_page * 90;
-
- QString char_ini_path = ao_app->get_character_path(char_list.at(n_real_char).name) + "char.ini";
-
- if (!file_exists(char_ini_path))
- {
- qDebug() << "did not find " << char_ini_path;
- call_notice("Could not find " + char_ini_path);
- return;
- }
-
- if (n_real_char == m_cid)
- enter_courtroom(m_cid);
- else
- ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_real_char) + "#" + get_hdid() + "#%"));
-}
-
void Courtroom::ping_server()
{
ao_app->send_server_packet(new AOPacket("CH#" + QString::number(m_cid) + "#%"));
diff --git a/courtroom.h b/courtroom.h
index cf9bcefb..8beaeb67 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -127,6 +127,7 @@ private:
//used to determine how often blips sound
int blip_pos = 0;
int blip_rate = 1;
+ int rainbow_counter = 0;
bool blank_blip = false;
//delay before chat messages starts ticking
@@ -164,8 +165,6 @@ private:
//state of text ticking, 0 = not yet ticking, 1 = ticking in progress, 2 = ticking done
int text_state = 2;
- int current_char_page = 0;
-
//character id, which index of the char_list the player is
int m_cid = -1;
//cid and this may differ in cases of ini-editing
@@ -178,6 +177,11 @@ private:
int defense_bar_state = 0;
int prosecution_bar_state = 0;
+ int current_char_page = 0;
+ int char_columns = 10;
+ int char_rows = 9;
+ int max_chars_on_page = 90;
+
int current_emote_page = 0;
int current_emote = 0;
int emote_columns = 5;
@@ -217,7 +221,7 @@ private:
AOScene *ui_vp_legacy_desk;
AOImage *ui_vp_chatbox;
QLabel *ui_vp_showname;
- QPlainTextEdit *ui_vp_message;
+ QTextEdit *ui_vp_message;
AOImage *ui_vp_testimony;
AOImage *ui_vp_realization;
AOMovie *ui_vp_wtce;
diff --git a/datatypes.h b/datatypes.h
index d7dcc3f1..5cb60824 100644
--- a/datatypes.h
+++ b/datatypes.h
@@ -103,7 +103,6 @@ enum COLOR
ORANGE,
BLUE,
YELLOW,
- BLACK,
RAINBOW
};
diff --git a/emotes.cpp b/emotes.cpp
index 21db249b..7fcb219c 100644
--- a/emotes.cpp
+++ b/emotes.cpp
@@ -36,7 +36,6 @@ void Courtroom::construct_emotes()
++x_mod_count;
- //if emote number is divisible by columns with rest columns -1 then the next emote button should start on a new line
if (x_mod_count == emote_columns)
{
++y_mod_count;
diff --git a/packet_distribution.cpp b/packet_distribution.cpp
index 27a845f7..8740f050 100644
--- a/packet_distribution.cpp
+++ b/packet_distribution.cpp
@@ -169,7 +169,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (server_software == "v1312.150")
{
encryption_needed = false;
- yellow_text_enabled = true;
custom_objection_enabled = true;
}
else if (server_software == "tsuserver3")
diff --git a/text_file_functions.cpp b/text_file_functions.cpp
index 970ad3c4..5c7f89e5 100644
--- a/text_file_functions.cpp
+++ b/text_file_functions.cpp
@@ -185,6 +185,36 @@ QString AOApplication::read_design_ini(QString p_identifier, QString p_design_pa
return result;
}
+QPoint AOApplication::get_button_spacing(QString p_identifier, QString p_file)
+{
+ QString design_ini_path = get_theme_path() + p_file;
+ QString default_path = get_default_theme_path() + p_file;
+ QString f_result = read_design_ini(p_identifier, design_ini_path);
+
+ QPoint return_value;
+
+ return_value.setX(0);
+ return_value.setY(0);
+
+ if (f_result == "")
+ {
+ f_result = read_design_ini(p_identifier, default_path);
+
+ if (f_result == "")
+ return return_value;
+ }
+
+ QStringList sub_line_elements = f_result.split(",");
+
+ if (sub_line_elements.size() < 2)
+ return return_value;
+
+ return_value.setX(sub_line_elements.at(0).toInt());
+ return_value.setY(sub_line_elements.at(1).toInt());
+
+ return return_value;
+}
+
pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QString p_file)
{
QString design_ini_path = get_theme_path() + p_file;