Example #1
0
    // Saves the changes based on the states of the UI in the customization menu to the chosen alarm.
    public void SaveChanges(AlarmScript newAlarm)
    {
        int newHour;
        int newMinute;

        int.TryParse(windowManager.GetComponentInChildren <WindowManagerScript>().hourField.text, out newHour);
        int.TryParse(windowManager.GetComponentInChildren <WindowManagerScript>().minuteField.text, out newMinute);

        newAlarm.GetComponentInChildren <AlarmScript>().SetHour(newHour);
        newAlarm.GetComponentInChildren <AlarmScript>().SetMinute(newMinute);

        for (int i = 0; i < 7; i++)
        {
            // This sets the weekday state in the new alarm to the state of the corresponding button.
            newAlarm.GetComponentInChildren <AlarmScript>().SetWeekdayState(
                i, windowManager.GetComponentInChildren <WindowManagerScript>().weekdayButtons[i].GetComponentInChildren <WeekdayButtonScript>().WeekdayIsSelected());
        }
        string newWeekdayText = "";

        if (newAlarm.GetComponentInChildren <AlarmScript>().GetWeekdayState(0))
        {
            newWeekdayText += "Mon ";
        }
        if (newAlarm.GetComponentInChildren <AlarmScript>().GetWeekdayState(1))
        {
            newWeekdayText += "Tue ";
        }
        if (newAlarm.GetComponentInChildren <AlarmScript>().GetWeekdayState(2))
        {
            newWeekdayText += "Wed ";
        }
        if (newAlarm.GetComponentInChildren <AlarmScript>().GetWeekdayState(3))
        {
            newWeekdayText += "Thu ";
        }
        if (newAlarm.GetComponentInChildren <AlarmScript>().GetWeekdayState(4))
        {
            newWeekdayText += "Fri ";
        }
        if (newAlarm.GetComponentInChildren <AlarmScript>().GetWeekdayState(5))
        {
            newWeekdayText += "Sat ";
        }
        if (newAlarm.GetComponentInChildren <AlarmScript>().GetWeekdayState(6))
        {
            newWeekdayText += "Sun";
        }
        if (newWeekdayText == "")
        {
            newWeekdayText = "No repeat";
        }

        newAlarm.GetComponentInChildren <Text>().text = newWeekdayText;
    }
Example #2
0
 // Returns 1 if this alarm is later than the other alarm, 0 if they are equal, and -1 if this one is earlier.
 public int CompareAlarmTimes(AlarmScript alarm2)
 {
     if (hour > alarm2.GetHour())
     {
         return(1);
     }
     if (hour == alarm2.GetHour())
     {
         if (minute > alarm2.GetMinute())
         {
             return(1);
         }
         else if (minute == alarm2.GetMinute())
         {
             return(0);
         }
     }
     return(-1);
 }
Example #3
0
    // Loads an alarm's values into the UI
    public void LoadAlarm(AlarmScript alarm)
    {
        editingMode = true;

        hourField.text   = "";
        minuteField.text = "";
        if (alarm.GetHour() < 10)
        {
            hourField.text += "0";
        }
        if (alarm.GetMinute() < 10)
        {
            minuteField.text += "0";
        }
        hourField.text   += alarm.GetHour().ToString();
        minuteField.text += alarm.GetMinute().ToString();
        for (int i = 0; i < weekdayButtons.Length; i++)
        {
            weekdayButtons[i].GetComponent <WeekdayButtonScript>().SetWeekday(alarm.GetWeekdayState(i));
        }
    }
Example #4
0
 // Finds the alarm that is being edited.
 public void SetExistingAlarm()
 {
     existingAlarm = GameObject.FindGameObjectWithTag("loaded").GetComponent <AlarmScript>();
 }