From: Samual Lenks Date: Sat, 21 Dec 2013 09:04:44 +0000 (-0500) Subject: Add statslist to Profile tab (now just needs to be made to look pretty) X-Git-Tag: xonotic-v0.8.0~139^2~1^2~68 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=a57d9d473dc96a01476b6cfb045be54f1ef1984c;p=xonotic%2Fxonotic-data.pk3dir.git Add statslist to Profile tab (now just needs to be made to look pretty) --- diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index 3667d30d4..52008ee44 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -1,33 +1,3 @@ -#ifdef SVQC -//float PS_PM_IN_DB; // playerstats_prematch_in_db // db for info COLLECTED at the beginning of a match -float PS_GR_OUT_DB; // playerstats_gamereport_out_db // db of info SENT at the end of a match -//float PS_GR_IN_DB; // playerstats_gamereport_in_db // db for info COLLECTED at the end of a match -//float PS_B_IN_DB; // playerstats_playerbasic_in_db // db for info COLLECTED for basic player info (ELO) -// http://stats.xonotic.org/player/GgXRw6piDtFIbMArMuiAi8JG4tiin8VLjZgsKB60Uds=/elo.txt -- this works, -// http://stats.xonotic.org/player/ENkUjf83vKMVZcNm%2F6Ao1EmXEj1apQ6XvdQTxwELvmA%3D/elo.txt -- but this doesn't?!? -// ENkUjf83vKMVZcNm/6Ao1EmXEj1apQ6XvdQTxwELvmA= -#endif - -#ifdef MENUQC -float PS_D_IN_DB; // playerstats_playerdetail_in_db // db for info COLLECTED for detailed player profile display -// http://stats.xonotic.org/player/me -#endif - -#ifdef SVQC -//string PS_PM_IN_EVL; // playerstats_prematch_in_events_last -string PS_GR_OUT_TL; // playerstats_gamereport_out_teams_last -string PS_GR_OUT_PL; // playerstats_gamereport_out_players_las -string PS_GR_OUT_EVL; // playerstats_gamereport_out_events_last -//string PS_GR_IN_PL; // playerstats_gamereport_in_players_last -//string PS_GR_IN_EVL; // playerstats_gamereport_in_events_last -//string PS_B_IN_PL; // playerstats_playerbasic_in_players_last -//string PS_B_IN_EVL; // playerstats_playerbasic_in_events_last -#endif - -#ifdef MENUQC -string PS_D_IN_EVL; // playerstats_playerdetail_in_events_last -#endif - #ifdef SVQC void PlayerStats_Prematch(void) { diff --git a/qcsrc/common/playerstats.qh b/qcsrc/common/playerstats.qh index 481d33a04..300ae66da 100644 --- a/qcsrc/common/playerstats.qh +++ b/qcsrc/common/playerstats.qh @@ -1,3 +1,33 @@ +#ifdef SVQC +//float PS_PM_IN_DB; // playerstats_prematch_in_db // db for info COLLECTED at the beginning of a match +float PS_GR_OUT_DB; // playerstats_gamereport_out_db // db of info SENT at the end of a match +//float PS_GR_IN_DB; // playerstats_gamereport_in_db // db for info COLLECTED at the end of a match +//float PS_B_IN_DB; // playerstats_playerbasic_in_db // db for info COLLECTED for basic player info (ELO) +// http://stats.xonotic.org/player/GgXRw6piDtFIbMArMuiAi8JG4tiin8VLjZgsKB60Uds=/elo.txt -- this works, +// http://stats.xonotic.org/player/ENkUjf83vKMVZcNm%2F6Ao1EmXEj1apQ6XvdQTxwELvmA%3D/elo.txt -- but this doesn't?!? +// ENkUjf83vKMVZcNm/6Ao1EmXEj1apQ6XvdQTxwELvmA= +#endif + +#ifdef MENUQC +float PS_D_IN_DB; // playerstats_playerdetail_in_db // db for info COLLECTED for detailed player profile display +// http://stats.xonotic.org/player/me +#endif + +#ifdef SVQC +//string PS_PM_IN_EVL; // playerstats_prematch_in_events_last +string PS_GR_OUT_TL; // playerstats_gamereport_out_teams_last +string PS_GR_OUT_PL; // playerstats_gamereport_out_players_las +string PS_GR_OUT_EVL; // playerstats_gamereport_out_events_last +//string PS_GR_IN_PL; // playerstats_gamereport_in_players_last +//string PS_GR_IN_EVL; // playerstats_gamereport_in_events_last +//string PS_B_IN_PL; // playerstats_playerbasic_in_players_last +//string PS_B_IN_EVL; // playerstats_playerbasic_in_events_last +#endif + +#ifdef MENUQC +string PS_D_IN_EVL; // playerstats_playerdetail_in_events_last +#endif + #ifdef SVQC // time the player was alive and kicking diff --git a/qcsrc/menu/classes.c b/qcsrc/menu/classes.c index 5a9e516c8..6890f04c6 100644 --- a/qcsrc/menu/classes.c +++ b/qcsrc/menu/classes.c @@ -94,6 +94,7 @@ #include "xonotic/dialog_multiplayer_media_screenshot.c" #include "xonotic/dialog_multiplayer_media_screenshot_viewer.c" #include "xonotic/screenshotlist.c" +#include "xonotic/statslist.c" #include "xonotic/colorpicker.c" #include "xonotic/colorpicker_string.c" #include "xonotic/cvarlist.c" diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_profile.c b/qcsrc/menu/xonotic/dialog_multiplayer_profile.c index 34d34e200..3ce19b9b8 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_profile.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_profile.c @@ -64,33 +64,12 @@ void XonoticProfileTab_fill(entity me) // Statistic Stuff -Debugger me.TR(me); - me.TDempty(me, 0.5); - me.TD(me, 1, 2, e = makeXonoticTextLabel(0.5, _("Player Statistics"))); + me.TD(me, 1, 3, e = makeXonoticTextLabel(0.5, _("Player Statistics"))); e.isBold = TRUE; e.alpha = 0.5; me.TR(me); - me.TR(me); - /*me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Join time:"))); - me.TR(me); - me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Total playing time:"))); - me.TR(me); - me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Last played:"))); - me.TR(me); - me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Games played:"))); - me.TR(me); - me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Win / Losses:"))); - me.TR(me); - me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Kills / Deaths:"))); - me.TR(me); - me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("CTF elo:"))); - me.TR(me); - me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("DM elo:"))); - me.TR(me); - me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("TDM elo:"))); - me.TR(me); - me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("DUEL elo:"))); - me.TR(me);*/ - + me.TD(me, 11, 3, e = makeXonoticStatsList()); + me.gotoRC(me, 0.5, 3.2); me.setFirstColumn(me, me.currentColumn); me.TDempty(me, 1); diff --git a/qcsrc/menu/xonotic/statslist.c b/qcsrc/menu/xonotic/statslist.c new file mode 100644 index 000000000..70d0b5609 --- /dev/null +++ b/qcsrc/menu/xonotic/statslist.c @@ -0,0 +1,131 @@ +#ifdef INTERFACE +CLASS(XonoticStatsList) EXTENDS(XonoticListBox) + METHOD(XonoticStatsList, configureXonoticStatsList, void(entity)) + ATTRIB(XonoticStatsList, rowsPerItem, float, 1.25) + METHOD(XonoticStatsList, resizeNotify, void(entity, vector, vector, vector, vector)) + METHOD(XonoticStatsList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticStatsList, getStats, void(entity)) + METHOD(XonoticStatsList, clickListBoxItem, void(entity, float, vector)) + METHOD(XonoticStatsList, keyDown, float(entity, float, float, float)) + METHOD(XonoticStatsList, destroy, void(entity)) + METHOD(XonoticStatsList, showNotify, void(entity)) + + ATTRIB(XonoticStatsList, listStats, float, -1) + ATTRIB(XonoticStatsList, realFontSize, vector, '0 0 0') + ATTRIB(XonoticStatsList, columnNameOrigin, float, 0) + ATTRIB(XonoticStatsList, columnNameSize, float, 0) + ATTRIB(XonoticStatsList, realUpperMargin, float, 0) + ATTRIB(XonoticStatsList, origin, vector, '0 0 0') + ATTRIB(XonoticStatsList, itemAbsSize, vector, '0 0 0') + + ATTRIB(XonoticStatsList, lastClickedDemo, float, -1) + ATTRIB(XonoticStatsList, lastClickedTime, float, 0) + ATTRIB(XonoticStatsList, filterString, string, string_null) +ENDCLASS(XonoticStatsList) + +entity demolist; // for reference elsewhere +entity makeXonoticStatsList(); +#endif + +#ifdef IMPLEMENTATION + +entity makeXonoticStatsList() +{ + entity me; + me = spawnXonoticStatsList(); + me.configureXonoticStatsList(me); + return me; +} + +void XonoticStatsList_configureXonoticStatsList(entity me) +{ + me.configureXonoticListBox(me); + me.getStats(me); +} + +void XonoticStatsList_getStats(entity me) +{ + if (me.listStats >= 0) + buf_del(me.listStats); + me.listStats = buf_create(); + if (me.listStats < 0) + { + me.nItems = 0; + return; + } + + string e = "", en = ""; + float i = 0; + for(e = PS_D_IN_EVL; (en = db_get(PS_D_IN_DB, e)) != ""; e = en) + { + ++i; + bufstr_add(me.listStats, sprintf("%d:%s:%s\n", i, e, db_get(PS_D_IN_DB, sprintf("#%s", e))), TRUE); + } + + me.nItems = buf_getsize(me.listStats); + if(me.nItems > 0) + buf_sort(me.listStats, 128, FALSE); +} + +void XonoticStatsList_destroy(entity me) +{ + if(me.nItems > 0) + buf_del(me.listStats); +} + +void XonoticStatsList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize) +{ + me.itemAbsSize = '0 0 0'; + SUPER(XonoticStatsList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize); + + me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize_y * me.itemHeight)); + me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize_x * (1 - me.controlWidth))); + me.realUpperMargin = 0.5 * (1 - me.realFontSize_y); + + me.columnNameOrigin = me.realFontSize_x; + me.columnNameSize = 1 - 2 * me.realFontSize_x; +} + +void XonoticStatsList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +{ + string s; + if(isSelected) + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED); + + s = bufstr_get(me.listStats, i); + s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize); + draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 1); +} + +void XonoticStatsList_showNotify(entity me) +{ + me.getStats(me); +} + +void XonoticStatsList_clickListBoxItem(entity me, float i, vector where) +{ + if(i == me.lastClickedDemo) + if(time < me.lastClickedTime + 0.3) + { + // DOUBLE CLICK! + me.setSelected(me, i); + //DemoConfirm_ListClick_Check_Gamestatus(me); + } + me.lastClickedDemo = i; + me.lastClickedTime = time; +} + +float XonoticStatsList_keyDown(entity me, float scan, float ascii, float shift) +{ + if(scan == K_ENTER || scan == K_KP_ENTER) + { + //DemoConfirm_ListClick_Check_Gamestatus(me); + return 1; + } + else + { + return SUPER(XonoticStatsList).keyDown(me, scan, ascii, shift); + } +} +#endif +