shithub: rott

Download patch

ref: c89c890fc7609504802ec4a45e63dc36e14bde2d
parent: b0ca26c9821919ed202d7b53c6bb94cd0c95454e
author: LTCHIPS <ltchips994@gmail.com>
date: Wed Mar 28 19:51:30 EDT 2018

Set up hud scaling options properly. Need an alternate solution for transparent hud

--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -41,6 +41,7 @@
 #include "rt_util.h"
 #include "rt_net.h" // for GamePaused
 #include "myprint.h"
+#include "rt_view.h"
 
 static void StretchMemPicture ();
 // GLOBAL VARIABLES
@@ -715,8 +716,6 @@
 {
 }
 
-int hudRescaleFactor = 4;
-
 //DO NOT CALL UNTIL AFTER THE INITIAL SCENE IS RENDERERED
 void RescaleAreaOfTexture(SDL_Renderer* renderer, SDL_Texture * source, SDL_Rect src, SDL_Rect dest)
 {
@@ -730,19 +729,12 @@
     SDL_DestroyTexture(sourceToResize);
 }
 
+int hudRescaleFactor = 1;
 
+boolean doRescaling = false;
 
-/* C version of rt_vh_a.asm */
-
-void VH_UpdateScreen (void)
+void RenderSurface(void)
 {
-
-    if (StretchScreen) { //bna++
-        StretchMemPicture ();
-    } else {
-        DrawCenterAim ();
-    }
-    
     SDL_Texture *newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
     if (newTex == NULL) 
     {
@@ -753,11 +745,13 @@
     SDL_RenderClear(renderer);
     SDL_RenderCopy(renderer, newTex, NULL, NULL);
     
-    if (!StretchScreen && hudRescaleFactor > 1)
+    if (!StretchScreen && hudRescaleFactor > 1 && doRescaling)
     {
-        RescaleAreaOfTexture(renderer, newTex, (SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, 0, 320, 16}, 
-               (SDL_Rect) {(iGLOBAL_SCREENWIDTH - (320 * hudRescaleFactor)) >> 1, 0, 320*hudRescaleFactor, 16*hudRescaleFactor}); //Status Bar
-        RescaleAreaOfTexture(renderer, newTex,(SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, iGLOBAL_SCREENHEIGHT - 16, 320, 16},
+        if(SHOW_TOP_STATUS_BAR())
+            RescaleAreaOfTexture(renderer, newTex, (SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, 0, 320, 16}, 
+                   (SDL_Rect) {(iGLOBAL_SCREENWIDTH - (320 * hudRescaleFactor)) >> 1, 0, 320*hudRescaleFactor, 16*hudRescaleFactor}); //Status Bar
+        if(SHOW_BOTTOM_STATUS_BAR())
+            RescaleAreaOfTexture(renderer, newTex,(SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, iGLOBAL_SCREENHEIGHT - 16, 320, 16},
                (SDL_Rect) {(iGLOBAL_SCREENWIDTH - (320* hudRescaleFactor)) >> 1, iGLOBAL_SCREENHEIGHT - 16*hudRescaleFactor, 320*hudRescaleFactor, 16*hudRescaleFactor}); //Bottom Bar
     }
     
@@ -764,10 +758,26 @@
     SDL_RenderPresent(renderer);
     
     SDL_DestroyTexture(newTex);
+
 }
 
 
 
+/* C version of rt_vh_a.asm */
+
+void VH_UpdateScreen (void)
+{
+
+    if (StretchScreen) { //bna++
+        StretchMemPicture ();
+    } else {
+        DrawCenterAim ();
+    }
+    
+    RenderSurface();
+}
+
+
 /*
 =================
 =
@@ -799,27 +809,8 @@
     } else {
         DrawCenterAim ();
     }
+    RenderSurface();
     
-    SDL_Texture *newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
-    if (newTex == NULL) 
-    {
-        Error("CreateTextureFromSurface failed: %s\n", SDL_GetError());
-        exit(1);
-    }
-    
-    SDL_RenderClear(renderer);
-    SDL_RenderCopy(renderer, newTex, NULL, NULL);
-    if (!StretchScreen && hudRescaleFactor > 1 ){
-        RescaleAreaOfTexture(renderer, newTex, (SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, 0, 320, 16}, 
-               (SDL_Rect) {(iGLOBAL_SCREENWIDTH - (320 * hudRescaleFactor)) >> 1, 0, 320*hudRescaleFactor, 16*hudRescaleFactor}); //Status Bar
-        RescaleAreaOfTexture(renderer, newTex,(SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, iGLOBAL_SCREENHEIGHT - 16, 320, 16},
-               (SDL_Rect) {(iGLOBAL_SCREENWIDTH - (320* hudRescaleFactor)) >> 1, iGLOBAL_SCREENHEIGHT - 16*hudRescaleFactor, 320*hudRescaleFactor, 16*hudRescaleFactor}); //Bottom Bar
-    }
-    
-    SDL_RenderPresent(renderer);
-    
-    SDL_DestroyTexture(newTex);
-
 
 #endif
 }
--- a/rott/rt_game.c
+++ b/rott/rt_game.c
@@ -5622,7 +5622,9 @@
     UpdateScore (gamestate.score);
     UpdateLives (locplayerstate->lives);
     UpdateTriads (player, 0);
+    
     PreCache ();
+    DisableScreenStretch();
     InitializeMessages();
 
     for (i=0; i<100; i++)
--- a/rott/rt_main.c
+++ b/rott/rt_main.c
@@ -1144,6 +1144,7 @@
 
 extern boolean allowBlitzMoreMissileWeps;
 extern boolean enableZomROTT;
+extern boolean doRescaling;
 
 void GameLoop (void)
 {
@@ -1465,6 +1466,7 @@
                     }
                     else
                     {
+                        
                         fizzlein = true;
                         SetupGameLevel ();
                         UpdateTriads(player,0);
@@ -1472,6 +1474,7 @@
                     }
                 }
             }
+            doRescaling = true;
             break;
 
         case ex_warped:
@@ -1995,13 +1998,14 @@
 
 }
 
-
+extern boolean doRescaling;
 void PauseLoop ( void )
 {
     StopWind();
 
     UpdateClientControls ();
-
+    
+    doRescaling = false;
     while (oldpolltime<oldtime)
     {
         CheckUnPause();
@@ -2018,6 +2022,7 @@
                 DrawTiledRegion( 0, 16, iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT - 32, 0, 16, shape );
                 DisableScreenStretch();//dont strech when we go BACK TO GAME
                 DrawPlayScreen(true);//repaint ammo and life stat
+                doRescaling = true;
                 VW_UpdateScreen ();//update screen
             }
             StartupClientControls();
--- a/rott/rt_menu.c
+++ b/rott/rt_menu.c
@@ -775,6 +775,7 @@
 {
     "SCREEN RESOLUTION",
     "ADJUST FOCAL WIDTH",
+    "HUD SCALING",
     "DISPLAY OPTIONS"
 };
 
@@ -836,7 +837,7 @@
     {1, "", 'B', NULL}
 };
 
-CP_iteminfo VisualOptionsItems = { 20, MENU_Y, 3, 0, 43, VisualOptionsNames, mn_largefont };
+CP_iteminfo VisualOptionsItems = { 20, MENU_Y, 4, 0, 43, VisualOptionsNames, mn_largefont };
 
 CP_iteminfo ScreenResolutionItems = {NORMALKEY_X, 17, 19, 0, 16, ScreenResolutions, mn_tinyfont};
 
@@ -849,11 +850,13 @@
 void CP_ScreenResolution(void);
 
 void CP_DisplayOptions(void);
+void DoAdjustHudScale(void);
 
 CP_itemtype VisualsOptionsMenu[] = 
 {
     {1, "", 'S', (menuptr)CP_ScreenResolution},
     {1, "", 'F', (menuptr)DoAdjustFocalWidth},
+    {1, "", 'H', (menuptr)DoAdjustHudScale},
     {1, "", 'D', (menuptr)CP_DisplayOptions}
 };
 
@@ -5478,6 +5481,15 @@
 {
     SliderMenu (&FocalWidthOffset, 200, 0, 44, 81, 194, 1, "block2", NULL,
                 "Adjust Focal Width", "Default", "You Crazy" );
+    DrawVisualsMenu ();
+}
+
+
+extern int hudRescaleFactor;
+void DoAdjustHudScale (void)
+{
+    SliderMenu (&hudRescaleFactor, 200, 0, 44, 81, 194, 1, "block2", NULL,
+                "Adjust Hud Scaling", "Small", "Large" );
     DrawVisualsMenu ();
 }
 
--- a/rott/rt_msg.c
+++ b/rott/rt_msg.c
@@ -466,6 +466,8 @@
 ====================
 */
 
+extern int hudRescaleFactor;
+
 void DisplayMessage   (int num,int position)
 {
     PrintX = 1;
@@ -478,7 +480,7 @@
 
     if ( SHOW_TOP_STATUS_BAR() )
     {
-        PrintY += 16;
+        PrintY += 16 * hudRescaleFactor;
     }
     if ( !MessagesEnabled )
     {
--- a/rott/rt_ted.c
+++ b/rott/rt_ted.c
@@ -1131,6 +1131,8 @@
 =
 ======================
 */
+
+extern boolean doRescaling;
 void PreCache( void )
 {
     int i;
@@ -1149,6 +1151,8 @@
     double Gs;
     Gs = (iGLOBAL_SCREENWIDTH*100/320);
     Gs = Gs / 100;
+    
+    doRescaling = false;
 
 //SetTextMode (  );
 
@@ -1342,6 +1346,7 @@
 #if (PRECACHETEST == 1)
     SoftError("<<<<<<<<<<<<<<<<<<<<<<<Precaching done\n");
 #endif
+    doRescaling = true;
 }
 
 
--- a/rott/rt_view.c
+++ b/rott/rt_view.c
@@ -288,6 +288,8 @@
 ==========================
 */
 
+extern int hudRescaleFactor;
+
 void SetViewSize
 (
     int size
@@ -630,8 +632,8 @@
         StatusBar |= TOP_STATUS_BAR;
 
         // Account for height of top status bar
-        maxheight -= 16;
-        topy      += 16;
+        maxheight -= 16 * hudRescaleFactor;
+        topy      += 16 * hudRescaleFactor;
     }
 
 //   if ( size == 7 ){maxheight -= 16;}//bna++
@@ -642,7 +644,7 @@
         // Turn on health and ammo bar
         StatusBar |= BOTTOM_STATUS_BAR;
 
-        maxheight -= 16;
+        maxheight -= 16 * hudRescaleFactor;
 
     }
     else if ( size < 10 )
@@ -665,7 +667,7 @@
     centerx     = viewwidth >> 1;
     centery     = viewheight >> 1;
     centeryfrac = (centery << 16);
-    yzangleconverter = ( 0xaf85 * viewheight ) / iGLOBAL_SCREENHEIGHT;
+    yzangleconverter = ( 0xaf85 * viewheight ) / 200;
 
     // Center the view horizontally
     screenx = ( iGLOBAL_SCREENWIDTH - viewwidth ) >> 1;