#160 Remove component interests, now setup it with function declaring

This commit is contained in:
Insality
2022-01-27 01:48:05 +02:00
parent 7a5faa2b85
commit 54f80aeccd
20 changed files with 72 additions and 85 deletions

View File

@@ -22,7 +22,7 @@
local Event = require("druid.event")
local component = require("druid.component")
local Checkbox = component.create("checkbox", { component.ON_LAYOUT_CHANGE })
local Checkbox = component.create("checkbox")
local function on_click(self)

View File

@@ -5,7 +5,7 @@
-- @local
local component = require("druid.component")
local Component = component.create("my_component_name", { component.ON_UPDATE })
local Component = component.create("my_component_name")
-- Component constructor
@@ -13,12 +13,12 @@ function Component:init(...)
end
-- Call only if exist interest: component.ON_UPDATE
-- Call every update step
function Component:update(dt)
end
-- Call only if exist interest: component.ON_INPUT
-- Call default on_input from gui script
function Component:on_input(action_id, action)
return false
end
@@ -29,17 +29,17 @@ function Component:on_style_change(style)
end
-- Call only if exist interest: component.ON_MESSAGE
-- Call default on_message from gui script
function Component:on_message(message_id, message, sender)
end
-- Call only if component with ON_LANGUAGE_CHANGE interest
-- Call if druid has triggered on_language_change
function Component:on_language_change()
end
-- Call only if component with ON_LAYOUT_CHANGE interest
-- Call if game layout has changed and need to restore values in component
function Component:on_layout_change()
end
@@ -50,12 +50,12 @@ function Component:on_input_interrupt()
end
-- Call, if game lost focus. Need ON_FOCUS_LOST intereset
-- Call, if game lost focus
function Component:on_focus_lost()
end
-- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
-- Call, if game gained focus
function Component:on_focus_gained()
end

View File

@@ -45,7 +45,7 @@ local Event = require("druid.event")
local helper = require("druid.helper")
local component = require("druid.component")
local DynamicGrid = component.create("dynamic_grid", { component.ON_LAYOUT_CHANGE })
local DynamicGrid = component.create("dynamic_grid")
local SIDE_VECTORS = {

View File

@@ -53,7 +53,7 @@ local const = require("druid.const")
local component = require("druid.component")
local utf8 = require("druid.system.utf8")
local Input = component.create("input", { component.ON_INPUT, component.ON_FOCUS_LOST })
local Input = component.create("input")
--- Mask text by replacing every character with a mask character

View File

@@ -18,7 +18,7 @@ local Event = require("druid.event")
local settings = require("druid.system.settings")
local component = require("druid.component")
local LangText = component.create("lang_text", { component.ON_LANGUAGE_CHANGE })
local LangText = component.create("lang_text")
--- Component init function

View File

@@ -34,7 +34,7 @@ local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Progress = component.create("progress", { component.ON_UPDATE, component.ON_LAYOUT_CHANGE })
local Progress = component.create("progress")
local function check_steps(self, from, to, exactly)

View File

@@ -40,7 +40,7 @@ local helper = require("druid.helper")
local const = require("druid.const")
local component = require("druid.component")
local Slider = component.create("slider", { component.ON_INPUT, component.ON_LAYOUT_CHANGE }, const.PRIORITY_INPUT_HIGH)
local Slider = component.create("slider", const.PRIORITY_INPUT_HIGH)
local function on_change_value(self)

View File

@@ -35,7 +35,7 @@ local formats = require("druid.helper.formats")
local helper = require("druid.helper")
local component = require("druid.component")
local Timer = component.create("timer", { component.ON_UPDATE })
local Timer = component.create("timer")
--- Component init function