Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mrge #1

Merged
merged 4 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Attorney_Online_remake.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ SOURCES += main.cpp\
aoimage.cpp \
file_functions.cpp \
aobutton.cpp \
global_variables.cpp \
debug_functions.cpp \
networkmanager.cpp \
aoapplication.cpp \
Expand All @@ -29,15 +28,15 @@ SOURCES += main.cpp\
hex_functions.cpp \
encryption_functions.cpp \
courtroom.cpp \
aocharbutton.cpp
aocharbutton.cpp \
hardware_functions.cpp

HEADERS += lobby.h \
text_file_functions.h \
path_functions.h \
aoimage.h \
file_functions.h \
aobutton.h \
global_variables.h \
debug_functions.h \
networkmanager.h \
aoapplication.h \
Expand All @@ -46,4 +45,5 @@ HEADERS += lobby.h \
hex_functions.h \
encryption_functions.h \
courtroom.h \
aocharbutton.h
aocharbutton.h \
hardware_functions.h
2 changes: 2 additions & 0 deletions aoapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ void AOApplication::construct_lobby()

w_lobby = new Lobby(this);
lobby_constructed = true;

w_lobby->show();
}

void AOApplication::destruct_lobby()
Expand Down
2 changes: 1 addition & 1 deletion aocharbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <QFile>

AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app)
AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app) : QPushButton(parent)
{
m_parent = parent;

Expand Down
46 changes: 37 additions & 9 deletions courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,22 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()

ui_char_select_background = new AOImage(this, ao_app);

//T0D0: allocate and position charbuttons
//QVector<AOCharButton*> ui_char_button_list;
//setting up the grid and positions
const int base_x_pos{25};
const int base_y_pos{36};

const int x_modifier{67};
int x_mod_count{0};

const int y_modifier{67};
int y_mod_count{0};

for (int n = 0 ; n < 90 ; ++n)
{
ui_char_button_list.append(new AOCharButton(ui_char_select_background, ao_app));
}

ui_char_select_background->hide();

ui_selector = new AOImage(ui_char_select_background, ao_app);

Expand All @@ -96,12 +110,15 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()

connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));

connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked()));

set_widgets();
}

void Courtroom::set_widgets()
{
this->setFixedSize(m_courtroom_width, m_courtroom_height);
this->setWindowTitle("Attorney Online 2: Server name here");

ui_background->set_image("courtroombackground.png");
ui_background->move(0, 0);
Expand Down Expand Up @@ -146,10 +163,10 @@ void Courtroom::set_widgets()

set_size_and_pos(ui_ooc_toggle, "ooc_toggle");

set_size_and_pos(ui_witness_testimony, "witness testimony");
set_size_and_pos(ui_witness_testimony, "witness_testimony");
set_size_and_pos(ui_cross_examination, "cross_examination");

set_size_and_pos(ui_change_character, "change_character";
set_size_and_pos(ui_change_character, "change_character");

set_size_and_pos(ui_reload_theme, "reload_theme");
ui_reload_theme->setText("Reload theme");
Expand Down Expand Up @@ -185,14 +202,19 @@ void Courtroom::set_widgets()
ui_char_select_background->move(0, 0);
ui_char_select_background->resize(m_courtroom_width, m_courtroom_height);

QVector<AOCharButton*> ui_char_button_list;
AOImage *ui_selector;
//T0D0: uncomment and set position properly
//QVector<AOCharButton*> ui_char_button_list;

ui_selector->set_image("selector.png");
ui_selector->hide();

AOButton *ui_back_to_lobby;
ui_back_to_lobby->setText("Back to Lobby");
set_size_and_pos(ui_back_to_lobby, "back_to_lobby");

QLineEdit *ui_char_password;
set_size_and_pos(ui_char_password, "char_password");

AOButton *ui_spectator;
ui_spectator->setText("spectator");
set_size_and_pos(ui_spectator, "spectator");

}

Expand Down Expand Up @@ -227,6 +249,12 @@ void Courtroom::on_reload_theme_clicked()
set_widgets();
}

void Courtroom::on_back_to_lobby_clicked()
{
ao_app->construct_lobby();
ao_app->destruct_courtroom();
}

Courtroom::~Courtroom()
{

Expand Down
2 changes: 2 additions & 0 deletions courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class Courtroom : public QMainWindow
private slots:
void on_reload_theme_clicked();

void on_back_to_lobby_clicked();

};

#endif // COURTROOM_H
8 changes: 0 additions & 8 deletions global_variables.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions global_variables.h

This file was deleted.

34 changes: 34 additions & 0 deletions hardware_functions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "hardware_functions.h"

#if (defined (_WIN32) || defined (_WIN64))
DWORD dwVolSerial;
BOOL bIsRetrieved;

QString get_hdid()
{
bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL);

if (bIsRetrieved)
return QString::number(dwVolSerial, 16);
else
return "invalid_windows_hd"; //what could possibly go wrong

}

#elif (defined (LINUX) || defined (__linux__))

QString get_hdid()
{
//T0D0: add linux implementation
return "linux_os_hdid";
}

#else

QString get_hdid()
{
//T0D0: find a sane way to handle this
return "unknown_os_hdid";
}

#endif
14 changes: 14 additions & 0 deletions hardware_functions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef WIN32_FUNCTIONS_H
#define WIN32_FUNCTIONS_H

#include <QString>

#ifdef Q_OS_WIN32
#include <windows.h>
#endif // Q_OS_WIN32

#include <stdio.h>

QString get_hdid();

#endif // WIN32_FUNCTIONS_H
13 changes: 0 additions & 13 deletions lobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow()
ao_app = p_ao_app;

this->setWindowTitle("Attorney Online 2");
this->resize(m_lobby_width, m_lobby_height);
this->setFixedSize(m_lobby_width, m_lobby_height);

ui_background = new AOImage(this, ao_app);
Expand Down Expand Up @@ -167,18 +166,6 @@ void Lobby::on_add_to_fav_released()
return;

ao_app->add_favorite_server(ui_server_list->currentRow());
/*
if (n_server < 0 || n_server >= ao_app->get_server_list().size())
return;

server_type fav_server = ao_app->get_server_list().at(n_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);
*/
}

void Lobby::on_connect_pressed()
Expand Down
16 changes: 8 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

int main(int argc, char *argv[])
{
AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
AOApplication main_app(argc, argv);
main_app.construct_lobby();
main_app.net_manager->connect_to_master();
AOPacket *f_packet = new AOPacket("ALL#%");
main_app.send_ms_packet(f_packet);
main_app.w_lobby->show();
AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
AOApplication main_app(argc, argv);
main_app.construct_lobby();
main_app.net_manager->connect_to_master();
AOPacket *f_packet = new AOPacket("ALL#%");
main_app.send_ms_packet(f_packet);
main_app.w_lobby->show();

return main_app.exec();
return main_app.exec();
}
7 changes: 5 additions & 2 deletions packet_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "lobby.h"
#include "networkmanager.h"
#include "encryption_functions.h"
#include "hardware_functions.h"

#include <QDebug>

Expand Down Expand Up @@ -85,9 +86,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
//you may ask where 322 comes from. that would be a good question.
s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt();

//T0D0 add an actual HDID here
AOPacket *hi_packet = new AOPacket("HI#ao2testinginprogressdontmindme#%");
QString f_hdid;
f_hdid = get_hdid();

AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%");
send_server_packet(hi_packet);

delete hi_packet;
Expand All @@ -97,6 +99,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (f_contents.size() < 1)
return;

//T0D0: save server version here, somehow(it's in the HI# packet usually)
}
else if (header == "CT")
{
Expand Down