diff options
5 files changed, 81 insertions, 0 deletions
diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index 6f46095f..13a7edd3 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -729,6 +729,12 @@ "helpText":"", "returnTypeString":"void", "argTypes":"struct presence" + }, + { + "name":"NSGetMasterServerAuthResult", + "helpText":"", + "returnTypeString":"MasterServerAuthResult", + "argTypes":"" } ] }
\ No newline at end of file diff --git a/Northstar.Client/mod.json b/Northstar.Client/mod.json index 7d695a4b..f7c7c9b5 100644 --- a/Northstar.Client/mod.json +++ b/Northstar.Client/mod.json @@ -128,6 +128,13 @@ { "Path": "ui/ui_mouse_capture.nut", "RunOn": "UI" + }, + { + "Path": "ui/atlas_auth.nut", + "RunOn": "UI", + "UICallback": { + "After": "AtlasAuthDialog" + } } ], "Localisation": [ diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt index 8c7bab3a..49e9ee43 100644 --- a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt +++ b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt @@ -322,6 +322,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!" + "AUTHENTICATION_FAILED_ERROR_CODE" "Error code: ^DB6F2C00%s1^" + "AUTHENTICATION_FAILED_HELP" "Help" // Mod Settings "MOD_SETTINGS" "Mod Settings" diff --git a/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut b/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut index 2a2ed3db..a844478a 100644 --- a/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut +++ b/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut @@ -41,3 +41,10 @@ global struct ServerInfo string region array< RequiredModInfo > requiredMods } + +global struct MasterServerAuthResult +{ + bool success + string errorCode + string errorMessage +} diff --git a/Northstar.Client/mod/scripts/vscripts/ui/atlas_auth.nut b/Northstar.Client/mod/scripts/vscripts/ui/atlas_auth.nut new file mode 100644 index 00000000..89b7f719 --- /dev/null +++ b/Northstar.Client/mod/scripts/vscripts/ui/atlas_auth.nut @@ -0,0 +1,56 @@ +global function AtlasAuthDialog + +void function AtlasAuthDialog() +{ + thread AtlasAuthDialog_Threaded() +} + +void function AtlasAuthDialog_Threaded() +{ + // wait at least 1 frame so that the main menu can be loaded first + WaitFrame() + + 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" ) + + // if we got a special error message from Atlas, display it + if ( res.errorMessage != "" ) + dialogData.message = res.errorMessage + else + dialogData.message = Localize( "#AUTHENTICATION_FAILED_BODY" ) + + if ( res.errorCode != "" ) + dialogData.message += format( "\n\n%s", Localize( "#AUTHENTICATION_FAILED_ERROR_CODE", res.errorCode ) ) + + string link = "https://r2northstar.gitbook.io/r2northstar-wiki/installing-northstar/troubleshooting" + // link to generic troubleshooting page if we don't have an error code from Atlas + if ( res.errorCode != "" ) + link = format( "%s#%s", link, res.errorCode ) + + CloseAllDialogs() + AddDialogButton( dialogData, "#OK" ) + AddDialogButton( dialogData, Localize( "#AUTHENTICATION_FAILED_HELP" ), void function() : ( dialogData, link ) + { + // todo: get MS to redirect, so i can use an MS link or something? + LaunchExternalWebBrowser( link, WEBBROWSER_FLAG_FORCEEXTERNAL ) + // keep the dialog open + OpenDialog( dialogData ) + } ) + + OpenDialog( dialogData ) +} |