aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2019-09-16 06:09:39 +0300
committerCrystalwarrior <varsash@gmail.com>2019-09-16 06:09:39 +0300
commit9b39b7d6aa2beb8b5496a528c2351adf125c4601 (patch)
tree605b75c820fd63deb8a4e0b2032d1c0851fc32ff
parent03ebad6bb6c922323b16b3ae6a701ddc34ba538b (diff)
Allow char.ini to override the chat font and font size with chat_font = and chat_size =
Scream at the coders that decided hard-coding fonts and colors was a good idea (gotta properly let the themes modify that later) Fix a lot of ui elements not properly respecting the themes and their colors add a set_qfont method for those situations that need it Allow the theme to change sender colors for ooc and ms chatlogs rename url parser variable to something more immediately apparent as to what it is for readability's sake
-rw-r--r--include/aoapplication.h8
-rw-r--r--include/aotextarea.h2
-rw-r--r--include/courtroom.h5
-rw-r--r--src/aotextarea.cpp4
-rw-r--r--src/courtroom.cpp44
-rw-r--r--src/evidence.cpp1
-rw-r--r--src/lobby.cpp1
-rw-r--r--src/text_file_functions.cpp16
8 files changed, 63 insertions, 18 deletions
diff --git a/include/aoapplication.h b/include/aoapplication.h
index fcee38f..e4a5b7f 100644
--- a/include/aoapplication.h
+++ b/include/aoapplication.h
@@ -261,9 +261,15 @@ public:
//Returns the showname from the ini of p_char
QString get_showname(QString p_char);
- //Returns the value of chat from the specific p_char's ini file
+ //Returns the value of chat image from the specific p_char's ini file
QString get_chat(QString p_char);
+ //Returns the value of chat font from the specific p_char's ini file
+ QString get_chat_font(QString p_char);
+
+ //Returns the value of chat font size from the specific p_char's ini file
+ int get_chat_size(QString p_char);
+
//Returns the value of shouts from the specified p_char's ini file
QString get_char_shouts(QString p_char);
diff --git a/include/aotextarea.h b/include/aotextarea.h
index d44596b..266b722 100644
--- a/include/aotextarea.h
+++ b/include/aotextarea.h
@@ -16,7 +16,7 @@ public:
void append_error(QString p_message);
private:
- const QRegExp omnis_dank_url_regex = QRegExp("\\b(https?://\\S+\\.\\S+)\\b");
+ const QRegExp url_parser_regex = QRegExp("\\b(https?://\\S+\\.\\S+)\\b");
void auto_scroll(QTextCursor old_cursor, int scrollbar_value, bool is_scrolled_down);
};
diff --git a/include/courtroom.h b/include/courtroom.h
index 9d33a91..304dd64 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -117,8 +117,13 @@ public:
//sets position of widgets based on theme ini files
void set_widgets();
+
//sets font size based on theme ini files
void set_font(QWidget *widget, QString p_identifier);
+
+ //actual operation of setting the font on a widget
+ void set_qfont(QWidget *widget, QFont font, QColor f_color = Qt::black, bool bold = false);
+
//helper function that calls above function on the relevant widgets
void set_fonts();
diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp
index 5e14632..f9d21e6 100644
--- a/src/aotextarea.cpp
+++ b/src/aotextarea.cpp
@@ -18,7 +18,7 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message, QString p
//cheap workarounds ahoy
p_message += " ";
- QString result = p_message.toHtmlEscaped().replace("\n", "<br>").replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>" );
+ QString result = p_message.toHtmlEscaped().replace("\n", "<br>").replace(url_parser_regex, "<a href='\\1'>\\1</a>" );
this->insertHtml(result);
@@ -36,7 +36,7 @@ void AOTextArea::append_error(QString p_message)
this->append("");
p_message += " ";
- QString result = p_message.replace("\n", "<br>").replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>" );
+ QString result = p_message.replace("\n", "<br>").replace(url_parser_regex, "<a href='\\1'>\\1</a>" );
this->insertHtml("<font color='red'>" + result + "</font>");
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index c87da55..d56719f 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -86,6 +86,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_showname->setAlignment(Qt::AlignHCenter);
ui_vp_message = new QTextEdit(this);
ui_vp_message->setFrameStyle(QFrame::NoFrame);
ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -482,8 +483,8 @@ void Courtroom::set_widgets()
//We detached the text as parent from the chatbox so it doesn't get affected by the screenshake.
ui_vp_message->move(ui_vp_message->x() + ui_vp_chatbox->x(), ui_vp_message->y() + ui_vp_chatbox->y());
ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction);
- ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
- "color: white");
+// ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
+// "color: white");
ui_vp_testimony->move(ui_viewport->x(), ui_viewport->y());
ui_vp_testimony->combo_resize(ui_viewport->width(), ui_viewport->height());
@@ -514,8 +515,6 @@ void Courtroom::set_widgets()
ui_pair_button->set_image("pair_button.png");
set_size_and_pos(ui_area_list, "music_list");
- ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
-
set_size_and_pos(ui_music_list, "music_list");
if (is_ao2_bg)
@@ -739,18 +738,20 @@ void Courtroom::set_font(QWidget *widget, QString p_identifier)
{
QString design_file = "courtroom_fonts.ini";
int f_weight = ao_app->get_font_size(p_identifier, design_file);
- QString class_name = widget->metaObject()->className();
-
QString font_name = ao_app->get_font_name(p_identifier + "_font", design_file);
-
- widget->setFont(QFont(font_name, f_weight));
-
QColor f_color = ao_app->get_color(p_identifier + "_color", design_file);
- int bold = ao_app->get_font_size(p_identifier + "_bold", design_file); // is the font bold or not?
+ bool bold = static_cast<bool>(ao_app->get_font_size(p_identifier + "_bold", design_file)); // is the font bold or not?
+ this->set_qfont(widget, QFont(font_name, f_weight), f_color, bold);
+}
+
+void Courtroom::set_qfont(QWidget *widget, QFont font, QColor f_color, bool bold)
+{
+ QString class_name = widget->metaObject()->className();
+ widget->setFont(font);
QString is_bold = "";
- if(bold == 1) is_bold = "bold";
+ if(bold) is_bold = "bold";
QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n" +
"color: rgba(" +
@@ -1094,7 +1095,7 @@ void Courtroom::list_areas()
void Courtroom::append_ms_chatmessage(QString f_name, QString f_message)
{
- ui_ms_chatlog->append_chatmessage(f_name, f_message, ao_app->get_color("ooc_default_color", "courtroom_design.ini").name());
+ ui_ms_chatlog->append_chatmessage(f_name, f_message, ao_app->get_color("ms_chatlog_sender_color", "courtroom_fonts.ini").name());
}
void Courtroom::append_server_chatmessage(QString p_name, QString p_message, QString p_colour)
@@ -1102,9 +1103,9 @@ void Courtroom::append_server_chatmessage(QString p_name, QString p_message, QSt
QString colour = "#000000";
if (p_colour == "0")
- colour = ao_app->get_color("ooc_default_color", "courtroom_design.ini").name();
+ colour = ao_app->get_color("ms_chatlog_sender_color", "courtroom_fonts.ini").name();
if (p_colour == "1")
- colour = ao_app->get_color("ooc_server_color", "courtroom_design.ini").name();
+ colour = ao_app->get_color("server_chatlog_sender_color", "courtroom_fonts.ini").name();
if(p_message == "Logged in as a moderator.")
{
ui_guard->show();
@@ -1505,6 +1506,21 @@ void Courtroom::handle_chatmessage_2()
ui_vp_chatbox->set_image_from_path(chatbox_path);
}
+ QString design_file = "courtroom_fonts.ini";
+ int f_weight = ao_app->get_font_size("message", design_file);
+ QString font_name = ao_app->get_font_name("message_font", design_file);
+ QColor f_color = ao_app->get_color("message_color", design_file);
+ bool bold = static_cast<bool>(ao_app->get_font_size("message_bold", design_file)); // is the font bold or not?
+
+ QString chatfont = ao_app->get_chat_font(m_chatmessage[CHAR_NAME]);
+ if (chatfont != "")
+ font_name = chatfont;
+
+ int chatsize = ao_app->get_chat_size(m_chatmessage[CHAR_NAME]);
+ if (chatsize != -1)
+ f_weight = chatsize;
+ this->set_qfont(ui_vp_message, QFont(font_name, f_weight), f_color, bold);
+
ui_vp_showname->setStyleSheet("QLabel { color : " + get_text_color("_showname").name() + "; }");
set_scene();
diff --git a/src/evidence.cpp b/src/evidence.cpp
index 341bed0..7e29b25 100644
--- a/src/evidence.cpp
+++ b/src/evidence.cpp
@@ -7,6 +7,7 @@ void Courtroom::construct_evidence()
//ui_evidence_name = new QLabel(ui_evidence);
ui_evidence_name = new AOLineEdit(ui_evidence);
ui_evidence_name->setAlignment(Qt::AlignCenter);
+ //WHY IS THIS FONT HARDCODED, WHAT IS WRONG WITH YOU
ui_evidence_name->setFont(QFont("Arial", 14, QFont::Bold));
ui_evidence_name->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
"color: rgba(255, 128, 0, 255);");
diff --git a/src/lobby.cpp b/src/lobby.cpp
index 7df2cdc..951ff9a 100644
--- a/src/lobby.cpp
+++ b/src/lobby.cpp
@@ -139,6 +139,7 @@ void Lobby::set_widgets()
set_size_and_pos(ui_loading_text, "loading_label");
+ //WHY IS THIS FONT HARDCODED, WHAT IS WRONG WITH YOU
ui_loading_text->setFont(QFont("Arial", 20, QFont::Bold));
ui_loading_text->setReadOnly(true);
ui_loading_text->setAlignment(Qt::AlignCenter);
diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp
index ad82581..02c0b71 100644
--- a/src/text_file_functions.cpp
+++ b/src/text_file_functions.cpp
@@ -576,6 +576,22 @@ QString AOApplication::get_chat(QString p_char)
return f_result;
}
+QString AOApplication::get_chat_font(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "chat_font", "Options");
+
+ return f_result;
+}
+
+int AOApplication::get_chat_size(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "chat_size", "Options");
+
+ if (f_result == "")
+ return -1;
+ return f_result.toInt();
+}
+
QString AOApplication::get_char_shouts(QString p_char)
{
QString f_result = read_char_ini(p_char, "shouts", "Options");