Example #1
0
 public override void Run()
 {
     this.ReloadConfig();
     StartCoroutine(Fade(RunRoutine, 1f));
     scrollbarBackground.color = Colours.Darken(GetWidgetColour());
     scrollbarHandle.color     = Colours.Lighten(GetWidgetColour());
     this.UpdateLastUpdatedText();
 }
        public override void ReloadConfig()
        {
            JSONNode config = this.GetConfig();

            journeys                  = config["journeys"];
            mediumTrafficMinutes      = config["mediumTrafficMinutes"] == null ? 15 : config["mediumTrafficMinutes"].AsInt;
            heavyTrafficMinutes       = config["heavyTrafficMinutes"] == null ? 25 : config["heavyTrafficMinutes"].AsInt;
            scrollbarBackground.color = Colours.Darken(GetWidgetColour());
            scrollbarHandle.color     = Colours.Lighten(GetWidgetColour());
        }
Example #3
0
        public override void ApplyAdditionalColours(Color mainColour, Color textColour)
        {
            addIngredientButton.GetComponent <Image>().color = mainColour;
            addIngredientButton.GetComponentInChildren <TMP_Text>().color = textColour;

            addRecipeButton.GetComponent <Image>().color = mainColour;
            addRecipeButton.GetComponentInChildren <TMP_Text>().color = textColour;

            scrollBackground.color = Colours.Darken(mainColour);
            scrollHandle.color     = Colours.Lighten(mainColour);
        }
Example #4
0
        public override void Start()
        {
            base.Start();

            JSONNode config = this.GetConfig();

            addButton.GetComponent <Image>().color = Colours.Darken(GetWidgetColour());

            foreach (PlannerEntry planner in FindObjectsOfType <PlannerEntry>())
            {
                planner.SetDayTextColour(GetTextColour());
                planner.SetRecipeTextColour(Colours.ToColour(config["plannerTextColour"]));
                planner.SetRecipeBackgroundColour(Colours.ToColour(config["plannerBackgroundColour"]));
                planner.SetDayBackgroundColour(Colours.Lighten(GetWidgetColour()));
            }
        }
Example #5
0
        public override void Run()
        {
            this.ReloadConfig();

            DateTime today    = DateTime.Today;
            DateTime tomorrow = today.AddDays(1);

            bool stopProcessing = false;

            foreach (JSONNode bin in bins)
            {
                // If the first bin in the config is active, and we carry on processing,
                // then the next time around the widget will show 'no bins today'
                if (stopProcessing)
                {
                    break;
                }

                DateTime firstBinDay      = DateTime.ParseExact(bin["firstDate"], "dd-MM-yyyy", null);
                int      repeatRateInDays = bin["repeatRateInDays"];
                string   binName          = bin["name"];

                DateTime lastBinDay = GetLastBinDate(firstBinDay, repeatRateInDays);
                DateTime nextBinDay = GetNextBinDate(lastBinDay, repeatRateInDays);

                Color binColour = Colours.ToColour(bin["binColour"]);

                if (IsBin(today, nextBinDay, lastBinDay))
                {
                    Display(binName + " bin today!", FontStyles.Bold, binColour, Colours.Lighten(binColour));
                    stopProcessing = true;
                }
                else if (IsBin(tomorrow, nextBinDay, lastBinDay))
                {
                    Display(binName + " bin tomorrow!", FontStyles.Normal, binColour, Colours.Lighten(binColour));
                    stopProcessing = true;
                }
                else
                {
                    Display("No bins today!", FontStyles.Bold, noBinColour, Colours.Darken(noBinColour));
                }
            }

            this.UpdateLastUpdatedText();
        }
        private IEnumerator RunRoutine()
        {
            UnityWebRequest request = Postman.CreateGetRequest(Endpoints.instance.GOOGLE_CALENDAR(gmailAddress, numberOfEvents, apiKey));

            yield return(request.SendWebRequest());

            json = JSON.Parse(request.downloadHandler.text);

            bool ok = request.error == null ? true : false;

            if (!ok)
            {
                WidgetLogger.instance.Log(this, "Error: " + request.error);
                yield break;
            }

            // Remove old events
            foreach (Transform child in scrollParent)
            {
                Destroy(child.gameObject);
            }

            for (int i = 0; i < json["events"].Count; i++)
            {
                JSONNode item      = json["events"][i];
                DateTime startDate = DateTime.Parse(item["start"]);
                DateTime endDate   = DateTime.Parse(item["end"]);

                GoogleCalendarEvent eventEntry = Instantiate(googleCalendarEventPrefab, scrollParent).GetComponent <GoogleCalendarEvent>();
                eventEntry.SetDescription(item["description"]);
                eventEntry.SetEndDateText(endDate.ToString("dd MMM"));
                eventEntry.SetEndTime(item["endTime"]);
                eventEntry.SetGoogleCalendar(this);
                eventEntry.SetLocation(item["location"]);
                eventEntry.SetStartDateText(startDate.ToString("dd MMM"));
                eventEntry.SetStartDateTextColour(GetTextColour());
                eventEntry.SetStartTime(item["startTime"]);
                eventEntry.SetSummaryText(item["summary"]);
                eventEntry.SetSummaryTextColour(GetTextColour());
            }

            scrollbarBackground.color = Colours.Darken(GetWidgetColour());
            scrollbarHandle.color     = Colours.Lighten(GetWidgetColour(), 0.1f);
        }
        private IEnumerator RunRoutine()
        {
            UnityWebRequest request = Postman.CreateGetRequest(Endpoints.instance.TODOIST_PROJECT(projectId));

            request.SetRequestHeader("Authorization", "Bearer " + apiKey);
            yield return(request.SendWebRequest());

            bool ok = request.error == null ? true : false;

            if (!ok)
            {
                WidgetLogger.instance.Log(this, "Error: " + request.error + "\n URL: " + Endpoints.instance.TODOIST_PROJECT(projectId));
                yield break;
            }

            // Remove previous entries so there are no duplicates
            foreach (Transform g in content)
            {
                Destroy(g.gameObject);
            }

            JSONNode json = JSON.Parse(request.downloadHandler.text);

            foreach (JSONNode task in json)
            {
                OnlineListEntry e = Instantiate(entryPrefab, content).GetComponent <OnlineListEntry>();
                e.SetApiKey(apiKey);
                e.SetNameText(Utility.CapitaliseFirstLetter(task["content"].Value));
                e.SetNameTextColour(GetTextColour());
                e.SetRemoveButtonTextColour(GetTextColour());
                e.SetTaskId(task["id"].Value);
            }

            addButtonColour.color     = Colours.Darken(GetWidgetColour());
            addButtonText.color       = GetTextColour();
            scrollbarBackground.color = Colours.Darken(GetWidgetColour());
            scrollbarHandle.color     = Colours.Lighten(GetWidgetColour());
        }
Example #8
0
 public override void ApplyAdditionalColours(Color mainColour, Color textColour)
 {
     scrollBackground.color = Colours.Darken(mainColour);
     scrollHandle.color     = Colours.Lighten(mainColour);
 }