mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Update new component template, replace component name with M as module name
This commit is contained in:
parent
7e16dacbc2
commit
ba1ab07e0d
@ -9,7 +9,7 @@ local component = require("druid.component")
|
|||||||
|
|
||||||
---@class {COMPONENT_TYPE}: druid.base_component{COMPONENT_ANNOTATIONS}
|
---@class {COMPONENT_TYPE}: druid.base_component{COMPONENT_ANNOTATIONS}
|
||||||
---@field druid druid_instance
|
---@field druid druid_instance
|
||||||
local {COMPONENT_NAME} = component.create("{COMPONENT_TYPE}")
|
local M = component.create("{COMPONENT_TYPE}")
|
||||||
|
|
||||||
local SCHEME = {
|
local SCHEME = {
|
||||||
{SCHEME_LIST}
|
{SCHEME_LIST}
|
||||||
@ -18,15 +18,15 @@ local SCHEME = {
|
|||||||
|
|
||||||
---@param template string
|
---@param template string
|
||||||
---@param nodes table<hash, node>
|
---@param nodes table<hash, node>
|
||||||
function {COMPONENT_NAME}:init(template, nodes)
|
function M:init(template, nodes)
|
||||||
self:set_template(template)
|
self:set_template(template)
|
||||||
self:set_nodes(nodes)
|
self:set_nodes(nodes)
|
||||||
self.druid = self:get_druid(){COMPONENT_DEFINE}
|
self.druid = self:get_druid(){COMPONENT_DEFINE}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function {COMPONENT_NAME}:on_remove()
|
function M:on_remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
{COMPONENT_FUNCTIONS}
|
{COMPONENT_FUNCTIONS}
|
||||||
return {COMPONENT_NAME}
|
return M
|
||||||
|
@ -32,7 +32,7 @@ def process_component(node_name, component_name):
|
|||||||
|
|
||||||
if node_name.startswith("button"):
|
if node_name.startswith("button"):
|
||||||
component_annotations += "\n---@field {0} druid.button".format(node_name)
|
component_annotations += "\n---@field {0} druid.button".format(node_name)
|
||||||
component_functions += "\nfunction {1}:_on_{0}()\n\tprint(\"Click on {0}\")\nend\n\n".format(node_name, component_name)
|
component_functions += "\nfunction M:_on_{0}()\n\tprint(\"Click on {0}\")\nend\n\n".format(node_name)
|
||||||
component_define += "\n\tself.{0} = self.druid:new_button(SCHEME.{1}, self._on_{0})".format(node_name, get_id(node_name))
|
component_define += "\n\tself.{0} = self.druid:new_button(SCHEME.{1}, self._on_{0})".format(node_name, get_id(node_name))
|
||||||
|
|
||||||
if node_name.startswith("text"):
|
if node_name.startswith("text"):
|
||||||
@ -66,7 +66,7 @@ def process_component(node_name, component_name):
|
|||||||
component_annotations += "\n---@field {0} druid.slider".format(node_name)
|
component_annotations += "\n---@field {0} druid.slider".format(node_name)
|
||||||
component_define += "\n--TODO: Replace slider end position. It should be only vertical or horizontal"
|
component_define += "\n--TODO: Replace slider end position. It should be only vertical or horizontal"
|
||||||
component_define += "\n\tself.{0} = self.druid:new_slider(SCHEME.{1}, vmath.vector3(100, 0, 0), self._on_{0}_change)".format(node_name, get_id(node_name))
|
component_define += "\n\tself.{0} = self.druid:new_slider(SCHEME.{1}, vmath.vector3(100, 0, 0), self._on_{0}_change)".format(node_name, get_id(node_name))
|
||||||
component_functions += "\nfunction {1}:_on_{0}_change(value)\n\tprint(\"Slider change:\", value)\nend\n\n".format(node_name, component_name)
|
component_functions += "\nfunction M:_on_{0}_change(value)\n\tprint(\"Slider change:\", value)\nend\n\n".format(node_name)
|
||||||
|
|
||||||
if node_name.startswith("progress"):
|
if node_name.startswith("progress"):
|
||||||
component_annotations += "\n---@field {0} druid.progress".format(node_name)
|
component_annotations += "\n---@field {0} druid.progress".format(node_name)
|
||||||
@ -75,7 +75,7 @@ def process_component(node_name, component_name):
|
|||||||
if node_name.startswith("timer"):
|
if node_name.startswith("timer"):
|
||||||
component_annotations += "\n---@field {0} druid.timer".format(node_name)
|
component_annotations += "\n---@field {0} druid.timer".format(node_name)
|
||||||
component_define += "\n\tself.{0} = self.druid:new_timer(SCHEME.{1}, 59, 0, self._on_{0}_end)".format(node_name, get_id(node_name))
|
component_define += "\n\tself.{0} = self.druid:new_timer(SCHEME.{1}, 59, 0, self._on_{0}_end)".format(node_name, get_id(node_name))
|
||||||
component_functions += "\nfunction {1}:_on_{0}_end()\n\tprint(\"Timer {0} trigger\")\nend\n\n".format(node_name, component_name)
|
component_functions += "\nfunction M:_on_{0}_end()\n\tprint(\"Timer {0} trigger\")\nend\n\n".format(node_name)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user