diff --git a/DDrawCompat/Config/Config.cpp b/DDrawCompat/Config/Config.cpp index 115d9f7..275af31 100644 --- a/DDrawCompat/Config/Config.cpp +++ b/DDrawCompat/Config/Config.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +57,7 @@ namespace Config Settings::BltFilter bltFilter; Settings::ColorKeyMethod colorKeyMethod; Settings::ConfigHotKey configHotKey; + Settings::ConfigTransparency configTransparency; Settings::CpuAffinity cpuAffinity; Settings::CpuAffinityRotation cpuAffinityRotation; Settings::DepthFormat depthFormat; @@ -85,6 +88,7 @@ namespace Config Settings::StatsPosX statsPosX; Settings::StatsPosY statsPosY; Settings::StatsRows statsRows; + Settings::StatsTransparency statsTransparency; Settings::StatsUpdateRate statsUpdateRate; Settings::SupportedResolutions supportedResolutions; Settings::SupportedDepthFormats supportedDepthFormats; diff --git a/DDrawCompat/Config/Settings/ConfigTransparency.h b/DDrawCompat/Config/Settings/ConfigTransparency.h new file mode 100644 index 0000000..4d4777f --- /dev/null +++ b/DDrawCompat/Config/Settings/ConfigTransparency.h @@ -0,0 +1,34 @@ +#pragma once + +#pragma once + +#include + +namespace Config +{ + namespace Settings + { + class ConfigTransparency : public MappedSetting + { + public: + static const int ALPHA = -1; + + ConfigTransparency() + : MappedSetting("ConfigTransparency", "alpha(75)", { {"off", 100}, {"alpha", ALPHA} }) + { + } + + int get() const + { + return ALPHA == m_value ? m_param : m_value; + } + + virtual ParamInfo getParamInfo() const override + { + return ALPHA == m_value ? ParamInfo{ "Alpha", 25, 100, 75 } : ParamInfo{}; + } + }; + } + + extern Settings::ConfigTransparency configTransparency; +} diff --git a/DDrawCompat/Config/Settings/StatsTransparency.h b/DDrawCompat/Config/Settings/StatsTransparency.h new file mode 100644 index 0000000..51e1e76 --- /dev/null +++ b/DDrawCompat/Config/Settings/StatsTransparency.h @@ -0,0 +1,34 @@ +#pragma once + +#pragma once + +#include + +namespace Config +{ + namespace Settings + { + class StatsTransparency : public MappedSetting + { + public: + static const int ALPHA = -1; + + StatsTransparency() + : MappedSetting("StatsTransparency", "alpha(75)", { {"off", 100}, {"alpha", ALPHA} }) + { + } + + int get() const + { + return ALPHA == m_value ? m_param : m_value; + } + + virtual ParamInfo getParamInfo() const override + { + return ALPHA == m_value ? ParamInfo{ "Alpha", 25, 100, 75 } : ParamInfo{}; + } + }; + } + + extern Settings::StatsTransparency statsTransparency; +} diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index e36cf41..0ebbf85 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -170,6 +170,7 @@ + @@ -200,6 +201,7 @@ + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index 564efea..d5ba8d4 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -693,6 +693,12 @@ Header Files\Config\Settings + + Header Files\Config\Settings + + + Header Files\Config\Settings + diff --git a/DDrawCompat/Overlay/ComboBoxDropDown.cpp b/DDrawCompat/Overlay/ComboBoxDropDown.cpp index 0e6c529..191d78c 100644 --- a/DDrawCompat/Overlay/ComboBoxDropDown.cpp +++ b/DDrawCompat/Overlay/ComboBoxDropDown.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -8,7 +9,8 @@ namespace Overlay { ComboBoxDropDown::ComboBoxDropDown(ComboBoxControl& parent, const std::vector& values) - : Window(&static_cast(parent.getRoot()), calculateRect(parent, values.size()), WS_BORDER) + : Window(&static_cast(parent.getRoot()), calculateRect(parent, values.size()), WS_BORDER, + Config::configTransparency.get()) , m_parent(parent) { for (int i = 0; i < static_cast(values.size()); ++i) diff --git a/DDrawCompat/Overlay/ConfigWindow.cpp b/DDrawCompat/Overlay/ConfigWindow.cpp index 06d06c9..f71a4b9 100644 --- a/DDrawCompat/Overlay/ConfigWindow.cpp +++ b/DDrawCompat/Overlay/ConfigWindow.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -41,11 +43,12 @@ namespace const int ROW_HEIGHT = 25; const int ROWS = 15; - std::array g_settingRows = { { + std::array g_settingRows = { { { &Config::alternatePixelCenter }, { &Config::antialiasing, &D3dDdi::Device::updateAllConfig }, { &Config::bltFilter }, { &Config::colorKeyMethod, &D3dDdi::Device::updateAllConfig }, + { &Config::configTransparency, [&]() { Gdi::GuiThread::getConfigWindow()->setAlpha(Config::configTransparency.get()); }}, { &Config::depthFormat, &D3dDdi::Device::updateAllConfig }, { &Config::displayFilter }, { &Config::fontAntialiasing }, @@ -58,6 +61,7 @@ namespace { &Config::spriteTexCoord, &D3dDdi::Device::updateAllConfig }, { &Config::statsPosX, []() { Gdi::GuiThread::getStatsWindow()->updatePos(); } }, { &Config::statsPosY, []() { Gdi::GuiThread::getStatsWindow()->updatePos(); } }, + { &Config::statsTransparency, [&]() { Gdi::GuiThread::getStatsWindow()->setAlpha(Config::statsTransparency.get()); }}, { &Config::textureFilter, &D3dDdi::Device::updateAllConfig }, { &Config::vSync } } }; @@ -67,7 +71,7 @@ namespace Overlay { ConfigWindow::ConfigWindow() : Window(nullptr, { 0, 0, SettingControl::TOTAL_WIDTH + ARROW_SIZE + BORDER / 2, ROWS * ROW_HEIGHT + 80 }, - WS_BORDER, Config::configHotKey.get()) + WS_BORDER, Config::configTransparency.get(), Config::configHotKey.get()) , m_buttonCount(0) , m_focus(nullptr) { @@ -81,7 +85,7 @@ namespace Overlay r.top = CAPTION_HEIGHT + BORDER; r.right = r.left + ARROW_SIZE; r.bottom = r.top + ROWS * ROW_HEIGHT; - m_scrollBar.reset(new ScrollBarControl(*this, r, 0, g_settingRows.size() - ROWS)); + m_scrollBar.reset(new ScrollBarControl(*this, r, 0, g_settingRows.size() - ROWS, 0)); addSettingControls(); diff --git a/DDrawCompat/Overlay/ScrollBarControl.cpp b/DDrawCompat/Overlay/ScrollBarControl.cpp index 39840a8..6fc8ad3 100644 --- a/DDrawCompat/Overlay/ScrollBarControl.cpp +++ b/DDrawCompat/Overlay/ScrollBarControl.cpp @@ -19,11 +19,11 @@ namespace namespace Overlay { - ScrollBarControl::ScrollBarControl(Control& parent, const RECT& rect, int min, int max) + ScrollBarControl::ScrollBarControl(Control& parent, const RECT& rect, int min, int max, int pos) : Control(&parent, rect, WS_VISIBLE) , m_min(min) , m_max(std::max(min, max)) - , m_pos(min) + , m_pos(std::max(min, std::min(max, pos))) , m_state(State::IDLE) , m_left(isHorizontal() ? &RECT::left : &RECT::top) , m_top(isHorizontal() ? &RECT::top : &RECT::left) diff --git a/DDrawCompat/Overlay/ScrollBarControl.h b/DDrawCompat/Overlay/ScrollBarControl.h index d581e04..8c814bf 100644 --- a/DDrawCompat/Overlay/ScrollBarControl.h +++ b/DDrawCompat/Overlay/ScrollBarControl.h @@ -7,7 +7,7 @@ namespace Overlay class ScrollBarControl : public Control { public: - ScrollBarControl(Control& parent, const RECT& rect, int min, int max); + ScrollBarControl(Control& parent, const RECT& rect, int min, int max, int pos); virtual void onLButtonDown(POINT pos) override; virtual void onLButtonUp(POINT pos) override; diff --git a/DDrawCompat/Overlay/SettingControl.cpp b/DDrawCompat/Overlay/SettingControl.cpp index f4d7197..7434be8 100644 --- a/DDrawCompat/Overlay/SettingControl.cpp +++ b/DDrawCompat/Overlay/SettingControl.cpp @@ -128,7 +128,7 @@ namespace Overlay r.left = r.right; r.right = r.left + PARAM_CONTROL_WIDTH; - m_paramControl.reset(new ScrollBarControl(*this, r, paramInfo.min, paramInfo.max)); + m_paramControl.reset(new ScrollBarControl(*this, r, paramInfo.min, paramInfo.max, m_setting.getParam())); m_paramControl->setPos(m_setting.getParam()); } } diff --git a/DDrawCompat/Overlay/StatsWindow.cpp b/DDrawCompat/Overlay/StatsWindow.cpp index 5d1ed0f..649205a 100644 --- a/DDrawCompat/Overlay/StatsWindow.cpp +++ b/DDrawCompat/Overlay/StatsWindow.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,7 @@ namespace Overlay StatsWindow::StatsWindow() : Window(nullptr, { 0, 0, StatsControl::getWidth(), static_cast(Config::statsRows.get().size()) * ROW_HEIGHT + BORDER }, - 0, Config::statsHotKey.get()) + 0, Config::statsTransparency.get(), Config::statsHotKey.get()) { m_statsRows.push_back({ "", [](auto) { return std::array{ "cur", "avg", "min", "max" }; }, WS_VISIBLE | WS_DISABLED }); diff --git a/DDrawCompat/Overlay/Window.cpp b/DDrawCompat/Overlay/Window.cpp index 3983bd8..11d513d 100644 --- a/DDrawCompat/Overlay/Window.cpp +++ b/DDrawCompat/Overlay/Window.cpp @@ -43,11 +43,11 @@ namespace namespace Overlay { - Window::Window(Window* parentWindow, const RECT& rect, DWORD style, const Input::HotKey& hotKey) + Window::Window(Window* parentWindow, const RECT& rect, DWORD style, int alpha, const Input::HotKey& hotKey) : Control(nullptr, rect, style) , m_hwnd(Gdi::PresentationWindow::create(parentWindow ? parentWindow->m_hwnd : nullptr)) , m_parentWindow(parentWindow) - , m_transparency(25) + , m_alpha(alpha) , m_scaleFactor(1) , m_dc(CreateCompatibleDC(nullptr)) , m_bitmap(nullptr) @@ -56,7 +56,7 @@ namespace Overlay { g_windows.emplace(m_hwnd, *this); CALL_ORIG_FUNC(SetWindowLongA)(m_hwnd, GWL_WNDPROC, reinterpret_cast(&staticWindowProc)); - setTransparency(m_transparency); + setAlpha(alpha); if (0 != hotKey.vk) { @@ -108,10 +108,10 @@ namespace Overlay DDraw::RealPrimarySurface::scheduleOverlayUpdate(); } - void Window::setTransparency(int transparency) + void Window::setAlpha(int alpha) { - m_transparency = transparency; - CALL_ORIG_FUNC(SetLayeredWindowAttributes)(m_hwnd, 0, static_cast(100 - transparency) * 255 / 100, ULW_ALPHA); + m_alpha = alpha; + CALL_ORIG_FUNC(SetLayeredWindowAttributes)(m_hwnd, 0, static_cast(alpha * 255 / 100), ULW_ALPHA); } void Window::setVisible(bool isVisible) diff --git a/DDrawCompat/Overlay/Window.h b/DDrawCompat/Overlay/Window.h index a04524e..ad318f8 100644 --- a/DDrawCompat/Overlay/Window.h +++ b/DDrawCompat/Overlay/Window.h @@ -13,7 +13,7 @@ namespace Overlay class Window : public Control { public: - Window(Window* parentWindow, const RECT& rect, DWORD style, const Input::HotKey& hotKey = {}); + Window(Window* parentWindow, const RECT& rect, DWORD style, int alpha, const Input::HotKey& hotKey = {}); virtual ~Window() override; virtual RECT calculateRect(const RECT& monitorRect) const = 0; @@ -22,14 +22,14 @@ namespace Overlay int getScaleFactor() const { return m_scaleFactor; } HWND getWindow() const { return m_hwnd; } - void setTransparency(int transparency); + void setAlpha(int alpha); void update(); void updatePos(); protected: HWND m_hwnd; Window* m_parentWindow; - int m_transparency; + int m_alpha; virtual HWND getTopmost() const;