Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions addons/core/Configs/System/chimeraMenus.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MenuManager {
MenuPresets {
MenuPreset ACE_InspectGadgetMenu {
Layout "{6661B07C2C6D0CC7}UI/layouts/Gagets/ACE_InspectGadgetMenu.layout"
Class "ACE_InspectGadgetMenu"
}
}
}
17 changes: 17 additions & 0 deletions addons/core/Configs/System/chimeraMenus.conf.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MetaFileClass {
Name "{C747AFB6B750CE9A}Configs/System/chimeraMenus.conf"
Configurations {
CONFResourceClass PC {
}
CONFResourceClass XBOX_ONE : PC {
}
CONFResourceClass XBOX_SERIES : PC {
}
CONFResourceClass PS4 : PC {
}
CONFResourceClass PS5 : PC {
}
CONFResourceClass HEADLESS : PC {
}
}
}
30 changes: 30 additions & 0 deletions addons/core/UI/layouts/Gagets/ACE_GamepadPhysicalButton.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ButtonWidgetClass {
Name "Button"
Slot FrameWidgetSlot "{6563682E29BADC1C}" {
OffsetLeft 0
OffsetTop 0
SizeX 128
OffsetRight -128
SizeY 128
OffsetBottom -128
Alignment 0.5 0.5
SizeToContent 1
}
Opacity 0
components {
ACE_GamepadPhysicalButtonUIComponent "{65641D94B3955D9B}" {
}
}
style blank
{
ImageWidgetClass "{6563682E0ED041D0}" {
Name "GamepadCursorFocus"
Slot ButtonWidgetSlot "{65641D97992C7EAE}" {
}
Color 0.7605 0.3916 0.0802 1
Texture "{272DB16BAE0E7D3C}UI/Textures/Editor/Cursors/GamepadCursor_Default.edds"
Image ""
Size 128 128
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MetaFileClass {
Name "{7063BDFDF0B3998C}UI/layouts/Gagets/ACE_ControllerButton.layout"
Configurations {
LayoutResourceClass PC {
}
LayoutResourceClass XBOX_ONE : PC {
}
LayoutResourceClass XBOX_SERIES : PC {
}
LayoutResourceClass PS4 : PC {
}
LayoutResourceClass PS5 : PC {
}
LayoutResourceClass HEADLESS : PC {
}
}
}
8 changes: 8 additions & 0 deletions addons/core/UI/layouts/Gagets/ACE_InspectGadgetMenu.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FrameWidgetClass {
Name "rootFrame"
"Ignore Cursor" 0
components {
ACE_PhysicalButtonsUIComponent "{6563032AD753AEC4}" {
}
}
}
17 changes: 17 additions & 0 deletions addons/core/UI/layouts/Gagets/ACE_InspectGadgetMenu.layout.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MetaFileClass {
Name "{6661B07C2C6D0CC7}UI/layouts/Gagets/ACE_InspectGadgetMenu.layout"
Configurations {
LayoutResourceClass PC {
}
LayoutResourceClass XBOX_ONE : PC {
}
LayoutResourceClass XBOX_SERIES : PC {
}
LayoutResourceClass PS4 : PC {
}
LayoutResourceClass PS5 : PC {
}
LayoutResourceClass HEADLESS : PC {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//------------------------------------------------------------------------------------------------
class ACE_PhysicalButtonsComponentClass : ScriptComponentClass
{
}

//------------------------------------------------------------------------------------------------
//! Component for registering physical buttons on an entity
class ACE_PhysicalButtonsComponent : ScriptComponent
{
[Attribute()]
protected ref array<ref ACE_PhysicalButtonConfig> m_aButtonConfigs;

//------------------------------------------------------------------------------------------------
override protected void OnPostInit(IEntity owner)
{
super.OnPostInit(owner);
SetEventMask(owner, EntityEvent.INIT);
}

//------------------------------------------------------------------------------------------------
override protected void EOnInit(IEntity owner)
{
super.EOnInit(owner);

if (!GetGame().InPlayMode())
return;

foreach (ACE_PhysicalButtonConfig buttonConfig : m_aButtonConfigs)
{
buttonConfig.Init(owner);
}
}

//------------------------------------------------------------------------------------------------
void SetButtonState(string colliderName, bool state)
{
ACE_PhysicalButtonConfig config = GetButtonConfig(colliderName);
if (!config)
return;

Animation anim = GetOwner().GetAnimation();
if (!anim)
return;

TNodeId boneID = anim.GetBoneIndex(config.m_sBoneName);
vector transform[4];
Math3D.MatrixIdentity4(transform);

if (state)
transform[3] = config.m_vPressedOffset;

anim.SetBoneMatrix(GetOwner(), boneID, transform);

if (!state)
PrintFormat("Button %1 clicked", colliderName, level: LogLevel.DEBUG);

if (state)
AudioSystem.PlaySound(config.m_sPressedSoundPath);
else
AudioSystem.PlaySound(config.m_sReleasedSoundPath);

if (!state && config.m_Command)
config.m_Command.Execute();
}

//------------------------------------------------------------------------------------------------
ACE_PhysicalButtonConfig GetButtonConfig(string colliderName)
{
foreach (ACE_PhysicalButtonConfig buttonConfig : m_aButtonConfigs)
{
if (buttonConfig.m_sColliderName == colliderName)
return buttonConfig;
}

return null;
}

//------------------------------------------------------------------------------------------------
array<ref ACE_PhysicalButtonConfig> GetAllButtonConfigs()
{
return m_aButtonConfigs;
}
}

//------------------------------------------------------------------------------------------------
//! Config for a physical button
[BaseContainerProps(), BaseContainerCustomTitleField("m_sColliderName")]
class ACE_PhysicalButtonConfig
{
[Attribute(desc: "Name of the collider of the button")]
string m_sColliderName;

[Attribute(desc: "Name of the button's bone")]
string m_sBoneName;

[Attribute(defvalue: "0 -0.001 0", desc: "Displacement vector for when the button is pressed button")]
vector m_vPressedOffset;

[Attribute(defvalue: "{9DDDC275FFCC545F}Sounds/Props/Military/Radios/Samples/Props_Radios_Button_Press_1.wav", desc: "Sound for when the button is pressed", uiwidget: UIWidgets.ResourceNamePicker, params: "wav")]
ResourceName m_sPressedSoundPath;

[Attribute(defvalue: "{A8CB8AE57458C226}Sounds/Props/Military/Radios/Samples/Props_Radios_Button_Release_1.wav", desc: "Sound for when the button is released", uiwidget: UIWidgets.ResourceNamePicker, params: "wav")]
ResourceName m_sReleasedSoundPath;

[Attribute(desc: "Command that the button executes")]
ref ACE_IGadgetCommand m_Command;

//------------------------------------------------------------------------------------------------
void Init(IEntity gadget)
{
if (m_Command)
m_Command.Init(gadget);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//------------------------------------------------------------------------------------------------
class ACE_IGadgetCommand : ScriptAndConfig
{
protected IEntity m_Gadget;

//------------------------------------------------------------------------------------------------
void Init(IEntity gadget)
{
m_Gadget = gadget;
}

//------------------------------------------------------------------------------------------------
void Execute();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//------------------------------------------------------------------------------------------------
class ACE_GamepadPhysicalButtonUIComponent : ScriptedWidgetComponent
{
protected Widget m_wWidget;
protected ACE_PhysicalButtonsComponent m_PhysicalButtonsComponent;
protected ACE_PhysicalButtonConfig m_ButtonConfig;

protected static const int BUTTON_RELEASE_DELAY_MS = 250;

//------------------------------------------------------------------------------------------------
override void HandlerAttached(Widget w)
{
m_wWidget = w;
}

//------------------------------------------------------------------------------------------------
void SetPhysicalButton(ACE_PhysicalButtonsComponent component, ACE_PhysicalButtonConfig buttonConfig)
{
m_PhysicalButtonsComponent = component;
m_ButtonConfig = buttonConfig;
m_wWidget.SetName(buttonConfig.m_sColliderName);
}

//------------------------------------------------------------------------------------------------
override bool OnClick(Widget w, int x, int y, int button)
{
m_PhysicalButtonsComponent.SetButtonState(m_ButtonConfig.m_sColliderName, true);
GetGame().GetCallqueue().CallLater(m_PhysicalButtonsComponent.SetButtonState, BUTTON_RELEASE_DELAY_MS, false, m_ButtonConfig.m_sColliderName, false);
return true;
}

//------------------------------------------------------------------------------------------------
override bool OnFocus(Widget w, int x, int y)
{
m_wWidget.SetOpacity(1);
return false;
}

//------------------------------------------------------------------------------------------------
override bool OnFocusLost(Widget w, int x, int y)
{
m_wWidget.SetOpacity(0);
return false;
}
}
Loading