diff options
-rw-r--r-- | csgo_images.qrc | 27 | ||||
-rw-r--r-- | csgo_stats.pro | 19 | ||||
-rw-r--r-- | csgo_stats.pro.user | 2 | ||||
-rw-r--r-- | file_download.cpp | 3 | ||||
-rw-r--r-- | file_download.h | 2 | ||||
-rw-r--r-- | game_integration_window.cpp | 153 | ||||
-rw-r--r-- | game_integration_window.h | 60 | ||||
-rw-r--r-- | game_integration_window.ui | 148 | ||||
-rw-r--r-- | graphical_stats.cpp | 54 | ||||
-rw-r--r-- | graphical_stats.h | 33 | ||||
-rw-r--r-- | graphical_stats.ui | 31 | ||||
-rw-r--r-- | icons/CT.png | bin | 0 -> 10743 bytes | |||
-rw-r--r-- | icons/T.png | bin | 0 -> 16137 bytes | |||
-rw-r--r-- | maps/images/ar_baggage.png | bin | 0 -> 71656 bytes | |||
-rw-r--r-- | maps/images/ar_monastery.png | bin | 0 -> 73961 bytes | |||
-rw-r--r-- | maps/images/ar_shoots.png | bin | 0 -> 72751 bytes | |||
-rw-r--r-- | maps/images/cs_assault.png | bin | 0 -> 74883 bytes | |||
-rw-r--r-- | maps/images/cs_italy.png | bin | 0 -> 72665 bytes | |||
-rw-r--r-- | maps/images/cs_militia.png | bin | 0 -> 79212 bytes | |||
-rw-r--r-- | maps/images/cs_office.png | bin | 0 -> 74271 bytes | |||
-rw-r--r-- | maps/images/de_aztec.png | bin | 0 -> 70933 bytes | |||
-rw-r--r-- | maps/images/de_bank.png | bin | 0 -> 85829 bytes | |||
-rw-r--r-- | maps/images/de_cache.png | bin | 0 -> 80526 bytes | |||
-rw-r--r-- | maps/images/de_cbble.png | bin | 0 -> 69662 bytes | |||
-rw-r--r-- | maps/images/de_dust.png | bin | 0 -> 72376 bytes | |||
-rw-r--r-- | maps/images/de_dust2.png | bin | 0 -> 71462 bytes | |||
-rw-r--r-- | maps/images/de_inferno.png | bin | 0 -> 75376 bytes | |||
-rw-r--r-- | maps/images/de_lake.png | bin | 0 -> 71540 bytes | |||
-rw-r--r-- | maps/images/de_mirage.png | bin | 0 -> 75841 bytes | |||
-rw-r--r-- | maps/images/de_nuke.png | bin | 0 -> 83632 bytes | |||
-rw-r--r-- | maps/images/de_overpass.png | bin | 0 -> 73014 bytes | |||
-rw-r--r-- | maps/images/de_safehouse.png | bin | 0 -> 87045 bytes | |||
-rw-r--r-- | maps/images/de_shortdust.png | bin | 0 -> 76646 bytes | |||
-rw-r--r-- | maps/images/de_shorttrain.png | bin | 0 -> 69004 bytes | |||
-rw-r--r-- | maps/images/de_stmarc.png | bin | 0 -> 75710 bytes | |||
-rw-r--r-- | maps/images/de_sugarcane.png | bin | 0 -> 75946 bytes | |||
-rw-r--r-- | maps/images/de_train.png | bin | 0 -> 69004 bytes | |||
-rw-r--r-- | maps/images/de_vertigo.png | bin | 0 -> 74322 bytes | |||
-rw-r--r-- | message_box.cpp | 26 | ||||
-rw-r--r-- | message_box.h | 13 | ||||
-rw-r--r-- | parse_file.h | 2 | ||||
-rw-r--r-- | stats_display_window.cpp | 27 | ||||
-rw-r--r-- | stats_display_window.h | 23 | ||||
-rw-r--r-- | stats_display_window.ui | 196 | ||||
-rw-r--r-- | user_management.cpp | 16 | ||||
-rw-r--r-- | user_management.h | 2 | ||||
-rw-r--r-- | user_select_dialog.cpp | 4 |
47 files changed, 735 insertions, 106 deletions
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 @@ <file>icons/avatar.jpg</file> <file>icons/domination.png</file> <file>icons/suicide.png</file> + <file>icons/CT.png</file> + <file>icons/T.png</file> </qresource> <qresource prefix="/weapons"> <file>weapons/ak47.png</file> @@ -82,5 +84,30 @@ <file>maps/de_sugarcane.png</file> <file>maps/de_train.png</file> <file>maps/de_vertigo.png</file> + <file>maps/images/ar_baggage.png</file> + <file>maps/images/ar_monastery.png</file> + <file>maps/images/ar_shoots.png</file> + <file>maps/images/cs_assault.png</file> + <file>maps/images/cs_italy.png</file> + <file>maps/images/cs_militia.png</file> + <file>maps/images/cs_office.png</file> + <file>maps/images/de_aztec.png</file> + <file>maps/images/de_bank.png</file> + <file>maps/images/de_cache.png</file> + <file>maps/images/de_cbble.png</file> + <file>maps/images/de_dust.png</file> + <file>maps/images/de_dust2.png</file> + <file>maps/images/de_inferno.png</file> + <file>maps/images/de_lake.png</file> + <file>maps/images/de_mirage.png</file> + <file>maps/images/de_nuke.png</file> + <file>maps/images/de_overpass.png</file> + <file>maps/images/de_safehouse.png</file> + <file>maps/images/de_shortdust.png</file> + <file>maps/images/de_shorttrain.png</file> + <file>maps/images/de_stmarc.png</file> + <file>maps/images/de_sugarcane.png</file> + <file>maps/images/de_train.png</file> + <file>maps/images/de_vertigo.png</file> </qresource> </RCC> 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 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> -<!-- Written by QtCreator 4.0.3, 2016-07-30T08:47:12. --> +<!-- Written by QtCreator 4.0.3, 2016-08-14T16:55:30. --> <qtcreator> <data> <variable>EnvironmentId</variable> 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 <QNetworkAccessManager> #include <QNetworkReply> #include <QFile> +#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("<center><img src=:/icons/icons/CT.png></center>"); + ui->t_label->setText("<center><img src=:/icons/icons/T.png></center>"); +} + +game_integration_window::~game_integration_window() +{ + server->close(); + delete ui; +} + +void game_integration_window::write_console(QString color, QString line) +{ + ui->console->append("<font color=" + color + ">" + line + "</font>"); +} + +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("<img src=:/maps/maps/images/" + game.current_map + ".png /> <br />" + 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("<font size = 15>" + game.player_map["name"].toString() + "</font>"); + ui->player_score_label->setText("Score: " + game.stats_map["score"].toString()); + ui->ct_score_label->setText("<center>" + game.ct_score_map["score"].toString() + "</center>"); + ui->t_score_label->setText("<center>" + game.t_score_map["score"].toString() + "</center>"); + ui->round_number_label->setText("<center><font size = 10> Round <br />" + game.map_map["round"].toString() + "</font></center>"); + 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 <QWidget> +#include <QDebug> +#include <QTcpServer> +#include <QTcpSocket> +#include <QJsonDocument> +#include <QJsonObject> +#include <QJsonArray> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>game_integration_window</class> + <widget class="QWidget" name="game_integration_window"> + <property name="windowModality"> + <enum>Qt::WindowModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Game Integration</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QFormLayout" name="player_layout"> + <item row="0" column="0"> + <widget class="QLabel" name="map_picture_label"> + <property name="text"> + <string>map_picture</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QFormLayout" name="player_info_layout"> + <item row="0" column="0"> + <widget class="QLabel" name="player_name_label"> + <property name="text"> + <string><html><head/><body><p><span style=" font-size:14pt;">player_name</span></p></body></html></string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="player_team_label"> + <property name="text"> + <string>player_team</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="player_score_label"> + <property name="text"> + <string>player_score</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="kills_label"> + <property name="text"> + <string>kills_count</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="deaths_label"> + <property name="text"> + <string>deaths_count</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="team_icon_layout"> + <item> + <widget class="QLabel" name="ct_label"> + <property name="text"> + <string>CT_label</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="round_number_label"> + <property name="text"> + <string>round_number</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="t_label"> + <property name="text"> + <string>T_label</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QGridLayout" name="team_score_layout"> + <item row="0" column="2"> + <widget class="QLabel" name="t_score_label"> + <property name="text"> + <string>T_score</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="buffer_label"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="ct_score_label"> + <property name="text"> + <string>CT_score</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTextEdit" name="console"/> + </item> + <item> + <widget class="QPushButton" name="start_server_button"> + <property name="text"> + <string>Start server</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="stop_server_button"> + <property name="text"> + <string>Stop server</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="close_window_button"> + <property name="text"> + <string>Close window</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> 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 <QWidget> +#include <QtCharts/QChartView> +#include <QtCharts/QPieSeries> +#include <QtCharts/QPieSlice> +#include <QtCharts> +#include <QDebug> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>graphical_stats</class> + <widget class="QWidget" name="graphical_stats"> + <property name="windowModality"> + <enum>Qt::WindowModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Graphical stats</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QGraphicsView" name="graphicsView"> + <property name="sizeAdjustPolicy"> + <enum>QAbstractScrollArea::AdjustToContents</enum> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/icons/CT.png b/icons/CT.png Binary files differnew file mode 100644 index 0000000..be58703 --- /dev/null +++ b/icons/CT.png diff --git a/icons/T.png b/icons/T.png Binary files differnew file mode 100644 index 0000000..8e83fb8 --- /dev/null +++ b/icons/T.png diff --git a/maps/images/ar_baggage.png b/maps/images/ar_baggage.png Binary files differnew file mode 100644 index 0000000..8ed7c67 --- /dev/null +++ b/maps/images/ar_baggage.png diff --git a/maps/images/ar_monastery.png b/maps/images/ar_monastery.png Binary files differnew file mode 100644 index 0000000..3767f8b --- /dev/null +++ b/maps/images/ar_monastery.png diff --git a/maps/images/ar_shoots.png b/maps/images/ar_shoots.png Binary files differnew file mode 100644 index 0000000..69565cf --- /dev/null +++ b/maps/images/ar_shoots.png diff --git a/maps/images/cs_assault.png b/maps/images/cs_assault.png Binary files differnew file mode 100644 index 0000000..8a5f873 --- /dev/null +++ b/maps/images/cs_assault.png diff --git a/maps/images/cs_italy.png b/maps/images/cs_italy.png Binary files differnew file mode 100644 index 0000000..6c1f0a3 --- /dev/null +++ b/maps/images/cs_italy.png diff --git a/maps/images/cs_militia.png b/maps/images/cs_militia.png Binary files differnew file mode 100644 index 0000000..5fa26d1 --- /dev/null +++ b/maps/images/cs_militia.png diff --git a/maps/images/cs_office.png b/maps/images/cs_office.png Binary files differnew file mode 100644 index 0000000..026b730 --- /dev/null +++ b/maps/images/cs_office.png diff --git a/maps/images/de_aztec.png b/maps/images/de_aztec.png Binary files differnew file mode 100644 index 0000000..e5c7fb8 --- /dev/null +++ b/maps/images/de_aztec.png diff --git a/maps/images/de_bank.png b/maps/images/de_bank.png Binary files differnew file mode 100644 index 0000000..3dbc27f --- /dev/null +++ b/maps/images/de_bank.png diff --git a/maps/images/de_cache.png b/maps/images/de_cache.png Binary files differnew file mode 100644 index 0000000..e9eead1 --- /dev/null +++ b/maps/images/de_cache.png diff --git a/maps/images/de_cbble.png b/maps/images/de_cbble.png Binary files differnew file mode 100644 index 0000000..e7bb381 --- /dev/null +++ b/maps/images/de_cbble.png diff --git a/maps/images/de_dust.png b/maps/images/de_dust.png Binary files differnew file mode 100644 index 0000000..0e4f0a9 --- /dev/null +++ b/maps/images/de_dust.png diff --git a/maps/images/de_dust2.png b/maps/images/de_dust2.png Binary files differnew file mode 100644 index 0000000..a855b22 --- /dev/null +++ b/maps/images/de_dust2.png diff --git a/maps/images/de_inferno.png b/maps/images/de_inferno.png Binary files differnew file mode 100644 index 0000000..8736477 --- /dev/null +++ b/maps/images/de_inferno.png diff --git a/maps/images/de_lake.png b/maps/images/de_lake.png Binary files differnew file mode 100644 index 0000000..6cc1f99 --- /dev/null +++ b/maps/images/de_lake.png diff --git a/maps/images/de_mirage.png b/maps/images/de_mirage.png Binary files differnew file mode 100644 index 0000000..582199e --- /dev/null +++ b/maps/images/de_mirage.png diff --git a/maps/images/de_nuke.png b/maps/images/de_nuke.png Binary files differnew file mode 100644 index 0000000..23f643e --- /dev/null +++ b/maps/images/de_nuke.png diff --git a/maps/images/de_overpass.png b/maps/images/de_overpass.png Binary files differnew file mode 100644 index 0000000..ff6a97c --- /dev/null +++ b/maps/images/de_overpass.png diff --git a/maps/images/de_safehouse.png b/maps/images/de_safehouse.png Binary files differnew file mode 100644 index 0000000..eb0fd9c --- /dev/null +++ b/maps/images/de_safehouse.png diff --git a/maps/images/de_shortdust.png b/maps/images/de_shortdust.png Binary files differnew file mode 100644 index 0000000..de8d47a --- /dev/null +++ b/maps/images/de_shortdust.png diff --git a/maps/images/de_shorttrain.png b/maps/images/de_shorttrain.png Binary files differnew file mode 100644 index 0000000..b053c75 --- /dev/null +++ b/maps/images/de_shorttrain.png diff --git a/maps/images/de_stmarc.png b/maps/images/de_stmarc.png Binary files differnew file mode 100644 index 0000000..05acba9 --- /dev/null +++ b/maps/images/de_stmarc.png diff --git a/maps/images/de_sugarcane.png b/maps/images/de_sugarcane.png Binary files differnew file mode 100644 index 0000000..13ced9c --- /dev/null +++ b/maps/images/de_sugarcane.png diff --git a/maps/images/de_train.png b/maps/images/de_train.png Binary files differnew file mode 100644 index 0000000..b053c75 --- /dev/null +++ b/maps/images/de_train.png diff --git a/maps/images/de_vertigo.png b/maps/images/de_vertigo.png Binary files differnew file mode 100644 index 0000000..ece0fe4 --- /dev/null +++ b/maps/images/de_vertigo.png 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 <QMessageBox> + +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 <QFile> #include <QDebug> #include <QTextStream> +#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 <QWidget> #include <QDebug> #include <QLabel> +#include <message_box.h> #include "file_download.h" #include "parse_file.h" #include "user_management.h" +#include "game_integration_window.h" +#include <graphical_stats.h> +#include <QtCharts/QChartView> +#include <QtCharts/QPieSeries> +#include <QtCharts/QPieSlice> +#include <QtCharts> 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<QLabel *> 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 @@ <rect> <x>0</x> <y>0</y> - <width>643</width> - <height>402</height> + <width>645</width> + <height>587</height> </rect> </property> <property name="windowTitle"> <string>CS:GO Statistics</string> </property> <layout class="QGridLayout" name="gridLayout"> + <item row="2" column="2"> + <widget class="QPushButton" name="manage_users_button"> + <property name="text"> + <string>Manage users</string> + </property> + </widget> + </item> + <item row="8" column="2"> + <widget class="QPushButton" name="new_id_button"> + <property name="text"> + <string>New user</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <layout class="QFormLayout" name="stats_layout"> + <item row="0" column="0"> + <widget class="QLabel" name="avatar_label"> + <property name="text"> + <string>avatar</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="username_label"> + <property name="font"> + <font> + <family>Arial [Mono]</family> + <pointsize>14</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>username</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="realname_label"> + <property name="text"> + <string>realname</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="status_label"> + <property name="text"> + <string>status</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="time_in_label"> + <property name="text"> + <string>Time in CS:GO</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="mvp_number_label"> + <property name="text"> + <string>MVPs</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="total_kills_label"> + <property name="text"> + <string>total kills</string> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="total_deaths_label"> + <property name="text"> + <string>total deaths</string> + </property> + </widget> + </item> + <item row="8" column="0"> + <widget class="QLabel" name="kd_ratio_label"> + <property name="text"> + <string>K/D ratio</string> + </property> + </widget> + </item> + </layout> + </item> <item row="0" column="2"> <layout class="QGridLayout" name="base_grid"> <item row="0" column="0"> @@ -146,12 +235,8 @@ </item> </layout> </item> - <item row="7" column="0"> - <widget class="QPushButton" name="close_button"> - <property name="text"> - <string>Close</string> - </property> - </widget> + <item row="1" column="2"> + <widget class="QComboBox" name="users_dropdown"/> </item> <item row="6" column="2"> <widget class="QLineEdit" name="new_steam_id"> @@ -160,90 +245,19 @@ </property> </widget> </item> - <item row="1" column="2"> - <widget class="QComboBox" name="users_dropdown"/> - </item> - <item row="7" column="2"> - <widget class="QPushButton" name="new_id_button"> + <item row="8" column="0"> + <widget class="QPushButton" name="close_button"> <property name="text"> - <string>New user</string> + <string>Close</string> </property> </widget> </item> - <item row="0" column="0"> - <layout class="QFormLayout" name="stats_layout"> - <item row="0" column="0"> - <widget class="QLabel" name="avatar_label"> - <property name="text"> - <string>avatar</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="username_label"> - <property name="font"> - <font> - <family>Arial [Mono]</family> - <pointsize>14</pointsize> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>username</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="realname_label"> - <property name="text"> - <string>realname</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="status_label"> - <property name="text"> - <string>status</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="time_in_label"> - <property name="text"> - <string>Time in CS:GO</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="mvp_number_label"> - <property name="text"> - <string>MVPs</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="total_kills_label"> - <property name="text"> - <string>total kills</string> - </property> - </widget> - </item> - <item row="7" column="0"> - <widget class="QLabel" name="total_deaths_label"> - <property name="text"> - <string>total deaths</string> - </property> - </widget> - </item> - <item row="8" column="0"> - <widget class="QLabel" name="kd_ratio_label"> - <property name="text"> - <string>K/D ratio</string> - </property> - </widget> - </item> - </layout> + <item row="3" column="0"> + <widget class="QPushButton" name="graphical_view_button"> + <property name="text"> + <string>Graphical view</string> + </property> + </widget> </item> <item row="6" column="0"> <widget class="QPushButton" name="refresh_button"> @@ -252,10 +266,10 @@ </property> </widget> </item> - <item row="2" column="2"> - <widget class="QPushButton" name="manage_users_button"> + <item row="4" column="0"> + <widget class="QPushButton" name="game_integration_button"> <property name="text"> - <string>Manage users</string> + <string>Game integration</string> </property> </widget> </item> 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 <QWidget> #include <QDebug> #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."); } } |