Skip to content

Commit

Permalink
Plugins v3 (#652)
Browse files Browse the repository at this point in the history
Script component of plugins v3. See launcher PR for more info.
R2Northstar/NorthstarLauncher#472
  • Loading branch information
catornot authored Nov 6, 2023
1 parent 318561f commit c0e8a90
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 32 deletions.
14 changes: 1 addition & 13 deletions .github/nativefuncs.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,7 @@
"helpText":"Returns whether or not a given path leads to a folder.",
"returnTypeString":"bool",
"argTypes":"string path"
},
{
"name":"NSPushGameStateData",
"helpText":"",
"returnTypeString":"void",
"argTypes":"struct gamestate"
}
}
],
"UI":[
{
Expand Down Expand Up @@ -724,12 +718,6 @@
"returnTypeString":"bool",
"argTypes":"string path"
},
{
"name":"NSPushUIPresence",
"helpText":"",
"returnTypeString":"void",
"argTypes":"struct presence"
},
{
"name":"NSGetMasterServerAuthResult",
"helpText":"",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
global enum eDiscordGameState
{
LOADING = 0
MAINMENU
LOBBY
INGAME
}

global struct GameStateStruct {

string map
Expand All @@ -15,10 +23,7 @@ global struct GameStateStruct {
}

global struct UIPresenceStruct {
bool isLoading
bool isLobby
string loadingLevel
string loadedLevel
int gameState
}

global struct RequiredModInfo
Expand Down
11 changes: 4 additions & 7 deletions Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
untyped
globalize_all_functions

void function NorthstarCodeCallback_GenerateGameState() {

GameStateStruct gs

GameStateStruct function DiscordRPC_GenerateGameState( GameStateStruct gs )
{
int highestScore = 0
int secondHighest = 0

Expand Down Expand Up @@ -40,6 +38,5 @@ void function NorthstarCodeCallback_GenerateGameState() {
gs.timeEnd = expect float(level.nv.roundEndTime - Time())
else
gs.timeEnd = expect float(level.nv.gameEndTime - Time())

NSPushGameStateData(gs)
}
return gs
}
20 changes: 12 additions & 8 deletions Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
untyped
globalize_all_functions

void function NorthstarCodeCallback_GenerateUIPresence() {
UIPresenceStruct uis
UIPresenceStruct function DiscordRPC_GenerateUIPresence( UIPresenceStruct uis )
{
if ( uiGlobal.isLoading )
uis.gameState = eDiscordGameState.LOADING;
else if ( uiGlobal.loadedLevel == "" )
uis.gameState = eDiscordGameState.MAINMENU;
else if ( IsLobby() || uiGlobal.loadedLevel == "mp_lobby" )
uis.gameState = eDiscordGameState.LOBBY;
else
uis.gameState = eDiscordGameState.INGAME;

uis.isLoading = uiGlobal.isLoading
uis.isLobby = IsLobby()
uis.loadingLevel = uiGlobal.loadingLevel
uis.loadedLevel = uiGlobal.loadedLevel
NSPushUIPresence(uis)
}
return uis
}

0 comments on commit c0e8a90

Please sign in to comment.