mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 08:02:23 -07:00
CogEngine: Add BuildInfo window to display the build changelist, target, and so on.
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
#include "CogEngineWindow_BuildInfo.h"
|
||||
|
||||
#include "CogImguiHelper.h"
|
||||
#include "imgui.h"
|
||||
#include "BuildSettings.h"
|
||||
#include "GenericPlatform/GenericPlatformMisc.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::Initialize()
|
||||
{
|
||||
FCogWindow::Initialize();
|
||||
|
||||
Config = GetConfig<UCogEngineConfig_BuildInfo>();
|
||||
|
||||
BuildText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::RenderHelp()
|
||||
{
|
||||
ImGui::Text(
|
||||
"This window can be used to display the build information such as the build version, changelist, date, target, and so on."
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::RenderTick(float DeltaTime)
|
||||
{
|
||||
FCogWindow::RenderTick(DeltaTime);
|
||||
|
||||
if (FApp::GetBuildTargetType() == EBuildTargetType::Editor)
|
||||
{
|
||||
if (Config->ShowInEditor == false)
|
||||
{ return; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Config->ShowInPackage == false)
|
||||
{ return;}
|
||||
}
|
||||
|
||||
const auto TextStr = StringCast<ANSICHAR>(*Text);
|
||||
ImDrawList* DrawList = Config->ShowInForeground ? ImGui::GetForegroundDrawList() : ImGui::GetBackgroundDrawList();
|
||||
const ImVec2 WindowPadding = ImGui::GetStyle().WindowPadding;
|
||||
const ImVec2 TextSize = ImGui::CalcTextSize(TextStr.Get(), nullptr, false);
|
||||
const ImVec2 RectSize = TextSize + WindowPadding * 2;
|
||||
const ImVec2 Pos = FCogWindowWidgets::ComputeScreenCornerLocation(Config->Alignment, Config->Padding);
|
||||
const ImVec2 AlignedPos = Pos - (FCogImguiHelper::ToImVec2(Config->Alignment) * RectSize);
|
||||
|
||||
DrawList->AddRectFilled(AlignedPos, AlignedPos + RectSize, FCogImguiHelper::ToImU32(Config->BackgroundColor), Config->Rounding);
|
||||
DrawList->AddRect(AlignedPos, AlignedPos + RectSize, FCogImguiHelper::ToImU32(Config->BorderColor), Config->Rounding);
|
||||
DrawList->AddText(AlignedPos + WindowPadding, FCogImguiHelper::ToImU32(Config->TextColor), TextStr.Get());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
FCogWindowWidgets::ThinSeparatorText("Build Properties");
|
||||
|
||||
if (ImGui::BeginChild("Settings", ImVec2(-1, 100 * GetDpiScale()), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeY))
|
||||
{
|
||||
if (ImGui::Checkbox("Branch Name", &Config->ShowBranchName)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build Date", &Config->ShowBuildDate)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build Configuration", &Config->ShowBuildConfiguration)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build User", &Config->ShowBuildUser)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build Machine", &Config->ShowBuildMachine)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Build Target Type", &Config->ShowBuildTargetType)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Current Change list", &Config->ShowCurrentChangelist)) { BuildText(); }
|
||||
if (ImGui::Checkbox("Compatible Change list", &Config->ShowCompatibleChangelist)) { BuildText(); }
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
FCogWindowWidgets::ThinSeparatorText("Display");
|
||||
|
||||
ImGui::Checkbox("Show In Editor", &Config->ShowInEditor);
|
||||
ImGui::Checkbox("Show In Package", &Config->ShowInPackage);
|
||||
ImGui::Checkbox("Show In Foreground", &Config->ShowInForeground);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::SliderFloat2("Alignment", &Config->Alignment.X, 0, 1.0f, "%.2f");
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::SliderInt2("Padding", &Config->Padding.X, 0, 100);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::SliderInt("Rounding", &Config->Rounding, 0, 12);
|
||||
|
||||
constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
FCogImguiHelper::ColorEdit4("Background Color", Config->BackgroundColor, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Border Color", Config->BorderColor, ColorEditFlags);
|
||||
FCogImguiHelper::ColorEdit4("Text Color", Config->TextColor, ColorEditFlags);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Reset Settings", ImVec2(-1, 0)))
|
||||
{
|
||||
ResetConfig();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogEngineWindow_BuildInfo::BuildText()
|
||||
{
|
||||
FStringBuilderBase S;
|
||||
if (Config->ShowBranchName) { S.Append(BuildSettings::GetBranchName()); S.Append(" "); }
|
||||
if (Config->ShowBuildDate) { S.Append(BuildSettings::GetBuildDate()); S.Append(" "); }
|
||||
if (Config->ShowBuildConfiguration) { S.Append(LexToString(FApp::GetBuildConfiguration())); S.Append(" "); }
|
||||
if (Config->ShowBuildTargetType) { S.Append(LexToString(FApp::GetBuildTargetType())); S.Append(" "); }
|
||||
if (Config->ShowBuildUser) { S.Append(BuildSettings::GetBuildUser()); S.Append(" "); }
|
||||
if (Config->ShowBuildMachine) { S.Append(BuildSettings::GetBuildMachine()); S.Append(" "); }
|
||||
if (Config->ShowCurrentChangelist) { S.Appendf(TEXT("%d"), BuildSettings::GetCurrentChangelist()); S.Append(" "); }
|
||||
if (Config->ShowCompatibleChangelist) { S.Appendf(TEXT("%d"),BuildSettings::GetCompatibleChangelist()); }
|
||||
|
||||
Text = FString(S).TrimEnd();
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogEngineWindow_BuildInfo.generated.h"
|
||||
|
||||
class UCogEngineConfig_BuildInfo;
|
||||
|
||||
class COGENGINE_API FCogEngineWindow_BuildInfo : public FCogWindow
|
||||
{
|
||||
typedef FCogWindow Super;
|
||||
|
||||
public:
|
||||
|
||||
virtual void Initialize() override;
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void RenderTick(float DeltaTime) override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
protected:
|
||||
|
||||
void BuildText();
|
||||
|
||||
TWeakObjectPtr<UCogEngineConfig_BuildInfo> Config;
|
||||
|
||||
FString Text;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Config = Cog)
|
||||
class UCogEngineConfig_BuildInfo : public UCogCommonConfig
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowInEditor = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowInPackage = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowBranchName = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowBuildDate = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowCurrentChangelist = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowCompatibleChangelist = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowBuildConfiguration = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowBuildUser = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowBuildMachine = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowBuildTargetType = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool ShowInForeground = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector2f Alignment = { 0, 1 };
|
||||
|
||||
UPROPERTY(Config)
|
||||
FIntVector2 Padding = { 10, 10 };
|
||||
|
||||
UPROPERTY(Config)
|
||||
int32 Rounding = 6;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor BackgroundColor = FColor(0, 0, 0, 80);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor BorderColor = FColor(255, 255, 255, 50);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FColor TextColor = FColor(255, 255, 255, 100);
|
||||
|
||||
virtual void Reset() override
|
||||
{
|
||||
Super::Reset();
|
||||
|
||||
ShowInEditor = false;
|
||||
ShowInPackage = true;
|
||||
ShowInForeground = true;
|
||||
ShowBranchName = false;
|
||||
ShowBuildDate = true;
|
||||
ShowCurrentChangelist = true;
|
||||
ShowCompatibleChangelist = false;
|
||||
ShowBuildConfiguration = true;
|
||||
ShowBuildUser = false;
|
||||
ShowBuildMachine = false;
|
||||
ShowBuildTargetType = true;
|
||||
Alignment = { 0, 1 };
|
||||
Padding = { 10, 10 };
|
||||
Rounding = 6;
|
||||
BackgroundColor = FColor(0, 0, 0, 80);
|
||||
BorderColor = FColor(255, 255, 255, 50);
|
||||
TextColor = FColor(255, 255, 255, 100);
|
||||
}
|
||||
};
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "CogAbilityWindow_Tweaks.h"
|
||||
#include "CogAIWindow_BehaviorTree.h"
|
||||
#include "CogAIWindow_Blackboard.h"
|
||||
#include "CogEngineWindow_BuildInfo.h"
|
||||
#include "CogEngineWindow_Cheats.h"
|
||||
#include "CogEngineWindow_CollisionTester.h"
|
||||
#include "CogEngineWindow_CollisionViewer.h"
|
||||
@@ -45,6 +46,8 @@ void Cog::AddAllWindows(UCogWindowManager& CogWindowManager)
|
||||
//---------------------------------------
|
||||
// Engine
|
||||
//---------------------------------------
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_BuildInfo>("Engine.Build Info");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_CollisionTester>("Engine.Collision Tester");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_CollisionViewer>("Engine.Collision Viewer");
|
||||
@@ -95,7 +98,7 @@ void Cog::AddAllWindows(UCogWindowManager& CogWindowManager)
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_TimeScale>("Engine.Time Scale");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Transform>("Engine.Transform");
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
// Abilities
|
||||
//---------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user