Added drag-&-drop launch

This commit is contained in:
Akop Karapetyan 2019-10-18 23:16:01 -07:00 committed by tmaul
parent 703af9d764
commit fdc1141f4c
5 changed files with 95 additions and 18 deletions

View File

@ -23,13 +23,12 @@
- (void) awakeFromNib
{
NSLog(@"awakeFromNib");
main = [FBMainThread new];
[main start];
}
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
NSLog(@"applicationDidFinishLaunching");
[main start];
}
@ -48,4 +47,11 @@
return YES;
}
- (BOOL) application:(NSApplication *) sender
openFile:(NSString *) filename
{
main.fileToOpen = filename;
return YES;
}
@end

View File

@ -4,6 +4,49 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>zip</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/zip</string>
</array>
<key>CFBundleTypeName</key>
<string>Zip Compressed ROM Set</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>com.pkware.zip-archive</string>
</array>
<key>LSTypeIsPackage</key>
<integer>0</integer>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>7z</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-7z-compressed</string>
</array>
<key>CFBundleTypeName</key>
<string>7zip Compressed ROM Set</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>org.7-zip.7-zip-archive</string>
</array>
<key>LSTypeIsPackage</key>
<integer>0</integer>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
@ -32,5 +75,30 @@
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
<string>public.archive</string>
</array>
<key>UTTypeDescription</key>
<string>7zip Compressed ROM Set</string>
<key>UTTypeIdentifier</key>
<string>org.7-zip.7-zip-archive</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>7z</string>
</array>
<key>public.mime-type</key>
<array>
<string>application/x-7z-compressed</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>

View File

@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface FBMainThread : NSThread
@property NSString *fileToOpen;
@end
NS_ASSUME_NONNULL_END

View File

@ -8,7 +8,7 @@
#import "FBMainThread.h"
extern int MainInit();
extern int MainInit(const char *, const char *);
extern int MainFrame();
extern int MainEnd();
@ -23,7 +23,10 @@ extern int MainEnd();
- (void) main
{
if (!MainInit())
NSString *path = [[_fileToOpen stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
NSString *setname = [[_fileToOpen lastPathComponent] stringByDeletingPathExtension];
if (!MainInit([path cStringUsingEncoding:NSUTF8StringEncoding], [setname cStringUsingEncoding:NSUTF8StringEncoding]))
return;
NSLog(@"Entering main loop");

View File

@ -4,28 +4,34 @@ extern int RunIdle();
extern int RunInit();
extern int RunExit();
int MainInit()
int MainInit(const char *path, const char *setname)
{
if (path == NULL || setname == NULL) {
fprintf(stderr, "Path or set name uninitialized\n");
return 0;
}
fprintf(stderr, "Initializing '%s' with path '%s'\n", setname, path);
SDL_Init(SDL_INIT_AUDIO);
BurnLibInit();
const char *set = "sfiii3";
int i;
for (i = 0; i < nBurnDrvCount; i++) {
nBurnDrvActive = i;
if (strcmp(BurnDrvGetTextA(0), set) == 0) {
if (strcmp(BurnDrvGetTextA(0), setname) == 0) {
break;
}
}
if (i == nBurnDrvCount) {
printf("%s is not supported by FB Neo.", set);
fprintf(stderr, "%s is not supported by FB Neo.", setname);
return 0;
}
bCheatsAllowed = false;
sprintf(szAppRomPaths[0], "/Volumes/Stuff/Emulation/mame/");
sprintf(szAppRomPaths[0], path);
DrvInit(i, 0);
MediaInit();
@ -36,14 +42,6 @@ int MainInit()
int MainFrame()
{
// SDL_Event event;
// while (SDL_PollEvent(&event)) {
// switch (event.type) {
// case SDL_QUIT: /* Windows was closed */
// quit = 1;
// break;
// }
// }
RunIdle();
return 1;