Search
lxdream.org :: lxdream :: r718:047a244936d1
lxdream 0.9.1
released Jun 29
Download Now
changeset718:047a244936d1
parent717:bdc41b26c942
child719:8ce31b3d0dab
authornkeynes
dateMon Jun 30 04:58:26 2008 +0000 (11 years ago)
Use the configured paths for the dialog boxes by default
src/cocoaui/cocoaui.c
1.1 --- a/src/cocoaui/cocoaui.c Sun Jun 29 23:31:12 2008 +0000
1.2 +++ b/src/cocoaui/cocoaui.c Mon Jun 30 04:58:26 2008 +0000
1.3 @@ -22,8 +22,10 @@
1.4 #include <string.h>
1.5 #include <sys/time.h>
1.6 #include "lxdream.h"
1.7 +#include "dream.h"
1.8 #include "dreamcast.h"
1.9 -#include "dream.h"
1.10 +#include "config.h"
1.11 +#include "display.h"
1.12 #include "gui.h"
1.13 #include "cocoaui/cocoaui.h"
1.14
1.15 @@ -146,8 +148,10 @@
1.16 - (void) load_action: (id)sender
1.17 {
1.18 NSOpenPanel *panel = [NSOpenPanel openPanel];
1.19 + const gchar *dir = lxdream_get_config_value(CONFIG_SAVE_PATH);
1.20 + NSString *path = (dir == NULL ? NSHomeDirectory() : [NSString stringWithCString: dir]);
1.21 NSArray *fileTypes = [NSArray arrayWithObject: @"dst"];
1.22 - int result = [panel runModalForDirectory: NSHomeDirectory() file: nil types: fileTypes];
1.23 + int result = [panel runModalForDirectory: path file: nil types: fileTypes];
1.24 if( result == NSOKButton && [[panel filenames] count] > 0 ) {
1.25 NSString *filename = [[panel filenames] objectAtIndex: 0];
1.26 dreamcast_load_state( [filename UTF8String] );
1.27 @@ -156,8 +160,10 @@
1.28 - (void) save_action: (id)sender
1.29 {
1.30 NSSavePanel *panel = [NSSavePanel savePanel];
1.31 + const gchar *dir = lxdream_get_config_value(CONFIG_SAVE_PATH);
1.32 + NSString *path = (dir == NULL ? NSHomeDirectory() : [NSString stringWithCString: dir]);
1.33 [panel setRequiredFileType: @"dst"];
1.34 - int result = [panel runModalForDirectory: NSHomeDirectory() file:@""];
1.35 + int result = [panel runModalForDirectory: path file:@""];
1.36 if( result == NSOKButton ) {
1.37 NSString *filename = [panel filename];
1.38 dreamcast_save_state( [filename UTF8String] );
1.39 @@ -166,7 +172,9 @@
1.40 - (void) load_binary_action: (id)sender
1.41 {
1.42 NSOpenPanel *panel = [NSOpenPanel openPanel];
1.43 - int result = [panel runModalForDirectory: NSHomeDirectory() file: nil types: nil];
1.44 + const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
1.45 + NSString *path = (dir == NULL ? NSHomeDirectory() : [NSString stringWithCString: dir]);
1.46 + int result = [panel runModalForDirectory: path file: nil types: nil];
1.47 if( result == NSOKButton && [[panel filenames] count] > 0 ) {
1.48 NSString *filename = [[panel filenames] objectAtIndex: 0];
1.49 file_load_magic( [filename UTF8String] );
1.50 @@ -175,7 +183,9 @@
1.51 - (void) mount_action: (id)sender
1.52 {
1.53 NSOpenPanel *panel = [NSOpenPanel openPanel];
1.54 - int result = [panel runModalForDirectory: NSHomeDirectory() file: nil types: nil];
1.55 + const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
1.56 + NSString *path = (dir == NULL ? NSHomeDirectory() : [NSString stringWithCString: dir]);
1.57 + int result = [panel runModalForDirectory: path file: nil types: nil];
1.58 if( result == NSOKButton && [[panel filenames] count] > 0 ) {
1.59 NSString *filename = [[panel filenames] objectAtIndex: 0];
1.60 gdrom_mount_image( [filename UTF8String] );
1.61 @@ -223,6 +233,7 @@
1.62
1.63 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1.64 [NSApplication sharedApplication];
1.65 +
1.66 LxdreamDelegate *delegate = [[LxdreamDelegate alloc] init];
1.67 [NSApp setDelegate: delegate];
1.68 NSString *iconFile = [[NSBundle mainBundle] pathForResource:@"dcemu" ofType:@"gif"];
1.69 @@ -232,6 +243,7 @@
1.70 NSWindow *window = cocoa_gui_create_main_window();
1.71 [window makeKeyAndOrderFront: nil];
1.72 [NSApp activateIgnoringOtherApps: YES];
1.73 +
1.74 [pool release];
1.75 }
1.76
1.77 @@ -347,4 +359,19 @@
1.78 [[NSRunLoop currentRunLoop] performSelector: @selector(run_immediate)
1.79 target: [NSApp delegate] argument: nil order: 1
1.80 modes: [NSArray arrayWithObject: NSDefaultRunLoopMode] ];
1.81 -}
1.82 \ No newline at end of file
1.83 +}
1.84 +
1.85 +NSImage *NSImage_new_from_framebuffer( frame_buffer_t buffer )
1.86 +{
1.87 + NSBitmapImageRep *rep =
1.88 + [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: &buffer->data
1.89 + pixelsWide: buffer->width pixelsHigh: buffer->height
1.90 + bitsPerSample: 8 samplesPerPixel: 3
1.91 + hasAlpha: NO isPlanar: NO
1.92 + colorSpaceName: NSDeviceRGBColorSpace bitmapFormat: 0
1.93 + bytesPerRow: buffer->rowstride bitsPerPixel: 24];
1.94 +
1.95 + NSImage *image = [[NSImage alloc] initWithSize: NSMakeSize(0.0,0.0)];
1.96 + [image addRepresentation: rep];
1.97 + return image;
1.98 +}
.