mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 02:17:52 +02:00
Update
This commit is contained in:
parent
a2bb93a03b
commit
ad0447b649
@ -92,6 +92,18 @@ function M:on_style_change(style)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@return druid.button self
|
||||||
|
function M:set_animations_disabled()
|
||||||
|
self.style.on_click = function() end
|
||||||
|
self.style.on_click_disabled = function() end
|
||||||
|
self.style.on_mouse_hover = function() end
|
||||||
|
self.style.on_hover = function() end
|
||||||
|
self.style.on_set_enabled = function() end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function M:on_late_init()
|
function M:on_late_init()
|
||||||
if not self.click_zone then
|
if not self.click_zone then
|
||||||
local stencil_node = helper.get_closest_stencil_node(self.node)
|
local stencil_node = helper.get_closest_stencil_node(self.node)
|
||||||
|
@ -9,8 +9,8 @@ local component = require("druid.component")
|
|||||||
|
|
||||||
---@class druid.hover: druid.component
|
---@class druid.hover: druid.component
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field on_hover event
|
---@field on_hover event fun(self: druid.hover, is_hover: boolean)
|
||||||
---@field on_mouse_hover event
|
---@field on_mouse_hover event fun(self: druid.hover, is_hover: boolean)
|
||||||
---@field style druid.hover.style
|
---@field style druid.hover.style
|
||||||
---@field click_zone node
|
---@field click_zone node
|
||||||
---@field private _is_hovered boolean|nil
|
---@field private _is_hovered boolean|nil
|
||||||
|
@ -113,8 +113,8 @@ end
|
|||||||
---Get a binded widget to the current game object.
|
---Get a binded widget to the current game object.
|
||||||
---@generic T: druid.widget
|
---@generic T: druid.widget
|
||||||
---@param widget_class T The class of the widget to return
|
---@param widget_class T The class of the widget to return
|
||||||
---@param gui_url_string string GUI url, if nil current gui will be used
|
---@param gui_url_string string? GUI url, if nil current gui will be used
|
||||||
---@return T|nil
|
---@return T
|
||||||
function M.get_widget(widget_class, gui_url_string)
|
function M.get_widget(widget_class, gui_url_string)
|
||||||
local gui_url = msg.url(gui_url_string)
|
local gui_url = msg.url(gui_url_string)
|
||||||
local guis = REGISTERED_GUI_WIDGETS[gui_url.socket]
|
local guis = REGISTERED_GUI_WIDGETS[gui_url.socket]
|
||||||
@ -135,7 +135,7 @@ end
|
|||||||
|
|
||||||
---Register a widget to the current game object.
|
---Register a widget to the current game object.
|
||||||
---@param druid druid.instance The druid instance to register
|
---@param druid druid.instance The druid instance to register
|
||||||
function M.register_gui_widget(druid)
|
function M.register_druid_as_widget(druid)
|
||||||
local gui_url = msg.url()
|
local gui_url = msg.url()
|
||||||
REGISTERED_GUI_WIDGETS[gui_url.socket] = REGISTERED_GUI_WIDGETS[gui_url.socket] or {}
|
REGISTERED_GUI_WIDGETS[gui_url.socket] = REGISTERED_GUI_WIDGETS[gui_url.socket] or {}
|
||||||
table.insert(REGISTERED_GUI_WIDGETS[gui_url.socket], {
|
table.insert(REGISTERED_GUI_WIDGETS[gui_url.socket], {
|
||||||
@ -147,4 +147,5 @@ function M.register_gui_widget(druid)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -3,7 +3,7 @@ local druid = require("druid.druid")
|
|||||||
|
|
||||||
function init(self)
|
function init(self)
|
||||||
self.druid = druid.new(self)
|
self.druid = druid.new(self)
|
||||||
druid.register_gui_widget(self.druid)
|
druid.register_druid_as_widget(self.druid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -14,13 +14,13 @@ local utf8 = utf8 or utf8_lua
|
|||||||
---@field on_input_wrong fun(self: druid.input, button_node: node) Callback on wrong user input
|
---@field on_input_wrong fun(self: druid.input, button_node: node) Callback on wrong user input
|
||||||
|
|
||||||
---@class druid.input: druid.component
|
---@class druid.input: druid.component
|
||||||
---@field on_input_select event
|
---@field on_input_select event fun(self: druid.input, input: druid.input)
|
||||||
---@field on_input_unselect event
|
---@field on_input_unselect event fun(self: druid.input, text: string, input: druid.input)
|
||||||
---@field on_input_text event
|
---@field on_input_text event fun(self: druid.input)
|
||||||
---@field on_input_empty event
|
---@field on_input_empty event fun(self: druid.input)
|
||||||
---@field on_input_full event
|
---@field on_input_full event fun(self: druid.input)
|
||||||
---@field on_input_wrong event
|
---@field on_input_wrong event fun(self: druid.input)
|
||||||
---@field on_select_cursor_change event
|
---@field on_select_cursor_change event fun(self: druid.input, cursor_index: number, start_index: number, end_index: number)
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field text druid.text
|
---@field text druid.text
|
||||||
local M = component.create("input")
|
local M = component.create("input")
|
||||||
|
@ -700,7 +700,7 @@ end
|
|||||||
local hotkey = require("druid.extended.hotkey")
|
local hotkey = require("druid.extended.hotkey")
|
||||||
---Create Hotkey component
|
---Create Hotkey component
|
||||||
---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys
|
---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys
|
||||||
---@param callback function|nil The callback function
|
---@param callback function|event|nil The callback function
|
||||||
---@param callback_argument any|nil The argument to pass into the callback function
|
---@param callback_argument any|nil The argument to pass into the callback function
|
||||||
---@return druid.hotkey component Hotkey component
|
---@return druid.hotkey component Hotkey component
|
||||||
function M:new_hotkey(keys_array, callback, callback_argument)
|
function M:new_hotkey(keys_array, callback, callback_argument)
|
||||||
|
@ -30,14 +30,16 @@ function M:set_text_property(text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---@param text string
|
---@param text string|number
|
||||||
---@return widget.property_input
|
---@return widget.property_input
|
||||||
function M:set_text_value(text)
|
function M:set_text_value(text)
|
||||||
self.rich_input:set_text(text)
|
self.rich_input:set_text(tostring(text))
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param callback fun(self: widget.property_input, text: string)
|
||||||
|
---@param callback_context any
|
||||||
function M:on_change(callback, callback_context)
|
function M:on_change(callback, callback_context)
|
||||||
self.rich_input.input.on_input_unselect:subscribe(callback, callback_context)
|
self.rich_input.input.on_input_unselect:subscribe(callback, callback_context)
|
||||||
end
|
end
|
||||||
|
@ -8,6 +8,7 @@ local helper = require("druid.helper")
|
|||||||
---@field text_name druid.text
|
---@field text_name druid.text
|
||||||
---@field text_value druid.text
|
---@field text_value druid.text
|
||||||
---@field slider druid.slider
|
---@field slider druid.slider
|
||||||
|
---@field on_change_value event fun(value:number)
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user