Add expanded style sheet support
Allow lobby fonts to happen
This commit is contained in:
parent
6785f35762
commit
03ebad6bb6
@ -252,6 +252,9 @@ public:
|
|||||||
//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_char_ini_tag(QString p_char, QString target_tag);
|
||||||
|
|
||||||
|
//Returns the text between target_tag and terminator_tag in p_file
|
||||||
|
QString get_stylesheet(QString target_tag, QString p_file);
|
||||||
|
|
||||||
//Returns the side of the p_char character from that characters ini file
|
//Returns the side of the p_char character from that characters ini file
|
||||||
QString get_char_side(QString p_char);
|
QString get_char_side(QString p_char);
|
||||||
|
|
||||||
|
@ -122,6 +122,12 @@ public:
|
|||||||
//helper function that calls above function on the relevant widgets
|
//helper function that calls above function on the relevant widgets
|
||||||
void set_fonts();
|
void set_fonts();
|
||||||
|
|
||||||
|
//sets dropdown menu stylesheet
|
||||||
|
void set_dropdown(QWidget *widget, QString target_tag);
|
||||||
|
|
||||||
|
//helper funciton that call above function on the relevant widgets
|
||||||
|
void set_dropdowns();
|
||||||
|
|
||||||
void set_window_title(QString p_title);
|
void set_window_title(QString p_title);
|
||||||
|
|
||||||
//reads theme inis and sets size and pos based on the identifier
|
//reads theme inis and sets size and pos based on the identifier
|
||||||
|
@ -32,6 +32,10 @@ public:
|
|||||||
void append_chatmessage(QString f_name, QString f_message);
|
void append_chatmessage(QString f_name, QString f_message);
|
||||||
void append_error(QString f_message);
|
void append_error(QString f_message);
|
||||||
void set_player_count(int players_online, int max_players);
|
void set_player_count(int players_online, int max_players);
|
||||||
|
void set_stylesheet(QWidget *widget, QString target_tag);
|
||||||
|
void set_stylesheets();
|
||||||
|
void set_fonts();
|
||||||
|
void set_font(QWidget *widget, QString p_identifier);
|
||||||
void set_loading_text(QString p_text);
|
void set_loading_text(QString p_text);
|
||||||
void show_loading_overlay(){ui_loading_background->show();}
|
void show_loading_overlay(){ui_loading_background->show();}
|
||||||
void hide_loading_overlay(){ui_loading_background->hide();}
|
void hide_loading_overlay(){ui_loading_background->hide();}
|
||||||
|
@ -709,6 +709,8 @@ void Courtroom::set_widgets()
|
|||||||
ui_char_select_right->set_image("arrow_right.png");
|
ui_char_select_right->set_image("arrow_right.png");
|
||||||
|
|
||||||
set_size_and_pos(ui_spectator, "spectator");
|
set_size_and_pos(ui_spectator, "spectator");
|
||||||
|
|
||||||
|
set_dropdowns();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Courtroom::set_fonts()
|
void Courtroom::set_fonts()
|
||||||
@ -719,7 +721,7 @@ void Courtroom::set_fonts()
|
|||||||
set_font(ui_ms_chatlog, "ms_chatlog");
|
set_font(ui_ms_chatlog, "ms_chatlog");
|
||||||
set_font(ui_server_chatlog, "server_chatlog");
|
set_font(ui_server_chatlog, "server_chatlog");
|
||||||
set_font(ui_music_list, "music_list");
|
set_font(ui_music_list, "music_list");
|
||||||
set_font(ui_area_list, "music_list");
|
set_font(ui_area_list, "area_list");
|
||||||
|
|
||||||
// Set color of labels and checkboxes
|
// Set color of labels and checkboxes
|
||||||
const QString design_file = "courtroom_fonts.ini";
|
const QString design_file = "courtroom_fonts.ini";
|
||||||
@ -739,21 +741,43 @@ void Courtroom::set_font(QWidget *widget, QString p_identifier)
|
|||||||
int f_weight = ao_app->get_font_size(p_identifier, design_file);
|
int f_weight = ao_app->get_font_size(p_identifier, design_file);
|
||||||
QString class_name = widget->metaObject()->className();
|
QString class_name = widget->metaObject()->className();
|
||||||
|
|
||||||
QString fontt = ao_app->get_font_name(p_identifier + "_font", design_file);
|
QString font_name = ao_app->get_font_name(p_identifier + "_font", design_file);
|
||||||
widget->setFont(QFont(fontt, f_weight));
|
|
||||||
|
|
||||||
|
widget->setFont(QFont(font_name, f_weight));
|
||||||
|
|
||||||
QColor f_color = ao_app->get_color(p_identifier + "_color", design_file);
|
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?
|
||||||
|
|
||||||
|
QString is_bold = "";
|
||||||
|
if(bold == 1) is_bold = "bold";
|
||||||
|
|
||||||
QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n" +
|
QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n" +
|
||||||
"color: rgba(" +
|
"color: rgba(" +
|
||||||
QString::number(f_color.red()) + ", " +
|
QString::number(f_color.red()) + ", " +
|
||||||
QString::number(f_color.green()) + ", " +
|
QString::number(f_color.green()) + ", " +
|
||||||
QString::number(f_color.blue()) + ", 255); }";
|
QString::number(f_color.blue()) + ", 255);\n"
|
||||||
|
"font: " + is_bold + "; }";
|
||||||
|
|
||||||
widget->setStyleSheet(style_sheet_string);
|
widget->setStyleSheet(style_sheet_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Courtroom::set_dropdown(QWidget *widget, QString target_tag)
|
||||||
|
{
|
||||||
|
QString f_file = "courtroom_stylesheets.css";
|
||||||
|
QString style_sheet_string = ao_app->get_stylesheet(target_tag, f_file);
|
||||||
|
if (style_sheet_string != "")
|
||||||
|
widget->setStyleSheet(style_sheet_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Courtroom::set_dropdowns()
|
||||||
|
{
|
||||||
|
set_dropdown(ui_text_color, "[TEXT COLOR]");
|
||||||
|
set_dropdown(ui_pos_dropdown, "[POS DROPDOWN]");
|
||||||
|
set_dropdown(ui_emote_dropdown, "[EMOTE DROPDOWN]");
|
||||||
|
set_dropdown(ui_mute_list, "[MUTE LIST]");
|
||||||
|
}
|
||||||
|
|
||||||
void Courtroom::set_window_title(QString p_title)
|
void Courtroom::set_window_title(QString p_title)
|
||||||
{
|
{
|
||||||
this->setWindowTitle(p_title);
|
this->setWindowTitle(p_title);
|
||||||
|
@ -153,6 +153,8 @@ void Lobby::set_widgets()
|
|||||||
|
|
||||||
ui_loading_background->hide();
|
ui_loading_background->hide();
|
||||||
|
|
||||||
|
set_fonts();
|
||||||
|
set_stylesheets();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
||||||
@ -173,6 +175,66 @@ void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lobby::set_fonts()
|
||||||
|
{
|
||||||
|
set_font(ui_player_count, "player_count");
|
||||||
|
set_font(ui_description, "description");
|
||||||
|
set_font(ui_chatbox, "chatbox");
|
||||||
|
set_font(ui_chatname, "chatname");
|
||||||
|
set_font(ui_chatmessage, "chatmessage");
|
||||||
|
set_font(ui_loading_text, "loading_text");
|
||||||
|
set_font(ui_server_list, "server_list");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lobby::set_stylesheet(QWidget *widget, QString target_tag)
|
||||||
|
{
|
||||||
|
QString f_file = "lobby_stylesheets.css";
|
||||||
|
QString style_sheet_string = ao_app->get_stylesheet(target_tag, f_file);
|
||||||
|
if (style_sheet_string != "")
|
||||||
|
widget->setStyleSheet(style_sheet_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lobby::set_stylesheets()
|
||||||
|
{
|
||||||
|
set_stylesheet(ui_player_count, "[PLAYER COUNT]");
|
||||||
|
set_stylesheet(ui_description, "[DESCRIPTION]");
|
||||||
|
set_stylesheet(ui_chatbox, "[CHAT BOX]");
|
||||||
|
set_stylesheet(ui_chatname, "[CHAT NAME]");
|
||||||
|
set_stylesheet(ui_chatmessage, "[CHAT MESSAGE]");
|
||||||
|
set_stylesheet(ui_loading_text, "[LOADING TEXT]");
|
||||||
|
set_stylesheet(ui_server_list, "[SERVER LIST]");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lobby::set_font(QWidget *widget, QString p_identifier)
|
||||||
|
{
|
||||||
|
QString design_file = "lobby_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("font_" + p_identifier, design_file);
|
||||||
|
QFont font(font_name, f_weight);
|
||||||
|
bool use = static_cast<bool>(ao_app->get_font_size("use_custom_fonts", design_file));
|
||||||
|
if(use)
|
||||||
|
{
|
||||||
|
widget->setFont(font);
|
||||||
|
QColor f_color = ao_app->get_color(p_identifier + "_color", design_file);
|
||||||
|
bool bold = static_cast<bool>(ao_app->get_font_size(p_identifier + "_bold", design_file)); // is the font bold or not?
|
||||||
|
bool center = static_cast<bool>(ao_app->get_font_size(p_identifier + "_center", design_file)); // should it be centered?
|
||||||
|
QString is_bold = "";
|
||||||
|
if(bold) is_bold = "bold";
|
||||||
|
QString is_center = "";
|
||||||
|
if(center) is_center = "qproperty-alignment: AlignCenter;";
|
||||||
|
QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n" +
|
||||||
|
"color: rgba(" +
|
||||||
|
QString::number(f_color.red()) + ", " +
|
||||||
|
QString::number(f_color.green()) + ", " +
|
||||||
|
QString::number(f_color.blue()) + ", 255);\n" +
|
||||||
|
is_center + "\n" +
|
||||||
|
"font: " + is_bold + "; }";
|
||||||
|
widget->setStyleSheet(style_sheet_string);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void Lobby::set_loading_text(QString p_text)
|
void Lobby::set_loading_text(QString p_text)
|
||||||
{
|
{
|
||||||
ui_loading_text->clear();
|
ui_loading_text->clear();
|
||||||
|
@ -350,6 +350,45 @@ QColor AOApplication::get_color(QString p_identifier, QString p_file)
|
|||||||
return return_color;
|
return return_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AOApplication::get_stylesheet(QString target_tag, QString p_file)
|
||||||
|
{
|
||||||
|
QString design_ini_path = get_theme_path(p_file);
|
||||||
|
|
||||||
|
QFile design_ini;
|
||||||
|
|
||||||
|
design_ini.setFileName(design_ini_path);
|
||||||
|
|
||||||
|
if(!design_ini.open(QIODevice::ReadOnly))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
QTextStream in(&design_ini);
|
||||||
|
|
||||||
|
QString f_text;
|
||||||
|
|
||||||
|
bool tag_found = false;
|
||||||
|
|
||||||
|
while(!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
|
||||||
|
if (line.startsWith(target_tag, Qt::CaseInsensitive))
|
||||||
|
{
|
||||||
|
tag_found = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tag_found)
|
||||||
|
{
|
||||||
|
if((line.startsWith("[") && line.endsWith("]")))
|
||||||
|
break;
|
||||||
|
f_text.append(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
design_ini.close();
|
||||||
|
return f_text;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user