Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display origin auth failure in a dialog #648

Merged
merged 13 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/nativefuncs.json
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,12 @@
"helpText":"",
"returnTypeString":"void",
"argTypes":"struct presence"
},
{
"name":"NSGetMasterServerAuthResult",
"helpText":"",
"returnTypeString":"MasterServerAuthResult",
"argTypes":""
}
]
}
7 changes: 7 additions & 0 deletions Northstar.Client/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@
{
"Path": "ui/ui_mouse_capture.nut",
"RunOn": "UI"
},
{
"Path": "ui/atlas_auth.nut",
"RunOn": "UI",
"UICallback": {
"After": "AtlasAuthDialog"
}
}
],
"Localisation": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ Press Yes if you agree to this. This choice can be changed in the mods menu at a
"INVALID_MASTERSERVER_TOKEN" "Invalid or expired masterserver token"
"JSON_PARSE_ERROR" "Error parsing json response"
"UNSUPPORTED_VERSION" "The version you are using is no longer supported"

"AUTHENTICATION_FAILED_HEADER" "Authentication Failed"
"AUTHENTICATION_FAILED_BODY" "Failed to authenticate with Atlas!"
ASpoonPlaysGames marked this conversation as resolved.
Show resolved Hide resolved
"AUTHENTICATION_FAILED_ERROR_CODE" "Error code: %s1"
"AUTHENTICATION_FAILED_HELP" "Help"

// Mod Settings
"MOD_SETTINGS" "Mod Settings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ global struct ServerInfo
string region
array< RequiredModInfo > requiredMods
}

global struct MasterServerAuthResult
{
bool success
string errorCode
string errorMessage
}
47 changes: 47 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/ui/atlas_auth.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
global function AtlasAuthDialog

void function AtlasAuthDialog()
{
thread AtlasAuthDialog_Threaded()
}

void function AtlasAuthDialog_Threaded()
{
while ( !NSIsMasterServerAuthenticated() || GetConVarBool( "ns_auth_allow_insecure" ) )
WaitFrame()

if ( GetConVarBool( "ns_auth_allow_insecure" ) )
return

MasterServerAuthResult res = NSGetMasterServerAuthResult()

// do nothing on successful authentication
if ( res.success )
return

EmitUISound( "blackmarket_purchase_fail" )

DialogData dialogData
dialogData.image = $"ui/menu/common/dialog_error"
dialogData.header = Localize( "#AUTHENTICATION_FAILED_HEADER" )
dialogData.message = Localize( "#AUTHENTICATION_FAILED_BODY" )

// if we got a special error message from Atlas, display it
if ( res.errorMessage != "" )
dialogData.message += "\n" + res.errorMessage

if ( res.errorCode != "" )
dialogData.message += "\n\n" + Localize( "#AUTHENTICATION_FAILED_ERROR_CODE", res.errorCode )


CloseAllDialogs()
AddDialogButton( dialogData, "#OK", null )
AddDialogButton( dialogData, Localize( "#AUTHENTICATION_FAILED_HELP" ), void function() {
// todo: get MS to redirect, so i can use an MS link or something?
ASpoonPlaysGames marked this conversation as resolved.
Show resolved Hide resolved
// also todo: link using # to the error code given, needs work on wiki side of things
string link = "https://r2northstar.gitbook.io/r2northstar-wiki/installing-northstar/troubleshooting"
LaunchExternalWebBrowser( link, WEBBROWSER_FLAG_FORCEEXTERNAL )
} )

OpenDialog( dialogData )
}