OSDN Git Service

dungeon_turnの過剰経過による、NASTY_MONSTER発生率と階層上昇を有効な形に実装し直した上で、若干調整。
[hengband/hengband.git] / src / main-win.c
index 2fddbbf..b698e1b 100644 (file)
@@ -76,7 +76,7 @@
 
 
 #ifdef WINDOWS
-
+#include <windows.h>
 #include <direct.h>
 
 /*
 #define IDM_FILE_OPEN                  101
 #define IDM_FILE_SAVE                  110
 #define IDM_FILE_SCORE                 120
+#define IDM_FILE_MOVIE                 121
 #define IDM_FILE_EXIT                  130
 
 #define IDM_WINDOW_VIS_0               200
 /*
  * This may need to be removed for some compilers XXX XXX XXX
  */
+#if 0
 #define STRICT
+#endif
 
 /*
  * Exclude parts of WINDOWS.H that are not needed
@@ -575,6 +578,14 @@ static COLORREF win_clr[256];
  */
 static bool Term_no_press = FALSE;
 
+/*
+ * Copy and paste
+ */
+static bool mouse_down = FALSE;
+static bool paint_rect = FALSE;
+static int mousex = 0, mousey = 0;
+static int oldx, oldy;
+
 
 /*
  * The "simple" color values
@@ -1926,6 +1937,28 @@ static void term_data_redraw(term_data *td)
 }
 
 
+void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
+{
+       HDC hdc;
+       HPEN oldPen;
+       HBRUSH myBrush, oldBrush;
+
+       term_data *td = (term_data *)GetWindowLong(hWnd, 0);
+       int tx = td->size_ow1 + x * td->tile_wid;
+       int ty = td->size_oh1 + y * td->tile_hgt;
+       int tw = w * td->tile_wid - 1;
+       int th = h * td->tile_hgt - 1;
+
+       hdc = GetDC(hWnd);
+       myBrush = CreateSolidBrush(RGB(255, 255, 255));
+       oldBrush = SelectObject(hdc, myBrush);
+       oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
+
+       PatBlt(hdc, tx, ty, tw, th, PATINVERT);
+
+       SelectObject(hdc, oldBrush);
+       SelectObject(hdc, oldPen);
+}
 
 
 
@@ -2612,8 +2645,7 @@ static errr Term_text_win(int x, int y, int n, byte a, const char *s)
                                rc.right += td->tile_wid;
                        } else {
                                /* Dump the text */
-                               ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
-                                      s+i, 1, NULL);
+                               ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
 
                                /* Advance */
                                rc.left += td->tile_wid;
@@ -3637,6 +3669,49 @@ static void process_menus(WORD wCmd)
                        break;
                }
 
+               /* Open game */
+               case IDM_FILE_MOVIE:
+               {
+                       if (!initialized)
+                       {
+#ifdef JP
+                               plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
+#else
+                               plog("You cannot do that yet...");
+#endif
+                       }
+                       else if (game_in_progress)
+                       {
+#ifdef JP
+                               plog("¥×¥ì¥¤Ãæ¤Ï¥à¡¼¥Ó¡¼¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡ª");
+#else
+                               plog("You can't open a movie while you're playing!");
+#endif
+                       }
+                       else
+                       {
+                               memset(&ofn, 0, sizeof(ofn));
+                               ofn.lStructSize = sizeof(ofn);
+                               ofn.hwndOwner = data[0].w;
+                               ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
+                               ofn.nFilterIndex = 1;
+                               ofn.lpstrFile = savefile;
+                               ofn.nMaxFile = 1024;
+                               ofn.lpstrInitialDir = ANGBAND_DIR_USER;
+                               ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
+
+                               if (GetOpenFileName(&ofn))
+                               {
+                                       /* Load 'savefile' */
+                                       prepare_browse_movie_aux(savefile);
+                                       play_game(FALSE);
+                                       quit(NULL);
+                                       return;
+                               }
+                       }
+                       break;
+               }
+
 
                case IDM_WINDOW_VIS_0:
                {
@@ -4339,6 +4414,124 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
                        return 0;
                }
 
+               case WM_LBUTTONDOWN:
+               {
+                       mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
+                       mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
+                       mouse_down = TRUE;
+                       oldx = mousex;
+                       oldy = mousey;
+                       return 0;
+               }
+
+               case WM_LBUTTONUP:
+               {
+                       HGLOBAL hGlobal;
+                       LPSTR lpStr;
+                       int i, j, sz;
+                       int dx = abs(oldx - mousex) + 1;
+                       int dy = abs(oldy - mousey) + 1;
+                       int ox = (oldx > mousex) ? mousex : oldx;
+                       int oy = (oldy > mousey) ? mousey : oldy;
+
+                       mouse_down = FALSE;
+                       paint_rect = FALSE;
+
+#ifdef JP
+                       sz = (dx + 3) * dy;
+#else
+                       sz = (dx + 2) * dy;
+#endif
+                       hGlobal = GlobalAlloc(GHND, sz + 1);
+                       if (hGlobal == NULL) return 0;
+                       lpStr = (LPSTR)GlobalLock(hGlobal);
+
+                       for (i = 0; i < dy; i++)
+                       {
+#ifdef JP
+                               char *s;
+                               char **scr = data[0].t.scr->c;
+
+                               C_MAKE(s, (dx + 1), char);
+                               strncpy(s, &scr[oy + i][ox], dx);
+
+                               if (ox > 0)
+                               {
+                                       if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
+                               }
+
+                               if (ox + dx < data[0].cols)
+                               {
+                                       if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
+                               }
+
+                               for (j = 0; j < dx; j++)
+                               {
+                                       if (s[j] == 127) s[j] = '#';
+                                       *lpStr++ = s[j];
+                               }
+#else
+                               for (j = 0; j < dx; j++)
+                               {
+                                       *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
+                               }
+#endif
+                               if (dy > 1)
+                               {
+                                       *lpStr++ = '\r';
+                                       *lpStr++ = '\n';
+                               }
+                       }
+
+                       GlobalUnlock(hGlobal);
+                       if (OpenClipboard(hWnd) == 0)
+                       {
+                               GlobalFree(hGlobal);
+                               return 0;
+                       }
+                       EmptyClipboard();
+                       SetClipboardData(CF_TEXT, hGlobal);
+                       CloseClipboard();
+
+                       Term_redraw();
+
+                       return 0;
+               }
+
+               case WM_MOUSEMOVE:
+               {
+                       if (mouse_down)
+                       {
+                               int dx, dy;
+                               int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
+                               int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
+                               int ox, oy;
+
+                               if (paint_rect)
+                               {
+                                       dx = abs(oldx - mousex) + 1;
+                                       dy = abs(oldy - mousey) + 1;
+                                       ox = (oldx > mousex) ? mousex : oldx;
+                                       oy = (oldy > mousey) ? mousey : oldy;
+                                       Term_inversed_area(hWnd, ox, oy, dx, dy);
+                               }
+                               else
+                               {
+                                       paint_rect = TRUE;
+                               }
+
+                               dx = abs(cx - mousex) + 1;
+                               dy = abs(cy - mousey) + 1;
+                               ox = (cx > mousex) ? mousex : cx;
+                               oy = (cy > mousey) ? mousey : cy;
+                               Term_inversed_area(hWnd, ox, oy, dx, dy);
+
+                               oldx = cx;
+                               oldy = cy;
+                       }
+                       return 0;
+               }
+
                case WM_INITMENU:
                {
                        setup_menus();
@@ -5276,7 +5469,6 @@ int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
 
        /* We are now initialized */
        initialized = TRUE;
-
 #ifdef CHUUKEI
        if(lpCmdLine[0] == '-'){
          switch(lpCmdLine[1])
@@ -5305,6 +5497,15 @@ int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
              quit(NULL);
              return 0;
            }
+         case 'X':
+         case 'x':
+           {
+             if (!lpCmdLine[2]) break;
+             prepare_browse_movie(&lpCmdLine[2]);
+             play_game(FALSE);
+             quit(NULL);
+             return 0;
+           }
          }
        }
 #endif