Tanoda
OpenCurseButton.cs
Go to the documentation of this file.
1using GILES.Interface;
2using System;
3using System.Collections;
4using System.Collections.Generic;
5using UnityEngine;
6using UnityEngine.UI;
7
8public class OpenCurseButton : MonoBehaviour
9{
10 // Start is called before the first frame update
11 void Start()
12 {
13 Button button = GetComponent<Button>();
14 button.onClick.AddListener(delegate () { openCurse(); });
15 }
16
17 public void openCurse()
18 {
19
20 var currentUser = SavedUser.instance.currentUser.Value;
21 var selectedJson = GetComponentInChildren<Text>().text;
22 pb_FileDialog dlog = GetComponent<MenuLoadScene>().dialogPrefab;
23 var path = System.IO.Directory.GetCurrentDirectory() + "/" + selectedJson;
24 if (currentUser.Access == UserManager.UserType.User)
25 {
26 GetComponent<MenuLoadScene>().Open(path);
27 var trainings = SavedUser.instance.currentUser.Value.addedTrainings;
28
29 for (int i = 0; i < trainings.Count; i++)
30 {
31 var addedTraining = SavedUser.instance.currentUser.Value.addedTrainings[i];
32 if (trainings[i].TrainingName == selectedJson)
33 {
34 addedTraining.Status = "Folyamatban";
35 addedTraining.ModificationDate = DateTime.Now.Date;
36 SavedUser.instance.currentUser.Value.addedTrainings[i] = addedTraining;
37 UserManager.instance.UpdateUser(currentUser);
38 UserManager.instance.PopulateCurseList(currentUser);
39
40 }
41 }
42 }
43
44 else
45 {
46 UserStatManager.instance.ShowStats(currentUser, selectedJson);
47 }
48 }
49
50 // Update is called once per frame
51 void Update()
52 {
53
54 }
55}
UnityEngine.UI.Button Button
Definition: Pointer.cs:7