mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-03 22:28:45 +00:00
CogAbility: UI improvements
Attribute Window: - Fix ID conflicts - Add attribute set column (hidden by default) - Improve indentation when displaying attribute set or categories
This commit is contained in:
@@ -341,7 +341,7 @@ bool FCogDebugPlotEntry::FindValue(float x, float& y) const
|
||||
Index = (i + ValueOffset) % Values.size();
|
||||
}
|
||||
|
||||
ImVec2 Point = Values[Index];
|
||||
const ImVec2 Point = Values[Index];
|
||||
if (Point.x > x)
|
||||
{
|
||||
FoundAfter = true;
|
||||
|
||||
@@ -14,12 +14,17 @@
|
||||
#include "InputCoreTypes.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowWidgets::BeginTableTooltip()
|
||||
bool FCogWindowWidgets::BeginTableTooltip()
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4, 4));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, IM_COL32(29, 42, 62, 240));
|
||||
ImGui::BeginTooltip();
|
||||
if (ImGui::BeginTooltip() == false)
|
||||
{
|
||||
EndTableTooltip();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -30,6 +35,21 @@ void FCogWindowWidgets::EndTableTooltip()
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogWindowWidgets::BeginItemTableTooltip()
|
||||
{
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort) == false)
|
||||
{ return false; }
|
||||
|
||||
return BeginTableTooltip();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowWidgets::EndItemTableTooltip()
|
||||
{
|
||||
return EndTableTooltip();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowWidgets::ThinSeparatorText(const char* Label)
|
||||
{
|
||||
@@ -1044,4 +1064,39 @@ bool FCogWindowWidgets::InputText(const char* Text, FString& Value)
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogWindowWidgets::BeginRightAlign(const char* Id)
|
||||
{
|
||||
if (ImGui::BeginTable(Id, 2, ImGuiTableFlags_SizingFixedFit, ImVec2(-1, 0)))
|
||||
{
|
||||
ImGui::TableSetupColumn("a", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableNextColumn();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowWidgets::EndRightAlign()
|
||||
{
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowWidgets::MenuItemShortcut(const char* Id, const FString& Text)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
if (BeginRightAlign(Id))
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
|
||||
const auto TextStr = StringCast<ANSICHAR>(*Text);
|
||||
ImGui::Text("%s", TextStr.Get());
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
EndRightAlign();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "CogWindowManager.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui.h"
|
||||
#include "InputCoreTypes.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -77,17 +78,7 @@ void FCogWindow_Settings::RenderContent()
|
||||
Context.SetEnableInput(bEnableInput);
|
||||
}
|
||||
ImGui::SetItemTooltip("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui.");
|
||||
|
||||
const auto ShortcutText = StringCast<ANSICHAR>(*FCogImguiInputHelper::CommandToString(PlayerInput, UCogWindowManager::ToggleInputCommand));
|
||||
const float ShortcutWidth = (ShortcutText.Get() != nullptr && ShortcutText.Get()[0]) ? ImGui::CalcTextSize(ShortcutText.Get(), NULL).x : 0.0f;
|
||||
if (ShortcutWidth > 0.0f)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(ImGui::GetContentRegionAvail().x - ShortcutWidth);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
|
||||
ImGui::Text("%s", ShortcutText.Get());
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
FCogWindowWidgets::MenuItemShortcut("EnableInputShortcut", FCogImguiInputHelper::CommandToString(PlayerInput, UCogWindowManager::ToggleInputCommand));
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
bool bShareKeyboard = Context.GetShareKeyboard();
|
||||
|
||||
@@ -23,10 +23,14 @@ class COGWINDOW_API FCogWindowWidgets
|
||||
{
|
||||
public:
|
||||
|
||||
static void BeginTableTooltip();
|
||||
static bool BeginTableTooltip();
|
||||
|
||||
static void EndTableTooltip();
|
||||
|
||||
static bool BeginItemTableTooltip();
|
||||
|
||||
static void EndItemTableTooltip();
|
||||
|
||||
static void ThinSeparatorText(const char* Label);
|
||||
|
||||
static void ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay);
|
||||
@@ -111,6 +115,11 @@ public:
|
||||
|
||||
static bool InputText(const char* Text, FString& Value);
|
||||
|
||||
static bool BeginRightAlign(const char* Id);
|
||||
|
||||
static void EndRightAlign();
|
||||
|
||||
static void MenuItemShortcut(const char* Id, const FString& Text);
|
||||
};
|
||||
|
||||
template<typename EnumType>
|
||||
|
||||
Reference in New Issue
Block a user