mirror of
https://github.com/nickshanks/ResKnife.git
synced 2024-06-07 11:29:29 +00:00
Additional preferences, icon for info window.
This commit is contained in:
parent
40c8861964
commit
c2087c99be
|
@ -42,6 +42,7 @@
|
|||
[[self window] setTitle:@"Resource Info"];
|
||||
[placeholderView setContentView:resourceView];
|
||||
[nameView setStringValue:[selectedResource name]];
|
||||
[iconView setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[selectedResource type]]];
|
||||
[[attributesMatrix cellAtRow:changedBox column:0] setState:[[selectedResource attributes] shortValue] & resChanged];
|
||||
[[attributesMatrix cellAtRow:preloadBox column:0] setState:[[selectedResource attributes] shortValue] & resPreload];
|
||||
[[attributesMatrix cellAtRow:protectedBox column:0] setState:[[selectedResource attributes] shortValue] & resProtected];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import "OutlineViewDelegate.h"
|
||||
#import "ResourceNameCell.h"
|
||||
#import "Resource.h"
|
||||
|
||||
@implementation OutlineViewDelegate
|
||||
|
||||
|
@ -18,6 +19,7 @@
|
|||
if( [tableColumn isEqual:nameColumn] )
|
||||
{
|
||||
[(ResourceNameCell *)cell setImage:[NSImage imageNamed:@"Resource file"]];
|
||||
// [(ResourceNameCell *)cell setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[(Resource *)item type]]];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,18 @@ enum DataProtection
|
|||
deleteResourceWarningBox
|
||||
};
|
||||
|
||||
enum LaunchAction
|
||||
{
|
||||
doNothingBox = 0,
|
||||
createNewDocumentBox,
|
||||
displayOpenPanelBox
|
||||
};
|
||||
|
||||
@interface PrefsWindowController : NSWindowController
|
||||
{
|
||||
IBOutlet NSTextField *autosaveIntervalField;
|
||||
IBOutlet NSMatrix *dataProtectionMatrix;
|
||||
IBOutlet NSMatrix *launchActionMatrix;
|
||||
}
|
||||
|
||||
- (void)updatePrefs:(NSNotification *)notification;
|
||||
|
|
|
@ -32,12 +32,14 @@
|
|||
BOOL autosave = [defaults boolForKey:@"Autosave"];
|
||||
int autosaveInterval = [defaults integerForKey:@"AutosaveInterval"];
|
||||
BOOL deleteResourceWarning = [defaults boolForKey:@"DeleteResourceWarning"];
|
||||
int createNewDocument = [defaults integerForKey:@"OpenUntitledFileOnLaunch"];
|
||||
|
||||
// Éand set widgets accordingly
|
||||
[[dataProtectionMatrix cellAtRow:preserveBackupsBox column:0] setState:preserveBackups];
|
||||
[[dataProtectionMatrix cellAtRow:autosaveBox column:0] setState:autosave];
|
||||
[autosaveIntervalField setStringValue:[NSString stringWithFormat:@"%d", autosaveInterval]];
|
||||
[[dataProtectionMatrix cellAtRow:deleteResourceWarningBox column:0] setState:deleteResourceWarning];
|
||||
[launchActionMatrix selectCellAtRow:createNewDocument column:0];
|
||||
}
|
||||
|
||||
- (IBAction)acceptPrefs:(id)sender
|
||||
|
@ -48,6 +50,7 @@
|
|||
BOOL autosave = [[dataProtectionMatrix cellAtRow:autosaveBox column:0] intValue]? YES:NO;
|
||||
int autosaveInterval = [autosaveIntervalField intValue];
|
||||
BOOL deleteResourceWarning = [[dataProtectionMatrix cellAtRow:deleteResourceWarningBox column:0] intValue]? YES:NO;
|
||||
BOOL createNewDocument = ([launchActionMatrix selectedRow] == createNewDocumentBox)? YES:NO;
|
||||
|
||||
// hide the window
|
||||
[[self window] orderOut:nil];
|
||||
|
@ -57,26 +60,17 @@
|
|||
[defaults setBool:autosave forKey:@"Autosave"];
|
||||
[defaults setInteger:autosaveInterval forKey:@"AutosaveInterval"];
|
||||
[defaults setBool:deleteResourceWarning forKey:@"DeleteResourceWarning"];
|
||||
[defaults setBool:createNewDocument forKey:@"OpenUntitledFileOnLaunch"];
|
||||
[defaults synchronize];
|
||||
}
|
||||
|
||||
- (IBAction)cancelPrefs:(id)sender
|
||||
{
|
||||
// load saved defaults
|
||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||
BOOL preserveBackups = [defaults boolForKey:@"PreserveBackups"];
|
||||
BOOL autosave = [defaults boolForKey:@"Autosave"];
|
||||
int autosaveInterval = [defaults integerForKey:@"AutosaveInterval"];
|
||||
BOOL deleteResourceWarning = [defaults boolForKey:@"DeleteResourceWarning"];
|
||||
|
||||
// hide the window
|
||||
[[self window] orderOut:nil];
|
||||
|
||||
// and reset dialog to match
|
||||
[[dataProtectionMatrix cellAtRow:preserveBackupsBox column:0] setState:preserveBackups];
|
||||
[[dataProtectionMatrix cellAtRow:autosaveBox column:0] setState:autosave];
|
||||
[autosaveIntervalField setStringValue:[NSString stringWithFormat:@"%d", autosaveInterval]];
|
||||
[[dataProtectionMatrix cellAtRow:deleteResourceWarningBox column:0] setState:deleteResourceWarning];
|
||||
// reset widgets to saved values
|
||||
[self updatePrefs:nil];
|
||||
}
|
||||
|
||||
- (IBAction)resetToDefault:(id)sender
|
||||
|
@ -87,12 +81,14 @@
|
|||
BOOL autosave = [[defaultsPlist objectForKey:@"Autosave"] intValue]? YES:NO;
|
||||
int autosaveInterval = [[defaultsPlist objectForKey:@"AutosaveInterval"] intValue];
|
||||
BOOL deleteResourceWarning = [[defaultsPlist objectForKey:@"DeleteResourceWarning"] intValue]? YES:NO;
|
||||
int createNewDocument = [[defaultsPlist objectForKey:@"OpenUntitledFileOnLaunch"] intValue];
|
||||
|
||||
// note that this function does not modify the user defaults - the user still has to accept or cancel the panel
|
||||
[[dataProtectionMatrix cellAtRow:preserveBackupsBox column:0] setState:preserveBackups];
|
||||
[[dataProtectionMatrix cellAtRow:autosaveBox column:0] setState:autosave];
|
||||
[autosaveIntervalField setStringValue:[NSString stringWithFormat:@"%d", autosaveInterval]];
|
||||
[[dataProtectionMatrix cellAtRow:deleteResourceWarningBox column:0] setState:deleteResourceWarning];
|
||||
[launchActionMatrix selectCellAtRow:createNewDocument column:0];
|
||||
}
|
||||
|
||||
+ (id)sharedPrefsWindowController
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
- (IBAction)openResource:(id)sender;
|
||||
- (IBAction)openResourceAsHex:(id)sender;
|
||||
- (IBAction)playSound:(id)sender;
|
||||
- (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)finished;
|
||||
|
||||
- (BOOL)readResourceMap:(SInt16)fileRefNum;
|
||||
- (BOOL)writeResourceMap:(SInt16)fileRefNum;
|
||||
|
|
|
@ -287,6 +287,16 @@ static NSString *RKShowInfoItemIdentifier = @"com.nickshanks.resknife.toolbar.sh
|
|||
|
||||
- (IBAction)playSound:(id)sender
|
||||
{
|
||||
Resource *resource = [outlineView itemAtRow:[outlineView selectedRow]];
|
||||
NSSound *sound = [[NSSound alloc] initWithData:[resource data]];
|
||||
[sound setDelegate:self];
|
||||
[sound play];
|
||||
}
|
||||
|
||||
- (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)finished
|
||||
{
|
||||
if( finished ) [sound release];
|
||||
NSLog( @"sound released" );
|
||||
}
|
||||
|
||||
/* FILE HANDLING */
|
||||
|
|
6
Cocoa/English.lproj/PrefsWindow.nib/classes.nib
generated
6
Cocoa/English.lproj/PrefsWindow.nib/classes.nib
generated
|
@ -5,7 +5,11 @@
|
|||
ACTIONS = {acceptPrefs = id; cancelPrefs = id; resetToDefault = id; };
|
||||
CLASS = PrefsWindowController;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {autosaveIntervalField = id; dataProtectionMatrix = id; };
|
||||
OUTLETS = {
|
||||
autosaveIntervalField = NSTextField;
|
||||
dataProtectionMatrix = NSMatrix;
|
||||
launchActionMatrix = NSMatrix;
|
||||
};
|
||||
SUPERCLASS = NSWindowController;
|
||||
}
|
||||
);
|
||||
|
|
8
Cocoa/English.lproj/PrefsWindow.nib/info.nib
generated
8
Cocoa/English.lproj/PrefsWindow.nib/info.nib
generated
|
@ -4,6 +4,14 @@
|
|||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>70 184 468 280 0 74 1280 928 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>248.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>5</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5P48</string>
|
||||
<key>IBUserGuides</key>
|
||||
<dict>
|
||||
<key>PrefsWindow</key>
|
||||
|
|
BIN
Cocoa/English.lproj/PrefsWindow.nib/objects.nib
generated
BIN
Cocoa/English.lproj/PrefsWindow.nib/objects.nib
generated
Binary file not shown.
Loading…
Reference in New Issue
Block a user