This is RiskController.m in view mode; [Download] [Up]
// RiskController.m
// Part of Risk by Mike Ferris
#import "RiskController.h"
#import "GameSetup.h"
#import "DiceInspector.h"
#import "DeckInspector.h"
#import "CardManager.h"
#import "Mover.h"
#import "DefaultManager.h"
#import <stdlib.h>
#import <strings.h>
#import <appkit/Panel.h>
#import <appkit/publicWraps.h>
#import <appkit/Button.h>
#import "LanguageApp.h"
#import <mach/mach_init.h>
#import <appkit/Speaker.h>
#import <appkit/Listener.h>
@implementation RiskController
+ initialize
{
if (self == [RiskController class]) {
[self setVersion:1];
}
return self;
}
- appDidInit:sender
{
infoPanel = nil;
helpPanel = nil;
diceInspector = nil;
deckInspector = nil;
[mapWindow setExcludedFromWindowsMenu:YES];
[theGameSetup appDidInit:self];
[theMover appDidInit:self];
[theMapView appDidInit:self];
[theCardManager appDidInit:self];
[controlPanel setBecomeKeyOnlyIfNeeded:YES];
return self;
}
- newAction:sender
{
int ret;
if ([theMover isGameInProgress]) {
ret = NXRunAlertPanel("Warning", "Are you sure you want to stop and "
"clear the game in progress to start a new one?",
"Yes", "Cancel", NULL);
if (ret == NX_ALERTALTERNATE) {
return nil;
}
}
[theGameSetup defaultSetup:self];
[theGameSetup newGame:self];
return self;
}
#define HELPDIRNAME "Help"
- helpAction:sender
// ask workspace to open a directory browser for the Help directory
{
int ok=0;
id ws = [Application workspace];
char dir[1000];
sprintf(dir, "%s/%s", [NXApp applicationDirectory], HELPDIRNAME);
if (![ws openFile:dir]) {
NXRunAlertPanel("Error", "Couldn't open file: %s", "OK",
NULL, NULL, dir);
}
return self;
}
- prefAction:sender
{
[theDefaultManager showPrefPanel:self];
return self;
}
- closeAction:sender
{
return self;
}
- infoAction:sender
{
if (infoPanel == nil) {
[NXApp loadNibSection:"Info.nib" owner:self withNames:NO];
}
[infoPanel makeKeyAndOrderFront:self];
return self;
}
#define fcall(a) [s performRemoteMethod:a]
#define call(a,b) [s performRemoteMethod:a with:b length:strlen(b)+1]
- suggestion:sender {
char subj[50]="Comments and suggestions for Risk .97";
char body[100]="Mike,\n\nI wanted to write you regarding Risk.\n";
id s = [NXApp appSpeaker];
NXPortFromName("Mail", NULL); // make sure app is launched
[s setSendPort:NXPortFromName("MailSendDemo", NULL)];
// sprintf(subj,"Comments and suggestions for Risk .97");
call("setTo:","mike@trirex.com");
call("setSubject:",subj);
call("setBody:",body);
return self;
}
- changeSetupAction:sender
{
[theGameSetup changeSettings:self];
return self;
}
- diceInspectorAction:sender
{
if (diceInspector == nil) {
diceInspector = [[DiceInspector allocFromZone:[self zone]] init];
[theMover setDiceInspector:diceInspector];
}
[diceInspector showPanel];
return self;
}
- deckInspectorAction:sender
{
{
if (deckInspector == nil) {
deckInspector = [[DeckInspector allocFromZone:[self zone]] init];
[theCardManager setDeckInspector:deckInspector];
}
[deckInspector showPanel];
return self;
}
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.