-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
314 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
#import <UIKit/UIKit.h> | ||
#import <MobileGoose.h> | ||
|
||
@interface PXJoeTheGooseMod : NSObject<MGMod> | ||
#define PrefValue(key) ([NSUserDefaults.standardUserDefaults \ | ||
objectForKey:key \ | ||
inDomain:@"com.pixelomer.joethegoose" \ | ||
]) | ||
|
||
@interface NSUserDefaults(Private) | ||
- (id)objectForKey:(NSString *)key inDomain:(NSString *)domain; | ||
@end | ||
|
||
@interface PXJoeTheGooseMod : NSObject<MGMod> { | ||
UILabel *nameLabel; | ||
} | ||
@property (nonatomic, assign) BOOL enabled; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>items</key> | ||
<array> | ||
<dict> | ||
<key>cell</key> | ||
<string>PSGroupCell</string> | ||
<key>label</key> | ||
<string>Options</string> | ||
</dict> | ||
<dict> | ||
<key>cell</key> | ||
<string>PSEditTextCell</string> | ||
<key>default</key> | ||
<string>Joe</string> | ||
<key>placeholder</key> | ||
<string>Joe</string> | ||
<key>key</key> | ||
<string>Name</string> | ||
<key>label</key> | ||
<string>Goose Name:</string> | ||
</dict> | ||
</array> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#import <Preferences/PSListController.h> | ||
|
||
@interface PXMGPModDetailsController : PSListController { | ||
NSBundle *_modBundle; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#include "PXMGPModDetailsController.h" | ||
#import <Preferences/PSSpecifier.h> | ||
|
||
@interface PSSpecifier(Private) | ||
- (instancetype)initWithName:(NSString *)identifier target:(id)target set:(SEL)set get:(SEL)get detail:(Class)detail cell:(PSCellType)cellType edit:(Class)edit; | ||
@end | ||
|
||
@interface NSUserDefaults(Private) | ||
- (void)setObject:(id)arg1 forKey:(id)arg2 inDomain:(id)arg3; | ||
- (id)objectForKey:(id)arg1 inDomain:(id)arg2; | ||
@end | ||
|
||
@interface NSDistributedNotificationCenter : NSNotificationCenter | ||
- (void)postNotificationName:(NSNotificationName)name | ||
object:(NSString *)object | ||
userInfo:(NSDictionary *)userInfo | ||
deliverImmediately:(BOOL)deliverImmediately; | ||
@end | ||
|
||
@implementation PXMGPModDetailsController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
self.title = self.specifier.name; | ||
} | ||
|
||
- (NSArray *)specifiers { | ||
if (!_specifiers) { | ||
NSString *modPath = [self.specifier propertyForKey:@"modPath"]; | ||
if (!modPath) return nil; | ||
_modBundle = [NSBundle bundleWithPath:modPath]; | ||
if (!_modBundle) return nil; | ||
NSMutableArray *mutableSpecifiers = [NSMutableArray new]; | ||
PSSpecifier *enabledSpecifier; | ||
SEL setter = @selector(setModPreferenceValue:specifier:); | ||
SEL getter = @selector(modPreferenceValueForSpecifier:); | ||
enabledSpecifier = [PSSpecifier | ||
preferenceSpecifierNamed:@"Enabled" | ||
target:self | ||
set:setter | ||
get:getter | ||
detail:nil | ||
cell:PSSwitchCell | ||
edit:nil | ||
]; | ||
[enabledSpecifier setProperty:@"Enabled" forKey:@"key"]; | ||
[enabledSpecifier setProperty:@YES forKey:@"default"]; | ||
[mutableSpecifiers addObject:enabledSpecifier]; | ||
NSArray *specifiersFromFile = [self | ||
loadSpecifiersFromPlistName:@"Root" | ||
target:self | ||
bundle:_modBundle | ||
]; | ||
for (PSSpecifier *specifier in specifiersFromFile) { | ||
NSMutableDictionary *properties = specifier.properties; | ||
PSSpecifier *correctedSpecifier = [specifier | ||
initWithName:specifier.name | ||
target:self | ||
set:setter | ||
get:getter | ||
detail:nil | ||
cell:specifier.cellType | ||
edit:nil | ||
]; | ||
specifier.properties = properties; | ||
[mutableSpecifiers addObject:correctedSpecifier]; | ||
} | ||
_specifiers = mutableSpecifiers.copy; | ||
} | ||
return _specifiers; | ||
} | ||
|
||
- (void)setModPreferenceValue:(id)value specifier:(PSSpecifier *)specifier { | ||
NSLog(@"%@ <= %@", specifier, value); | ||
NSString *key = [specifier propertyForKey:@"key"]; | ||
NSString *bundleID = _modBundle.bundleIdentifier; | ||
[NSUserDefaults.standardUserDefaults setObject:value forKey:key inDomain:bundleID]; | ||
[NSUserDefaults.standardUserDefaults synchronize]; | ||
[(NSDistributedNotificationCenter *)[NSClassFromString(@"NSDistributedNotificationCenter") defaultCenter] | ||
postNotificationName:@"com.pixelomer.mobilegoose/ModPreferencesChanged" | ||
object:_modBundle.bundlePath | ||
userInfo:@{ @"key": key, @"newValue" : value } | ||
deliverImmediately:YES | ||
]; | ||
} | ||
|
||
- (id)modPreferenceValueForSpecifier:(PSSpecifier *)specifier { | ||
NSString *key = [specifier propertyForKey:@"key"]; | ||
NSString *bundleID = _modBundle.bundleIdentifier; | ||
id value = [NSUserDefaults.standardUserDefaults objectForKey:key inDomain:bundleID]; | ||
NSLog(@"%@ => %@", specifier, value); | ||
return value ?: [specifier propertyForKey:@"default"]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#import <Preferences/PSListController.h> | ||
|
||
@interface PXMGPModListController : PSListController | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#import "PXMGPModListController.h" | ||
#import "PXMGPModDetailsController.h" | ||
#import <Preferences/PSSpecifier.h> | ||
|
||
@implementation PXMGPModListController | ||
|
||
- (NSArray *)specifiers { | ||
if (!_specifiers) { | ||
NSMutableArray *mutableSpecifiers = [NSMutableArray new]; | ||
NSString *modRoot = @"/Library/MobileGoose/Mods"; | ||
NSError *error = nil; | ||
NSArray *modNames = [NSFileManager.defaultManager | ||
contentsOfDirectoryAtPath:modRoot | ||
error:&error | ||
]; | ||
PSSpecifier *specifier; | ||
if (!error && modNames.count) { | ||
specifier = [PSSpecifier | ||
preferenceSpecifierNamed:@"Installed Mods" | ||
target:nil | ||
set:nil | ||
get:nil | ||
detail:nil | ||
cell:PSGroupCell | ||
edit:nil | ||
]; | ||
[mutableSpecifiers addObject:specifier]; | ||
for (NSString *modName in modNames) { | ||
@autoreleasepool { | ||
NSString *fullModPath = [modRoot stringByAppendingPathComponent:modName]; | ||
NSBundle *bundle = [NSBundle bundleWithPath:fullModPath]; | ||
specifier = [PSSpecifier | ||
preferenceSpecifierNamed:( | ||
(bundle.localizedInfoDictionary ?: bundle.infoDictionary)[@"CFBundleDisplayName"] ?: | ||
modName.stringByDeletingPathExtension | ||
) | ||
target:self | ||
set:nil | ||
get:nil | ||
detail:(bundle ? [PXMGPModDetailsController class] : nil) | ||
cell:PSLinkCell | ||
edit:nil | ||
]; | ||
NSLog(@"%@ %@", specifier.name, bundle.infoDictionary); | ||
[specifier setProperty:fullModPath forKey:@"modPath"]; | ||
[mutableSpecifiers addObject:specifier]; | ||
} | ||
} | ||
} | ||
else { | ||
specifier = [PSSpecifier | ||
preferenceSpecifierNamed:nil | ||
target:nil | ||
set:nil | ||
get:nil | ||
detail:nil | ||
cell:PSGroupCell | ||
edit:nil | ||
]; | ||
[specifier setProperty:@"No MobileGoose mods seem to be installed." forKey:@"footerText"]; | ||
[mutableSpecifiers addObject:specifier]; | ||
} | ||
_specifiers = mutableSpecifiers.copy; | ||
} | ||
|
||
return _specifiers; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.