mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Add option to enable or disable auto-scale
This commit is contained in:
@@ -81,6 +81,14 @@
|
|||||||
"id" : 0,
|
"id" : 0,
|
||||||
"enabled" : true
|
"enabled" : true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name" : "Adjust resolution to fit window",
|
||||||
|
"itemType" : "CheckBox",
|
||||||
|
"pos" : [ 8, 182 ],
|
||||||
|
"size" : [ 256, 18 ],
|
||||||
|
"id" : 0,
|
||||||
|
"enabled" : true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name" : "",
|
"name" : "",
|
||||||
"itemType" : "UserItem",
|
"itemType" : "UserItem",
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
#define kDisplay12Inch 2
|
#define kDisplay12Inch 2
|
||||||
#define kDisplay13Inch 3
|
#define kDisplay13Inch 3
|
||||||
|
|
||||||
|
extern Boolean isAutoScale;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -327,15 +329,20 @@ public:
|
|||||||
if (physicalHeight < 480)
|
if (physicalHeight < 480)
|
||||||
physicalHeight = 480;
|
physicalHeight = 480;
|
||||||
|
|
||||||
double xMul = static_cast<double>(physicalWidth) / 640;
|
double minMul = 1.0;
|
||||||
double yMul = static_cast<double>(physicalHeight) / 480;
|
|
||||||
|
if (isAutoScale)
|
||||||
|
{
|
||||||
|
double xMul = static_cast<double>(physicalWidth) / 640.0;
|
||||||
|
double yMul = static_cast<double>(physicalHeight) / 480.0;
|
||||||
|
|
||||||
double granularity = 2.0;
|
double granularity = 2.0;
|
||||||
|
|
||||||
xMul = floor(xMul * granularity) / granularity;
|
xMul = floor(xMul * granularity) / granularity;
|
||||||
yMul = floor(yMul * granularity) / granularity;
|
yMul = floor(yMul * granularity) / granularity;
|
||||||
|
|
||||||
double minMul = std::max<double>(1.0, std::min(xMul, yMul));
|
minMul = std::max<double>(1.0, std::min(xMul, yMul));
|
||||||
|
}
|
||||||
|
|
||||||
virtualWidth = physicalWidth / minMul;
|
virtualWidth = physicalWidth / minMul;
|
||||||
virtualHeight = physicalHeight / minMul;
|
virtualHeight = physicalHeight / minMul;
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ typedef struct
|
|||||||
Boolean wasCoordOpen, wasQuickTrans;
|
Boolean wasCoordOpen, wasQuickTrans;
|
||||||
Boolean wasIdleMusic, wasGameMusic;
|
Boolean wasIdleMusic, wasGameMusic;
|
||||||
Boolean wasEscPauseKey;
|
Boolean wasEscPauseKey;
|
||||||
Boolean wasDoAutoDemo, wasScreen2;
|
Boolean wasDoAutoDemo, wasAutoScale;
|
||||||
Boolean wasDoBackground, wasHouseChecks;
|
Boolean wasDoBackground, wasHouseChecks;
|
||||||
Boolean wasPrettyMap, wasBitchDialogs;
|
Boolean wasPrettyMap, wasBitchDialogs;
|
||||||
} prefsInfo;
|
} prefsInfo;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ int main(int argc, const char **argv);
|
|||||||
|
|
||||||
short isVolume, wasVolume;
|
short isVolume, wasVolume;
|
||||||
short isDepthPref, dataResFile, numSMWarnings;
|
short isDepthPref, dataResFile, numSMWarnings;
|
||||||
Boolean quitting, doZooms, quickerTransitions, isUseSecondScreen;
|
Boolean quitting, doZooms, quickerTransitions, isAutoScale;
|
||||||
|
|
||||||
|
|
||||||
extern Str31 highBanner;
|
extern Str31 highBanner;
|
||||||
@@ -122,9 +122,7 @@ void ReadInPrefs (void)
|
|||||||
toolMode = thePrefs.wasToolGroup;
|
toolMode = thePrefs.wasToolGroup;
|
||||||
doAutoDemo = thePrefs.wasDoAutoDemo;
|
doAutoDemo = thePrefs.wasDoAutoDemo;
|
||||||
isEscPauseKey = thePrefs.wasEscPauseKey;
|
isEscPauseKey = thePrefs.wasEscPauseKey;
|
||||||
isUseSecondScreen = thePrefs.wasScreen2;
|
isAutoScale = thePrefs.wasAutoScale;
|
||||||
if (thisMac.numScreens < 2)
|
|
||||||
isUseSecondScreen = false;
|
|
||||||
doBackground = thePrefs.wasDoBackground;
|
doBackground = thePrefs.wasDoBackground;
|
||||||
doPrettyMap = thePrefs.wasPrettyMap;
|
doPrettyMap = thePrefs.wasPrettyMap;
|
||||||
doBitchDialogs = thePrefs.wasBitchDialogs;
|
doBitchDialogs = thePrefs.wasBitchDialogs;
|
||||||
@@ -199,7 +197,7 @@ void ReadInPrefs (void)
|
|||||||
toolMode = kBlowerMode;
|
toolMode = kBlowerMode;
|
||||||
doAutoDemo = true;
|
doAutoDemo = true;
|
||||||
isEscPauseKey = false;
|
isEscPauseKey = false;
|
||||||
isUseSecondScreen = false;
|
isAutoScale = true;
|
||||||
doBackground = false;
|
doBackground = false;
|
||||||
doPrettyMap = false;
|
doPrettyMap = false;
|
||||||
doBitchDialogs = true;
|
doBitchDialogs = true;
|
||||||
@@ -291,7 +289,7 @@ void WriteOutPrefs (void)
|
|||||||
thePrefs.wasToolGroup = toolMode;
|
thePrefs.wasToolGroup = toolMode;
|
||||||
thePrefs.wasDoAutoDemo = doAutoDemo;
|
thePrefs.wasDoAutoDemo = doAutoDemo;
|
||||||
thePrefs.wasEscPauseKey = isEscPauseKey;
|
thePrefs.wasEscPauseKey = isEscPauseKey;
|
||||||
thePrefs.wasScreen2 = isUseSecondScreen;
|
thePrefs.wasAutoScale = isAutoScale;
|
||||||
thePrefs.wasDoBackground = doBackground;
|
thePrefs.wasDoBackground = doBackground;
|
||||||
thePrefs.wasPrettyMap = doPrettyMap;
|
thePrefs.wasPrettyMap = doPrettyMap;
|
||||||
thePrefs.wasBitchDialogs = doBitchDialogs;
|
thePrefs.wasBitchDialogs = doBitchDialogs;
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
#include "DialogUtils.h"
|
#include "DialogUtils.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
|
#include "HostDisplayDriver.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
|
#include "IGpDisplayDriver.h"
|
||||||
#include "WindowManager.h"
|
#include "WindowManager.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -35,13 +37,10 @@
|
|||||||
#define kBorder1Item 8
|
#define kBorder1Item 8
|
||||||
#define kDoColorFadeItem 9
|
#define kDoColorFadeItem 9
|
||||||
#define k32BitColorItem 10
|
#define k32BitColorItem 10
|
||||||
//#define k256Depth 11
|
#define kScaleResolutionItem 11
|
||||||
//#define k16Depth 12
|
#define kBorder2Item 12
|
||||||
#define kBorder2Item 11
|
#define kBorder3Item 13
|
||||||
#define kBorder3Item 12
|
#define kDispDefault 14
|
||||||
#define kDispDefault 13
|
|
||||||
//#define kUseQDItem 13
|
|
||||||
//#define kUseScreen2Item 14
|
|
||||||
#define kSofterItem 4
|
#define kSofterItem 4
|
||||||
#define kLouderItem 5
|
#define kLouderItem 5
|
||||||
#define kVolNumberItem 7
|
#define kVolNumberItem 7
|
||||||
@@ -98,11 +97,11 @@ Str15 tempLeftStr, tempRightStr, tempBattStr, tempBandStr;
|
|||||||
long tempLeftMap, tempRightMap, tempBattMap, tempBandMap;
|
long tempLeftMap, tempRightMap, tempBattMap, tempBandMap;
|
||||||
short whichCtrl, wasDepthPref;
|
short whichCtrl, wasDepthPref;
|
||||||
Boolean wasFade, wasIdle, wasPlay, wasTransit, wasZooms, wasBackground;
|
Boolean wasFade, wasIdle, wasPlay, wasTransit, wasZooms, wasBackground;
|
||||||
Boolean wasEscPauseKey, wasDemos, wasScreen2, nextRestartChange, wasErrorCheck;
|
Boolean wasEscPauseKey, wasDemos, wasAutoScale, nextRestartChange, wasErrorCheck, needResolutionReset;
|
||||||
Boolean wasPrettyMap, wasBitchDialogs;
|
Boolean wasPrettyMap, wasBitchDialogs;
|
||||||
|
|
||||||
extern short numNeighbors, isDepthPref, maxFiles, willMaxFiles;
|
extern short numNeighbors, isDepthPref, maxFiles, willMaxFiles;
|
||||||
extern Boolean isDoColorFade, isPlayMusicIdle, isUseSecondScreen;
|
extern Boolean isDoColorFade, isPlayMusicIdle, isAutoScale;
|
||||||
extern Boolean isHouseChecks, doBitchDialogs;
|
extern Boolean isHouseChecks, doBitchDialogs;
|
||||||
extern Boolean isEscPauseKey, failedMusic, isSoundOn, doBackground;
|
extern Boolean isEscPauseKey, failedMusic, isSoundOn, doBackground;
|
||||||
extern Boolean isMusicOn, quickerTransitions, doAutoDemo;
|
extern Boolean isMusicOn, quickerTransitions, doAutoDemo;
|
||||||
@@ -862,7 +861,7 @@ void DisplayDefaults (void)
|
|||||||
numNeighbors = 9;
|
numNeighbors = 9;
|
||||||
wasDepthPref = kSwitchIfNeeded;
|
wasDepthPref = kSwitchIfNeeded;
|
||||||
wasFade = true;
|
wasFade = true;
|
||||||
wasScreen2 = false;
|
wasAutoScale = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- FrameDisplayIcon
|
//-------------------------------------------------------------- FrameDisplayIcon
|
||||||
@@ -907,6 +906,7 @@ void DisplayUpdate (Dialog *theDialog)
|
|||||||
|
|
||||||
SetDialogItemValue(theDialog, kDoColorFadeItem, (short)wasFade);
|
SetDialogItemValue(theDialog, kDoColorFadeItem, (short)wasFade);
|
||||||
SetDialogItemValue(theDialog, k32BitColorItem, wasDepthPref == 32);
|
SetDialogItemValue(theDialog, k32BitColorItem, wasDepthPref == 32);
|
||||||
|
SetDialogItemValue(theDialog, kScaleResolutionItem, (short)isAutoScale);
|
||||||
|
|
||||||
FrameDisplayIcon(theDialog, StdColors::Red());
|
FrameDisplayIcon(theDialog, StdColors::Red());
|
||||||
FrameDialogItemC(theDialog, kBorder1Item, kRedOrangeColor8);
|
FrameDialogItemC(theDialog, kBorder1Item, kRedOrangeColor8);
|
||||||
@@ -1005,7 +1005,7 @@ void DoDisplayPrefs (void)
|
|||||||
wasNeighbors = numNeighbors;
|
wasNeighbors = numNeighbors;
|
||||||
wasFade = isDoColorFade;
|
wasFade = isDoColorFade;
|
||||||
wasDepthPref = isDepthPref;
|
wasDepthPref = isDepthPref;
|
||||||
wasScreen2 = isUseSecondScreen;
|
wasAutoScale = isAutoScale;
|
||||||
leaving = false;
|
leaving = false;
|
||||||
|
|
||||||
DisplayUpdate(prefDlg);
|
DisplayUpdate(prefDlg);
|
||||||
@@ -1017,10 +1017,12 @@ void DoDisplayPrefs (void)
|
|||||||
{
|
{
|
||||||
case kOkayButton:
|
case kOkayButton:
|
||||||
isDoColorFade = wasFade;
|
isDoColorFade = wasFade;
|
||||||
isDepthPref = wasDepthPref;
|
if (isDepthPref != wasDepthPref)
|
||||||
if (isUseSecondScreen != wasScreen2)
|
|
||||||
nextRestartChange = true;
|
nextRestartChange = true;
|
||||||
isUseSecondScreen = wasScreen2;
|
if (isAutoScale != wasAutoScale)
|
||||||
|
needResolutionReset = true;
|
||||||
|
isDepthPref = wasDepthPref;
|
||||||
|
isAutoScale = wasAutoScale;
|
||||||
leaving = true;
|
leaving = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1066,6 +1068,11 @@ void DoDisplayPrefs (void)
|
|||||||
SetDialogItemValue(prefDlg, k32BitColorItem, wasDepthPref == 32);
|
SetDialogItemValue(prefDlg, k32BitColorItem, wasDepthPref == 32);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kScaleResolutionItem:
|
||||||
|
wasAutoScale = !wasAutoScale;
|
||||||
|
SetDialogItemValue(prefDlg, kScaleResolutionItem, (short)wasAutoScale);
|
||||||
|
break;
|
||||||
|
|
||||||
case kDispDefault:
|
case kDispDefault:
|
||||||
FrameDisplayIcon(prefDlg, StdColors::White());
|
FrameDisplayIcon(prefDlg, StdColors::White());
|
||||||
DisplayDefaults();
|
DisplayDefaults();
|
||||||
@@ -1126,6 +1133,8 @@ void SetAllDefaults (void)
|
|||||||
quickerTransitions = false;
|
quickerTransitions = false;
|
||||||
isDepthPref = kSwitchIfNeeded;
|
isDepthPref = kSwitchIfNeeded;
|
||||||
isDoColorFade = true;
|
isDoColorFade = true;
|
||||||
|
|
||||||
|
needResolutionReset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- FlashSettingsButton
|
//-------------------------------------------------------------- FlashSettingsButton
|
||||||
@@ -1307,7 +1316,16 @@ void DoSettingsMain (void)
|
|||||||
prefDlg->Destroy();
|
prefDlg->Destroy();
|
||||||
|
|
||||||
if (nextRestartChange)
|
if (nextRestartChange)
|
||||||
|
{
|
||||||
BitchAboutChanges();
|
BitchAboutChanges();
|
||||||
|
nextRestartChange = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needResolutionReset)
|
||||||
|
{
|
||||||
|
PortabilityLayer::HostDisplayDriver::GetInstance()->RequestResetVirtualResolution();
|
||||||
|
needResolutionReset = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- BitchAboutChanges
|
//-------------------------------------------------------------- BitchAboutChanges
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public:
|
|||||||
virtual void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) = 0;
|
virtual void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) = 0;
|
||||||
|
|
||||||
virtual void RequestToggleFullScreen(uint32_t timestamp) = 0;
|
virtual void RequestToggleFullScreen(uint32_t timestamp) = 0;
|
||||||
|
virtual void RequestResetVirtualResolution() = 0;
|
||||||
|
|
||||||
virtual const GpDisplayDriverProperties &GetProperties() const = 0;
|
virtual const GpDisplayDriverProperties &GetProperties() const = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1152,7 +1152,7 @@ void GpDisplayDriverD3D11::Run()
|
|||||||
|
|
||||||
unsigned int desiredWidth = clientRect.right - clientRect.left;
|
unsigned int desiredWidth = clientRect.right - clientRect.left;
|
||||||
unsigned int desiredHeight = clientRect.bottom - clientRect.top;
|
unsigned int desiredHeight = clientRect.bottom - clientRect.top;
|
||||||
if (clientRect.right - clientRect.left != m_windowWidthPhysical || clientRect.bottom - clientRect.top != m_windowHeightPhysical)
|
if (clientRect.right - clientRect.left != m_windowWidthPhysical || clientRect.bottom - clientRect.top != m_windowHeightPhysical || m_isResolutionResetDesired)
|
||||||
{
|
{
|
||||||
uint32_t prevWidthPhysical = m_windowWidthPhysical;
|
uint32_t prevWidthPhysical = m_windowWidthPhysical;
|
||||||
uint32_t prevHeightPhysical = m_windowHeightPhysical;
|
uint32_t prevHeightPhysical = m_windowHeightPhysical;
|
||||||
@@ -1177,6 +1177,7 @@ void GpDisplayDriverD3D11::Run()
|
|||||||
m_windowHeightVirtual = virtualHeight;
|
m_windowHeightVirtual = virtualHeight;
|
||||||
m_pixelScaleX = pixelScaleX;
|
m_pixelScaleX = pixelScaleX;
|
||||||
m_pixelScaleY = pixelScaleY;
|
m_pixelScaleY = pixelScaleY;
|
||||||
|
m_isResolutionResetDesired = false;
|
||||||
|
|
||||||
if (GpVOSEvent *resizeEvent = m_properties.m_eventQueue->QueueEvent())
|
if (GpVOSEvent *resizeEvent = m_properties.m_eventQueue->QueueEvent())
|
||||||
{
|
{
|
||||||
@@ -1422,6 +1423,11 @@ void GpDisplayDriverD3D11::RequestToggleFullScreen(uint32_t timestamp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GpDisplayDriverD3D11::RequestResetVirtualResolution()
|
||||||
|
{
|
||||||
|
m_isResolutionResetDesired = true;
|
||||||
|
}
|
||||||
|
|
||||||
const GpDisplayDriverProperties &GpDisplayDriverD3D11::GetProperties() const
|
const GpDisplayDriverProperties &GpDisplayDriverD3D11::GetProperties() const
|
||||||
{
|
{
|
||||||
return m_properties;
|
return m_properties;
|
||||||
@@ -1454,6 +1460,7 @@ GpDisplayDriverD3D11::GpDisplayDriverD3D11(const GpDisplayDriverProperties &prop
|
|||||||
, m_mouseIsInClientArea(false)
|
, m_mouseIsInClientArea(false)
|
||||||
, m_isFullScreen(false)
|
, m_isFullScreen(false)
|
||||||
, m_isFullScreenDesired(false)
|
, m_isFullScreenDesired(false)
|
||||||
|
, m_isResolutionResetDesired(false)
|
||||||
, m_lastFullScreenToggleTimeStamp(0)
|
, m_lastFullScreenToggleTimeStamp(0)
|
||||||
{
|
{
|
||||||
memset(&m_syncTimeBase, 0, sizeof(m_syncTimeBase));
|
memset(&m_syncTimeBase, 0, sizeof(m_syncTimeBase));
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public:
|
|||||||
void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) override;
|
void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) override;
|
||||||
|
|
||||||
void RequestToggleFullScreen(uint32_t timestamp) override;
|
void RequestToggleFullScreen(uint32_t timestamp) override;
|
||||||
|
void RequestResetVirtualResolution() override;
|
||||||
|
|
||||||
const GpDisplayDriverProperties &GetProperties() const override;
|
const GpDisplayDriverProperties &GetProperties() const override;
|
||||||
|
|
||||||
@@ -146,6 +147,7 @@ private:
|
|||||||
|
|
||||||
bool m_isFullScreen;
|
bool m_isFullScreen;
|
||||||
bool m_isFullScreenDesired;
|
bool m_isFullScreenDesired;
|
||||||
|
bool m_isResolutionResetDesired;
|
||||||
RECT m_windowModeRevertRect;
|
RECT m_windowModeRevertRect;
|
||||||
uint32_t m_lastFullScreenToggleTimeStamp;
|
uint32_t m_lastFullScreenToggleTimeStamp;
|
||||||
|
|
||||||
@@ -154,7 +156,7 @@ private:
|
|||||||
|
|
||||||
DWORD m_windowWidthPhysical; // Physical resolution is the resolution of the actual window
|
DWORD m_windowWidthPhysical; // Physical resolution is the resolution of the actual window
|
||||||
DWORD m_windowHeightPhysical;
|
DWORD m_windowHeightPhysical;
|
||||||
DWORD m_windowWidthVirtual; // Virtual resolution is the resolution reported to teh game
|
DWORD m_windowWidthVirtual; // Virtual resolution is the resolution reported to the game
|
||||||
DWORD m_windowHeightVirtual;
|
DWORD m_windowHeightVirtual;
|
||||||
float m_pixelScaleX;
|
float m_pixelScaleX;
|
||||||
float m_pixelScaleY;
|
float m_pixelScaleY;
|
||||||
|
|||||||
Reference in New Issue
Block a user