- (void)playSound:(int)event;
/**
- * Impose an arbitary limit on number of possible samples per event.
+ * Impose an arbitrary limit on the number of possible samples per event.
* Currently not declaring this as a class property for compatibility with
* versions of Xcode prior to 8.
*/
+ (AngbandSoundCatalog*)sharedSounds;
/**
- * Release any resouces associated with shared sounds.
+ * Release any resources associated with shared sounds.
*/
+ (void)clearSharedSounds;
if (gSharedSounds == nil) {
gSharedSounds = [[AngbandSoundCatalog alloc] init];
}
- return gSharedSounds;;
+ return gSharedSounds;
}
+ (void)clearSharedSounds {
*/
#define GLYPH_COUNT 256
-/* An AngbandContext represents a logical Term (i.e. what Angband thinks is
- * a window). */
+/*
+ * An AngbandContext represents a logical Term (i.e. what Angband thinks is
+ * a window).
+ */
@interface AngbandContext : NSObject <NSWindowDelegate>
{
@public
- (void)drawWChar:(wchar_t)wchar inRect:(NSRect)tile screenFont:(NSFont*)font
context:(CGContextRef)ctx;
-/* Returns the primary window for this angband context, creating it if
- * necessary */
+/*
+ * Returns the primary window for this angband context, creating it if
+ * necessary
+ */
- (NSWindow *)makePrimaryWindow;
/* Handle becoming the main window */
*/
static void AngbandUpdateWindowVisibility(void)
{
- /* Because this function is called frequently, we'll make the mask static.
- * It doesn't change between calls, as the flags themselves are hardcoded */
+ /*
+ * Because this function is called frequently, we'll make the mask static.
+ * It doesn't change between calls, as the flags themselves are hardcoded
+ */
static u32b validWindowFlagsMask = 0;
if( validWindowFlagsMask == 0 )
validWindowFlagsMask = AngbandMaskForValidSubwindowFlags();
}
- /* Loop through all of the subwindows and see if there is a change in the
- * flags. If so, show or hide the corresponding window. We don't care about
- * the flags themselves; we just want to know if any are set. */
+ /*
+ * Loop through all of the subwindows and see if there is a change in the
+ * flags. If so, show or hide the corresponding window. We don't care about
+ * the flags themselves; we just want to know if any are set.
+ */
for( int i = 1; i < ANGBAND_TERM_MAX; i++ )
{
AngbandContext *angbandContext =
continue;
}
- /* This horrible mess of flags is so that we can try to maintain some
- * user visibility preference. This should allow the user a window and
- * have it stay closed between application launches. However, this
- * means that when a subwindow is turned on, it will no longer appear
- * automatically. Angband has no concept of user control over window
- * visibility, other than the subwindow flags. */
+ /*
+ * This horrible mess of flags is so that we can try to maintain some
+ * user visibility preference. This should allow the user a window and
+ * have it stay closed between application launches. However, this
+ * means that when a subwindow is turned on, it will no longer appear
+ * automatically. Angband has no concept of user control over window
+ * visibility, other than the subwindow flags.
+ */
if( !angbandContext.windowVisibilityChecked )
{
if( [angbandContext windowVisibleUsingDefaults] )
}
@end
-/* Methods for pulling images out of the Angband bundle (which may be separate
- * from the current bundle in the case of a screensaver */
+/*
+ * Methods for pulling images out of the Angband bundle (which may be separate
+ * from the current bundle in the case of a screensaver
+ */
@interface NSImage (AngbandImages)
+ (NSImage *)angbandImage:(NSString *)name;
@end
@implementation NSImage (AngbandImages)
-/* Returns an image in the resource directoy of the bundle containing the
- * Angband view class. */
+/*
+ * Returns an image in the resource directoy of the bundle containing the
+ * Angband view class.
+ */
+ (NSImage *)angbandImage:(NSString *)name
{
NSBundle *bundle = [NSBundle bundleForClass:[AngbandView class]];
advances, 1);
CGSize advance = advances[0];
- /* If our font is not monospaced, our tile width is deliberately not big
- * enough for every character. In that event, if our glyph is too wide, we
- * need to compress it horizontally. Compute the compression ratio.
- * 1.0 means no compression. */
+ /*
+ * If our font is not monospaced, our tile width is deliberately not big
+ * enough for every character. In that event, if our glyph is too wide, we
+ * need to compress it horizontally. Compute the compression ratio.
+ * 1.0 means no compression.
+ */
double compressionRatio;
if (advance.width <= NSWidth(tile))
{
if( adjustTerminal )
{
- /* Adjust terminal to fit window with new font; save the new columns
- * and rows since they could be changed */
+ /*
+ * Adjust terminal to fit window with new font; save the new columns
+ * and rows since they could be changed
+ */
NSRect contentRect =
[self.primaryWindow
contentRectForFrameRect: [self.primaryWindow frame]];
{
if (! self.primaryWindow)
{
- /* This has to be done after the font is set, which it already is in
- * term_init_cocoa() */
+ /*
+ * This has to be done after the font is set, which it already is in
+ * term_init_cocoa()
+ */
NSSize sz = self.baseSize;
NSRect contentRect = NSMakeRect( 0.0, 0.0, sz.width, sz.height );
*/
- (void)drawRect:(NSRect)rect inView:(NSView *)view
{
- /* Take this opportunity to throttle so we don't flush faster than desired.
- */
+ /*
+ * Take this opportunity to throttle so we don't flush faster than desired.
+ */
[self throttle];
CGFloat bottomY =
NSGraphicsContext *nsctx = nil;
CGContextRef ctx = 0;
NSFont* screenFont = nil;
- term *old = 0;
int graf_width = 0, graf_height = 0;
int overdraw_row = 0, overdraw_max = 0;
wchar_t blank = 0;
rect.origin.x + rect.size.width > self.borderSize.width &&
rect.origin.y < bottomY &&
rect.origin.y + rect.size.height > self.borderSize.height) {
- old = Term;
- Term_activate(self->terminal);
nsctx = [NSGraphicsContext currentContext];
ctx = [nsctx graphicsPort];
screenFont = [self.angbandViewFont screenFont];
if (overdraw_row && invalidCount > 1) {
sortedRects = malloc(invalidCount * sizeof(NSRect));
if (sortedRects == 0) {
- if (old != 0) {
- Term_activate(old);
- }
NSException *exc = [NSException exceptionWithName:@"OutOfMemory"
reason:@"sorted rects in drawRect"
userInfo:nil];
}
free(sortedRects);
- if (old != 0) {
- Term_activate(old);
- }
}
- (BOOL)isOrderedIn
{
/* Hack -- Forget messages and term */
msg_flag = FALSE;
- Term->mapped_flag = FALSE;
+ Term->mapped_flag = FALSE;
/* Save the game */
do_cmd_save_game(FALSE);
NSSize border = angbandContext.borderSize;
NSPoint windowPoint = [event locationInWindow];
- /* Adjust for border; add border height because window origin is at
- * bottom */
+ /*
+ * Adjust for border; add border height because window origin
+ * is at bottom
+ */
windowPoint = NSMakePoint( windowPoint.x - border.width, windowPoint.y + border.height );
NSPoint p = [[[event window] contentView] convertPoint: windowPoint fromView: nil];
x = floor( p.x / tileSize.width );
y = floor( p.y / tileSize.height );
- /* Being safe about this, since xcode doesn't seem to like the
- * bool_hack stuff */
+ /*
+ * Being safe about this, since xcode doesn't seem to like the
+ * bool_hack stuff
+ */
BOOL displayingMapInterface = ((int)inkey_flag != 0);
/* Sidebar plus border == thirteen characters; top row is reserved. */
/* Coordinates run from (0,0) to (cols-1, rows-1). */
BOOL mouseInMapSection = (x > 13 && x <= cols - 1 && y > 0 && y <= rows - 2);
- /* If we are displaying a menu, allow clicks anywhere within
+ /*
+ * If we are displaying a menu, allow clicks anywhere within
* the terminal bounds; if we are displaying the main game
- * interface, only allow clicks in the map section */
+ * interface, only allow clicks in the map section
+ */
if ((!displayingMapInterface && x >= 0 && x < cols &&
y >= 0 && y < rows) ||
(displayingMapInterface && mouseInMapSection))
{
- /* [event buttonNumber] will return 0 for left click,
- * 1 for right click, but this is safer */
+ /*
+ * [event buttonNumber] will return 0 for left click,
+ * 1 for right click, but this is safer
+ */
int button = ([event type] == NSLeftMouseDown) ? 1 : 2;
#ifdef KC_MOD_ALT
if( !libExists || !isDirectory )
{
- NSLog( @"Hengband: can't find %@/ in bundle: isDirectory: %d libExists: %d", AngbandDirectoryNameLib, isDirectory, libExists );
+ NSLog( @"%@: can't find %@/ in bundle: isDirectory: %d libExists: %d", @VERSION_NAME, AngbandDirectoryNameLib, isDirectory, libExists );
NSString *msg = NSLocalizedStringWithDefaultValue(
@"Error.MissingResources",
/* Initialize the term */
term_init(newterm, columns, rows, 256 /* keypresses, for some reason? */);
- /* Differentiate between BS/^h, Tab/^i, etc. */
- /* newterm->complex_input = TRUE; */
-
/* Use a "software" cursor */
newterm->soft_cursor = TRUE;
/* Disable the per-row flush notifications since they are not used. */
newterm->never_frosh = TRUE;
+ /*
+ * Differentiate between BS/^h, Tab/^i, ... so ^h and ^j work under the
+ * roguelike command set.
+ */
+ /* newterm->complex_input = TRUE; */
+
/* Erase with "white space" */
newterm->attr_blank = TERM_WHITE;
newterm->char_blank = ' ';
{
/*
* Another window is only usable after Term_init_cocoa() has
- * been called for it. For Angband if window_flag[i] is nonzero
+ * been called for it. For Angband, if window_flag[i] is nonzero
* then that has happened for window i. For Hengband, that is
* not the case so also test angband_term[i]->data.
*/
{
[self beginGame];
- /* Once beginGame finished, the game is over - that's how Angband works,
- * and we should quit */
+ /*
+ * Once beginGame finished, the game is over - that's how Angband works,
+ * and we should quit
+ */
game_is_finished = TRUE;
[NSApp terminate:self];
}
/* Stop playing */
/* player->upkeep->playing = FALSE; */
- /* Post an escape event so that we can return from our get-key-event
- * function */
+ /*
+ * Post an escape event so that we can return from our get-key-event
+ * function
+ */
wakeup_event_loop();
quit_when_ready = true;
- /* Must return Cancel, not Later, because we need to get out of the
- * run loop and back to Angband's loop */
+ /*
+ * Must return Cancel, not Later, because we need to get out of the
+ * run loop and back to Angband's loop
+ */
return NSTerminateCancel;
}
}
if (! [menu isEqual:self.graphicsMenu])
return;
- /* If it's non-empty, then we've already built it. Currently graphics modes
- * won't change once created; if they ever can we can remove this check.
+ /*
+ * If it's non-empty, then we've already built it. Currently graphics modes
+ * won't change once created; if they ever can we can remove this check.
* Note that the check mark does change, but that's handled in
- * validateMenuItem: instead of menuNeedsUpdate: */
+ * validateMenuItem: instead of menuNeedsUpdate:
+ */
if ([menu numberOfItems] > 0)
return;
game_in_progress = TRUE;
- /* Wake us up in case this arrives while we're sitting at the Welcome
- * screen! */
+ /*
+ * Wake us up in case this arrives while we're sitting at the Welcome
+ * screen!
+ */
wakeup_event_loop();
[[NSApplication sharedApplication]