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.
Revision | d97d359231982cc5ef4915c0ba0b301fa92716f1 (tree) |
---|---|
Time | 2020-02-25 02:53:21 |
Author | Eric Branlund <ebranlund@fast...> |
Commiter | Eric Branlund |
Added menu item and backing value stored in the preferences to control whether big tile mode is enabled in the Cocoa front end.
@@ -30,6 +30,7 @@ | ||
30 | 30 | - (IBAction)saveGame:(id)sender; |
31 | 31 | - (IBAction)setRefreshRate:(NSMenuItem *)sender; |
32 | 32 | - (IBAction)toggleSound:(NSMenuItem *)menuItem; |
33 | +- (IBAction)toggleWideTiles:(NSMenuItem *)sender; | |
33 | 34 | - (void)setGraphicsMode:(NSMenuItem *)sender; |
34 | 35 | - (void)selectWindow:(id)sender; |
35 | 36 |
@@ -106,6 +106,9 @@ | ||
106 | 106 | - (IBAction)toggleSound:(NSMenuItem*)menuItem { |
107 | 107 | } |
108 | 108 | |
109 | +- (IBAction)toggleWideTiles:(NSMenuItem *)sender { | |
110 | +} | |
111 | + | |
109 | 112 | - (IBAction)setGraphicsMode:(NSMenuItem *)sender { |
110 | 113 | } |
111 | 114 |
@@ -154,6 +154,12 @@ | ||
154 | 154 | <action selector="toggleSound:" target="Voe-Tx-rLC" id="y1f-OG-ExO"/> |
155 | 155 | </connections> |
156 | 156 | </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> | |
157 | 163 | </items> |
158 | 164 | </menu> |
159 | 165 | </menuItem> |
@@ -88,6 +88,9 @@ | ||
88 | 88 | /* Class = "NSMenu"; title = "Window"; ObjectID = "Td7-aD-5lo"; */ |
89 | 89 | "Td7-aD-5lo.title" = "ウインドウ"; |
90 | 90 | |
91 | +/* Class = "NSMenuItem"; title = "Toggle Wide Tiles"; ObjectID = "tR9-z3-4SZ"; */ | |
92 | +"tR9-z3-4SZ.title" = "広いタイルを切り替え"; | |
93 | + | |
91 | 94 | /* Class = "NSMenu"; title = "Hengband"; ObjectID = "uQy-DD-JDr"; */ |
92 | 95 | "uQy-DD-JDr.title" = "変愚蛮怒"; |
93 | 96 |
@@ -41,6 +41,7 @@ static NSString * const AngbandTerminalRowsDefaultsKey = @"Rows"; | ||
41 | 41 | static NSString * const AngbandTerminalColumnsDefaultsKey = @"Columns"; |
42 | 42 | static NSString * const AngbandTerminalVisibleDefaultsKey = @"Visible"; |
43 | 43 | static NSString * const AngbandGraphicsDefaultsKey = @"GraphicsID"; |
44 | +static NSString * const AngbandBigTileDefaultsKey = @"UseBigTiles"; | |
44 | 45 | static NSString * const AngbandFrameRateDefaultsKey = @"FramesPerSecond"; |
45 | 46 | static NSString * const AngbandSoundDefaultsKey = @"AllowSound"; |
46 | 47 | static NSInteger const AngbandWindowMenuItemTagBase = 1000; |
@@ -2236,6 +2237,9 @@ static errr Term_xtra_cocoa_react(void) | ||
2236 | 2237 | /* If we failed to create the image, revert to ASCII. */ |
2237 | 2238 | if (! pict_image) { |
2238 | 2239 | new_mode = NULL; |
2240 | + if (use_bigtile) { | |
2241 | + arg_bigtile = FALSE; | |
2242 | + } | |
2239 | 2243 | [[NSUserDefaults angbandDefaults] |
2240 | 2244 | setInteger:GRAPHICS_NONE |
2241 | 2245 | forKey:AngbandGraphicsDefaultsKey]; |
@@ -2285,12 +2289,20 @@ static errr Term_xtra_cocoa_react(void) | ||
2285 | 2289 | } |
2286 | 2290 | |
2287 | 2291 | /* Reset visuals */ |
2288 | - if (initialized && game_in_progress) | |
2292 | + if (arg_bigtile == use_bigtile) | |
2289 | 2293 | { |
2290 | 2294 | reset_visuals(); |
2291 | 2295 | } |
2292 | 2296 | } |
2293 | 2297 | |
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 | + | |
2294 | 2306 | [pool drain]; |
2295 | 2307 | |
2296 | 2308 | /* Success */ |
@@ -3313,6 +3325,7 @@ static void load_prefs() | ||
3313 | 3325 | [NSNumber numberWithInt:60], AngbandFrameRateDefaultsKey, |
3314 | 3326 | [NSNumber numberWithBool:YES], AngbandSoundDefaultsKey, |
3315 | 3327 | [NSNumber numberWithInt:GRAPHICS_NONE], AngbandGraphicsDefaultsKey, |
3328 | + [NSNumber numberWithBool:YES], AngbandBigTileDefaultsKey, | |
3316 | 3329 | defaultTerms, AngbandTerminalsDefaultsKey, |
3317 | 3330 | nil]; |
3318 | 3331 | [defs registerDefaults:defaults]; |
@@ -3321,7 +3334,16 @@ static void load_prefs() | ||
3321 | 3334 | |
3322 | 3335 | /* Preferred graphics mode */ |
3323 | 3336 | 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 | + | |
3325 | 3347 | /* Use sounds; set the Angband global */ |
3326 | 3348 | use_sound = ([defs boolForKey:AngbandSoundDefaultsKey] == YES) ? TRUE : FALSE; |
3327 | 3349 |
@@ -4192,8 +4214,23 @@ static void hook_quit(const char * str) | ||
4192 | 4214 | [[NSUserDefaults angbandDefaults] setInteger:graf_mode_req forKey:AngbandGraphicsDefaultsKey]; |
4193 | 4215 | [[NSUserDefaults angbandDefaults] synchronize]; |
4194 | 4216 | |
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 | + | |
4195 | 4227 | if (game_in_progress) |
4196 | 4228 | { |
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 | + | |
4197 | 4234 | /* Hack -- Force redraw */ |
4198 | 4235 | do_cmd_redraw(); |
4199 | 4236 |
@@ -4213,6 +4250,27 @@ static void hook_quit(const char * str) | ||
4213 | 4250 | forKey:AngbandSoundDefaultsKey]; |
4214 | 4251 | } |
4215 | 4252 | |
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 | + | |
4216 | 4274 | /** |
4217 | 4275 | * Send a command to Angband via a menu item. This places the appropriate key |
4218 | 4276 | * down events into the queue so that it seems like the user pressed them |