Changeset 114

Show
Ignore:
Timestamp:
05/06/07 10:18:41 (1 year ago)
Author:
takkaria
Message:

Update SDL port. (Iain McFall?)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/pref/font.prf

    r85 r114  
    5757 
    5858?:[EQU $SYS sdl] 
    59 %:font-win.prf 
     59%:font-sdl.prf 
    6060 
    6161?:1 
  • trunk/lib/pref/graf.prf

    r1 r114  
    4747%:graf-acn.prf 
    4848 
     49?:[EQU $SYS sdl] 
     50%:graf-sdl.prf 
     51 
    4952?:1 
    5053 
  • trunk/src/Makefile.src

    r96 r114  
    1414ZFILES = z-file z-form z-rand z-term z-type z-util z-virt 
    1515MAINFILES = main maid-x11 \ 
    16         $(addprefix main-,cap crb dos gcu gtk ibm lsl ros sla vcs win x11 xaw xpj) 
     16        $(addprefix main-,cap crb dos gcu gtk ibm lsl ros sdl sla vcs win x11 xaw xpj) 
    1717 
    1818ANGFILES = \ 
  • trunk/src/main-sdl.c

    r111 r114  
    22 
    33/* 
    4  * Angband SDL port by Iain McFall (mcfall.iain@googlemail.com) 
     4 * Angband SDL port (c) 2007 Iain McFall (mcfall.iain@googlemail.com) 
    55 *  
    66 * Based on the sangband SDL port, by Leon Marrick & others. 
    77 * 
    8  * This port is definately in its early stages and as yet 
    9  * has no support for graphics or sound. Its current purpose is 
    10  * to see how it works on different machines. 
    11  * There is no support for 256 colours at the moment either. 
    128 * 
    139 * Comments and suggestions are welcome. The UI probably needs some 
     
    1814 
    1915/* 
    20  * Copyright (c) 2007 Leon Marrick and others 
    21  * 
    2216 * This program is free software; you can redistribute it and/or modify it 
    2317 * under the terms of the GNU General Public License.  Parts may also be 
     
    4034 * you are new to all this, read "makefile.sdl". 
    4135 * 
    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 
    4639 * 
    4740 * 
     
    5144 * - If "USE_GRAPHICS" is defined, then it also needs some bitmapped (.bmp) 
    5245 *   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 into 
    54  *   "lib/xtra/sound/". 
    5546 * 
    5647 * - The "lib/pref/pref-sdl.prf" file contains keymaps, macro definitions, 
     
    5950 *   normal "*.fon" font files in the "lib/xtra/font/" directory. 
    6051 * 
    61  * - The files "win/angband.rc" and "win/angband.ico" can be included in your 
    62  *   project if using MSVC++.  "win/angband.ico" can also be added if using 
    63  *   DevC++ and probably other Windows compilers. 
    6452 * 
    6553 * 
     
    112100 *   Windows machines. 
    113101 */ 
     102#include "angband.h" 
    114103 
    115104#ifdef USE_SDL 
    116 #include "angband.h" 
     105 
    117106#include "main.h" 
     107#include "SDL.h" 
    118108#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 */ 
     111static Uint32 vflags = SDL_ANYFORMAT; 
     112 
     113/* Current screen dimensions */ 
     114static int screen_w = 800; 
     115static int screen_h = 600; 
     116 
     117/* Fullscreen dimensions */ 
     118static int full_w; 
     119static int full_h; 
     120 
     121/* Want fullscreen? */ 
     122static bool fullscreen = FALSE; 
    128123 
    129124/* 
     
    131126 */ 
    132127static cptr ANGBAND_DIR_XTRA_FONT; 
     128static cptr ANGBAND_DIR_XTRA_GRAF; 
    133129/* Later... 
    134 static cptr ANGBAND_DIR_XTRA_GRAF; 
    135130static cptr ANGBAND_DIR_XTRA_SOUND; 
    136 static cptr ANGBAND_DIR_XTRA_MUSIC; 
    137131*/ 
    138132 
     133/* 
     134 * Used as 'system' font 
     135 */ 
    139136static 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 
    146139cptr FontList[MAX_FONTS]; 
    147140static int num_fonts = 0; 
     
    307300static bool popped; 
    308301 
     302/* 
     303 * Term windows 
     304 */ 
    309305static term_window windows[ANGBAND_TERM_MAX]; 
    310306static int Zorder[ANGBAND_TERM_MAX]; 
     
    338334 
    339335static int StatusHeight;        /* The height in pixels of the status bar */ 
    340  
    341336static int SelectedTerm;        /* Current selected Term */ 
    342337 
     338static int AboutSelect;         /* About button */ 
    343339static int TermSelect;          /* Term selector button */ 
    344340static int FontSelect;          /* Font selector button */ 
    345341static int VisibleSelect;       /* Hide/unhide window button*/ 
     342static int MoreSelect;          /* Other options button */ 
    346343static int QuitSelect;          /* Quit button */ 
     344 
     345/* Buttons on the 'More' panel */ 
     346static int MoreOK;                      /* Accept changes */ 
     347static int MoreFullscreen;      /* Fullscreen toggle button */ 
    347348 
    348349static bool Moving;                             /* Moving a window */ 
    349350static bool Sizing;                             /* Sizing a window */ 
    350 static SDL_Rect SizingSpot;             /* Rect to descibe the sizing button */ 
     351static SDL_Rect SizingSpot;             /* Rect to descibe the sizing area */ 
     352static bool Sizingshow = FALSE; /* Is the resize thingy displayed? */ 
    351353static SDL_Rect SizingRect;             /* Rect to describe the current resize window */ 
    352354 
    353 /* 
    354  * The basic angband text colours in a sdl friendly form 
     355#ifdef USE_GRAPHICS 
     356typedef struct GfxInfo GfxInfo; 
     357struct 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 
     368static SDL_Surface *GfxSurface = NULL;  /* A surface for the graphics */ 
     369 
     370#define GfxModes 4 
     371static 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 
     386static int MoreBigtile;                         /* Toggle bigtile button */ 
     387static int GfxButtons[GfxModes];        /* Graphics mode buttons */ 
     388static int SelectedGfx;                         /* Current selected gfx */ 
     389#endif 
     390 
     391/* 
     392 * The basic angband text colours in an sdl friendly form 
    355393 */ 
    356394static u32b text_colours[16]; 
     
    930968 * sdl_Window functions 
    931969 */ 
    932  
    933970static void sdl_WindowFree(sdl_Window* window) 
    934971{ 
     
    10251062        } 
    10261063         
     1064#ifdef USE_GRAPHICS 
     1065        /* Free the graphics surface */ 
     1066        if (GfxSurface) SDL_FreeSurface(GfxSurface); 
     1067#endif 
    10271068        /* Free the 'System font' */ 
    10281069        sdl_FontFree(&SystemFont); 
     
    10961137                SDL_Rect rc; 
    10971138                 
     1139                if (!win->visible) continue; 
    10981140                if (!point_in(RECT(win->left, win->top, win->width, win->height, &rc), x, y)) continue; 
    10991141                 
     
    11061148static void draw_statusbar(sdl_Window *window) 
    11071149{ 
    1108         char buf[1024]; 
     1150        char buf[128]; 
     1151        term_window *win = &windows[SelectedTerm]; 
    11091152        int fw = window->font.width; 
    11101153        int x = 1; 
     
    11121155         
    11131156        SDL_Rect rc; 
    1114         my_strcpy(buf, format("%s v%s", VERSION_NAME, VERSION_STRING), sizeof(buf)); 
    11151157         
    11161158        u32b c = SDL_MapRGB(window->surface->format, 160, 160, 60); 
     
    11191161        SDL_FillRect(StatusBar.surface, &rc, c); 
    11201162         
     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)); 
    11211174        sdl_WindowText(&StatusBar, c, x, 1, buf); 
    11221175        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; 
    11301176         
    11311177        sdl_WindowText(&StatusBar, c, x, 1, "Visible:"); 
     
    11421188         
    11431189        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         
    11451198} 
    11461199 
     
    11711224        int i; 
    11721225        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); 
    11741227        SDL_FillRect(AppWin, NULL, back_colour); 
    11751228         
     
    11901243                        SizingSpot.x = win->left + win->width - 10; 
    11911244                        SizingSpot.y = win->top + win->height - 10; 
    1192                         SDL_FillRect(AppWin, &SizingSpot, ccolour); 
     1245                        //SDL_FillRect(AppWin, &SizingSpot, ccolour); 
    11931246                         
    11941247                        if (Sizing) 
     
    12391292         
    12401293        sdl_ButtonCaption(button, angband_term_name[SelectedTerm]); 
    1241  
     1294         
    12421295        if (!win->visible) 
    12431296        { 
     
    12651318        sdl_BlitAll(); 
    12661319}        
    1267          
     1320 
     1321static 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         
     1335static 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 
    12681348static void SelectTerm(sdl_Button *sender) 
    12691349{ 
     
    13181398                term_windowFree(window); 
    13191399                angband_term[SelectedTerm] = NULL; 
    1320                 sdl_BlitAll(); 
     1400                 
    13211401        } 
    13221402        else 
     
    13281408         
    13291409        SetStatusButtons(); 
     1410        sdl_BlitAll(); 
    13301411} 
    13311412 
     
    13421423        sdl_CheckFont(window->req_font, &w, &h); 
    13431424         
    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); 
    13451427         
    13461428        SetStatusButtons(); 
     
    13481430        RemovePopUp(); 
    13491431         
    1350        
     1432
    13511433 
    13521434 
     
    13801462} 
    13811463 
     1464#ifdef USE_GRAPHICS 
     1465static errr load_gfx(void); 
     1466 
     1467static void SelectGfx(sdl_Button *sender) 
     1468{ 
     1469        SelectedGfx = sender->tag; 
     1470} 
     1471#endif 
     1472 
     1473static 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 
     1546static 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 
     1560static 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 
     1617static 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 
    13821689static errr Term_xtra_sdl_clear(void); 
    13831690 
     
    13871694 * This may be called when a window wants resizing, 
    13881695 * 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! 
    13891698 */ 
    13901699static void ResizeWin(term_window* win, int w, int h) 
     
    14871796        } 
    14881797         
     1798        StatusBar.need_update = TRUE; 
     1799         
    14891800        /* Hmmmm... */ 
    14901801        if (character_dungeon) do_cmd_redraw(); 
     
    14981809        term_window *win; 
    14991810        int i; 
    1500          
    1501         screen_w = 800; 
    1502         screen_h = 600; 
    1503         fullscreen = 0; 
    15041811         
    15051812        /* Initialize the windows with crappy defaults! */ 
     
    15541861                 
    15551862                s = strchr(buf, '='); 
     1863                s++; 
     1864                while (!isalnum(*s)) s++; 
    15561865                 
    15571866                if (strstr(buf, "Resolution")) 
    15581867                { 
    1559                         screen_w = atoi(s + 1); 
     1868                        screen_w = atoi(s); 
    15601869                        s = strchr(buf, 'x'); 
    15611870                        screen_h = atoi(s + 1); 
     
    15631872                else if (strstr(buf, "Fullscreen")) 
    15641873                { 
    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); 
    15661884                } 
    15671885                else if (strstr(buf, "Window")) 
    15681886                { 
    1569                         win = &windows[atoi(s + 1)]; 
     1887                        win = &windows[atoi(s)]; 
    15701888                } 
    15711889                else if (strstr(buf, "Visible")) 
    15721890                { 
    1573                         int v = atoi(s + 1); 
    1574                         if (v) win->visible = TRUE; 
    1575                         else win->visible = FALSE; 
     1891                        win->visible = atoi(s); 
    15761892                } 
    15771893                else if (strstr(buf, "Left")) 
    15781894                { 
    1579                         win->left = atoi(s + 1); 
     1895                        win->left = atoi(s); 
    15801896                } 
    15811897                else if (strstr(buf, "Top")) 
    15821898                { 
    1583                         win->top = atoi(s + 1); 
     1899                        win->top = atoi(s); 
    15841900                } 
    15851901                else if (strstr(buf, "Width")) 
    15861902                { 
    1587                         win->width = atoi(s + 1); 
     1903                        win->width = atoi(s); 
    15881904                } 
    15891905                else if (strstr(buf, "Height")) 
    15901906                { 
    1591                         win->height = atoi(s + 1); 
     1907                        win->height = atoi(s); 
    15921908                } 
    15931909                else if (strstr(buf, "Keys")) 
    15941910                { 
    1595                         win->keys = atoi(s + 1); 
     1911                        win->keys = atoi(s); 
    15961912                } 
    15971913                else if (strstr(buf, "Font")) 
    15981914                { 
    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; 
    16041923         
    16051924        my_fclose(fff); 
     
    16251944        fprintf(fff, "Resolution = %dx%d\n", screen_w, screen_h); 
    16261945        fprintf(fff, "Fullscreen = %d\n", fullscreen); 
     1946        fprintf(fff, "Graphics = %d\n", use_graphics); 
     1947        fprintf(fff, "Bigtile = %d\n", use_bigtile); 
    16271948        for (i = 0; i < ANGBAND_TERM_MAX; i++) 
    16281949        { 
     
    16471968} 
    16481969 
    1649  
     1970static void set_update_rect(term_window *win, SDL_Rect *rc); 
     1971 
     1972static 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
    16501978 
    16511979static int Movingx; 
     
    16661994                        mouse.x = event->motion.x; 
    16671995                        mouse.y = event->motion.y; 
     1996                        win = &windows[SelectedTerm]; 
    16681997                         
    16691998                        /* We are moving a window */ 
    16701999                        if (Moving) 
    16712000                        { 
    1672                                 win = &windows[SelectedTerm]; 
    1673                                  
    16742001                                /* Move the window */ 
    16752002                                win->left = (mouse.x - Movingx); 
     
    17112038                        else if (Sizing) 
    17122039                        { 
    1713                                 win = &windows[SelectedTerm]; 
    1714                                  
    17152040                                /* Adjust the sizing rectangle */ 
    17162041                                SizingRect.w = win->width - win->left + (mouse.x - Movingx); 
     
    17202045                                if (SelectedTerm == 0) 
    17212046                                { 
    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; 
    17262053                                } 
    17272054                                 
     
    17292056                                sdl_BlitAll(); 
    17302057                        } 
     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                        } 
    17312079                        break; 
    17322080                } 
     
    17422090                        if (event->button.button == SDL_BUTTON_LEFT) 
    17432091                        { 
    1744                                  
     2092                                bool just_gained_focus = FALSE; 
    17452093                                mouse.left = 1; 
    17462094                                mouse.leftx = event->button.x; 
     
    17662114                                if (idx < 0) break; 
    17672115                                 
    1768                                 /* The 'focused' window has changed -> set focus and exit */ 
     2116                                /* The 'focused' window has changed */ 
    17692117                                if (idx != SelectedTerm) 
    17702118                                { 
    17712119                                        TermFocus(idx); 
    1772                                         break
     2120                                        just_gained_focus = TRUE
    17732121                                } 
    17742122         
     
    18042152                                } 
    18052153                                 
    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) 
    18082156                                { 
    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                                        } 
    18172168                                } 
    18182169                        } 
     
    19772328 
    19782329 
    1979  
     2330static void init_windows(void); 
     2331static void init_morewindows(void); 
    19802332/* 
    19812333 * Handle a single message sent to the application. 
     
    20322384                case SDL_VIDEORESIZE: 
    20332385                { 
    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                         
    20362415                        break; 
    20372416                } 
     
    22602639        SDL_Rect rc; 
    22612640         
     2641        //if (use_bigtile) n*=2; 
    22622642        /* Build the area to black out */ 
    22632643        rc.x = col * win->tile_wid; 
     
    23032683} 
    23042684 
     2685#ifdef USE_GRAPHICS 
     2686/*