OSDN Git Service

In case a tile set fails to load, provide feedback to the user in the form of an...
authorEric Branlund <ebranlund@fastmail.com>
Fri, 21 Feb 2020 03:34:51 +0000 (19:34 -0800)
committerEric Branlund <ebranlund@fastmail.com>
Fri, 21 Feb 2020 03:34:51 +0000 (19:34 -0800)
src/cocoa/en.lproj/Localizable.strings
src/cocoa/ja.lproj/Localizable.strings
src/main-cocoa.m

index 3c82f51..b5d1359 100644 (file)
@@ -7,5 +7,11 @@
 /* Alert informative message for missing Angband lib/ folder */
 "Error.MissingAngbandLib" = "Hengband was unable to find required resources and must quit. Please send a bug report to \"hengband-dev@lists.sourceforge.jp\".";
 
+/* Alert text for failed tile set load */
+"Error.TileSetLoadFailed" = "Failed to Load Tile Set";
+
+/* Alert informative message for failed tile set load */
+"Error.TileSetRevertToASCII" = "Could not load the tile set.  Switched back to ASCII.";
+
 /* Quit */
 "Label.Quit" = "Quit";
index f081c54..ef8190c 100644 (file)
@@ -7,5 +7,11 @@
 /* Alert informative message for missing Angband lib/ folder */
 "Error.MissingAngbandLib" = "変愚蛮怒 は必要なリソースを見つけることができなかったため、終了する必要があります。 バグレポートを「hengband-dev@lists.sourceforge.jp」に送信してください。";
 
+/* Alert text for failed tile set load */
+"Error.TileSetLoadFailed" = "タイルセットを読み込めませんでした";
+
+/* Alert informative message for failed tile set load */
+"Error.TileSetRevertToASCII" = "タイルセットを読み込めませんでした。 ASCIIに切り替えます。";
+
 /* Quit */
 "Label.Quit" = "を終了";
index 1ef7623..d47ddf8 100644 (file)
@@ -2233,10 +2233,33 @@ static errr Term_xtra_cocoa_react(void)
             NSString *img_path = [NSString stringWithFormat:@"%s/%s", new_mode->path, new_mode->file];
             pict_image = create_angband_image(img_path);
 
-            /* If we failed to create the image, set the new desired mode to
-                        * NULL */
-            if (! pict_image)
+            /* If we failed to create the image, revert to ASCII. */
+            if (! pict_image) {
                 new_mode = NULL;
+               [[NSUserDefaults angbandDefaults]
+                   setInteger:GRAPHICS_NONE
+                   forKey:AngbandGraphicsDefaultsKey];
+               [[NSUserDefaults angbandDefaults] synchronize];
+
+               NSString *msg = NSLocalizedStringWithDefaultValue(
+                   @"Error.TileSetLoadFailed",
+                   AngbandMessageCatalog,
+                   [NSBundle mainBundle],
+                   @"Failed to Load Tile Set",
+                   @"Alert text for failed tile set load");
+               NSString *info = NSLocalizedStringWithDefaultValue(
+                   @"Error.TileSetRevertToASCII",
+                   AngbandMessageCatalog,
+                   [NSBundle mainBundle],
+                   @"Could not load the tile set.  Switched back to ASCII.",
+                   @"Alert informative message for failed tile set load");
+               NSAlert *alert = [[NSAlert alloc] init];
+
+               alert.messageText = msg;
+               alert.informativeText = info;
+               NSModalResponse result = [alert runModal];
+               [alert release];
+           }
         }
         
         /* Record what we did */