• R/O
  • HTTP
  • SSH
  • HTTPS

hengbandosx: Commit

The master and develop branches track hengband.

OS X development happens on the macos-1-6-2, macos-2-2-1, and macos-develop branches.


Commit MetaInfo

Revisiond97d359231982cc5ef4915c0ba0b301fa92716f1 (tree)
Time2020-02-25 02:53:21
AuthorEric Branlund <ebranlund@fast...>
CommiterEric Branlund

Log Message

Added menu item and backing value stored in the preferences to control whether big tile mode is enabled in the Cocoa front end.

Change Summary

Incremental Difference

--- a/src/cocoa/AppDelegate.h
+++ b/src/cocoa/AppDelegate.h
@@ -30,6 +30,7 @@
3030 - (IBAction)saveGame:(id)sender;
3131 - (IBAction)setRefreshRate:(NSMenuItem *)sender;
3232 - (IBAction)toggleSound:(NSMenuItem *)menuItem;
33+- (IBAction)toggleWideTiles:(NSMenuItem *)sender;
3334 - (void)setGraphicsMode:(NSMenuItem *)sender;
3435 - (void)selectWindow:(id)sender;
3536
--- a/src/cocoa/AppDelegate.m
+++ b/src/cocoa/AppDelegate.m
@@ -106,6 +106,9 @@
106106 - (IBAction)toggleSound:(NSMenuItem*)menuItem {
107107 }
108108
109+- (IBAction)toggleWideTiles:(NSMenuItem *)sender {
110+}
111+
109112 - (IBAction)setGraphicsMode:(NSMenuItem *)sender {
110113 }
111114
Binary files a/src/cocoa/Base.lproj/MainMenu.nib and b/src/cocoa/Base.lproj/MainMenu.nib differ
--- a/src/cocoa/Base.lproj/MainMenu.xib
+++ b/src/cocoa/Base.lproj/MainMenu.xib
@@ -154,6 +154,12 @@
154154 <action selector="toggleSound:" target="Voe-Tx-rLC" id="y1f-OG-ExO"/>
155155 </connections>
156156 </menuItem>
157+ <menuItem title="Toggle Wide Tiles" state="on" id="tR9-z3-4SZ" userLabel="Toggle Wide Tiles">
158+ <modifierMask key="keyEquivalentModifierMask"/>
159+ <connections>
160+ <action selector="toggleWideTiles:" target="Voe-Tx-rLC" id="fLa-ij-GCQ"/>
161+ </connections>
162+ </menuItem>
157163 </items>
158164 </menu>
159165 </menuItem>
--- a/src/cocoa/ja.lproj/MainMenu.strings
+++ b/src/cocoa/ja.lproj/MainMenu.strings
@@ -88,6 +88,9 @@
8888 /* Class = "NSMenu"; title = "Window"; ObjectID = "Td7-aD-5lo"; */
8989 "Td7-aD-5lo.title" = "ウインドウ";
9090
91+/* Class = "NSMenuItem"; title = "Toggle Wide Tiles"; ObjectID = "tR9-z3-4SZ"; */
92+"tR9-z3-4SZ.title" = "広いタイルを切り替え";
93+
9194 /* Class = "NSMenu"; title = "Hengband"; ObjectID = "uQy-DD-JDr"; */
9295 "uQy-DD-JDr.title" = "変愚蛮怒";
9396
--- a/src/main-cocoa.m
+++ b/src/main-cocoa.m
@@ -41,6 +41,7 @@ static NSString * const AngbandTerminalRowsDefaultsKey = @"Rows";
4141 static NSString * const AngbandTerminalColumnsDefaultsKey = @"Columns";
4242 static NSString * const AngbandTerminalVisibleDefaultsKey = @"Visible";
4343 static NSString * const AngbandGraphicsDefaultsKey = @"GraphicsID";
44+static NSString * const AngbandBigTileDefaultsKey = @"UseBigTiles";
4445 static NSString * const AngbandFrameRateDefaultsKey = @"FramesPerSecond";
4546 static NSString * const AngbandSoundDefaultsKey = @"AllowSound";
4647 static NSInteger const AngbandWindowMenuItemTagBase = 1000;
@@ -2236,6 +2237,9 @@ static errr Term_xtra_cocoa_react(void)
22362237 /* If we failed to create the image, revert to ASCII. */
22372238 if (! pict_image) {
22382239 new_mode = NULL;
2240+ if (use_bigtile) {
2241+ arg_bigtile = FALSE;
2242+ }
22392243 [[NSUserDefaults angbandDefaults]
22402244 setInteger:GRAPHICS_NONE
22412245 forKey:AngbandGraphicsDefaultsKey];
@@ -2285,12 +2289,20 @@ static errr Term_xtra_cocoa_react(void)
22852289 }
22862290
22872291 /* Reset visuals */
2288- if (initialized && game_in_progress)
2292+ if (arg_bigtile == use_bigtile)
22892293 {
22902294 reset_visuals();
22912295 }
22922296 }
22932297
2298+ if (arg_bigtile != use_bigtile) {
2299+ /* Reset visuals */
2300+ reset_visuals();
2301+
2302+ Term_activate(angband_term[0]);
2303+ Term_resize(angband_term[0]->wid, angband_term[0]->hgt);
2304+ }
2305+
22942306 [pool drain];
22952307
22962308 /* Success */
@@ -3313,6 +3325,7 @@ static void load_prefs()
33133325 [NSNumber numberWithInt:60], AngbandFrameRateDefaultsKey,
33143326 [NSNumber numberWithBool:YES], AngbandSoundDefaultsKey,
33153327 [NSNumber numberWithInt:GRAPHICS_NONE], AngbandGraphicsDefaultsKey,
3328+ [NSNumber numberWithBool:YES], AngbandBigTileDefaultsKey,
33163329 defaultTerms, AngbandTerminalsDefaultsKey,
33173330 nil];
33183331 [defs registerDefaults:defaults];
@@ -3321,7 +3334,16 @@ static void load_prefs()
33213334
33223335 /* Preferred graphics mode */
33233336 graf_mode_req = [defs integerForKey:AngbandGraphicsDefaultsKey];
3324-
3337+ if (graf_mode_req != GRAPHICS_NONE &&
3338+ get_graphics_mode(graf_mode_req)->grafID != GRAPHICS_NONE &&
3339+ [defs boolForKey:AngbandBigTileDefaultsKey] == YES) {
3340+ use_bigtile = TRUE;
3341+ arg_bigtile = TRUE;
3342+ } else {
3343+ use_bigtile = FALSE;
3344+ arg_bigtile = FALSE;
3345+ }
3346+
33253347 /* Use sounds; set the Angband global */
33263348 use_sound = ([defs boolForKey:AngbandSoundDefaultsKey] == YES) ? TRUE : FALSE;
33273349
@@ -4192,8 +4214,23 @@ static void hook_quit(const char * str)
41924214 [[NSUserDefaults angbandDefaults] setInteger:graf_mode_req forKey:AngbandGraphicsDefaultsKey];
41934215 [[NSUserDefaults angbandDefaults] synchronize];
41944216
4217+ if (graf_mode_req == GRAPHICS_NONE ||
4218+ get_graphics_mode(graf_mode_req) == GRAPHICS_NONE) {
4219+ if (use_bigtile) {
4220+ arg_bigtile = FALSE;
4221+ }
4222+ } else if ([[NSUserDefaults angbandDefaults] boolForKey:AngbandBigTileDefaultsKey] == YES &&
4223+ ! use_bigtile) {
4224+ arg_bigtile = TRUE;
4225+ }
4226+
41954227 if (game_in_progress)
41964228 {
4229+ if (arg_bigtile != use_bigtile) {
4230+ Term_activate(angband_term[0]);
4231+ Term_resize(angband_term[0]->wid, angband_term[0]->hgt);
4232+ }
4233+
41974234 /* Hack -- Force redraw */
41984235 do_cmd_redraw();
41994236
@@ -4213,6 +4250,27 @@ static void hook_quit(const char * str)
42134250 forKey:AngbandSoundDefaultsKey];
42144251 }
42154252
4253+- (IBAction)toggleWideTiles:(NSMenuItem *) sender
4254+{
4255+ BOOL is_on = (sender.state == NSOnState);
4256+
4257+ /* Toggle the state and update the Angband globals and preferences. */
4258+ sender.state = (is_on) ? NSOffState : NSOnState;
4259+ [[NSUserDefaults angbandDefaults] setBool:(! is_on)
4260+ forKey:AngbandBigTileDefaultsKey];
4261+ [[NSUserDefaults angbandDefaults] synchronize];
4262+ if (graphics_are_enabled()) {
4263+ arg_bigtile = (is_on) ? FALSE : TRUE;
4264+ /* Mimics the logic in setGraphicsMode(). */
4265+ if (game_in_progress && arg_bigtile != use_bigtile) {
4266+ Term_activate(angband_term[0]);
4267+ Term_resize(angband_term[0]->wid, angband_term[0]->hgt);
4268+ do_cmd_redraw();
4269+ wakeup_event_loop();
4270+ }
4271+ }
4272+}
4273+
42164274 /**
42174275 * Send a command to Angband via a menu item. This places the appropriate key
42184276 * down events into the queue so that it seems like the user pressed them
Show on old repository browser