Initial #14
This commit is contained in:
@@ -8,6 +8,7 @@ global function getMapKillFromToneAPI
|
||||
global function getMapDeathFromToneAPI
|
||||
global function getMapDistFromToneAPI
|
||||
global function getMapMDistFromToneAPI
|
||||
global function getGamemodeStatsFromToneAPI
|
||||
|
||||
global table globalToneAPIKillData = {}
|
||||
global table globalToneAPIDeathData = {}
|
||||
@@ -16,11 +17,13 @@ global table globalToneAPIMapDeathData = {}
|
||||
global table globalToneAPIMapDistData = {}
|
||||
global table globalToneAPIMapKillData = {}
|
||||
global table globalToneAPIMapMDistData = {}
|
||||
global table globalToneAPIGamemodeData = {}
|
||||
|
||||
string prefix = "default"
|
||||
string HTTPrequestURL = "default"
|
||||
int weaponEntries = 0
|
||||
int mapEntries = 0
|
||||
int mapGamemodeEntries = 0
|
||||
|
||||
void function pulseInit()
|
||||
{
|
||||
@@ -90,6 +93,35 @@ void function GetMapStatsFromToneAPI()
|
||||
NSHttpRequest(getMapStats, onSuccess, onFailure)
|
||||
}
|
||||
|
||||
void function getGamemodeStatsFromToneAPI(string mapName)
|
||||
{
|
||||
print(prefix + "test")
|
||||
mapGamemodeEntries = 0
|
||||
string mapNameSliced = mapName.slice(3)
|
||||
HttpRequest getMapGamemodeStats
|
||||
getMapGamemodeStats.method = HttpRequestMethod.GET
|
||||
getMapGamemodeStats.url = HTTPrequestURL + "/gamemodes"
|
||||
getMapGamemodeStats.queryParameters["map"] <- [mapNameSliced]
|
||||
getMapGamemodeStats.queryParameters["player"] <- [NSGetLocalPlayerUID()]
|
||||
void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
|
||||
{
|
||||
table JSONForConversion = DecodeJSON(response.body)
|
||||
foreach (var key, var value in JSONForConversion) {
|
||||
table test = expect table(value)
|
||||
globalToneAPIGamemodeData[string(key)] <- test.kills
|
||||
mapGamemodeEntries += 1
|
||||
}
|
||||
print(prefix + "Map gamemode data has been processed with a total of " + string(mapGamemodeEntries) + " entries.")
|
||||
}
|
||||
|
||||
void functionref(HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
|
||||
{
|
||||
print(prefix + "Encountered an error getting map gamemode data...")
|
||||
}
|
||||
|
||||
NSHttpRequest(getMapGamemodeStats, onSuccess, onFailure)
|
||||
}
|
||||
|
||||
int function getWeaponKillsFromToneAPI(string weaponRef){
|
||||
|
||||
if(weaponRef in globalToneAPIKillData){
|
||||
@@ -148,4 +180,4 @@ int function getMapDistFromToneAPI(string mapName){
|
||||
return expect int(globalToneAPIMapDistData[mapName])
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
|
||||
global function InitViewStatsMenu
|
||||
|
||||
struct{
|
||||
array<string> allMaps
|
||||
} file
|
||||
|
||||
void function InitViewStatsMenu()
|
||||
{
|
||||
var menu = GetMenu( "ViewStatsMenu" )
|
||||
@@ -37,6 +41,10 @@ void function InitViewStatsMenu()
|
||||
|
||||
void function OnViewStats_Open()
|
||||
{
|
||||
foreach(elemNum in file.allMaps){
|
||||
string mapName = expect string(file.allMaps[ elemNum ])
|
||||
getGamemodeStatsFromToneAPI(mapName)
|
||||
}
|
||||
GetWeaponStatsFromToneAPI()
|
||||
GetMapStatsFromToneAPI()
|
||||
UI_SetPresentationType( ePresentationType.DEFAULT )
|
||||
|
||||
@@ -141,6 +141,8 @@ void function UpdateStatsForMap( string mapName )
|
||||
|
||||
Hud_SetText( Hud_GetChild( file.menu, "WeaponName" ), GetMapDisplayName( mapName ) )
|
||||
|
||||
getGamemodeStatsFromToneAPI(mapName)
|
||||
|
||||
// Image
|
||||
var imageElem = Hud_GetRui( Hud_GetChild( file.menu, "WeaponImageLarge" ) )
|
||||
RuiSetImage( imageElem, "basicImage", GetMapImageForMapName( mapName ) )
|
||||
@@ -178,13 +180,19 @@ void function UpdateStatsForMap( string mapName )
|
||||
array<string> gameModesArray = GetPersistenceEnumAsArray( "gameModes" )
|
||||
|
||||
array<PieChartEntry> modes
|
||||
foreach ( modeName in gameModesArray )
|
||||
int enumCount = PersistenceGetEnumCount( "gameModes" )
|
||||
for ( int modeId = 0; modeId < enumCount; modeId++ )
|
||||
{
|
||||
float modePlayedTime = GetGameStatForMapAndModeFloat( "hoursPlayed", mapName, modeName )
|
||||
if ( modePlayedTime > 0 )
|
||||
AddPieChartEntry( modes, GameMode_GetName( modeName ), modePlayedTime, GetGameModeDisplayColor( modeName ) )
|
||||
string modeName = PersistenceGetEnumItemNameForIndex( "gameModes", modeId )
|
||||
if ( modeName in globalToneAPIGamemodeData )
|
||||
{
|
||||
float modePlayedTime = float(globalToneAPIGamemodeData[modeName])
|
||||
print(modePlayedTime)
|
||||
if ( modePlayedTime > 0 ) {
|
||||
AddPieChartEntry( modes, GameMode_GetName( modeName ), modePlayedTime, GetGameModeDisplayColor( modeName ) )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const MAX_MODE_ROWS = 8
|
||||
|
||||
if ( modes.len() > 0 )
|
||||
|
||||
Reference in New Issue
Block a user