*/
#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 =
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
{
/*
* 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]