|
@@ -1,40 +1,50 @@
|
|
|
|
+----------------------------------------------------------------------------------------------------
|
|
|
|
+--
|
|
|
|
+-- Copyright (c) Contributors to the Open 3D Engine Project.
|
|
|
|
+-- For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
|
|
+--
|
|
|
|
+-- SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
|
|
+--
|
|
|
|
+--
|
|
|
|
+--
|
|
|
|
+----------------------------------------------------------------------------------------------------
|
|
local UIGameplayEventButton = {
|
|
local UIGameplayEventButton = {
|
|
- Properties = {
|
|
|
|
- Debug = false,
|
|
|
|
- Event = { default = "", description = "Event name" },
|
|
|
|
- Value = { default = "", description = "Event value" },
|
|
|
|
- InputEvent = { default = "", description = "Optional input event name"}
|
|
|
|
- }
|
|
|
|
|
|
+ Properties = {
|
|
|
|
+ Debug = false,
|
|
|
|
+ Event = { default = "", description = "Event name" },
|
|
|
|
+ Value = { default = "", description = "Event value" },
|
|
|
|
+ InputEvent = { default = "", description = "Optional input event name"}
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
function UIGameplayEventButton:OnActivate()
|
|
function UIGameplayEventButton:OnActivate()
|
|
- self.buttonHandler = UiButtonNotificationBus.Connect(self, self.entityId)
|
|
|
|
-
|
|
|
|
- if self.Properties.InputEvent ~= "" then
|
|
|
|
- local id = InputEventNotificationId(self.Properties.InputEvent)
|
|
|
|
- self.inputHandler = InputEventNotificationBus.Connect(self, id)
|
|
|
|
- end
|
|
|
|
|
|
+ self.buttonHandler = UiButtonNotificationBus.Connect(self, self.entityId)
|
|
|
|
+ self.gameplayNotificationId = GameplayNotificationId(EntityId(0), self.Properties.Event, "float")
|
|
|
|
+
|
|
|
|
+ if self.Properties.InputEvent ~= "" then
|
|
|
|
+ local id = InputEventNotificationId(self.Properties.InputEvent)
|
|
|
|
+ self.inputHandler = InputEventNotificationBus.Connect(self, id)
|
|
|
|
+ end
|
|
end
|
|
end
|
|
|
|
|
|
function UIGameplayEventButton:OnPressed(value)
|
|
function UIGameplayEventButton:OnPressed(value)
|
|
- GameplayNotificationBus.Event.OnEventBegin(GameplayNotificationId(EntityId(0), self.Properties.Event, "float"), self.Properties.Value)
|
|
|
|
|
|
+ GameplayNotificationBus.Event.OnEventBegin(self.gameplayNotificationId, self.Properties.Value)
|
|
end
|
|
end
|
|
|
|
|
|
-
|
|
|
|
function UIGameplayEventButton:OnButtonClick()
|
|
function UIGameplayEventButton:OnButtonClick()
|
|
- Debug.Log("Sending " .. tostring(self.Properties.Event))
|
|
|
|
- GameplayNotificationBus.Event.OnEventBegin(GameplayNotificationId(EntityId(0),self.Properties.Event, "float"), self.Properties.Value)
|
|
|
|
|
|
+ GameplayNotificationBus.Event.OnEventBegin(self.gameplayNotificationId, self.Properties.Value)
|
|
end
|
|
end
|
|
|
|
|
|
function UIGameplayEventButton:OnDeactivate()
|
|
function UIGameplayEventButton:OnDeactivate()
|
|
- if self.buttonHandler ~= nil then
|
|
|
|
- self.buttonHandler:Disconnect()
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- if self.inputHandler ~= nil then
|
|
|
|
- self.inputHandler:Disconnect()
|
|
|
|
- end
|
|
|
|
|
|
+ if self.buttonHandler ~= nil then
|
|
|
|
+ self.buttonHandler:Disconnect()
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ if self.inputHandler ~= nil then
|
|
|
|
+ self.inputHandler:Disconnect()
|
|
|
|
+ end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
-return UIGameplayEventButton
|
|
|
|
|
|
+return UIGameplayEventButton
|
|
|
|
+
|