예제 #1
0
        private void DoTime(Rect rect)
        {
            var labelRect = rect;

            labelRect.height = 25;
            Widgets.Label(labelRect, I18n.Translate("EditReminder.ReminderTime"));

            var radioRect = labelRect;

            radioRect.y      = labelRect.yMax;
            radioRect.height = 30;
            radioRect.width  = 24f + 20f + absTextLength;

            if (FWidgets.RadioButtonLabeled(radioRect, I18n.Translate(TimeRepresentation.Absolute.ToString()), selectedTimeRep == TimeRepresentation.Absolute))
            {
                if (selectedTimeRep != TimeRepresentation.Absolute && fireOnTick != 0)
                {
                    UpdateAbsoluteFieldsFromTicks(fireOnTick);
                }
                selectedTimeRep = TimeRepresentation.Absolute;
            }

            radioRect.x     = radioRect.xMax + 20f;
            radioRect.width = 24f + 20f + relTextLength;

            if (FWidgets.RadioButtonLabeled(radioRect, I18n.Translate(TimeRepresentation.Relative.ToString()), selectedTimeRep == TimeRepresentation.Relative))
            {
                if (selectedTimeRep != TimeRepresentation.Relative && fireOnTick != 0)
                {
                    UpdateRelativeFieldsFromTicks(fireOnTick);
                }
                selectedTimeRep = TimeRepresentation.Relative;
            }

            radioRect.x     = radioRect.xMax + 20f;
            radioRect.width = 100f;
            bool nextLoadRadioSelected = FWidgets.RadioButtonLabeled(radioRect, I18n.Translate("Reminder.NextLoad"), selectedTimeRep == TimeRepresentation.NextLoad);

            if (nextLoadRadioSelected)
            {
                selectedTimeRep = TimeRepresentation.NextLoad;
            }
            nextLoad = selectedTimeRep == TimeRepresentation.NextLoad;

            var timeInputRect = new Rect(labelRect.x, radioRect.yMax + 5, rect.width, 30f);

            switch (selectedTimeRep)
            {
            case TimeRepresentation.Absolute:
                DoAbsoluteTime(timeInputRect);
                break;

            case TimeRepresentation.Relative:
                DoRelativeTime(timeInputRect);
                break;
            }
        }
예제 #2
0
 public Window_EditReminder(Reminder reminder, bool fromNextLoadQueue) : this()
 {
     this.reminder     = reminder;
     title             = reminder.Title;
     body              = reminder.Body;
     selectedLetterDef = reminder.LetterDef;
     fireOnTick        = fromNextLoadQueue ? 0 : reminder.FireOnTick;
     nextLoad          = fromNextLoadQueue;
     if (nextLoad)
     {
         selectedTimeRep = TimeRepresentation.NextLoad;
     }
     if (reminder.RecurEvery.HasValue)
     {
         recur = true;
         var days           = Mathf.FloorToInt((float)reminder.RecurEvery.Value / (float)GenDate.TicksPerDay);
         var ticksRemainder = reminder.RecurEvery.Value - days * GenDate.TicksPerDay;
         var hours          = Mathf.CeilToInt((float)ticksRemainder / (float)GenDate.TicksPerHour);
         recurEveryDays  = days;
         recurEveryHours = hours;
     }
 }
예제 #3
0
        private static void ParseTime()
        {
            string             timeRaw = jsonDoc.Value <string>("time");
            TimeRepresentation time    = timeRaw.StringToEnum <TimeRepresentation>();

            Config.currentTime_Func = GetTimeFunc();

            Func <DateTime> GetTimeFunc()
            {
                switch (time)
                {
                case TimeRepresentation.LOCAL:
                    return(() => DateTime.Now);

                case TimeRepresentation.UTC:
                    return(() => DateTime.UtcNow);

                default:
                    Console.WriteLine("StruLog: Time format not found in config, will be set UTC format.");
                    return(() => DateTime.UtcNow);
                }
            }
        }