mirror of
https://github.com/Ed94/Cog.git
synced 2026-07-23 16:07:51 +00:00
Improve behavior tree
add hover feedback on gamepad buttons
This commit is contained in:
@@ -38,6 +38,7 @@ void UCogInputWindow_Gamepad::ResetConfig()
|
||||
ButtonColor = FVector4f(0.2f, 0.2f, 0.2f, 1.0f);
|
||||
BorderColor = FVector4f(0.03f, 0.03f, 0.03f, 1.0f);
|
||||
PressedColor = FVector4f(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
HoveredColor = FVector4f(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
InjectColor = FVector4f(1.0f, 0.5f, 0.0f, 0.5f);
|
||||
Border = 0.02f;
|
||||
}
|
||||
@@ -105,8 +106,7 @@ void UCogInputWindow_Gamepad::AddButton(const FKey& Key, const ImVec2& RelativeP
|
||||
const ImVec2& Size = RelativeSize * CanvasSize.x;
|
||||
const ImVec2 Position = (CanvasMin + CanvasSize * RelativePosition) - Alignment * Size;
|
||||
|
||||
ImU32 Color = ImGui::GetColorU32(ImLerp(FCogImguiHelper::ToImVec4(ButtonColor), FCogImguiHelper::ToImVec4(PressedColor), Value));
|
||||
|
||||
bool IsPressed = false;
|
||||
FCogInjectActionInfo* ActionInfo = Actions.Find(Key);
|
||||
if (ActionInfo != nullptr)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ void UCogInputWindow_Gamepad::AddButton(const FKey& Key, const ImVec2& RelativeP
|
||||
{
|
||||
if (Input->GetActionValue(ActionInfo->Action).Get<bool>())
|
||||
{
|
||||
Color = FCogImguiHelper::ToImU32(PressedColor);
|
||||
IsPressed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,6 +125,16 @@ void UCogInputWindow_Gamepad::AddButton(const FKey& Key, const ImVec2& RelativeP
|
||||
OnButtonClicked(ActionInfo);
|
||||
}
|
||||
|
||||
ImU32 Color = FCogImguiHelper::ToImU32(ButtonColor);
|
||||
if (IsPressed)
|
||||
{
|
||||
Color = FCogImguiHelper::ToImU32(PressedColor);
|
||||
}
|
||||
else if (ImGui::IsItemHovered())
|
||||
{
|
||||
Color = FCogImguiHelper::ToImU32(HoveredColor);
|
||||
}
|
||||
|
||||
InputContextMenu(Key, ActionInfo, nullptr);
|
||||
|
||||
if (Border > 0.0f)
|
||||
@@ -144,8 +154,6 @@ void UCogInputWindow_Gamepad::AddStick(const FKey& Key2D, const FKey& KeyBool, b
|
||||
{
|
||||
ImGui::PushID((void*)(&Key2D));
|
||||
|
||||
ImU32 Color = Input->GetKeyValue(KeyBool) > 0.0f ? FCogImguiHelper::ToImU32(PressedColor) : FCogImguiHelper::ToImU32(ButtonColor);
|
||||
|
||||
FCogInjectActionInfo* ActionInfoBool = Actions.Find(KeyBool);
|
||||
FCogInjectActionInfo* ActionInfo2D = Actions.Find(Key2D);
|
||||
|
||||
@@ -169,6 +177,16 @@ void UCogInputWindow_Gamepad::AddStick(const FKey& Key2D, const FKey& KeyBool, b
|
||||
OnButtonClicked(ActionInfoBool);
|
||||
}
|
||||
|
||||
ImU32 Color = FCogImguiHelper::ToImU32(ButtonColor);
|
||||
if (Input->GetKeyValue(KeyBool) > 0.0f)
|
||||
{
|
||||
Color = FCogImguiHelper::ToImU32(PressedColor);
|
||||
}
|
||||
else if (ImGui::IsItemHovered())
|
||||
{
|
||||
Color = FCogImguiHelper::ToImU32(HoveredColor);
|
||||
}
|
||||
|
||||
InputContextMenu(Key2D, ActionInfoBool, ActionInfo2D);
|
||||
|
||||
if (Border > 0.0f)
|
||||
@@ -302,11 +320,12 @@ void UCogInputWindow_Gamepad::RenderContent()
|
||||
ImGui::Checkbox("Invert Left Stick Y", &bInvertLeftStickY);
|
||||
ImGui::Checkbox("Invert Right Stick Y", &bInvertRightStickY);
|
||||
ImGui::Separator();
|
||||
ImGui::ColorEdit4("Background Color", (float*)&BackgroundColor, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit4("Border Color", (float*)&BorderColor, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit4("Button Color", (float*)&ButtonColor, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit4("Pressed Color", (float*)&PressedColor, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit4("Inject Color", (float*)&InjectColor, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit4("Background Color", (float*)&BackgroundColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Border Color", (float*)&BorderColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Button Color", (float*)&ButtonColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Pressed Color", (float*)&PressedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Hovered Color", (float*)&HoveredColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Inject Color", (float*)&InjectColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
FCogWindowWidgets::SliderWithReset("Border", &Border, 0.0f, 0.1f, 0.02f, "%0.3f");
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ private:
|
||||
UPROPERTY(Config)
|
||||
FVector4f PressedColor = FVector4f(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector4f HoveredColor = FVector4f(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector4f InjectColor = FVector4f(1.0f, 0.5f, 0.0f, 0.5f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user