Work on making map piecharts function
again...
This commit is contained in:
@@ -16,13 +16,16 @@ void function pulsePrintt(string content) //Prints whatever we want printed with
|
||||
bool function pulseRequestData(string givenURL, table parameterTable, string tablepath) //Gets data from API (see ToneURL within mod.json) and puts it into one table for processing.
|
||||
{
|
||||
table<string, array<string> > requestTable
|
||||
pulsePrintt(tablepath)
|
||||
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (parameterTable, requestTable, tablepath)
|
||||
{
|
||||
table DecodedJSON = DecodeJSON(response.body)
|
||||
if ("map" in parameterTable)
|
||||
{
|
||||
string mapName = expect string(parameterTable["map"])
|
||||
pulseData["mp_" + mapName] <- DecodedJSON
|
||||
table withMapName = {}
|
||||
withMapName[mapName] <- DecodedJSON
|
||||
pulseData[tablepath] <- withMapName
|
||||
} else {
|
||||
pulseData[tablepath] <- DecodedJSON
|
||||
}
|
||||
@@ -43,7 +46,6 @@ int function pulseParse(...) //Returns data from our pulseData table.
|
||||
table parser = pulseData
|
||||
int result = 0
|
||||
for (int i; i < vargc; i++) {
|
||||
print (vargc)
|
||||
if (i < expect int(vargc) - 1) {
|
||||
if (expect string (vargv[i]) in parser) {
|
||||
parser = expect table(parser[expect string(vargv[i])])
|
||||
|
||||
@@ -10,6 +10,7 @@ struct {
|
||||
void function pulseInit()
|
||||
{
|
||||
pulsePrefixSet()
|
||||
file.allMaps = GetPrivateMatchMaps()
|
||||
pulsePrintt("Initialized.")
|
||||
}
|
||||
|
||||
@@ -21,7 +22,7 @@ void function pulseGetData()
|
||||
pulseRequestData(URL + URLpath[0], {["player"] = NSGetLocalPlayerUID()}, tablepath[0])
|
||||
pulseRequestData(URL + URLpath[1], {["player"] = "!" + NSGetLocalPlayerUID()}, tablepath[1])
|
||||
pulseRequestData(URL + URLpath[2], {["player"] = NSGetLocalPlayerUID()}, tablepath[2])
|
||||
foreach (string map in file.allMaps)
|
||||
foreach (map in file.allMaps)
|
||||
{
|
||||
pulseRequestData(URL + URLpath[3], {["player"] = NSGetLocalPlayerUID(), ["map"] = map.slice(3)}, tablepath[3])
|
||||
}
|
||||
|
||||
@@ -153,16 +153,16 @@ void function UpdateStatsForMap( string mapName )
|
||||
//SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat3" ), Localize( "#STATS_GAMES_PLAYED" ), gamesPlayed )
|
||||
|
||||
SetStatsLabelValue( file.menu, "KillsLabel0", "KILLS ON MAP" )
|
||||
SetStatsLabelValue( file.menu, "KillsValue0", pulseParse("maps", mapName, "kills") )
|
||||
SetStatsLabelValue( file.menu, "KillsValue0", pulseParse("maps", mapName.slice(3), "kills") )
|
||||
|
||||
SetStatsLabelValue( file.menu, "KillsLabel1", "DEATHS ON MAP" )
|
||||
SetStatsLabelValue( file.menu, "KillsValue1", pulseParse("maps", mapName, "deaths") )
|
||||
SetStatsLabelValue( file.menu, "KillsValue1", pulseParse("maps", mapName.slice(3), "deaths") )
|
||||
|
||||
SetStatsLabelValue( file.menu, "KillsLabel2", "TOTAL SHOT DISTANCE" )
|
||||
SetStatsLabelValue( file.menu, "KillsValue2", string(int((1.905 * float(pulseParse("maps", mapName, "total_distance") ) ) )/100) + "m" )
|
||||
SetStatsLabelValue( file.menu, "KillsValue2", string(int((1.905 * float(pulseParse("maps", mapName.slice(3), "total_distance") ) ) )/100) + "m" )
|
||||
|
||||
SetStatsLabelValue( file.menu, "KillsLabel3", "MAXIMUM SHOT DISTANCE" )
|
||||
SetStatsLabelValue( file.menu, "KillsValue3", string(int((1.905 * float(pulseParse("maps", mapName, "max_distance") ) ) )/100) + "m" )
|
||||
SetStatsLabelValue( file.menu, "KillsValue3", string(int((1.905 * float(pulseParse("maps", mapName.slice(3), "max_distance") ) ) )/100) + "m" )
|
||||
|
||||
SetStatsLabelValue( file.menu, "KillsLabel4", "--" )
|
||||
SetStatsLabelValue( file.menu, "KillsValue4", "--" )
|
||||
@@ -191,21 +191,23 @@ void function UpdateStatsForMap( string mapName )
|
||||
for ( int modeId = 0; modeId < enumCount; modeId++ )
|
||||
{
|
||||
string modeName = PersistenceGetEnumItemNameForIndex( "gameModes", modeId )
|
||||
if (mapName in pulseData["gamemodesSeparated"])
|
||||
if (mapName.slice(3) in pulseData["gamemodesSeparated"])
|
||||
{
|
||||
float modePlayedTime = 0
|
||||
modePlayedTime = float(pulseParse("gamemodesSeparated", mapName, modeName, "kills"))
|
||||
modePlayedTime = float(pulseParse("gamemodesSeparated", mapName.slice(3), modeName, "kills"))
|
||||
if ( modePlayedTime > 0 ) {
|
||||
AddPieChartEntry( modes, GameMode_GetName( modeName ), modePlayedTime, GetGameModeDisplayColor( modeName ) )
|
||||
}
|
||||
} else {
|
||||
pulsePrintt("No " + mapName.slice(3) + " in pulseData")
|
||||
}
|
||||
}
|
||||
foreach (string key, array<int> value in customGamemodeList)
|
||||
{
|
||||
if (mapName in pulseData["gamemodesSeparated"])
|
||||
if (mapName.slice(3) in pulseData["gamemodesSeparated"])
|
||||
{
|
||||
float modePlayedTime = 0
|
||||
modePlayedTime = float(pulseParse("gamemodesSeparated", mapName, key, "kills"))
|
||||
modePlayedTime = float(pulseParse("gamemodesSeparated", mapName.slice(3), key, "kills"))
|
||||
if ( modePlayedTime > 0 ) {
|
||||
AddPieChartEntry( modes, customGamemodeNames[key], modePlayedTime, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user