Skip to content

Commit

Permalink
leadboard update
Browse files Browse the repository at this point in the history
* new: now displays top10 instead of top5
* fixed: rounding
  • Loading branch information
McDiod committed Sep 10, 2016
1 parent 2a2396e commit 348f3c3
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 17 deletions.
43 changes: 34 additions & 9 deletions leaderboard/defines.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,36 @@
#define lb_4_2 4402
#define lb_4_3 4403
#define lb_4_4 4404
#define mystats_0 4500
#define mystats_1 4501
#define mystats_2 4502
#define mystats_3 4503
#define mystats_4 4504
#define lb_5_0 4500
#define lb_5_1 4501
#define lb_5_2 4502
#define lb_5_3 4503
#define lb_5_4 4504
#define lb_6_0 4600
#define lb_6_1 4601
#define lb_6_2 4602
#define lb_6_3 4603
#define lb_6_4 4604
#define lb_7_0 4700
#define lb_7_1 4701
#define lb_7_2 4702
#define lb_7_3 4703
#define lb_7_4 4704
#define lb_8_0 4800
#define lb_8_1 4801
#define lb_8_2 4802
#define lb_8_3 4803
#define lb_8_4 4804
#define lb_9_0 4900
#define lb_9_1 4901
#define lb_9_2 4902
#define lb_9_3 4903
#define lb_9_4 4904
#define mystats_0 4990
#define mystats_1 4991
#define mystats_2 4992
#define mystats_3 4993
#define mystats_4 4994

//COORDS AND DIMS ==============================================================
#define lb_cellW (0.075 * X_SCALE)
Expand All @@ -51,19 +76,19 @@
#define lb_cellPaddingX (0.01 * X_SCALE)
#define lb_cellPaddingY (0.01 * Y_SCALE)

#define lb_numberOfRows (5)
#define lb_numberOfColumns (5)
#define lb_numberOfRows 10
#define lb_numberOfColumns 5

#define lb_titleH (0.025 * Y_SCALE)
#define lb_mainW ((lb_numberOfColumns * lb_cellW) + ((lb_numberOfColumns+1) * lb_cellPaddingX))
#define lb_mainH (lb_cellPaddingY + lb_titleH + lb_cellPaddingY + ((lb_cellH + lb_cellPaddingY) * lb_numberOfRows))
#define lb_mystatsH (lb_cellPaddingY + lb_titleH + lb_cellPaddingY + lb_cellH + lb_cellPaddingY)

#define lb_mainX CENTER(1, lb_mainW)
#define lb_titleY CENTER(1, lb_titleH + lb_mainH + lb_titleH + lb_mystatsH)
#define lb_titleY CENTER(Y_SCALE, lb_titleH + lb_mainH + lb_titleH + lb_mystatsH)
#define lb_mainY (lb_titleY + lb_titleH + lb_elementPaddingY)

#define lb_mystatsTitleY (lb_mainY + lb_mainH + 2*lb_elementPaddingY)
#define lb_mystatsY (lb_mystatsTitleY + lb_titleH + lb_elementPaddingY)

#define lb_DURATION 15
#define lb_DURATION 25
178 changes: 178 additions & 0 deletions leaderboard/dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,185 @@ class leaderboard
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (4 * (lb_cellH + lb_cellPaddingY));
};

class Cell50: Cell
{
idc = lb_5_0;
x = lb_mainX + lb_cellPaddingX + (0 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (5 * (lb_cellH + lb_cellPaddingY));
style = ST_LEFT;
};

class Cell51: Cell
{
idc = lb_5_1;
x = lb_mainX + lb_cellPaddingX + (1 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (5 * (lb_cellH + lb_cellPaddingY));
};

class Cell52: Cell
{
idc = lb_5_2;
x = lb_mainX + lb_cellPaddingX + (2 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (5 * (lb_cellH + lb_cellPaddingY));
};

class Cell53: Cell
{
idc = lb_5_3;
x = lb_mainX + lb_cellPaddingX + (3 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (5 * (lb_cellH + lb_cellPaddingY));
};

class Cell54: Cell
{
idc = lb_5_4;
x = lb_mainX + lb_cellPaddingX + (4 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (5 * (lb_cellH + lb_cellPaddingY));
};

class Cell60: Cell
{
idc = lb_6_0;
x = lb_mainX + lb_cellPaddingX + (0 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (6 * (lb_cellH + lb_cellPaddingY));
style = ST_LEFT;
};

class Cell61: Cell
{
idc = lb_6_1;
x = lb_mainX + lb_cellPaddingX + (1 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (6 * (lb_cellH + lb_cellPaddingY));
};

class Cell62: Cell
{
idc = lb_6_2;
x = lb_mainX + lb_cellPaddingX + (2 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (6 * (lb_cellH + lb_cellPaddingY));
};

class Cell63: Cell
{
idc = lb_6_3;
x = lb_mainX + lb_cellPaddingX + (3 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (6 * (lb_cellH + lb_cellPaddingY));
};

class Cell64: Cell
{
idc = lb_6_4;
x = lb_mainX + lb_cellPaddingX + (4 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (6 * (lb_cellH + lb_cellPaddingY));
};

class Cell70: Cell
{
idc = lb_7_0;
x = lb_mainX + lb_cellPaddingX + (0 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (7 * (lb_cellH + lb_cellPaddingY));
style = ST_LEFT;
};

class Cell71: Cell
{
idc = lb_7_1;
x = lb_mainX + lb_cellPaddingX + (1 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (7 * (lb_cellH + lb_cellPaddingY));
};

class Cell72: Cell
{
idc = lb_7_2;
x = lb_mainX + lb_cellPaddingX + (2 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (7 * (lb_cellH + lb_cellPaddingY));
};

class Cell73: Cell
{
idc = lb_7_3;
x = lb_mainX + lb_cellPaddingX + (3 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (7 * (lb_cellH + lb_cellPaddingY));
};

class Cell74: Cell
{
idc = lb_7_4;
x = lb_mainX + lb_cellPaddingX + (4 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (7 * (lb_cellH + lb_cellPaddingY));
};

class Cell80: Cell
{
idc = lb_8_0;
x = lb_mainX + lb_cellPaddingX + (0 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (8 * (lb_cellH + lb_cellPaddingY));
style = ST_LEFT;
};

class Cell81: Cell
{
idc = lb_8_1;
x = lb_mainX + lb_cellPaddingX + (1 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (8 * (lb_cellH + lb_cellPaddingY));
};

class Cell82: Cell
{
idc = lb_8_2;
x = lb_mainX + lb_cellPaddingX + (2 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (8 * (lb_cellH + lb_cellPaddingY));
};

class Cell83: Cell
{
idc = lb_8_3;
x = lb_mainX + lb_cellPaddingX + (3 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (8 * (lb_cellH + lb_cellPaddingY));
};

class Cell84: Cell
{
idc = lb_8_4;
x = lb_mainX + lb_cellPaddingX + (4 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (8 * (lb_cellH + lb_cellPaddingY));
};

class Cell90: Cell
{
idc = lb_9_0;
x = lb_mainX + lb_cellPaddingX + (0 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (9 * (lb_cellH + lb_cellPaddingY));
style = ST_LEFT;
};

class Cell91: Cell
{
idc = lb_9_1;
x = lb_mainX + lb_cellPaddingX + (1 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (9 * (lb_cellH + lb_cellPaddingY));
};

class Cell92: Cell
{
idc = lb_9_2;
x = lb_mainX + lb_cellPaddingX + (2 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (9 * (lb_cellH + lb_cellPaddingY));
};

class Cell93: Cell
{
idc = lb_9_3;
x = lb_mainX + lb_cellPaddingX + (3 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (9 * (lb_cellH + lb_cellPaddingY));
};

class Cell94: Cell
{
idc = lb_9_4;
x = lb_mainX + lb_cellPaddingX + (4 * (lb_cellW + lb_cellPaddingX));
y = lb_mainY + lb_cellPaddingY + lb_titleH + lb_cellPaddingY + (9 * (lb_cellH + lb_cellPaddingY));
};

class MyStatsTitle0: TitleCell
{
Expand Down
14 changes: 7 additions & 7 deletions leaderboard/fn_showLeaderboard.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ _fillRow = {
(_display displayCtrl (_startID+3)) ctrlSetText (str _games);

_playerUnit = [_playerArray select 1] call BIS_fnc_getUnitByUID;
_playerPointsGained = _playerUnit getVariable ["eloThisGame", 0];
_playerPointsGained = round (_playerUnit getVariable ["eloThisGame", 0]);
_points = round (_playerArray select 0);
_sign = if (_playerPointsGained < 0) then {""} else {"+"};
_pointsText = format ["%1 (%2%3)", _points, _sign, _playerPointsGained];
(_display displayCtrl (_startID+4)) ctrlSetText _pointsText;
};

//fill first 4 rows
for [{_i=0}, {_i< ((count _gogStats) min 4)}, {_i=_i+1}] do {
//fill all but last rows
for [{_i=0}, {_i< ((count _gogStats) min (lb_numberOfRows-1))}, {_i=_i+1}] do {
[_display, lb_0_0 + (_i*100), _gogStats select _i, _i+1] call _fillRow;
};

//fill row 5
if (count _gogStats > 4) then {
//fill last row
if (count _gogStats > (lb_numberOfRows-1)) then {
_playerID = [_gogStats, getPlayerUID player, 1] call mcd_fnc_findStringInArray;
_rowFiveID = if (_playerID < 4) then {4} else {_playerID};
[_display, lb_4_0, _gogStats select _rowFiveID, _rowFiveID + 1] call _fillRow;
_rowFiveID = if (_playerID < (lb_numberOfRows-1)) then {(lb_numberOfRows-1)} else {_playerID};
[_display, lb_9_0, _gogStats select _rowFiveID, _rowFiveID + 1] call _fillRow;
};
2 changes: 1 addition & 1 deletion server/endGame.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ sleep ((10 - (serverTime - _startTime)) max 0);
//show leaderboard on clients
[GOGSTATS] remoteExec ["mcd_fnc_showLeaderboard", 0, false];

sleep 17;
sleep 27;
[_winner] remoteExec ["mcd_fnc_endMission",0,false];

0 comments on commit 348f3c3

Please sign in to comment.