This is DiceInspector.m in view mode; [Download] [Up]
// DiceInspector.m
// Part of Risk by Mike Ferris
#import "DiceInspector.h"
#import "LanguageApp.h"
#import <appkit/Button.h>
#import <appkit/Panel.h>
#import <appkit/TextField.h>
#import <appkit/publicWraps.h>
@implementation DiceInspector
+ initialize
{
if (self == [DiceInspector class]) {
[self setVersion:1];
}
return self;
}
- init
{
[super init];
[NXApp loadNibSection:"DiceInspector.nib" owner:self withNames:NO];
[attackerButton1 setImage:nil];
[attackerButton2 setImage:nil];
[attackerButton3 setImage:nil];
[defenderButton1 setImage:nil];
[defenderButton2 setImage:nil];
[dicePanel setBecomeKeyOnlyIfNeeded:YES];
[dicePanel orderFront:self];
return self;
}
- free
{
return [super free];
}
- showPanel
{
[dicePanel orderFront:self];
return self;
}
- (BOOL)panelOnScreen
{
return [dicePanel isVisible];
}
- setButton:button fromInt:(int)val
{
switch (val) {
case 1:
[button setIcon:"Die1"];
break;
case 2:
[button setIcon:"Die2"];
break;
case 3:
[button setIcon:"Die3"];
break;
case 4:
[button setIcon:"Die4"];
break;
case 5:
[button setIcon:"Die5"];
break;
case 6:
[button setIcon:"Die6"];
break;
default:
[button setImage:nil];
break;
}
return self;
}
- setFromCountry:(const char *)fc toCountry:(const char *)tc
fromArmies:(int)fa toArmies:(int)ta attackerRolling:(int)ar
attackerUsing:(int)au attackerDie1:(int)ad1 attackerDie2:(int)ad2
attackerDie3:(int)ad3 defenderRolling:(int)dr defenderUsing:(int)du
attackerDie1:(int)dd1 attackerDie2:(int)dd2
{
[fromCountryField setStringValue:fc];
[toCountryField setStringValue:tc];
[fromArmiesField setIntValue:fa];
[toArmiesField setIntValue:ta];
[attackerRollingField setIntValue:ar];
[attackerUsingField setIntValue:au];
[self setButton:attackerButton1 fromInt:((ar > 0)?ad1:-1)];
[self setButton:attackerButton2 fromInt:((ar > 1)?ad2:-1)];
[self setButton:attackerButton3 fromInt:((ar > 2)?ad3:-1)];
[defenderRollingField setIntValue:dr];
[defenderUsingField setIntValue:du];
[self setButton:defenderButton1 fromInt:((dr > 0)?dd1:-1)];
[self setButton:defenderButton2 fromInt:((dr > 1)?dd2:-1)];
if ([pauseCheckBox state] == 1) {
[self waitForContinue];
}
return self;
}
- waitForContinue
{
int retVal;
NXBeep();
[dicePanel orderFront:self];
retVal = [NXApp runModalFor:dicePanel];
return self;
}
- continueAction:sender
{
[NXApp stopModal];
return self;
}
- pauseCheckAction:sender
{
[NXApp stopModal];
if ([sender state] == 1) {
[continueButton setEnabled:YES];
} else {
[continueButton setEnabled:NO];
}
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.