mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07:00
move layout menu items into its own window
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "CogImguiInputHelper.h"
|
||||
#include "CogImguiModule.h"
|
||||
#include "CogWindow_Inputs.h"
|
||||
#include "CogWindow_Layouts.h"
|
||||
#include "CogWindow_Settings.h"
|
||||
#include "CogWindow_Spacing.h"
|
||||
#include "CogWindowConfig.h"
|
||||
@@ -63,7 +64,7 @@ void UCogWindowManager::InitializeInternal()
|
||||
SpaceWindows.Add(AddWindow<FCogWindow_Spacing>("Spacing 4", false));
|
||||
|
||||
InputsWindow = AddWindow<FCogWindow_Inputs>("Window.Inputs", false);
|
||||
|
||||
LayoutsWindow = AddWindow<FCogWindow_Layouts>("Window.Layouts", false);
|
||||
SettingsWindow = AddWindow<FCogWindow_Settings>("Window.Settings", false);
|
||||
|
||||
ConsoleCommands.Add(IConsoleManager::Get().RegisterConsoleCommand(
|
||||
@@ -354,33 +355,16 @@ void UCogWindowManager::RenderMainMenu()
|
||||
CloseAllWindows();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Reset Window Layout"))
|
||||
{
|
||||
ResetLayout();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Load Window Layout"))
|
||||
{
|
||||
for (int32 i = 1; i <= 4; ++i)
|
||||
{
|
||||
RenderLoadLayoutMenuItem(PlayerInput, i);
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Save Window Layout"))
|
||||
{
|
||||
for (int32 i = 1; i <= 4; ++i)
|
||||
{
|
||||
RenderSaveLayoutMenuItem(PlayerInput, i);
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
RenderMenuItem(*InputsWindow, "Inputs");
|
||||
|
||||
RenderMenuItem(*LayoutsWindow, "Layouts");
|
||||
|
||||
RenderMenuItem(*SettingsWindow, "Settings");
|
||||
|
||||
if (ImGui::BeginMenu("Spacing"))
|
||||
{
|
||||
for (FCogWindow* SpaceWindow : SpaceWindows)
|
||||
@@ -428,14 +412,8 @@ void UCogWindowManager::RenderMainMenu()
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
RenderMenuItem(*InputsWindow, "Inputs");
|
||||
|
||||
RenderMenuItem(*SettingsWindow, "Settings");
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
@@ -512,28 +490,6 @@ void UCogWindowManager::RenderMainMenu()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::RenderLoadLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex)
|
||||
{
|
||||
FString Command = FString::Printf(TEXT("%s %d"), *LoadLayoutCommand, LayoutIndex);
|
||||
FString Shortcut = FCogImguiInputHelper::CommandToString(PlayerInput, Command);
|
||||
if (ImGui::MenuItem(TCHAR_TO_ANSI(*FString::Printf(TEXT("Load Layout %d"), LayoutIndex)), TCHAR_TO_ANSI(*Shortcut)))
|
||||
{
|
||||
LoadLayout(LayoutIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::RenderSaveLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex)
|
||||
{
|
||||
FString Command = FString::Printf(TEXT("%s %d"), *SaveLayoutCommand, LayoutIndex);
|
||||
FString Shortcut = FCogImguiInputHelper::CommandToString(PlayerInput, Command);
|
||||
if (ImGui::MenuItem(TCHAR_TO_ANSI(*FString::Printf(TEXT("Save Layout %d"), LayoutIndex)), TCHAR_TO_ANSI(*Shortcut)))
|
||||
{
|
||||
SaveLayout(LayoutIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::RenderOptionMenu(UCogWindowManager::FMenu& Menu)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#include "CogWindow_Layouts.h"
|
||||
|
||||
#include "CogImguiInputHelper.h"
|
||||
#include "CogWindowManager.h"
|
||||
#include "InputCoreTypes.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Layouts::Initialize()
|
||||
{
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Layouts::RenderContent()
|
||||
{
|
||||
const UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*GetWorld());
|
||||
if (PlayerInput == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Reset Window Layout"))
|
||||
{
|
||||
GetOwner()->ResetLayout();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
for (int32 i = 1; i <= 4; ++i)
|
||||
{
|
||||
RenderLoadLayoutMenuItem(PlayerInput, i);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
for (int32 i = 1; i <= 4; ++i)
|
||||
{
|
||||
RenderSaveLayoutMenuItem(PlayerInput, i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Layouts::RenderLoadLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex)
|
||||
{
|
||||
FString Command = FString::Printf(TEXT("%s %d"), *UCogWindowManager::LoadLayoutCommand, LayoutIndex);
|
||||
FString Shortcut = FCogImguiInputHelper::CommandToString(PlayerInput, Command);
|
||||
if (ImGui::MenuItem(TCHAR_TO_ANSI(*FString::Printf(TEXT("Load Layout %d"), LayoutIndex)), TCHAR_TO_ANSI(*Shortcut)))
|
||||
{
|
||||
GetOwner()->LoadLayout(LayoutIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindow_Layouts::RenderSaveLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex)
|
||||
{
|
||||
FString Command = FString::Printf(TEXT("%s %d"), *UCogWindowManager::SaveLayoutCommand, LayoutIndex);
|
||||
FString Shortcut = FCogImguiInputHelper::CommandToString(PlayerInput, Command);
|
||||
if (ImGui::MenuItem(TCHAR_TO_ANSI(*FString::Printf(TEXT("Save Layout %d"), LayoutIndex)), TCHAR_TO_ANSI(*Shortcut)))
|
||||
{
|
||||
GetOwner()->SaveLayout(LayoutIndex);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "CogWindowManager.generated.h"
|
||||
|
||||
class FCogWindow;
|
||||
class FCogWindow_Inputs;
|
||||
class FCogWindow_Layouts;
|
||||
class FCogWindow_Settings;
|
||||
class IConsoleObject;
|
||||
class SCogImguiWidget;
|
||||
@@ -91,8 +93,9 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
friend class FCogWindow_Settings;
|
||||
friend class FCogWindow_Inputs;
|
||||
friend class FCogWindow_Layouts;
|
||||
friend class FCogWindow_Settings;
|
||||
|
||||
struct FMenu
|
||||
{
|
||||
@@ -113,10 +116,6 @@ protected:
|
||||
|
||||
virtual void RenderMenuItem(FCogWindow& Window, const char* MenuItemName);
|
||||
|
||||
virtual void RenderLoadLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex);
|
||||
|
||||
virtual void RenderSaveLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex);
|
||||
|
||||
virtual void TickDPI();
|
||||
|
||||
virtual void ToggleInputMode();
|
||||
@@ -201,6 +200,8 @@ protected:
|
||||
|
||||
FCogWindow_Settings* SettingsWindow = nullptr;
|
||||
|
||||
FCogWindow_Layouts* LayoutsWindow = nullptr;
|
||||
|
||||
FMenu MainMenu;
|
||||
|
||||
int32 LayoutToLoad = -1;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogImGuiKeyInfo.h"
|
||||
|
||||
class COGWINDOW_API FCogWindow_Inputs : public FCogWindow
|
||||
{
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
|
||||
class COGWINDOW_API FCogWindow_Layouts : public FCogWindow
|
||||
{
|
||||
typedef FCogWindow Super;
|
||||
|
||||
public:
|
||||
|
||||
virtual void Initialize() override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void RenderLoadLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex);
|
||||
|
||||
virtual void RenderSaveLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex);
|
||||
};
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogImGuiKeyInfo.h"
|
||||
|
||||
class COGWINDOW_API FCogWindow_Settings : public FCogWindow
|
||||
{
|
||||
@@ -15,7 +14,4 @@ public:
|
||||
protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user