Changeset 114
- Timestamp:
- 05/06/07 10:18:41 (1 year ago)
- Files:
-
- trunk/lib/pref/font-sdl.prf (added)
- trunk/lib/pref/font.prf (modified) (1 diff)
- trunk/lib/pref/graf-sdl.prf (added)
- trunk/lib/pref/graf.prf (modified) (1 diff)
- trunk/src/Makefile.src (modified) (1 diff)
- trunk/src/main-sdl.c (modified) (55 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/pref/font.prf
r85 r114 57 57 58 58 ?:[EQU $SYS sdl] 59 %:font- win.prf59 %:font-sdl.prf 60 60 61 61 ?:1 trunk/lib/pref/graf.prf
r1 r114 47 47 %:graf-acn.prf 48 48 49 ?:[EQU $SYS sdl] 50 %:graf-sdl.prf 51 49 52 ?:1 50 53 trunk/src/Makefile.src
r96 r114 14 14 ZFILES = z-file z-form z-rand z-term z-type z-util z-virt 15 15 MAINFILES = main maid-x11 \ 16 $(addprefix main-,cap crb dos gcu gtk ibm lsl ros s la vcs win x11 xaw xpj)16 $(addprefix main-,cap crb dos gcu gtk ibm lsl ros sdl sla vcs win x11 xaw xpj) 17 17 18 18 ANGFILES = \ trunk/src/main-sdl.c
r111 r114 2 2 3 3 /* 4 * Angband SDL port byIain McFall (mcfall.iain@googlemail.com)4 * Angband SDL port (c) 2007 Iain McFall (mcfall.iain@googlemail.com) 5 5 * 6 6 * Based on the sangband SDL port, by Leon Marrick & others. 7 7 * 8 * This port is definately in its early stages and as yet9 * has no support for graphics or sound. Its current purpose is10 * to see how it works on different machines.11 * There is no support for 256 colours at the moment either.12 8 * 13 9 * Comments and suggestions are welcome. The UI probably needs some … … 18 14 19 15 /* 20 * Copyright (c) 2007 Leon Marrick and others21 *22 16 * This program is free software; you can redistribute it and/or modify it 23 17 * under the terms of the GNU General Public License. Parts may also be … … 40 34 * you are new to all this, read "makefile.sdl". 41 35 * 42 * This port uses the following libraries: SDL (v1.2+), SDL_ttf, and 43 * SDL_mixer (only needed if USE_SOUND is defined). All are available as 44 * source code, pre-compiled libs for developers, and libs (or dlls) for 45 * players from www.libsdl.org 36 * This port uses the following libraries: SDL (v1.2+) and SDL_ttf. 37 * All are available as source code, pre-compiled libs for developers, 38 * and libs (or dlls) for players from www.libsdl.org 46 39 * 47 40 * … … 51 44 * - If "USE_GRAPHICS" is defined, then it also needs some bitmapped (.bmp) 52 45 * graphics files in /lib/xtra/graf, such as "16x16.bmp" and "16x16m.bmp". 53 * - If "USE_SOUND" is defined "*.WAV" sound files must be placed into54 * "lib/xtra/sound/".55 46 * 56 47 * - The "lib/pref/pref-sdl.prf" file contains keymaps, macro definitions, … … 59 50 * normal "*.fon" font files in the "lib/xtra/font/" directory. 60 51 * 61 * - The files "win/angband.rc" and "win/angband.ico" can be included in your62 * project if using MSVC++. "win/angband.ico" can also be added if using63 * DevC++ and probably other Windows compilers.64 52 * 65 53 * … … 112 100 * Windows machines. 113 101 */ 102 #include "angband.h" 114 103 115 104 #ifdef USE_SDL 116 #include "angband.h" 105 117 106 #include "main.h" 107 #include "SDL.h" 118 108 #include "SDL_ttf.h" 119 #include <string.h> 120 121 #ifdef USE_GRAPHICS 122 #undef USE_GRAPHICS 123 #endif 124 125 #ifdef USE_SOUND 126 #undef USE_SOUND 127 #endif 109 110 /* SDL flags used for the main window surface */ 111 static Uint32 vflags = SDL_ANYFORMAT; 112 113 /* Current screen dimensions */ 114 static int screen_w = 800; 115 static int screen_h = 600; 116 117 /* Fullscreen dimensions */ 118 static int full_w; 119 static int full_h; 120 121 /* Want fullscreen? */ 122 static bool fullscreen = FALSE; 128 123 129 124 /* … … 131 126 */ 132 127 static cptr ANGBAND_DIR_XTRA_FONT; 128 static cptr ANGBAND_DIR_XTRA_GRAF; 133 129 /* Later... 134 static cptr ANGBAND_DIR_XTRA_GRAF;135 130 static cptr ANGBAND_DIR_XTRA_SOUND; 136 static cptr ANGBAND_DIR_XTRA_MUSIC;137 131 */ 138 132 133 /* 134 * Used as 'system' font 135 */ 139 136 static cptr DEFAULT_FONT_FILE = "6x10.fon"; 140 static int screen_w; 141 static int screen_h; 142 static int fullscreen; 143 144 145 #define MAX_FONTS 30 137 138 #define MAX_FONTS 20 146 139 cptr FontList[MAX_FONTS]; 147 140 static int num_fonts = 0; … … 307 300 static bool popped; 308 301 302 /* 303 * Term windows 304 */ 309 305 static term_window windows[ANGBAND_TERM_MAX]; 310 306 static int Zorder[ANGBAND_TERM_MAX]; … … 338 334 339 335 static int StatusHeight; /* The height in pixels of the status bar */ 340 341 336 static int SelectedTerm; /* Current selected Term */ 342 337 338 static int AboutSelect; /* About button */ 343 339 static int TermSelect; /* Term selector button */ 344 340 static int FontSelect; /* Font selector button */ 345 341 static int VisibleSelect; /* Hide/unhide window button*/ 342 static int MoreSelect; /* Other options button */ 346 343 static int QuitSelect; /* Quit button */ 344 345 /* Buttons on the 'More' panel */ 346 static int MoreOK; /* Accept changes */ 347 static int MoreFullscreen; /* Fullscreen toggle button */ 347 348 348 349 static bool Moving; /* Moving a window */ 349 350 static bool Sizing; /* Sizing a window */ 350 static SDL_Rect SizingSpot; /* Rect to descibe the sizing button */ 351 static SDL_Rect SizingSpot; /* Rect to descibe the sizing area */ 352 static bool Sizingshow = FALSE; /* Is the resize thingy displayed? */ 351 353 static SDL_Rect SizingRect; /* Rect to describe the current resize window */ 352 354 353 /* 354 * The basic angband text colours in a sdl friendly form 355 #ifdef USE_GRAPHICS 356 typedef struct GfxInfo GfxInfo; 357 struct GfxInfo 358 { 359 cptr name; /* Name to show on button */ 360 cptr gfxfile; /* The file with tiles */ 361 cptr maskfile; /* The mask file (if any) */ 362 int width; /* Width of a tile */ 363 int height; /* Height of a tile */ 364 cptr pref; /* Preference file to use */ 365 bool avail; /* Are the appropriate files available? */ 366 }; 367 368 static SDL_Surface *GfxSurface = NULL; /* A surface for the graphics */ 369 370 #define GfxModes 4 371 static GfxInfo GfxDesc[GfxModes] = 372 { 373 /* No gfx (GRAPHICS_NONE) */ 374 {"None", NULL, NULL, -1, -1, NULL, TRUE}, 375 /* 8x8 tiles (GRAPHICS_ORIGINAL) */ 376 {"8x8", "8x8.bmp", NULL, 8, 8, "old", TRUE}, 377 /* 16x16 tiles (GRAPHICS_ADAM_BOLT) */ 378 {"16x16", "16x16.bmp", "mask.bmp", 16, 16, "new", TRUE}, 379 /* XXX (GRAPHICS_DAVID_GERVAIS) */ 380 {"32x32", "32x32.bmp", "mask32.bmp", 32, 32, "david", TRUE}, 381 382 /* XXX (GRAPHICS_PSEUDO ???) */ 383 /*{NULL, NULL, NULL, -1, -1}, */ 384 }; 385 386 static int MoreBigtile; /* Toggle bigtile button */ 387 static int GfxButtons[GfxModes]; /* Graphics mode buttons */ 388 static int SelectedGfx; /* Current selected gfx */ 389 #endif 390 391 /* 392 * The basic angband text colours in an sdl friendly form 355 393 */ 356 394 static u32b text_colours[16]; … … 930 968 * sdl_Window functions 931 969 */ 932 933 970 static void sdl_WindowFree(sdl_Window* window) 934 971 { … … 1025 1062 } 1026 1063 1064 #ifdef USE_GRAPHICS 1065 /* Free the graphics surface */ 1066 if (GfxSurface) SDL_FreeSurface(GfxSurface); 1067 #endif 1027 1068 /* Free the 'System font' */ 1028 1069 sdl_FontFree(&SystemFont); … … 1096 1137 SDL_Rect rc; 1097 1138 1139 if (!win->visible) continue; 1098 1140 if (!point_in(RECT(win->left, win->top, win->width, win->height, &rc), x, y)) continue; 1099 1141 … … 1106 1148 static void draw_statusbar(sdl_Window *window) 1107 1149 { 1108 char buf[1024]; 1150 char buf[128]; 1151 term_window *win = &windows[SelectedTerm]; 1109 1152 int fw = window->font.width; 1110 1153 int x = 1; … … 1112 1155 1113 1156 SDL_Rect rc; 1114 my_strcpy(buf, format("%s v%s", VERSION_NAME, VERSION_STRING), sizeof(buf));1115 1157 1116 1158 u32b c = SDL_MapRGB(window->surface->format, 160, 160, 60); … … 1119 1161 SDL_FillRect(StatusBar.surface, &rc, c); 1120 1162 1163 button = sdl_ButtonBankGet(&StatusBar.buttons, AboutSelect); 1164 x += button->pos.w + 20; 1165 1166 sdl_WindowText(&StatusBar, c, x, 1, "Term:"); 1167 x += 5 * fw; 1168 1169 button = sdl_ButtonBankGet(&StatusBar.buttons, TermSelect); 1170 button->pos.x = x; 1171 x += button->pos.w + 10; 1172 1173 my_strcpy(buf, format("(%dx%d)", win->cols, win->rows), sizeof(buf)); 1121 1174 sdl_WindowText(&StatusBar, c, x, 1, buf); 1122 1175 x += strlen(buf) * fw + 20; 1123 1124 sdl_WindowText(&StatusBar, c, x, 1, "Term:");1125 x += 5 * fw;1126 1127 button = sdl_ButtonBankGet(&StatusBar.buttons, TermSelect);1128 button->pos.x = x;1129 x += button->pos.w + 20;1130 1176 1131 1177 sdl_WindowText(&StatusBar, c, x, 1, "Visible:"); … … 1142 1188 1143 1189 button->pos.x = x; 1144 x += button->pos.w + 40; 1190 x += button->pos.w + 20; 1191 1192 button = sdl_ButtonBankGet(&StatusBar.buttons, MoreSelect); 1193 button->pos.x = x; 1194 1195 x += button->pos.w + 20; 1196 1197 1145 1198 } 1146 1199 … … 1171 1224 int i; 1172 1225 Uint32 colour = SDL_MapRGB(AppWin->format, 160, 160, 60); 1173 Uint32 ccolour = SDL_MapRGB(AppWin->format, 160, 40, 40);1226 //Uint32 ccolour = SDL_MapRGB(AppWin->format, 160, 40, 40); 1174 1227 SDL_FillRect(AppWin, NULL, back_colour); 1175 1228 … … 1190 1243 SizingSpot.x = win->left + win->width - 10; 1191 1244 SizingSpot.y = win->top + win->height - 10; 1192 SDL_FillRect(AppWin, &SizingSpot, ccolour);1245 //SDL_FillRect(AppWin, &SizingSpot, ccolour); 1193 1246 1194 1247 if (Sizing) … … 1239 1292 1240 1293 sdl_ButtonCaption(button, angband_term_name[SelectedTerm]); 1241 1294 1242 1295 if (!win->visible) 1243 1296 { … … 1265 1318 sdl_BlitAll(); 1266 1319 } 1267 1320 1321 static void AboutDraw(sdl_Window *win) 1322 { 1323 SDL_Rect rc; 1324 1325 /* Wow - a different colour! */ 1326 Uint32 colour = SDL_MapRGB(win->surface->format, 160, 60, 60); 1327 1328 RECT(0, 0, win->width, win->height, &rc); 1329 1330 /* Draw a nice box */ 1331 sdl_DrawBox(win->surface, &rc, colour, 5); 1332 } 1333 1334 1335 static void AboutActivate(sdl_Button *sender) 1336 { 1337 int width = 300; 1338 int height = 300; 1339 1340 sdl_WindowInit(&PopUp, width, height, AppWin, StatusBar.font.name); 1341 PopUp.left = (AppWin->w / 2) - width / 2; 1342 PopUp.top = (AppWin->h / 2) - height / 2; 1343 PopUp.draw_extra = AboutDraw; 1344 1345 popped = TRUE; 1346 } 1347 1268 1348 static void SelectTerm(sdl_Button *sender) 1269 1349 { … … 1318 1398 term_windowFree(window); 1319 1399 angband_term[SelectedTerm] = NULL; 1320 sdl_BlitAll();1400 1321 1401 } 1322 1402 else … … 1328 1408 1329 1409 SetStatusButtons(); 1410 sdl_BlitAll(); 1330 1411 } 1331 1412 … … 1342 1423 sdl_CheckFont(window->req_font, &w, &h); 1343 1424 1344 ResizeWin(window, w * window->cols, h * window->rows); 1425 ResizeWin(window, (w * window->cols) + (2 * window->border), 1426 (h * window->rows) + window->border + window->title_height); 1345 1427 1346 1428 SetStatusButtons(); … … 1348 1430 RemovePopUp(); 1349 1431 1350 }1432 } 1351 1433 1352 1434 … … 1380 1462 } 1381 1463 1464 #ifdef USE_GRAPHICS 1465 static errr load_gfx(void); 1466 1467 static void SelectGfx(sdl_Button *sender) 1468 { 1469 SelectedGfx = sender->tag; 1470 } 1471 #endif 1472 1473 static void AcceptChanges(sdl_Button *sender) 1474 { 1475 sdl_Button *button; 1476 bool do_update = FALSE; 1477 bool do_video_reset = FALSE; 1478 1479 #ifdef USE_GRAPHICS 1480 /* Check to see if bigtile has changed */ 1481 button = sdl_ButtonBankGet(&PopUp.buttons, MoreBigtile); 1482 1483 if (button->tag != use_bigtile) 1484 { 1485 do_update = TRUE; 1486 1487 use_bigtile = !use_bigtile; 1488 } 1489 1490 if (use_graphics != SelectedGfx) 1491 { 1492 do_update = TRUE; 1493 1494 use_graphics = SelectedGfx; 1495 1496 if (use_graphics) 1497 { 1498 arg_graphics = TRUE; 1499 load_gfx(); 1500 } 1501 else 1502 { 1503 arg_graphics = FALSE; 1504 use_bigtile = FALSE; 1505 reset_visuals(TRUE); 1506 } 1507 } 1508 1509 1510 #endif 1511 1512 button = sdl_ButtonBankGet(&PopUp.buttons, MoreFullscreen); 1513 1514 if (button->tag != fullscreen) 1515 { 1516 fullscreen = !fullscreen; 1517 1518 do_video_reset = TRUE; 1519 } 1520 1521 1522 SetStatusButtons(); 1523 1524 RemovePopUp(); 1525 1526 if (do_update) 1527 { 1528 if (character_dungeon) do_cmd_redraw(); 1529 } 1530 1531 if (do_video_reset) 1532 { 1533 SDL_Event Event; 1534 1535 WIPE(&Event, SDL_Event); 1536 1537 Event.type = SDL_VIDEORESIZE; 1538 Event.resize.w = screen_w; 1539 Event.resize.h = screen_h; 1540 1541 SDL_PushEvent(&Event); 1542 } 1543 1544 } 1545 1546 static void FlipTag(sdl_Button *sender) 1547 { 1548 if (sender->tag) 1549 { 1550 sender->tag = 0; 1551 sdl_ButtonCaption(sender, "Off"); 1552 } 1553 else 1554 { 1555 sender->tag = 1; 1556 sdl_ButtonCaption(sender, "On"); 1557 } 1558 } 1559 1560 static void MoreDraw(sdl_Window *win) 1561 { 1562 SDL_Rect rc; 1563 sdl_Button *button; 1564 int y = 20, i; 1565 1566 /* Wow - a different colour! */ 1567 Uint32 colour = SDL_MapRGB(win->surface->format, 160, 60, 60); 1568 1569 RECT(0, 0, win->width, win->height, &rc); 1570 1571 /* Draw a nice box */ 1572 sdl_DrawBox(win->surface, &rc, colour, 5); 1573 1574 #ifdef USE_GRAPHICS 1575 1576 button = sdl_ButtonBankGet(&win->buttons, MoreBigtile); 1577 1578 if (SelectedGfx) 1579 { 1580 sdl_ButtonVisible(button, TRUE); 1581 sdl_WindowText(win, colour, 20, y, "Bigtile is:"); 1582 1583 sdl_ButtonMove(button, 200, y); 1584 1585 y += 20; 1586 } 1587 else 1588 { 1589 sdl_ButtonVisible(button, FALSE); 1590 } 1591 1592 1593 1594 sdl_WindowText(win, colour, 20, y, "Selected Graphics:"); 1595 sdl_WindowText(win, SDL_MapRGB(win->surface->format, 210, 110, 110), 1596 200, y, GfxDesc[SelectedGfx].name); 1597 1598 y += 20; 1599 1600 sdl_WindowText(win, colour, 20, y, "Available Graphics:"); 1601 1602 for (i = 0; i < GfxModes; i++) 1603 { 1604 if (!GfxDesc[i].avail) continue; 1605 button = sdl_ButtonBankGet(&win->buttons, GfxButtons[i]); 1606 sdl_ButtonMove(button, 200, y); 1607 y += 20; 1608 } 1609 #endif 1610 1611 button = sdl_ButtonBankGet(&win->buttons, MoreFullscreen); 1612 sdl_WindowText(win, colour, 20, y, "Fullscreen is:"); 1613 1614 sdl_ButtonMove(button, 200, y); 1615 } 1616 1617 static void MoreActivate(sdl_Button *sender) 1618 { 1619 int width = 300; 1620 int height = 300; 1621 int i; 1622 sdl_Button *button; 1623 1624 Uint32 ucolour; 1625 Uint32 scolour; 1626 1627 sdl_WindowInit(&PopUp, width, height, AppWin, StatusBar.font.name); 1628 PopUp.left = (AppWin->w / 2) - width / 2; 1629 PopUp.top = (AppWin->h / 2) - height / 2; 1630 PopUp.draw_extra = MoreDraw; 1631 1632 ucolour = SDL_MapRGB(PopUp.surface->format, 160, 60, 60); 1633 scolour = SDL_MapRGB(PopUp.surface->format, 210, 110, 110); 1634 1635 #ifdef USE_GRAPHICS 1636 MoreBigtile = sdl_ButtonBankNew(&PopUp.buttons); 1637 button = sdl_ButtonBankGet(&PopUp.buttons, MoreBigtile); 1638 1639 button->unsel_colour = ucolour; 1640 button->sel_colour = scolour; 1641 sdl_ButtonSize(button, 50 , PopUp.font.height + 2); 1642 sdl_ButtonVisible(button, TRUE); 1643 sdl_ButtonCaption(button, use_bigtile ? "On" : "Off"); 1644 button->tag = use_bigtile; 1645 button->activate = FlipTag; 1646 1647 SelectedGfx = use_graphics; 1648 1649 for (i = 0; i < GfxModes; i++) 1650 { 1651 if (!GfxDesc[i].avail) continue; 1652 GfxButtons[i] = sdl_ButtonBankNew(&PopUp.buttons); 1653 button = sdl_ButtonBankGet(&PopUp.buttons, GfxButtons[i]); 1654 1655 button->unsel_colour = ucolour; 1656 button->sel_colour = scolour; 1657 sdl_ButtonSize(button, 50 , PopUp.font.height + 2); 1658 sdl_ButtonVisible(button, TRUE); 1659 sdl_ButtonCaption(button, GfxDesc[i].name); 1660 button->tag = i; 1661 button->activate = SelectGfx; 1662 } 1663 #endif 1664 MoreFullscreen = sdl_ButtonBankNew(&PopUp.buttons); 1665 button = sdl_ButtonBankGet(&PopUp.buttons, MoreFullscreen); 1666 1667 button->unsel_colour = ucolour; 1668 button->sel_colour = scolour; 1669 sdl_ButtonSize(button, 50 , PopUp.font.height + 2); 1670 sdl_ButtonVisible(button, TRUE); 1671 sdl_ButtonCaption(button, fullscreen ? "On" : "Off"); 1672 button->tag = fullscreen; 1673 button->activate = FlipTag; 1674 1675 MoreOK = sdl_ButtonBankNew(&PopUp.buttons); 1676 button = sdl_ButtonBankGet(&PopUp.buttons, MoreOK); 1677 1678 button->unsel_colour = ucolour; 1679 button->sel_colour = scolour; 1680 sdl_ButtonSize(button, 50 , PopUp.font.height + 2); 1681 sdl_ButtonVisible(button, TRUE); 1682 sdl_ButtonCaption(button, "OK"); 1683 sdl_ButtonMove(button, width / 2 - 25, height - 40); 1684 button->activate = AcceptChanges; 1685 1686 popped = TRUE; 1687 } 1688 1382 1689 static errr Term_xtra_sdl_clear(void); 1383 1690 … … 1387 1694 * This may be called when a window wants resizing, 1388 1695 * is made visible, or the font has changed. 1696 * This function doesn't go in for heavy optimization, and doesn't need it- 1697 * it may initialize a few too many redraws or whatnot, but everything gets done! 1389 1698 */ 1390 1699 static void ResizeWin(term_window* win, int w, int h) … … 1487 1796 } 1488 1797 1798 StatusBar.need_update = TRUE; 1799 1489 1800 /* Hmmmm... */ 1490 1801 if (character_dungeon) do_cmd_redraw(); … … 1498 1809 term_window *win; 1499 1810 int i; 1500 1501 screen_w = 800;1502 screen_h = 600;1503 fullscreen = 0;1504 1811 1505 1812 /* Initialize the windows with crappy defaults! */ … … 1554 1861 1555 1862 s = strchr(buf, '='); 1863 s++; 1864 while (!isalnum(*s)) s++; 1556 1865 1557 1866 if (strstr(buf, "Resolution")) 1558 1867 { 1559 screen_w = atoi(s + 1);1868 screen_w = atoi(s); 1560 1869 s = strchr(buf, 'x'); 1561 1870 screen_h = atoi(s + 1); … … 1563 1872 else if (strstr(buf, "Fullscreen")) 1564 1873 { 1565 fullscreen = atoi(s + 1); 1874 fullscreen = atoi(s); 1875 } 1876 else if (strstr(buf, "Graphics")) 1877 { 1878 use_graphics = atoi(s); 1879 if (use_graphics) arg_graphics = TRUE; 1880 } 1881 else if (strstr(buf, "Bigtile")) 1882 { 1883 use_bigtile = atoi(s); 1566 1884 } 1567 1885 else if (strstr(buf, "Window")) 1568 1886 { 1569 win = &windows[atoi(s + 1)];1887 win = &windows[atoi(s)]; 1570 1888 } 1571 1889 else if (strstr(buf, "Visible")) 1572 1890 { 1573 int v = atoi(s + 1); 1574 if (v) win->visible = TRUE; 1575 else win->visible = FALSE; 1891 win->visible = atoi(s); 1576 1892 } 1577 1893 else if (strstr(buf, "Left")) 1578 1894 { 1579 win->left = atoi(s + 1);1895 win->left = atoi(s); 1580 1896 } 1581 1897 else if (strstr(buf, "Top")) 1582 1898 { 1583 win->top = atoi(s + 1);1899 win->top = atoi(s); 1584 1900 } 1585 1901 else if (strstr(buf, "Width")) 1586 1902 { 1587 win->width = atoi(s + 1);1903 win->width = atoi(s); 1588 1904 } 1589 1905 else if (strstr(buf, "Height")) 1590 1906 { 1591 win->height = atoi(s + 1);1907 win->height = atoi(s); 1592 1908 } 1593 1909 else if (strstr(buf, "Keys")) 1594 1910 { 1595 win->keys = atoi(s + 1);1911 win->keys = atoi(s); 1596 1912 } 1597 1913 else if (strstr(buf, "Font")) 1598 1914 { 1599 win->req_font = string_make(s + 2); 1600 } 1601 1602 1603 } 1915 win->req_font = string_make(s); 1916 } 1917 1918 1919 } 1920 1921 if (screen_w < 640) screen_w = 640; 1922 if (screen_h < 480) screen_h = 480; 1604 1923 1605 1924 my_fclose(fff); … … 1625 1944 fprintf(fff, "Resolution = %dx%d\n", screen_w, screen_h); 1626 1945 fprintf(fff, "Fullscreen = %d\n", fullscreen); 1946 fprintf(fff, "Graphics = %d\n", use_graphics); 1947 fprintf(fff, "Bigtile = %d\n", use_bigtile); 1627 1948 for (i = 0; i < ANGBAND_TERM_MAX; i++) 1628 1949 { … … 1647 1968 } 1648 1969 1649 1970 static void set_update_rect(term_window *win, SDL_Rect *rc); 1971 1972 static void DrawSizeWidget(void) 1973 { 1974 Uint32 colour = SDL_MapRGB(AppWin->format, 30, 160, 70); 1975 SDL_FillRect(AppWin, &SizingSpot, colour); 1976 SDL_UpdateRects(AppWin, 1, &SizingSpot); 1977 } 1650 1978 1651 1979 static int Movingx; … … 1666 1994 mouse.x = event->motion.x; 1667 1995 mouse.y = event->motion.y; 1996 win = &windows[SelectedTerm]; 1668 1997 1669 1998 /* We are moving a window */ 1670 1999 if (Moving) 1671 2000 { 1672 win = &windows[SelectedTerm];1673 1674 2001 /* Move the window */ 1675 2002 win->left = (mouse.x - Movingx); … … 1711 2038 else if (Sizing) 1712 2039 { 1713 win = &windows[SelectedTerm];1714 1715 2040 /* Adjust the sizing rectangle */ 1716 2041 SizingRect.w = win->width - win->left + (mouse.x - Movingx); … … 1720 2045 if (SelectedTerm == 0) 1721 2046 { 1722 if (SizingRect.w < win->tile_wid * 80) 1723 SizingRect.w = win->tile_wid * 80; 1724 if (SizingRect.h < win->tile_hgt * 24) 1725 SizingRect.h = win->tile_hgt * 24; 2047 int minwidth = (win->tile_wid * 80) + 2 * win->border; 2048 int minheight = (win->tile_hgt * 24) + win->border + win->title_height; 2049 if (SizingRect.w < minwidth) 2050 SizingRect.w = minwidth; 2051 if (SizingRect.h < minheight) 2052 SizingRect.h = minheight; 1726 2053 } 1727 2054 … … 1729 2056 sdl_BlitAll(); 1730 2057 } 2058 else 2059 { 2060 /* Have a look for the corner stuff */ 2061 if (point_in(&SizingSpot, mouse.x, mouse.y)) 2062 { 2063 if (!Sizingshow) 2064 { 2065 /* Indicate the hotspot */ 2066 Sizingshow = TRUE; 2067 DrawSizeWidget(); 2068 } 2069 } 2070 else if (Sizingshow) 2071 { 2072 SDL_Rect rc; 2073 Sizingshow = FALSE; 2074 RECT(win->width - 10, win->height - 10, 10, 10, &rc); 2075 set_update_rect(win, &rc); 2076 sdl_BlitWin(win); 2077 } 2078 } 1731 2079 break; 1732 2080 } … … 1742 2090 if (event->button.button == SDL_BUTTON_LEFT) 1743 2091 { 1744 2092 bool just_gained_focus = FALSE; 1745 2093 mouse.left = 1; 1746 2094 mouse.leftx = event->button.x; … … 1766 2114 if (idx < 0) break; 1767 2115 1768 /* The 'focused' window has changed -> set focus and exit*/2116 /* The 'focused' window has changed */ 1769 2117 if (idx != SelectedTerm) 1770 2118 { 1771 2119 TermFocus(idx); 1772 break;2120 just_gained_focus = TRUE; 1773 2121 } 1774 2122 … … 1804 2152 } 1805 2153 1806 /* Signal a mouse press to angband */1807 else 2154 /* Signal a mouse press to angband (only if the window is already focused) */ 2155 else if (!just_gained_focus) 1808 2156 { 1809 /* Calculate the 'cell' coords */ 1810 int x = (mouse.x - win->left - win->border) / win->tile_wid; 1811 int y = (mouse.y - win->top - win->title_height) / win->tile_hgt; 1812 1813 /* Send the mousepress to the appropriate term */ 1814 Term_activate(angband_term[idx]); 1815 Term_mousepress(x, y, 1); 1816 Term_activate(old); 2157 if (win->visible) 2158 { 2159 /* Calculate the 'cell' coords */ 2160 int x = (mouse.x - win->left - win->border) / win->tile_wid; 2161 int y = (mouse.y - win->top - win->title_height) / win->tile_hgt; 2162 2163 /* Send the mousepress to the appropriate term */ 2164 Term_activate(angband_term[idx]); 2165 Term_mousepress(x, y, 1); 2166 Term_activate(old); 2167 } 1817 2168 } 1818 2169 } … … 1977 2328 1978 2329 1979 2330 static void init_windows(void); 2331 static void init_morewindows(void); 1980 2332 /* 1981 2333 * Handle a single message sent to the application. … … 2032 2384 case SDL_VIDEORESIZE: 2033 2385 { 2034 /* Resize the application surface */ 2035 SDL_SetVideoMode(event->resize.w, event->resize.h, 0, 0); 2386 /* Free the surface */ 2387 SDL_FreeSurface(AppWin); 2388 2389 if (!fullscreen) 2390 { 2391 /* Make sure */ 2392 vflags &= ~(SDL_FULLSCREEN); 2393 vflags |= SDL_RESIZABLE; 2394 2395 screen_w = event->resize.w; 2396 screen_h = event->resize.h; 2397 2398 if (screen_w < 640) screen_w = 640; 2399 if (screen_h < 480) screen_h = 480; 2400 2401 /* Resize the application surface */ 2402 AppWin = SDL_SetVideoMode(screen_w, screen_h, 0, vflags); 2403 } 2404 else 2405 { 2406 /* Make sure */ 2407 vflags |= SDL_FULLSCREEN; 2408 vflags &= ~(SDL_RESIZABLE); 2409 2410 AppWin = SDL_SetVideoMode(full_w, full_h, 0, vflags); 2411 } 2412 init_morewindows(); 2413 init_windows(); 2414 2036 2415 break; 2037 2416 } … … 2260 2639 SDL_Rect rc; 2261 2640 2641 //if (use_bigtile) n*=2; 2262 2642 /* Build the area to black out */ 2263 2643 rc.x = col * win->tile_wid; … … 2303 2683 } 2304 2684 2685 #ifdef USE_GRAPHICS 2686 /*
