mirror of https://github.com/LIJI32/SameBoy.git
Make palettes upgradable in the Cocoa frontend, fixes #672. Slightly improve palette editor UI.
This commit is contained in:
parent
a659de9960
commit
4d28af4fcf
|
@ -22,5 +22,6 @@
|
|||
@property (strong) IBOutlet NSButton *updateProgressButton;
|
||||
@property (strong) IBOutlet NSWindow *updateProgressWindow;
|
||||
@property (strong) IBOutlet NSProgressIndicator *updateProgressSpinner;
|
||||
- (void)updateThemesDefault:(bool)overwrite;
|
||||
@end
|
||||
|
||||
|
|
|
@ -235,6 +235,27 @@ static uint32_t color_to_int(NSColor *color)
|
|||
if ([[NSProcessInfo processInfo].arguments containsObject:@"--update-launch"]) {
|
||||
[NSApp activateIgnoringOtherApps:true];
|
||||
}
|
||||
|
||||
if (![[[NSUserDefaults standardUserDefaults] stringForKey:@"GBThemesVersion"] isEqualToString:@(GB_VERSION)]) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@(GB_VERSION) forKey:@"GBThemesVersion"];
|
||||
[self updateThemesDefault:false];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateThemesDefault:(bool)overwrite
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSMutableDictionary *currentThemes = [defaults dictionaryForKey:@"GBThemes"].mutableCopy;
|
||||
[defaults removeObjectForKey:@"GBThemes"];
|
||||
NSMutableDictionary *defaultThemes = [defaults dictionaryForKey:@"GBThemes"].mutableCopy;
|
||||
if (overwrite) {
|
||||
[currentThemes addEntriesFromDictionary:defaultThemes];
|
||||
[defaults setObject:currentThemes forKey:@"GBThemes"];
|
||||
}
|
||||
else {
|
||||
[defaultThemes addEntriesFromDictionary:currentThemes];
|
||||
[defaults setObject:defaultThemes forKey:@"GBThemes"];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)toggleDeveloperMode:(id)sender
|
||||
|
|
|
@ -14,5 +14,7 @@
|
|||
@property (weak) IBOutlet NSSlider *hueStrengthSlider;
|
||||
@property (weak) IBOutlet NSTableView *themesList;
|
||||
@property (weak) IBOutlet NSMenu *menu;
|
||||
@property (weak) IBOutlet NSSegmentedControl *segmentControl;
|
||||
@property IBOutlet NSMenu *segmentMenu;
|
||||
+ (const GB_palette_t *)userPalette;
|
||||
@end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import "GBPaletteEditorController.h"
|
||||
#import "GBHueSliderCell.h"
|
||||
#import "GBApp.h"
|
||||
#import <Core/gb.h>
|
||||
|
||||
#define MAGIC 'SBPL'
|
||||
|
@ -199,11 +200,17 @@ static double blend(double from, double to, double position)
|
|||
if (theme && themes[theme]) {
|
||||
unsigned index = [[themes.allKeys sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] indexOfObject:theme];
|
||||
[_themesList selectRowIndexes:[NSIndexSet indexSetWithIndex:index] byExtendingSelection:false];
|
||||
[_themesList scrollRowToVisible:index];
|
||||
}
|
||||
else {
|
||||
[_themesList selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:false];
|
||||
[_themesList scrollRowToVisible:0];
|
||||
}
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
if (@available(macOS 10.10, *)) {
|
||||
_themesList.enclosingScrollView.contentView.automaticallyAdjustsContentInsets = false;
|
||||
_themesList.enclosingScrollView.contentView.contentInsets = NSEdgeInsetsMake(0, 0, 10, 0);
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)addTheme:(id)sender
|
||||
|
@ -365,6 +372,29 @@ static double blend(double from, double to, double position)
|
|||
}
|
||||
}
|
||||
|
||||
- (IBAction)segmentAction:(NSSegmentedControl *)sender
|
||||
{
|
||||
switch (sender.selectedSegment) {
|
||||
case 0: [self addTheme:sender]; return;
|
||||
case 1: [self deleteTheme:sender]; return;
|
||||
case 3: {
|
||||
NSSize menuSize = _segmentMenu.size;
|
||||
NSSize buttonSize = _segmentControl.bounds.size;
|
||||
[_segmentMenu popUpMenuPositioningItem:_segmentMenu.itemArray.lastObject
|
||||
atLocation:NSMakePoint(buttonSize.width,
|
||||
0)
|
||||
inView:sender];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)restoreDefaultPalettes:(id)sender
|
||||
{
|
||||
[(GBApp *)NSApp updateThemesDefault:true];
|
||||
[self awakeFromNib];
|
||||
}
|
||||
|
||||
- (IBAction)done:(NSButton *)sender
|
||||
{
|
||||
[sender.window.sheetParent endSheet:sender.window];
|
||||
|
|
|
@ -1055,7 +1055,7 @@
|
|||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<clipView key="contentView" focusRingType="none" drawsBackground="NO" id="AMs-PO-nid">
|
||||
<rect key="frame" x="1" y="1" width="260" height="247"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" id="UDd-IJ-fxX">
|
||||
<rect key="frame" x="0.0" y="0.0" width="260" height="247"/>
|
||||
|
@ -1176,14 +1176,14 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<scrollView focusRingType="none" fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DPL-nH-GVw">
|
||||
<rect key="frame" x="-1" y="24" width="160" height="318"/>
|
||||
<rect key="frame" x="-1" y="20" width="160" height="322"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" drawsBackground="NO" id="5Al-aC-tq8">
|
||||
<rect key="frame" x="1" y="1" width="158" height="316"/>
|
||||
<rect key="frame" x="1" y="1" width="158" height="320"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="sourceList" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" id="ZVn-bk-duk">
|
||||
<rect key="frame" x="0.0" y="0.0" width="158" height="316"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="158" height="320"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" name="_sourceListBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -1327,50 +1327,6 @@
|
|||
<rect key="frame" x="387" y="266" width="5" height="55"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
</box>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="t0j-uz-CIi">
|
||||
<rect key="frame" x="0.0" y="-1" width="32" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSAddTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="61Q-ht-htH">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="addTheme:" target="Zxl-vm-6c9" id="lAZ-PU-7Rk"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1Qv-3A-Fy9">
|
||||
<rect key="frame" x="31" y="-1" width="32" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Qax-9H-bwb">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="deleteTheme:" target="Zxl-vm-6c9" id="nlR-Hp-4m9"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xtD-ub-MX7">
|
||||
<rect key="frame" x="62" y="-1" width="49" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<buttonCell key="cell" type="smallSquare" title="Export" bezelStyle="smallSquare" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="RBw-u5-zpv">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="export:" target="Zxl-vm-6c9" id="9Fg-bN-W6z"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2E2-qz-P8N">
|
||||
<rect key="frame" x="110" y="-1" width="49" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<buttonCell key="cell" type="smallSquare" title="Import" bezelStyle="smallSquare" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="u9o-6G-fwU">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="import:" target="Zxl-vm-6c9" id="OTl-HS-9Rt"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="CZc-qZ-GLV">
|
||||
<rect key="frame" x="167" y="82" width="277" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
|
@ -1391,6 +1347,22 @@
|
|||
<action selector="done:" target="Zxl-vm-6c9" id="RKB-kM-yzA"/>
|
||||
</connections>
|
||||
</button>
|
||||
<segmentedControl verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="msj-PX-5Me">
|
||||
<rect key="frame" x="-1" y="-1" width="160" height="23"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<segmentedCell key="cell" borderStyle="border" alignment="left" segmentDistribution="fill" style="smallSquare" trackingMode="momentary" id="rIH-ls-kr1">
|
||||
<font key="font" metaFont="system"/>
|
||||
<segments>
|
||||
<segment image="NSAddTemplate" width="23"/>
|
||||
<segment image="NSRemoveTemplate" width="23"/>
|
||||
<segment enabled="NO"/>
|
||||
<segment label="⋯" width="23"/>
|
||||
</segments>
|
||||
</segmentedCell>
|
||||
<connections>
|
||||
<action selector="segmentAction:" target="Zxl-vm-6c9" id="6e6-CQ-Cko"/>
|
||||
</connections>
|
||||
</segmentedControl>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="-62.5" y="222.5"/>
|
||||
|
@ -1408,6 +1380,8 @@
|
|||
<outlet property="hueStrengthSlider" destination="ij9-bn-1y8" id="lcn-4q-27B"/>
|
||||
<outlet property="manualModeCheckbox" destination="l33-w0-rLw" id="NBU-1I-UzJ"/>
|
||||
<outlet property="menu" destination="dHJ-3R-Ora" id="SWT-qM-tca"/>
|
||||
<outlet property="segmentControl" destination="msj-PX-5Me" id="0sp-qI-mlU"/>
|
||||
<outlet property="segmentMenu" destination="v6S-Bm-QLG" id="c0x-OP-R0a"/>
|
||||
<outlet property="themesList" destination="ZVn-bk-duk" id="S4b-vM-ioi"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
|
@ -1473,7 +1447,7 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" id="4U7-cB-J7O">
|
||||
<rect key="frame" x="1" y="1" width="479" height="203"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="24" rowSizeStyle="large" id="XQa-0K-gl3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="488" height="203"/>
|
||||
|
@ -1548,6 +1522,30 @@ Test</string>
|
|||
<outlet property="tableView" destination="XQa-0K-gl3" id="fhZ-wM-dnm"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<menu id="v6S-Bm-QLG">
|
||||
<items>
|
||||
<menuItem title="Restore Default Palettes" id="pZX-co-uHd">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="restoreDefaultPalettes:" target="Zxl-vm-6c9" id="zr5-w7-DYc"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="hH1-bz-mOh"/>
|
||||
<menuItem title="Import Palette…" id="WaC-3o-BP0">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="import:" target="Zxl-vm-6c9" id="FBi-7Q-NQg"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Export Palette…" id="9zU-Mf-6ia">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="export:" target="Zxl-vm-6c9" id="62i-Lv-2IO"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="349.5" y="434.5"/>
|
||||
</menu>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="CPU" width="32" height="32"/>
|
||||
|
|
Loading…
Reference in New Issue