From 5ea87e0d32bf5ac9efc6cec2d53253fc4b48abfc Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Mon, 25 Nov 2024 16:59:59 +0100 Subject: [PATCH] Added separate tint colours for sleep times --- KittieCats/resources/themes/default.json | 2 ++ KittieCats/resources/themes/xmas.json | 2 ++ KittieCats/source/KittieCatsView.mc | 28 ++++++++++++------------ KittieCats/source/ThemeManager.mc | 4 ++++ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/KittieCats/resources/themes/default.json b/KittieCats/resources/themes/default.json index 8bcdfb9..fe6421b 100644 --- a/KittieCats/resources/themes/default.json +++ b/KittieCats/resources/themes/default.json @@ -1,7 +1,9 @@ { "ArmHourTintHi": 9708837, "ArmHourTintLo": 14429228, + "ArmHourTintSleep": 14429228, "ArmMinuteTintHi": 9708837, "ArmMinuteTintLo": 14429228, + "ArmMinuteTintSleep": 14429228, "MinuteOrnamentOffset": 0 } \ No newline at end of file diff --git a/KittieCats/resources/themes/xmas.json b/KittieCats/resources/themes/xmas.json index a5455a9..b82db74 100644 --- a/KittieCats/resources/themes/xmas.json +++ b/KittieCats/resources/themes/xmas.json @@ -1,7 +1,9 @@ { "ArmHourTintHi": 9708837, "ArmHourTintLo": 3583350, + "ArmHourTintSleep": 1194278, "ArmMinuteTintHi": 9708837, "ArmMinuteTintLo": 6804128, + "ArmMinuteTintSleep": 2311732, "MinuteOrnamentOffset": 130 } \ No newline at end of file diff --git a/KittieCats/source/KittieCatsView.mc b/KittieCats/source/KittieCatsView.mc index 9013dc6..178d0cf 100644 --- a/KittieCats/source/KittieCatsView.mc +++ b/KittieCats/source/KittieCatsView.mc @@ -28,7 +28,7 @@ class KittieCatsView extends WatchUi.WatchFace private var sleepTime; private var wakeTime; - private var sleeping = false; + private var highPowerMode = true; function initialize() @@ -87,7 +87,9 @@ class KittieCatsView extends WatchUi.WatchFace function onUpdate(dc as Dc) as Void { - var highPowerMode = self.isHighPowerMode(); + var isSleepMode = self.isSleepMode(); + var highPowerMode = !isSleepMode && self.highPowerMode; + var clockTime = System.getClockTime(); var complications = ComplicationSubscriber.getSnapshot(); @@ -110,10 +112,13 @@ class KittieCatsView extends WatchUi.WatchFace // --- Arms --- + var hourTint = highPowerMode ? self.theme.ArmHourTintHi : isSleepMode ? self.theme.ArmHourTintSleep : self.theme.ArmHourTintLo; + var minuteTint = highPowerMode ? self.theme.ArmMinuteTintHi : isSleepMode ? self.theme.ArmMinuteTintSleep : self.theme.ArmMinuteTintLo; + // Base the hour arm on minutes as well, to prevent the arm from staying on the // current hour tick mark right up until the 59th minute - self.drawArm(dc, self.armHour, 0, (clockTime.hour * 60) + clockTime.min, 720, highPowerMode ? self.theme.ArmHourTintHi : self.theme.ArmHourTintLo); - self.drawArm(dc, self.armMinute, 0, clockTime.min, 60, highPowerMode ? self.theme.ArmMinuteTintHi : self.theme.ArmMinuteTintLo); + self.drawArm(dc, self.armHour, 0, (clockTime.hour * 60) + clockTime.min, 720, hourTint); + self.drawArm(dc, self.armMinute, 0, clockTime.min, 60, minuteTint); if (highPowerMode) { @@ -148,23 +153,18 @@ class KittieCatsView extends WatchUi.WatchFace function onExitSleep() as Void { - self.sleeping = false; + self.highPowerMode = true; } function onEnterSleep() as Void { - self.sleeping = true; + self.highPowerMode = false; } - private function isHighPowerMode() as Boolean + private function isSleepMode() as Boolean { - if (self.sleeping) - { - return false; - } - // Since isSleepMode is deprecated, base it on the wake and sleep times. Unfortunately this means // the display will never be in high power mode between those times even if desired. // Can't figure out how to check for the locked state either. @@ -174,10 +174,10 @@ class KittieCatsView extends WatchUi.WatchFace if (now.greaterThan(today.add(self.sleepTime)) || now.lessThan(today.add(self.wakeTime))) { - return false; + return true; } - return true; + return false; } diff --git a/KittieCats/source/ThemeManager.mc b/KittieCats/source/ThemeManager.mc index 4c54a0a..e59cd9f 100644 --- a/KittieCats/source/ThemeManager.mc +++ b/KittieCats/source/ThemeManager.mc @@ -15,8 +15,10 @@ class Theme public var ArmHourTintHi; public var ArmHourTintLo; + public var ArmHourTintSleep; public var ArmMinuteTintHi; public var ArmMinuteTintLo; + public var ArmMinuteTintSleep; function initialize(backgroundHi, backgroundLo, armHour, armMinute, armSecond, minuteOrnamentLo, variablesJsonResource) @@ -33,8 +35,10 @@ class Theme var variables = Application.loadResource(variablesJsonResource) as Dictionary; self.ArmHourTintHi = variables["ArmHourTintHi"]; self.ArmHourTintLo = variables["ArmHourTintLo"]; + self.ArmHourTintSleep = variables["ArmHourTintSleep"]; self.ArmMinuteTintHi = variables["ArmMinuteTintHi"]; self.ArmMinuteTintLo = variables["ArmMinuteTintLo"]; + self.ArmMinuteTintSleep = variables["ArmMinuteTintSleep"]; self.MinuteOrnamentOffset = variables["MinuteOrnamentOffset"]; } }