CogInput: Add multiple IMC on the input data asset. Maybe propose a current imc

This commit is contained in:
Arnaud Jamin
2023-10-22 23:16:00 -04:00
parent 9a7766b9a7
commit a39c8b277d
8 changed files with 57 additions and 30 deletions
Binary file not shown.
@@ -288,7 +288,7 @@ void UCogEngineWindow_OutputLog::RenderContent()
ImGui::EndChild();
}
if (ImGui::BeginPopupContextItem())
if (ImGui::BeginPopupContextItem("OutputLog"))
{
if (ImGui::MenuItem("Clear"))
{
@@ -20,6 +20,12 @@ void UCogInputWindow_Actions::RenderHelp()
);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogInputWindow_Actions::ResetConfig()
{
RepeatPeriod = 0.5f;
}
//--------------------------------------------------------------------------------------------------------------------------
UCogInputWindow_Actions::UCogInputWindow_Actions()
{
@@ -39,12 +45,6 @@ void UCogInputWindow_Actions::RenderContent()
return;
}
if (Asset->MappingContext == nullptr)
{
ImGui::Text("No MappingContext");
return;
}
ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController();
if (LocalPlayer == nullptr)
{
@@ -80,14 +80,22 @@ void UCogInputWindow_Actions::RenderContent()
if (Actions.Num() == 0)
{
for (const FEnhancedActionKeyMapping& Mapping : Asset->MappingContext->GetMappings())
for (TObjectPtr<const UInputMappingContext> MappingContext : Asset->MappingContexts)
{
if (Mapping.Action != nullptr && Actions.ContainsByPredicate([&Mapping](const FCogInjectActionInfo& ActionInfo) { return Mapping.Action == ActionInfo.Action; }) == false)
for (const FEnhancedActionKeyMapping& Mapping : MappingContext->GetMappings())
{
FCogInjectActionInfo& ActionInfo = Actions.AddDefaulted_GetRef();
ActionInfo.Action = Mapping.Action;
if (Mapping.Action != nullptr && Actions.ContainsByPredicate([&Mapping](const FCogInjectActionInfo& ActionInfo) { return Mapping.Action == ActionInfo.Action; }) == false)
{
FCogInjectActionInfo& ActionInfo = Actions.AddDefaulted_GetRef();
ActionInfo.Action = Mapping.Action;
}
}
}
Actions.Sort([](const FCogInjectActionInfo& Lhs, const FCogInjectActionInfo& Rhs)
{
return GetNameSafe(Lhs.Action).Compare(GetNameSafe(Rhs.Action)) < 0;
});
}
if (ImGui::BeginTable("Actions", 3, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize))
@@ -62,7 +62,7 @@ void UCogInputWindow_Gamepad::InputContextMenu(const FKey& Key, FCogInjectAction
if (ActionInfoButton != nullptr && ActionInfoButton->Action != nullptr && ActionInfoButton->Action->ValueType == EInputActionValueType::Axis1D)
{
FCogWindowWidgets::SliderWithReset("X", &ActionInfo2D->X, -1.0f, 1.0f, 0.0f, "%0.2f");
FCogWindowWidgets::SliderWithReset("X", &ActionInfoButton->X, -1.0f, 1.0f, 0.0f, "%0.2f");
}
if (ActionInfo2D != nullptr)
@@ -236,7 +236,11 @@ void UCogInputWindow_Gamepad::RenderContent()
return;
}
if (Asset != nullptr && Asset->MappingContext != nullptr)
if (Asset == nullptr)
{
ImGui::Text("No Input Asset");
}
else
{
if (Actions.Num() == 0)
{
@@ -267,20 +271,20 @@ void UCogInputWindow_Gamepad::RenderContent()
Actions.FindOrAdd(EKeys:: Gamepad_DPad_Right);
Actions.FindOrAdd(EKeys:: Gamepad_DPad_Left);
for (const FEnhancedActionKeyMapping& Mapping : Asset->MappingContext->GetMappings())
for (TObjectPtr<const UInputMappingContext> MappingContext : Asset->MappingContexts)
{
if (Mapping.Action != nullptr)
for (const FEnhancedActionKeyMapping& Mapping : MappingContext->GetMappings())
{
FCogInjectActionInfo& ActionInfo = Actions.FindOrAdd(Mapping.Key);
ActionInfo.Action = Mapping.Action;
if (Mapping.Action != nullptr)
{
FCogInjectActionInfo& ActionInfo = Actions.FindOrAdd(Mapping.Key);
ActionInfo.Action = Mapping.Action;
}
}
}
}
}
else
{
ImGui::Text("No Action Asset");
}
const float AspectRatio = 0.55f;
const float StickAmplitude = 0.04f;
@@ -311,7 +315,7 @@ void UCogInputWindow_Gamepad::RenderContent()
DrawList = ImGui::GetWindowDrawList();
ImGui::Dummy(bShowAsOverlay ? CanvasMax - CanvasMin : ContentSize);
if (ImGui::BeginPopupContextItem())
if (ImGui::BeginPopupContextItem("Gamepad"))
{
if (ImGui::Button("Close", ImVec2(-1.0f, 0)))
{
@@ -15,5 +15,5 @@ public:
UCogInputDataAsset() {}
UPROPERTY(EditAnywhere)
TObjectPtr<const UInputMappingContext> MappingContext;
TArray<TObjectPtr<const UInputMappingContext>> MappingContexts;
};
@@ -19,7 +19,9 @@ public:
protected:
void RenderHelp();
virtual void ResetConfig() override;
virtual void RenderHelp() override;
virtual void RenderContent() override;
+19 -2
View File
@@ -393,9 +393,26 @@ void ACogSampleCharacter::OnAbilityInputStarted(const FInputActionValue& Value,
{
return;
}
Spec->InputPressed = true;
AbilitySystem->TryActivateAbility(Handle);
//-----------------------------------------------------
// Replicate button press if ability is already active
//-----------------------------------------------------
if (Spec->IsActive())
{
const UGameplayAbility* AbilityToActivate = Spec->GetPrimaryInstance();
if (AbilityToActivate->bReplicateInputDirectly && AbilitySystem->IsOwnerActorAuthoritative() == false)
{
AbilitySystem->ServerSetInputPressed(Spec->Handle);
}
AbilitySystem->AbilitySpecInputPressed(*Spec);
AbilitySystem->InvokeReplicatedEvent(EAbilityGenericReplicatedEvent::InputPressed, Spec->Handle, Spec->ActivationInfo.GetActivationPredictionKey());
}
else
{
AbilitySystem->TryActivateAbility(Handle);
}
}
//--------------------------------------------------------------------------------------------------------------------------
-4
View File
@@ -9,10 +9,6 @@
- CogEngine: Stat main menu widget could have a tooltip on each stat with a control to change set the emulation (FPS, Ping, Packetloss)
- CogEngine: Add screen settings (fullscreen, borderless, window and resolution)
- CogInput: Add multiple IMC on the input data asset. Maybe propose a current imc
- CogAbilities: Apply tweaks on spawn
- CogSample: Add a custom window in sample (changing the character faction)
- CogSample: Create more abilities