From 38ad868214aea3a066948b23a8bec70303d0789f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 28 Jan 2020 13:57:56 +0100 Subject: [PATCH] [hud] Add parameter to allow placing HUD items --- src/d3d9/d3d9_swapchain.cpp | 2 +- src/dxvk/hud/dxvk_hud.cpp | 20 ++++++++++---------- src/dxvk/hud/dxvk_hud.h | 4 ++-- src/dxvk/hud/dxvk_hud_item.h | 12 +++++++++--- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index e30d0153..c307c1c2 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -1024,7 +1024,7 @@ namespace dxvk { m_hud = hud::Hud::createHud(m_device); if (m_hud != nullptr) - m_hud->addItem("samplers", m_parent); + m_hud->addItem("samplers", -1, m_parent); } diff --git a/src/dxvk/hud/dxvk_hud.cpp b/src/dxvk/hud/dxvk_hud.cpp index 6576c504..cdf8ddee 100644 --- a/src/dxvk/hud/dxvk_hud.cpp +++ b/src/dxvk/hud/dxvk_hud.cpp @@ -29,16 +29,16 @@ namespace dxvk::hud { | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; - addItem("version"); - addItem("devinfo", m_device); - addItem("fps"); - addItem("frametimes"); - addItem("submissions", device); - addItem("drawcalls", device); - addItem("pipelines", device); - addItem("memory", device); - addItem("gpuload", device); - addItem("compiler", device); + addItem("version", -1); + addItem("devinfo", -1, m_device); + addItem("fps", -1); + addItem("frametimes", -1); + addItem("submissions", -1, device); + addItem("drawcalls", -1, device); + addItem("pipelines", -1, device); + addItem("memory", -1, device); + addItem("gpuload", -1, device); + addItem("compiler", -1, device); } diff --git a/src/dxvk/hud/dxvk_hud.h b/src/dxvk/hud/dxvk_hud.h index f70fda0c..3dc1b6f7 100644 --- a/src/dxvk/hud/dxvk_hud.h +++ b/src/dxvk/hud/dxvk_hud.h @@ -57,8 +57,8 @@ namespace dxvk::hud { * \param [in] args Constructor arguments */ template - void addItem(const char* name, Args... args) { - m_hudItems.add(name, std::forward(args)...); + void addItem(const char* name, int32_t at, Args... args) { + m_hudItems.add(name, at, std::forward(args)...); } /** diff --git a/src/dxvk/hud/dxvk_hud_item.h b/src/dxvk/hud/dxvk_hud_item.h index 8a773755..d71af880 100644 --- a/src/dxvk/hud/dxvk_hud_item.h +++ b/src/dxvk/hud/dxvk_hud_item.h @@ -76,10 +76,11 @@ namespace dxvk::hud { * * \tparam T The HUD item type * \param [in] name HUD item name + * \param [in] at Position at which to insert the item * \param [in] args Constructor arguments */ template - void add(const char* name, Args... args) { + void add(const char* name, int32_t at, Args... args) { bool enable = m_enableFull; if (!enable) { @@ -87,8 +88,13 @@ namespace dxvk::hud { enable = entry != m_enabled.end(); } - if (enable) - m_items.push_back(new T(std::forward(args)...)); + if (at < 0 || at > int32_t(m_items.size())) + at = m_items.size(); + + if (enable) { + m_items.insert(m_items.begin() + at, + new T(std::forward(args)...)); + } } private: