Hellcommit of doom and suffering

Create two new helper functions - get_chat_markdown and remake read_char_ini_tag to be read_ini_tags for more general purpose
Modify aolineedit to support preserving selection after unfocusing (building this for using dropdown list for setting colors), as well as remove the setReadOnly functionality and use it in signals instead
Overhaul the color system to get rid of inline colors, allow full customization of colors and usage of configuration files for every facet of how a color functions (should we be talking, should we remove that markdown char, etc.)
Complete overhaul of color markdowns system

TODO: Make this thing not lag to hell, fix chat messages hogging the IC as the animation never ends apparently
This commit is contained in:
Crystalwarrior 2019-09-25 02:05:52 +03:00
parent 7097053723
commit 923548c997
8 changed files with 234 additions and 223 deletions

View File

@ -242,6 +242,9 @@ public:
//Returns the color with p_identifier from p_file //Returns the color with p_identifier from p_file
QColor get_color(QString p_identifier, QString p_file); QColor get_color(QString p_identifier, QString p_file);
// Returns the markdown symbol used for specified p_identifier such as colors
QString get_chat_markdown(QString p_identifier, QString p_file);
// Returns the color from the misc folder. // Returns the color from the misc folder.
QColor get_chat_color(QString p_identifier, QString p_chat); QColor get_chat_color(QString p_identifier, QString p_chat);
@ -261,7 +264,7 @@ public:
QString read_char_ini(QString p_char, QString p_search_line, QString target_tag); QString read_char_ini(QString p_char, QString p_search_line, QString target_tag);
//Returns a QStringList of all key=value definitions on a given tag. //Returns a QStringList of all key=value definitions on a given tag.
QStringList read_char_ini_tag(QString p_char, QString target_tag); QStringList read_ini_tags(QString p_file, QString target_tag = "");
//Sets the char.ini p_search_line key under tag target_tag to value. //Sets the char.ini p_search_line key under tag target_tag to value.
void set_char_ini(QString p_char, QString value, QString p_search_line, QString target_tag); void set_char_ini(QString p_char, QString value, QString p_search_line, QString target_tag);

View File

@ -11,16 +11,17 @@ class AOLineEdit : public QLineEdit
public: public:
AOLineEdit(QWidget *parent); AOLineEdit(QWidget *parent);
void preserve_selection(bool toggle) {p_selection = toggle;}
private:
bool p_selection = false;
protected: protected:
void mouseDoubleClickEvent(QMouseEvent *e); void mouseDoubleClickEvent(QMouseEvent *e);
void focusOutEvent(QFocusEvent *ev);
signals: signals:
void double_clicked(); void double_clicked();
private slots:
void on_enter_pressed();
}; };
#endif // AOLINEEDIT_H #endif // AOLINEEDIT_H

View File

@ -168,12 +168,6 @@ public:
//sets desk and bg based on pos in chatmessage //sets desk and bg based on pos in chatmessage
void set_scene(QString f_desk_mod, QString f_side); void set_scene(QString f_desk_mod, QString f_side);
//sets text color based on text color in chatmessage
void set_text_color();
// And gets the color, too!
QColor get_text_color(QString color);
//takes in serverD-formatted IP list as prints a converted version to server OOC //takes in serverD-formatted IP list as prints a converted version to server OOC
//admittedly poorly named //admittedly poorly named
void set_ip_list(QString p_list); void set_ip_list(QString p_list);
@ -213,7 +207,7 @@ public:
//This function filters out the common CC inline text trickery, for appending to //This function filters out the common CC inline text trickery, for appending to
//the IC chatlog. //the IC chatlog.
QString filter_ic_text(QString p_text, bool colorize = false, int pos = -1, int default_color = WHITE); QString filter_ic_text(QString p_text, bool colorize = false, int pos = -1, int default_color = 0);
//adds text to the IC chatlog. p_name first as bold then p_text then a newlin //adds text to the IC chatlog. p_name first as bold then p_text then a newlin
//this function keeps the chatlog scrolled to the top unless there's text selected //this function keeps the chatlog scrolled to the top unless there's text selected
@ -360,6 +354,9 @@ private:
int realization_state = 0; int realization_state = 0;
int screenshake_state = 0; int screenshake_state = 0;
int text_color = 0; int text_color = 0;
static const int max_colors = 12; //How many unique user colors are possible
QVector<int> color_row_to_number; //Current color list indexes to real color references
bool is_presenting_evidence = false; bool is_presenting_evidence = false;
QString effect = ""; QString effect = "";
@ -440,7 +437,7 @@ private:
QListWidget *ui_pair_list; QListWidget *ui_pair_list;
QSpinBox *ui_pair_offset_spinbox; QSpinBox *ui_pair_offset_spinbox;
QLineEdit *ui_ic_chat_message; AOLineEdit *ui_ic_chat_message;
QLineEdit *ui_ic_chat_name; QLineEdit *ui_ic_chat_name;
QLineEdit *ui_ooc_chat_message; QLineEdit *ui_ooc_chat_message;
@ -625,7 +622,7 @@ private slots:
QString get_char_sfx(); QString get_char_sfx();
int get_char_sfx_delay(); int get_char_sfx_delay();
void on_evidence_name_edited(QString text); void on_evidence_name_edited();
void on_evidence_image_name_edited(); void on_evidence_image_name_edited();
void on_evidence_image_button_clicked(); void on_evidence_image_button_clicked();
void on_evidence_clicked(int p_id); void on_evidence_clicked(int p_id);
@ -654,6 +651,7 @@ private slots:
void on_prosecution_plus_clicked(); void on_prosecution_plus_clicked();
void on_text_color_changed(int p_color); void on_text_color_changed(int p_color);
void set_text_color_dropdown();
void on_music_slider_moved(int p_value); void on_music_slider_moved(int p_value);
void on_sfx_slider_moved(int p_value); void on_sfx_slider_moved(int p_value);

View File

@ -110,19 +110,4 @@ enum CHAT_MESSAGE
EFFECTS EFFECTS
}; };
enum COLOR
{
WHITE = 0,
GREEN,
RED,
ORANGE,
BLUE,
YELLOW,
RAINBOW,
PINK,
CYAN,
GRAY,
BLANK
};
#endif // DATATYPES_H #endif // DATATYPES_H

View File

@ -2,21 +2,19 @@
AOLineEdit::AOLineEdit(QWidget *parent) : QLineEdit(parent) AOLineEdit::AOLineEdit(QWidget *parent) : QLineEdit(parent)
{ {
this->setReadOnly(true);
this->setFrame(false);
connect(this, SIGNAL(returnPressed()), this, SLOT(on_enter_pressed()));
} }
void AOLineEdit::mouseDoubleClickEvent(QMouseEvent *e) void AOLineEdit::mouseDoubleClickEvent(QMouseEvent *e)
{ {
QLineEdit::mouseDoubleClickEvent(e); QLineEdit::mouseDoubleClickEvent(e);
this->setReadOnly(false);
double_clicked(); double_clicked();
} }
void AOLineEdit::focusOutEvent(QFocusEvent *ev)
void AOLineEdit::on_enter_pressed()
{ {
this->setReadOnly(true); int start = selectionStart();
int end = selectionEnd();
QLineEdit::focusOutEvent(ev);
if (p_selection && start != -1 && end != -1)
this->setSelection(start, end);
} }

View File

@ -141,9 +141,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ic_chat_name->setFrame(false); ui_ic_chat_name->setFrame(false);
ui_ic_chat_name->setPlaceholderText(tr("Showname")); ui_ic_chat_name->setPlaceholderText(tr("Showname"));
ui_ic_chat_message = new QLineEdit(this); ui_ic_chat_message = new AOLineEdit(this);
ui_ic_chat_message->setFrame(false); ui_ic_chat_message->setFrame(false);
ui_ic_chat_message->setPlaceholderText(tr("Message")); ui_ic_chat_message->setPlaceholderText(tr("Message"));
ui_ic_chat_message->preserve_selection(true);
ui_muted = new AOImage(ui_ic_chat_message, ao_app); ui_muted = new AOImage(ui_ic_chat_message, ao_app);
ui_muted->hide(); ui_muted->hide();
@ -247,15 +248,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_prosecution_minus = new AOButton(this, ao_app); ui_prosecution_minus = new AOButton(this, ao_app);
ui_text_color = new QComboBox(this); ui_text_color = new QComboBox(this);
ui_text_color->addItem(tr("White"));
ui_text_color->addItem(tr("Green"));
ui_text_color->addItem(tr("Red"));
ui_text_color->addItem(tr("Orange"));
ui_text_color->addItem(tr("Blue"));
ui_text_color->addItem(tr("Yellow"));
ui_text_color->addItem(tr("Rainbow"));
ui_text_color->addItem(tr("Pink"));
ui_text_color->addItem(tr("Cyan"));
ui_music_slider = new QSlider(Qt::Horizontal, this); ui_music_slider = new QSlider(Qt::Horizontal, this);
ui_music_slider->setRange(0, 100); ui_music_slider->setRange(0, 100);
@ -784,6 +776,7 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_text_color, "text_color"); set_size_and_pos(ui_text_color, "text_color");
ui_text_color->setToolTip(tr("Change the text color of the spoken message.")); ui_text_color->setToolTip(tr("Change the text color of the spoken message."));
set_text_color_dropdown();
set_size_and_pos(ui_music_slider, "music_slider"); set_size_and_pos(ui_music_slider, "music_slider");
set_size_and_pos(ui_sfx_slider, "sfx_slider"); set_size_and_pos(ui_sfx_slider, "sfx_slider");
@ -1513,7 +1506,7 @@ void Courtroom::on_chat_return_pressed()
packet += f_emote; packet += f_emote;
if (ao_app->is_frame_network_enabled()) if (ao_app->is_frame_network_enabled())
{ {
QString sfx_frames = ao_app->read_char_ini_tag(current_char, f_emote.append(f_effect)).join("|"); QString sfx_frames = ao_app->read_ini_tags(ao_app->get_character_path(current_char, "char.ini"), f_emote.append(f_effect)).join("|");
if (sfx_frames != "") if (sfx_frames != "")
packet += "|" + sfx_frames; packet += "|" + sfx_frames;
} }
@ -1770,7 +1763,6 @@ void Courtroom::handle_chatmessage_2()
this->set_qfont(ui_vp_message, "", QFont(font_name, f_weight), f_color, bold); this->set_qfont(ui_vp_message, "", QFont(font_name, f_weight), f_color, bold);
set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]); set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]);
set_text_color();
// Check if the message needs to be centered. // Check if the message needs to be centered.
QString f_message = m_chatmessage[MESSAGE]; QString f_message = m_chatmessage[MESSAGE];
@ -2058,38 +2050,6 @@ void Courtroom::handle_chatmessage_3()
} }
int f_anim_state = 0;
//BLUE is from an enum in datatypes.h
bool text_is_blue = m_chatmessage[TEXT_COLOR].toInt() == BLUE || m_chatmessage[TEXT_COLOR].toInt() == ORANGE;
if (!text_is_blue && text_state == 1)
{
//talking
f_anim_state = 2;
}
else
{
//idle
f_anim_state = 3;
}
if (f_anim_state <= anim_state)
return;
ui_vp_player_char->stop();
QString f_char = m_chatmessage[CHAR_NAME];
QString f_emote = m_chatmessage[EMOTE];
if (f_anim_state == 2) {
ui_vp_player_char->play_talking(f_char, f_emote);
anim_state = 2;
}
else
{
ui_vp_player_char->play_idle(f_char, f_emote);
anim_state = 3;
}
QString f_message = m_chatmessage[MESSAGE]; QString f_message = m_chatmessage[MESSAGE];
QStringList call_words = ao_app->get_call_words(); QStringList call_words = ao_app->get_call_words();
@ -2115,13 +2075,13 @@ QString Courtroom::filter_ic_text(QString p_text, bool colorize, int pos, int de
int check_pos = 0; int check_pos = 0;
bool ic_next_is_not_special = false; bool ic_next_is_not_special = false;
QString f_character = p_text.at(check_pos); QString f_character = p_text.at(check_pos);
std::stack<COLOR> ic_color_stack; std::stack<int> ic_color_stack;
if (colorize) if (colorize)
{ {
ic_color_stack.push(static_cast<COLOR>(default_color)); ic_color_stack.push(default_color);
qDebug() << ic_color_stack.top(); qDebug() << ic_color_stack.top();
QString appendage = "<font color=\""+ get_text_color(QString::number(ic_color_stack.top())).name(QColor::HexRgb) +"\">"; QString appendage = "<font color=\""+ ao_app->get_chat_color(QString::number(ic_color_stack.top()), m_chatmessage[CHAR_NAME]).name(QColor::HexRgb) +"\">";
p_text.insert(check_pos, appendage); p_text.insert(check_pos, appendage);
check_pos += appendage.size(); check_pos += appendage.size();
if (pos > -1) if (pos > -1)
@ -2151,86 +2111,93 @@ QString Courtroom::filter_ic_text(QString p_text, bool colorize, int pos, int de
pos -= 1; pos -= 1;
} }
//Colors that destroy the character bool is_end = false;
else if (f_character == "`") bool remove = false;
//Parse markdown colors
for (int c = 0; c < max_colors; ++c)
{ {
if (colorize) QString markdown_start = ao_app->get_chat_markdown("c" + QString::number(c) + "_start", m_chatmessage[CHAR_NAME]);
{ if (markdown_start.isEmpty()) //Not defined
if (!ic_color_stack.empty() && ic_color_stack.top() == GREEN && default_color != GREEN) continue;
ic_color_stack.pop(); //Cease our coloring QString markdown_end = ao_app->get_chat_markdown("c" + QString::number(c) + "_end", m_chatmessage[CHAR_NAME]);
else bool markdown_remove = ao_app->get_chat_markdown("c" + QString::number(c) + "_remove", m_chatmessage[CHAR_NAME]) == "1";
{
ic_color_stack.push(GREEN); //Begin our coloring
}
color_update = true;
}
else
p_text.remove(check_pos, 1);
}
else if (f_character == "|")
{
if (colorize)
{
if (!ic_color_stack.empty() && ic_color_stack.top() == ORANGE && default_color != ORANGE)
ic_color_stack.pop(); //Cease our coloring
else
{
ic_color_stack.push(ORANGE); //Begin our coloring
}
color_update = true;
}
else
p_text.remove(check_pos, 1);
}
//Colors that don't destroy the character and use 2 chars for beginning/end if (markdown_end.isEmpty() || markdown_end == markdown_start) //"toggle switch" type
else if (colorize && f_character == "(")
{ {
ic_color_stack.push(BLUE); //Begin our coloring if (f_character == markdown_start)
color_update = true;
}
else if (colorize && f_character == ")" && ic_color_stack.top() == BLUE)
{
ic_color_stack.pop(); //Cease our coloring
color_update = true;
}
else if (colorize && f_character == "[")
{ {
if (colorize) if (colorize)
ic_color_stack.push(GRAY); //Begin our coloring {
if (!ic_color_stack.empty() && ic_color_stack.top() == c && default_color != c)
ic_color_stack.pop(); //Cease our coloring
else
{
ic_color_stack.push(c); //Begin our coloring
}
color_update = true; color_update = true;
} }
else if (colorize && f_character == "]" && ic_color_stack.top() == GRAY) remove = markdown_remove;
break; //Prevent it from looping forward for whatever reason
}
}
else if (f_character == markdown_start || (f_character == markdown_end && ic_color_stack.top() == c))
{ {
if (colorize) if (colorize)
{
if (f_character == markdown_start)
{
ic_color_stack.push(c); //Begin our coloring
}
else if (f_character == markdown_end)
{
ic_color_stack.pop(); //Cease our coloring ic_color_stack.pop(); //Cease our coloring
is_end = true;
}
color_update = true; color_update = true;
} }
remove = markdown_remove;
break; //Prevent it from looping forward for whatever reason
}
}
//Parse the newest color stack //Parse the newest color stack
if (!ic_next_is_not_special && color_update && (pos <= -1 || check_pos < pos)) //Only color text if we haven't reached the "invisible threshold" if (color_update)
{
if (!ic_next_is_not_special && (pos <= -1 || check_pos < pos)) //Only color text if we haven't reached the "invisible threshold"
{ {
QString appendage = "</font>"; QString appendage = "</font>";
if (!ic_color_stack.empty()) if (!ic_color_stack.empty())
appendage += "<font color=\""+ get_text_color(QString::number(ic_color_stack.top())).name(QColor::HexRgb) +"\">"; appendage += "<font color=\""+ ao_app->get_chat_color(QString::number(ic_color_stack.top()), m_chatmessage[CHAR_NAME]).name(QColor::HexRgb) +"\">";
if (f_character == "(" || f_character == "[") //Gotta capture them in the color too if (!is_end || remove)
p_text.insert(check_pos, appendage);
else if (f_character == ")" || f_character == "]")
p_text.insert(check_pos+1, appendage);
else
{ {
if (remove)
p_text.remove(check_pos, 1); p_text.remove(check_pos, 1);
p_text.insert(check_pos, appendage); p_text.insert(check_pos, appendage);
if (remove)
{
check_pos -= 1; check_pos -= 1;
pos -= 1; pos -= 1;
} }
}
else
{
p_text.insert(check_pos+1, appendage);
}
check_pos += appendage.size(); check_pos += appendage.size();
if (pos > -1) if (pos > -1)
pos += appendage.size(); pos += appendage.size();
} }
} }
else if (remove) //Simple remove request
{
p_text.remove(check_pos, 1);
check_pos -= 1;
pos -= 1;
}
}
else else
ic_next_is_not_special = false; ic_next_is_not_special = false;
@ -2246,8 +2213,8 @@ QString Courtroom::filter_ic_text(QString p_text, bool colorize, int pos, int de
appendage += "</font>"; appendage += "</font>";
} }
ic_color_stack.push(BLANK); ic_color_stack.push(-1); //Dummy colorstack push for maximum </font> appendage
appendage += "<font color=\""+ get_text_color(QString::number(BLANK)).name(QColor::HexArgb) +"\">"; appendage += "<font color=\"#00000000\">";
p_text.insert(check_pos, appendage); p_text.insert(check_pos, appendage);
} }
check_pos += 1; check_pos += 1;
@ -2447,9 +2414,6 @@ void Courtroom::start_chat_ticking()
this->do_screenshake(); this->do_screenshake();
} }
set_text_color();
// rainbow_counter = 0;
if (chatmessage_is_empty) if (chatmessage_is_empty)
{ {
//since the message is empty, it's technically done ticking //since the message is empty, it's technically done ticking
@ -2457,13 +2421,6 @@ void Courtroom::start_chat_ticking()
return; return;
} }
// At this point, we'd do well to clear the inline colour stack.
// This stops it from flowing into next messages.
// while (!inline_colour_stack.empty())
// {
// inline_colour_stack.pop();
// }
ui_vp_chatbox->show(); ui_vp_chatbox->show();
ui_vp_message->show(); ui_vp_message->show();
@ -2486,6 +2443,22 @@ void Courtroom::start_chat_ticking()
//means text is currently ticking //means text is currently ticking
text_state = 1; text_state = 1;
//If this color is talking
bool color_is_talking = ao_app->get_chat_markdown("c" + m_chatmessage[TEXT_COLOR] + "_talking", m_chatmessage[CHAR_NAME]) == "1";
if (color_is_talking && text_state == 1 && anim_state < 2) //Set it to talking as we're not on that already
{
// ui_vp_player_char->stop();
ui_vp_player_char->play_talking(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]);
anim_state = 2;
}
else if (anim_state < 3) //Set it to idle as we're not on that already
{
// ui_vp_player_char->stop();
ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]);
anim_state = 3;
}
} }
void Courtroom::chat_tick() void Courtroom::chat_tick()
@ -2500,6 +2473,7 @@ void Courtroom::chat_tick()
// Stops blips from playing when we have a formatting option. // Stops blips from playing when we have a formatting option.
bool formatting_char = false; bool formatting_char = false;
bool is_talking = ao_app->get_chat_markdown("c" + m_chatmessage[TEXT_COLOR] + "_talking", m_chatmessage[CHAR_NAME]) == "1";
if (tick_pos >= f_message.size()) if (tick_pos >= f_message.size())
{ {
@ -2568,11 +2542,25 @@ void Courtroom::chat_tick()
this->do_flash(); this->do_flash();
formatting_char = true; formatting_char = true;
} }
else
{
//Parse markdown colors
for (int c = 0; c < max_colors; ++c)
{
QString markdown_start = ao_app->get_chat_markdown("c" + QString::number(c) + "_start", m_chatmessage[CHAR_NAME]);
if (markdown_start.isEmpty())
continue;
QString markdown_end = ao_app->get_chat_markdown("c" + QString::number(c) + "_end", m_chatmessage[CHAR_NAME]);
bool markdown_remove = ao_app->get_chat_markdown("c" + QString::number(c) + "_remove", m_chatmessage[CHAR_NAME]) == "1";
bool color_is_talking = ao_app->get_chat_markdown("c" + QString::number(c) + "_talking", m_chatmessage[CHAR_NAME]) == "1";
//Color memes if (markdown_remove && (f_character == markdown_start || f_character == markdown_end))
else if (f_character == "`" || f_character == "|")
{ {
formatting_char = true; formatting_char = true;
is_talking = color_is_talking;
break;
}
}
} }
} }
else else
@ -2615,9 +2603,23 @@ void Courtroom::chat_tick()
} }
else else
{ {
chat_tick_timer->start(message_display_speed[current_display_speed]); //If this color is talking
if (is_talking && text_state == 1 && anim_state < 2) //Set it to talking as we're not on that already
{
// ui_vp_player_char->stop();
ui_vp_player_char->play_talking(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]);
anim_state = 2;
}
else if (anim_state < 3) //Set it to idle as we're not on that already
{
// ui_vp_player_char->stop();
ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]);
anim_state = 3;
} }
//Continue ticking
chat_tick_timer->start(message_display_speed[current_display_speed]);
}
} }
} }
@ -2722,30 +2724,6 @@ void Courtroom::set_scene(QString f_desk_mod, QString f_side)
} }
} }
void Courtroom::set_text_color()
{
QColor textcolor = ao_app->get_chat_color(m_chatmessage[TEXT_COLOR], ao_app->get_chat(m_chatmessage[CHAR_NAME]));
ui_vp_message->setTextBackgroundColor(QColor(0,0,0,0));
ui_vp_message->setTextColor(textcolor);
QString style = "background-color: rgba(0, 0, 0, 0);";
style.append("color: rgb(");
style.append(QString::number(textcolor.red()));
style.append(", ");
style.append(QString::number(textcolor.green()));
style.append(", ");
style.append(QString::number(textcolor.blue()));
style.append(")");
ui_vp_message->setStyleSheet(style);
}
QColor Courtroom::get_text_color(QString color)
{
return ao_app->get_chat_color(color, ao_app->get_chat(m_chatmessage[CHAR_NAME]));
}
void Courtroom::set_ip_list(QString p_list) void Courtroom::set_ip_list(QString p_list)
{ {
QString f_list = p_list.replace("|", ":").replace("*", "\n"); QString f_list = p_list.replace("|", ":").replace("*", "\n");
@ -3830,9 +3808,44 @@ void Courtroom::on_prosecution_plus_clicked()
ao_app->send_server_packet(new AOPacket("HP#2#" + QString::number(f_state) + "#%")); ao_app->send_server_packet(new AOPacket("HP#2#" + QString::number(f_state) + "#%"));
} }
void Courtroom::set_text_color_dropdown()
{
ui_text_color->clear();
color_row_to_number.clear();
//Set the default color 0
QString c0_name = ao_app->get_chat_markdown("c0_name", current_char);
if (c0_name.isEmpty())
c0_name = tr("Default");
ui_text_color->addItem(c0_name);
color_row_to_number.append(0);
//Set the rest of the colors
for (int c = 1; c < max_colors; ++c)
{
QString color_name = ao_app->get_chat_markdown("c" + QString::number(c) + "_name", current_char);
if (color_name.isEmpty()) //Not defined
continue;
ui_text_color->addItem(color_name);
color_row_to_number.append(c);
}
}
void Courtroom::on_text_color_changed(int p_color) void Courtroom::on_text_color_changed(int p_color)
{ {
text_color = p_color; if (ui_ic_chat_message->selectionStart() != -1) //We have a selection!
{
qDebug() << "Setting color to selection" << ui_ic_chat_message->selectionStart() << ui_ic_chat_message->selectionEnd();
ui_ic_chat_message->end(false);
ui_text_color->setCurrentIndex(0);
}
else
{
if (p_color != -1 && p_color < color_row_to_number.size())
text_color = color_row_to_number.at(p_color);
else
text_color = 0;
}
ui_ic_chat_message->setFocus(); ui_ic_chat_message->setFocus();
} }

View File

@ -26,7 +26,7 @@ void Courtroom::initialize_evidence()
ui_evidence_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" ui_evidence_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
"color: white;"); "color: white;");
connect(ui_evidence_name, SIGNAL(textEdited(QString)), this, SLOT(on_evidence_name_edited(QString))); connect(ui_evidence_name, SIGNAL(returnPressed()), this, SLOT(on_evidence_name_edited()));
connect(ui_evidence_name, SIGNAL(double_clicked()), this, SLOT(on_evidence_name_double_clicked())); connect(ui_evidence_name, SIGNAL(double_clicked()), this, SLOT(on_evidence_name_double_clicked()));
connect(ui_evidence_left, SIGNAL(clicked()), this, SLOT(on_evidence_left_clicked())); connect(ui_evidence_left, SIGNAL(clicked()), this, SLOT(on_evidence_left_clicked()));
connect(ui_evidence_right, SIGNAL(clicked()), this, SLOT(on_evidence_right_clicked())); connect(ui_evidence_right, SIGNAL(clicked()), this, SLOT(on_evidence_right_clicked()));
@ -179,8 +179,9 @@ void Courtroom::set_evidence_page()
} }
} }
void Courtroom::on_evidence_name_edited(QString text) void Courtroom::on_evidence_name_edited()
{ {
ui_evidence_name->setReadOnly(true);
if (current_evidence >= local_evidence_list.size()) if (current_evidence >= local_evidence_list.size())
return; return;
@ -206,6 +207,7 @@ void Courtroom::on_evidence_name_double_clicked()
void Courtroom::on_evidence_image_name_edited() void Courtroom::on_evidence_image_name_edited()
{ {
ui_evidence_image_name->setReadOnly(true);
if (current_evidence >= local_evidence_list.size()) if (current_evidence >= local_evidence_list.size())
return; return;

View File

@ -432,48 +432,57 @@ QString AOApplication::get_tagged_stylesheet(QString target_tag, QString p_file)
return f_text; return f_text;
} }
QString AOApplication::get_chat_markdown(QString p_identifier, QString p_chat)
{
QString design_ini_path = get_base_path() + "misc/" + p_chat + "/config.ini";
QString default_path = get_base_path() + "misc/default/config.ini";
QString f_result = read_design_ini(p_identifier, design_ini_path);
if (f_result == "")
f_result = read_design_ini(p_identifier, default_path);
return f_result;
}
QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat) QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat)
{ {
QColor return_color(255, 255, 255); QColor return_color(255, 255, 255);
switch (p_identifier.toInt()) { switch (p_identifier.toInt()) {
case WHITE: case 0: //White
case GREEN: return_color = QColor(255, 255, 255);
break;
case 1: //Green
return_color = QColor(0, 255, 0); return_color = QColor(0, 255, 0);
break; break;
case RED: case 2: //Red
return_color = QColor(255, 0, 0); return_color = QColor(255, 0, 0);
break; break;
case ORANGE: case 3: //Orange
return_color = QColor(255, 165, 0); return_color = QColor(255, 165, 0);
break; break;
case BLUE: case 4: //Blue
return_color = QColor(45, 150, 255); return_color = QColor(45, 150, 255);
break; break;
case YELLOW: case 5: //Yellow
return_color = QColor(255, 255, 0); return_color = QColor(255, 255, 0);
break; break;
case RAINBOW: // 6 is rainbow. case 6: //Pink
case PINK:
return_color = QColor(255, 192, 203); return_color = QColor(255, 192, 203);
break; break;
case CYAN: case 7: //Cyan
return_color = QColor(0, 255, 255); return_color = QColor(0, 255, 255);
break; break;
case GRAY: case 8: //Grey
return_color = QColor(187, 187, 187); return_color = QColor(187, 187, 187);
break; break;
case BLANK:
return_color = QColor(0, 0, 0, 0);
break;
default: default:
return_color = QColor(255, 255, 255); return_color = QColor(255, 255, 255);
break; break;
} }
p_identifier = p_identifier.prepend("c");
QString design_ini_path = get_base_path() + "misc/" + p_chat + "/config.ini"; QString design_ini_path = get_base_path() + "misc/" + p_chat + "/config.ini";
QString default_path = get_base_path() + "misc/default/config.ini"; QString default_path = get_base_path() + "misc/default/config.ini";
QString f_result = read_design_ini(p_identifier, design_ini_path); QString f_result = read_design_ini("c" + p_identifier, design_ini_path);
if (f_result == "") if (f_result == "")
{ {
@ -567,10 +576,11 @@ void AOApplication::set_char_ini(QString p_char, QString value, QString p_search
} }
//returns all the values of target_tag //returns all the values of target_tag
QStringList AOApplication::read_char_ini_tag(QString p_char, QString target_tag) QStringList AOApplication::read_ini_tags(QString p_path, QString target_tag)
{ {
QStringList r_values; QStringList r_values;
QSettings settings(get_character_path(p_char, "char.ini"), QSettings::IniFormat); QSettings settings(p_path, QSettings::IniFormat);
if (!target_tag.isEmpty())
settings.beginGroup(target_tag); settings.beginGroup(target_tag);
QStringList keys = settings.allKeys(); QStringList keys = settings.allKeys();
foreach (QString key, keys) foreach (QString key, keys)
@ -578,6 +588,7 @@ QStringList AOApplication::read_char_ini_tag(QString p_char, QString target_tag)
QString value = settings.value(key).toString(); QString value = settings.value(key).toString();
r_values << key + "=" + value; r_values << key + "=" + value;
} }
if (!settings.group().isEmpty())
settings.endGroup(); settings.endGroup();
return r_values; return r_values;
} }