added text resize functionality
This commit is contained in:
parent
bcb368efb6
commit
ba9f9390fc
@ -99,7 +99,8 @@ public:
|
|||||||
QString read_user_theme();
|
QString read_user_theme();
|
||||||
void write_to_serverlist_txt(QString p_line);
|
void write_to_serverlist_txt(QString p_line);
|
||||||
QVector<server_type> read_serverlist_txt();
|
QVector<server_type> read_serverlist_txt();
|
||||||
pos_size_type get_pos_and_size(QString p_identifier, QString p_design_path);
|
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);
|
QString read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag);
|
||||||
QString get_char_side(QString p_char);
|
QString get_char_side(QString p_char);
|
||||||
QString get_showname(QString p_char);
|
QString get_showname(QString p_char);
|
||||||
@ -116,6 +117,8 @@ public:
|
|||||||
int get_sfx_delay(QString p_char, int p_emote);
|
int get_sfx_delay(QString p_char, int p_emote);
|
||||||
int get_emote_mod(QString p_char, int p_emote);
|
int get_emote_mod(QString p_char, int p_emote);
|
||||||
QString get_gender(QString p_char);
|
QString get_gender(QString p_char);
|
||||||
|
QString read_design_ini(QString p_identifier, QString p_design_path);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int RELEASE = 2;
|
const int RELEASE = 2;
|
||||||
|
@ -328,25 +328,25 @@ void Courtroom::set_mute_list()
|
|||||||
|
|
||||||
void Courtroom::set_widgets()
|
void Courtroom::set_widgets()
|
||||||
{
|
{
|
||||||
QString design_ini_path = ao_app->get_theme_path() + "courtroom_design.ini";
|
QString filename = "courtroom_design.ini";
|
||||||
QString default_ini_path = ao_app->get_base_path() + "themes/default/courtroom_design.ini";
|
|
||||||
|
|
||||||
pos_size_type f_courtroom = ao_app->get_pos_and_size("courtroom", design_ini_path);
|
pos_size_type f_courtroom = ao_app->get_element_dimensions("courtroom", filename);
|
||||||
|
|
||||||
if (f_courtroom.width < 0 || f_courtroom.height < 0)
|
if (f_courtroom.width < 0 || f_courtroom.height < 0)
|
||||||
{
|
{
|
||||||
f_courtroom = ao_app->get_pos_and_size("courtroom", default_ini_path);
|
qDebug() << "W: did not find courtroom width or height in " << filename;
|
||||||
if (f_courtroom.width < 0 || f_courtroom.height < 0)
|
|
||||||
{
|
this->resize(714, 668);
|
||||||
qDebug() << "ERROR: did not find courtroom width or height in courtroom_design.ini!";
|
}
|
||||||
//T0D0: add error box then quit application, this is not recoverable
|
else
|
||||||
}
|
{
|
||||||
|
m_courtroom_width = f_courtroom.width;
|
||||||
|
m_courtroom_height = f_courtroom.height;
|
||||||
|
|
||||||
|
this->resize(f_courtroom.width, f_courtroom.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_courtroom_width = f_courtroom.width;
|
set_fonts();
|
||||||
m_courtroom_height = f_courtroom.height;
|
|
||||||
|
|
||||||
this->resize(m_courtroom_width, m_courtroom_height);
|
|
||||||
|
|
||||||
ui_background->move(0, 0);
|
ui_background->move(0, 0);
|
||||||
ui_background->resize(m_courtroom_width, m_courtroom_height);
|
ui_background->resize(m_courtroom_width, m_courtroom_height);
|
||||||
@ -391,11 +391,6 @@ void Courtroom::set_widgets()
|
|||||||
|
|
||||||
set_size_and_pos(ui_vp_message, "message");
|
set_size_and_pos(ui_vp_message, "message");
|
||||||
ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction);
|
ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction);
|
||||||
#if (defined (_WIN32) || defined (_WIN64))
|
|
||||||
ui_vp_message->setFont(pt_10);
|
|
||||||
#else
|
|
||||||
ui_vp_message->setFont(pt_9);
|
|
||||||
#endif
|
|
||||||
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
||||||
"color: white");
|
"color: white");
|
||||||
|
|
||||||
@ -416,11 +411,6 @@ void Courtroom::set_widgets()
|
|||||||
ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height());
|
ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height());
|
||||||
|
|
||||||
set_size_and_pos(ui_ic_chatlog, "ic_chatlog");
|
set_size_and_pos(ui_ic_chatlog, "ic_chatlog");
|
||||||
#if (defined (_WIN32) || defined (_WIN64))
|
|
||||||
ui_ic_chatlog->setFont(pt_10);
|
|
||||||
#else
|
|
||||||
ui_ic_chatlog->setFont(pt_9);
|
|
||||||
#endif
|
|
||||||
ui_ic_chatlog->setStyleSheet("QPlainTextEdit{ background-color: rgba(0, 0, 0, 0);"
|
ui_ic_chatlog->setStyleSheet("QPlainTextEdit{ background-color: rgba(0, 0, 0, 0);"
|
||||||
"color: white; }");
|
"color: white; }");
|
||||||
|
|
||||||
@ -573,6 +563,22 @@ void Courtroom::set_widgets()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Courtroom::set_font(QWidget *widget, int weight)
|
||||||
|
{
|
||||||
|
widget->setFont(QFont("Sans", weight));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Courtroom::set_fonts()
|
||||||
|
{
|
||||||
|
QString design_file = "courtroom_fonts.ini";
|
||||||
|
|
||||||
|
set_font(ui_vp_showname, ao_app->get_font_size("showname", design_file));
|
||||||
|
set_font(ui_vp_message, ao_app->get_font_size("message", design_file));
|
||||||
|
set_font(ui_ic_chatlog, ao_app->get_font_size("ic_chatlog", design_file));
|
||||||
|
set_font(ui_ms_chatlog, ao_app->get_font_size("ms_chatlog", design_file));
|
||||||
|
set_font(ui_server_chatlog, ao_app->get_font_size("server_chatlog", design_file));
|
||||||
|
}
|
||||||
|
|
||||||
void Courtroom::set_window_title(QString p_title)
|
void Courtroom::set_window_title(QString p_title)
|
||||||
{
|
{
|
||||||
this->setWindowTitle(p_title);
|
this->setWindowTitle(p_title);
|
||||||
@ -580,23 +586,20 @@ void Courtroom::set_window_title(QString p_title)
|
|||||||
|
|
||||||
void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
||||||
{
|
{
|
||||||
QString design_ini_path = ao_app->get_theme_path() + "courtroom_design.ini";
|
QString filename = "courtroom_design.ini";
|
||||||
QString default_ini_path = ao_app->get_base_path() + "themes/default/courtroom_design.ini";
|
|
||||||
|
|
||||||
pos_size_type design_ini_result = ao_app->get_pos_and_size(p_identifier, design_ini_path);
|
pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename);
|
||||||
|
|
||||||
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
||||||
{
|
{
|
||||||
design_ini_result = ao_app->get_pos_and_size(p_identifier, default_ini_path);
|
qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename;
|
||||||
|
p_widget->hide();
|
||||||
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
}
|
||||||
{
|
else
|
||||||
qDebug() << "W: could not find \"" << p_identifier << "\" in courtroom_design.ini";
|
{
|
||||||
}
|
p_widget->move(design_ini_result.x, design_ini_result.y);
|
||||||
|
p_widget->resize(design_ini_result.width, design_ini_result.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_widget->move(design_ini_result.x, design_ini_result.y);
|
|
||||||
p_widget->resize(design_ini_result.width, design_ini_result.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Courtroom::set_taken(int n_char, bool p_taken)
|
void Courtroom::set_taken(int n_char, bool p_taken)
|
||||||
@ -638,27 +641,19 @@ void Courtroom::done_received()
|
|||||||
|
|
||||||
void Courtroom::set_char_select()
|
void Courtroom::set_char_select()
|
||||||
{
|
{
|
||||||
QString design_ini_path = ao_app->get_theme_path() + "courtroom_design.ini";
|
QString filename = "courtroom_design.ini";
|
||||||
QString default_ini_path = ao_app->get_base_path() + "themes/default/courtroom_design.ini";
|
|
||||||
|
|
||||||
pos_size_type f_charselect = ao_app->get_pos_and_size("char_select", design_ini_path);
|
pos_size_type f_charselect = ao_app->get_element_dimensions("char_select", filename);
|
||||||
|
|
||||||
if (f_charselect.width < 0 || f_charselect.height < 0)
|
if (f_charselect.width < 0 || f_charselect.height < 0)
|
||||||
{
|
{
|
||||||
f_charselect = ao_app->get_pos_and_size("char_select", default_ini_path);
|
qDebug() << "W: did not find courtroom width or height in courtroom_design.ini!";
|
||||||
if (f_charselect.width < 0 || f_charselect.height < 0)
|
this->resize(714, 668);
|
||||||
{
|
|
||||||
qDebug() << "W: did not find courtroom width or height in courtroom_design.ini!";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
this->resize(f_charselect.width, f_charselect.height);
|
this->resize(f_charselect.width, f_charselect.height);
|
||||||
|
|
||||||
ui_char_select_background->resize(f_charselect.width, f_charselect.height);
|
|
||||||
|
|
||||||
ui_char_select_background->set_image("charselect_background.png");
|
ui_char_select_background->set_image("charselect_background.png");
|
||||||
ui_char_select_background->move(0, 0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Courtroom::set_char_select_page()
|
void Courtroom::set_char_select_page()
|
||||||
|
@ -40,6 +40,8 @@ public:
|
|||||||
void append_music(QString f_music){music_list.append(f_music);}
|
void append_music(QString f_music){music_list.append(f_music);}
|
||||||
|
|
||||||
void set_widgets();
|
void set_widgets();
|
||||||
|
void set_font(QWidget *widget, int weight);
|
||||||
|
void set_fonts();
|
||||||
void set_window_title(QString p_title);
|
void set_window_title(QString p_title);
|
||||||
void set_size_and_pos(QWidget *p_widget, QString p_identifier);
|
void set_size_and_pos(QWidget *p_widget, QString p_identifier);
|
||||||
void set_taken(int n_char, bool p_taken);
|
void set_taken(int n_char, bool p_taken);
|
||||||
|
21
lobby.cpp
21
lobby.cpp
@ -131,23 +131,20 @@ void Lobby::set_widgets()
|
|||||||
|
|
||||||
void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
||||||
{
|
{
|
||||||
QString design_ini_path = ao_app->get_theme_path() + "lobby_design.ini";
|
QString filename = "lobby_design.ini";
|
||||||
QString default_ini_path = ao_app->get_base_path() + "themes/default/lobby_design.ini";
|
|
||||||
|
|
||||||
pos_size_type design_ini_result = ao_app->get_pos_and_size(p_identifier, design_ini_path);
|
pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename);
|
||||||
|
|
||||||
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
||||||
{
|
{
|
||||||
design_ini_result = ao_app->get_pos_and_size(p_identifier, default_ini_path);
|
qDebug() << "W: could not find " << p_identifier << " in " << filename;
|
||||||
|
p_widget->hide();
|
||||||
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
}
|
||||||
{
|
else
|
||||||
qDebug() << "W: could not find " << p_identifier << " in lobby_design.ini";
|
{
|
||||||
}
|
p_widget->move(design_ini_result.x, design_ini_result.y);
|
||||||
|
p_widget->resize(design_ini_result.width, design_ini_result.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_widget->move(design_ini_result.x, design_ini_result.y);
|
|
||||||
p_widget->resize(design_ini_result.width, design_ini_result.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::set_loading_text(QString p_text)
|
void Lobby::set_loading_text(QString p_text)
|
||||||
|
@ -85,26 +85,23 @@ QVector<server_type> AOApplication::read_serverlist_txt()
|
|||||||
return f_server_list;
|
return f_server_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos_size_type AOApplication::get_pos_and_size(QString p_identifier, QString p_design_path)
|
QString AOApplication::read_design_ini(QString p_identifier, QString p_design_path)
|
||||||
{
|
{
|
||||||
QFile design_ini;
|
QFile design_ini;
|
||||||
|
|
||||||
pos_size_type return_value;
|
|
||||||
|
|
||||||
design_ini.setFileName(p_design_path);
|
design_ini.setFileName(p_design_path);
|
||||||
|
|
||||||
if (!design_ini.open(QIODevice::ReadOnly))
|
if (!design_ini.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
qDebug() << "W: Could not open or read " << p_design_path;
|
qDebug() << "W: Could not open or read " << p_design_path;
|
||||||
//caller should deal with the result properly(check width and height of output for negatives)
|
|
||||||
return_value.height = -1;
|
|
||||||
return_value.width = -1;
|
|
||||||
|
|
||||||
return return_value;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream in(&design_ini);
|
QTextStream in(&design_ini);
|
||||||
|
|
||||||
|
QString result = "";
|
||||||
|
|
||||||
while (!in.atEnd())
|
while (!in.atEnd())
|
||||||
{
|
{
|
||||||
QString f_line = in.readLine();
|
QString f_line = in.readLine();
|
||||||
@ -114,29 +111,72 @@ pos_size_type AOApplication::get_pos_and_size(QString p_identifier, QString p_de
|
|||||||
|
|
||||||
QStringList line_elements = f_line.split("=");
|
QStringList line_elements = f_line.split("=");
|
||||||
|
|
||||||
|
if (line_elements.at(0).trimmed() != p_identifier)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (line_elements.size() < 2)
|
if (line_elements.size() < 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QStringList sub_line_elements = line_elements.at(1).split(",");
|
result = line_elements.at(1).trimmed();
|
||||||
|
break;
|
||||||
if (sub_line_elements.size() < 4)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//T0D0 check if integer conversion actually succeeded
|
|
||||||
return_value.x = sub_line_elements.at(0).toInt();
|
|
||||||
return_value.y = sub_line_elements.at(1).toInt();
|
|
||||||
return_value.width = sub_line_elements.at(2).toInt();
|
|
||||||
return_value.height = sub_line_elements.at(3).toInt();
|
|
||||||
|
|
||||||
return return_value;
|
|
||||||
}
|
}
|
||||||
//caller should deal with the result properly(check width and height of output for negatives)
|
|
||||||
return_value.height = -1;
|
design_ini.close();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos_size_type AOApplication::get_element_dimensions(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);
|
||||||
|
|
||||||
|
pos_size_type return_value;
|
||||||
|
|
||||||
|
return_value.x = 0;
|
||||||
|
return_value.y = 0;
|
||||||
return_value.width = -1;
|
return_value.width = -1;
|
||||||
|
return_value.height = -1;
|
||||||
|
|
||||||
|
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() < 4)
|
||||||
|
return return_value;
|
||||||
|
|
||||||
|
return_value.x = sub_line_elements.at(0).toInt();
|
||||||
|
return_value.y = sub_line_elements.at(1).toInt();
|
||||||
|
return_value.width = sub_line_elements.at(2).toInt();
|
||||||
|
return_value.height = sub_line_elements.at(3).toInt();
|
||||||
|
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AOApplication::get_font_size(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);
|
||||||
|
|
||||||
|
if (f_result == "")
|
||||||
|
{
|
||||||
|
f_result = read_design_ini(p_identifier, default_path);
|
||||||
|
|
||||||
|
if (f_result == "")
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
return f_result.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
//returns whatever is to the right of "search_line =" within target_tag and terminator_tag, trimmed
|
//returns whatever is to the right of "search_line =" within target_tag and terminator_tag, trimmed
|
||||||
//returns the empty string if the search line couldnt be found
|
//returns the empty string if the search line couldnt be found
|
||||||
QString AOApplication::read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag)
|
QString AOApplication::read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag)
|
||||||
|
Loading…
Reference in New Issue
Block a user