Add option to enable or disable auto-scale

This commit is contained in:
elasota
2020-06-20 01:33:26 -04:00
parent 1981320afe
commit 3c662845b4
8 changed files with 70 additions and 29 deletions

View File

@@ -31,6 +31,8 @@
#define kDisplay12Inch 2
#define kDisplay13Inch 3
extern Boolean isAutoScale;
typedef struct
{
@@ -327,15 +329,20 @@ public:
if (physicalHeight < 480)
physicalHeight = 480;
double xMul = static_cast<double>(physicalWidth) / 640;
double yMul = static_cast<double>(physicalHeight) / 480;
double minMul = 1.0;
double granularity = 2.0;
if (isAutoScale)
{
double xMul = static_cast<double>(physicalWidth) / 640.0;
double yMul = static_cast<double>(physicalHeight) / 480.0;
xMul = floor(xMul * granularity) / granularity;
yMul = floor(yMul * granularity) / granularity;
double granularity = 2.0;
double minMul = std::max<double>(1.0, std::min(xMul, yMul));
xMul = floor(xMul * granularity) / granularity;
yMul = floor(yMul * granularity) / granularity;
minMul = std::max<double>(1.0, std::min(xMul, yMul));
}
virtualWidth = physicalWidth / minMul;
virtualHeight = physicalHeight / minMul;

View File

@@ -116,7 +116,7 @@ typedef struct
Boolean wasCoordOpen, wasQuickTrans;
Boolean wasIdleMusic, wasGameMusic;
Boolean wasEscPauseKey;
Boolean wasDoAutoDemo, wasScreen2;
Boolean wasDoAutoDemo, wasAutoScale;
Boolean wasDoBackground, wasHouseChecks;
Boolean wasPrettyMap, wasBitchDialogs;
} prefsInfo;

View File

@@ -25,7 +25,7 @@ int main(int argc, const char **argv);
short isVolume, wasVolume;
short isDepthPref, dataResFile, numSMWarnings;
Boolean quitting, doZooms, quickerTransitions, isUseSecondScreen;
Boolean quitting, doZooms, quickerTransitions, isAutoScale;
extern Str31 highBanner;
@@ -122,9 +122,7 @@ void ReadInPrefs (void)
toolMode = thePrefs.wasToolGroup;
doAutoDemo = thePrefs.wasDoAutoDemo;
isEscPauseKey = thePrefs.wasEscPauseKey;
isUseSecondScreen = thePrefs.wasScreen2;
if (thisMac.numScreens < 2)
isUseSecondScreen = false;
isAutoScale = thePrefs.wasAutoScale;
doBackground = thePrefs.wasDoBackground;
doPrettyMap = thePrefs.wasPrettyMap;
doBitchDialogs = thePrefs.wasBitchDialogs;
@@ -199,7 +197,7 @@ void ReadInPrefs (void)
toolMode = kBlowerMode;
doAutoDemo = true;
isEscPauseKey = false;
isUseSecondScreen = false;
isAutoScale = true;
doBackground = false;
doPrettyMap = false;
doBitchDialogs = true;
@@ -291,7 +289,7 @@ void WriteOutPrefs (void)
thePrefs.wasToolGroup = toolMode;
thePrefs.wasDoAutoDemo = doAutoDemo;
thePrefs.wasEscPauseKey = isEscPauseKey;
thePrefs.wasScreen2 = isUseSecondScreen;
thePrefs.wasAutoScale = isAutoScale;
thePrefs.wasDoBackground = doBackground;
thePrefs.wasPrettyMap = doPrettyMap;
thePrefs.wasBitchDialogs = doBitchDialogs;

View File

@@ -16,7 +16,9 @@
#include "DialogUtils.h"
#include "Externs.h"
#include "Environ.h"
#include "HostDisplayDriver.h"
#include "House.h"
#include "IGpDisplayDriver.h"
#include "WindowManager.h"
@@ -35,13 +37,10 @@
#define kBorder1Item 8
#define kDoColorFadeItem 9
#define k32BitColorItem 10
//#define k256Depth 11
//#define k16Depth 12
#define kBorder2Item 11
#define kBorder3Item 12
#define kDispDefault 13
//#define kUseQDItem 13
//#define kUseScreen2Item 14
#define kScaleResolutionItem 11
#define kBorder2Item 12
#define kBorder3Item 13
#define kDispDefault 14
#define kSofterItem 4
#define kLouderItem 5
#define kVolNumberItem 7
@@ -98,11 +97,11 @@ Str15 tempLeftStr, tempRightStr, tempBattStr, tempBandStr;
long tempLeftMap, tempRightMap, tempBattMap, tempBandMap;
short whichCtrl, wasDepthPref;
Boolean wasFade, wasIdle, wasPlay, wasTransit, wasZooms, wasBackground;
Boolean wasEscPauseKey, wasDemos, wasScreen2, nextRestartChange, wasErrorCheck;
Boolean wasEscPauseKey, wasDemos, wasAutoScale, nextRestartChange, wasErrorCheck, needResolutionReset;
Boolean wasPrettyMap, wasBitchDialogs;
extern short numNeighbors, isDepthPref, maxFiles, willMaxFiles;
extern Boolean isDoColorFade, isPlayMusicIdle, isUseSecondScreen;
extern Boolean isDoColorFade, isPlayMusicIdle, isAutoScale;
extern Boolean isHouseChecks, doBitchDialogs;
extern Boolean isEscPauseKey, failedMusic, isSoundOn, doBackground;
extern Boolean isMusicOn, quickerTransitions, doAutoDemo;
@@ -862,7 +861,7 @@ void DisplayDefaults (void)
numNeighbors = 9;
wasDepthPref = kSwitchIfNeeded;
wasFade = true;
wasScreen2 = false;
wasAutoScale = true;
}
//-------------------------------------------------------------- FrameDisplayIcon
@@ -907,6 +906,7 @@ void DisplayUpdate (Dialog *theDialog)
SetDialogItemValue(theDialog, kDoColorFadeItem, (short)wasFade);
SetDialogItemValue(theDialog, k32BitColorItem, wasDepthPref == 32);
SetDialogItemValue(theDialog, kScaleResolutionItem, (short)isAutoScale);
FrameDisplayIcon(theDialog, StdColors::Red());
FrameDialogItemC(theDialog, kBorder1Item, kRedOrangeColor8);
@@ -1005,7 +1005,7 @@ void DoDisplayPrefs (void)
wasNeighbors = numNeighbors;
wasFade = isDoColorFade;
wasDepthPref = isDepthPref;
wasScreen2 = isUseSecondScreen;
wasAutoScale = isAutoScale;
leaving = false;
DisplayUpdate(prefDlg);
@@ -1017,10 +1017,12 @@ void DoDisplayPrefs (void)
{
case kOkayButton:
isDoColorFade = wasFade;
isDepthPref = wasDepthPref;
if (isUseSecondScreen != wasScreen2)
if (isDepthPref != wasDepthPref)
nextRestartChange = true;
isUseSecondScreen = wasScreen2;
if (isAutoScale != wasAutoScale)
needResolutionReset = true;
isDepthPref = wasDepthPref;
isAutoScale = wasAutoScale;
leaving = true;
break;
@@ -1066,6 +1068,11 @@ void DoDisplayPrefs (void)
SetDialogItemValue(prefDlg, k32BitColorItem, wasDepthPref == 32);
break;
case kScaleResolutionItem:
wasAutoScale = !wasAutoScale;
SetDialogItemValue(prefDlg, kScaleResolutionItem, (short)wasAutoScale);
break;
case kDispDefault:
FrameDisplayIcon(prefDlg, StdColors::White());
DisplayDefaults();
@@ -1126,6 +1133,8 @@ void SetAllDefaults (void)
quickerTransitions = false;
isDepthPref = kSwitchIfNeeded;
isDoColorFade = true;
needResolutionReset = true;
}
//-------------------------------------------------------------- FlashSettingsButton
@@ -1307,7 +1316,16 @@ void DoSettingsMain (void)
prefDlg->Destroy();
if (nextRestartChange)
{
BitchAboutChanges();
nextRestartChange = false;
}
if (needResolutionReset)
{
PortabilityLayer::HostDisplayDriver::GetInstance()->RequestResetVirtualResolution();
needResolutionReset = false;
}
}
//-------------------------------------------------------------- BitchAboutChanges