mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-17 15:20:17 +01:00
Added integer scaling option.
Useful for getting exact upscale in combination with nearest neighbor. Ref issue #97.
This commit is contained in:
parent
64c3f2031b
commit
37198f1b99
4 changed files with 25 additions and 3 deletions
|
@ -116,17 +116,27 @@ void fullscrn::window_size_changed()
|
|||
ScaleX = static_cast<float>(width) / res->TableWidth;
|
||||
ScaleY = static_cast<float>(height) / res->TableHeight;
|
||||
OffsetX = OffsetY = 0;
|
||||
auto offset2X = 0, offset2Y = 0;
|
||||
|
||||
if (options::Options.IntegerScaling)
|
||||
{
|
||||
ScaleX = ScaleX < 1 ? ScaleX : std::floor(ScaleX);
|
||||
ScaleY = ScaleY < 1 ? ScaleY : std::floor(ScaleY);
|
||||
}
|
||||
|
||||
if (options::Options.UniformScaling)
|
||||
{
|
||||
ScaleY = ScaleX = std::min(ScaleX, ScaleY);
|
||||
OffsetX = static_cast<int>(floor((width - res->TableWidth * ScaleX) / 2));
|
||||
OffsetY = static_cast<int>(floor((height - res->TableHeight * ScaleY) / 2));
|
||||
}
|
||||
|
||||
offset2X = static_cast<int>(floor(width - res->TableWidth * ScaleX));
|
||||
offset2Y = static_cast<int>(floor(height - res->TableHeight * ScaleY));
|
||||
OffsetX = offset2X / 2;
|
||||
OffsetY = offset2Y / 2;
|
||||
|
||||
render::DestinationRect = SDL_Rect
|
||||
{
|
||||
OffsetX, OffsetY + menuHeight,
|
||||
width - OffsetX * 2, height - OffsetY * 2
|
||||
width - offset2X, height - offset2Y
|
||||
};
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ void options::InitPrimary()
|
|||
Options.SoundChannels = std::min(MaxSoundChannels, std::max(MinSoundChannels, Options.SoundChannels));
|
||||
Options.HybridSleep = get_int("HybridSleep", false);
|
||||
Options.Prefer3DPBGameData = get_int("Prefer 3DPB Game Data", false);
|
||||
Options.IntegerScaling = get_int("Integer Scaling", false);
|
||||
}
|
||||
|
||||
void options::InitSecondary()
|
||||
|
@ -137,6 +138,7 @@ void options::uninit()
|
|||
set_int("Sound Channels", Options.SoundChannels);
|
||||
set_int("HybridSleep", Options.HybridSleep);
|
||||
set_int("Prefer 3DPB Game Data", Options.Prefer3DPBGameData);
|
||||
set_int("Integer Scaling", Options.IntegerScaling);
|
||||
}
|
||||
|
||||
|
||||
|
@ -260,6 +262,10 @@ void options::toggle(Menu1 uIDCheckItem)
|
|||
Options.Prefer3DPBGameData ^= true;
|
||||
winmain::Restart();
|
||||
break;
|
||||
case Menu1::WindowIntegerScale:
|
||||
Options.IntegerScaling ^= true;
|
||||
fullscrn::window_size_changed();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ enum class Menu1:int
|
|||
R1024x768 = 503,
|
||||
WindowUniformScale = 600,
|
||||
WindowLinearFilter = 601,
|
||||
WindowIntegerScale = 602,
|
||||
Prefer3DPBGameData = 700,
|
||||
};
|
||||
|
||||
|
@ -76,6 +77,7 @@ struct optionsStruct
|
|||
int SoundChannels;
|
||||
bool HybridSleep;
|
||||
bool Prefer3DPBGameData;
|
||||
bool IntegerScaling;
|
||||
};
|
||||
|
||||
struct ControlRef
|
||||
|
|
|
@ -466,6 +466,10 @@ void winmain::RenderUi()
|
|||
{
|
||||
options::toggle(Menu1::WindowLinearFilter);
|
||||
}
|
||||
if (ImGui::MenuItem("Integer Scaling", nullptr, Options.IntegerScaling))
|
||||
{
|
||||
options::toggle(Menu1::WindowIntegerScale);
|
||||
}
|
||||
ImGui::DragFloat("UI Scale", &ImIO->FontGlobalScale, 0.005f, 0.8f, 5,
|
||||
"%.2f", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::Separator();
|
||||
|
|
Loading…
Reference in a new issue