fixed the charselect and added some features, ready for 2.2.5 release

This commit is contained in:
OmniTroid 2017-03-16 02:05:44 +01:00
parent 939f6cc3fd
commit 3b97f88db4
8 changed files with 142 additions and 57 deletions

View File

@ -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;

View File

@ -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 x_modifier{67};
int x_mod_count{0};
const int button_width = 60;
int x_spacing = f_spacing.x();
int x_mod_count = 0;
const int y_modifier{67};
int y_mod_count{0};
const int button_height = 60;
int y_spacing = f_spacing.y();
int y_mod_count = 0;
for (int n = 0 ; n < 90 ; ++n)
set_size_and_pos(ui_char_buttons, "char_buttons");
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;
max_chars_on_page = char_columns * char_rows;
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() + "#%"));
}

View File

@ -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) + "#%"));

View File

@ -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;

View File

@ -103,7 +103,6 @@ enum COLOR
ORANGE,
BLUE,
YELLOW,
BLACK,
RAINBOW
};

View File

@ -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;

View File

@ -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")

View File

@ -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;