From ca548026050c9643c82640cb46926545c2114949 Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Mon, 1 Aug 2016 21:57:47 +0930 Subject: Added stats for maps, added a user management tool that will allow you to add/remove user profiles from storage. --- csgo_images.qrc | 22 +++++ csgo_stats.pro | 9 +- csgo_stats.pro.user | 17 ++-- maps/ar_baggage.png | Bin 0 -> 6639 bytes maps/ar_monastery.png | Bin 0 -> 19402 bytes maps/ar_shoots.png | Bin 0 -> 17585 bytes maps/cs_assault.png | Bin 0 -> 8077 bytes maps/cs_italy.png | Bin 0 -> 9623 bytes maps/cs_militia.png | Bin 0 -> 8566 bytes maps/cs_office.png | Bin 0 -> 8465 bytes maps/de_aztec.png | Bin 0 -> 6213 bytes maps/de_bank.png | Bin 0 -> 5895 bytes maps/de_cbble.png | Bin 0 -> 10061 bytes maps/de_dust.png | Bin 0 -> 11216 bytes maps/de_dust2.png | Bin 0 -> 11459 bytes maps/de_inferno.png | Bin 0 -> 8141 bytes maps/de_lake.png | Bin 0 -> 6510 bytes maps/de_nuke.png | Bin 0 -> 11225 bytes maps/de_safehouse.png | Bin 0 -> 8545 bytes maps/de_stmarc.png | Bin 0 -> 18850 bytes maps/de_sugarcane.png | Bin 0 -> 18819 bytes maps/de_train.png | Bin 0 -> 8467 bytes maps/de_vertigo.png | Bin 0 -> 20007 bytes maps2/ar_baggage.png | Bin 0 -> 7039 bytes maps2/ar_monastery.png | Bin 0 -> 19402 bytes maps2/ar_shoots.png | Bin 0 -> 17585 bytes maps2/cs_assault.png | Bin 0 -> 8077 bytes maps2/cs_italy.png | Bin 0 -> 9623 bytes maps2/cs_militia.png | Bin 0 -> 12105 bytes maps2/cs_office.png | Bin 0 -> 10646 bytes maps2/de_aztec.png | Bin 0 -> 9738 bytes maps2/de_bank.png | Bin 0 -> 8254 bytes maps2/de_cbble.png | Bin 0 -> 13422 bytes maps2/de_dust.png | Bin 0 -> 14797 bytes maps2/de_dust2.png | Bin 0 -> 15436 bytes maps2/de_inferno.png | Bin 0 -> 10182 bytes maps2/de_lake.png | Bin 0 -> 9611 bytes maps2/de_nuke.png | Bin 0 -> 12909 bytes maps2/de_safehouse.png | Bin 0 -> 9914 bytes maps2/de_stmarc.png | Bin 0 -> 18850 bytes maps2/de_sugarcane.png | Bin 0 -> 18819 bytes maps2/de_train.png | Bin 0 -> 9698 bytes maps2/de_vertigo.png | Bin 0 -> 20007 bytes maps2/temp.png | Bin 0 -> 11416 bytes parse_file.cpp | 36 +++++++ parse_file.h | 2 + stats_display_window.cpp | 72 ++++++++++---- stats_display_window.h | 32 ++++++- stats_display_window.ui | 245 +++++++++++++++++++++++++++++------------------ user_management.cpp | 50 ++++++++++ user_management.h | 35 +++++++ user_management.ui | 100 +++++++++++++++++++ user_select_dialog.cpp | 15 ++- user_select_dialog.h | 6 ++ user_select_dialog.ui | 40 ++++++-- weapons/nova.png | Bin 1154 -> 2851 bytes weapons/sawedoff.png | Bin 1100 -> 2396 bytes 57 files changed, 544 insertions(+), 137 deletions(-) create mode 100644 maps/ar_baggage.png create mode 100644 maps/ar_monastery.png create mode 100644 maps/ar_shoots.png create mode 100644 maps/cs_assault.png create mode 100644 maps/cs_italy.png create mode 100644 maps/cs_militia.png create mode 100644 maps/cs_office.png create mode 100644 maps/de_aztec.png create mode 100644 maps/de_bank.png create mode 100644 maps/de_cbble.png create mode 100644 maps/de_dust.png create mode 100644 maps/de_dust2.png create mode 100644 maps/de_inferno.png create mode 100644 maps/de_lake.png create mode 100644 maps/de_nuke.png create mode 100644 maps/de_safehouse.png create mode 100644 maps/de_stmarc.png create mode 100644 maps/de_sugarcane.png create mode 100644 maps/de_train.png create mode 100644 maps/de_vertigo.png create mode 100644 maps2/ar_baggage.png create mode 100644 maps2/ar_monastery.png create mode 100644 maps2/ar_shoots.png create mode 100644 maps2/cs_assault.png create mode 100644 maps2/cs_italy.png create mode 100644 maps2/cs_militia.png create mode 100644 maps2/cs_office.png create mode 100644 maps2/de_aztec.png create mode 100644 maps2/de_bank.png create mode 100644 maps2/de_cbble.png create mode 100644 maps2/de_dust.png create mode 100644 maps2/de_dust2.png create mode 100644 maps2/de_inferno.png create mode 100644 maps2/de_lake.png create mode 100644 maps2/de_nuke.png create mode 100644 maps2/de_safehouse.png create mode 100644 maps2/de_stmarc.png create mode 100644 maps2/de_sugarcane.png create mode 100644 maps2/de_train.png create mode 100644 maps2/de_vertigo.png create mode 100644 maps2/temp.png create mode 100644 user_management.cpp create mode 100644 user_management.h create mode 100644 user_management.ui diff --git a/csgo_images.qrc b/csgo_images.qrc index 968ebef..5ae9dad 100644 --- a/csgo_images.qrc +++ b/csgo_images.qrc @@ -61,4 +61,26 @@ weapons/xm1014.png weapons/m249.png + + maps/ar_baggage.png + maps/ar_monastery.png + maps/ar_shoots.png + maps/cs_assault.png + maps/cs_italy.png + maps/cs_militia.png + maps/cs_office.png + maps/de_aztec.png + maps/de_bank.png + maps/de_cbble.png + maps/de_dust.png + maps/de_dust2.png + maps/de_inferno.png + maps/de_lake.png + maps/de_nuke.png + maps/de_safehouse.png + maps/de_stmarc.png + maps/de_sugarcane.png + maps/de_train.png + maps/de_vertigo.png + diff --git a/csgo_stats.pro b/csgo_stats.pro index dcdd896..bc584ff 100644 --- a/csgo_stats.pro +++ b/csgo_stats.pro @@ -16,15 +16,18 @@ SOURCES += main.cpp\ user_select_dialog.cpp \ file_download.cpp \ stats_display_window.cpp \ - parse_file.cpp + parse_file.cpp \ + user_management.cpp HEADERS += user_select_dialog.h \ file_download.h \ stats_display_window.h \ - parse_file.h + parse_file.h \ + user_management.h FORMS += user_select_dialog.ui \ - stats_display_window.ui + stats_display_window.ui \ + user_management.ui RESOURCES += \ csgo_images.qrc diff --git a/csgo_stats.pro.user b/csgo_stats.pro.user index 5349ab4..85df869 100644 --- a/csgo_stats.pro.user +++ b/csgo_stats.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -300,14 +300,17 @@ 13 14 - -1 + 2 - - - %{buildDir} - Custom Executable + csgo_stats - ProjectExplorer.CustomExecutableRunConfiguration + Qt4ProjectManager.Qt4RunConfiguration:/home/daniel_j/programming/c++/csgo_stats/csgo_stats/csgo_stats.pro + true + + csgo_stats.pro + false + + /home/daniel_j/programming/c++/csgo_stats/build-csgo_stats-Desktop-Debug 3768 false true diff --git a/maps/ar_baggage.png b/maps/ar_baggage.png new file mode 100644 index 0000000..c33c5e0 Binary files /dev/null and b/maps/ar_baggage.png differ diff --git a/maps/ar_monastery.png b/maps/ar_monastery.png new file mode 100644 index 0000000..8954c2c Binary files /dev/null and b/maps/ar_monastery.png differ diff --git a/maps/ar_shoots.png b/maps/ar_shoots.png new file mode 100644 index 0000000..066d04c Binary files /dev/null and b/maps/ar_shoots.png differ diff --git a/maps/cs_assault.png b/maps/cs_assault.png new file mode 100644 index 0000000..7932e05 Binary files /dev/null and b/maps/cs_assault.png differ diff --git a/maps/cs_italy.png b/maps/cs_italy.png new file mode 100644 index 0000000..c20a880 Binary files /dev/null and b/maps/cs_italy.png differ diff --git a/maps/cs_militia.png b/maps/cs_militia.png new file mode 100644 index 0000000..091be17 Binary files /dev/null and b/maps/cs_militia.png differ diff --git a/maps/cs_office.png b/maps/cs_office.png new file mode 100644 index 0000000..451c786 Binary files /dev/null and b/maps/cs_office.png differ diff --git a/maps/de_aztec.png b/maps/de_aztec.png new file mode 100644 index 0000000..f824da5 Binary files /dev/null and b/maps/de_aztec.png differ diff --git a/maps/de_bank.png b/maps/de_bank.png new file mode 100644 index 0000000..ab54ae1 Binary files /dev/null and b/maps/de_bank.png differ diff --git a/maps/de_cbble.png b/maps/de_cbble.png new file mode 100644 index 0000000..6c6ae29 Binary files /dev/null and b/maps/de_cbble.png differ diff --git a/maps/de_dust.png b/maps/de_dust.png new file mode 100644 index 0000000..2c3e897 Binary files /dev/null and b/maps/de_dust.png differ diff --git a/maps/de_dust2.png b/maps/de_dust2.png new file mode 100644 index 0000000..53b5a9e Binary files /dev/null and b/maps/de_dust2.png differ diff --git a/maps/de_inferno.png b/maps/de_inferno.png new file mode 100644 index 0000000..93a7b5c Binary files /dev/null and b/maps/de_inferno.png differ diff --git a/maps/de_lake.png b/maps/de_lake.png new file mode 100644 index 0000000..9543c72 Binary files /dev/null and b/maps/de_lake.png differ diff --git a/maps/de_nuke.png b/maps/de_nuke.png new file mode 100644 index 0000000..ca164d7 Binary files /dev/null and b/maps/de_nuke.png differ diff --git a/maps/de_safehouse.png b/maps/de_safehouse.png new file mode 100644 index 0000000..933736e Binary files /dev/null and b/maps/de_safehouse.png differ diff --git a/maps/de_stmarc.png b/maps/de_stmarc.png new file mode 100644 index 0000000..b31af7c Binary files /dev/null and b/maps/de_stmarc.png differ diff --git a/maps/de_sugarcane.png b/maps/de_sugarcane.png new file mode 100644 index 0000000..e15a25a Binary files /dev/null and b/maps/de_sugarcane.png differ diff --git a/maps/de_train.png b/maps/de_train.png new file mode 100644 index 0000000..b50ef19 Binary files /dev/null and b/maps/de_train.png differ diff --git a/maps/de_vertigo.png b/maps/de_vertigo.png new file mode 100644 index 0000000..b87f80e Binary files /dev/null and b/maps/de_vertigo.png differ diff --git a/maps2/ar_baggage.png b/maps2/ar_baggage.png new file mode 100644 index 0000000..87049a3 Binary files /dev/null and b/maps2/ar_baggage.png differ diff --git a/maps2/ar_monastery.png b/maps2/ar_monastery.png new file mode 100644 index 0000000..8954c2c Binary files /dev/null and b/maps2/ar_monastery.png differ diff --git a/maps2/ar_shoots.png b/maps2/ar_shoots.png new file mode 100644 index 0000000..066d04c Binary files /dev/null and b/maps2/ar_shoots.png differ diff --git a/maps2/cs_assault.png b/maps2/cs_assault.png new file mode 100644 index 0000000..7932e05 Binary files /dev/null and b/maps2/cs_assault.png differ diff --git a/maps2/cs_italy.png b/maps2/cs_italy.png new file mode 100644 index 0000000..c20a880 Binary files /dev/null and b/maps2/cs_italy.png differ diff --git a/maps2/cs_militia.png b/maps2/cs_militia.png new file mode 100644 index 0000000..871c427 Binary files /dev/null and b/maps2/cs_militia.png differ diff --git a/maps2/cs_office.png b/maps2/cs_office.png new file mode 100644 index 0000000..3bb0eac Binary files /dev/null and b/maps2/cs_office.png differ diff --git a/maps2/de_aztec.png b/maps2/de_aztec.png new file mode 100644 index 0000000..2f4b753 Binary files /dev/null and b/maps2/de_aztec.png differ diff --git a/maps2/de_bank.png b/maps2/de_bank.png new file mode 100644 index 0000000..738e694 Binary files /dev/null and b/maps2/de_bank.png differ diff --git a/maps2/de_cbble.png b/maps2/de_cbble.png new file mode 100644 index 0000000..793eb9e Binary files /dev/null and b/maps2/de_cbble.png differ diff --git a/maps2/de_dust.png b/maps2/de_dust.png new file mode 100644 index 0000000..4a0d85e Binary files /dev/null and b/maps2/de_dust.png differ diff --git a/maps2/de_dust2.png b/maps2/de_dust2.png new file mode 100644 index 0000000..c20138a Binary files /dev/null and b/maps2/de_dust2.png differ diff --git a/maps2/de_inferno.png b/maps2/de_inferno.png new file mode 100644 index 0000000..4d5ba69 Binary files /dev/null and b/maps2/de_inferno.png differ diff --git a/maps2/de_lake.png b/maps2/de_lake.png new file mode 100644 index 0000000..2012bd7 Binary files /dev/null and b/maps2/de_lake.png differ diff --git a/maps2/de_nuke.png b/maps2/de_nuke.png new file mode 100644 index 0000000..ab38d70 Binary files /dev/null and b/maps2/de_nuke.png differ diff --git a/maps2/de_safehouse.png b/maps2/de_safehouse.png new file mode 100644 index 0000000..70de0d8 Binary files /dev/null and b/maps2/de_safehouse.png differ diff --git a/maps2/de_stmarc.png b/maps2/de_stmarc.png new file mode 100644 index 0000000..b31af7c Binary files /dev/null and b/maps2/de_stmarc.png differ diff --git a/maps2/de_sugarcane.png b/maps2/de_sugarcane.png new file mode 100644 index 0000000..e15a25a Binary files /dev/null and b/maps2/de_sugarcane.png differ diff --git a/maps2/de_train.png b/maps2/de_train.png new file mode 100644 index 0000000..d16da9a Binary files /dev/null and b/maps2/de_train.png differ diff --git a/maps2/de_vertigo.png b/maps2/de_vertigo.png new file mode 100644 index 0000000..b87f80e Binary files /dev/null and b/maps2/de_vertigo.png differ diff --git a/maps2/temp.png b/maps2/temp.png new file mode 100644 index 0000000..da5bc46 Binary files /dev/null and b/maps2/temp.png differ diff --git a/parse_file.cpp b/parse_file.cpp index 2193a04..3d6a078 100644 --- a/parse_file.cpp +++ b/parse_file.cpp @@ -91,3 +91,39 @@ QStringList parse_file::get_ids() { return userids; } + +void parse_file::delete_user(QString user) +{ + /* copy pasta, make pretty */ + qDebug() << "deleting user" << user; + QFile f("users.dat"); + if(f.open(QIODevice::ReadWrite | QIODevice::Text)) + { + QString s; + QTextStream t(&f); + while(!t.atEnd()) + { + QString line = t.readLine(); + if(line != user) + s.append(line + "\n"); + } + f.resize(0); + t << s; + f.close(); + } +} + +void parse_file::add_user(QString user) +{ + qDebug() << "adding user" << user; + QFile file("users.dat"); + if(!file.open(QIODevice::Append)) { + qDebug() << "Cannot open file to save"; + + } else + { + QTextStream stream(&file); + stream << user; + file.close(); + } +} diff --git a/parse_file.h b/parse_file.h index e12a66f..25b0aa6 100644 --- a/parse_file.h +++ b/parse_file.h @@ -15,6 +15,8 @@ public: QStringList get_ids(); /* returns pre parsed data */ QStringList usernames; QStringList userids; + void delete_user(QString user); + void add_user(QString user); }; #endif // PARSE_FILE_H diff --git a/stats_display_window.cpp b/stats_display_window.cpp index 1af8907..577586e 100644 --- a/stats_display_window.cpp +++ b/stats_display_window.cpp @@ -68,34 +68,56 @@ void stats_display_window::setup_user() void stats_display_window::setup_csgo_data() { - /* this function populates our data templates and filsl in the UI */ + /* this function populates our data templates and fills in the UI */ + /* tables */ ui->weapon_table->setColumnCount(2); ui->weapon_table->setRowCount(33); - /* set data in user,weapons */ + ui->map_table->setColumnCount(2); + ui->map_table->setRowCount(20); + /* + * set data in user.weapons + * create a qlabel for each weapon * 2 and set the info + */ for (int x = 0; x < 33; x++) { + /* parse stats */ user.weapons[x][2] = parse.parse_csgo_data("total_kills_" + user.weapons[x][0]); user.weapons[x][3] = parse.parse_csgo_data("total_shots_" + user.weapons[x][0]); user.weapons[x][4] = parse.parse_csgo_data("total_hits_" + user.weapons[x][0]); user.weapons[x][5] = QString::number(user.weapons[x][4].toFloat() / user.weapons[x][3].toFloat(), 'f', 2); + /* set weapon label */ + user.weapon_labels << new QLabel(this); + user.weapon_labels.at(x)->setTextFormat(Qt::RichText); + user.weapon_labels.at(x)->setText("

" + user.weapons[x][0] + "
"); + ui->weapon_table->setCellWidget(x, 0, user.weapon_labels.at(x)); + /* set weapon stat labels */ + user.stat_labels << new QLabel(this); + user.stat_labels.at(x)->setTextFormat(Qt::RichText); + user.stat_labels.at(x)->setText(user.weapons[x][2] + " kills
" + user.weapons[x][3] + " shots
" + user.weapons[x][4] + " hits
" + user.weapons[x][5] + " hit ratio"); + ui->weapon_table->setCellWidget(x, 1, user.stat_labels.at(x)); } - /* weapon label/image */ - QList weapon_labels; - for (int i = 0; i < 33; ++i) - { - weapon_labels << new QLabel(this); - weapon_labels.at(i)->setTextFormat(Qt::RichText); - weapon_labels.at(i)->setText("
" + user.weapons[i][0] + "
"); - ui->weapon_table->setCellWidget(i, 0, weapon_labels.at(i)); - } - /* stats */ - QList stat_labels; - for (int i = 0; i < 33; ++i) + + /* + * set data in user.maps + * create a qlabel for each map * 2 and set the info + */ + for (int x = 0; x < 20; x++) { - stat_labels << new QLabel(this); - stat_labels.at(i)->setTextFormat(Qt::RichText); - stat_labels.at(i)->setText(user.weapons[i][2] + " kills
" + user.weapons[i][3] + " shots
" + user.weapons[i][4] + " hits
" + user.weapons[i][5] + " hit ratio"); - ui->weapon_table->setCellWidget(i, 1, stat_labels.at(i)); + /* parse stats */ + user.maps[x][2] = parse.parse_csgo_data("total_rounds_map_" + user.maps[x][0] + '"'); + user.maps[x][3] = parse.parse_csgo_data("total_wins_map_" + user.maps[x][0] + '"'); + user.maps[x][4] = QString::number(user.maps[x][2].toInt() - user.maps[x][3].toInt()); + user.maps[x][5] = QString::number(user.maps[x][3].toFloat() / user.maps[x][2].toFloat(), 'f', 2); + /* set map label */ + user.map_labels << new QLabel(this); + user.map_labels.at(x)->setTextFormat(Qt::RichText); + user.map_labels.at(x)->setText("

" + user.maps[x][0] + "
"); + ui->map_table->setCellWidget(x, 0, user.map_labels.at(x)); + /* set map stat labels */ + user.map_stat_labels << new QLabel(this); + user.map_stat_labels.at(x)->setTextFormat(Qt::RichText); + user.map_stat_labels.at(x)->setText(user.maps[x][2] + " rounds
" + user.maps[x][3] + " won
" + user.maps[x][4] + " lost
" + user.maps[x][5] + " W/L ratio"); + ui->map_table->setCellWidget(x, 1, user.map_stat_labels.at(x)); } /* time played */ @@ -182,9 +204,12 @@ void stats_display_window::on_refresh_button_clicked() void stats_display_window::on_new_id_button_clicked() { - user.user_64id = ui->new_steam_id->text(); - reload_profile(); - load_players(); + if (ui->new_steam_id->text() != "") + { + user.user_64id = ui->new_steam_id->text(); + reload_profile(); + load_players(); + } } void stats_display_window::on_users_dropdown_currentIndexChanged(int index) @@ -192,3 +217,8 @@ void stats_display_window::on_users_dropdown_currentIndexChanged(int index) if (!usernames.isEmpty() && index != -1) ui->new_steam_id->setText(userids.at(index)); } + +void stats_display_window::on_manage_users_button_clicked() +{ + manage.show(); +} diff --git a/stats_display_window.h b/stats_display_window.h index 971b9ca..7748097 100644 --- a/stats_display_window.h +++ b/stats_display_window.h @@ -3,8 +3,10 @@ #include #include +#include #include "file_download.h" #include "parse_file.h" +#include "user_management.h" namespace Ui { class stats_display_window; @@ -40,6 +42,31 @@ private: QString total_kills; QString total_deaths; float kd_ratio; + QString maps[20][6] = { + /* map name | image location | rounds total | rounds win | rounds lost | win percent*/ + {"cs_assault", ":/maps/maps/cs_assault.png", "", "", ""}, + {"cs_italy", ":/maps/maps/cs_italy.png", "", "", "", ""}, + {"cs_office", ":/maps/maps/cs_office.png", "", "", "", ""}, + {"de_aztec", ":/maps/maps/de_aztec.png", "", "", "", ""}, + {"de_cbble", ":/maps/maps/de_cbble.png", "", "", "", ""}, + {"de_dust2", ":/maps/maps/de_dust2.png", "", "", "", ""}, + {"de_dust", ":/maps/maps/de_dust.png", "", "", "", ""}, + {"de_inferno", ":/maps/maps/de_inferno.png", "" "", "", ""}, + {"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_safehouse", ":/maps/maps/de_safehouse.png", "" "", "" , ""}, + {"ar_baggage", ":/maps/maps/ar_baggage.png", "", "", "", ""}, + {"ar_shoots", ":/maps/maps/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", "", "", "", ""}, + {"cs_militia", ":/maps/maps/cs_militia.png", "", "", "", ""}, + }; + QList map_labels; + QList map_stat_labels; QString weapons[33][6] = { /*weapon name | image location | kills | shots | hits | ratio of hits to shots */ {"ak47", ":/weapons/weapons/ak47.png", "0", "0", "0", "0"}, @@ -76,12 +103,14 @@ private: {"taser", ":/weapons/weapons/taser.png", "0", "0", "0", "0"}, {"molotov", ":/weapons/weapons/molotov.png", "0", "0", "0", "0"}, }; - + QList weapon_labels; + QList stat_labels; } user; file_download download; parse_file parse; QStringList usernames; QStringList userids; + user_management manage; signals: void window_loaded(); @@ -90,6 +119,7 @@ private slots: void on_refresh_button_clicked(); void on_new_id_button_clicked(); void on_users_dropdown_currentIndexChanged(int index); + void on_manage_users_button_clicked(); }; #endif // STATS_DISPLAY_WINDOW_H diff --git a/stats_display_window.ui b/stats_display_window.ui index 06e36af..9274368 100644 --- a/stats_display_window.ui +++ b/stats_display_window.ui @@ -9,7 +9,7 @@ 0 0 - 416 + 643 402 @@ -17,37 +17,159 @@ CS:GO Statistics - - + + + + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-size:16pt;">Weapon Statistics</span></p></body></html> + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + QAbstractScrollArea::AdjustToContents + + + false + + + false + + + true + + + false + + + false + + + 100 + + + false + + + 15 + + + false + + + 70 + + + false + + + + + + + QAbstractScrollArea::AdjustToContents + + + false + + + false + + + false + + + false + + + 100 + + + false + + + 15 + + + false + + + 70 + + + false + + + + + + + <html><head/><body><p><span style=" font-size:16pt;">Map Statistics</span></p></body></html> + + + + + + + + + - refresh + Close - + New Steam account ID here - - - - Close - - + + - + - New ID + New user - - - @@ -123,84 +245,19 @@ - - - - - - - - - 0 - 0 - - - - <html><head/><body><p><span style=" font-size:16pt;">Weapon Statistics</span></p></body></html> - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - QAbstractScrollArea::AdjustToContents - - - false - - - false - - - true - - - false - - - false - - - 100 - - - 15 - - - false - - - 70 - - - - - - + + + + Refresh statistics + + + + + + + Manage users + + diff --git a/user_management.cpp b/user_management.cpp new file mode 100644 index 0000000..21058b0 --- /dev/null +++ b/user_management.cpp @@ -0,0 +1,50 @@ +#include "user_management.h" +#include "ui_user_management.h" + +user_management::user_management(QWidget *parent) : + QWidget(parent), + ui(new Ui::user_management) +{ + ui->setupUi(this); + load_players(); +} + +user_management::~user_management() +{ + delete ui; +} + +void user_management::load_players() +{ + ui->user_dropdown->clear(); + usernames.clear(); + userids.clear(); + parse.parse_users(); + usernames = parse.get_usernames(); + userids = parse.get_ids(); + for (int x = 0; x < usernames.length(); x++) + { + ui->user_dropdown->addItem(usernames.at(x)); + } +} + +void user_management::on_refresh_users_button_clicked() +{ + load_players(); +} + +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(); +} + +void user_management::on_add_user_button_clicked() +{ + if (ui->username_text->text() != "" && ui->user_id_text->text() != "") + { + QString user = ui->username_text->text() + "=" + ui->user_id_text->text(); + parse.add_user(user); + } +} diff --git a/user_management.h b/user_management.h new file mode 100644 index 0000000..88e2bd0 --- /dev/null +++ b/user_management.h @@ -0,0 +1,35 @@ +#ifndef USER_MANAGEMENT_H +#define USER_MANAGEMENT_H + +#include +#include +#include "parse_file.h" + +namespace Ui { +class user_management; +} + +class user_management : public QWidget +{ + Q_OBJECT + +public: + explicit user_management(QWidget *parent = 0); + ~user_management(); + +private slots: + void on_refresh_users_button_clicked(); + + void on_delete_user_button_clicked(); + + void on_add_user_button_clicked(); + +private: + Ui::user_management *ui; + parse_file parse; + QStringList usernames; + QStringList userids; + void load_players(); +}; + +#endif // USER_MANAGEMENT_H diff --git a/user_management.ui b/user_management.ui new file mode 100644 index 0000000..c9f3fe7 --- /dev/null +++ b/user_management.ui @@ -0,0 +1,100 @@ + + + user_management + + + Qt::ApplicationModal + + + + 0 + 0 + 157 + 208 + + + + User Management + + + + + + + + + Remove selected user + + + + + + + Refresh list + + + + + + + Username + + + + + + + Username + + + + + + + Steam ID + + + + + + + Steam ID + + + + + + + Add user + + + + + + + Close + + + + + + + + + close_button + clicked() + user_management + close() + + + 99 + 84 + + + 94 + 107 + + + + + diff --git a/user_select_dialog.cpp b/user_select_dialog.cpp index 1ba0593..8431417 100644 --- a/user_select_dialog.cpp +++ b/user_select_dialog.cpp @@ -77,6 +77,19 @@ void user_select_dialog::load_players() void user_select_dialog::on_player_dropdown_currentIndexChanged(int index) { - if (!usernames.isEmpty()) + if (!usernames.isEmpty() && index != -1) ui->steam_url_text->setText(userids.at(index)); } + +void user_select_dialog::on_manage_users_button_clicked() +{ + manage.show(); +} + +void user_select_dialog::on_refresh_users_button_clicked() +{ + ui->player_dropdown->clear(); + usernames.clear(); + userids.clear(); + load_players(); +} diff --git a/user_select_dialog.h b/user_select_dialog.h index 5e8253f..dc83ddb 100644 --- a/user_select_dialog.h +++ b/user_select_dialog.h @@ -7,6 +7,7 @@ #include "file_download.h" #include "stats_display_window.h" #include "parse_file.h" +#include "user_management.h" namespace Ui { class user_select_dialog; @@ -25,10 +26,15 @@ private slots: void on_player_dropdown_currentIndexChanged(int index); + void on_manage_users_button_clicked(); + + void on_refresh_users_button_clicked(); + private: Ui::user_select_dialog *ui; file_download download; stats_display_window n_window; + user_management manage; parse_file parse; void download_info(); void load_players(); diff --git a/user_select_dialog.ui b/user_select_dialog.ui index f435425..fcd9877 100644 --- a/user_select_dialog.ui +++ b/user_select_dialog.ui @@ -10,9 +10,15 @@ 0 0 269 - 138 + 190 + + + 269 + 16777215 + + Select a Steam account @@ -20,10 +26,10 @@ - - + + - Close + 76561198055087665 @@ -34,23 +40,37 @@ - - + + - 76561198055087665 + Select - - + + - Select + Manage users + + + + Close + + + + + + + Refresh list + + + diff --git a/weapons/nova.png b/weapons/nova.png index a759e4a..0d3a0bb 100644 Binary files a/weapons/nova.png and b/weapons/nova.png differ diff --git a/weapons/sawedoff.png b/weapons/sawedoff.png index a440e24..4285e61 100644 Binary files a/weapons/sawedoff.png and b/weapons/sawedoff.png differ -- cgit v1.2.3