mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-10-30 07:11:05 +00:00
reddog: window improvements, added "welcome" message
This commit is contained in:
parent
72a0a17e3a
commit
4ab26a1696
9 changed files with 179 additions and 62 deletions
|
|
@ -167,6 +167,7 @@ set(SWA_UI_CXX_SOURCES
|
||||||
"ui/reddog/windows/counter_window.cpp"
|
"ui/reddog/windows/counter_window.cpp"
|
||||||
"ui/reddog/windows/exports_window.cpp"
|
"ui/reddog/windows/exports_window.cpp"
|
||||||
"ui/reddog/windows/view_window.cpp"
|
"ui/reddog/windows/view_window.cpp"
|
||||||
|
"ui/reddog/windows/welcome_window.cpp"
|
||||||
"ui/reddog/windows/window_list.cpp"
|
"ui/reddog/windows/window_list.cpp"
|
||||||
"ui/reddog/reddog_controls.cpp"
|
"ui/reddog/reddog_controls.cpp"
|
||||||
"ui/reddog/reddog_manager.cpp"
|
"ui/reddog/reddog_manager.cpp"
|
||||||
|
|
|
||||||
|
|
@ -231,85 +231,121 @@ void Reddog::Window::DrawFrame()
|
||||||
|
|
||||||
drawList->AddText({ cmnIconMax.x + 5, windowPos.y + 4 }, colTitleText, Name);
|
drawList->AddText({ cmnIconMax.x + 5, windowPos.y + 4 }, colTitleText, Name);
|
||||||
|
|
||||||
ImVec2 closeButtonMin = { windowPos.x + windowSize.x - cmnSize - 4, windowPos.y + 3 };
|
float controlsWidth = 0;
|
||||||
|
float controlsMargin = 4;
|
||||||
|
|
||||||
|
ImVec2 closeButtonMin = { windowPos.x + windowSize.x - cmnSize - controlsMargin, windowPos.y + 3 };
|
||||||
ImVec2 closeButtonMax = { closeButtonMin.x + cmnSize, closeButtonMin.y + cmnSize };
|
ImVec2 closeButtonMax = { closeButtonMin.x + cmnSize, closeButtonMin.y + cmnSize };
|
||||||
|
|
||||||
ImGui::SetCursorScreenPos(closeButtonMin);
|
if (IsCloseVisible)
|
||||||
ImGui::InvisibleButton("##CloseButton", { cmnSize, cmnSize });
|
|
||||||
bool isCloseButtonActive = ImGui::IsItemActive();
|
|
||||||
|
|
||||||
if (isCloseButtonActive)
|
|
||||||
{
|
{
|
||||||
drawList->AddImage(g_upButtonClose2.get(), closeButtonMin, closeButtonMax);
|
controlsWidth += closeButtonMax.x - closeButtonMin.x + controlsMargin;
|
||||||
m_isCloseButtonPressed = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
drawList->AddImage(g_upButtonClose1.get(), closeButtonMin, closeButtonMax);
|
|
||||||
|
|
||||||
if (m_isCloseButtonPressed && m_pIsVisible)
|
ImGui::SetCursorScreenPos(closeButtonMin);
|
||||||
|
ImGui::InvisibleButton("##CloseButton", { cmnSize, cmnSize });
|
||||||
|
bool isCloseButtonActive = ImGui::IsItemActive();
|
||||||
|
|
||||||
|
if (isCloseButtonActive)
|
||||||
{
|
{
|
||||||
*m_pIsVisible = !*m_pIsVisible;
|
drawList->AddImage(g_upButtonClose2.get(), closeButtonMin, closeButtonMax);
|
||||||
m_isCloseButtonPressed = false;
|
m_isCloseButtonPressed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
drawList->AddImage(g_upButtonClose1.get(), closeButtonMin, closeButtonMax);
|
||||||
|
|
||||||
|
if (m_isCloseButtonPressed && m_pIsVisible)
|
||||||
|
{
|
||||||
|
*m_pIsVisible = !*m_pIsVisible;
|
||||||
|
m_isCloseButtonPressed = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 minimumButtonMin = { closeButtonMin.x - cmnSize - 4, windowPos.y + 3 };
|
ImVec2 minimumButtonMin = { closeButtonMin.x - cmnSize - controlsMargin, windowPos.y + 3 };
|
||||||
ImVec2 minimumButtonMax = { minimumButtonMin.x + cmnSize, minimumButtonMin.y + cmnSize };
|
ImVec2 minimumButtonMax = { minimumButtonMin.x + cmnSize, minimumButtonMin.y + cmnSize };
|
||||||
|
|
||||||
ImGui::SetCursorScreenPos(minimumButtonMin);
|
if (IsMinimumVisible)
|
||||||
ImGui::InvisibleButton("##MinimumButton", { cmnSize, cmnSize });
|
|
||||||
bool isMinimumButtonActive = ImGui::IsItemActive();
|
|
||||||
|
|
||||||
if (isMinimumButtonActive)
|
|
||||||
{
|
{
|
||||||
drawList->AddImage(g_upButtonMinimum2.get(), minimumButtonMin, minimumButtonMax);
|
controlsWidth += minimumButtonMax.x - minimumButtonMin.x + controlsMargin;
|
||||||
m_isMinimumButtonPressed = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
drawList->AddImage(g_upButtonMinimum1.get(), minimumButtonMin, minimumButtonMax);
|
|
||||||
|
|
||||||
if (m_isMinimumButtonPressed)
|
ImGui::SetCursorScreenPos(minimumButtonMin);
|
||||||
|
ImGui::InvisibleButton("##MinimumButton", { cmnSize, cmnSize });
|
||||||
|
bool isMinimumButtonActive = ImGui::IsItemActive();
|
||||||
|
|
||||||
|
if (isMinimumButtonActive)
|
||||||
{
|
{
|
||||||
IsMinimum = !IsMinimum;
|
drawList->AddImage(g_upButtonMinimum2.get(), minimumButtonMin, minimumButtonMax);
|
||||||
|
m_isMinimumButtonPressed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
drawList->AddImage(g_upButtonMinimum1.get(), minimumButtonMin, minimumButtonMax);
|
||||||
|
|
||||||
if (IsMinimum)
|
if (m_isMinimumButtonPressed)
|
||||||
{
|
{
|
||||||
m_preMinimumWindowSize = windowSize;
|
SetMinimum(!IsMinimum);
|
||||||
ImGui::SetWindowSize(ImWindow, { windowSize.x, MIN_WINDOW_SIZE });
|
m_isMinimumButtonPressed = false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ImGui::SetWindowSize(ImWindow, { windowSize.x, m_preMinimumWindowSize.y });
|
|
||||||
}
|
|
||||||
|
|
||||||
m_isMinimumButtonPressed = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 pinButtonMin = { minimumButtonMin.x - cmnSize - 4, windowPos.y + 3 };
|
ImVec2 pinButtonMin = { minimumButtonMin.x - cmnSize - controlsMargin, windowPos.y + 3 };
|
||||||
ImVec2 pinButtonMax = { pinButtonMin.x + cmnSize, pinButtonMin.y + cmnSize };
|
ImVec2 pinButtonMax = { pinButtonMin.x + cmnSize, pinButtonMin.y + cmnSize };
|
||||||
|
|
||||||
ImGui::SetCursorScreenPos(pinButtonMin);
|
if (IsPinVisible)
|
||||||
ImGui::InvisibleButton("##PinButton", { cmnSize, cmnSize });
|
|
||||||
bool isPinButtonActive = ImGui::IsItemActive();
|
|
||||||
|
|
||||||
if (isPinButtonActive)
|
|
||||||
{
|
{
|
||||||
drawList->AddImage(g_upButtonPin2.get(), pinButtonMin, pinButtonMax);
|
controlsWidth += pinButtonMax.x - pinButtonMin.x + controlsMargin;
|
||||||
m_isPinButtonPressed = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
drawList->AddImage(g_upButtonPin1.get(), pinButtonMin, pinButtonMax);
|
|
||||||
|
|
||||||
if (m_isPinButtonPressed)
|
ImGui::SetCursorScreenPos(pinButtonMin);
|
||||||
|
ImGui::InvisibleButton("##PinButton", { cmnSize, cmnSize });
|
||||||
|
bool isPinButtonActive = ImGui::IsItemActive();
|
||||||
|
|
||||||
|
if (isPinButtonActive)
|
||||||
{
|
{
|
||||||
IsPinned = !IsPinned;
|
drawList->AddImage(g_upButtonPin2.get(), pinButtonMin, pinButtonMax);
|
||||||
m_isPinButtonPressed = false;
|
m_isPinButtonPressed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
drawList->AddImage(g_upButtonPin1.get(), pinButtonMin, pinButtonMax);
|
||||||
|
|
||||||
|
if (m_isPinButtonPressed)
|
||||||
|
{
|
||||||
|
IsPinned = !IsPinned;
|
||||||
|
m_isPinButtonPressed = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImVec2 titleBarMin = { windowPos.x, windowPos.y };
|
||||||
|
ImVec2 titleBarMax = { windowPos.x + windowSize.x - controlsWidth, windowPos.y + titleBarHeight };
|
||||||
|
|
||||||
|
if (ImGui::IsMouseHoveringRect(titleBarMin, titleBarMax, false))
|
||||||
|
{
|
||||||
|
if (IsMinimumVisible && ImGui::IsMouseDoubleClicked(0))
|
||||||
|
SetMinimum(!IsMinimum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reddog::Window::SetMinimum(bool isMinimum)
|
||||||
|
{
|
||||||
|
IsMinimum = isMinimum;
|
||||||
|
|
||||||
|
if (!ImWindow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto windowSize = ImWindow->Size;
|
||||||
|
|
||||||
|
if (IsMinimum)
|
||||||
|
{
|
||||||
|
m_preMinimumWindowSize = windowSize;
|
||||||
|
ImGui::SetWindowSize(ImWindow, { windowSize.x, MIN_WINDOW_SIZE });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::SetWindowSize(ImWindow, { windowSize.x, m_preMinimumWindowSize.y });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -338,13 +374,32 @@ bool Reddog::Window::Begin(bool* pIsVisible)
|
||||||
if ((Flags & eWindowFlags_NoResize) != 0)
|
if ((Flags & eWindowFlags_NoResize) != 0)
|
||||||
flags |= ImGuiWindowFlags_NoResize;
|
flags |= ImGuiWindowFlags_NoResize;
|
||||||
|
|
||||||
|
if (m_preBegin)
|
||||||
|
m_preBegin();
|
||||||
|
|
||||||
bool result = ImGui::Begin(Name, m_pIsVisible, flags);
|
bool result = ImGui::Begin(Name, m_pIsVisible, flags);
|
||||||
|
|
||||||
|
if (m_postBegin)
|
||||||
|
m_postBegin();
|
||||||
|
|
||||||
if (result && *m_pIsVisible)
|
if (result && *m_pIsVisible)
|
||||||
{
|
{
|
||||||
ImWindow = ImGui::GetCurrentWindow();
|
ImWindow = ImGui::GetCurrentWindow();
|
||||||
IsFocused = ImGui::IsWindowFocused();
|
IsFocused = ImGui::IsWindowFocused();
|
||||||
|
|
||||||
|
if ((Flags & eWindowFlags_Centre) != 0 && !m_isSetCentre)
|
||||||
|
{
|
||||||
|
auto viewport = ImGui::GetMainViewport();
|
||||||
|
auto windowPos = ImGui::GetWindowPos();
|
||||||
|
auto pos = ImVec2((viewport->Size.x / 2) - (ImWindow->Size.x / 2), (viewport->Size.y / 2) - (ImWindow->Size.y / 2));
|
||||||
|
|
||||||
|
ImGui::SetWindowPos(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep centring window until it has been moved.
|
||||||
|
if (ImGui::IsMouseDragging(0) && ImGui::IsWindowHovered())
|
||||||
|
m_isSetCentre = true;
|
||||||
|
|
||||||
if (m_isSetVisible)
|
if (m_isSetVisible)
|
||||||
{
|
{
|
||||||
ImGui::SetWindowFocus();
|
ImGui::SetWindowFocus();
|
||||||
|
|
@ -361,6 +416,13 @@ bool Reddog::Window::Begin(bool* pIsVisible)
|
||||||
|
|
||||||
void Reddog::Window::End()
|
void Reddog::Window::End()
|
||||||
{
|
{
|
||||||
|
if (m_preEnd)
|
||||||
|
m_preEnd();
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
if (m_postEnd)
|
||||||
|
m_postEnd();
|
||||||
|
|
||||||
EndStyle();
|
EndStyle();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@ namespace Reddog
|
||||||
{
|
{
|
||||||
enum EWindowFlags : uint32_t
|
enum EWindowFlags : uint32_t
|
||||||
{
|
{
|
||||||
eWindowFlags_None = 0,
|
eWindowFlags_None = 0,
|
||||||
eWindowFlags_NoTitleBar = 1 << 0,
|
eWindowFlags_NoTitleBar = 1 << 0,
|
||||||
eWindowFlags_NoResize = 1 << 1,
|
eWindowFlags_NoResize = 1 << 1,
|
||||||
eWindowFlags_NoListEntry = 1 << 2
|
eWindowFlags_NoListEntry = 1 << 2,
|
||||||
|
eWindowFlags_Centre = 1 << 3
|
||||||
};
|
};
|
||||||
|
|
||||||
class IWindow
|
class IWindow
|
||||||
|
|
@ -27,7 +28,9 @@ namespace Reddog
|
||||||
private:
|
private:
|
||||||
bool* m_pIsVisible{ nullptr };
|
bool* m_pIsVisible{ nullptr };
|
||||||
|
|
||||||
|
bool m_isSetCentre{};
|
||||||
bool m_isSetVisible{};
|
bool m_isSetVisible{};
|
||||||
|
|
||||||
bool m_isCloseButtonPressed{};
|
bool m_isCloseButtonPressed{};
|
||||||
bool m_isMinimumButtonPressed{};
|
bool m_isMinimumButtonPressed{};
|
||||||
bool m_isPinButtonPressed{};
|
bool m_isPinButtonPressed{};
|
||||||
|
|
@ -46,10 +49,18 @@ namespace Reddog
|
||||||
float m_maxWidth{ FLT_MAX };
|
float m_maxWidth{ FLT_MAX };
|
||||||
float m_maxHeight{ FLT_MAX };
|
float m_maxHeight{ FLT_MAX };
|
||||||
|
|
||||||
|
std::function<void()> m_preBegin{ nullptr };
|
||||||
|
std::function<void()> m_postBegin{ nullptr };
|
||||||
|
std::function<void()> m_preEnd{ nullptr };
|
||||||
|
std::function<void()> m_postEnd{ nullptr };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const char* Name{ "(null)" };
|
const char* Name{ "(null)" };
|
||||||
EWindowFlags Flags{ eWindowFlags_None };
|
EWindowFlags Flags{ eWindowFlags_None };
|
||||||
bool IsFocused{ true };
|
bool IsFocused{ true };
|
||||||
|
bool IsCloseVisible{ true };
|
||||||
|
bool IsMinimumVisible{ true };
|
||||||
|
bool IsPinVisible{ true };
|
||||||
bool IsMinimum{};
|
bool IsMinimum{};
|
||||||
bool IsPinned{ true };
|
bool IsPinned{ true };
|
||||||
bool IsVisible{};
|
bool IsVisible{};
|
||||||
|
|
@ -78,6 +89,7 @@ namespace Reddog
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetMinimum(bool isMinimum);
|
||||||
void SetVisible(bool isVisible = true);
|
void SetVisible(bool isVisible = true);
|
||||||
bool Begin(bool* pIsVisible = nullptr);
|
bool Begin(bool* pIsVisible = nullptr);
|
||||||
void End();
|
void End();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <ui/reddog/reddog_controls.h>
|
#include <ui/reddog/reddog_controls.h>
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
|
|
||||||
static ExportsWindow g_window{ "Exports" };
|
static ExportsWindow g_window;
|
||||||
|
|
||||||
void ExportsWindow::Draw()
|
void ExportsWindow::Draw()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,11 @@
|
||||||
class ExportsWindow : public Reddog::Window
|
class ExportsWindow : public Reddog::Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Reddog::Window::Window;
|
ExportsWindow() : Window()
|
||||||
|
{
|
||||||
|
Name = "Exports";
|
||||||
|
Flags = Reddog::eWindowFlags_NoResize;
|
||||||
|
}
|
||||||
|
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
#include <api/SWA.h>
|
#include <api/SWA.h>
|
||||||
#include <gpu/video.h>
|
#include <gpu/video.h>
|
||||||
#include <kernel/memory.h>
|
#include <kernel/memory.h>
|
||||||
#include <ui/reddog/reddog_controls.h>
|
|
||||||
#include <ui/reddog/debug_draw.h>
|
#include <ui/reddog/debug_draw.h>
|
||||||
|
#include <ui/reddog/reddog_controls.h>
|
||||||
#include <ui/game_window.h>
|
#include <ui/game_window.h>
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
|
|
||||||
static ViewWindow g_window{ "View" };
|
static ViewWindow g_window;
|
||||||
|
|
||||||
void ViewWindow::Draw()
|
void ViewWindow::Draw()
|
||||||
{
|
{
|
||||||
|
|
@ -46,6 +46,7 @@ void ViewWindow::Draw()
|
||||||
Reddog::Checkbox("Render Event Collision", SWA::SGlobals::ms_IsTriggerRender);
|
Reddog::Checkbox("Render Event Collision", SWA::SGlobals::ms_IsTriggerRender);
|
||||||
Reddog::Checkbox("Render Object Collision", SWA::SGlobals::ms_IsObjectCollisionRender);
|
Reddog::Checkbox("Render Object Collision", SWA::SGlobals::ms_IsObjectCollisionRender);
|
||||||
Reddog::Checkbox("Render Stage Collision", SWA::SGlobals::ms_IsCollisionRender);
|
Reddog::Checkbox("Render Stage Collision", SWA::SGlobals::ms_IsCollisionRender);
|
||||||
|
ImGui::TextColored({ 1, 0, 0, 1 }, "* Requires stage restart.");
|
||||||
|
|
||||||
Reddog::Separator();
|
Reddog::Separator();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,11 @@
|
||||||
class ViewWindow : public Reddog::Window
|
class ViewWindow : public Reddog::Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Reddog::Window::Window;
|
ViewWindow() : Window()
|
||||||
|
{
|
||||||
|
Name = "View";
|
||||||
|
Flags = Reddog::eWindowFlags_NoResize;
|
||||||
|
}
|
||||||
|
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
13
UnleashedRecomp/ui/reddog/windows/welcome_window.cpp
Normal file
13
UnleashedRecomp/ui/reddog/windows/welcome_window.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include "welcome_window.h"
|
||||||
|
|
||||||
|
static WelcomeWindow g_window;
|
||||||
|
|
||||||
|
void WelcomeWindow::Draw()
|
||||||
|
{
|
||||||
|
if (Begin())
|
||||||
|
{
|
||||||
|
ImGui::TextColored({ 1, 0, 0, 1 }, "!!! ATTENTION !!!");
|
||||||
|
ImGui::Text("For development use only.\nAny changes made here may cause unexpected behaviour.\nUse at your own risk!");
|
||||||
|
}
|
||||||
|
End();
|
||||||
|
}
|
||||||
20
UnleashedRecomp/ui/reddog/windows/welcome_window.h
Normal file
20
UnleashedRecomp/ui/reddog/windows/welcome_window.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ui/game_window.h>
|
||||||
|
#include <ui/reddog/reddog_window.h>
|
||||||
|
|
||||||
|
class WelcomeWindow : public Reddog::Window
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WelcomeWindow() : Window()
|
||||||
|
{
|
||||||
|
Name = "Welcome";
|
||||||
|
Flags = (Reddog::EWindowFlags)(Reddog::eWindowFlags_NoResize | Reddog::eWindowFlags_NoListEntry | Reddog::eWindowFlags_Centre);
|
||||||
|
IsMinimumVisible = false;
|
||||||
|
IsPinVisible = false;
|
||||||
|
IsPinned = false;
|
||||||
|
IsVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draw() override;
|
||||||
|
};
|
||||||
Loading…
Add table
Reference in a new issue