implemented widget size from ini functionality
This commit is contained in:
parent
4512e35dff
commit
93e2ddcab1
@ -51,6 +51,9 @@ void AOApplication::construct_courtroom()
|
||||
|
||||
w_courtroom = new Courtroom(this);
|
||||
courtroom_constructed = true;
|
||||
|
||||
//D3BUG
|
||||
w_courtroom->show();
|
||||
}
|
||||
|
||||
void AOApplication::destruct_courtroom()
|
||||
|
@ -12,6 +12,7 @@ public:
|
||||
~AOImage();
|
||||
|
||||
void set_image(QString p_image);
|
||||
void set_size_and_pos(QString identifier);
|
||||
};
|
||||
|
||||
#endif // AOIMAGE_H
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "courtroom.h"
|
||||
|
||||
#include "aoapplication.h"
|
||||
#include "text_file_functions.h"
|
||||
#include "path_functions.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@ -91,6 +93,8 @@ Courtroom::Courtroom(AOApplication *parent) : QMainWindow()
|
||||
|
||||
ui_spectator = new AOButton(ui_char_select_background);
|
||||
|
||||
connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));
|
||||
|
||||
set_widgets();
|
||||
}
|
||||
|
||||
@ -102,26 +106,24 @@ void Courtroom::set_widgets()
|
||||
ui_background->move(0, 0);
|
||||
ui_background->resize(m_courtroom_width, m_courtroom_height);
|
||||
|
||||
//viewport elements like background, desk, etc.
|
||||
//viewport elements like background, desk, etc. go here
|
||||
|
||||
ui_ic_chatlog->move(231, 319);
|
||||
ui_ic_chatlog->resize(260, 0);
|
||||
set_size_and_pos(ui_ic_chatlog, "ic_chatlog");
|
||||
|
||||
ui_ms_chatlog->move(490, 1);
|
||||
ui_ms_chatlog->move(224, 277);
|
||||
set_size_and_pos(ui_ms_chatlog, "ms_chatlog");
|
||||
|
||||
//T0D0: finish the rest of this using set_size_and_pos
|
||||
|
||||
ui_server_chatlog->move(490, 1);
|
||||
ui_server_chatlog->resize(224, 277);
|
||||
|
||||
|
||||
|
||||
ui_mute_list->move(260, 160);
|
||||
ui_mute_list->resize(231, 159);
|
||||
|
||||
ui_area_list->move(266, 494);
|
||||
//ui_area_list->resize();
|
||||
|
||||
/*
|
||||
|
||||
QListWidget *ui_music_list;
|
||||
|
||||
QLineEdit *ui_ic_chat_message;
|
||||
@ -148,13 +150,18 @@ void Courtroom::set_widgets()
|
||||
AOButton *ui_objection;
|
||||
AOButton *ui_take_that;
|
||||
|
||||
ui_ooc_toggle->move(100,100);
|
||||
//ui_ooc_toggle->move(100,100);
|
||||
|
||||
AOButton *ui_witness_testimony;
|
||||
AOButton *ui_cross_examination;
|
||||
|
||||
AOButton *ui_change_character;
|
||||
AOButton *ui_reload_theme;
|
||||
|
||||
|
||||
set_size_and_pos(ui_reload_theme, "reload_theme");
|
||||
ui_reload_theme->setText("Reload theme");
|
||||
|
||||
|
||||
AOButton *ui_call_mod;
|
||||
|
||||
QCheckBox *ui_pre;
|
||||
@ -191,7 +198,37 @@ void Courtroom::set_widgets()
|
||||
QLineEdit *ui_char_password;
|
||||
|
||||
AOButton *ui_spectator;
|
||||
*/
|
||||
}
|
||||
|
||||
void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
||||
{
|
||||
QString design_ini_path = get_theme_path() + "courtroom_design.ini";
|
||||
QString default_ini_path = get_base_path() + "themes/default/courtroom_design.ini";
|
||||
|
||||
pos_size_type design_ini_result = get_pos_and_size(p_identifier, design_ini_path);
|
||||
|
||||
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
||||
{
|
||||
design_ini_result = get_pos_and_size(p_identifier, default_ini_path);
|
||||
|
||||
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
||||
{
|
||||
//at this point it's pretty much game over
|
||||
//T0D0: add message box
|
||||
qDebug() << "CRITICAL ERROR: NO SUITABLE DATA FOR SETTING " << p_identifier;
|
||||
ao_app->quit();
|
||||
}
|
||||
}
|
||||
|
||||
p_widget->move(design_ini_result.x, design_ini_result.y);
|
||||
p_widget->resize(design_ini_result.width, design_ini_result.height);
|
||||
}
|
||||
|
||||
void Courtroom::on_reload_theme_clicked()
|
||||
{
|
||||
get_user_theme() = get_user_theme();
|
||||
|
||||
set_widgets();
|
||||
}
|
||||
|
||||
Courtroom::~Courtroom()
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "aobutton.h"
|
||||
#include "aocharbutton.h"
|
||||
#include "aopacket.h"
|
||||
#include "datatypes.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QLineEdit>
|
||||
@ -24,6 +25,8 @@ class Courtroom : public QMainWindow
|
||||
public:
|
||||
explicit Courtroom(AOApplication *parent = 0);
|
||||
void set_widgets();
|
||||
void set_size_and_pos(QWidget *p_widget, QString p_identifier);
|
||||
|
||||
~Courtroom();
|
||||
|
||||
private:
|
||||
@ -117,6 +120,8 @@ private:
|
||||
QLineEdit *ui_char_password;
|
||||
|
||||
AOButton *ui_spectator;
|
||||
private slots:
|
||||
void on_reload_theme_clicked();
|
||||
|
||||
};
|
||||
|
||||
|
@ -65,4 +65,12 @@ struct pos_type
|
||||
int y;
|
||||
};
|
||||
|
||||
struct pos_size_type
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
};
|
||||
|
||||
#endif // DATATYPES_H
|
||||
|
@ -189,6 +189,14 @@ void Lobby::on_connect_released()
|
||||
{
|
||||
ui_connect->set_image("connect.png");
|
||||
|
||||
//D3BUG START
|
||||
|
||||
ao_app->construct_courtroom();
|
||||
|
||||
ao_app->destruct_lobby();
|
||||
|
||||
//D3BUG END
|
||||
|
||||
//T0D0: call ao_app to initialize loading sequence
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QTextStream>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
|
||||
QString get_user_theme(){
|
||||
QFile config_file(get_base_path() + "config.ini");
|
||||
@ -84,3 +85,58 @@ QVector<server_type> read_serverlist_txt()
|
||||
|
||||
return f_server_list;
|
||||
}
|
||||
|
||||
pos_size_type get_pos_and_size(QString p_identifier, QString p_design_path)
|
||||
{
|
||||
QFile design_ini;
|
||||
|
||||
pos_size_type return_value;
|
||||
|
||||
design_ini.setFileName(p_design_path);
|
||||
|
||||
if (!design_ini.open(QIODevice::ReadOnly))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
QTextStream in(&design_ini);
|
||||
|
||||
while (!in.atEnd())
|
||||
{
|
||||
QString f_line = in.readLine();
|
||||
|
||||
if (!f_line.startsWith(p_identifier))
|
||||
continue;
|
||||
|
||||
QStringList line_elements = f_line.split("=");
|
||||
|
||||
if (line_elements.size() < 2)
|
||||
continue;
|
||||
|
||||
QStringList sub_line_elements = line_elements.at(1).split(",");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
qDebug() << "W: Could not find proper " << p_identifier << " in " << 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;
|
||||
}
|
||||
|
||||
|
@ -9,5 +9,6 @@
|
||||
QString get_user_theme();
|
||||
void write_to_serverlist_txt(QString p_line);
|
||||
QVector<server_type> read_serverlist_txt();
|
||||
pos_size_type get_pos_and_size(QString p_identifier, QString p_design_path);
|
||||
|
||||
#endif // TEXT_FILE_FUNCTIONS_H
|
||||
|
Loading…
Reference in New Issue
Block a user