Tanoda
LoadLicenseButton.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.IO;
5using GILES;
6using GILES.Interface;
7using UnityEngine;
8
10{
12
13 public override string tooltip { get { return "Load License"; } }
14
18 public void OpenLoadPanel()
19 {
20 pb_FileDialog dlog = GameObject.Instantiate(dialogPrefab);
21 dlog.SetDirectory(System.IO.Directory.GetCurrentDirectory());
22 dlog.isFileBrowser = true;
23 dlog.filePattern = "*.bin";
24 dlog.AddOnSaveListener(OnOpen);
25
26 pb_ModalWindow.SetContent(dlog.gameObject);
27 pb_ModalWindow.SetTitle("Open License");
29 }
30
31 private void OnOpen(string path)
32 {
33 Open(path);
34 }
35
36 public void Open(string path)
37 {
38 string san = pb_FileUtility.SanitizePath(path);
39 if (path.StartsWith("\\\\"))
40 {
41 san = path;
42 }
43
44 if(!pb_FileUtility.IsValidPath(san, ".bin"))
45 {
46 PopupManager.instance.ShowPopup("Can't open license", "The selected file is in a not accessable location.");
47 Debug.LogWarning(san + " not found, or file is not a License file.");
48 return;
49 }
50
52
53 try
54 {
55 if (UserManager.instance.CheckLicense(File.ReadAllBytes(san)))
56 {
57 UserManager.instance.licenseWindow.SetActive(false);
58 File.Copy(san, Path.Combine(Application.persistentDataPath, "License.bin"));
59 UserManager.instance.AfterSuccessfulLicenseCheck();
60 }
61 else
62 {
63 // invalid license
64 PopupManager.instance.ShowPopup("Invalid License", "The selected license file is invalid, or it's not issued for this computer.");
65 //PopupManager.instance.InvokeOnOK(() => { });
66 }
67
68 }
69 catch (Exception e)
70 {
71 PopupManager.instance.ShowPopup("Can't open license", e.Message);
72 Console.WriteLine(e);
73 }
74 }
75}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19
string filePattern
If isFileBrowser is true, this string my be used to filter file results (see https://msdn....
void AddOnSaveListener(Callback< string > listener)
void SetDirectory(string directory)
static void SetTitle(string title)
static void SetContent(GameObject prefab)
void Open(string path)
pb_FileDialog dialogPrefab
override string tooltip