From a2cbf0f5948c89334511aff60df12f4a77b4bb5e Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Tue, 16 Aug 2016 08:20:06 +0930 Subject: Many changes to the stat viewer - work on the stat viewer halted for now. I have added CS:GO game integration. You can now view live game information. Uses port 3000 (see the CS:GO wiki for setting up game integration). --- csgo_images.qrc | 27 ++++++ csgo_stats.pro | 19 ++-- csgo_stats.pro.user | 2 +- file_download.cpp | 3 + file_download.h | 2 + game_integration_window.cpp | 153 +++++++++++++++++++++++++++++++++ game_integration_window.h | 60 +++++++++++++ game_integration_window.ui | 148 +++++++++++++++++++++++++++++++ graphical_stats.cpp | 54 ++++++++++++ graphical_stats.h | 33 +++++++ graphical_stats.ui | 31 +++++++ icons/CT.png | Bin 0 -> 10743 bytes icons/T.png | Bin 0 -> 16137 bytes maps/images/ar_baggage.png | Bin 0 -> 71656 bytes maps/images/ar_monastery.png | Bin 0 -> 73961 bytes maps/images/ar_shoots.png | Bin 0 -> 72751 bytes maps/images/cs_assault.png | Bin 0 -> 74883 bytes maps/images/cs_italy.png | Bin 0 -> 72665 bytes maps/images/cs_militia.png | Bin 0 -> 79212 bytes maps/images/cs_office.png | Bin 0 -> 74271 bytes maps/images/de_aztec.png | Bin 0 -> 70933 bytes maps/images/de_bank.png | Bin 0 -> 85829 bytes maps/images/de_cache.png | Bin 0 -> 80526 bytes maps/images/de_cbble.png | Bin 0 -> 69662 bytes maps/images/de_dust.png | Bin 0 -> 72376 bytes maps/images/de_dust2.png | Bin 0 -> 71462 bytes maps/images/de_inferno.png | Bin 0 -> 75376 bytes maps/images/de_lake.png | Bin 0 -> 71540 bytes maps/images/de_mirage.png | Bin 0 -> 75841 bytes maps/images/de_nuke.png | Bin 0 -> 83632 bytes maps/images/de_overpass.png | Bin 0 -> 73014 bytes maps/images/de_safehouse.png | Bin 0 -> 87045 bytes maps/images/de_shortdust.png | Bin 0 -> 76646 bytes maps/images/de_shorttrain.png | Bin 0 -> 69004 bytes maps/images/de_stmarc.png | Bin 0 -> 75710 bytes maps/images/de_sugarcane.png | Bin 0 -> 75946 bytes maps/images/de_train.png | Bin 0 -> 69004 bytes maps/images/de_vertigo.png | Bin 0 -> 74322 bytes message_box.cpp | 26 ++++++ message_box.h | 13 +++ parse_file.h | 2 + stats_display_window.cpp | 27 +++++- stats_display_window.h | 23 +++-- stats_display_window.ui | 196 ++++++++++++++++++++++-------------------- user_management.cpp | 16 +++- user_management.h | 2 + user_select_dialog.cpp | 4 + 47 files changed, 735 insertions(+), 106 deletions(-) create mode 100644 game_integration_window.cpp create mode 100644 game_integration_window.h create mode 100644 game_integration_window.ui create mode 100644 graphical_stats.cpp create mode 100644 graphical_stats.h create mode 100644 graphical_stats.ui create mode 100644 icons/CT.png create mode 100644 icons/T.png create mode 100644 maps/images/ar_baggage.png create mode 100644 maps/images/ar_monastery.png create mode 100644 maps/images/ar_shoots.png create mode 100644 maps/images/cs_assault.png create mode 100644 maps/images/cs_italy.png create mode 100644 maps/images/cs_militia.png create mode 100644 maps/images/cs_office.png create mode 100644 maps/images/de_aztec.png create mode 100644 maps/images/de_bank.png create mode 100644 maps/images/de_cache.png create mode 100644 maps/images/de_cbble.png create mode 100644 maps/images/de_dust.png create mode 100644 maps/images/de_dust2.png create mode 100644 maps/images/de_inferno.png create mode 100644 maps/images/de_lake.png create mode 100644 maps/images/de_mirage.png create mode 100644 maps/images/de_nuke.png create mode 100644 maps/images/de_overpass.png create mode 100644 maps/images/de_safehouse.png create mode 100644 maps/images/de_shortdust.png create mode 100644 maps/images/de_shorttrain.png create mode 100644 maps/images/de_stmarc.png create mode 100644 maps/images/de_sugarcane.png create mode 100644 maps/images/de_train.png create mode 100644 maps/images/de_vertigo.png create mode 100644 message_box.cpp create mode 100644 message_box.h diff --git a/csgo_images.qrc b/csgo_images.qrc index 5ae9dad..7c4dd35 100644 --- a/csgo_images.qrc +++ b/csgo_images.qrc @@ -4,6 +4,8 @@ icons/avatar.jpg icons/domination.png icons/suicide.png + icons/CT.png + icons/T.png weapons/ak47.png @@ -82,5 +84,30 @@ maps/de_sugarcane.png maps/de_train.png maps/de_vertigo.png + maps/images/ar_baggage.png + maps/images/ar_monastery.png + maps/images/ar_shoots.png + maps/images/cs_assault.png + maps/images/cs_italy.png + maps/images/cs_militia.png + maps/images/cs_office.png + maps/images/de_aztec.png + maps/images/de_bank.png + maps/images/de_cache.png + maps/images/de_cbble.png + maps/images/de_dust.png + maps/images/de_dust2.png + maps/images/de_inferno.png + maps/images/de_lake.png + maps/images/de_mirage.png + maps/images/de_nuke.png + maps/images/de_overpass.png + maps/images/de_safehouse.png + maps/images/de_shortdust.png + maps/images/de_shorttrain.png + maps/images/de_stmarc.png + maps/images/de_sugarcane.png + maps/images/de_train.png + maps/images/de_vertigo.png diff --git a/csgo_stats.pro b/csgo_stats.pro index bc584ff..8f33dd8 100644 --- a/csgo_stats.pro +++ b/csgo_stats.pro @@ -3,8 +3,7 @@ # Project created by QtCreator 2016-07-21T13:21:39 # #------------------------------------------------- - -QT += core gui network +QT += core gui network datavisualization charts greaterThan(QT_MAJOR_VERSION, 4): QT += widgets @@ -17,17 +16,27 @@ SOURCES += main.cpp\ file_download.cpp \ stats_display_window.cpp \ parse_file.cpp \ - user_management.cpp + user_management.cpp \ + message_box.cpp \ + graphical_stats.cpp \ + game_integration_window.cpp HEADERS += user_select_dialog.h \ file_download.h \ stats_display_window.h \ parse_file.h \ - user_management.h + user_management.h \ + message_box.h \ + graphical_stats.h \ + game_integration_window.h FORMS += user_select_dialog.ui \ stats_display_window.ui \ - user_management.ui + user_management.ui \ + graphical_stats.ui \ + game_integration_window.ui RESOURCES += \ csgo_images.qrc + +DISTFILES += diff --git a/csgo_stats.pro.user b/csgo_stats.pro.user index 85df869..b44f029 100644 --- a/csgo_stats.pro.user +++ b/csgo_stats.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/file_download.cpp b/file_download.cpp index c155f8b..add1207 100644 --- a/file_download.cpp +++ b/file_download.cpp @@ -24,5 +24,8 @@ int file_download::file_download::download_file(QString url, QString save_locati if (QFile::exists(save_location) && file.size() > 0) return 1; /* file downloaded - could just be a blank file at this point */ else + { + msgbox.info_box("Unable to download file", "Notice"); return 0; /* file did not download */ + } } diff --git a/file_download.h b/file_download.h index f8e1a94..d8ebd37 100644 --- a/file_download.h +++ b/file_download.h @@ -5,6 +5,7 @@ #include #include #include +#include "message_box.h" class file_download { @@ -14,6 +15,7 @@ public: private: QNetworkAccessManager http; QEventLoop loop; + message_box msgbox; }; #endif // FILE_DOWNLOAD_H diff --git a/game_integration_window.cpp b/game_integration_window.cpp new file mode 100644 index 0000000..b929b41 --- /dev/null +++ b/game_integration_window.cpp @@ -0,0 +1,153 @@ +#include "game_integration_window.h" +#include "ui_game_integration_window.h" + +game_integration_window::game_integration_window(QWidget *parent) : + QWidget(parent), + ui(new Ui::game_integration_window) +{ + ui->setupUi(this); + server = new QTcpServer(this); /* create our server */ + connect(this, SIGNAL(window_loaded()), this, SLOT(window_open())); + connect(server, SIGNAL(newConnection()), this, SLOT(new_connection())); + ui->map_picture_label->setTextFormat(Qt::RichText); + ui->ct_label->setTextFormat(Qt::RichText); + ui->t_label->setTextFormat(Qt::RichText); + ui->ct_label->setText("
"); + ui->t_label->setText("
"); +} + +game_integration_window::~game_integration_window() +{ + server->close(); + delete ui; +} + +void game_integration_window::write_console(QString color, QString line) +{ + ui->console->append("" + line + ""); +} + +void game_integration_window::handle_data(QString data) +{ + /* + * here we will handle our JSON data + * first, split it so we only have the JSON data, no post headers + * then we setup our json parser + * we need to create a qvariantmap for each section we are subscribed to: + * - map + * - round + * - player_id + * - player_state + * - match_stats + */ + data = "{" + data.section('{', 1); + game.json_doc = QJsonDocument::fromJson(data.toUtf8()); + if (!game.json_doc.isEmpty()) + { + game.json_object = game.json_doc.object(); + game.main_map = game.json_object.toVariantMap(); + game.map_map = game.main_map["map"].toMap(); + game.player_map = game.main_map["player"].toMap(); + game.round_map = game.player_map["round"].toMap(); + game.weapon_map = game.player_map["weapons"].toMap(); + game.stats_map = game.player_map["match_stats"].toMap(); + game.ct_score_map = game.map_map["team_ct"].toMap(); + game.t_score_map = game.map_map["team_t"].toMap(); + display_data(); + } +} + +void game_integration_window::display_data() +{ + /* in this function we dynamically display the user data on the GUI */ + if (game.current_user_id != game.player_map["steam_id"].toString()) /* if our name has not changed, don't update it */ + { + write_console("red", "changing user ID"); + game.current_user_id = game.player_map["steam_id"].toString(); + } + if (game.current_map != game.map_map["name"].toString()) /* if our map has not changed, don't update it */ + { + game.current_map = game.map_map["name"].toString(); + ui->map_picture_label->setText("
" + game.current_map); + } + if (game.current_team != game.player_map["team"].toString()) /* if our team has not changed, don't update */ + { + game.current_team = game.player_map["team"].toString(); + if (game.current_team == "T") + ui->player_team_label->setText("Terrorist"); + if (game.current_team == "CT") + ui->player_team_label->setText("Counter Terrorist"); + } + ui->player_name_label->setText("" + game.player_map["name"].toString() + ""); + ui->player_score_label->setText("Score: " + game.stats_map["score"].toString()); + ui->ct_score_label->setText("
" + game.ct_score_map["score"].toString() + "
"); + ui->t_score_label->setText("
" + game.t_score_map["score"].toString() + "
"); + ui->round_number_label->setText("
Round
" + game.map_map["round"].toString() + "
"); + ui->kills_label->setText("Kills: " + game.stats_map["kills"].toString()); + ui->deaths_label->setText("Deaths: " + game.stats_map["deaths"].toString()); +} + +void game_integration_window::showEvent(QShowEvent *ev) +{ + emit window_loaded(); +} + +void game_integration_window::window_open() +{ + write_console("green", "Game Integration window open"); + ui->start_server_button->setEnabled(true); + ui->stop_server_button->setEnabled(false); +} + +void game_integration_window::new_connection() +{ + /* this is ugly code - it just works, I believe this is a HORRIBLE way to do it */ + /* + * new connection found, things to do: + * - create socket + * - wait for it to be ready to read + * - read all data + * - send it to be handled elsewhere + * - close our socket + */ + QTcpSocket *socket; /* our socket instance */ + socket = server->nextPendingConnection(); + socket->waitForReadyRead(1000); /* one second of tolerence */ + handle_data(QString(socket->readAll())); + socket->close(); + delete socket; +} + +void game_integration_window::on_start_server_button_clicked() +{ + /* here we start our server */ + if (server->listen(QHostAddress::LocalHost, 3000)) + { + /* start the server */ + write_console("blue", "Server started, waiting for data"); + ui->start_server_button->setEnabled(false); + ui->stop_server_button->setEnabled(true); + } else + { + /* server msut be running or some other error */ + write_console("red", "Server cannot be started"); + } +} + +void game_integration_window::on_stop_server_button_clicked() +{ + if (server->isListening()) + { + /* close our server */ + server->close(); + ui->start_server_button->setEnabled(true); + ui->stop_server_button->setEnabled(false); + write_console("blue", "Server stopped"); + } +} + +void game_integration_window::on_close_window_button_clicked() +{ + server->close(); + this->close(); +} diff --git a/game_integration_window.h b/game_integration_window.h new file mode 100644 index 0000000..80eae3e --- /dev/null +++ b/game_integration_window.h @@ -0,0 +1,60 @@ +#ifndef GAME_INTEGRATION_WINDOW_H +#define GAME_INTEGRATION_WINDOW_H + +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { +class game_integration_window; +} + +class game_integration_window : public QWidget +{ + Q_OBJECT + +public: + explicit game_integration_window(QWidget *parent = 0); + ~game_integration_window(); + +private: + Ui::game_integration_window *ui; + void write_console(QString color, QString line); + void handle_data(QString data); + void display_data(); + QTcpServer *server; /* our server instance */ + struct game_data { + QJsonDocument json_doc; + QJsonObject json_object; + QVariantMap main_map; + QVariantMap map_map; + QVariantMap player_map; + QVariantMap round_map; + QVariantMap weapon_map; + QVariantMap stats_map; + QVariantMap ct_score_map; + QVariantMap t_score_map; + QString current_user_id; + QString current_map; + QString current_team; + } game; + +protected: + void showEvent(QShowEvent *ev); + +signals: + void window_loaded(); + +private slots: + void window_open(); + void new_connection(); + void on_start_server_button_clicked(); + void on_stop_server_button_clicked(); + void on_close_window_button_clicked(); +}; + +#endif // GAME_INTEGRATION_WINDOW_H diff --git a/game_integration_window.ui b/game_integration_window.ui new file mode 100644 index 0000000..07776a5 --- /dev/null +++ b/game_integration_window.ui @@ -0,0 +1,148 @@ + + + game_integration_window + + + Qt::WindowModal + + + + 0 + 0 + 400 + 300 + + + + Game Integration + + + + + + + + map_picture + + + + + + + + + <html><head/><body><p><span style=" font-size:14pt;">player_name</span></p></body></html> + + + + + + + player_team + + + + + + + player_score + + + + + + + kills_count + + + + + + + deaths_count + + + + + + + + + + + + + CT_label + + + + + + + round_number + + + + + + + T_label + + + + + + + + + + + T_score + + + + + + + + + + + + + + CT_score + + + + + + + + + + + + Start server + + + + + + + Stop server + + + + + + + Close window + + + + + + + + diff --git a/graphical_stats.cpp b/graphical_stats.cpp new file mode 100644 index 0000000..e88d7bb --- /dev/null +++ b/graphical_stats.cpp @@ -0,0 +1,54 @@ +#include "graphical_stats.h" +#include "ui_graphical_stats.h" + +graphical_stats::graphical_stats(QWidget *parent) : + QWidget(parent), + ui(new Ui::graphical_stats) +{ + ui->setupUi(this); + + connect(this, SIGNAL(window_loaded()), this, SLOT(window_open()), Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection)); +} + +graphical_stats::~graphical_stats() +{ + delete ui; +} + +void graphical_stats::weapon_use_graph() +{ + QPieSeries *series = new QPieSeries(); + for (int x = 0; x < 5; x ++) + { + series->append(QString::number(x), 1000); + QPieSlice *slice = series->slices().at(x); + slice->setExploded(); + slice->setLabelVisible(); + slice->setPen(QPen(Qt::darkGreen, 2)); + slice->setBrush(Qt::green); + } + + + QChart *chart = new QChart(); + chart->addSeries(series); + chart->setTitle("Simple chart"); + chart->legend()->hide(); + QGraphicsScene *scene = new QGraphicsScene; + scene->addItem(chart); + scene->addText("test"); + ui->graphicsView->setScene(scene); +} + +void graphical_stats::window_open() +{ + /* + * our graphicals stats are ready to be done + * setup our first graph + */ + weapon_use_graph(); +} + +void graphical_stats::showEvent(QShowEvent *ev) +{ + emit window_loaded(); +} diff --git a/graphical_stats.h b/graphical_stats.h new file mode 100644 index 0000000..948d8de --- /dev/null +++ b/graphical_stats.h @@ -0,0 +1,33 @@ +#ifndef GRAPHICAL_STATS_H +#define GRAPHICAL_STATS_H +#include +#include +#include +#include +#include +#include + +namespace Ui { +class graphical_stats; +} + +class graphical_stats : public QWidget +{ + Q_OBJECT +protected: + void showEvent(QShowEvent *ev); +signals: + void window_loaded(); +public: + explicit graphical_stats(QWidget *parent = 0); + ~graphical_stats(); + +private: + Ui::graphical_stats *ui; + void weapon_use_graph(); + +private slots: + void window_open(); +}; + +#endif // GRAPHICAL_STATS_H diff --git a/graphical_stats.ui b/graphical_stats.ui new file mode 100644 index 0000000..da8cf48 --- /dev/null +++ b/graphical_stats.ui @@ -0,0 +1,31 @@ + + + graphical_stats + + + Qt::WindowModal + + + + 0 + 0 + 400 + 300 + + + + Graphical stats + + + + + + QAbstractScrollArea::AdjustToContents + + + + + + + + diff --git a/icons/CT.png b/icons/CT.png new file mode 100644 index 0000000..be58703 Binary files /dev/null and b/icons/CT.png differ diff --git a/icons/T.png b/icons/T.png new file mode 100644 index 0000000..8e83fb8 Binary files /dev/null and b/icons/T.png differ diff --git a/maps/images/ar_baggage.png b/maps/images/ar_baggage.png new file mode 100644 index 0000000..8ed7c67 Binary files /dev/null and b/maps/images/ar_baggage.png differ diff --git a/maps/images/ar_monastery.png b/maps/images/ar_monastery.png new file mode 100644 index 0000000..3767f8b Binary files /dev/null and b/maps/images/ar_monastery.png differ diff --git a/maps/images/ar_shoots.png b/maps/images/ar_shoots.png new file mode 100644 index 0000000..69565cf Binary files /dev/null and b/maps/images/ar_shoots.png differ diff --git a/maps/images/cs_assault.png b/maps/images/cs_assault.png new file mode 100644 index 0000000..8a5f873 Binary files /dev/null and b/maps/images/cs_assault.png differ diff --git a/maps/images/cs_italy.png b/maps/images/cs_italy.png new file mode 100644 index 0000000..6c1f0a3 Binary files /dev/null and b/maps/images/cs_italy.png differ diff --git a/maps/images/cs_militia.png b/maps/images/cs_militia.png new file mode 100644 index 0000000..5fa26d1 Binary files /dev/null and b/maps/images/cs_militia.png differ diff --git a/maps/images/cs_office.png b/maps/images/cs_office.png new file mode 100644 index 0000000..026b730 Binary files /dev/null and b/maps/images/cs_office.png differ diff --git a/maps/images/de_aztec.png b/maps/images/de_aztec.png new file mode 100644 index 0000000..e5c7fb8 Binary files /dev/null and b/maps/images/de_aztec.png differ diff --git a/maps/images/de_bank.png b/maps/images/de_bank.png new file mode 100644 index 0000000..3dbc27f Binary files /dev/null and b/maps/images/de_bank.png differ diff --git a/maps/images/de_cache.png b/maps/images/de_cache.png new file mode 100644 index 0000000..e9eead1 Binary files /dev/null and b/maps/images/de_cache.png differ diff --git a/maps/images/de_cbble.png b/maps/images/de_cbble.png new file mode 100644 index 0000000..e7bb381 Binary files /dev/null and b/maps/images/de_cbble.png differ diff --git a/maps/images/de_dust.png b/maps/images/de_dust.png new file mode 100644 index 0000000..0e4f0a9 Binary files /dev/null and b/maps/images/de_dust.png differ diff --git a/maps/images/de_dust2.png b/maps/images/de_dust2.png new file mode 100644 index 0000000..a855b22 Binary files /dev/null and b/maps/images/de_dust2.png differ diff --git a/maps/images/de_inferno.png b/maps/images/de_inferno.png new file mode 100644 index 0000000..8736477 Binary files /dev/null and b/maps/images/de_inferno.png differ diff --git a/maps/images/de_lake.png b/maps/images/de_lake.png new file mode 100644 index 0000000..6cc1f99 Binary files /dev/null and b/maps/images/de_lake.png differ diff --git a/maps/images/de_mirage.png b/maps/images/de_mirage.png new file mode 100644 index 0000000..582199e Binary files /dev/null and b/maps/images/de_mirage.png differ diff --git a/maps/images/de_nuke.png b/maps/images/de_nuke.png new file mode 100644 index 0000000..23f643e Binary files /dev/null and b/maps/images/de_nuke.png differ diff --git a/maps/images/de_overpass.png b/maps/images/de_overpass.png new file mode 100644 index 0000000..ff6a97c Binary files /dev/null and b/maps/images/de_overpass.png differ diff --git a/maps/images/de_safehouse.png b/maps/images/de_safehouse.png new file mode 100644 index 0000000..eb0fd9c Binary files /dev/null and b/maps/images/de_safehouse.png differ diff --git a/maps/images/de_shortdust.png b/maps/images/de_shortdust.png new file mode 100644 index 0000000..de8d47a Binary files /dev/null and b/maps/images/de_shortdust.png differ diff --git a/maps/images/de_shorttrain.png b/maps/images/de_shorttrain.png new file mode 100644 index 0000000..b053c75 Binary files /dev/null and b/maps/images/de_shorttrain.png differ diff --git a/maps/images/de_stmarc.png b/maps/images/de_stmarc.png new file mode 100644 index 0000000..05acba9 Binary files /dev/null and b/maps/images/de_stmarc.png differ diff --git a/maps/images/de_sugarcane.png b/maps/images/de_sugarcane.png new file mode 100644 index 0000000..13ced9c Binary files /dev/null and b/maps/images/de_sugarcane.png differ diff --git a/maps/images/de_train.png b/maps/images/de_train.png new file mode 100644 index 0000000..b053c75 Binary files /dev/null and b/maps/images/de_train.png differ diff --git a/maps/images/de_vertigo.png b/maps/images/de_vertigo.png new file mode 100644 index 0000000..ece0fe4 Binary files /dev/null and b/maps/images/de_vertigo.png differ diff --git a/message_box.cpp b/message_box.cpp new file mode 100644 index 0000000..65ef798 --- /dev/null +++ b/message_box.cpp @@ -0,0 +1,26 @@ +#include "message_box.h" + +message_box::message_box() +{ + +} + +void message_box::info_box(QString message, QString title) +{ + QMessageBox msgbox; + msgbox.setWindowTitle(title); + msgbox.setText(message); + msgbox.exec(); +} + +int message_box::confirm_box(QString warning, QString message, QString title) +{ + /* returns 1 for yes, 0 for no */ + QMessageBox msgbox; + msgbox.setWindowTitle(title); + msgbox.setText(warning); + msgbox.setInformativeText(message); + msgbox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgbox.setDefaultButton(QMessageBox::No); + return msgbox.exec(); +} diff --git a/message_box.h b/message_box.h new file mode 100644 index 0000000..cf1cf08 --- /dev/null +++ b/message_box.h @@ -0,0 +1,13 @@ +#ifndef MESSAGE_BOX_H +#define MESSAGE_BOX_H +#include + +class message_box +{ +public: + message_box(); + void info_box(QString message, QString title); + int confirm_box(QString warning, QString message, QString title); +}; + +#endif // MESSAGE_BOX_H diff --git a/parse_file.h b/parse_file.h index 25b0aa6..9c2faae 100644 --- a/parse_file.h +++ b/parse_file.h @@ -3,6 +3,7 @@ #include #include #include +#include "message_box.h" class parse_file { @@ -16,6 +17,7 @@ public: QStringList usernames; QStringList userids; void delete_user(QString user); + message_box msgbox; void add_user(QString user); }; diff --git a/stats_display_window.cpp b/stats_display_window.cpp index 577586e..5e9b570 100644 --- a/stats_display_window.cpp +++ b/stats_display_window.cpp @@ -7,6 +7,7 @@ stats_display_window::stats_display_window(QWidget *parent) : { ui->setupUi(this); connect(this, SIGNAL(window_loaded()), this, SLOT(window_open()), Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection)); + ui->graphical_view_button->hide(); /* will i ever do this? */ } stats_display_window::~stats_display_window() @@ -14,6 +15,13 @@ stats_display_window::~stats_display_window() delete ui; } +QStringList stats_display_window::get_most_kills_gun() +{ + QStringList ret; + ret << "1" << "2"; + return ret; +} + void stats_display_window::setup_user() { /* @@ -27,7 +35,11 @@ void stats_display_window::setup_user() user.user_64id = parse.parse_user_data("\"steamid\":", ": "); download.download_file(user.avatar_url, "avatar.jpg"); /* now we have to deal with our user account details */ - ui->username_label->setText(user.username.left(15)); + if (user.username.length() > 15) + { + ui->username_label->setText(user.username.left(15) + "[...]"); + } else + ui->username_label->setText(user.username); if (user.realname == "null") ui->realname_label->setText("Real name not set"); else @@ -222,3 +234,16 @@ void stats_display_window::on_manage_users_button_clicked() { manage.show(); } + +void stats_display_window::on_graphical_view_button_clicked() +{ + graphs.show(); +} + +void stats_display_window::on_game_integration_button_clicked() +{ + /* + * game state integration + */ + game.show(); +} diff --git a/stats_display_window.h b/stats_display_window.h index 7748097..5da3bc9 100644 --- a/stats_display_window.h +++ b/stats_display_window.h @@ -4,9 +4,16 @@ #include #include #include +#include #include "file_download.h" #include "parse_file.h" #include "user_management.h" +#include "game_integration_window.h" +#include +#include +#include +#include +#include namespace Ui { class stats_display_window; @@ -23,6 +30,7 @@ protected: public: explicit stats_display_window(QWidget *parent = 0); ~stats_display_window(); + QStringList get_most_kills_gun(); private: Ui::stats_display_window *ui; @@ -55,14 +63,14 @@ private: {"de_nuke", ":/maps/maps/de_nuke.png", "", "", "", ""}, {"de_train", ":/maps/maps/de_train.png", "", "", "", ""}, {"de_lake", ":/maps/maps/de_lake.png", "", "", "", ""}, - {"de_stmarc", ":/maps/maps/de_stmarc.png", "", "", "", ""}, + {"de_stmarc", ":/maps/maps/images/de_stmarc.png", "", "", "", ""}, {"de_safehouse", ":/maps/maps/de_safehouse.png", "" "", "" , ""}, {"ar_baggage", ":/maps/maps/ar_baggage.png", "", "", "", ""}, - {"ar_shoots", ":/maps/maps/ar_shoots.png", "", "", "", ""}, + {"ar_shoots", ":/maps/maps/images/ar_shoots.png", "", "", "", ""}, {"de_bank", ":/maps/maps/de_bank.png", "", "", "", ""}, - {"ar_monas", ":/maps/maps/ar_monastery.png", "" "", "", ""}, - {"de_vertigo", ":/maps/maps/de_vertigo.png", "", "", "", ""}, - {"de_sugarcane", ":/maps/maps/de_sugarcane.png", "", "", "", ""}, + {"ar_monas", ":/maps/maps/images/ar_monastery.png", "" "", "", ""}, + {"de_vertigo", ":/maps/maps/images/de_vertigo.png", "", "", "", ""}, + {"de_sugarcane", ":/maps/maps/images/de_sugarcane.png", "", "", "", ""}, {"cs_militia", ":/maps/maps/cs_militia.png", "", "", "", ""}, }; QList map_labels; @@ -111,6 +119,9 @@ private: QStringList usernames; QStringList userids; user_management manage; + message_box msgbox; + graphical_stats graphs; + game_integration_window game; signals: void window_loaded(); @@ -120,6 +131,8 @@ private slots: void on_new_id_button_clicked(); void on_users_dropdown_currentIndexChanged(int index); void on_manage_users_button_clicked(); + void on_graphical_view_button_clicked(); + void on_game_integration_button_clicked(); }; #endif // STATS_DISPLAY_WINDOW_H diff --git a/stats_display_window.ui b/stats_display_window.ui index 9274368..de88674 100644 --- a/stats_display_window.ui +++ b/stats_display_window.ui @@ -9,14 +9,103 @@ 0 0 - 643 - 402 + 645 + 587 CS:GO Statistics + + + + Manage users + + + + + + + New user + + + + + + + + + avatar + + + + + + + + Arial [Mono] + 14 + 75 + true + + + + username + + + + + + + realname + + + + + + + status + + + + + + + Time in CS:GO + + + + + + + MVPs + + + + + + + total kills + + + + + + + total deaths + + + + + + + K/D ratio + + + + + @@ -146,12 +235,8 @@ - - - - Close - - + + @@ -160,90 +245,19 @@ - - - - - + + - New user + Close - - - - - - avatar - - - - - - - - Arial [Mono] - 14 - 75 - true - - - - username - - - - - - - realname - - - - - - - status - - - - - - - Time in CS:GO - - - - - - - MVPs - - - - - - - total kills - - - - - - - total deaths - - - - - - - K/D ratio - - - - + + + + Graphical view + + @@ -252,10 +266,10 @@ - - + + - Manage users + Game integration diff --git a/user_management.cpp b/user_management.cpp index 21058b0..488773b 100644 --- a/user_management.cpp +++ b/user_management.cpp @@ -35,9 +35,19 @@ void user_management::on_refresh_users_button_clicked() void user_management::on_delete_user_button_clicked() { - QString to_remove = ui->user_dropdown->currentText() + "=" + userids.at(ui->user_dropdown->currentIndex()); - parse.delete_user(to_remove); - load_players(); + int opt = msgbox.confirm_box("You are about to delete a user", "Are you sure?", "Warning"); + switch (opt) { + case QMessageBox::Yes: { + QString to_remove = ui->user_dropdown->currentText() + "=" + userids.at(ui->user_dropdown->currentIndex()); + parse.delete_user(to_remove); + load_players(); + break; + } + case QMessageBox::No: + break; + default: + break; + } } void user_management::on_add_user_button_clicked() diff --git a/user_management.h b/user_management.h index 88e2bd0..a1209b5 100644 --- a/user_management.h +++ b/user_management.h @@ -4,6 +4,7 @@ #include #include #include "parse_file.h" +#include "message_box.h" namespace Ui { class user_management; @@ -30,6 +31,7 @@ private: QStringList usernames; QStringList userids; void load_players(); + message_box msgbox; }; #endif // USER_MANAGEMENT_H diff --git a/user_select_dialog.cpp b/user_select_dialog.cpp index 8431417..c071fd7 100644 --- a/user_select_dialog.cpp +++ b/user_select_dialog.cpp @@ -35,6 +35,8 @@ void user_select_dialog::download_info() ui->select_account_button->setEnabled(false); ui->steam_url_text->setEnabled(false); ui->player_dropdown->setEnabled(false); + ui->manage_users_button->setEnabled(false); + ui->refresh_users_button->setEnabled(false); ui->info_label->setText("Downloading data.."); /* user data was a last second thought when designing this fucntion, clean it up one day, error checking etc */ qDebug() << "Attempting to download user data"; @@ -60,6 +62,8 @@ void user_select_dialog::download_info() ui->close_button->setEnabled(true); ui->select_account_button->setEnabled(true); ui->steam_url_text->setEnabled(true); + ui->player_dropdown->setEnabled(true); + ui->manage_users_button->setEnabled(true); ui->info_label->setText("Failed to download, try again."); } } -- cgit v1.2.3