OSDN Git Service

Tweak color settings in main-gcu.c
[hengband/hengband.git] / src / main-gcu.c
index b51b383..281ec6c 100644 (file)
@@ -254,6 +254,9 @@ static term_data data[MAX_TERM_DATA];
 #endif
 
 
+#include <locale.h>
+
+
 /*
  * XXX XXX Hack -- POSIX uses "O_NONBLOCK" instead of "O_NDELAY"
  *
@@ -600,7 +603,7 @@ static errr Term_xtra_gcu_alive(int v)
       mvcur(curscr->cury, curscr->curx, LINES - 1, 0);
 #else
       /* this moves curses to bottom right corner */
-      mvcur(curscr->_cury, curscr->_curx, LINES - 1, 0);
+      mvcur(getcury(curscr), getcurx(curscr), LINES - 1, 0);
 #endif
 
       /* Exit curses */
@@ -664,14 +667,14 @@ static bool init_sound(void)
       /* Prepare the sounds */
       for (i = 1; i < SOUND_MAX; i++)
       {
-         /* Extract name of sound file */
-         sprintf(wav, "%s.wav", angband_sound_name[i]);
+        /* Extract name of sound file */
+        sprintf(wav, "%s.wav", angband_sound_name[i]);
 
-         /* Access the sound */
-         path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, wav);
+        /* Access the sound */
+        path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_SOUND, wav);
 
-         /* Save the sound filename, if it exists */
-         if (check_file(buf)) sound_file[i] = string_make(buf);
+        /* Save the sound filename, if it exists */
+        if (check_file(buf)) sound_file[i] = string_make(buf);
       }
 
       /* Sound available */
@@ -736,7 +739,7 @@ static void Term_nuke_gcu(term *t)
    mvcur(curscr->cury, curscr->curx, LINES - 1, 0);
 #else
    /* This moves curses to bottom right corner */
-   mvcur(curscr->_cury, curscr->_curx, LINES - 1, 0);
+   mvcur(getcury(curscr), getcurx(curscr), LINES - 1, 0);
 #endif
 
    /* Flush the curses buffer */
@@ -929,8 +932,8 @@ static errr Term_xtra_gcu_react(void)
        {
                /* Set one color (note scaling) */
                init_color(i, angband_color_table[i][1] * 1000 / 255,
-                             angband_color_table[i][2] * 1000 / 255,
-                             angband_color_table[i][3] * 1000 / 255);
+                             angband_color_table[i][2] * 1000 / 255,
+                             angband_color_table[i][3] * 1000 / 255);
        }
 
 #endif
@@ -964,7 +967,7 @@ static errr Term_xtra_gcu(int n, int v)
 #ifdef USE_SOUND
       /* Make a special sound */
       case TERM_XTRA_SOUND:
-         return (Term_xtra_gcu_sound(v));
+        return (Term_xtra_gcu_sound(v));
 #endif
 
       /* Flush the Curses buffer */
@@ -1174,6 +1177,17 @@ static errr term_data_init(term_data *td, int rows, int cols, int y, int x)
    return (0);
 }
 
+
+static void hook_quit(cptr str)
+{
+       /* Unused */
+       (void)str;
+
+       /* Exit curses */
+       endwin();
+}
+
+
 /*
  * Prepare "curses" for use by the file "term.c"
  *
@@ -1189,10 +1203,17 @@ errr init_gcu(int argc, char *argv[])
    int num_term = 4, next_win = 0;
    char path[1024];
 
+   /* Unused */
+   (void)argc;
+   (void)argv;
+
+
+   setlocale(LC_ALL, "");
+
 #ifdef USE_SOUND
 
    /* Build the "sound" path */
-   path_build(path, 1024, ANGBAND_DIR_XTRA, "sound");
+   path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
 
    /* Allocate the path */
    ANGBAND_DIR_XTRA_SOUND = string_make(path);
@@ -1210,6 +1231,10 @@ errr init_gcu(int argc, char *argv[])
    if (initscr() == (WINDOW*)ERR) return (-1);
 #endif
 
+   /* Activate hooks */
+   quit_aux = hook_quit;
+   core_aux = hook_quit;
+
    /* Hack -- Require large screen, or Quit with message */
    i = ((LINES < 24) || (COLS < 80));
    if (i) quit("Angband needs an 80x24 'curses' screen");
@@ -1221,12 +1246,12 @@ errr init_gcu(int argc, char *argv[])
 
    /* Do we have color, and enough color, available? */
    can_use_color = ((start_color() != ERR) && has_colors() &&
-                    (COLORS >= 8) && (COLOR_PAIRS >= 8));
+                   (COLORS >= 8) && (COLOR_PAIRS >= 8));
 
 #ifdef REDEFINE_COLORS
        /* Can we change colors? */
        can_fix_color = (can_use_color && can_change_color() &&
-                        (COLORS >= 16) && (COLOR_PAIRS > 8));
+                        (COLORS >= 16) && (COLOR_PAIRS > 8));
 #endif
 
    /* Attempt to use customized colors */
@@ -1235,17 +1260,17 @@ errr init_gcu(int argc, char *argv[])
       /* Prepare the color pairs */
       for (i = 1; i <= 63; i++)
       {
-         /* Reset the color */
-         if (init_pair(i, (i - 1) % 8, (i - 1) / 8) == ERR)
-         {
-            quit("Color pair init failed");
-         }
+        /* Reset the color */
+        if (init_pair(i, (i - 1) % 8, (i - 1) / 8) == ERR)
+        {
+           quit("Color pair init failed");
+        }
 
        /* Set up the colormap */
        colortable[i - 1] = (COLOR_PAIR(i) | A_NORMAL);
        colortable[i + 7] = (COLOR_PAIR(i) | A_BRIGHT);
 
-        /* XXX XXX XXX Take account of "gamma correction" */
+       /* XXX XXX XXX Take account of "gamma correction" */
 
        /* Prepare the "Angband Colors" */
        Term_xtra_gcu_react();
@@ -1254,7 +1279,7 @@ errr init_gcu(int argc, char *argv[])
    /* Attempt to use colors */
    else if (can_use_color)
    {
-                /* Color-pair 0 is *always* WHITE on BLACK */
+               /* Color-pair 0 is *always* WHITE on BLACK */
 
                /* Prepare the color pairs */
                init_pair(1, COLOR_RED,     COLOR_BLACK);
@@ -1273,15 +1298,15 @@ errr init_gcu(int argc, char *argv[])
                colortable[3] = (COLOR_PAIR(1) | A_BRIGHT);     /* Orange XXX */
                colortable[4] = (COLOR_PAIR(1) | A_NORMAL);     /* Red */
                colortable[5] = (COLOR_PAIR(2) | A_NORMAL);     /* Green */
-               colortable[6] = (COLOR_PAIR(4) | A_NORMAL);     /* Blue */
+               colortable[6] = (COLOR_PAIR(4) | A_BRIGHT);     /* Blue */
                colortable[7] = (COLOR_PAIR(3) | A_NORMAL);     /* Umber */
                colortable[8] = (COLOR_PAIR(7) | A_BRIGHT);     /* Dark-grey XXX */
                colortable[9] = (COLOR_PAIR(0) | A_NORMAL);     /* Light-grey XXX */
-               colortable[10] = (COLOR_PAIR(5) | A_NORMAL);    /* Purple */
+               colortable[10] = (COLOR_PAIR(5) | A_BRIGHT);    /* Purple */
                colortable[11] = (COLOR_PAIR(3) | A_BRIGHT);    /* Yellow */
-               colortable[12] = (COLOR_PAIR(5) | A_BRIGHT);    /* Light Red XXX */
+               colortable[12] = (COLOR_PAIR(5) | A_NORMAL);    /* Light Red XXX */
                colortable[13] = (COLOR_PAIR(2) | A_BRIGHT);    /* Light Green */
-               colortable[14] = (COLOR_PAIR(4) | A_BRIGHT);    /* Light Blue */
+               colortable[14] = (COLOR_PAIR(6) | A_BRIGHT);    /* Light Blue */
                colortable[15] = (COLOR_PAIR(3) | A_NORMAL);    /* Light Umber XXX */
 
    }
@@ -1295,11 +1320,11 @@ errr init_gcu(int argc, char *argv[])
       /* Initialize (if needed) */
       if (arg_sound && !init_sound())
       {
-         /* Warning */
-         plog("Cannot initialize sound!");
+        /* Warning */
+        plog("Cannot initialize sound!");
 
-         /* Cannot enable */
-         arg_sound = FALSE;
+        /* Cannot enable */
+        arg_sound = FALSE;
       }
 
       /* Change setting */
@@ -1349,33 +1374,33 @@ errr init_gcu(int argc, char *argv[])
 
       switch (i)
       {
-         /* Upper left */
-         case 0: rows = 24;
-            cols = 80;
-            y = x = 0;
-            break;
-         /* Lower left */
-         case 1: rows = LINES - 25;
-            cols = 80;
-            y = 24;
-            x = 0;
-            break;
-         /* Upper right */
-         case 2: rows = 24;
-            cols = COLS - 81;
-            y = 0;
-            x = 81;
-            break;
-         /* Lower right */
-         case 3: rows = LINES - 25;
-            cols = COLS - 81;
-            y = 24;
-            x = 81;
-            break;
-         /* XXX */
-         default: rows = cols = 0;
-             y = x = 0;
-             break;
+        /* Upper left */
+        case 0: rows = 24;
+           cols = 80;
+           y = x = 0;
+           break;
+        /* Lower left */
+        case 1: rows = LINES - 25;
+           cols = 80;
+           y = 24;
+           x = 0;
+           break;
+        /* Upper right */
+        case 2: rows = 24;
+           cols = COLS - 81;
+           y = 0;
+           x = 81;
+           break;
+        /* Lower right */
+        case 3: rows = LINES - 25;
+           cols = COLS - 81;
+           y = 24;
+           x = 81;
+           break;
+        /* XXX */
+        default: rows = cols = 0;
+            y = x = 0;
+            break;
       }
 
       /* No non-windows */