Update of /cvsroot/netrek/client/netrekxp/src In directory sc8-pr-cvs16:/tmp/cvs-serv22675/src Modified Files: data.c defaults.c docwin.c findslot.c getname.c local.c map.c mswindow.c newwin.c pingstats.c stats.c Log Message: This patch begins the work on making the game work when font size changes. Added new font W_SmallFont which will always be the traditional 6x10 pixel font. Not used currently, but for applications that require a small font regardless of regular font size, will use this. Fontsize is now a proper global variable and the ability to change it via netrekrc is now made aware to user via netrekrc entry. Restored xtrekrc and motdwin (aka entry window) to follow TWINSIDE as it seems the right thing to do, people expect tactical window and entry window to be same size. Removed debug statement in phasers I left in on accident. Centered planet names and army count on global map, so they scale properly with font size. Moved handy MIN function to global defs file. Added functions for determining size of stats window width and height for initial window creation. Main title bar is now on by default (most people agreed it should be on, deferring to their opinion). Fixed a ton of places where entry window was not scaling properly to text height. Team and quit windows will now remap properly if entry window is moved/resized. Fixed ping stats and stat window widths so that slider bars are never lost if font size is increased greatly. Index: findslot.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/findslot.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- findslot.c 6 Apr 2007 06:46:31 -0000 1.8 +++ findslot.c 13 Apr 2007 07:12:24 -0000 1.9 @@ -142,8 +142,8 @@ W_MapWindow (waitqWin); if (showMotd) { - motdWin = W_MakeWindow ("waitmotd", 1, WAITWIDTH + 1, 500, - 500, 0, 2, foreColor); + motdWin = W_MakeWindow ("waitmotd", 1, WAITWIDTH + 1, TWINSIDE, + TWINSIDE, 0, 2, foreColor); W_MapWindow (motdWin); showMotdWin (motdWin, WaitMotdLine); } Index: mswindow.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/mswindow.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -d -r1.69 -r1.70 --- mswindow.c 12 Apr 2007 09:06:10 -0000 1.69 +++ mswindow.c 13 Apr 2007 07:12:24 -0000 1.70 @@ -178,7 +178,7 @@ HWND AnyWindow; int W_FastClear = 0; -W_Font W_BigFont, W_RegularFont; +W_Font W_BigFont, W_SmallFont, W_RegularFont; W_Font W_HighlightFont, W_UnderlineFont; W_Color W_White = WHITE, W_Black = BLACK, W_Red = RED, W_Green = GREEN; W_Color W_Yellow = YELLOW, W_Cyan = CYAN, W_Grey = GREY; @@ -401,6 +401,7 @@ DeleteObject ((HFONT) W_RegularFont); DeleteObject ((HFONT) W_HighlightFont); DeleteObject ((HFONT) W_UnderlineFont); + DeleteObject ((HFONT) W_SmallFont); DeleteObject ((HFONT) W_BigFont); strcpy (FileName, GetExeDir ()); @@ -751,7 +752,7 @@ lf.lfPitchAndFamily = FF_MODERN | FIXED_PITCH; strcpy (lf.lfFaceName, "Netrek"); - lf.lfHeight = -intDefault ("fontsize", 10); + lf.lfHeight = -intDefault ("fontSize", fontSize); lf.lfWeight = FW_REGULAR; W_RegularFont = (W_Font) CreateFontIndirect (&lf); @@ -765,9 +766,15 @@ lf.lfUnderline = TRUE; W_UnderlineFont = (W_Font) CreateFontIndirect (&lf); + //Make a small font for whatever we need + strcpy (lf.lfFaceName, "Netrek"); + lf.lfUnderline = FALSE; + lf.lfHeight = 10; + lf.lfWidth = 6; + W_SmallFont = (W_Font) CreateFontIndirect (&lf); + //Use arial for the BigFont strcpy (lf.lfFaceName, "Arial"); - lf.lfUnderline = FALSE; lf.lfWeight = FW_MEDIUM; lf.lfHeight = 52; lf.lfWidth = 32; @@ -1990,11 +1997,15 @@ W_UnmapWindow (teamWin[i]); teamWin[i] = W_MakeWindow (teamshort[1 << i], i * (TWINSIDE / 5), TWINSIDE - (TWINSIDE / 5), (TWINSIDE / 5), (TWINSIDE / 5), w, 1, foreColor); + if (!ingame) + W_MapWindow (teamWin[i]); } W_UnmapWindow (qwin); qwin = W_MakeWindow ("quit", 4 * (TWINSIDE / 5), TWINSIDE - (TWINSIDE / 5), (TWINSIDE / 5), (TWINSIDE / 5), w, 1, foreColor); + if (!ingame) + W_MapWindow (qwin); W_FastClear = 1; if (viewBox) Index: pingstats.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/pingstats.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- pingstats.c 13 Feb 2007 04:34:32 -0000 1.4 +++ pingstats.c 13 Apr 2007 07:12:25 -0000 1.5 @@ -10,8 +10,6 @@ #include "data.h" #include "proto.h" -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) - #define BX_OFF() ((textWidth + 1) * W_Textwidth + S_IBORDER) #define BY_OFF(line) ((line) * (W_Textheight + S_IBORDER) + S_IBORDER) #define TX_OFF(len) ((textWidth - len) * W_Textwidth + S_IBORDER) @@ -19,7 +17,8 @@ /* right side labels */ #define TEXT_WIDTH (5*W_Textwidth + 2*STAT_BORDER) -#define STAT_WIDTH (260 + TEXT_WIDTH) +/* width assumes no label longer than 17 chars */ +#define STAT_WIDTH (MAX(260, TEXT_WIDTH + 17*W_Textwidth) + TEXT_WIDTH) #define STAT_HEIGHT BY_OFF(NUM_SLIDERS) #define STAT_BORDER 2 #define S_IBORDER 5 @@ -27,7 +26,7 @@ #define STAT_Y 13 #define SL_WID \ - (STAT_WIDTH -TEXT_WIDTH - 2 * S_IBORDER - (textWidth + 1) * W_Textwidth) + (STAT_WIDTH - TEXT_WIDTH - 2 * S_IBORDER - (textWidth + 1) * W_Textwidth) #define SL_HEI (W_Textheight) #define NUM_ELS(a) (sizeof (a) / sizeof (*(a))) Index: newwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- newwin.c 6 Apr 2007 06:46:32 -0000 1.60 +++ newwin.c 13 Apr 2007 07:12:25 -0000 1.61 @@ -1016,7 +1016,7 @@ BOXSIDE, w, 1, foreColor); statwin = W_MakeWindow ("stats", TWINSIDE + 2 * THICKBORDER - 100, TWINSIDE + 2 * THICKBORDER, - 100, 80, baseWin, BORDER, foreColor); + StatsWidth(), StatsHeight(), baseWin, BORDER, foreColor); W_SetWindowExposeHandler (statwin, redrawStats); W_DefineTrekCursor (baseWin); @@ -1935,12 +1935,12 @@ sprintf (buf, "--- %s ---", (char *) query_cowid ()); length = strlen (buf); - center = 250 - (length * W_Textwidth) / 2; + center = TWINSIDE / 2 - (length * W_Textwidth) / 2; W_WriteText (motdwin, center, W_Textheight, textColor, buf, length, W_BoldFont); sprintf (buf, CBUGS); length = strlen (buf); - center = 250 - (length * W_Textwidth) / 2; + center = TWINSIDE / 2 - (length * W_Textwidth) / 2; W_WriteText (motdwin, center, 3 * W_Textheight, textColor, buf, length, W_RegularFont); Index: local.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- local.c 12 Apr 2007 00:56:28 -0000 1.96 +++ local.c 13 Apr 2007 07:12:24 -0000 1.97 @@ -1590,7 +1590,6 @@ so check if we have it first */ if (php->ph_x > 0 && php->ph_y > 0 && php->ph_x < GWIDTH && php->ph_y < GWIDTH) { - LineToConsole("x, y %d %d\n", php->ph_x, php->ph_y); tx = (php->ph_x - me->p_x) / scaleFactor + TWINSIDE / 2; ty = (php->ph_y - me->p_y) / scaleFactor + TWINSIDE / 2; } Index: getname.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/getname.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- getname.c 23 Feb 2007 13:43:56 -0000 1.8 +++ getname.c 13 Apr 2007 07:12:24 -0000 1.9 @@ -60,7 +60,7 @@ autologin = 0; *defpasswd = *password1 = *password2 = '\0'; - W_WriteText (w, 100, 130, textColor, alf, strlen (alf), W_BoldFont); + W_WriteText (w, 100, 30 + 10 * W_Textheight, textColor, alf, strlen (alf), W_BoldFont); } @@ -97,7 +97,7 @@ { length = strlen (README[i]); - W_WriteText (w, 20, i * W_Textheight + 220, textColor, README[i], + W_WriteText (w, 20, i * W_Textheight + 30 + 19 * W_Textheight, textColor, README[i], length, W_RegularFont); } } @@ -185,7 +185,7 @@ if (loginAccept == 0) { s = "Bad password!"; - W_WriteText (w, 100, 110, textColor, s, strlen (s), W_BoldFont); + W_WriteText (w, 100, 30 + 8 * W_Textheight, textColor, s, strlen (s), W_BoldFont); (void) W_EventsPending (); sleep (1); W_ClearWindow (w); @@ -230,7 +230,7 @@ if (strcmp (password1, password2) != 0) { s = "Passwords do not match"; - W_WriteText (w, 100, 160, textColor, s, strlen (s), W_BoldFont); + W_WriteText (w, 100, 30 + 13 * W_Textheight, textColor, s, strlen (s), W_BoldFont); (void) W_EventsPending (); sleep (3); W_ClearWindow (w); @@ -255,16 +255,17 @@ W_WriteText (w, 40, 30, textColor, t, strlen (t), W_RegularFont); t = "a temporary name or hit ^G (CTRL-G) to autologin as guest."; - W_WriteText (w, 40, 40, textColor, t, strlen (t), W_RegularFont); + W_WriteText (w, 40, 30 + W_Textheight, textColor, t, strlen (t), W_RegularFont); t = "Or, hit ^D (CTRL-D) with a blank name to exit immediately."; - W_WriteText (w, 40, 50, textColor, t, strlen (t), W_RegularFont); + W_WriteText (w, 40, 30 + 2 * W_Textheight, textColor, t, strlen (t), W_RegularFont); sprintf (s, "Character name (\"%s\"): ", defname); - W_WriteText (w, 40, 70, textColor, s, strlen (s), W_RegularFont); + W_WriteText (w, 40, 30 + 4 * W_Textheight, textColor, s, strlen (s), W_RegularFont); t = ". ."; - W_WriteText (w, 40 + ((20 + strlen (defname)) * W_Textwidth), 68, + W_WriteText (w, 40 + ((20 + strlen (defname)) * W_Textwidth), + 30 + 4 * W_Textheight - W_Textheight / 5, textColor, t, strlen (t), W_RegularFont); } @@ -288,65 +289,65 @@ sprintf (buf, "Connection established to %s", serverName); t = buf; - W_WriteText (w, 100, 170, textColor, t, strlen (t), W_BoldFont); + W_WriteText (w, 100, 30 + 14 * W_Textheight, textColor, t, strlen (t), W_BoldFont); sprintf (s, "%-15s", tempname); - W_WriteText (w, 40 + (21 + strlen (defname)) * W_Textwidth, 70, textColor, + W_WriteText (w, 40 + (21 + strlen (defname)) * W_Textwidth, 30 + 4 * W_Textheight, textColor, s, strlen (s), W_BoldFont); t = " ^ "; W_WriteText (w, 40 + (20 + strlen (defname) + - strlen (tempname)) * W_Textwidth, 80, textColor, t, 3, + strlen (tempname)) * W_Textwidth, 30 + 5 * W_Textheight, textColor, t, 3, W_RegularFont); if (state == ST_GETPASS) { t = "Enter password: "; - W_WriteText (w, 100, 90, textColor, t, strlen (t), W_BoldFont); + W_WriteText (w, 100, 30 + 6 * W_Textheight, textColor, t, strlen (t), W_BoldFont); t = ". ."; - W_WriteText (w, 100 + ((16) * W_Textwidth), 88, + W_WriteText (w, 100 + ((16) * W_Textwidth), 30 + 6 * W_Textheight - W_Textheight / 5, textColor, t, strlen (t), W_RegularFont); for (i = 0; i < strlen (password1); i++) - W_WriteText (w, 100 + ((16 + 1 + i) * W_Textwidth), 90, + W_WriteText (w, 100 + ((16 + 1 + i) * W_Textwidth), 30 + 6 * W_Textheight, textColor, "x", 1, W_BoldFont); t = " ^ "; W_WriteText (w, 100 + (16 + strlen (password1)) * W_Textwidth, - 100, textColor, t, 3, W_RegularFont); + 30 + 7 * W_Textheight, textColor, t, 3, W_RegularFont); } if (state > ST_GETPASS) { t = "You need to make a password."; - W_WriteText (w, 100, 90, textColor, t, strlen (t), W_BoldFont); + W_WriteText (w, 100, 30 + 6 * W_Textheight, textColor, t, strlen (t), W_BoldFont); t = "So think of a password you can remember, and enter it."; - W_WriteText (w, 100, 100, textColor, t, strlen (t), W_BoldFont); + W_WriteText (w, 100, 30 + 7 * W_Textheight, textColor, t, strlen (t), W_BoldFont); t = "What is your password? :"; - W_WriteText (w, 100, 110, textColor, t, strlen (t), W_BoldFont); + W_WriteText (w, 100, 30 + 8 * W_Textheight, textColor, t, strlen (t), W_BoldFont); t = ". ."; - W_WriteText (w, 100 + ((24) * W_Textwidth), 108, + W_WriteText (w, 100 + ((24) * W_Textwidth), 30 + 8 * W_Textheight - W_Textheight / 5, textColor, t, strlen (t), W_RegularFont); for (i = 0; i < strlen (password1); i++) - W_WriteText (w, 100 + ((24 + 1 + i) * W_Textwidth), 110, + W_WriteText (w, 100 + ((24 + 1 + i) * W_Textwidth), 30 + 8 * W_Textheight, textColor, "x", 1, W_BoldFont); t = " ^ "; W_WriteText (w, 100 + (24 + strlen (password1)) * W_Textwidth, - 120, textColor, t, 3, W_RegularFont); + 30 + 9 * W_Textheight, textColor, t, 3, W_RegularFont); } if (state == ST_MAKEPASS2) { t = "Enter it again to make sure you typed it right."; - W_WriteText (w, 100, 130, textColor, t, strlen (t), W_BoldFont); + W_WriteText (w, 100, 30 + 10 * W_Textheight, textColor, t, strlen (t), W_BoldFont); t = "Your password? :"; - W_WriteText (w, 100, 140, textColor, t, strlen (t), W_BoldFont); + W_WriteText (w, 100, 30 + 11 * W_Textheight, textColor, t, strlen (t), W_BoldFont); t = ". ."; - W_WriteText (w, 100 + ((16) * W_Textwidth), 138, + W_WriteText (w, 100 + ((16) * W_Textwidth), 30 + 11 * W_Textheight - W_Textheight / 5, textColor, t, strlen (t), W_RegularFont); for (i = 0; i < strlen (password2); i++) - W_WriteText (w, 100 + ((16 + 1 + i) * W_Textwidth), 140, + W_WriteText (w, 100 + ((16 + 1 + i) * W_Textwidth), 30 + 11 * W_Textheight, textColor, "x", 1, W_BoldFont); t = " ^ "; W_WriteText (w, 100 + (16 + strlen (password2)) * W_Textwidth, - 150, textColor, t, 3, W_RegularFont); + 30 + 12 * W_Textheight, textColor, t, 3, W_RegularFont); } } Index: stats.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/stats.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- stats.c 20 Sep 2006 16:54:20 -0000 1.3 +++ stats.c 13 Apr 2007 07:12:25 -0000 1.4 @@ -23,18 +23,14 @@ #include "data.h" #include "proto.h" -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) - #define BX_OFF() ((textWidth + 1) * W_Textwidth + S_IBORDER) #define BY_OFF(line) ((line) * (W_Textheight + S_IBORDER) + S_IBORDER) #define TX_OFF(len) ((textWidth - len) * W_Textwidth + S_IBORDER) #define TY_OFF(line) BY_OFF(line) -#if 0 -#define STAT_WIDTH 160 -#else -#define STAT_WIDTH st_width -#endif +/* left side labels, assumes no label longer than 2 chars */ +#define TEXT_WIDTH (2*W_Textwidth + 2*STAT_BORDER) +#define STAT_WIDTH (MAX(80,TEXT_WIDTH) + TEXT_WIDTH) #define STAT_HEIGHT BY_OFF(NUM_SLIDERS) #define STAT_BORDER 2 #define S_IBORDER 5 @@ -79,7 +75,17 @@ static int textWidth = 0; static int initialized = 0; -static int st_width = -1; +int +StatsHeight (void) +{ + return STAT_HEIGHT; +} + +int +StatsWidth (void) +{ + return STAT_WIDTH; +} static void box (int filled, @@ -144,7 +150,6 @@ sliders[i].diff = sliders[i].max - sliders[i].min; sliders[i].lastVal = 0; } - st_width = W_WindowWidth (statwin); } void Index: defaults.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/defaults.c,v retrieving revision 1.77 retrieving revision 1.78 diff -u -d -r1.77 -r1.78 --- defaults.c 12 Apr 2007 00:56:28 -0000 1.77 +++ defaults.c 13 Apr 2007 07:12:23 -0000 1.78 @@ -189,6 +189,12 @@ NULL } }, + {"fontSize", &fontSize, RC_INT, + { + "Height in pixels of font, default 10", + NULL + } + }, {"forceDisplay", &forceDisplay, RC_INT, { "Number of colors the client will display", Index: data.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -d -r1.81 -r1.82 --- data.c 9 Apr 2007 02:52:31 -0000 1.81 +++ data.c 13 Apr 2007 07:12:23 -0000 1.82 @@ -736,6 +736,7 @@ HANDLE InputThread = NULL; // missing variables +int fontSize = 10; int forceDisplay = 0; int mungScrollbarColors = 0; int showMotd = 1; Index: docwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/docwin.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- docwin.c 6 Apr 2007 06:46:31 -0000 1.4 +++ docwin.c 13 Apr 2007 07:12:23 -0000 1.5 @@ -229,7 +229,7 @@ W_Font font = W_RegularFont; if (!xtrekrcwin) - xtrekrcwin = W_MakeWindow ("xtrekrcWin", 0, 200, 500, 500, 0, 2, + xtrekrcwin = W_MakeWindow ("xtrekrcWin", 0, 200, TWINSIDE, TWINSIDE, 0, 2, foreColor); W_ClearWindow (xtrekrcwin); @@ -239,12 +239,12 @@ sprintf (buf, "--- %s ---", (char *) query_cowid ()); length = strlen (buf); - center = 250 - (length * W_Textwidth) / 2; + center = TWINSIDE / 2 - (length * W_Textwidth) / 2; W_WriteText (xtrekrcwin, center, W_Textheight, textColor, buf, length, W_BoldFont); sprintf (buf, CBUGS); length = strlen (buf); - center = 250 - (length * W_Textwidth) / 2; + center = TWINSIDE / 2 - (length * W_Textwidth) / 2; W_WriteText (xtrekrcwin, center, 3 * W_Textheight, textColor, buf, length, W_RegularFont); Index: map.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/map.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- map.c 11 Apr 2007 23:06:34 -0000 1.50 +++ map.c 13 Apr 2007 07:12:24 -0000 1.51 @@ -556,7 +556,7 @@ ody - (BMP_MPLANET_HEIGHT / 2), BMP_MPLANET_WIDTH, BMP_MPLANET_HEIGHT); - W_WriteText (mapw, odx - (BMP_MPLANET_WIDTH / 2), + W_WriteText (mapw, odx - (W_Textwidth * 3 / 2), ody + (BMP_MPLANET_HEIGHT / 2), backColor, l->pl_name, 3, planetFont (l)); pl_update[l->pl_no].plu_update = 0; @@ -674,20 +674,20 @@ agri_name[0] = (char) (toupper (l->pl_name[0])); agri_name[1] = (char) (toupper (l->pl_name[1])); agri_name[2] = (char) (toupper (l->pl_name[2])); - W_WriteText (mapw, dx - (BMP_MPLANET_WIDTH / 2), + W_WriteText (mapw, dx - (W_Textwidth * 3 / 2), dy + (BMP_MPLANET_HEIGHT / 2), getAgriColor (l), agri_name, 3, planetFont (l)); } else { - W_WriteText (mapw, dx - (BMP_MPLANET_WIDTH / 2), + W_WriteText (mapw, dx - (W_Textwidth * 3 / 2), dy + (BMP_MPLANET_HEIGHT / 2), getAgriColor (l), l->pl_name, 3, planetFont (l)); } } else { - W_WriteText (mapw, dx - (BMP_MPLANET_WIDTH / 2), + W_WriteText (mapw, dx - (W_Textwidth * 3 / 2), dy + (BMP_MPLANET_HEIGHT / 2), planetColor (l), l->pl_name, 3, planetFont (l)); } @@ -719,7 +719,7 @@ armbuflen = 4; } - W_MaskText (mapw, dx - (BMP_MPLANET_WIDTH / 4) - 2*(armbuflen - 2), + W_MaskText (mapw, dx - (W_Textwidth * (armbuflen - 1) / 2), dy - (BMP_MPLANET_HEIGHT / 4), W_White, armbuf, armbuflen, W_BoldFont); }