Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

.DS_Store
.gitignore
Empty file modified DesktopShim/AppDelegate.h
100644 → 100755
Empty file.
Empty file modified DesktopShim/AppDelegate.m
100644 → 100755
Empty file.
Empty file modified DesktopShim/Assets.xcassets/AppIcon.appiconset/Contents.json
100644 → 100755
Empty file.
Empty file modified DesktopShim/Assets.xcassets/Contents.json
100644 → 100755
Empty file.
Empty file modified DesktopShim/Base.lproj/Main.storyboard
100644 → 100755
Empty file.
Empty file modified DesktopShim/DesktopShim.entitlements
100644 → 100755
Empty file.
Empty file modified DesktopShim/FaceWindow.h
100644 → 100755
Empty file.
Empty file modified DesktopShim/FaceWindow.m
100644 → 100755
Empty file.
Empty file modified DesktopShim/Info.plist
100644 → 100755
Empty file.
Empty file modified DesktopShim/ViewController.h
100644 → 100755
Empty file.
Empty file modified DesktopShim/ViewController.m
100644 → 100755
Empty file.
Empty file modified DesktopShim/main.m
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified SpriteKitWatchFace WatchKit App/Assets.xcassets/Contents.json
100644 → 100755
Empty file.
Empty file modified SpriteKitWatchFace WatchKit App/Base.lproj/Interface.storyboard
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions SpriteKitWatchFace WatchKit App/Info.plist
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>SpriteKitWatchFace WatchKit App</string>
<string>Watchie</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>97</string>
<string>213</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified SpriteKitWatchFace WatchKit Extension/ExtensionDelegate.h
100644 → 100755
Empty file.
Empty file modified SpriteKitWatchFace WatchKit Extension/ExtensionDelegate.m
100644 → 100755
Empty file.
8 changes: 8 additions & 0 deletions SpriteKitWatchFace WatchKit Extension/FaceScene.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <SpriteKit/SpriteKit.h>
#import <WatchKit/WatchKit.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -104,8 +105,15 @@ typedef enum : NSUInteger {
@property BOOL useProgrammaticLayout;
@property BOOL useMasking;
@property BOOL showDate;
@property BOOL showBattery;
@property BOOL showDailyMessage;
@property BOOL showWeather;
@property BOOL showCenterDisc;

@property BOOL batteryCenter;
@property BOOL romanNumerals;
@property BOOL romanBattery;

@property CGSize faceSize;

@end
Expand Down
214 changes: 203 additions & 11 deletions SpriteKitWatchFace WatchKit Extension/FaceScene.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,20 @@ - (instancetype)initWithCoder:(NSCoder *)coder

self.theme = [[NSUserDefaults standardUserDefaults] integerForKey:@"Theme"];
self.useProgrammaticLayout = YES;
self.faceStyle = FaceStyleRound;
self.faceStyle = FaceStyleRectangular;
self.numeralStyle = NumeralStyleAll;
self.tickmarkStyle = TickmarkStyleAll;
self.tickmarkStyle = TickmarkStyleNone;
self.majorTickmarkShape = TickmarkShapeRectangular;
self.minorTickmarkShape = TickmarkShapeRectangular;

self.colorRegionStyle = ColorRegionStyleDynamicDuo;
self.showDate = YES;
self.showBattery = YES;
self.showDailyMessage = YES;
self.showWeather = YES;
self.batteryCenter = NO;
self.romanNumerals = YES;
self.romanBattery = NO;

[self refreshTheme];

Expand All @@ -102,6 +108,28 @@ - (instancetype)initWithCoder:(NSCoder *)coder
return self;
}

- (NSString*)romain:(int)num {
if (num < 0 || num > 9999) { return @""; } // out of range

NSArray *r_ones = [NSArray arrayWithObjects:@"I", @"II", @"III", @"IV", @"V", @"VI", @"VII", @"VIII", @"IX", nil];
NSArray *r_tens = [NSArray arrayWithObjects:@"X", @"XX", @"XXX", @"XL", @"L", @"LX", @"LXX",@"LXXX", @"XC", nil];
NSArray *r_hund = [NSArray arrayWithObjects:@"C", @"CC", @"CCC", @"CD", @"D", @"DC", @"DCC",@"DCCC", @"CM", nil];
NSArray *r_thou = [NSArray arrayWithObjects:@"M", @"MM", @"MMM", @"MMMM", @"MMMMM", @"MMMMMM", @"MMMMMMM", @"MMMMMMMM", @"MMMMMMMMM", nil];
// real romans should have an horizontal __ ___ _____
// bar over number to make x 1000: 4000 is IV, 16000 is XVI, 32767 is XXXMMDCCLXVII...

int thou = num / 1000;
int hundreds = (num -= thou*1000) / 100;
int tens = (num -= hundreds*100) / 10;
int ones = num % 10; // cheap %, 'cause num is < 100!

return [NSString stringWithFormat:@"%@%@%@%@",
thou ? [r_thou objectAtIndex:thou-1] : @"",
hundreds ? [r_hund objectAtIndex:hundreds-1] : @"",
tens ? [r_tens objectAtIndex:tens-1] : @"",
ones ? [r_ones objectAtIndex:ones-1] : @""];
}

#pragma mark -

-(void)setupTickmarksForRoundFaceWithLayerName:(NSString *)layerName
Expand Down Expand Up @@ -160,12 +188,22 @@ -(void)setupTickmarksForRoundFaceWithLayerName:(NSString *)layerName
}

}

CGFloat h = 25;

NSDictionary *attribs = @{NSFontAttributeName : [NSFont systemFontOfSize:h weight:NSFontWeightMedium], NSForegroundColorAttributeName : self.textColor};

NSAttributedString *labelText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%i", i == 0 ? 12 : i] attributes:attribs];

NSAttributedString *labelText;

if (self.romanNumerals) {
CGFloat h = 20;

NSDictionary *attribs = @{NSFontAttributeName : [NSFont systemFontOfSize:h weight:NSFontWeightMedium], NSForegroundColorAttributeName : self.textColor};

labelText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@", [self romain:i == 0 ? 12 : i]] attributes:attribs];
} else {
CGFloat h = 25;

NSDictionary *attribs = @{NSFontAttributeName : [NSFont systemFontOfSize:h weight:NSFontWeightMedium], NSForegroundColorAttributeName : self.textColor};

labelText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%i", i == 0 ? 12 : i] attributes:attribs];
}

SKLabelNode *numberLabel = [SKLabelNode labelNodeWithAttributedText:labelText];
numberLabel.position = CGPointMake((workingRadius-labelMargin) * -sin(angle), (workingRadius-labelMargin) * cos(angle) - 9);
Expand Down Expand Up @@ -245,6 +283,91 @@ -(void)setupTickmarksForRoundFaceWithLayerName:(NSString *)layerName

[faceMarkings addChild:numberLabel];
}

if (self.showBattery)
{
[WKInterfaceDevice currentDevice].batteryMonitoringEnabled = YES;
float watchBatteryPercentage = [WKInterfaceDevice currentDevice].batteryLevel;

CGFloat h = 12;

NSDictionary *attribs = @{NSFontAttributeName : [[NSFont systemFontOfSize:h weight:NSFontWeightMedium] smallCaps], NSForegroundColorAttributeName : self.textColor};

NSAttributedString *labelText = [[NSAttributedString alloc] initWithString:[[NSString stringWithFormat:@"%.0f%%", watchBatteryPercentage * 100] uppercaseString] attributes:attribs];
if (self.romanBattery) {
labelText = [[NSAttributedString alloc] initWithString:[[NSString stringWithFormat:@"%@%%", [self romain:watchBatteryPercentage * 100]] uppercaseString] attributes:attribs];
}

SKLabelNode *numberLabel = [SKLabelNode labelNodeWithAttributedText:labelText];
CGFloat numeralDelta = 0.0;

if (self.numeralStyle == NumeralStyleNone)
numeralDelta = 10.0;

if (self.batteryCenter) {
numberLabel.position = CGPointMake(0+numeralDelta, -40);
} else {
numberLabel.position = CGPointMake(-32+numeralDelta, -4);
}

[faceMarkings addChild:numberLabel];
}

if (self.showWeather)
{

NSURLSession *aSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[[aSession dataTaskWithURL:[NSURL URLWithString:@"https://custom-y7ru.frb.io/"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (((NSHTTPURLResponse *)response).statusCode == 200) {
if (data) {
NSString *contentOfURL = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", contentOfURL);
CGFloat h = 18;

NSDictionary *attribs = @{NSFontAttributeName : [[NSFont systemFontOfSize:h weight:NSFontWeightMedium] smallCaps], NSForegroundColorAttributeName : self.textColor};

NSAttributedString *labelText = [[NSAttributedString alloc] initWithString:[[NSString stringWithFormat:@"%@", contentOfURL] uppercaseString] attributes:attribs];

SKLabelNode *numberLabel = [SKLabelNode labelNodeWithAttributedText:labelText];
CGFloat numeralDelta = 0.0;

if (self.numeralStyle == NumeralStyleNone)
numeralDelta = 10.0;

numberLabel.position = CGPointMake(0+numeralDelta, 40);

[faceMarkings addChild:numberLabel];
}
}
}] resume];
}

// if (self.showDailyMessage)
// {
//// [WKInterfaceDevice currentDevice].batteryMonitoringEnabled = YES;
//// float watchBatteryPercentage = [WKInterfaceDevice currentDevice].batteryLevel;
//
// CGFloat h = 12;
//
// NSDictionary *attribs = @{NSFontAttributeName : [[NSFont systemFontOfSize:h weight:NSFontWeightMedium] smallCaps], NSForegroundColorAttributeName : self.textColor};
//
// NSAttributedString *labelText = [[NSAttributedString alloc] initWithString:[[NSString stringWithFormat:@"Failure is just another chance of getting better."] uppercaseString] attributes:attribs];
//
// SKLabelNode *numberLabel = [SKLabelNode labelNodeWithAttributedText:labelText];
// CGFloat numeralDelta = 0.0;
//
// if (self.numeralStyle == NumeralStyleNone)
// numeralDelta = 10.0;
//
//// if (self.dailyMessageCenter) {
//// numberLabel.position = CGPointMake(0+numeralDelta, 40);
//// } else {
//// numberLabel.position = CGPointMake(-32+numeralDelta, -4);
//// }
// numberLabel.position = CGPointMake(0+numeralDelta, 40);
//
// [faceMarkings addChild:numberLabel];
// }

[self addChild:faceMarkings];
}
Expand Down Expand Up @@ -388,9 +511,19 @@ -(void)setupTickmarksForRectangularFaceWithLayerName:(NSString *)layerName

[faceMarkings addChild:labelNode];

NSDictionary *attribs = @{NSFontAttributeName : [NSFont fontWithName:@"Futura-Medium" size:fontSize], NSForegroundColorAttributeName : self.textColor};

NSAttributedString *labelText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%i", i] attributes:attribs];

NSAttributedString *labelText;

if (self.romanNumerals) {
CGFloat fontSize = 20;
NSDictionary *attribs = @{NSFontAttributeName : [NSFont fontWithName:@"Futura-Medium" size:fontSize], NSForegroundColorAttributeName : self.textColor};

labelText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@", [self romain:i]] attributes:attribs];
} else {
NSDictionary *attribs = @{NSFontAttributeName : [NSFont fontWithName:@"Futura-Medium" size:fontSize], NSForegroundColorAttributeName : self.textColor};

labelText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%i", i] attributes:attribs];
}

SKLabelNode *numberLabel = [SKLabelNode labelNodeWithAttributedText:labelText];

Expand Down Expand Up @@ -422,6 +555,65 @@ -(void)setupTickmarksForRectangularFaceWithLayerName:(NSString *)layerName

[faceMarkings addChild:numberLabel];
}

if (self.showBattery)
{
[WKInterfaceDevice currentDevice].batteryMonitoringEnabled = YES;
float watchBatteryPercentage = [WKInterfaceDevice currentDevice].batteryLevel;

CGFloat h = 12;

NSDictionary *attribs = @{NSFontAttributeName : [[NSFont systemFontOfSize:h weight:NSFontWeightMedium] smallCaps], NSForegroundColorAttributeName : self.textColor};

NSAttributedString *labelText = [[NSAttributedString alloc] initWithString:[[NSString stringWithFormat:@"%.0f%%", watchBatteryPercentage * 100] uppercaseString] attributes:attribs];

if (self.romanBattery) {
labelText = [[NSAttributedString alloc] initWithString:[[NSString stringWithFormat:@"%@%%", [self romain:watchBatteryPercentage * 100]] uppercaseString] attributes:attribs];
}

SKLabelNode *numberLabel = [SKLabelNode labelNodeWithAttributedText:labelText];
CGFloat numeralDelta = 0.0;

if (self.numeralStyle == NumeralStyleNone)
numeralDelta = 10.0;

if (self.batteryCenter) {
numberLabel.position = CGPointMake(0+numeralDelta, -40);
} else {
numberLabel.position = CGPointMake(-32+numeralDelta, -4);
}

[faceMarkings addChild:numberLabel];
}

if (self.showWeather)
{

NSURLSession *aSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[[aSession dataTaskWithURL:[NSURL URLWithString:@"https://custom-y7ru.frb.io/"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (((NSHTTPURLResponse *)response).statusCode == 200) {
if (data) {
NSString *contentOfURL = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", contentOfURL);
CGFloat h = 18;

NSDictionary *attribs = @{NSFontAttributeName : [[NSFont systemFontOfSize:h weight:NSFontWeightMedium] smallCaps], NSForegroundColorAttributeName : self.textColor};

NSAttributedString *labelText = [[NSAttributedString alloc] initWithString:[[NSString stringWithFormat:@"%@", contentOfURL] uppercaseString] attributes:attribs];

SKLabelNode *numberLabel = [SKLabelNode labelNodeWithAttributedText:labelText];
CGFloat numeralDelta = 0.0;

if (self.numeralStyle == NumeralStyleNone)
numeralDelta = 10.0;

numberLabel.position = CGPointMake(0+numeralDelta, 40);

[faceMarkings addChild:numberLabel];
}
}
}] resume];
}

[self addChild:faceMarkings];
}
Expand Down
Empty file modified SpriteKitWatchFace WatchKit Extension/FaceScene.sks
100644 → 100755
Empty file.
12 changes: 10 additions & 2 deletions SpriteKitWatchFace WatchKit Extension/Info.plist
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>SpriteKitWatchFace WatchKit Extension</string>
<string>Watchie WatchKit Extension</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>97</string>
<string>213</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand All @@ -30,6 +30,14 @@
<key>NSExtensionPointIdentifier</key>
<string>com.apple.watchkit</string>
</dict>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>SpriteKitWatchFace requires your location to use the Weather Complication.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>SpriteKitWatchFace requires your location to use the Weather Complication.</string>
<key>NSLocationUsageDescription</key>
<string>SpriteKitWatchFace requires your location to use the Weather Complication.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>SpriteKitWatchFace requires your location to use the Weather Complication.</string>
<key>WKExtensionDelegateClassName</key>
<string>ExtensionDelegate</string>
</dict>
Expand Down
5 changes: 4 additions & 1 deletion SpriteKitWatchFace WatchKit Extension/InterfaceController.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@

#import <WatchKit/WatchKit.h>
#import <Foundation/Foundation.h>
#import <WatchConnectivity/WatchConnectivity.h>
#import <CoreLocation/CoreLocation.h>
@import SpriteKit;

@interface InterfaceController : WKInterfaceController <SKSceneDelegate, WKCrownDelegate>
@interface InterfaceController : WKInterfaceController <WCSessionDelegate, SKSceneDelegate, WKCrownDelegate, CLLocationManagerDelegate>

@property IBOutlet WKInterfaceSKScene * scene;
@property CLLocationManager *locationManager;
@end
Loading