Changeset 97


Ignore:
Timestamp:
Mar 9, 2008, 7:22:52 PM (10 years ago)
Author:
Sam Hocevar
Message:
  • Updated the Mac OS X port, thanks to Julian Mayer.
Location:
abuse/trunk
Files:
6 added
3 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/osx/SDLMain.m

    r2 r97  
    77
    88#import "SDL.h"
    9 #import <Cocoa/Cocoa.h>
    10 
    11 @interface SDLMain : NSObject
    12 @end
    13 
     9#import "SDLMain.h"
    1410#import <sys/param.h> /* for MAXPATHLEN */
    1511#import <unistd.h>
    1612
    1713/* Use this flag to determine whether we use SDLMain.nib or not */
    18 #define         SDL_USE_NIB_FILE        1
     14#define         SDL_USE_NIB_FILE        0
    1915
    2016
     
    2723@interface NSString (ReplaceSubString)
    2824- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
     25@end
     26#else
     27/* An internal Apple class used to setup Apple menus */
     28@interface NSAppleMenuController:NSObject {}
     29- (void)controlMenu:(NSMenu *)aMenu;
    2930@end
    3031#endif
     
    4748/* The main class of the application, the application's delegate */
    4849@implementation SDLMain
    49 - (void)quit:(id)sender
    50 {
    51     /* Post a SDL_QUIT event */
    52     SDL_Event event;
    53     event.type = SDL_QUIT;
    54     SDL_PushEvent(&event);
    55 }
     50
    5651/* Set the working directory to the .app's parent directory */
    5752- (void) setupWorkingDirectory:(BOOL)shouldChdir
     
    10196    }
    10297    [ aMenu sizeToFit ];
     98}
     99
     100#else
     101
     102void setupAppleMenu(void)
     103{
     104    /* warning: this code is very odd */
     105    NSAppleMenuController *appleMenuController;
     106    NSMenu *appleMenu;
     107    NSMenuItem *appleMenuItem;
     108
     109    appleMenuController = [[NSAppleMenuController alloc] init];
     110    appleMenu = [[NSMenu alloc] initWithTitle:@""];
     111    appleMenuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
     112   
     113    [appleMenuItem setSubmenu:appleMenu];
     114
     115    /* yes, we do need to add it and then remove it --
     116       if you don't add it, it doesn't get displayed
     117       if you don't remove it, you have an extra, titleless item in the menubar
     118       when you remove it, it appears to stick around
     119       very, very odd */
     120    [[NSApp mainMenu] addItem:appleMenuItem];
     121    [appleMenuController controlMenu:appleMenu];
     122    [[NSApp mainMenu] removeItem:appleMenuItem];
     123    [appleMenu release];
     124    [appleMenuItem release];
     125}
     126
     127/* Create a window menu */
     128void setupWindowMenu(void)
     129{
     130    NSMenu              *windowMenu;
     131    NSMenuItem  *windowMenuItem;
     132    NSMenuItem  *menuItem;
     133
     134
     135    windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
     136   
     137    /* "Minimize" item */
     138    menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
     139    [windowMenu addItem:menuItem];
     140    [menuItem release];
     141   
     142    /* Put menu into the menubar */
     143    windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
     144    [windowMenuItem setSubmenu:windowMenu];
     145    [[NSApp mainMenu] addItem:windowMenuItem];
     146   
     147    /* Tell the application object that this is now the window menu */
     148    [NSApp setWindowsMenu:windowMenu];
     149
     150    /* Finally give up our references to the objects */
     151    [windowMenu release];
     152    [windowMenuItem release];
     153}
     154
     155/* Replacement for NSApplicationMain */
     156void CustomApplicationMain (argc, argv)
     157{
     158    NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
     159    SDLMain                             *sdlMain;
     160
     161    /* Ensure the application object is initialised */
     162    [SDLApplication sharedApplication];
     163   
     164    /* Set up the menubar */
     165    [NSApp setMainMenu:[[NSMenu alloc] init]];
     166    setupAppleMenu();
     167    setupWindowMenu();
     168   
     169    /* Create SDLMain and make it the app delegate */
     170    sdlMain = [[SDLMain alloc] init];
     171    [NSApp setDelegate:sdlMain];
     172   
     173    /* Start the main event loop */
     174    [NSApp run];
     175   
     176    [sdlMain release];
     177    [pool release];
    103178}
    104179
     
    197272    [SDLApplication poseAsClass:[NSApplication class]];
    198273    NSApplicationMain (argc, argv);
     274#else
     275    CustomApplicationMain (argc, argv);
    199276#endif
    200277    return 0;
  • abuse/trunk/src/imlib/specs.cpp

    r90 r97  
    932932void write_uint8(FILE *fp, uint8_t x) { fputc((unsigned char)x,fp); }
    933933
    934 uint32_t read_other_int32(FILE *fp)
     934uint32_t read_other_uint32(FILE *fp)
    935935{
    936936  uint32_t x;
  • abuse/trunk/src/imlib/system.h

    r90 r97  
    1111#define __SYS__
    1212
    13 
    14 #ifdef WORDS_BIGENDIAN
    15   #define BIG_ENDIANS
    16 #else
    17   #define LITTLE_ENDIANS
    18 #endif
    19 
     13#include <SDL.h>
    2014
    2115#include <unistd.h>
     
    2721   ((( ((uint32_t)(x)) )&0x0000ff00)<<8)|(( ((uint32_t)(x)) )<<24))
    2822
    29 #if defined BIG_ENDIANS
     23#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    3024#define LONG int32_t
    3125#define uint16_to_intel(x) uint16_swap(x)
  • abuse/trunk/src/imlib/xwdread.cpp

    r56 r97  
    2121#include "video.hpp"
    2222#include "dos.h"
     23#ifndef __APPLE__
    2324#include "main.hpp"
     25#endif
    2426#include "macs.hpp"
    2527#include "image24.hpp"
     
    296298  int i,j;
    297299  uint8_t *sl;
    298 #if BYTE_ORDER!=BIG_ENDIAN
    299   printf("little guys\n");
    300 #endif
     300
    301301  printf("getting image, bits_per_item = %d %d %d\n",bits_per_item,bits_used,bit_order==MSBFirst);
    302302  for (i=0; i<im->height(); i++)
  • abuse/trunk/src/net/tcpip.hpp

    r57 r97  
    99#include <sys/types.h>
    1010#include "isllist.hpp"
    11 
    12 #ifdef __APPLE__
    13 typedef int socklen_t;
    14 #endif
    1511
    1612#if (defined(__APPLE__) && !defined(__MACH__))
  • abuse/trunk/src/sdlport/setup.cpp

    r68 r97  
    2727#ifdef HAVE_OPENGL
    2828#ifdef __APPLE__
     29#include <Carbon/Carbon.h>
    2930#include <OpenGL/gl.h>
    3031#include <OpenGL/glu.h>
     
    9091    {
    9192        fputs( "; Abuse-SDL Configuration file\n\n", fd );
     93        fputs( "; Startup fullscreen\nfullscreen=0\n\n", fd );
     94                #ifdef __APPLE__
     95        fputs( "; Use DoubleBuffering\ndoublebuf=1\n\n", fd );
     96        fputs( "; Use OpenGL\ngl=1\n\n", fd );
     97        #else
     98                fputs( "; Use DoubleBuffering\ndoublebuf=0\n\n", fd );
     99        fputs( "; Use OpenGL\ngl=0\n\n", fd );
    92100        fputs( "; Location of the datafiles\ndatadir=/var/games/abuse\n\n", fd );
    93         fputs( "; Startup fullscreen\nfullscreen=0\n\n", fd );
    94         fputs( "; Use DoubleBuffering\ndoublebuf=0\n\n", fd );
    95         fputs( "; Use mono audio only\nmono=0\n\n", fd );
     101                #endif
     102                fputs( "; Use mono audio only\nmono=0\n\n", fd );
    96103        fputs( "; Grab the mouse to the window\ngrabmouse=0\n\n", fd );
    97104        fputs( "; Set the scale factor\nscale=2\n\n", fd );
    98         fputs( "; Use OpenGL\ngl=0\n\n", fd );
    99         fputs( "; Use anti-aliasing (with gl=1 only)\nantialias=1\n\n", fd );
     105                fputs( "; Use anti-aliasing (with gl=1 only)\nantialias=1\n\n", fd );
    100106//        fputs( "; Set the width of the window\nx=320\n\n", fd );
    101107//        fputs( "; Set the height of the window\ny=200\n\n", fd );
     
    339345    // Initialise default settings
    340346    flags.fullscreen        = 0;            // Start in a window
    341     flags.doublebuf            = 0;            // No double buffering
    342347    flags.mono                = 0;            // Enable stereo sound
    343348    flags.nosound            = 0;            // Enable sound
     
    346351    flags.xres = xres        = 320;            // Default window width
    347352    flags.yres = yres        = 200;            // Default window height
     353#ifdef __APPLE__       
     354    flags.gl                = 1;            // Use opengl
     355    flags.doublebuf            = 1;            // Do double buffering
     356#else
    348357    flags.gl                = 0;            // Don't use opengl
     358    flags.doublebuf            = 0;            // No double buffering
     359        #endif
    349360#ifdef HAVE_OPENGL
    350361    flags.antialias            = GL_NEAREST;    // Don't anti-alias
     
    403414    // Set the datadir to a default value
    404415    // (The current directory)
     416        #ifdef __APPLE__
     417        UInt8 buffer[255];
     418    CFURLRef bundleurl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
     419        CFURLRef url = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault, bundleurl, CFSTR("Contents/Resources/data"), true);
     420       
     421        if (!CFURLGetFileSystemRepresentation(url, true, buffer, 255))
     422        {
     423                exit(1);
     424        }
     425        else
     426                set_filename_prefix( (const char*)buffer );
     427        #else
    405428    set_filename_prefix( EXPDATADIR );
    406 
     429        #endif
     430       
    407431    // Load the users configuration
    408432    readRCFile();
Note: See TracChangeset for help on using the changeset viewer.