Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support floating-point window scale values #133

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion d2dx-defaults.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

[window]
scale=1 # range 1-3, an integer scale factor for the window
scale=1 # range 1.0-3.0, a rational scale factor for the window
position=[-1,-1] # if [-1,-1] the window will be centered, otherwise placed at the explicit position given here
frameless=false # if true, the window frame (caption bar etc) will be removed

Expand Down
14 changes: 7 additions & 7 deletions src/d2dx/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ void Options::ApplyCfg(

if (window)
{
auto windowScale = toml_int_in(window, "scale");
auto windowScale = toml_double_in(window, "scale");
if (windowScale.ok)
{
SetWindowScale((int32_t)windowScale.u.i);
SetWindowScale(windowScale.u.d);
}

auto windowPosition = toml_array_in(window, "position");
Expand Down Expand Up @@ -164,8 +164,8 @@ void Options::ApplyCommandLine(
if (strstr(cmdLine, "-dxnotitlechange")) SetFlag(OptionsFlag::NoTitleChange, true);
if (strstr(cmdLine, "-dxnomop")) SetFlag(OptionsFlag::NoMotionPrediction, true);

if (strstr(cmdLine, "-dxscale3")) SetWindowScale(3);
else if (strstr(cmdLine, "-dxscale2")) SetWindowScale(2);
if (strstr(cmdLine, "-dxscale3")) SetWindowScale(3.0);
else if (strstr(cmdLine, "-dxscale2")) SetWindowScale(2.0);

if (strstr(cmdLine, "-dxdbg_dump_textures")) SetFlag(OptionsFlag::DbgDumpTextures, true);
}
Expand All @@ -190,15 +190,15 @@ void Options::SetFlag(
}
}

int32_t Options::GetWindowScale() const
double Options::GetWindowScale() const
{
return _windowScale;
}

void Options::SetWindowScale(
_In_ int32_t windowScale)
_In_ double windowScale)
{
_windowScale = min(3, max(1, windowScale));
_windowScale = min(3.0, max(1.0, windowScale));
}

Offset Options::GetWindowPosition() const
Expand Down
6 changes: 3 additions & 3 deletions src/d2dx/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ namespace d2dx
_In_ OptionsFlag flag,
_In_ bool value);

int32_t GetWindowScale() const;
double GetWindowScale() const;

void SetWindowScale(
_In_ int32_t zoomLevel);
_In_ double zoomLevel);

Offset GetWindowPosition() const;

Expand All @@ -88,7 +88,7 @@ namespace d2dx

private:
uint32_t _flags = 0;
int32_t _windowScale = 1;
double _windowScale = 1.0;
Offset _windowPosition{ -1, -1 };
Size _userSpecifiedGameSize{ -1, -1 };
FilteringOption _filtering{ FilteringOption::HighQuality };
Expand Down
5 changes: 5 additions & 0 deletions src/d2dx/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ namespace d2dx
int32_t width = 0;
int32_t height = 0;

Size operator*(double value) noexcept
{
return { (int32_t)(width * value), (int32_t)(height * value) };
}

Size operator*(int32_t value) noexcept
{
return { width * value, height * value };
Expand Down