103 lines
2.0 KiB
C++
103 lines
2.0 KiB
C++
#include <QDebug>
|
|
|
|
#include "lobby.h"
|
|
#include "courtroom.h"
|
|
#include "networkmanager.h"
|
|
#include "text_file_functions.h"
|
|
|
|
#include "aoapplication.h"
|
|
|
|
AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
|
|
{
|
|
net_manager = new NetworkManager(this);
|
|
}
|
|
|
|
AOApplication::~AOApplication()
|
|
{
|
|
destruct_lobby();
|
|
destruct_courtroom();
|
|
}
|
|
|
|
void AOApplication::construct_lobby()
|
|
{
|
|
if (lobby_constructed)
|
|
{
|
|
qDebug() << "W: lobby was attempted constructed when it already exists";
|
|
return;
|
|
}
|
|
|
|
w_lobby = new Lobby(this);
|
|
lobby_constructed = true;
|
|
|
|
w_lobby->show();
|
|
}
|
|
|
|
void AOApplication::destruct_lobby()
|
|
{
|
|
if(!lobby_constructed)
|
|
{
|
|
qDebug() << "W: lobby was attempted destructed when it did not exist";
|
|
return;
|
|
}
|
|
|
|
delete w_lobby;
|
|
lobby_constructed = false;
|
|
}
|
|
|
|
void AOApplication::construct_courtroom()
|
|
{
|
|
if (courtroom_constructed)
|
|
{
|
|
qDebug() << "W: courtroom was attempted constructed when it already exists";
|
|
return;
|
|
}
|
|
|
|
w_courtroom = new Courtroom(this);
|
|
courtroom_constructed = true;
|
|
|
|
//D3BUG
|
|
w_courtroom->show();
|
|
}
|
|
|
|
void AOApplication::destruct_courtroom()
|
|
{
|
|
if (!courtroom_constructed)
|
|
{
|
|
qDebug() << "W: courtroom was attempted destructed when it did not exist";
|
|
return;
|
|
}
|
|
|
|
delete w_courtroom;
|
|
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);
|
|
}
|