From 0fae13bab4845cfa9d7b1f4bb0e552b7facef899 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 16 May 2018 06:17:34 -0400 Subject: [PATCH] - added vid_scaletowidth and vid_scaletoheight to calculate vid_scalefactor to reach a certain value on screen dynamics --- src/r_videoscale.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/r_videoscale.cpp b/src/r_videoscale.cpp index ff8e7eb286..752e34518a 100644 --- a/src/r_videoscale.cpp +++ b/src/r_videoscale.cpp @@ -99,3 +99,52 @@ bool ViewportIsScaled43() vid_scalemode = 0; return vScaleTable[vid_scalemode].isScaled43; } + +void R_ShowCurrentScaling() +{ + Printf("Current Scale: %f\n", (float)(vid_scalefactor)); +} + +bool R_CalcsShouldBeBlocked() +{ + if (vid_scalemode < 0 || vid_scalemode > 1) + { + Printf("vid_scalemode should be 0 or 1 before using this command.\n"); + return true; + } + return false; +} + +CCMD (vid_scaletowidth) +{ + float newscalefactor; + + if (R_CalcsShouldBeBlocked()) + return; + + if (argv.argc() > 1) + newscalefactor = (float)((double)vid_scalefactor * (double)atof(argv[1]) / (double)DisplayWidth); + else + newscalefactor = vid_scalefactor; + if ( newscalefactor > 2.0 || newscalefactor <= 0.0 ) + newscalefactor = 1.0; + vid_scalefactor = newscalefactor; + R_ShowCurrentScaling(); +} + +CCMD (vid_scaletoheight) +{ + float newscalefactor; + + if (R_CalcsShouldBeBlocked()) + return; + + if (argv.argc() > 1) + newscalefactor = (float)((double)vid_scalefactor * (double)atof(argv[1]) / (double)DisplayHeight); + else + newscalefactor = vid_scalefactor; + if ( newscalefactor > 2.0 || newscalefactor <= 0.0 ) + newscalefactor = 1.0; + vid_scalefactor = newscalefactor; + R_ShowCurrentScaling(); +}