Fleshed out LauncherController, progress display, etc
This commit is contained in:
parent
60440e1f36
commit
577928c588
|
@ -8,6 +8,11 @@
|
|||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="FBLauncherController">
|
||||
<connections>
|
||||
<outlet property="progressPanel" destination="hEA-LJ-CM5" id="orM-UI-yKC"/>
|
||||
<outlet property="progressPanelBar" destination="CGz-AO-sJG" id="fqP-zG-MPD"/>
|
||||
<outlet property="progressPanelCancelButton" destination="QBI-GE-Mwp" id="iAB-1p-RwW"/>
|
||||
<outlet property="progressPanelLabel" destination="wTx-rb-XUh" id="aBh-BZ-oN9"/>
|
||||
<outlet property="romSetTreeController" destination="IZb-g9-uEr" id="LXG-Ox-P93"/>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="qj1-RH-US7"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
|
@ -23,124 +28,70 @@
|
|||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uLN-UU-wUx">
|
||||
<rect key="frame" x="-1" y="-1" width="596" height="520"/>
|
||||
<rect key="frame" x="-1" y="-1" width="596" height="551"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" ambiguous="YES" id="Dhm-mF-Mxw">
|
||||
<rect key="frame" x="1" y="0.0" width="594" height="504"/>
|
||||
<rect key="frame" x="1" y="0.0" width="594" height="550"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<outlineView verticalHuggingPriority="750" ambiguous="YES" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="3Ac-aF-wVK" viewBased="YES" indentationPerLevel="16" outlineTableColumn="SfF-mw-sk3" id="LI1-S9-omw">
|
||||
<rect key="frame" x="0.0" y="0.0" width="670" height="479"/>
|
||||
<outlineView verticalHuggingPriority="750" ambiguous="YES" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" headerView="3Ac-aF-wVK" indentationPerLevel="16" outlineTableColumn="SfF-mw-sk3" id="LI1-S9-omw">
|
||||
<rect key="frame" x="0.0" y="0.0" width="594" height="525"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
|
||||
<tableColumns>
|
||||
<tableColumn width="73" minWidth="40" maxWidth="1000" id="sYe-77-mxg">
|
||||
<tableColumn editable="NO" width="73" minWidth="40" maxWidth="1000" id="sYe-77-mxg">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Status">
|
||||
<font key="font" metaFont="controlContent" size="11"/>
|
||||
<font key="font" metaFont="menu" size="11"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="dxk-DU-Pc5">
|
||||
<font key="font" metaFont="system"/>
|
||||
<font key="font" metaFont="menu" size="11"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView id="G0o-BL-fEc">
|
||||
<rect key="frame" x="1" y="1" width="73" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="P41-Ze-mFl">
|
||||
<rect key="frame" x="0.0" y="0.0" width="73" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="5th-SY-uoN">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="P41-Ze-mFl" id="IM4-jm-scW"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn width="116" minWidth="40" maxWidth="1000" id="SfF-mw-sk3">
|
||||
<tableColumn editable="NO" width="116" minWidth="40" maxWidth="1000" id="SfF-mw-sk3">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Name">
|
||||
<font key="font" metaFont="controlContent" size="11"/>
|
||||
<font key="font" metaFont="menu" size="11"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="AVl-5b-hSg">
|
||||
<font key="font" metaFont="system"/>
|
||||
<font key="font" metaFont="menu" size="11"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView id="nTd-r4-t77">
|
||||
<rect key="frame" x="77" y="1" width="116" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="69H-09-gNW">
|
||||
<rect key="frame" x="0.0" y="0.0" width="116" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="5tS-O3-h9a">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="69H-09-gNW" id="7zA-Sp-suK"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
<connections>
|
||||
<binding destination="IZb-g9-uEr" name="value" keyPath="arrangedObjects.name" id="sC4-4h-dIP"/>
|
||||
</connections>
|
||||
</tableColumn>
|
||||
<tableColumn width="472" minWidth="40" maxWidth="1000" id="HLR-VA-LE2">
|
||||
<tableColumn editable="NO" width="396" minWidth="40" maxWidth="1000" id="HLR-VA-LE2">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Title">
|
||||
<font key="font" metaFont="controlContent" size="11"/>
|
||||
<font key="font" metaFont="menu" size="11"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="Qf5-Np-ORW">
|
||||
<font key="font" metaFont="system"/>
|
||||
<font key="font" metaFont="menu" size="11"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView id="k2X-2G-SYa">
|
||||
<rect key="frame" x="196" y="1" width="472" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="g23-ZF-WrL">
|
||||
<rect key="frame" x="0.0" y="0.0" width="472" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="orb-Hs-gwr">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="g23-ZF-WrL" id="zLH-3d-nqm"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
<connections>
|
||||
<binding destination="IZb-g9-uEr" name="value" keyPath="arrangedObjects.title" id="kha-1D-9gI"/>
|
||||
</connections>
|
||||
</tableColumn>
|
||||
</tableColumns>
|
||||
</outlineView>
|
||||
</subviews>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="GKm-KM-6zH">
|
||||
<rect key="frame" x="1" y="504" width="594" height="15"/>
|
||||
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="GKm-KM-6zH">
|
||||
<rect key="frame" x="1" y="535" width="594" height="15"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="AXN-0R-j49">
|
||||
|
@ -148,27 +99,82 @@
|
|||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<tableHeaderView key="headerView" id="3Ac-aF-wVK">
|
||||
<rect key="frame" x="0.0" y="0.0" width="670" height="25"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="594" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</tableHeaderView>
|
||||
</scrollView>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="A6i-4x-jXw">
|
||||
<rect key="frame" x="14" y="521" width="81" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="vWH-LE-9g7">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="hiya:" target="-2" id="Rqv-xR-dJI"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<toolbar key="toolbar" implicitIdentifier="45801F3E-846E-4D62-9F9C-403E0D3C379B" autosavesConfiguration="NO" displayMode="iconAndLabel" sizeMode="regular" id="9cL-0S-sWb">
|
||||
<allowedToolbarItems>
|
||||
<toolbarItem implicitItemIdentifier="NSToolbarShowColorsItem" id="rRr-0R-A7H"/>
|
||||
<toolbarItem implicitItemIdentifier="NSToolbarShowFontsItem" id="B2k-1t-iyn"/>
|
||||
<toolbarItem implicitItemIdentifier="NSToolbarPrintItem" id="gMd-QL-JPh"/>
|
||||
<toolbarItem implicitItemIdentifier="NSToolbarSpaceItem" id="p3s-o2-ixw"/>
|
||||
<toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="ZKR-9D-uds"/>
|
||||
</allowedToolbarItems>
|
||||
<defaultToolbarItems>
|
||||
<toolbarItem reference="rRr-0R-A7H"/>
|
||||
<toolbarItem reference="B2k-1t-iyn"/>
|
||||
<toolbarItem reference="ZKR-9D-uds"/>
|
||||
<toolbarItem reference="gMd-QL-JPh"/>
|
||||
</defaultToolbarItems>
|
||||
</toolbar>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="uIo-I6-8Np"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="192" y="209.5"/>
|
||||
</window>
|
||||
<treeController objectClassName="NSDictionary" editable="NO" childrenKeyPath="subsets" id="IZb-g9-uEr">
|
||||
<connections>
|
||||
<binding destination="-2" name="contentArray" keyPath="romSets" id="i4j-NI-FYk"/>
|
||||
<binding destination="Mk3-du-Xcu" name="sortDescriptors" keyPath="values.romSetSortDescriptor" id="XzZ-ve-L7D">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSUnarchiveFromData</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</treeController>
|
||||
<userDefaultsController representsSharedInstance="YES" id="Mk3-du-Xcu"/>
|
||||
<window title="Import in Progress..." allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="hEA-LJ-CM5" customClass="NSPanel">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" utility="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="272" y="172" width="407" height="86"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||
<view key="contentView" id="epq-bd-srL">
|
||||
<rect key="frame" x="0.0" y="0.0" width="407" height="86"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<progressIndicator wantsLayer="YES" fixedFrame="YES" maxValue="1" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="CGz-AO-sJG">
|
||||
<rect key="frame" x="20" y="33" width="289" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
</progressIndicator>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wTx-rb-XUh">
|
||||
<rect key="frame" x="18" y="60" width="319" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="ziH-TJ-CzP">
|
||||
<font key="font" metaFont="menu" size="11"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QBI-GE-Mwp">
|
||||
<rect key="frame" x="312" y="28" width="80" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="ChL-9J-tsE">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu" size="11"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
Gw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="cancelProgress:" target="-2" id="rdI-OE-fwp"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="147" y="682"/>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
||||
|
|
|
@ -94,6 +94,12 @@
|
|||
</menu>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="m54-Is-iLE"/>
|
||||
<menuItem title="Rescan sets..." keyEquivalent="R" id="A6k-Dm-n7z">
|
||||
<connections>
|
||||
<action selector="rescanSets:" target="-1" id="uPw-AG-YhZ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="yui-D6-pxa"/>
|
||||
<menuItem title="Close" keyEquivalent="w" id="DVo-aG-piG">
|
||||
<connections>
|
||||
<action selector="performClose:" target="-1" id="HmO-Ls-i7Q"/>
|
||||
|
|
|
@ -12,8 +12,17 @@
|
|||
|
||||
@interface FBLauncherController : NSWindowController<FBScannerDelegate>
|
||||
{
|
||||
IBOutlet NSPanel *progressPanel;
|
||||
IBOutlet NSProgressIndicator *progressPanelBar;
|
||||
IBOutlet NSButton *progressPanelCancelButton;
|
||||
IBOutlet NSTextField *progressPanelLabel;
|
||||
|
||||
IBOutlet NSTreeController *romSetTreeController;
|
||||
}
|
||||
|
||||
- (IBAction) hiya:(id) sender;
|
||||
- (IBAction) rescanSets:(id) sender;
|
||||
- (IBAction) cancelProgress:(id) sender;
|
||||
|
||||
@property (readonly) NSArray<NSDictionary *> *romSets;
|
||||
|
||||
@end
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
#import "AppDelegate.h"
|
||||
#import "NSWindowController+Core.h"
|
||||
|
||||
@interface FBLauncherController ()
|
||||
|
||||
- (void) reloadSets:(NSArray<FBROMSet *> *) romSets;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLauncherController
|
||||
{
|
||||
FBScanner *scanner;
|
||||
|
@ -19,6 +25,7 @@
|
|||
- (id) init
|
||||
{
|
||||
if (self = [super initWithWindowNibName:@"Launcher"]) {
|
||||
_romSets = [NSMutableArray new];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -28,37 +35,123 @@
|
|||
{
|
||||
}
|
||||
|
||||
- (void) hiya:(id) sender
|
||||
{
|
||||
// FIXME!!
|
||||
// FIXME!!
|
||||
if (!scanner) {
|
||||
scanner = [FBScanner new];
|
||||
scanner.rootPath = AppDelegate.sharedInstance.romPath;
|
||||
scanner.delegate = self;
|
||||
[scanner start];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - NSWindowDelegate
|
||||
|
||||
- (void) windowWillLoad
|
||||
{
|
||||
if (_romSets.count == 0)
|
||||
[self rescanSets:self];
|
||||
}
|
||||
|
||||
- (void) windowWillClose:(NSNotification *) notification
|
||||
{
|
||||
[scanner cancel];
|
||||
scanner = nil;
|
||||
@synchronized (self) {
|
||||
[scanner cancel];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - FBScannerDelegate
|
||||
|
||||
- (void) scanDidStart
|
||||
{
|
||||
NSLog(@"scan started");
|
||||
progressPanelBar.doubleValue = 0;
|
||||
progressPanelLabel.stringValue = NSLocalizedString(@"Scanning...", nil);
|
||||
progressPanelCancelButton.enabled = YES;
|
||||
|
||||
[NSApp beginSheet:progressPanel
|
||||
modalForWindow:[self window]
|
||||
modalDelegate:self
|
||||
didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
|
||||
contextInfo:nil];
|
||||
}
|
||||
|
||||
- (void) scanDidEnd
|
||||
- (void) progressDidUpdate:(float) progress
|
||||
{
|
||||
scanner = nil;
|
||||
NSLog(@"scan ended");
|
||||
progressPanelBar.doubleValue = progress;
|
||||
}
|
||||
|
||||
- (void) scanDidEnd:(NSArray<FBROMSet *> *) romSets
|
||||
{
|
||||
@synchronized (self) {
|
||||
scanner = nil;
|
||||
}
|
||||
|
||||
[NSApp endSheet:progressPanel];
|
||||
|
||||
if (!romSets)
|
||||
return; // Cancelled, or otherwise failed
|
||||
|
||||
[self reloadSets:romSets];
|
||||
[romSetTreeController rearrangeObjects];
|
||||
}
|
||||
|
||||
#pragma mark - Callbacks
|
||||
|
||||
- (void) didEndSheet:(NSWindow *) sheet
|
||||
returnCode:(NSInteger) returnCode
|
||||
contextInfo:(void *) contextInfo
|
||||
{
|
||||
[sheet orderOut:self];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void) rescanSets:(id) sender
|
||||
{
|
||||
@synchronized (self) {
|
||||
if (!scanner) {
|
||||
scanner = [FBScanner new];
|
||||
scanner.rootPath = AppDelegate.sharedInstance.romPath;
|
||||
scanner.delegate = self;
|
||||
[scanner start];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) cancelProgress:(id) sender
|
||||
{
|
||||
progressPanelCancelButton.enabled = NO;
|
||||
progressPanelLabel.stringValue = NSLocalizedString(@"Cancelling...", nil);
|
||||
|
||||
@synchronized (self) {
|
||||
[scanner cancel];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (void) reloadSets:(NSArray<FBROMSet *> *) romSets
|
||||
{
|
||||
// Clear the master list
|
||||
[(NSMutableArray *) _romSets removeAllObjects];
|
||||
|
||||
// First, sweep the sets and add root-level sets to the master list,
|
||||
// and child sets to respective sub-list
|
||||
NSMutableDictionary<NSString *, NSMutableArray *> *childSetsByName = [NSMutableDictionary new];
|
||||
[romSets enumerateObjectsUsingBlock:^(FBROMSet *obj, NSUInteger idx, BOOL *stop) {
|
||||
NSDictionary *set = @{
|
||||
@"name": obj.name,
|
||||
@"title": obj.title,
|
||||
@"subsets": [NSMutableArray new],
|
||||
};
|
||||
if (!obj.parent)
|
||||
[(NSMutableArray *)_romSets addObject:set];
|
||||
else {
|
||||
NSMutableArray *childSet = childSetsByName[obj.parent];
|
||||
if (!childSet) {
|
||||
childSet = [NSMutableArray new];
|
||||
childSetsByName[obj.parent] = childSet;
|
||||
}
|
||||
[childSet addObject:set];
|
||||
}
|
||||
}];
|
||||
|
||||
// Sweep through master list and add any child sets
|
||||
[_romSets enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) {
|
||||
NSArray *children = childSetsByName[obj[@"name"]];
|
||||
if (children)
|
||||
[obj[@"subsets"] addObjectsFromArray:children];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#define FBROMSET_STATUS_OK 0
|
||||
|
||||
@interface FBROMSet: NSObject
|
||||
@interface FBROMSet: NSObject<NSCoding>
|
||||
|
||||
@property NSString *parent;
|
||||
@property NSString *name;
|
||||
|
@ -24,7 +24,7 @@
|
|||
@optional
|
||||
- (void) scanDidStart;
|
||||
- (void) progressDidUpdate:(float) progress;
|
||||
- (void) scanDidEnd;
|
||||
- (void) scanDidEnd:(NSArray<FBROMSet *> *) romSets;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -23,6 +23,28 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - NSCoding
|
||||
|
||||
- (instancetype) initWithCoder:(NSCoder *) coder
|
||||
{
|
||||
if ((self = [super init]) != nil) {
|
||||
_parent = [coder decodeObjectForKey:@"parent"];
|
||||
_name = [coder decodeObjectForKey:@"name"];
|
||||
_title = [coder decodeObjectForKey:@"title"];
|
||||
_status = (unsigned char) [coder decodeIntForKey:@"status"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder:(NSCoder *) coder
|
||||
{
|
||||
[coder encodeObject:_parent forKey:@"parent"];
|
||||
[coder encodeObject:_name forKey:@"name"];
|
||||
[coder encodeObject:_title forKey:@"title"];
|
||||
[coder encodeInt:(int) _status forKey:@"status"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - FBScanner
|
||||
|
@ -44,11 +66,6 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
NSLog(@"Cleaning up");
|
||||
}
|
||||
|
||||
#pragma mark - NSThread
|
||||
|
||||
- (void) main
|
||||
|
@ -63,6 +80,7 @@
|
|||
if ([del respondsToSelector:@selector(scanDidStart)])
|
||||
dispatch_async(dispatch_get_main_queue(), ^{ [del scanDidStart]; });
|
||||
|
||||
NSMutableArray<FBROMSet *> *romSets = [NSMutableArray new];
|
||||
UINT32 originallyActive = nBurnDrvActive;
|
||||
for (unsigned int i = 0; i < nBurnDrvCount && !self.cancelled; i++) {
|
||||
FBROMSet *set = [self newRomSetWithIndex:i];
|
||||
|
@ -79,11 +97,14 @@
|
|||
set.status = BzipOpen(TRUE);
|
||||
BzipClose();
|
||||
nBurnDrvActive = originallyActive;
|
||||
|
||||
[romSets addObject:set];
|
||||
}
|
||||
|
||||
NSArray<FBROMSet *> *doneSets = (!self.isCancelled) ? romSets : nil;
|
||||
del = _delegate;
|
||||
if ([del respondsToSelector:@selector(scanDidEnd)])
|
||||
dispatch_async(dispatch_get_main_queue(), ^{ [del scanDidEnd]; });
|
||||
if ([del respondsToSelector:@selector(scanDidEnd:)])
|
||||
dispatch_async(dispatch_get_main_queue(), ^{ [del scanDidEnd:doneSets]; });
|
||||
}
|
||||
|
||||
- (FBROMSet *) newRomSetWithIndex:(int) index
|
||||
|
|
Loading…
Reference in New Issue