Changes for Menu Enabling/Disabling and sending events instead of keypress from the Menu code.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1075 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
markgrebe 2006-04-05 02:18:58 +00:00
parent 667959a6e5
commit 4276b013c7
2 changed files with 34 additions and 5 deletions

View File

@ -4,17 +4,20 @@
Mark Grebe <atarimac@cox.net>
*/
/* $Id: Menus.m,v 1.12 2006-03-29 04:45:10 markgrebe Exp $ */
/* $Id: Menus.m,v 1.13 2006-04-05 02:18:58 markgrebe Exp $ */
#import <Cocoa/Cocoa.h>
#import "SDL.h"
#import "Menus.h"
#import "MenusEvents.h"
#define QZ_m 0x2E
#define QZ_o 0x1F
#define QZ_h 0x04
#define QZ_SLASH 0x2C
extern void macOSXSendMenuEvent(int event);
/*------------------------------------------------------------------------------
* releaseCmdKeys - This method fixes an issue when modal windows are used with
* the Mac OSX version of the SDL library.
@ -164,6 +167,10 @@ static Menus *sharedInstance = nil;
- (IBAction)openCart:(id)sender
{
[self pushKeyEvent:SDLK_ESCAPE:NO:NO];
// Fixme - This should work like the other keys, but instead
// if you send the LauncherOpen event, it crashes SDL in
// the poll loop.
// macOSXSendMenuEvent(MENU_OPEN);
}
- (IBAction)restartGame:(id)sender
@ -173,7 +180,7 @@ static Menus *sharedInstance = nil;
- (IBAction)pauseGame:(id)sender
{
[self pushKeyEvent:SDLK_PAUSE:NO:NO];
macOSXSendMenuEvent(MENU_PAUSE);
}
- (IBAction)ntscPalMode:(id)sender
@ -238,12 +245,12 @@ static Menus *sharedInstance = nil;
- (IBAction)volumePlus:(id)sender
{
[self pushKeyEvent:SDLK_RIGHTBRACKET:YES:YES];
macOSXSendMenuEvent(MENU_VOLUME_INCREASE);
}
- (IBAction)volumeMinus:(id)sender
{
[self pushKeyEvent:SDLK_LEFTBRACKET:YES:YES];
macOSXSendMenuEvent(MENU_VOLUME_DECREASE);
}
- (IBAction)saveProps:(id)sender

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: OSystemMACOSX.cxx,v 1.10 2006-03-29 04:45:10 markgrebe Exp $
// $Id: OSystemMACOSX.cxx,v 1.11 2006-04-05 02:18:58 markgrebe Exp $
//============================================================================
#include <cstdlib>
@ -29,6 +29,7 @@
#include "bspf.hxx"
#include "OSystem.hxx"
#include "OSystemMACOSX.hxx"
#include "MenusEvents.h"
#ifdef HAVE_GETTIMEOFDAY
#include <time.h>
@ -44,6 +45,7 @@ extern "C" {
void setOptionsMenus(void);
void setCommandMenus(void);
void setDebuggerMenus(void);
void macOSXSendMenuEvent(int event);
}
// Pointer to the main parent osystem object or the null pointer
@ -57,6 +59,26 @@ void macOpenConsole(char *romname)
theOSystem->createConsole(romname);
}
// Allow the Menus Objective-C object to pass event sends into the
// application.
void macOSXSendMenuEvent(int event)
{
switch(event) {
case MENU_PAUSE:
theOSystem->eventHandler().handleEvent(Event::Pause, 1);
break;
case MENU_OPEN:
theOSystem->eventHandler().handleEvent(Event::LauncherMode, 1);
break;
case MENU_VOLUME_INCREASE:
theOSystem->eventHandler().handleEvent(Event::VolumeIncrease, 1);
break;
case MENU_VOLUME_DECREASE:
theOSystem->eventHandler().handleEvent(Event::VolumeDecrease, 1);
break;
}
}
/**
Each derived class is responsible for calling the following methods
in its constructor: