diff --git a/docs/rh-log.txt b/docs/rh-log.txt index c64d60d4b..e166fc5d3 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ April 15, 2009 +- Changing screen resolution now adjusts the automap scale to be constant + relative to screen resolution. - Fixed: When FMultiPatchTexture::MakeTexture() needed to work in RGB colorspace, it didn't zero out the temporary buffer. - Fixed memory leak from leftover code for 7z loading and added the diff --git a/src/am_map.cpp b/src/am_map.cpp index 8e1558c09..2654d0b79 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -370,6 +370,7 @@ static fixed_t mapxstart=0; //x-value for the bitmap. static bool stopped = true; +static void AM_calcMinMaxMtoF(); void AM_rotatePoint (fixed_t *x, fixed_t *y); void AM_rotate (fixed_t *x, fixed_t *y, angle_t an); @@ -395,7 +396,7 @@ void AM_getIslope (mline_t *ml, islope_t *is) } */ -void AM_GetPosition(fixed_t & x, fixed_t & y) +void AM_GetPosition(fixed_t &x, fixed_t &y) { x = (m_x + m_w/2) << FRACTOMAPBITS; y = (m_y + m_h/2) << FRACTOMAPBITS; @@ -472,14 +473,10 @@ bool AM_addMark () // static void AM_findMinMaxBoundaries () { - int i; - fixed_t a; - fixed_t b; - min_x = min_y = FIXED_MAX; max_x = max_y = FIXED_MIN; - for (i = 0; i < numvertexes; i++) + for (int i = 0; i < numvertexes; i++) { if (vertexes[i].x < min_x) min_x = vertexes[i].x; @@ -498,8 +495,13 @@ static void AM_findMinMaxBoundaries () min_w = 2*PLAYERRADIUS; // const? never changed? min_h = 2*PLAYERRADIUS; - a = MapDiv (SCREENWIDTH << MAPBITS, max_w); - b = MapDiv (::ST_Y << MAPBITS, max_h); + AM_calcMinMaxMtoF(); +} + +static void AM_calcMinMaxMtoF() +{ + fixed_t a = MapDiv (SCREENWIDTH << MAPBITS, max_w); + fixed_t b = MapDiv (::ST_Y << MAPBITS, max_h); min_scale_mtof = a < b ? a : b; max_scale_mtof = MapDiv (SCREENHEIGHT << MAPBITS, 2*PLAYERRADIUS); @@ -864,9 +866,6 @@ void AM_LevelInit () scale_ftom = MapDiv(MAPUNIT, scale_mtof); } - - - // // // @@ -889,6 +888,8 @@ void AM_Start () AM_loadPics(); } + + // // set the window scale to the maximum size // @@ -907,6 +908,24 @@ void AM_maxOutWindowScale () scale_ftom = MapDiv(MAPUNIT, scale_mtof); } +// +// Called right after the resolution has changed +// +void AM_NewResolution() +{ + fixed_t oldmin = min_scale_mtof; + AM_calcMinMaxMtoF(); + scale_mtof = Scale(scale_mtof, min_scale_mtof, oldmin); + scale_ftom = MapDiv(MAPUNIT, scale_mtof); + if (scale_mtof < min_scale_mtof) + AM_minOutWindowScale(); + else if (scale_mtof > max_scale_mtof) + AM_maxOutWindowScale(); + f_w = screen->GetWidth(); + f_h = ST_Y; + AM_activateNewScale(); +} + CCMD (togglemap) { diff --git a/src/am_map.h b/src/am_map.h index afacdd178..71740b9a7 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -39,6 +39,7 @@ void AM_Drawer (void); // if the level is completed while it is up. void AM_Stop (void); +void AM_NewResolution (); void AM_ToggleMap (); void AM_LevelInit (); void AM_SerializeMarkers(FArchive &arc); diff --git a/src/d_main.cpp b/src/d_main.cpp index 1be642cc9..25c0a8407 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -540,6 +540,7 @@ void D_Display () C_NewModeAdjust (); // Reload crosshair if transitioned to a different size crosshair.Callback (); + AM_NewResolution (); } }