OSDN Git Service

プレイヤーが死亡して次のプレイで名前を変えるとセーブファイルが新規作
[hengband/hengband.git] / src / main-x11.c
index 092dc35..3fccd1c 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
 /*
  * ÆüËܸì(EUC-JAPAN)Âбþ (-DJP)
  *    ¡¦´Á»ú¥Õ¥©¥ó¥È¤Î°·¤¤¤òÄɲÃ
@@ -456,7 +456,7 @@ static infowin *Infowin = (infowin*)(NULL);
 static infowin *Focuswin = (infowin*)(NULL);
 #endif
 static infoclr *Infoclr = (infoclr*)(NULL);
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
 static infofnt *Infofnt = (infofnt*)(NULL);
 static infofnt *Infokfnt = (infofnt*)(NULL);
 #else
@@ -469,7 +469,7 @@ static infofnt *Infofnt = (infofnt*)(NULL);
 /**** Generic code ****/
 
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
 #define Infokfnt_set(I) \
        (Infokfnt = (I))
 #endif
@@ -1228,7 +1228,7 @@ static errr Infofnt_nuke(void)
 {
        infofnt *ifnt = Infofnt;
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        infofnt *ikfnt = Infokfnt;
 #endif
        /* Deal with 'name' */
@@ -1238,21 +1238,26 @@ static errr Infofnt_nuke(void)
                string_free(ifnt->name);
        }
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        if (ikfnt->name)
        {
                /* Free the name */
                string_free(ikfnt->name);
        }
 #endif
+
        /* Nuke info if needed */
        if (ifnt->nuke)
        {
                /* Free the font */
+#ifdef USE_FONTSET
+               XFreeFontSet(Metadpy->dpy, ifnt->info);
+#else
                XFreeFont(Metadpy->dpy, ifnt->info);
+#endif
        }
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        if (ikfnt->nuke)
        {
                /* Free the font */
@@ -1269,7 +1274,7 @@ static errr Infofnt_nuke(void)
 /*
  * Prepare a new 'infofnt'
  */
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
 static errr Infofnt_prepare(XFontStruct *info, XFontStruct *kinfo)
 #else
 #ifdef USE_FONTSET
@@ -1282,7 +1287,7 @@ static errr Infofnt_prepare(XFontStruct *info)
 {
        infofnt *ifnt = Infofnt;
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        infofnt *ikfnt = Infokfnt;
 #endif
        XCharStruct *cs;
@@ -1331,7 +1336,7 @@ static errr Infofnt_prepare(XFontStruct *info)
        else
                ifnt->twid = ifnt->wid;
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
     /* Assign the struct */
     ikfnt->info = kinfo;
  
@@ -1362,7 +1367,7 @@ static errr Infofnt_prepare(XFontStruct *info)
 /*
  * Initialize a new 'infofnt'.
  */
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
 static errr Infofnt_init_real(XFontStruct *info, XFontStruct *kinfo)
 #else
 #ifdef USE_FONTSET
@@ -1376,17 +1381,17 @@ static errr Infofnt_init_real(XFontStruct *info)
        /* Wipe the thing */
        (void)WIPE(Infofnt, infofnt);
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        WIPE(Infokfnt, infofnt);
 #endif
        /* No nuking */
        Infofnt->nuke = 0;
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        Infokfnt->nuke = 0;
 #endif
        /* Attempt to prepare it */
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        return (Infofnt_prepare (info, kinfo));
 #else
        return (Infofnt_prepare(info));
@@ -1403,7 +1408,7 @@ static errr Infofnt_init_real(XFontStruct *info)
  * Inputs:
  *     name: The name of the requested Font
  */
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
 static void Infofnt_init_data(cptr name, cptr kname)
 #else
 static void Infofnt_init_data(cptr name)
@@ -1420,7 +1425,7 @@ static void Infofnt_init_data(cptr name)
 #endif
 
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        XFontStruct *kinfo;
 #endif
        /*** Load the info Fresh, using the name ***/
@@ -1428,7 +1433,7 @@ static void Infofnt_init_data(cptr name)
        /* If the name is not given, report an error */
        if (!name || !*name) quit("Missing font!");
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        if (!kname || !*kname) quit("Missing kanji font!");
 #endif
        /* Attempt to load the font */
@@ -1443,7 +1448,7 @@ static void Infofnt_init_data(cptr name)
        }
 #else
        info = XLoadQueryFont(Metadpy->dpy, name);
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        kinfo = XLoadQueryFont(Metadpy->dpy, kname);
 #endif
 #endif
@@ -1451,7 +1456,7 @@ static void Infofnt_init_data(cptr name)
 
        /* The load failed, try to recover */
        if (!info) quit_fmt("Failed to find font:\"%s\"", name);
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        if (!kinfo) quit_fmt("Failed to find font:\"%s\"", kname);
 #endif
 
@@ -1462,11 +1467,11 @@ static void Infofnt_init_data(cptr name)
        /* Wipe the thing */
        (void)WIPE(Infofnt, infofnt);
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        WIPE(Infokfnt, infofnt);
 #endif
        /* Attempt to prepare it */
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        if (Infofnt_prepare(info, kinfo))
 #else
        if (Infofnt_prepare(info))
@@ -1478,7 +1483,7 @@ static void Infofnt_init_data(cptr name)
                XFreeFontSet(Metadpy->dpy, info);
 #else
                XFreeFont(Metadpy->dpy, info);
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
                XFreeFont(Metadpy->dpy, kinfo);
 #endif
 #endif
@@ -1488,19 +1493,19 @@ static void Infofnt_init_data(cptr name)
 
        /* Save a copy of the font name */
        Infofnt->name = string_make(name);
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        Infokfnt->name = string_make(kname);
 #endif
 
        /* Mark it as nukable */
        Infofnt->nuke = 1;
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        Infokfnt->nuke = 1;
 #endif
 }
 
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
 /*
  * EUCÆüËܸ쥳¡¼¥É¤ò´Þ¤àʸ»úÎó¤òɽ¼¨¤¹¤ë (Xlib)
  */
@@ -1624,19 +1629,17 @@ static errr Infofnt_text_std(int x, int y, cptr str, int len)
 
        /*** Actually draw 'str' onto the infowin ***/
 
-#if 1
-#ifndef JP
+#ifndef USE_FONTSET
        /* Be sure the correct font is ready */
        XSetFont(Metadpy->dpy, Infoclr->gc, Infofnt->info->fid);
 #endif
-#endif
 
        /*** Handle the fake mono we can enforce on fonts ***/
 
        /* Monotize the font */
        if (Infofnt->mono)
        {
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
                /* Be sure the correct font is ready */
                XSetFont(Metadpy->dpy, Infoclr->gc, Infofnt->info->fid);
 #endif
@@ -1653,7 +1656,7 @@ static errr Infofnt_text_std(int x, int y, cptr str, int len)
        else
        {
                /* Note that the Infoclr is set up to contain the Infofnt */
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
                /* ´Á»ú¥Õ¥©¥ó¥È¤Îɽ¼¨Éý¤Ï ASCII¥Õ¥©¥ó¥È¤Î2Çܤ˸ÇÄê */
                XDrawMultiString(Metadpy->dpy, Infowin->win, Infoclr->gc,
                                 x, y, str, len,
@@ -1757,7 +1760,7 @@ struct term_data
        term t;
 
        infofnt *fnt;
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        infofnt *kfnt;
 #endif
 
@@ -1768,15 +1771,11 @@ struct term_data
 
        XImage *tiles;
 
-#ifdef USE_TRANSPARENCY
-
        /* Tempory storage for overlaying tiles. */
        XImage *TmpImage;
 
 #endif
 
-#endif
-
 };
 
 
@@ -2313,13 +2312,15 @@ static bool paste_x11_send_text(XSelectionRequestEvent *rq)
 
        for (n = 0, y = 0; y < Term->hgt; y++)
        {
+#ifdef JP
                int kanji = 0;
-
+#endif
                if (y < min.y) continue;
                if (y > max.y) break;
 
                for (l = 0, x = 0; x < Term->wid; x++)
                {
+#ifdef JP
                        if (x > max.x) break;
 
                        /* Find the character. */
@@ -2338,12 +2339,22 @@ static bool paste_x11_send_text(XSelectionRequestEvent *rq)
                        if ((2 == kanji && x == min.x) ||
                            (1 == kanji && x == max.x))
                                c = ' ';
+#else
+                       if (x > max.x) break;
+                       if (x < min.x) continue;
+
+                       /* Find the character. */
+                       Term_what(x, y, &a, &c);
+#endif
 
                        /* Add it. */
                        buf[l] = c;
                        l++;
                }
 
+               /* Ignore trailing spaces */
+               while (buf[l-1] == ' ') l--;
+
                /* Terminate all line unless it's single line. */
                if (min.y != max.y)
                {
@@ -2890,7 +2901,7 @@ static errr Term_xtra_x11_level(int v)
 
                /* Activate the font */
                Infofnt_set(td->fnt);
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
                Infokfnt_set(td->kfnt);
 #endif
        }
@@ -3093,18 +3104,13 @@ static errr Term_text_x11(int x, int y, int n, byte a, cptr s)
 /*
  * Draw some graphical characters.
  */
-# ifdef USE_TRANSPARENCY
 static errr Term_pict_x11(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
-# else /* USE_TRANSPARENCY */
-static errr Term_pict_x11(int x, int y, int n, const byte *ap, const char *cp)
-# endif /* USE_TRANSPARENCY */
 {
        int i, x1, y1;
 
        byte a;
        char c;
 
-#ifdef USE_TRANSPARENCY
        byte ta;
        char tc;
 
@@ -3112,7 +3118,6 @@ static errr Term_pict_x11(int x, int y, int n, const byte *ap, const char *cp)
        int k,l;
 
        unsigned long pixel, blank;
-#endif /* USE_TRANSPARENCY */
 
        term_data *td = (term_data*)(Term->data);
 
@@ -3145,8 +3150,6 @@ static errr Term_pict_x11(int x, int y, int n, const byte *ap, const char *cp)
                        continue;
                }
 
-#ifdef USE_TRANSPARENCY
-
                ta = *tap++;
                tc = *tcp++;
 
@@ -3199,18 +3202,6 @@ static errr Term_pict_x11(int x, int y, int n, const byte *ap, const char *cp)
                             0, 0, x, y,
                             td->fnt->twid, td->fnt->hgt);
                }
-
-#else /* USE_TRANSPARENCY */
-
-               /* Draw object / terrain */
-               XPutImage(Metadpy->dpy, td->win->win,
-                         clr[0]->gc,
-                         td->tiles,
-                         x1, y1,
-                         x, y,
-                         td->fnt->twid, td->fnt->hgt);
-
-#endif /* USE_TRANSPARENCY */
        }
 
        /* Redraw the selection if any, as it may have been obscured. (later) */
@@ -3318,7 +3309,7 @@ static errr term_data_init(term_data *td, int i)
        cptr name = angband_term_name[i];
 
        cptr font;
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        cptr kfont;
 #endif
 
@@ -3411,7 +3402,7 @@ static errr term_data_init(term_data *td, int i)
                }
        }
 
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        /* Window specific font name */
        sprintf(buf, "ANGBAND_X11_KFONT_%d", i);
 
@@ -3517,7 +3508,7 @@ static errr term_data_init(term_data *td, int i)
 
 
        /* Prepare the standard font */
-#ifdef _JP
+#ifdef USE_JP_FONTSTRUCT
        MAKE(td->fnt, infofnt);
        Infofnt_set(td->fnt);
        MAKE(td->kfnt, infofnt);
@@ -3674,11 +3665,7 @@ errr init_x11(int argc, char *argv[])
        int pict_wid = 0;
        int pict_hgt = 0;
 
-#ifdef USE_TRANSPARENCY
-
        char *TmpData;
-#endif /* USE_TRANSPARENCY */
-
 #endif /* USE_GRAPHICS */
 
 
@@ -3735,25 +3722,32 @@ errr init_x11(int argc, char *argv[])
        }
 
 #ifdef USE_LOCALE
+
+#ifdef JP
+       /* Get locale information from environment variables */
        setlocale(LC_ALL, "");
+
 #ifdef DEFAULT_LOCALE
        if(!strcmp(setlocale(LC_ALL, NULL), "C")){
                printf("try default locale \"%s\"\n", DEFAULT_LOCALE);
                setlocale(LC_ALL, DEFAULT_LOCALE);
        }
 #endif
+
+       if(!strcmp(setlocale(LC_ALL, NULL), "C"))
        {
-               char *current_locale = setlocale(LC_ALL, NULL);
-/*             printf("set locale to \"%s\"\n", current_locale); */
-               if(!strcmp(current_locale, "C")){
-                       printf("WARNING: Locale is not supported. Non-english font may be displayed incorrectly.\n");
-               }
+               printf("WARNING: Locale is not supported. Non-english font may be displayed incorrectly.\n");
        }
 
        if(!XSupportsLocale()){
                printf("can't support locale in X\n");
                setlocale(LC_ALL, "C");
        }
+#else
+       /* Set locale to "C" without using environment variables */
+       setlocale(LC_ALL, "C");
+#endif /* JP */
+
 #endif /* USE_LOCALE */
 
 
@@ -3910,7 +3904,6 @@ errr init_x11(int argc, char *argv[])
                                    td->fnt->twid, td->fnt->hgt);
                }
 
-#ifdef USE_TRANSPARENCY
                /* Initialize the transparency masks */
                for (i = 0; i < num_term; i++)
                {
@@ -3935,8 +3928,6 @@ errr init_x11(int argc, char *argv[])
                                td->fnt->twid, td->fnt->hgt, 8, 0);
 
                }
-#endif /* USE_TRANSPARENCY */
-
 
                /* Free tiles_raw? XXX XXX */
        }