ample/Ample/SlotViewController.m

385 lines
8.6 KiB
Mathematica
Raw Normal View History

2020-09-11 02:06:41 +00:00
//
2021-05-30 22:19:51 +00:00
// SlotViewController.m
2020-09-11 02:06:41 +00:00
// Ample
//
// Created by Kelvin Sherlock on 9/9/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
2021-03-13 00:58:12 +00:00
#import "Ample.h"
2021-05-30 22:19:51 +00:00
#import "SlotViewController.h"
#import "Menu.h"
#import "Slot.h"
#import "Media.h"
2020-09-11 02:06:41 +00:00
2021-03-13 00:58:12 +00:00
#import <objc/runtime.h>
#define MAX_SLOTS 32
2020-09-11 02:06:41 +00:00
2021-03-13 00:58:12 +00:00
static unsigned RootKey = 0;
2020-09-11 02:06:41 +00:00
2021-05-30 22:19:51 +00:00
@interface SlotViewController ()
2020-09-11 02:06:41 +00:00
@property (weak) IBOutlet NSOutlineView *outlineView;
2021-03-13 00:58:12 +00:00
@property (weak) IBOutlet NSOutlineView *childOutlineView;
2020-09-11 02:06:41 +00:00
@end
2021-05-30 22:19:51 +00:00
@implementation SlotViewController {
NSArray *_root;
2020-09-11 02:06:41 +00:00
Media _slot_media[MAX_SLOTS];
Media _machine_media;
2020-09-11 02:06:41 +00:00
NSDictionary *_machine_data;
NSMutableDictionary *_slotValues;
IBOutlet NSPopover *_popover;
Squashed commit of the following: commit 78c81626670fdf41fa6bdd71a4243a89a0746615 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon Jun 7 00:33:48 2021 -0400 check if software set has a particular entry. commit ef5ab6b6948dc3bbbe2947ea099fcacd08435e86 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 22:20:34 2021 -0400 fix scroller background on recent disk images window. commit dee56fa50e87299b396b48361bd0a780aaaaa768 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 21:26:23 2021 -0400 update cheat sheet javascript to work with 10.11 * => functions not supported * NodeList.prototype.forEach not supported. commit b00cc05413f4ebd6d6d58f96e24303008608f3a6 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 17:10:41 2021 -0400 default full machine name for bookmark entry. commit a671cafdc98051b56b12cdd3ccd13c22f54f605a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:39:32 2021 -0400 loading a bookmark wasn't updating the media. commit 3000e0eb1b10bede3345aaab8478e9ec209f328c Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:38:53 2021 -0400 bump copyright year. commit 45222dacd4aa0047fae63a9112509de57139df63 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:38:23 2021 -0400 add reset w/ value for setting the item explicitely. commit cc7fde1253b71c4d8655eb4c010bbf4e61333a15 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:37:48 2021 -0400 add checkboxes for bitbanger/share directory. The general idea is it's easier to toggle a checkbox than to type/retype a path. commit 5674b2d7f6b0e2f0b973197bf3493ad61bf46428 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:43 2021 -0400 commentary on searches with diacritics. commit ec60634dcd9c573130dc34673b4d3fe597ea2b42 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:22 2021 -0400 clean up auto-complete a little bit when setting a value directly. commit 1a182bbdab237c89d355d8294b5a4a64b785783a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 13:08:29 2021 -0400 fix text color when value is set. There are still some bugs relating to multiple copies of the value being stored. commit 49c0bc15c73446259d8cc151cf52d6058644db76 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 12:09:44 2021 -0400 reset all controls first. commit 059797ad85b057e296cc707b4645f839bfccac13 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 10:52:06 2021 -0400 more bookmark loading. commit e5a612d9f8e7414dd15c66dbaa540b637765eeec Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:38 2021 -0400 bookmark - restore the software commit f9411a1e84df7bd46e352cc5ca995b585c2a0523 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:25 2021 -0400 clean up software / name logic. commit f628d99e4a70d65ea8703f3c182103cd3bfea969 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:21:08 2021 -0400 load bookmark... commit 0b248e6aad16cba848f88d294a1366cea5760aa0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:20:42 2021 -0400 stringValue can't be nil. commit 94aac38af45c3c95cb86b176393a469279c2539e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:04:37 2021 -0400 add bookmark menu commit 6215a0df120b6cd97f1ffea2d2db9aaa5ae61f29 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:03:29 2021 -0400 slot view needs to know the machine. commit d348c15dc56d9cee01e5417435dd236e0e541902 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:58 2021 -0400 transformer to enable/disable control based on string length. commit e14336a0094af7aa84e91da69ff59ebb9e8eea9b Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:14 2021 -0400 shut up compiler warning. commit 4baf545245d8d3debf8f436b36b14cca23bf7a33 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:01:15 2021 -0400 bookmark manager commit 0f3e6c83075a145a456728b57a499cfa35707002 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 23:54:29 2021 -0400 more (untested) bookmark code commit 8fdb149eb38952b13c4a78d7a6940c43d90870f1 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:13:43 2021 -0400 start of bookmarking support. Untested. commit 787eac87f6ac13cd677630cbaf2538cecab27b1f Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:12:45 2021 -0400 shut up warnings about content clipping. maybe it's a 10.11 thing. The size was chosen by interface builder.
2021-06-07 04:34:26 +00:00
BOOL _loadingBookmark;
2020-09-11 02:06:41 +00:00
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
2020-09-12 22:00:09 +00:00
_root = @[];
2021-03-13 00:58:12 +00:00
objc_setAssociatedObject(_outlineView, &RootKey, _root, OBJC_ASSOCIATION_RETAIN);
_slotValues = [NSMutableDictionary new];
2021-03-13 00:58:12 +00:00
//[_outlineView setIndentationPerLevel: 2.0];
2020-09-11 02:06:41 +00:00
}
-(void)resetMachine {
_root = @[];
2021-03-13 00:58:12 +00:00
objc_setAssociatedObject(_outlineView, &RootKey, _root, OBJC_ASSOCIATION_RETAIN);
2020-09-11 02:06:41 +00:00
[_outlineView reloadData];
[_slotValues removeAllObjects];
_machine_media = EmptyMedia;
2020-09-11 02:06:41 +00:00
_machine_data = nil;
for (unsigned i = 0; i < MAX_SLOTS; ++i) {
_slot_media[i] = EmptyMedia;
2020-09-11 02:06:41 +00:00
}
[self setResolution: NSMakeSize(0, 0)];
[self setArgs: @[]];
[self setMedia: EmptyMedia];
2020-09-11 02:06:41 +00:00
}
2020-09-11 02:06:41 +00:00
-(void)loadMachine {
NSDictionary *d = MameMachine(_machine);
2020-09-11 02:06:41 +00:00
if (!d) {
[self resetMachine];
return;
}
NSArray *r = [d objectForKey: @"resolution"];
NSSize res = NSMakeSize(0, 0);
if (r) {
res.width = [(NSNumber *)[r objectAtIndex: 0 /*@"width"*/] doubleValue];
res.height = [(NSNumber *)[r objectAtIndex: 1 /*@"height"*/] doubleValue];
}
[self setResolution: res];
_machine_media = MediaFromDictionary([d objectForKey: @"media"]);
2020-09-11 02:06:41 +00:00
_machine_data = d;
for (unsigned i = 0; i < MAX_SLOTS; ++i) {
_slot_media[i] = EmptyMedia;
}
2020-09-11 02:06:41 +00:00
extern NSArray *BuildSlots(NSString *name, NSDictionary *data);
_root = BuildSlots(_machine, d);
2021-03-13 00:58:12 +00:00
objc_setAssociatedObject(_outlineView, &RootKey, _root, OBJC_ASSOCIATION_RETAIN);
for (Slot *item in _root) {
NSString *name = [item name];
NSInteger index = [item index] - 1;
if (index < 0 || index >= MAX_SLOTS) continue;
2020-09-11 02:06:41 +00:00
if ([item type] == kSlotBIOS) continue;
NSString *v = [_slotValues objectForKey: name];
if (v) {
[item selectValue: v];
}
// TODO -- reset to default index???
_slot_media[index] = [item selectedMedia];
2020-09-11 02:06:41 +00:00
}
2020-09-11 02:06:41 +00:00
[_outlineView reloadData];
Squashed commit of the following: commit 78c81626670fdf41fa6bdd71a4243a89a0746615 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon Jun 7 00:33:48 2021 -0400 check if software set has a particular entry. commit ef5ab6b6948dc3bbbe2947ea099fcacd08435e86 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 22:20:34 2021 -0400 fix scroller background on recent disk images window. commit dee56fa50e87299b396b48361bd0a780aaaaa768 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 21:26:23 2021 -0400 update cheat sheet javascript to work with 10.11 * => functions not supported * NodeList.prototype.forEach not supported. commit b00cc05413f4ebd6d6d58f96e24303008608f3a6 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 17:10:41 2021 -0400 default full machine name for bookmark entry. commit a671cafdc98051b56b12cdd3ccd13c22f54f605a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:39:32 2021 -0400 loading a bookmark wasn't updating the media. commit 3000e0eb1b10bede3345aaab8478e9ec209f328c Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:38:53 2021 -0400 bump copyright year. commit 45222dacd4aa0047fae63a9112509de57139df63 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:38:23 2021 -0400 add reset w/ value for setting the item explicitely. commit cc7fde1253b71c4d8655eb4c010bbf4e61333a15 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:37:48 2021 -0400 add checkboxes for bitbanger/share directory. The general idea is it's easier to toggle a checkbox than to type/retype a path. commit 5674b2d7f6b0e2f0b973197bf3493ad61bf46428 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:43 2021 -0400 commentary on searches with diacritics. commit ec60634dcd9c573130dc34673b4d3fe597ea2b42 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:22 2021 -0400 clean up auto-complete a little bit when setting a value directly. commit 1a182bbdab237c89d355d8294b5a4a64b785783a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 13:08:29 2021 -0400 fix text color when value is set. There are still some bugs relating to multiple copies of the value being stored. commit 49c0bc15c73446259d8cc151cf52d6058644db76 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 12:09:44 2021 -0400 reset all controls first. commit 059797ad85b057e296cc707b4645f839bfccac13 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 10:52:06 2021 -0400 more bookmark loading. commit e5a612d9f8e7414dd15c66dbaa540b637765eeec Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:38 2021 -0400 bookmark - restore the software commit f9411a1e84df7bd46e352cc5ca995b585c2a0523 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:25 2021 -0400 clean up software / name logic. commit f628d99e4a70d65ea8703f3c182103cd3bfea969 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:21:08 2021 -0400 load bookmark... commit 0b248e6aad16cba848f88d294a1366cea5760aa0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:20:42 2021 -0400 stringValue can't be nil. commit 94aac38af45c3c95cb86b176393a469279c2539e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:04:37 2021 -0400 add bookmark menu commit 6215a0df120b6cd97f1ffea2d2db9aaa5ae61f29 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:03:29 2021 -0400 slot view needs to know the machine. commit d348c15dc56d9cee01e5417435dd236e0e541902 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:58 2021 -0400 transformer to enable/disable control based on string length. commit e14336a0094af7aa84e91da69ff59ebb9e8eea9b Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:14 2021 -0400 shut up compiler warning. commit 4baf545245d8d3debf8f436b36b14cca23bf7a33 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:01:15 2021 -0400 bookmark manager commit 0f3e6c83075a145a456728b57a499cfa35707002 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 23:54:29 2021 -0400 more (untested) bookmark code commit 8fdb149eb38952b13c4a78d7a6940c43d90870f1 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:13:43 2021 -0400 start of bookmarking support. Untested. commit 787eac87f6ac13cd677630cbaf2538cecab27b1f Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:12:45 2021 -0400 shut up warnings about content clipping. maybe it's a 10.11 thing. The size was chosen by interface builder.
2021-06-07 04:34:26 +00:00
if (!_loadingBookmark) {
[self rebuildMedia];
[self rebuildArgs];
}
2020-09-11 02:06:41 +00:00
}
-(void)setMachine: (NSString *)machine {
if (_machine == machine) return;
if (_machine && machine && [machine compare: _machine] == NSOrderedSame) return;
_machine = machine;
if (!machine) {
[self resetMachine];
return;
}
[self loadMachine];
}
-(void)rebuildMedia {
Media media = EmptyMedia;
for (unsigned i = 0; i < MAX_SLOTS; ++i) {
MediaAdd(&media, &_slot_media[i]);
2020-09-11 02:06:41 +00:00
}
// machine media last.
MediaAdd(&media, &_machine_media);
[self setMedia: media];
2020-09-11 02:06:41 +00:00
}
2020-09-11 02:06:41 +00:00
-(void)rebuildArgs {
NSMutableArray *args = [NSMutableArray new];
for (Slot *item in _root) {
2020-09-11 02:06:41 +00:00
NSArray *x = [item args];
if (x) [args addObjectsFromArray: x];
2020-09-11 02:06:41 +00:00
}
2020-09-11 02:06:41 +00:00
[self setArgs: args];
}
- (IBAction)menuChanged:(NSPopUpButton *)sender {
BOOL direct = YES;
NSInteger index = [sender tag];
if (index < 0x10000) {
direct = YES;
} else {
direct = NO;
index &= ~0x10000;
}
index--;
if (index < 0 || index >= MAX_SLOTS) return; //
2020-09-11 02:06:41 +00:00
SlotOption *o = [[sender selectedItem] representedObject];
Slot *item = [_root objectAtIndex: index];
2020-09-11 02:06:41 +00:00
if (direct && [item type] != kSlotBIOS) {
NSString *name = [item name];
NSString *value = [o value];
[_slotValues setObject: value forKey: name];
}
2020-09-11 02:06:41 +00:00
Media media = [item selectedMedia];
if (!MediaEqual(&media, &_slot_media[index])) {
_slot_media[index] = media;
2020-09-11 02:06:41 +00:00
[self rebuildMedia];
}
// needs to reload children if expanded.
2021-03-13 00:58:12 +00:00
#ifdef SLOT_TREE
if (direct) {
BOOL rc = ([_outlineView isItemExpanded: item]);
[_outlineView reloadItem: item reloadChildren: rc];
}
2021-03-13 00:58:12 +00:00
#endif
2020-09-11 02:06:41 +00:00
[self rebuildArgs];
}
- (IBAction)hamburger:(id)sender {
2021-03-13 00:58:12 +00:00
#if 0
if ([_popover isShown]) {
[_popover close];
}
#endif
2021-03-13 00:58:12 +00:00
NSInteger index = [sender tag];
if (index <= 0 || index >= 0x10000) return;
index--;
Slot *item = [_root objectAtIndex: index];
2021-03-13 00:58:12 +00:00
NSArray *children = [item selectedChildren];
objc_setAssociatedObject(_childOutlineView, &RootKey, children, OBJC_ASSOCIATION_RETAIN);
if (!children) return;
[_childOutlineView reloadData];
NSSize size = [_popover contentSize];
if (size.width < 200) size.width = 250;
size = [_childOutlineView sizeThatFits: size];
size.height += 40;
[_popover setContentSize: size];
[_popover showRelativeToRect: [sender bounds]
ofView: sender
2021-03-13 00:58:12 +00:00
preferredEdge: NSRectEdgeMaxY];
}
2020-09-11 02:06:41 +00:00
-(IBAction)resetSlots:(id)sender {
//_slots_explicit = 0;
for (unsigned i = 0; i < MAX_SLOTS; ++i) {
_slot_media[i] = EmptyMedia;
2020-09-11 02:06:41 +00:00
}
for (Slot *item in _root) {
NSString *name = [item name];
[_slotValues removeObjectForKey: name];
2020-09-11 02:06:41 +00:00
[item reset];
// if children, reset them too...
NSInteger index = [item index] - 1;
if (index < 0) continue;
2020-09-11 02:06:41 +00:00
_slot_media[index] = [item selectedMedia];
}
2021-03-13 00:58:12 +00:00
#ifdef SLOT_TREE
[_outlineView reloadData];
2021-03-13 00:58:12 +00:00
#endif
Squashed commit of the following: commit 78c81626670fdf41fa6bdd71a4243a89a0746615 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon Jun 7 00:33:48 2021 -0400 check if software set has a particular entry. commit ef5ab6b6948dc3bbbe2947ea099fcacd08435e86 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 22:20:34 2021 -0400 fix scroller background on recent disk images window. commit dee56fa50e87299b396b48361bd0a780aaaaa768 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 21:26:23 2021 -0400 update cheat sheet javascript to work with 10.11 * => functions not supported * NodeList.prototype.forEach not supported. commit b00cc05413f4ebd6d6d58f96e24303008608f3a6 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 17:10:41 2021 -0400 default full machine name for bookmark entry. commit a671cafdc98051b56b12cdd3ccd13c22f54f605a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:39:32 2021 -0400 loading a bookmark wasn't updating the media. commit 3000e0eb1b10bede3345aaab8478e9ec209f328c Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:38:53 2021 -0400 bump copyright year. commit 45222dacd4aa0047fae63a9112509de57139df63 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:38:23 2021 -0400 add reset w/ value for setting the item explicitely. commit cc7fde1253b71c4d8655eb4c010bbf4e61333a15 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:37:48 2021 -0400 add checkboxes for bitbanger/share directory. The general idea is it's easier to toggle a checkbox than to type/retype a path. commit 5674b2d7f6b0e2f0b973197bf3493ad61bf46428 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:43 2021 -0400 commentary on searches with diacritics. commit ec60634dcd9c573130dc34673b4d3fe597ea2b42 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:22 2021 -0400 clean up auto-complete a little bit when setting a value directly. commit 1a182bbdab237c89d355d8294b5a4a64b785783a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 13:08:29 2021 -0400 fix text color when value is set. There are still some bugs relating to multiple copies of the value being stored. commit 49c0bc15c73446259d8cc151cf52d6058644db76 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 12:09:44 2021 -0400 reset all controls first. commit 059797ad85b057e296cc707b4645f839bfccac13 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 10:52:06 2021 -0400 more bookmark loading. commit e5a612d9f8e7414dd15c66dbaa540b637765eeec Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:38 2021 -0400 bookmark - restore the software commit f9411a1e84df7bd46e352cc5ca995b585c2a0523 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:25 2021 -0400 clean up software / name logic. commit f628d99e4a70d65ea8703f3c182103cd3bfea969 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:21:08 2021 -0400 load bookmark... commit 0b248e6aad16cba848f88d294a1366cea5760aa0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:20:42 2021 -0400 stringValue can't be nil. commit 94aac38af45c3c95cb86b176393a469279c2539e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:04:37 2021 -0400 add bookmark menu commit 6215a0df120b6cd97f1ffea2d2db9aaa5ae61f29 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:03:29 2021 -0400 slot view needs to know the machine. commit d348c15dc56d9cee01e5417435dd236e0e541902 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:58 2021 -0400 transformer to enable/disable control based on string length. commit e14336a0094af7aa84e91da69ff59ebb9e8eea9b Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:14 2021 -0400 shut up compiler warning. commit 4baf545245d8d3debf8f436b36b14cca23bf7a33 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:01:15 2021 -0400 bookmark manager commit 0f3e6c83075a145a456728b57a499cfa35707002 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 23:54:29 2021 -0400 more (untested) bookmark code commit 8fdb149eb38952b13c4a78d7a6940c43d90870f1 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:13:43 2021 -0400 start of bookmarking support. Untested. commit 787eac87f6ac13cd677630cbaf2538cecab27b1f Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:12:45 2021 -0400 shut up warnings about content clipping. maybe it's a 10.11 thing. The size was chosen by interface builder.
2021-06-07 04:34:26 +00:00
if (!_loadingBookmark) {
[self rebuildMedia];
[self rebuildArgs];
}
2020-09-11 02:06:41 +00:00
}
@end
2021-05-30 22:19:51 +00:00
@implementation SlotViewController (OutlineView)
2020-09-11 02:06:41 +00:00
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
2021-03-13 00:58:12 +00:00
NSArray *root = objc_getAssociatedObject(outlineView, &RootKey);
if (!item) return [root count];
2020-09-11 02:06:41 +00:00
2021-03-13 00:58:12 +00:00
#ifdef SLOT_TREE
NSArray *tmp = [(Slot *)item selectedChildren];
return [tmp count];
2021-03-13 00:58:12 +00:00
#endif
return 0;
2020-09-11 02:06:41 +00:00
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
2021-03-13 00:58:12 +00:00
NSArray *root = objc_getAssociatedObject(outlineView, &RootKey);
if (!item) return [root objectAtIndex: index];
#ifdef SLOT_TREE
NSArray *tmp = [(Slot *)item selectedChildren];
return [tmp objectAtIndex: index];
2021-03-13 00:58:12 +00:00
#endif
2020-09-11 02:06:41 +00:00
return nil;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
2021-03-13 00:58:12 +00:00
#ifdef SLOT_TREE
if (!item) return NO;
NSArray *tmp = [(Slot *)item selectedChildren];
return [tmp count] > 0;
2021-03-13 00:58:12 +00:00
#else
return NO;
#endif
2020-09-11 02:06:41 +00:00
}
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(Slot *)item {
2020-09-11 02:06:41 +00:00
SlotTableCellView *v = [outlineView makeViewWithIdentifier: @"MenuCell" owner: self];
[item prepareView: v];
return v;
}
Squashed commit of the following: commit 78c81626670fdf41fa6bdd71a4243a89a0746615 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon Jun 7 00:33:48 2021 -0400 check if software set has a particular entry. commit ef5ab6b6948dc3bbbe2947ea099fcacd08435e86 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 22:20:34 2021 -0400 fix scroller background on recent disk images window. commit dee56fa50e87299b396b48361bd0a780aaaaa768 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 21:26:23 2021 -0400 update cheat sheet javascript to work with 10.11 * => functions not supported * NodeList.prototype.forEach not supported. commit b00cc05413f4ebd6d6d58f96e24303008608f3a6 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 17:10:41 2021 -0400 default full machine name for bookmark entry. commit a671cafdc98051b56b12cdd3ccd13c22f54f605a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:39:32 2021 -0400 loading a bookmark wasn't updating the media. commit 3000e0eb1b10bede3345aaab8478e9ec209f328c Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:38:53 2021 -0400 bump copyright year. commit 45222dacd4aa0047fae63a9112509de57139df63 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:38:23 2021 -0400 add reset w/ value for setting the item explicitely. commit cc7fde1253b71c4d8655eb4c010bbf4e61333a15 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:37:48 2021 -0400 add checkboxes for bitbanger/share directory. The general idea is it's easier to toggle a checkbox than to type/retype a path. commit 5674b2d7f6b0e2f0b973197bf3493ad61bf46428 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:43 2021 -0400 commentary on searches with diacritics. commit ec60634dcd9c573130dc34673b4d3fe597ea2b42 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:22 2021 -0400 clean up auto-complete a little bit when setting a value directly. commit 1a182bbdab237c89d355d8294b5a4a64b785783a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 13:08:29 2021 -0400 fix text color when value is set. There are still some bugs relating to multiple copies of the value being stored. commit 49c0bc15c73446259d8cc151cf52d6058644db76 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 12:09:44 2021 -0400 reset all controls first. commit 059797ad85b057e296cc707b4645f839bfccac13 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 10:52:06 2021 -0400 more bookmark loading. commit e5a612d9f8e7414dd15c66dbaa540b637765eeec Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:38 2021 -0400 bookmark - restore the software commit f9411a1e84df7bd46e352cc5ca995b585c2a0523 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:25 2021 -0400 clean up software / name logic. commit f628d99e4a70d65ea8703f3c182103cd3bfea969 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:21:08 2021 -0400 load bookmark... commit 0b248e6aad16cba848f88d294a1366cea5760aa0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:20:42 2021 -0400 stringValue can't be nil. commit 94aac38af45c3c95cb86b176393a469279c2539e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:04:37 2021 -0400 add bookmark menu commit 6215a0df120b6cd97f1ffea2d2db9aaa5ae61f29 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:03:29 2021 -0400 slot view needs to know the machine. commit d348c15dc56d9cee01e5417435dd236e0e541902 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:58 2021 -0400 transformer to enable/disable control based on string length. commit e14336a0094af7aa84e91da69ff59ebb9e8eea9b Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:14 2021 -0400 shut up compiler warning. commit 4baf545245d8d3debf8f436b36b14cca23bf7a33 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:01:15 2021 -0400 bookmark manager commit 0f3e6c83075a145a456728b57a499cfa35707002 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 23:54:29 2021 -0400 more (untested) bookmark code commit 8fdb149eb38952b13c4a78d7a6940c43d90870f1 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:13:43 2021 -0400 start of bookmarking support. Untested. commit 787eac87f6ac13cd677630cbaf2538cecab27b1f Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:12:45 2021 -0400 shut up warnings about content clipping. maybe it's a 10.11 thing. The size was chosen by interface builder.
2021-06-07 04:34:26 +00:00
@end
@implementation SlotViewController (Bookmark)
-(void)willLoadBookmark:(NSDictionary *)bookmark {
_loadingBookmark = YES;
[self setMachine: nil];
}
-(void)didLoadBookmark:(NSDictionary *)bookmark {
_loadingBookmark = NO;
[self rebuildArgs];
}
-(BOOL)loadBookmark: (NSDictionary *)bookmark {
NSDictionary *dict = [bookmark objectForKey: @"slots"];
[self setMachine: [bookmark objectForKey: @"machine"]];
[self resetSlots: nil];
for (Slot *item in _root) {
[item reserialize: dict];
NSInteger index = [item index] - 1;
if (index >= 0 && index < MAX_SLOTS) {
NSString *name = [item name];
[_slotValues removeObjectForKey: name];
if ([item defaultIndex] != [item selectedIndex]) {
NSString *v = [item selectedValue];
if (v) [_slotValues setObject: v forKey: name];
}
Squashed commit of the following: commit 78c81626670fdf41fa6bdd71a4243a89a0746615 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon Jun 7 00:33:48 2021 -0400 check if software set has a particular entry. commit ef5ab6b6948dc3bbbe2947ea099fcacd08435e86 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 22:20:34 2021 -0400 fix scroller background on recent disk images window. commit dee56fa50e87299b396b48361bd0a780aaaaa768 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 21:26:23 2021 -0400 update cheat sheet javascript to work with 10.11 * => functions not supported * NodeList.prototype.forEach not supported. commit b00cc05413f4ebd6d6d58f96e24303008608f3a6 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 17:10:41 2021 -0400 default full machine name for bookmark entry. commit a671cafdc98051b56b12cdd3ccd13c22f54f605a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:39:32 2021 -0400 loading a bookmark wasn't updating the media. commit 3000e0eb1b10bede3345aaab8478e9ec209f328c Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:38:53 2021 -0400 bump copyright year. commit 45222dacd4aa0047fae63a9112509de57139df63 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:38:23 2021 -0400 add reset w/ value for setting the item explicitely. commit cc7fde1253b71c4d8655eb4c010bbf4e61333a15 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:37:48 2021 -0400 add checkboxes for bitbanger/share directory. The general idea is it's easier to toggle a checkbox than to type/retype a path. commit 5674b2d7f6b0e2f0b973197bf3493ad61bf46428 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:43 2021 -0400 commentary on searches with diacritics. commit ec60634dcd9c573130dc34673b4d3fe597ea2b42 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:22 2021 -0400 clean up auto-complete a little bit when setting a value directly. commit 1a182bbdab237c89d355d8294b5a4a64b785783a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 13:08:29 2021 -0400 fix text color when value is set. There are still some bugs relating to multiple copies of the value being stored. commit 49c0bc15c73446259d8cc151cf52d6058644db76 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 12:09:44 2021 -0400 reset all controls first. commit 059797ad85b057e296cc707b4645f839bfccac13 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 10:52:06 2021 -0400 more bookmark loading. commit e5a612d9f8e7414dd15c66dbaa540b637765eeec Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:38 2021 -0400 bookmark - restore the software commit f9411a1e84df7bd46e352cc5ca995b585c2a0523 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:25 2021 -0400 clean up software / name logic. commit f628d99e4a70d65ea8703f3c182103cd3bfea969 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:21:08 2021 -0400 load bookmark... commit 0b248e6aad16cba848f88d294a1366cea5760aa0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:20:42 2021 -0400 stringValue can't be nil. commit 94aac38af45c3c95cb86b176393a469279c2539e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:04:37 2021 -0400 add bookmark menu commit 6215a0df120b6cd97f1ffea2d2db9aaa5ae61f29 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:03:29 2021 -0400 slot view needs to know the machine. commit d348c15dc56d9cee01e5417435dd236e0e541902 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:58 2021 -0400 transformer to enable/disable control based on string length. commit e14336a0094af7aa84e91da69ff59ebb9e8eea9b Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:14 2021 -0400 shut up compiler warning. commit 4baf545245d8d3debf8f436b36b14cca23bf7a33 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:01:15 2021 -0400 bookmark manager commit 0f3e6c83075a145a456728b57a499cfa35707002 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 23:54:29 2021 -0400 more (untested) bookmark code commit 8fdb149eb38952b13c4a78d7a6940c43d90870f1 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:13:43 2021 -0400 start of bookmarking support. Untested. commit 787eac87f6ac13cd677630cbaf2538cecab27b1f Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:12:45 2021 -0400 shut up warnings about content clipping. maybe it's a 10.11 thing. The size was chosen by interface builder.
2021-06-07 04:34:26 +00:00
_slot_media[index] = [item selectedMedia];
}
}
// need to do it here so it propogate to media view.
[self rebuildMedia];
return YES;
}
-(BOOL)saveBookmark: (NSMutableDictionary *)bookmark {
NSMutableDictionary *slots = [NSMutableDictionary new];
for (Slot *item in _root) {
NSDictionary *d = [item serialize];
[slots addEntriesFromDictionary: d];
}
[bookmark setObject: slots forKey: @"slots"];
return YES;
}
2020-09-11 02:06:41 +00:00
@end