Sfoglia il codice sorgente

Fix formatting and add copyright header

Alex Peterson 2 anni fa
parent
commit
e73260414e

+ 10 - 0
Project/Scripts/DynamicAppleSpawner.lua

@@ -1,3 +1,13 @@
+----------------------------------------------------------------------------------------------------
+--
+-- 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 DynamicAppleSpawner = {
     Properties = {
         Debug                = true,

+ 34 - 24
Project/Scripts/UIGameplayEventButton.lua

@@ -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 = {
-	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()
-	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
 
 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
 
-
 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
 
 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
 
 
-return UIGameplayEventButton
+return UIGameplayEventButton
+

+ 21 - 8
Project/Scripts/UILogic.lua

@@ -1,3 +1,13 @@
+----------------------------------------------------------------------------------------------------
+--
+-- 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 UILogic = {
     Properties = {
         Debug = false,
@@ -22,15 +32,15 @@ function UILogic:OnActivate()
     self.quitCanvasVisible = false
 
     for event, handler in pairs(self.InputHandlers) do
-		local id = InputEventNotificationId(event)
-		handler.busHandler = InputEventNotificationBus.Connect(handler, id)
+        local id = InputEventNotificationId(event)
+        handler.busHandler = InputEventNotificationBus.Connect(handler, id)
         handler.component = self
-	end
+    end
     for event, handler in pairs(self.GameplayEventHandlers) do
-		local id = GameplayNotificationId(EntityId(0), event, "float")
-		handler.busHandler = GameplayNotificationBus.Connect(handler, id)
+        local id = GameplayNotificationId(EntityId(0), event, "float")
+        handler.busHandler = GameplayNotificationBus.Connect(handler, id)
         handler.component = self
-	end
+    end
 end
 
 function UILogic:SetCanvasVisible(visible)
@@ -67,7 +77,9 @@ function UILogic:Reset()
     if self.resetPressed and self.ctrlPressed then
         Debug.Log("Re-loading level")
         ROSConDemoRequestBus.Broadcast.ReloadLevel();
-        --ConsoleRequestBus.Broadcast.ExecuteConsoleCommand("LoadLevel main")
+        -- LoadLevel command will reload the error but currently has graphic
+        -- issues so a custom ReloadLevel command above is used
+        -- ConsoleRequestBus.Broadcast.ExecuteConsoleCommand("LoadLevel main")
     end
 end
 
@@ -101,4 +113,5 @@ function UILogic:OnDeactivate()
     end
 end
 
-return UILogic
+return UILogic
+