changing structure from globals to OO with a flat construction
This commit is contained in:
parent
75e9c9b8ec
commit
50fe02cd77
@ -3,6 +3,7 @@
|
|||||||
#include "lobby.h"
|
#include "lobby.h"
|
||||||
#include "courtroom.h"
|
#include "courtroom.h"
|
||||||
#include "networkmanager.h"
|
#include "networkmanager.h"
|
||||||
|
#include "text_file_functions.h"
|
||||||
|
|
||||||
#include "aoapplication.h"
|
#include "aoapplication.h"
|
||||||
|
|
||||||
@ -68,4 +69,32 @@ void AOApplication::destruct_courtroom()
|
|||||||
courtroom_constructed = false;
|
courtroom_constructed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AOApplication::get_version_string(){
|
||||||
|
return
|
||||||
|
QString::number(RELEASE) + "." +
|
||||||
|
QString::number(MAJOR_VERSION) + "." +
|
||||||
|
QString::number(MINOR_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOApplication::set_user_theme(){
|
||||||
|
user_theme = read_user_theme();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOApplication::set_favorite_list()
|
||||||
|
{
|
||||||
|
favorite_list = read_serverlist_txt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOApplication::add_favorite_server(int p_server)
|
||||||
|
{
|
||||||
|
if (p_server < 0 || p_server >= server_list.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
server_type fav_server = server_list.at(p_server);
|
||||||
|
|
||||||
|
QString str_port = QString::number(fav_server.port);
|
||||||
|
|
||||||
|
QString server_line = fav_server.ip + ":" + str_port + ":" + fav_server.name;
|
||||||
|
|
||||||
|
write_to_serverlist_txt(server_line);
|
||||||
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
class NetworkManager;
|
class NetworkManager;
|
||||||
class Lobby;
|
class Lobby;
|
||||||
@ -32,9 +33,6 @@ public:
|
|||||||
void construct_courtroom();
|
void construct_courtroom();
|
||||||
void destruct_courtroom();
|
void destruct_courtroom();
|
||||||
|
|
||||||
QVector<server_type> server_list;
|
|
||||||
QVector<server_type> favorite_list;
|
|
||||||
|
|
||||||
void ms_packet_received(AOPacket *p_packet);
|
void ms_packet_received(AOPacket *p_packet);
|
||||||
void server_packet_received(AOPacket *p_packet);
|
void server_packet_received(AOPacket *p_packet);
|
||||||
|
|
||||||
@ -50,6 +48,44 @@ public:
|
|||||||
bool s_pv = 0;
|
bool s_pv = 0;
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
int get_release() {return RELEASE;}
|
||||||
|
int get_major_version() {return MAJOR_VERSION;}
|
||||||
|
int get_minor_version() {return MINOR_VERSION;}
|
||||||
|
QString get_version_string();
|
||||||
|
|
||||||
|
void set_favorite_list();
|
||||||
|
QVector<server_type>& get_favorite_list() {return favorite_list;}
|
||||||
|
void add_favorite_server(int p_server);
|
||||||
|
|
||||||
|
void set_server_list();
|
||||||
|
QVector<server_type>& get_server_list() {return server_list;}
|
||||||
|
|
||||||
|
void set_user_theme();
|
||||||
|
QString get_user_theme() {return user_theme;}
|
||||||
|
|
||||||
|
//path functions
|
||||||
|
QString get_base_path();
|
||||||
|
QString get_theme_path();
|
||||||
|
QString get_default_theme_path();
|
||||||
|
QString get_character_path(QString p_character);
|
||||||
|
QString get_demothings_path();
|
||||||
|
|
||||||
|
//text file functions
|
||||||
|
QString read_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);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const int RELEASE = 2;
|
||||||
|
const int MAJOR_VERSION = 1;
|
||||||
|
const int MINOR_VERSION = 0;
|
||||||
|
|
||||||
|
QString user_theme = "default";
|
||||||
|
|
||||||
|
QVector<server_type> server_list;
|
||||||
|
QVector<server_type> favorite_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AOAPPLICATION_H
|
#endif // AOAPPLICATION_H
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
AOButton::AOButton(QWidget *parent) : QPushButton(parent)
|
AOButton::AOButton(QWidget *parent, AOApplication *p_ao_app) : QPushButton(parent)
|
||||||
{
|
{
|
||||||
|
ao_app = p_ao_app;
|
||||||
}
|
}
|
||||||
|
|
||||||
AOButton::~AOButton()
|
AOButton::~AOButton()
|
||||||
@ -18,8 +18,8 @@ AOButton::~AOButton()
|
|||||||
|
|
||||||
void AOButton::set_image(QString p_image)
|
void AOButton::set_image(QString p_image)
|
||||||
{
|
{
|
||||||
QString image_path = get_theme_path() + p_image;
|
QString image_path = ao_app->get_theme_path() + p_image;
|
||||||
QString default_image_path = get_default_theme_path() + p_image;
|
QString default_image_path = ao_app->get_default_theme_path() + p_image;
|
||||||
|
|
||||||
if (file_exists(image_path))
|
if (file_exists(image_path))
|
||||||
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
|
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef AOBUTTON_H
|
#ifndef AOBUTTON_H
|
||||||
#define AOBUTTON_H
|
#define AOBUTTON_H
|
||||||
|
|
||||||
|
#include "aoapplication.h"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
class AOButton : public QPushButton
|
class AOButton : public QPushButton
|
||||||
@ -8,9 +10,11 @@ class AOButton : public QPushButton
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AOButton(QWidget *parent);
|
AOButton(QWidget *parent, AOApplication *p_ao_app);
|
||||||
~AOButton();
|
~AOButton();
|
||||||
|
|
||||||
|
AOApplication *ao_app;
|
||||||
|
|
||||||
void set_image(QString p_image);
|
void set_image(QString p_image);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,17 +5,19 @@
|
|||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
AOCharButton::AOCharButton(QWidget *parent)
|
AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app)
|
||||||
{
|
{
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
|
|
||||||
|
ao_app = p_ao_app;
|
||||||
|
|
||||||
this->resize(60, 60);
|
this->resize(60, 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOCharButton::set_image(QString p_character)
|
void AOCharButton::set_image(QString p_character)
|
||||||
{
|
{
|
||||||
QString image_path = get_character_path(p_character) + "char_icon.png";
|
QString image_path = ao_app->get_character_path(p_character) + "char_icon.png";
|
||||||
QString legacy_path = get_demothings_path() + p_character.toLower() + "_char_icon.png";
|
QString legacy_path = ao_app->get_demothings_path() + p_character.toLower() + "_char_icon.png";
|
||||||
|
|
||||||
if (file_exists(image_path))
|
if (file_exists(image_path))
|
||||||
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
|
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef AOCHARBUTTON_H
|
#ifndef AOCHARBUTTON_H
|
||||||
#define AOCHARBUTTON_H
|
#define AOCHARBUTTON_H
|
||||||
|
|
||||||
|
#include "aoapplication.h"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
@ -10,7 +12,9 @@ class AOCharButton : public QPushButton
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AOCharButton(QWidget *parent);
|
AOCharButton(QWidget *parent, AOApplication *p_ao_app);
|
||||||
|
|
||||||
|
AOApplication *ao_app;
|
||||||
|
|
||||||
void set_image(QString p_character);
|
void set_image(QString p_character);
|
||||||
|
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
|
|
||||||
#include "aoimage.h"
|
#include "aoimage.h"
|
||||||
|
|
||||||
AOImage::AOImage(QWidget *parent) : QLabel(parent)
|
AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
|
||||||
{
|
{
|
||||||
|
m_parent = parent;
|
||||||
|
ao_app = p_ao_app;
|
||||||
}
|
}
|
||||||
|
|
||||||
AOImage::~AOImage()
|
AOImage::~AOImage()
|
||||||
@ -16,8 +17,8 @@ AOImage::~AOImage()
|
|||||||
|
|
||||||
void AOImage::set_image(QString p_image)
|
void AOImage::set_image(QString p_image)
|
||||||
{
|
{
|
||||||
QString theme_image_path = get_theme_path() + p_image;
|
QString theme_image_path = ao_app->get_theme_path() + p_image;
|
||||||
QString default_image_path = get_default_theme_path() + p_image;
|
QString default_image_path = ao_app->get_default_theme_path() + p_image;
|
||||||
|
|
||||||
if (file_exists(theme_image_path))
|
if (file_exists(theme_image_path))
|
||||||
this->setPixmap(theme_image_path);
|
this->setPixmap(theme_image_path);
|
||||||
|
@ -3,14 +3,19 @@
|
|||||||
#ifndef AOIMAGE_H
|
#ifndef AOIMAGE_H
|
||||||
#define AOIMAGE_H
|
#define AOIMAGE_H
|
||||||
|
|
||||||
|
#include "aoapplication.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
class AOImage : public QLabel
|
class AOImage : public QLabel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AOImage(QWidget *parent);
|
AOImage(QWidget *parent, AOApplication *p_ao_app);
|
||||||
~AOImage();
|
~AOImage();
|
||||||
|
|
||||||
|
QWidget *m_parent;
|
||||||
|
AOApplication *ao_app;
|
||||||
|
|
||||||
void set_image(QString p_image);
|
void set_image(QString p_image);
|
||||||
void set_size_and_pos(QString identifier);
|
void set_size_and_pos(QString identifier);
|
||||||
};
|
};
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Courtroom::Courtroom(AOApplication *parent) : QMainWindow()
|
Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
||||||
{
|
{
|
||||||
ao_app = parent;
|
ao_app = p_ao_app;
|
||||||
|
|
||||||
ui_background = new AOImage(this);
|
ui_background = new AOImage(this, ao_app);
|
||||||
|
|
||||||
//viewport elements like background, desk, etc.
|
//viewport elements like background, desk, etc.
|
||||||
|
|
||||||
@ -35,41 +35,41 @@ Courtroom::Courtroom(AOApplication *parent) : QMainWindow()
|
|||||||
|
|
||||||
//emote buttons
|
//emote buttons
|
||||||
|
|
||||||
ui_emote_left = new AOButton(this);
|
ui_emote_left = new AOButton(this, ao_app);
|
||||||
ui_emote_right = new AOButton(this);
|
ui_emote_right = new AOButton(this, ao_app);
|
||||||
|
|
||||||
ui_defense_bar = new AOImage(this);
|
ui_defense_bar = new AOImage(this, ao_app);
|
||||||
ui_prosecution_bar = new AOImage(this);
|
ui_prosecution_bar = new AOImage(this, ao_app);
|
||||||
|
|
||||||
ui_music_label = new QLabel(this);
|
ui_music_label = new QLabel(this);
|
||||||
ui_sfx_label = new QLabel(this);
|
ui_sfx_label = new QLabel(this);
|
||||||
ui_blip_label = new QLabel(this);
|
ui_blip_label = new QLabel(this);
|
||||||
|
|
||||||
ui_hold_it = new AOButton(this);
|
ui_hold_it = new AOButton(this, ao_app);
|
||||||
ui_objection = new AOButton(this);
|
ui_objection = new AOButton(this, ao_app);
|
||||||
ui_take_that = new AOButton(this);
|
ui_take_that = new AOButton(this, ao_app);
|
||||||
|
|
||||||
ui_ooc_toggle = new AOButton(this);
|
ui_ooc_toggle = new AOButton(this, ao_app);
|
||||||
ui_witness_testimony = new AOButton(this);
|
ui_witness_testimony = new AOButton(this, ao_app);
|
||||||
ui_cross_examination = new AOButton(this);
|
ui_cross_examination = new AOButton(this, ao_app);
|
||||||
|
|
||||||
ui_change_character = new AOButton(this);
|
ui_change_character = new AOButton(this, ao_app);
|
||||||
ui_reload_theme = new AOButton(this);
|
ui_reload_theme = new AOButton(this, ao_app);
|
||||||
ui_call_mod = new AOButton(this);
|
ui_call_mod = new AOButton(this, ao_app);
|
||||||
|
|
||||||
ui_pre = new QCheckBox(this);
|
ui_pre = new QCheckBox(this);
|
||||||
ui_flip = new QCheckBox(this);
|
ui_flip = new QCheckBox(this);
|
||||||
ui_guard = new QCheckBox(this);
|
ui_guard = new QCheckBox(this);
|
||||||
|
|
||||||
ui_custom_objection = new AOButton(this);
|
ui_custom_objection = new AOButton(this, ao_app);
|
||||||
ui_realization = new AOButton(this);
|
ui_realization = new AOButton(this, ao_app);
|
||||||
ui_mute = new AOButton(this);
|
ui_mute = new AOButton(this, ao_app);
|
||||||
|
|
||||||
ui_defense_plus = new AOButton(this);
|
ui_defense_plus = new AOButton(this, ao_app);
|
||||||
ui_defense_minus = new AOButton(this);
|
ui_defense_minus = new AOButton(this, ao_app);
|
||||||
|
|
||||||
ui_prosecution_plus = new AOButton(this);
|
ui_prosecution_plus = new AOButton(this, ao_app);
|
||||||
ui_prosecution_minus = new AOButton(this);
|
ui_prosecution_minus = new AOButton(this, ao_app);
|
||||||
|
|
||||||
ui_text_color = new QComboBox(this);
|
ui_text_color = new QComboBox(this);
|
||||||
|
|
||||||
@ -77,22 +77,22 @@ Courtroom::Courtroom(AOApplication *parent) : QMainWindow()
|
|||||||
ui_sfx_slider = new QSlider(this);
|
ui_sfx_slider = new QSlider(this);
|
||||||
ui_blip_slider = new QSlider(this);
|
ui_blip_slider = new QSlider(this);
|
||||||
|
|
||||||
ui_muted = new AOImage(this);
|
ui_muted = new AOImage(this, ao_app);
|
||||||
|
|
||||||
/////////////char select widgets under here///////////////
|
/////////////char select widgets under here///////////////
|
||||||
|
|
||||||
ui_char_select_background = new AOImage(this);
|
ui_char_select_background = new AOImage(this, ao_app);
|
||||||
|
|
||||||
//T0D0: allocate and position charbuttons
|
//T0D0: allocate and position charbuttons
|
||||||
//QVector<AOCharButton*> ui_char_button_list;
|
//QVector<AOCharButton*> ui_char_button_list;
|
||||||
|
|
||||||
ui_selector = new AOImage(ui_char_select_background);
|
ui_selector = new AOImage(ui_char_select_background, ao_app);
|
||||||
|
|
||||||
ui_back_to_lobby = new AOButton(ui_char_select_background);
|
ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app);
|
||||||
|
|
||||||
ui_char_password = new QLineEdit(ui_char_select_background);
|
ui_char_password = new QLineEdit(ui_char_select_background);
|
||||||
|
|
||||||
ui_spectator = new AOButton(ui_char_select_background);
|
ui_spectator = new AOButton(ui_char_select_background, ao_app);
|
||||||
|
|
||||||
connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));
|
connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));
|
||||||
|
|
||||||
@ -203,14 +203,14 @@ void Courtroom::set_widgets()
|
|||||||
|
|
||||||
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 = get_theme_path() + "courtroom_design.ini";
|
QString design_ini_path = ao_app->get_theme_path() + "courtroom_design.ini";
|
||||||
QString default_ini_path = get_base_path() + "themes/default/courtroom_design.ini";
|
QString default_ini_path = ao_app->get_base_path() + "themes/default/courtroom_design.ini";
|
||||||
|
|
||||||
pos_size_type design_ini_result = get_pos_and_size(p_identifier, design_ini_path);
|
pos_size_type design_ini_result = ao_app->get_pos_and_size(p_identifier, design_ini_path);
|
||||||
|
|
||||||
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 = get_pos_and_size(p_identifier, default_ini_path);
|
design_ini_result = ao_app->get_pos_and_size(p_identifier, default_ini_path);
|
||||||
|
|
||||||
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
||||||
{
|
{
|
||||||
@ -227,7 +227,7 @@ void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
|||||||
|
|
||||||
void Courtroom::on_reload_theme_clicked()
|
void Courtroom::on_reload_theme_clicked()
|
||||||
{
|
{
|
||||||
g_user_theme = get_user_theme();
|
ao_app->set_user_theme();
|
||||||
|
|
||||||
set_widgets();
|
set_widgets();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class Courtroom : public QMainWindow
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Courtroom(AOApplication *parent = 0);
|
explicit Courtroom(AOApplication *p_ao_app);
|
||||||
void set_widgets();
|
void set_widgets();
|
||||||
void set_size_and_pos(QWidget *p_widget, QString p_identifier);
|
void set_size_and_pos(QWidget *p_widget, QString p_identifier);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "global_variables.h"
|
#include "global_variables.h"
|
||||||
|
#include "text_file_functions.h"
|
||||||
|
|
||||||
const int RELEASE = 2;
|
const int RELEASE = 2;
|
||||||
const int MAJOR_VERSION = 1;
|
const int MAJOR_VERSION = 1;
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
extern QString g_user_theme;
|
|
||||||
|
|
||||||
#endif // GLOBAL_VARIABLES_H
|
#endif // GLOBAL_VARIABLES_H
|
||||||
|
45
lobby.cpp
45
lobby.cpp
@ -9,21 +9,21 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Lobby::Lobby(AOApplication *parent) : QMainWindow()
|
Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow()
|
||||||
{
|
{
|
||||||
ao_app = parent;
|
ao_app = p_ao_app;
|
||||||
|
|
||||||
this->setWindowTitle("Attorney Online 2");
|
this->setWindowTitle("Attorney Online 2");
|
||||||
this->resize(m_lobby_width, m_lobby_height);
|
this->resize(m_lobby_width, m_lobby_height);
|
||||||
this->setFixedSize(m_lobby_width, m_lobby_height);
|
this->setFixedSize(m_lobby_width, m_lobby_height);
|
||||||
|
|
||||||
ui_background = new AOImage(this);
|
ui_background = new AOImage(this, ao_app);
|
||||||
ui_public_servers = new AOButton(this);
|
ui_public_servers = new AOButton(this, ao_app);
|
||||||
ui_favorites = new AOButton(this);
|
ui_favorites = new AOButton(this, ao_app);
|
||||||
ui_refresh = new AOButton(this);
|
ui_refresh = new AOButton(this, ao_app);
|
||||||
ui_add_to_fav = new AOButton(this);
|
ui_add_to_fav = new AOButton(this, ao_app);
|
||||||
ui_connect = new AOButton(this);
|
ui_connect = new AOButton(this, ao_app);
|
||||||
ui_about = new AOButton(this);
|
ui_about = new AOButton(this, ao_app);
|
||||||
ui_server_list = new QListWidget(this);
|
ui_server_list = new QListWidget(this);
|
||||||
ui_player_count = new QLabel(this);
|
ui_player_count = new QLabel(this);
|
||||||
ui_description = new QPlainTextEdit(this);
|
ui_description = new QPlainTextEdit(this);
|
||||||
@ -49,8 +49,7 @@ Lobby::Lobby(AOApplication *parent) : QMainWindow()
|
|||||||
//sets images, position and size
|
//sets images, position and size
|
||||||
void Lobby::set_widgets()
|
void Lobby::set_widgets()
|
||||||
{
|
{
|
||||||
//global to efficiently set images on button presses
|
ao_app->set_user_theme();
|
||||||
g_user_theme = get_user_theme();
|
|
||||||
|
|
||||||
ui_background->set_image("lobbybackground.png");
|
ui_background->set_image("lobbybackground.png");
|
||||||
ui_background->move(0, 0);
|
ui_background->move(0, 0);
|
||||||
@ -130,7 +129,8 @@ void Lobby::on_favorites_clicked()
|
|||||||
ui_favorites->set_image("favorites_selected.png");
|
ui_favorites->set_image("favorites_selected.png");
|
||||||
ui_public_servers->set_image("publicservers.png");
|
ui_public_servers->set_image("publicservers.png");
|
||||||
|
|
||||||
ao_app->favorite_list = read_serverlist_txt();
|
ao_app->set_favorite_list();
|
||||||
|
//ao_app->favorite_list = read_serverlist_txt();
|
||||||
|
|
||||||
list_favorites();
|
list_favorites();
|
||||||
|
|
||||||
@ -166,18 +166,19 @@ void Lobby::on_add_to_fav_released()
|
|||||||
if (!public_servers_selected)
|
if (!public_servers_selected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int n_server = ui_server_list->currentRow();
|
ao_app->add_favorite_server(ui_server_list->currentRow());
|
||||||
|
/*
|
||||||
if (n_server < 0 || n_server >= ao_app->server_list.size())
|
if (n_server < 0 || n_server >= ao_app->get_server_list().size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
server_type fav_server = ao_app->server_list.at(n_server);
|
server_type fav_server = ao_app->get_server_list().at(n_server);
|
||||||
|
|
||||||
QString str_port = QString::number(fav_server.port);
|
QString str_port = QString::number(fav_server.port);
|
||||||
|
|
||||||
QString server_line = fav_server.ip + ":" + str_port + ":" + fav_server.name;
|
QString server_line = fav_server.ip + ":" + str_port + ":" + fav_server.name;
|
||||||
|
|
||||||
write_to_serverlist_txt(server_line);
|
write_to_serverlist_txt(server_line);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::on_connect_pressed()
|
void Lobby::on_connect_pressed()
|
||||||
@ -216,17 +217,17 @@ void Lobby::on_server_list_clicked(QModelIndex p_model)
|
|||||||
|
|
||||||
if (public_servers_selected)
|
if (public_servers_selected)
|
||||||
{
|
{
|
||||||
if (n_server >= ao_app->server_list.size())
|
if (n_server >= ao_app->get_server_list().size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
f_server = ao_app->server_list.at(p_model.row());
|
f_server = ao_app->get_server_list().at(p_model.row());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (n_server >= ao_app->favorite_list.size())
|
if (n_server >= ao_app->get_favorite_list().size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
f_server = ao_app->favorite_list.at(p_model.row());
|
f_server = ao_app->get_favorite_list().at(p_model.row());
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_description->clear();
|
ui_description->clear();
|
||||||
@ -258,7 +259,7 @@ void Lobby::list_servers()
|
|||||||
{
|
{
|
||||||
ui_server_list->clear();
|
ui_server_list->clear();
|
||||||
|
|
||||||
for (server_type i_server : ao_app->server_list)
|
for (server_type i_server : ao_app->get_server_list())
|
||||||
{
|
{
|
||||||
ui_server_list->addItem(i_server.name);
|
ui_server_list->addItem(i_server.name);
|
||||||
}
|
}
|
||||||
@ -268,7 +269,7 @@ void Lobby::list_favorites()
|
|||||||
{
|
{
|
||||||
ui_server_list->clear();
|
ui_server_list->clear();
|
||||||
|
|
||||||
for (server_type i_server : ao_app->favorite_list)
|
for (server_type i_server : ao_app->get_favorite_list())
|
||||||
{
|
{
|
||||||
ui_server_list->addItem(i_server.name);
|
ui_server_list->addItem(i_server.name);
|
||||||
}
|
}
|
||||||
|
2
lobby.h
2
lobby.h
@ -18,7 +18,7 @@ class Lobby : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Lobby(AOApplication *parent);
|
Lobby(AOApplication *p_ao_app);
|
||||||
|
|
||||||
void set_widgets();
|
void set_widgets();
|
||||||
void list_servers();
|
void list_servers();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "path_functions.h"
|
#include "aoapplication.h"
|
||||||
|
|
||||||
#include "global_variables.h"
|
#include "global_variables.h"
|
||||||
#include "text_file_functions.h"
|
#include "text_file_functions.h"
|
||||||
@ -6,26 +6,26 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
QString get_base_path(){
|
QString AOApplication::get_base_path(){
|
||||||
return (QDir::currentPath() + "/base/");
|
return (QDir::currentPath() + "/base/");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString get_theme_path()
|
QString AOApplication::get_theme_path()
|
||||||
{
|
{
|
||||||
return get_base_path() + "themes/" + g_user_theme.toLower() + "/";
|
return get_base_path() + "themes/" + user_theme.toLower() + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString get_default_theme_path()
|
QString AOApplication::get_default_theme_path()
|
||||||
{
|
{
|
||||||
return get_base_path() + "themes/default/";
|
return get_base_path() + "themes/default/";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString get_character_path(QString p_character)
|
QString AOApplication::get_character_path(QString p_character)
|
||||||
{
|
{
|
||||||
return get_base_path() + "characters/" + p_character.toLower() + "/";
|
return get_base_path() + "characters/" + p_character.toLower() + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString get_demothings_path()
|
QString AOApplication::get_demothings_path()
|
||||||
{
|
{
|
||||||
return get_base_path() + "misc/demothings/";
|
return get_base_path() + "misc/demothings/";
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
QString get_base_path();
|
|
||||||
QString get_theme_path();
|
|
||||||
QString get_default_theme_path();
|
|
||||||
QString get_character_path(QString p_character);
|
|
||||||
QString get_demothings_path();
|
|
||||||
|
|
||||||
#endif // PATH_FUNCTIONS_H
|
#endif // PATH_FUNCTIONS_H
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "text_file_functions.h"
|
#include "aoapplication.h"
|
||||||
|
|
||||||
#include "path_functions.h"
|
#include "path_functions.h"
|
||||||
#include "file_functions.h"
|
#include "file_functions.h"
|
||||||
@ -8,7 +8,7 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
QString get_user_theme(){
|
QString AOApplication::read_user_theme(){
|
||||||
QFile config_file(get_base_path() + "config.ini");
|
QFile config_file(get_base_path() + "config.ini");
|
||||||
if (!config_file.open(QIODevice::ReadOnly))
|
if (!config_file.open(QIODevice::ReadOnly))
|
||||||
return "default";
|
return "default";
|
||||||
@ -31,7 +31,7 @@ QString get_user_theme(){
|
|||||||
return "default";
|
return "default";
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_to_serverlist_txt(QString p_line)
|
void AOApplication::write_to_serverlist_txt(QString p_line)
|
||||||
{
|
{
|
||||||
QFile serverlist_txt;
|
QFile serverlist_txt;
|
||||||
QString serverlist_txt_path = get_base_path() + "serverlist.txt";
|
QString serverlist_txt_path = get_base_path() + "serverlist.txt";
|
||||||
@ -50,7 +50,7 @@ void write_to_serverlist_txt(QString p_line)
|
|||||||
serverlist_txt.close();
|
serverlist_txt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<server_type> read_serverlist_txt()
|
QVector<server_type> AOApplication::read_serverlist_txt()
|
||||||
{
|
{
|
||||||
QVector<server_type> f_server_list;
|
QVector<server_type> f_server_list;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ QVector<server_type> read_serverlist_txt()
|
|||||||
return f_server_list;
|
return f_server_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos_size_type get_pos_and_size(QString p_identifier, QString p_design_path)
|
pos_size_type AOApplication::get_pos_and_size(QString p_identifier, QString p_design_path)
|
||||||
{
|
{
|
||||||
QFile design_ini;
|
QFile design_ini;
|
||||||
|
|
||||||
|
@ -6,9 +6,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
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
|
#endif // TEXT_FILE_FUNCTIONS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user