Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Source/MenuHandler.c
/* |
File: MenuHandler.c |
Contains: xxx put contents here xxx |
Version: xxx put version here xxx |
Copyright: © 1998-1999 by Apple Computer, Inc., all rights reserved. |
File Ownership: |
DRI: xxx put dri here xxx |
Other Contact: xxx put other contact here xxx |
Technology: xxx put technology here xxx |
Writers: |
(cjd) Chris De Salvo |
(BWS) Brent Schorsch |
Change History (most recent first): |
<SP10> 1/29/99 cjd Removed RedbookHandler.h |
<SP9> 1/21/99 cjd Removing 68K build code |
<8> 6/12/98 BWS Added support for InputSprocket 68k |
*/ |
//¥ ------------------------------------------------------------------------------------------ ¥ |
//¥ |
//¥ Copyright © 1996 Apple Computer, Inc., All Rights Reserved |
//¥ |
//¥ |
//¥ You may incorporate this sample code into your applications without |
//¥ restriction, though the sample code has been provided "AS IS" and the |
//¥ responsibility for its operation is 100% yours. However, what you are |
//¥ not permitted to do is to redistribute the source as "DSC Sample Code" |
//¥ after having made changes. If you're going to re-distribute the source, |
//¥ we require that you make it clear in the source that the code was |
//¥ descended from Apple Sample Code, but that you've made changes. |
//¥ |
//¥ Authors: |
//¥ Chris De Salvo |
//¥ |
//¥ ------------------------------------------------------------------------------------------ ¥ |
//¥ ------------------------------ Includes |
#include <Devices.h> |
#include <SoundSprocket.h> |
#include <ToolUtils.h> |
#include "AboutBox.h" |
#include "ErrorHandler.h" |
#include "EventHandler.h" |
#include "MemoryHandler.h" |
#include "MenuHandler.h" |
#include "MoviePlayback.h" |
#include "NetSprocketSupport.h" |
#include "SIResources.h" |
#include "SoundHandler.h" |
#include "SprocketInvaders.h" |
//¥ ------------------------------ Private Definitions |
#define iAboutBox 1 |
//¥ ------------------------------ |
#define iNewGame 1 |
#define iHostGame 2 |
#define iJoinGame 3 |
//¥ -------------- |
#define iSelectMovie 5 |
//¥ -------------- |
#define iQuit 7 |
//¥ ------------------------------ |
#define iUndo 1 |
//¥ -------------- |
#define iCut 3 |
#define iCopy 4 |
#define iPaste 5 |
//¥ ------------------------------ |
#define iConfigureInput 1 |
#define iConfigureSound 2 |
//¥ -------------- |
#define iSoundEffects 4 |
#define iTwoPlayers 5 |
//¥ -------------- |
#define iCDAudio 7 |
//¥ ------------------------------ Private Constants |
//¥ ------------------------------ Private Types |
//¥ ------------------------------ Private Structs |
//¥ ------------------------------ Private Variables |
static Boolean gMenuHandlerInited = false; |
//¥ ------------------------------ Private Functions |
//¥ ------------------------------ Public Variables |
//¥ -------------------- MenuInit |
void |
MenuInit(void) |
{ |
Handle theMenuBar; |
MenuHandle menu; |
//¥ Load the menu bar |
theMenuBar = GetNewMBar(kMBARMain); |
if (theMenuBar == nil) |
FatalError("Could not load MBAR."); |
//¥ Install the menu bar |
SetMenuBar(theMenuBar); |
//¥ Add Apple Menu items |
AppendResMenu(GetMenuHandle(kMENUApple), 'DRVR'); |
DisposeHandleZ(&theMenuBar); |
if (! gNetSprocketPresent) |
{ |
menu = GetMenuHandle(kMENUFile); |
DisableItem(menu, iHostGame); |
DisableItem(menu, iJoinGame); |
} |
menu = GetMenuHandle(kMENUOptions); |
CheckItem(menu, iSoundEffects, gSoundEffects); |
CheckItem(menu, iCDAudio, gCDAudio); |
DrawMenuBar(); |
gMenuHandlerInited = true; |
} |
//¥ -------------------- MenuDoChoice |
void |
MenuDoChoice(SInt32 whichMenu) |
{ |
SInt16 theMenu; |
SInt16 theItem; |
Str255 daName; |
MenuRef theMenuHandle; |
if (! gMenuHandlerInited) |
return; |
theMenu = HiWord(whichMenu); |
theItem = LoWord(whichMenu); |
theMenuHandle = GetMenuHandle(theMenu); |
switch (theMenu) |
{ |
case kMENUApple: |
switch (theItem) |
{ |
case iAboutBox: |
AboutBox(); |
break; |
default: |
OpenDeskAcc(daName); |
break; |
} |
break; |
case kMENUFile: |
switch (theItem) |
{ |
case iNewGame: |
gNetPlay = false; |
InitNewGame(1); |
break; |
case iHostGame: |
if (DoHostGame()) |
{ |
gTwoPlayers = true; |
gNetPlay = true; |
InitNewGame(1); |
} |
break; |
case iJoinGame: |
if (DoJoinGame()) |
{ |
gTwoPlayers = true; |
gNetPlay = true; |
InitNewGame(1); |
} |
break; |
case iSelectMovie: |
SelectBackgroundMovie(); |
break; |
case iQuit: |
gDone = true; |
break; |
} |
break; |
case kMENUOptions: |
switch (theItem) |
{ |
case iConfigureInput: |
ISpConfigure(nil); |
break; |
case iConfigureSound: |
if (SSpConfigureSpeakerSetup == nil) |
Alert(kALRTNoSoundSprocket, nil); |
else |
SSpConfigureSpeakerSetup(nil); |
break; |
case iSoundEffects: |
gSoundEffects ^= 1; |
CheckItem(theMenuHandle, iSoundEffects, gSoundEffects); |
break; |
case iTwoPlayers: |
gTwoPlayers ^= 1; |
CheckItem(theMenuHandle, iTwoPlayers, gTwoPlayers); |
break; |
case iCDAudio: |
gCDAudio ^= 1; |
CheckItem(theMenuHandle, iCDAudio, gCDAudio); |
break; |
} |
} |
HiliteMenu(0); |
DrawMenuBar(); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-10-14