From 8007b1d1b95d476821a6b2616c09824e54911ea9 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 31 Mar 2020 18:12:15 +0300 Subject: [PATCH] Add courtroom_design.ini partial parsing for misc/ folder (only chat_arrow and showname atm) Initialize chat arrow n stuff this is still pretty gay because you can't ignore size and set pos or something like that --- include/aoapplication.h | 4 ++-- src/courtroom.cpp | 16 ++++++++++++++-- src/text_file_functions.cpp | 26 ++++++++++++++++++-------- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index 8b520bc..e44f2d3 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -248,10 +248,10 @@ public: QPoint get_button_spacing(QString p_identifier, QString p_file); //Returns the dimensions of widget with specified identifier from p_file - pos_size_type get_element_dimensions(QString p_identifier, QString p_file); + pos_size_type get_element_dimensions(QString p_identifier, QString p_file, QString p_char=""); //Returns the value to you - QString get_design_element(QString p_identifier, QString p_file); + QString get_design_element(QString p_identifier, QString p_file, QString p_char=""); //Returns the name of the font with p_identifier from p_file QString get_font_name(QString p_identifier, QString p_file); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index d310a0a..c7f1936 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1806,10 +1806,22 @@ void Courtroom::handle_chatmessage_2() chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + "/chat"; if (!ui_vp_chatbox->set_chatbox(chatbox_path)) ui_vp_chatbox->set_chatbox(chatbox_path + "box"); + + pos_size_type design_ini_result = ao_app->get_element_dimensions("chat_arrow", "courtroom_design.ini", m_chatmessage[CHAR_NAME]); + if (design_ini_result.width < 0 || design_ini_result.height < 0) + { + qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; + ui_vp_chat_arrow->hide(); + } + else + { + ui_vp_chat_arrow->move(design_ini_result.x, design_ini_result.y); + ui_vp_chat_arrow->combo_resize(design_ini_result.width, design_ini_result.height); + } } - pos_size_type default_width = ao_app->get_element_dimensions("showname", "courtroom_design.ini"); - int extra_width = ao_app->get_design_element("showname_extra_width", "courtroom_design.ini").toInt(); + pos_size_type default_width = ao_app->get_element_dimensions("showname", "courtroom_design.ini", m_chatmessage[CHAR_NAME]); + int extra_width = ao_app->get_design_element("showname_extra_width", "courtroom_design.ini", m_chatmessage[CHAR_NAME]).toInt(); if(extra_width > 0) { diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index c394812..d986709 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -264,11 +264,12 @@ QPoint AOApplication::get_button_spacing(QString p_identifier, QString p_file) return return_value; } -pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QString p_file) +pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QString p_file, QString p_char) { + QString char_ini_path = get_base_path() + "misc/" + get_chat(p_char) + "/" + 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); + QString f_result = read_design_ini(p_identifier, char_ini_path); pos_size_type return_value; @@ -279,10 +280,14 @@ pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QStrin if (f_result == "") { - f_result = read_design_ini(p_identifier, default_path); - + f_result = read_design_ini(p_identifier, design_ini_path); if (f_result == "") - return return_value; + { + f_result = read_design_ini(p_identifier, default_path); + + if (f_result == "") + return return_value; + } } QStringList sub_line_elements = f_result.split(","); @@ -297,13 +302,18 @@ pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QStrin return return_value; } -QString AOApplication::get_design_element(QString p_identifier, QString p_file) +QString AOApplication::get_design_element(QString p_identifier, QString p_file, QString p_char) { + QString char_ini_path = get_base_path() + "misc/" + get_chat(p_char) + "/" + p_file; QString design_ini_path = get_theme_path(p_file); - QString f_result = read_design_ini(p_identifier, design_ini_path); QString default_path = get_default_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, char_ini_path); if (f_result == "") - f_result = read_design_ini(p_identifier, default_path); + { + 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; } QString AOApplication::get_font_name(QString p_identifier, QString p_file)