Bug fixes

This commit is contained in:
okvdai
2023-06-02 16:40:52 +02:00
parent 84ab278d92
commit da25a4dd29
4 changed files with 78 additions and 29 deletions
+12 -10
View File
@@ -15,17 +15,15 @@ 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> > params
foreach (parameter in paramTable)
{
params[parameter] <- [paramTable(parameter)]
}
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (params, tablepath)
table<string, array<string> > requestTable
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (parameterTable, requestTable, tablepath)
{
table DecodedJSON = DecodeJSON(response.body)
if (params["map"])
if ("map" in parameterTable)
{
table map[params["map"]] <- DecodedJSON
table map
map[expect string(parameterTable["map"])] <- DecodedJSON
pulsePrintt(tablepath)
pulseData[tablepath] <- map
} else {
pulseData[tablepath] <- DecodedJSON
@@ -35,7 +33,11 @@ bool function pulseRequestData(string givenURL, table parameterTable, string tab
{
pulsePrintt("Something went wrong while getting data.")
}
return NSHttpGet(givenURL, params, onSuccess, onFailure)
foreach (key, value in parameterTable)
{
requestTable[string(key)] <- [expect string(parameterTable[string(key)])]
}
return NSHttpGet(givenURL, requestTable, onSuccess, onFailure)
}
int function pulseParse(string parameter, string key, string value, string opt = "none")
@@ -54,7 +56,7 @@ int function pulseParse(string parameter, string key, string value, string opt =
{
return expect int(valTable[value])
} else {
actualValTable = expect table(valTable[value])
table actualValTable = expect table(valTable[value])
return expect int(actualValTable[opt])
}
}
+8 -7
View File
@@ -1,4 +1,5 @@
global function pulseInit
global function pulseGetData
global table pulseData = {}
@@ -15,14 +16,14 @@ void function pulseInit()
void function pulseGetData()
{
string URL = GetConVarString("ToneURL")
array URLpath = ["/weapons", "/weapons", "/gamemodes", "/gamemodes", "/maps"]
array tablepath = ["weaponsLocal", "weaponsGlobal", "gamemodesAll", "gamemodesSeparated", "maps"]
pulseRequestData(URL + URLpath[1], ["uid" = NSGetLocalPlayerUID()], tablepath[1])
pulseRequestData(URL + URLpath[2], ["uid" = "!" + NSGetLocalPlayerUID()], tablepath[2])
pulseRequestData(URL + URLpath[3], ["uid" = NSGetLocalPlayerUID()], tablepath[3])
array <string> URLpath = ["/weapons", "/weapons", "/gamemodes", "/gamemodes", "/maps"]
array <string> tablepath = ["weaponsLocal", "weaponsGlobal", "gamemodesAll", "gamemodesSeparated", "maps"]
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 (map in file.allMaps)
{
pulseRequestData(URL + URLpath[4], ["uid" = NSGetLocalPlayerUID(), "map" = map.slice(3)], tablepath[4])
pulseRequestData(URL + URLpath[3], {["player"] = NSGetLocalPlayerUID(), ["map"] = map.slice(3)}, tablepath[3])
}
pulseRequestData(URL + URLpath[5], ["uid" = NSGetLocalPlayerUID()], tablepath[5])
pulseRequestData(URL + URLpath[4], {["player"] = NSGetLocalPlayerUID()}, tablepath[4])
}
+57 -11
View File
@@ -124,6 +124,7 @@ void function MenuLobby_Init()
PrecacheHUDMaterial( $"ui/menu/main_menu/motd_background_happyhour" )
AddUICallback_OnLevelInit( OnLobbyLevelInit )
pulseGetData()
}
@@ -234,16 +235,46 @@ void function SetupComboButtonTest( var menu )
int headerIndex = 0
int buttonIndex = 0
file.playHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_PLAY" )
file.findGameButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_FIND_GAME" )
file.lobbyButtons.append( file.findGameButton )
Hud_AddEventHandler( file.findGameButton, UIE_CLICK, BigPlayButton1_Activate )
file.inviteRoomButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_INVITE_ROOM" )
Hud_AddEventHandler( file.inviteRoomButton, UIE_CLICK, DoRoomInviteIfAllowed )
bool isModded = IsNorthstarServer()
// this will be the server browser
if ( isModded )
{
file.findGameButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_SERVER_BROWSER" )
file.lobbyButtons.append( file.findGameButton )
Hud_SetLocked( file.findGameButton, true )
Hud_AddEventHandler( file.findGameButton, UIE_CLICK, OpenServerBrowser )
}
else
{
file.findGameButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_FIND_GAME" )
file.lobbyButtons.append( file.findGameButton )
Hud_AddEventHandler( file.findGameButton, UIE_CLICK, BigPlayButton1_Activate )
}
// this is used for launching private matches now
if ( isModded )
{
file.inviteRoomButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#PRIVATE_MATCH" )
Hud_AddEventHandler( file.inviteRoomButton, UIE_CLICK, StartPrivateMatch )
}
else
{
file.inviteRoomButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_INVITE_ROOM" )
Hud_AddEventHandler( file.inviteRoomButton, UIE_CLICK, DoRoomInviteIfAllowed )
}
file.inviteFriendsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_INVITE_FRIENDS" )
Hud_AddEventHandler( file.inviteFriendsButton, UIE_CLICK, InviteFriendsIfAllowed )
if ( isModded )
{
Hud_SetEnabled( file.inviteFriendsButton, false )
Hud_SetVisible( file.inviteFriendsButton, false )
}
// file.toggleMenuModeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_LOBBY_SWITCH_FD" )
// Hud_AddEventHandler( file.toggleMenuModeButton, UIE_CLICK, ToggleLobbyMode )
@@ -336,6 +367,16 @@ bool function MatchResultsExist()
return true // TODO
}
void function StartPrivateMatch( var button )
{
if ( Hud_IsLocked( button ) )
return
ClientCommand( "StartPrivateMatchSearch" )
NSSetLoading(true)
NSUpdateListenServer()
}
void function DoRoomInviteIfAllowed( var button )
{
if ( Hud_IsLocked( button ) )
@@ -1146,6 +1187,16 @@ void function SetUIPlayerCreditsInfo( var infoElement, int credits, int xp, int
RuiSetImage( rui, "callsignIcon", callsignIcon.image )
}
void function OpenServerBrowser( var button )
{
if ( Hud_IsLocked( button ) )
return
// nothing here yet lol
// look at OpenSelectedPlaylistMenu for advancing to server browser menu probably
AdvanceMenu( GetMenu( "ServerBrowserMenu" ) )
}
void function BigPlayButton1_Activate( var button )
{
if ( Hud_IsLocked( button ) )
@@ -1189,7 +1240,7 @@ function UpdateLobbyUI()
thread UpdateLobbyType()
thread UpdateMatchmakingStatus()
thread UpdateChatroomThread()
thread UpdateInviteJoinButton()
//thread UpdateInviteJoinButton()
thread UpdateInviteFriendsToNetworkButton()
thread UpdatePlayerInfo()
@@ -1578,8 +1629,3 @@ void function Lobby_SetFDModeBasedOnSearching( string playlistToSearch )
Lobby_SetFDMode( isFDMode )
}
void function pulseRefresh
{
pulseGetData()
}
+1 -1
View File
@@ -205,7 +205,7 @@ void function UpdateStatsForMap( string mapName )
if ( mapName in pulseData && key in pulseData[mapName])
{
float modePlayedTime = 0
modePlayedTime = float(pulseParse(mapName, "gamemodesSeparated", modeName, "kills"))
modePlayedTime = float(pulseParse(mapName, "gamemodesSeparated", key, "kills"))
if ( modePlayedTime > 0 ) {
AddPieChartEntry( modes, customGamemodeNames[key], modePlayedTime, value)
}