aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/ui/atlas_auth.nut
blob: 9666860254435ff43031d2077e01bd387392bf88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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://docs.northstar.tf/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 )
}