mirror of
https://github.com/ksherlock/ample.git
synced 2025-01-09 15:30:04 +00:00
add media to the command line.
This commit is contained in:
parent
259b5f31a7
commit
dc7b14d28d
@ -91,6 +91,7 @@ static NSString *kMyContext = @"kMyContext";
|
|||||||
[self addObserver: self forKeyPath: @"mameNoThrottle" options:0 context: (__bridge void * _Nullable)(kMyContext)];
|
[self addObserver: self forKeyPath: @"mameNoThrottle" options:0 context: (__bridge void * _Nullable)(kMyContext)];
|
||||||
|
|
||||||
[_slotController addObserver: self forKeyPath: @"args" options: 0 context: (__bridge void * _Nullable)(kMyContext)];
|
[_slotController addObserver: self forKeyPath: @"args" options: 0 context: (__bridge void * _Nullable)(kMyContext)];
|
||||||
|
[_mediaController addObserver: self forKeyPath: @"args" options: 0 context: (__bridge void * _Nullable)(kMyContext)];
|
||||||
|
|
||||||
[_mediaController bind: @"media" toObject: _slotController withKeyPath: @"media" options: 0];
|
[_mediaController bind: @"media" toObject: _slotController withKeyPath: @"media" options: 0];
|
||||||
|
|
||||||
@ -225,7 +226,13 @@ static NSString * JoinArguments(NSArray *argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NSArray *args = [_slotController args];
|
NSArray *args;
|
||||||
|
args = [_slotController args];
|
||||||
|
if ([args count]) {
|
||||||
|
[argv addObjectsFromArray: args];
|
||||||
|
}
|
||||||
|
|
||||||
|
args = [_mediaController args];
|
||||||
if ([args count]) {
|
if ([args count]) {
|
||||||
[argv addObjectsFromArray: args];
|
[argv addObjectsFromArray: args];
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,10 @@
|
|||||||
<rect key="frame" x="1" y="21" width="304" height="17"/>
|
<rect key="frame" x="1" y="21" width="304" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField identifier="CategoryView" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Pep-mX-LHY">
|
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Pep-mX-LHY">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="304" height="17"/>
|
<rect key="frame" x="0.0" y="0.0" width="304" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" identifier="CategoryView" title="Table View Cell" id="Rrg-wr-8eL">
|
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="Rrg-wr-8eL">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
@ -87,6 +87,9 @@
|
|||||||
<pathCell key="cell" controlSize="small" selectable="YES" editable="YES" focusRingType="none" alignment="left" pathStyle="popUp" id="dcz-8y-tKb">
|
<pathCell key="cell" controlSize="small" selectable="YES" editable="YES" focusRingType="none" alignment="left" pathStyle="popUp" id="dcz-8y-tKb">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
</pathCell>
|
</pathCell>
|
||||||
|
<connections>
|
||||||
|
<action selector="pathAction:" target="-2" id="4oX-bW-ANp"/>
|
||||||
|
</connections>
|
||||||
</pathControl>
|
</pathControl>
|
||||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zNo-ij-mUl">
|
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zNo-ij-mUl">
|
||||||
<rect key="frame" x="256" y="5" width="23" height="18"/>
|
<rect key="frame" x="256" y="5" width="23" height="18"/>
|
||||||
@ -96,7 +99,7 @@
|
|||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
</buttonCell>
|
</buttonCell>
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="buttonDelete:" target="-2" id="f30-YS-1UK"/>
|
<action selector="deleteAction:" target="-2" id="XAl-eQ-nUj"/>
|
||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
|
@ -14,7 +14,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@property (weak) IBOutlet NSOutlineView *outlineView;
|
@property (weak) IBOutlet NSOutlineView *outlineView;
|
||||||
@property (nonatomic) NSDictionary *media;
|
@property (nonatomic) NSDictionary *media;
|
||||||
- (IBAction)buttonDelete:(id)sender;
|
@property NSArray *args;
|
||||||
|
|
||||||
|
- (IBAction)deleteAction:(id)sender;
|
||||||
|
- (IBAction)pathAction:(id)sender;
|
||||||
|
|
||||||
|
|
||||||
//-(void)setMedia: (NSDictionary *)media;
|
//-(void)setMedia: (NSDictionary *)media;
|
||||||
|
@ -233,6 +233,36 @@ enum {
|
|||||||
kIndexCassette
|
kIndexCassette
|
||||||
};
|
};
|
||||||
|
|
||||||
|
-(void)rebuildArgs {
|
||||||
|
|
||||||
|
static char* prefix[] = {
|
||||||
|
"flop", "flop", "hard", "cdrm", "cass"
|
||||||
|
};
|
||||||
|
NSMutableArray *args = [NSMutableArray new];
|
||||||
|
|
||||||
|
unsigned counts[5] = { 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
for (unsigned j = 0; j < 5; ++j) {
|
||||||
|
|
||||||
|
MediaCategory *cat = _data[j];
|
||||||
|
NSInteger valid = [cat validCount];
|
||||||
|
for (NSInteger i = 0; i < valid; ++i) {
|
||||||
|
counts[j]++;
|
||||||
|
|
||||||
|
MediaItem *item = [cat objectAtIndex: i];
|
||||||
|
NSURL *url = [item url];
|
||||||
|
if (!url) continue;
|
||||||
|
[args addObject: [NSString stringWithFormat: @"-%s%u", prefix[j], counts[j]]];
|
||||||
|
NSString *s = [NSString stringWithCString: [url fileSystemRepresentation] encoding: NSUTF8StringEncoding];
|
||||||
|
|
||||||
|
[args addObject: s];
|
||||||
|
}
|
||||||
|
if (j == 0) counts[1] = counts[0]; // 3.5/5.25
|
||||||
|
}
|
||||||
|
|
||||||
|
[self setArgs: args];
|
||||||
|
}
|
||||||
|
|
||||||
-(void)rebuildRoot {
|
-(void)rebuildRoot {
|
||||||
NSMutableArray *tmp = [NSMutableArray new];
|
NSMutableArray *tmp = [NSMutableArray new];
|
||||||
for (unsigned j = 0 ; j < 5; ++j) {
|
for (unsigned j = 0 ; j < 5; ++j) {
|
||||||
@ -274,7 +304,10 @@ enum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (delta) [self rebuildRoot];
|
if (delta) {
|
||||||
|
[self rebuildRoot];
|
||||||
|
[self rebuildArgs];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
@ -371,7 +404,7 @@ enum {
|
|||||||
|
|
||||||
|
|
||||||
#pragma mark - IBActions
|
#pragma mark - IBActions
|
||||||
- (IBAction)buttonDelete:(id)sender {
|
- (IBAction)deleteAction:(id)sender {
|
||||||
|
|
||||||
NSInteger row = [_outlineView rowForView: sender];
|
NSInteger row = [_outlineView rowForView: sender];
|
||||||
if (row < 0) return;
|
if (row < 0) return;
|
||||||
@ -386,5 +419,10 @@ enum {
|
|||||||
MediaCategory *cat = [_outlineView parentForItem: item];
|
MediaCategory *cat = [_outlineView parentForItem: item];
|
||||||
if ([cat pruneChildren]) [self rebuildRoot];
|
if ([cat pruneChildren]) [self rebuildRoot];
|
||||||
}
|
}
|
||||||
|
[self rebuildArgs];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)pathAction:(id)sender {
|
||||||
|
[self rebuildArgs];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user