Exemplo n.º 1
0
    public void Refresh()
    {
        LanguageChanged(PlayerPrefs.GetString("settings.language", Application.systemLanguage.ToString()));

        var size = Content.Find("Size").GetComponentInChildren <Slider>();

        size.value = PlayerPrefs.GetInt("settings.size", 300 / Screen.dpi < 300 ? 3 : 4);
        if (!Content.gameObject.activeInHierarchy)
        {
            ChangeSize(size);
        }

        var logs = Content.Find("Logs").Find("List");

#if !UNITY_STANDALONE || !UNITY_EDITOR
        logs.Find("Open").gameObject.SetActive(false);
#endif
        var logsSize = UpdateManager.SizeUnit(new DirectoryInfo(Application.persistentDataPath + "/logs/").EnumerateFiles().Sum(file => file.Length));
        logs.Find("Delete").GetChild(0).GetComponent <Text>().text = LangueAPI.Get("settings.logs.delete", "Delete logs ([0])", logsSize);

        Content.Find("App Infos").GetComponent <Text>().text = LangueAPI.Get(
            "settings.infos", "[0] (v[1])\nBuild: [2] ([3])",
            Application.productName, Application.version,                                                                   //First line
            string.IsNullOrEmpty(Application.buildGUID) ? "<i>Editor</i>" : Application.buildGUID, Application.unityVersion //Second line
            );
    }
    void Start()
    {
        var options = GetComponent <Dropdown>().options;

        for (int i = 0; i < options.Capacity & i < id.Length; i++)
        {
            options[i].text = LangueAPI.Get(id[i], options[i].text);
        }
        GetComponent <Dropdown>().options = options;
    }
Exemplo n.º 3
0
    public static string SizeUnit(float size, string accuracy = "0")
    {
        var units = new[] { "B", "KB", "MB", "GB" };
        int i;

        for (i = 0; i < units.Length && size >= 1000; i++)
        {
            size /= 1000F;
        }
        return(LangueAPI.Get($"units.{units[i].ToLower()}", $"[0] {units[i]}", size.ToString(accuracy)));
    }
Exemplo n.º 4
0
        public void Refresh(IEnumerable <Integrations.Data.SessionContent> sessionContents)
        {
            var top = transform.Find("Top").Find("Week");

            top.GetComponentInChildren <Text>().text = LangueAPI.Get("homeworks.period", "from [0] to [1]", week.Start.ToString("dd/MM"), week.End.ToString("dd/MM"));
            top.Find("Next").GetComponent <Button>().interactable = week.End < DateTime.Now;
            var culture = LangueAPI.Culture;

            var sessionsContents = sessionContents.GroupBy(h => h.date);
            var content          = transform.Find("Content").GetComponent <ScrollRect>().content;

            for (int i = 1; i < content.childCount; i++)
            {
                Destroy(content.GetChild(i).gameObject);
            }
            foreach (var day in sessionsContents)
            {
                var dayPanel = Instantiate(content.GetChild(0).gameObject, content).transform;
                dayPanel.Find("Head").Find("Date").GetComponent <Text>().text = day.Key.ToString("D", culture);
                var panel = dayPanel.Find("Panel");

                foreach (var sessionContent in day)
                {
                    var go = Instantiate(panel.GetChild(0).gameObject, panel).transform;

                    // Set to subect color
                    Homeworks.SetColor(go.GetComponent <Image>(), sessionContent.subject?.color ?? new Color());
                    Homeworks.SetColor(go.Find("Tint").GetComponentInChildren <Image>(), sessionContent.subject?.color ?? new Color());
                    var goContent = go.Find("Content");

                    // Infos
                    var infos = goContent.Find("Infos");
                    infos.Find("Subject").GetComponent <Text>().text = sessionContent.subject?.name;
                    infos.Find("AddedBy").GetComponent <Text>().text = sessionContent.addedBy;
                    var docs = infos.Find("Docs");
                    foreach (var doc in sessionContent.documents)
                    {
                        var docGo = Instantiate(docs.GetChild(0).gameObject, docs).transform;
                        docGo.GetComponent <Text>().text = $"• {doc.name}";
                        docGo.GetComponent <Button>().onClick.AddListener(() => UnityThread.executeCoroutine(Manager.provider.GetModule <Integrations.Homeworks>().OpenHomeworkAttachment(doc)));
                        docGo.gameObject.SetActive(true);
                    }

                    // Content
                    goContent.Find("Content").GetComponent <TMPro.TMP_InputField>().text = sessionContent.content;

                    go.gameObject.SetActive(true);
                }

                dayPanel.gameObject.SetActive(true);
            }
        }
Exemplo n.º 5
0
    public static void UpdateLoadingStatus(string id, string fallback, bool log = true, params string[] args)
    {
        if (log)
        {
            Logging.Log(LangueAPI.Get(null, fallback, args));
        }
        instance.Loading.SetActive(true);
        var img = instance.Loading.transform.GetChild(0);

        img.GetComponent <UnityEngine.UI.RawImage>().color = Color.white;
        img.GetComponent <VideoRenderer>().Play();
        instance.Loading.transform.GetChild(1).GetComponent <UnityEngine.UI.Text>().text = LangueAPI.Get(id, fallback, args);
    }
Exemplo n.º 6
0
    public void LanguageChanged(string language)
    {
        foreach (Transform btn in Content.Find("Language").Find("List"))
        {
            btn.GetComponent <Button>().interactable = btn.name != language;
        }
        if (PlayerPrefs.GetString("settings.language") == language)
        {
            return;
        }

        PlayerPrefs.SetString("settings.language", language);
        LangueAPI.ReloadData();
        UnityEngine.SceneManagement.SceneManager.LoadScene(0);
    }
Exemplo n.º 7
0
        void SetupDeletePanel(FileInfo file, Data data)
        {
            var delete = transform.Find("Content").Find("Delete Confirm");

            delete.Find("Text").GetComponent <Text>().text = LangueAPI.Get("welcome.delete", "Are you sure you want to delete the \"<size=20><color=grey>[0]</color></size>\" account?", data.ID);
            var yesBtn = delete.Find("Buttons").Find("Yes").GetComponent <Button>();

            yesBtn.onClick.RemoveAllListeners();
            yesBtn.onClick.AddListener(() =>
            {
                UpdateCredentials(data.ID);
                file.Delete();
                Refresh();
            });
            OpenPanel(delete.gameObject);
        }
Exemplo n.º 8
0
        void Refresh(IEnumerable <Homework> homeworks, Homework.Period period)
        {
            var WeekSwitcher = transform.Find("Top").Find("Week");

            WeekSwitcher.Find("Text").GetComponent <Text>().text = period.name;
            WeekSwitcher.Find("Previous").GetComponent <Button>().interactable = periods.Count > periodIndex + 1 || LoadNext();
            WeekSwitcher.Find("Next").GetComponent <Button>().interactable     = periodIndex > 0;

            var Content = transform.Find("Content").GetComponent <ScrollRect>().content;

            for (int i = 1; i < Content.childCount; i++)
            {
                Destroy(Content.GetChild(i).gameObject);
            }

            transform.Find("Content").Find("Empty").gameObject.SetActive(!homeworks.Any());
            if (!homeworks.Any())
            {
                return;
            }

            var language = LangueAPI.Culture;

            foreach (var Homeworks in homeworks.GroupBy(h => h.forThe))
            {
                var datePanel = Instantiate(Content.GetChild(0).gameObject, Content).transform;
                datePanel.Find("Head").Find("Date").GetComponent <Text>().text = Homeworks.Key.ToString("D", language);

                var panel = datePanel.Find("Panel");
                for (int i = 1; i < panel.childCount; i++)
                {
                    Destroy(panel.GetChild(i).gameObject);
                }
                foreach (var homework in Homeworks)
                {
                    var go = Instantiate(panel.GetChild(0).gameObject, panel).transform;

                    // Set to subect color
                    SetColor(go.GetComponent <Image>(), homework.subject?.color ?? new Color());
                    SetColor(go.Find("Tint").GetComponentInChildren <Image>(), homework.subject?.color ?? new Color());
                    var goContent = go.Find("Content");

                    // Infos
                    var infos = goContent.Find("Infos");
                    infos.Find("Subject").GetComponent <Text>().text = homework.subject?.name;
                    infos.Find("Extra").GetComponent <Text>().text   = LangueAPI.Get("homeworks.added", "Added on [0] by [1]", homework.addedThe.ToString("dd/MM"), homework.addedBy);
                    var docs = infos.Find("Docs");
                    foreach (var doc in homework.documents)
                    {
                        var docGo = Instantiate(docs.GetChild(0).gameObject, docs).transform;
                        docGo.GetComponent <Text>().text = $"• {doc.name}";
                        docGo.GetComponent <Button>().onClick.AddListener(() => UnityThread.executeCoroutine(Manager.provider.GetModule <Integrations.Homeworks>().OpenHomeworkAttachment(doc)));
                        docGo.gameObject.SetActive(true);
                    }

                    // Content
                    goContent.Find("Content").GetComponent <TMPro.TMP_InputField>().text = homework.content;

                    // Indicator
                    var indicator = go.Find("Indicator");
                    SetIndicator();
                    if (!homework.exam)
                    {
                        indicator.GetComponent <Button>().onClick.AddListener(() =>
                        {
                            homework.done = !homework.done;
                            UnityThread.executeCoroutine(Manager.provider.GetModule <Integrations.Homeworks>().HomeworkDoneStatus(homework));
                            SetIndicator();
                        });
                    }
                    void SetIndicator() => indicator.GetComponentInChildren <Image>().color = homework.exam ? colorExam : (homework.done ? colorDone : colorToDo);

                    go.gameObject.SetActive(true);
                }
                panel.gameObject.SetActive(false);
                datePanel.gameObject.SetActive(true);
            }
        }
Exemplo n.º 9
0
 void Start()
 {
     GetComponent <Text>().text = LangueAPI.Get(id, GetComponent <Text>().text, arg);
 }
Exemplo n.º 10
0
        void Refresh(IEnumerable <ScheduledEvent> schedule, TimeRange period)
        {
            ProviderExtension.GenerateSubjectColors();
            var WeekSwitcher = transform.Find("Top").Find("Week");

            WeekSwitcher.Find("Text").GetComponent <Text>().text = Screen.width > Screen.height ? LangueAPI.Get("schedule.period", "from [0] to [1]", period.Start.ToString("dd/MM"), period.End.ToString("dd/MM")) : period.Start.ToString("dd/MM");

            transform.Find("Content").gameObject.SetActive(schedule?.Count() > 0);
            transform.Find("Empty").gameObject.SetActive(!(schedule?.Count() > 0));
            if (schedule == null || schedule.Count() == 0)
            {
                return;
            }

            for (int i = 1; i < content.childCount; i++)
            {
                Destroy(content.GetChild(i).gameObject);
            }
            min = schedule.Min(s => s.start.TimeOfDay);
            foreach (var Schedule in schedule.GroupBy(e => e.start.Date))
            {
                var datePanel = Instantiate(content.GetChild(0).gameObject, content).transform;
                datePanel.Find("Day").GetComponentInChildren <Text>().text = Schedule.Key.ToString("dddd", language);
                datePanel.name = Schedule.Key.ToString("yyyy-MM-dd");
                var dateContent = datePanel.Find("Content");
                var lastTime    = min;
                foreach (var Event in Schedule)
                {
                    if (lastTime < Event.start.TimeOfDay)
                    {
                        var hole = new GameObject();
                        hole.transform.SetParent(dateContent);
                        hole.AddComponent <RectTransform>().sizeDelta = new Vector2(1, sizePerHour * (float)(Event.start.TimeOfDay - lastTime).TotalHours);
                    }

                    var go      = Instantiate(dateContent.GetChild(0).gameObject, dateContent).transform;
                    var goColor = Event.subject?.color ?? Color.gray;
                    goColor.a = Event.canceled ? 0.4F : 1;
                    go.GetComponent <Image>().color = goColor;
                    var subject = Event.subject;
                    if (subject == null)
                    {
                        Debug.LogError(Event.room + " " + Event.start + "\n" + Event.subjectID);
                    }
                    go.Find("Subject").GetComponent <Text>().text = subject?.name ?? Event.subjectID;
                    go.Find("Room").GetComponent <Text>().text    = Event.canceled ? $"<color=#F56E6E>{LangueAPI.Get("schedule.canceled", "Canceled")}</color>" : Event.room;
                    go.Find("Teacher").GetComponent <Text>().text = Event.teacher ?? string.Join(" / ", subject.teachers);
                    go.Find("Hours").GetComponent <Text>().text   = $"{Event.start.ToString("HH:mm")} - {Event.end.ToString("HH:mm")}";
                    ((RectTransform)go).sizeDelta = new Vector2(1, sizePerHour * (float)(Event.end - Event.start).TotalHours);
                    go.gameObject.SetActive(true);
                    lastTime = Event.end.TimeOfDay;
                }
                datePanel.gameObject.SetActive(true);
            }
        }