mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Refactor text setting methods and remove ldoc files
This commit is contained in:
parent
9a1cd795b8
commit
6b8bbe1970
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -29,7 +29,7 @@
|
||||
"utils/annotations_manual.lua"
|
||||
],
|
||||
"Lua.runtime.pathStrict": true,
|
||||
"Lua.diagnostics.libraryFiles": "Enable",
|
||||
"Lua.diagnostics.libraryFiles": "Disable",
|
||||
"Lua.runtime.version": "Lua 5.1",
|
||||
"Lua.workspace.library": [
|
||||
"~/Library/Application Support/Code/User/globalStorage/astronachos.defold",
|
||||
|
18
config.ld
18
config.ld
@ -1,18 +0,0 @@
|
||||
project='Druid'
|
||||
title='Defold Druid UI Framework'
|
||||
description='Documentation for Druid Framework'
|
||||
file={"./druid",
|
||||
exclude = {
|
||||
"./druid/styles/",
|
||||
"./druid/templates/",
|
||||
"./druid/annotations.lua",
|
||||
"./druid/custom/rich_text/module",
|
||||
}
|
||||
}
|
||||
package='druid'
|
||||
sort=true
|
||||
dir='./docs'
|
||||
style='!fixed'
|
||||
topics={}
|
||||
use_markdown_titles=true
|
||||
no_space_before_args=true
|
@ -485,7 +485,11 @@ end
|
||||
---@param key hash|string The action_id of the input key. Example: "key_space"
|
||||
---@return druid.button self
|
||||
function M:set_key_trigger(key)
|
||||
if type(key) == "string" then
|
||||
self.key_trigger = hash(key)
|
||||
else
|
||||
self.key_trigger = key
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
@ -498,22 +502,24 @@ function M:get_key_trigger()
|
||||
end
|
||||
|
||||
|
||||
--- Set function for additional check for button click availability
|
||||
---Set function for additional check for button click availability
|
||||
---@param check_function function|nil Should return true or false. If true - button can be pressed.
|
||||
---@param failure_callback function|nil Function will be called on button click, if check function return false
|
||||
---@return druid.button self
|
||||
function M:set_check_function(check_function, failure_callback)
|
||||
self._check_function = check_function
|
||||
self._failure_callback = failure_callback
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set Button mode to work inside user HTML5 interaction event.
|
||||
--
|
||||
-- It's required to make protected things like copy & paste text, show mobile keyboard, etc
|
||||
-- The HTML5 button's doesn't call any events except on_click event.
|
||||
--
|
||||
-- If the game is not HTML, html mode will be not enabled
|
||||
---Set Button mode to work inside user HTML5 interaction event.
|
||||
---
|
||||
---It's required to make protected things like copy & paste text, show mobile keyboard, etc
|
||||
---The HTML5 button's doesn't call any events except on_click event.
|
||||
---
|
||||
---If the game is not HTML, html mode will be not enabled
|
||||
---@param is_web_mode boolean|nil If true - button will be called inside html5 callback
|
||||
---@return druid.button self
|
||||
function M:set_web_user_interaction(is_web_mode)
|
||||
|
@ -206,9 +206,10 @@ end
|
||||
-- @tfield number|nil DRAG_DEADZONE Distance in pixels to start dragging. Default: 10
|
||||
-- @tfield boolean|nil NO_USE_SCREEN_KOEF If screen aspect ratio affects on drag values. Default: false
|
||||
function M:on_style_change(style)
|
||||
self.style = {}
|
||||
self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10
|
||||
self.style.NO_USE_SCREEN_KOEF = style.NO_USE_SCREEN_KOEF or false
|
||||
self.style = {
|
||||
DRAG_DEADZONE = style.DRAG_DEADZONE or 10,
|
||||
NO_USE_SCREEN_KOEF = style.NO_USE_SCREEN_KOEF or false,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
@ -27,9 +27,9 @@ local component = require("druid.component")
|
||||
---@field on_mouse_hover event
|
||||
---@field style table
|
||||
---@field click_zone node
|
||||
---@field private _is_hovered boolean
|
||||
---@field private _is_mouse_hovered boolean
|
||||
---@field private _is_enabled boolean
|
||||
---@field private _is_hovered boolean|nil
|
||||
---@field private _is_mouse_hovered boolean|nil
|
||||
---@field private _is_enabled boolean|nil
|
||||
---@field private _is_mobile boolean
|
||||
local M = component.create("hover")
|
||||
|
||||
@ -163,6 +163,11 @@ end
|
||||
-- no click events outside stencil node
|
||||
---@param zone node|string|nil Gui node
|
||||
function M:set_click_zone(zone)
|
||||
if not zone then
|
||||
self.click_zone = nil
|
||||
return
|
||||
end
|
||||
|
||||
self.click_zone = self:get_node(zone)
|
||||
end
|
||||
|
||||
|
@ -515,22 +515,22 @@ function M:set_pivot(pivot)
|
||||
end
|
||||
|
||||
|
||||
--- Return true, if text with line break
|
||||
---Return true, if text with line break
|
||||
---@return boolean Is text node with line break
|
||||
function M:is_multiline()
|
||||
return gui.get_line_break(self.node)
|
||||
end
|
||||
|
||||
|
||||
--- Set text adjust, refresh the current text visuals, if needed
|
||||
---Set text adjust, refresh the current text visuals, if needed
|
||||
---Values are: "downscale", "trim", "no_adjust", "downscale_limited",
|
||||
---"scroll", "scale_then_scroll", "trim_left", "scale_then_trim", "scale_then_trim_left"
|
||||
---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type
|
||||
---@param minimal_scale number|nil If pass nil - not use minimal scale
|
||||
---@param minimal_scale number|nil To remove minimal scale, use `text:set_minimal_scale(nil)`, if pass nil - not change minimal scale
|
||||
---@return druid.text self Current text instance
|
||||
function M:set_text_adjust(adjust_type, minimal_scale)
|
||||
self.adjust_type = adjust_type
|
||||
self._minimal_scale = minimal_scale
|
||||
self._minimal_scale = minimal_scale or self._minimal_scale
|
||||
self:set_text(self.last_value)
|
||||
|
||||
return self
|
||||
|
@ -21,18 +21,18 @@ local helper = require("druid.helper")
|
||||
|
||||
---@class druid.base_component
|
||||
---@field druid druid_instance Druid instance to create inner components
|
||||
---@field protected init fun(self:druid.base_component, ...)|nil
|
||||
---@field protected update fun(self:druid.base_component, dt:number)|nil
|
||||
---@field protected on_remove fun(self:druid.base_component)|nil
|
||||
---@field protected on_input fun(self:druid.base_component, action_id:number, action:table)|nil
|
||||
---@field protected on_message fun(self:druid.base_component, message_id:hash, message:table, sender:userdata)|nil
|
||||
---@field protected on_late_init fun(self:druid.base_component)|nil
|
||||
---@field protected on_focus_lost fun(self:druid.base_component)|nil
|
||||
---@field protected on_focus_gained fun(self:druid.base_component)|nil
|
||||
---@field protected on_style_change fun(self:druid.base_component, style: table)|nil
|
||||
---@field protected on_layout_change fun(self:druid.base_component)|nil
|
||||
---@field protected on_window_resized fun(self:druid.base_component, width:number, height:number)|nil
|
||||
---@field protected on_language_change fun(self:druid.base_component, language:string)|nil
|
||||
---@field init fun(self:druid.base_component, ...)|nil
|
||||
---@field update fun(self:druid.base_component, dt:number)|nil
|
||||
---@field on_remove fun(self:druid.base_component)|nil
|
||||
---@field on_input fun(self:druid.base_component, action_id:number, action:table)|nil
|
||||
---@field on_message fun(self:druid.base_component, message_id:hash, message:table, sender:userdata)|nil
|
||||
---@field on_late_init fun(self:druid.base_component)|nil
|
||||
---@field on_focus_lost fun(self:druid.base_component)|nil
|
||||
---@field on_focus_gained fun(self:druid.base_component)|nil
|
||||
---@field on_style_change fun(self:druid.base_component, style: table)|nil
|
||||
---@field on_layout_change fun(self:druid.base_component)|nil
|
||||
---@field on_window_resized fun(self:druid.base_component)|nil
|
||||
---@field on_language_change fun(self:druid.base_component)|nil
|
||||
---@field private _component druid.base_component.component
|
||||
---@field private _meta druid.base_component.meta
|
||||
local M = {}
|
||||
|
@ -181,7 +181,7 @@ function M.create(text, settings, style)
|
||||
outline = settings.outline,
|
||||
font = gui.get_font(settings.text_prefab),
|
||||
-- Image params
|
||||
---@type druid.rich_text.image
|
||||
---@type druid.rich_text.word.image
|
||||
image = nil,
|
||||
-- Tags
|
||||
br = nil,
|
||||
|
@ -76,6 +76,27 @@
|
||||
local component = require("druid.component")
|
||||
local rich_text = require("druid.custom.rich_text.module.rt")
|
||||
|
||||
---@class druid.rich_text.settings
|
||||
---@field parent node
|
||||
---@field size number
|
||||
---@field fonts table<string, string>
|
||||
---@field scale vector3
|
||||
---@field color vector4
|
||||
---@field shadow vector4
|
||||
---@field outline vector4
|
||||
---@field position vector3
|
||||
---@field image_pixel_grid_snap boolean
|
||||
---@field combine_words boolean
|
||||
---@field default_animation string
|
||||
---@field text_prefab node
|
||||
---@field adjust_scale number
|
||||
---@field default_texture string
|
||||
---@field is_multiline boolean
|
||||
---@field text_leading number
|
||||
---@field font hash
|
||||
---@field width number
|
||||
---@field height number
|
||||
|
||||
---@class druid.rich_text.word
|
||||
---@field node node
|
||||
---@field relative_scale number
|
||||
|
@ -51,13 +51,13 @@ local event = require("event.event")
|
||||
---@field private _cache table
|
||||
---@field private _data table
|
||||
---@field private _data_visual table
|
||||
---@field private top_index number
|
||||
---@field top_index number
|
||||
local M = component.create("data_list")
|
||||
|
||||
|
||||
--- The DataList constructor
|
||||
---@param scroll Scroll The Scroll instance for Data List component
|
||||
---@param grid StaticGrid The StaticGrid} or @{DynamicGrid instance for Data List component
|
||||
---@param scroll druid.scroll The Scroll instance for Data List component
|
||||
---@param grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component
|
||||
---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component])
|
||||
function M:init(scroll, grid, create_function)
|
||||
self.scroll = scroll
|
||||
|
@ -157,7 +157,7 @@ end
|
||||
|
||||
--- The Input constructor
|
||||
---@param click_node node Node to enabled input component
|
||||
---@param text_node node|Text Text node what will be changed on user input. You can pass text component instead of text node name Text
|
||||
---@param text_node node|druid.text Text node what will be changed on user input. You can pass text component instead of text node name Text
|
||||
---@param keyboard_type number|nil Gui keyboard type for input field
|
||||
function M:init(click_node, text_node, keyboard_type)
|
||||
self.druid = self:get_druid()
|
||||
|
@ -10,13 +10,13 @@
|
||||
-- @alias druid.swipe
|
||||
|
||||
--- Swipe node
|
||||
---@param node node
|
||||
--@param node node
|
||||
|
||||
--- Restriction zone
|
||||
---@param click_zone node|nil
|
||||
--@param click_zone node|nil
|
||||
|
||||
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
|
||||
---@param event event on_swipe
|
||||
--@param event event on_swipe
|
||||
|
||||
---
|
||||
|
||||
@ -59,7 +59,7 @@ local function check_swipe(self, action)
|
||||
|
||||
if is_swipe then
|
||||
local is_x_swipe = math.abs(dx) >= math.abs(dy)
|
||||
local swipe_side = false
|
||||
local swipe_side = "undefined"
|
||||
|
||||
if is_x_swipe and dx > 0 then
|
||||
swipe_side = "right"
|
||||
@ -164,6 +164,11 @@ end
|
||||
-- restrict events outside stencil node
|
||||
---@param zone node|string|nil Gui node
|
||||
function M:set_click_zone(zone)
|
||||
if not zone then
|
||||
self.click_zone = nil
|
||||
return
|
||||
end
|
||||
|
||||
self.click_zone = self:get_node(zone)
|
||||
end
|
||||
|
||||
|
@ -311,9 +311,9 @@ end
|
||||
|
||||
---Get size of node with scale multiplier
|
||||
---@param node node GUI node
|
||||
---@treturn vector3 Scaled size
|
||||
---@return vector3 scaled_size
|
||||
function M.get_scaled_size(node)
|
||||
return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node))
|
||||
return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node)) --[[@as vector3]]
|
||||
end
|
||||
|
||||
|
||||
|
@ -32,16 +32,11 @@ void main()
|
||||
var_perspective = perspective;
|
||||
var_uv_rotated = uv_rotated;
|
||||
|
||||
float perspective_y = position.z;
|
||||
|
||||
float scale_x = 1.0 - abs(perspective.x);
|
||||
float scale_y = 1.0 - abs(perspective_y);
|
||||
|
||||
mat4 transform = mat4(
|
||||
scale_x, 0, 0, perspective.z,
|
||||
0, scale_y, 0, perspective.w,
|
||||
1.0, 0, 0, 0.0,
|
||||
0, 1.0, 0, 0.0,
|
||||
0, 0, 1, 0,
|
||||
perspective.x, perspective_y, 0, 1.0
|
||||
0.0, position.z, 0, 1.0
|
||||
);
|
||||
|
||||
// Matrix Info = mat4(
|
||||
|
@ -1,2 +1,55 @@
|
||||
---@class druid.widget: druid.base_component
|
||||
---@field druid druid_instance
|
||||
|
||||
---@class GUITextMetrics
|
||||
---@field width number
|
||||
---@field height number
|
||||
---@field max_ascent number
|
||||
---@field max_descent number
|
||||
|
||||
---@class utf8
|
||||
---@field len fun(s: string):number
|
||||
---@field sub fun(s: string, start_index: number, length: number)
|
||||
---@field reverse fun()
|
||||
---@field char fun()
|
||||
---@field unicode fun()
|
||||
---@field gensub fun()
|
||||
---@field byte fun()
|
||||
---@field find fun()
|
||||
---@field match fun(s: string, m: string)
|
||||
---@field gmatch fun(s: string, m: string)
|
||||
---@field gsub fun()
|
||||
---@field dump fun()
|
||||
---@field format fun()
|
||||
---@field lower fun()
|
||||
---@field upper fun()
|
||||
---@field rep fun()
|
||||
|
||||
---@class action
|
||||
---@field value number The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement.
|
||||
---@field pressed boolean If the input was pressed this frame. This is not present for mouse movement.
|
||||
---@field released boolean If the input was released this frame. This is not present for mouse movement.
|
||||
---@field repeated boolean If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement.
|
||||
---@field x number The x value of a pointer device, if present.
|
||||
---@field y number The y value of a pointer device, if present.
|
||||
---@field screen_x number The screen space x value of a pointer device, if present.
|
||||
---@field screen_y number The screen space y value of a pointer device, if present.
|
||||
---@field dx number The change in x value of a pointer device, if present.
|
||||
---@field dy number The change in y value of a pointer device, if present.
|
||||
---@field screen_dx number The change in screen space x value of a pointer device, if present.
|
||||
---@field screen_dy number The change in screen space y value of a pointer device, if present.
|
||||
---@field gamepad number The index of the gamepad device that provided the input.
|
||||
---@field touch touch[] List of touch input, one element per finger, if present. See table below about touch input
|
||||
|
||||
---@class touch
|
||||
---@field id number A number identifying the touch input during its duration.
|
||||
---@field pressed boolean True if the finger was pressed this frame.
|
||||
---@field released boolean True if the finger was released this frame.
|
||||
---@field tap_count number Number of taps, one for single, two for double-tap, etc
|
||||
---@field x number The x touch location.
|
||||
---@field y number The y touch location.
|
||||
---@field dx number The change in x value.
|
||||
---@field dy number The change in y value.
|
||||
---@field acc_x number|nil Accelerometer x value (if present).
|
||||
---@field acc_y number|nil Accelerometer y value (if present).
|
||||
---@field acc_z number|nil Accelerometer z value (if present).
|
||||
|
@ -147,10 +147,9 @@ end
|
||||
|
||||
|
||||
---Check whitelists and blacklists for input components
|
||||
---@param self druid_instance
|
||||
---@param component druid.base_component
|
||||
---@return boolean
|
||||
local function can_use_input_component(self, component)
|
||||
function M:_can_use_input_component(component)
|
||||
local can_by_whitelist = true
|
||||
local can_by_blacklist = true
|
||||
|
||||
@ -166,13 +165,13 @@ local function can_use_input_component(self, component)
|
||||
end
|
||||
|
||||
|
||||
local function process_input(self, action_id, action, components)
|
||||
function M:_process_input(action_id, action, components)
|
||||
local is_input_consumed = false
|
||||
|
||||
for i = #components, 1, -1 do
|
||||
local component = components[i]
|
||||
local meta = component._meta
|
||||
if meta.input_enabled and can_use_input_component(self, component) then
|
||||
if meta.input_enabled and self:_can_use_input_component(component) then
|
||||
if not is_input_consumed then
|
||||
is_input_consumed = component:on_input(action_id, action) or false
|
||||
else
|
||||
@ -356,7 +355,7 @@ function M:on_input(action_id, action)
|
||||
|
||||
local components = self.components_interest[const.ON_INPUT]
|
||||
check_sort_input_stack(self, components)
|
||||
local is_input_consumed = process_input(self, action_id, action, components)
|
||||
local is_input_consumed = self:_process_input(action_id, action, components)
|
||||
|
||||
self._is_late_remove_enabled = false
|
||||
self:_clear_late_remove()
|
||||
@ -421,7 +420,7 @@ end
|
||||
---Set whitelist components for input processing.
|
||||
---If whitelist is not empty and component not contains in this list,
|
||||
---component will be not processed on input step
|
||||
---@param whitelist_components table|druid.base_component[]|nil The array of component to whitelist
|
||||
---@param whitelist_components table|druid.base_component[] The array of component to whitelist
|
||||
---@return druid_instance
|
||||
function M:set_whitelist(whitelist_components)
|
||||
if whitelist_components and whitelist_components._component then
|
||||
@ -441,7 +440,7 @@ end
|
||||
---Set blacklist components for input processing.
|
||||
---If blacklist is not empty and component contains in this list,
|
||||
---component will be not processed on input step DruidInstance
|
||||
---@param blacklist_components table|druid.base_component[]|nil The array of component to blacklist
|
||||
---@param blacklist_components table|druid.base_component[] The array of component to blacklist
|
||||
---@return druid_instance
|
||||
function M:set_blacklist(blacklist_components)
|
||||
if blacklist_components and blacklist_components._component then
|
||||
|
@ -24,7 +24,7 @@ end
|
||||
|
||||
---@param info string
|
||||
function M:set_debug_info(info)
|
||||
self.text_debug_info:set_to(info)
|
||||
self.text_debug_info:set_text(info)
|
||||
end
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ function M:set_gui_path(path)
|
||||
-- We need add "/" before path and replace .lua to .gui
|
||||
path = "/" .. path:gsub(".lua", ".gui")
|
||||
|
||||
self.text_gui_path:set_to(path)
|
||||
self.text_gui_path:set_text(path)
|
||||
end
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ end
|
||||
|
||||
function M:update_memory()
|
||||
local memory = collectgarbage("count")
|
||||
self.text_memory_amount:set_to(tostring(math.ceil(memory)))
|
||||
self.text_memory_amount:set_text(tostring(math.ceil(memory)))
|
||||
|
||||
local width = helper.centrate_nodes(2, unpack(self.nodes_memory))
|
||||
for index = 1, #self.nodes_memory do
|
||||
@ -102,8 +102,8 @@ function M:update_fps()
|
||||
end
|
||||
average_frame_time = average_frame_time / #self.fps_samples
|
||||
|
||||
self.text_fps_amount:set_to(tostring(math.ceil(1 / average_frame_time)))
|
||||
self.text_fps_min:set_to("/ " .. tostring(math.ceil(1 / max_frame_time)))
|
||||
self.text_fps_amount:set_text(tostring(math.ceil(1 / average_frame_time)))
|
||||
self.text_fps_min:set_text("/ " .. tostring(math.ceil(1 / max_frame_time)))
|
||||
|
||||
local width = helper.centrate_nodes(2, unpack(self.nodes_fps))
|
||||
self.group_fps:set_size(width, nil)
|
||||
@ -114,14 +114,14 @@ function M:update_components()
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local components = #self.druid.components_all
|
||||
|
||||
self.text_components_amount:set_to(tostring(components))
|
||||
self.text_components_amount:set_text(tostring(components))
|
||||
local width = helper.centrate_nodes(2, unpack(self.nodes_components))
|
||||
self.group_components:set_size(width, nil)
|
||||
end
|
||||
|
||||
|
||||
function M:update_events()
|
||||
self.text_events_amount:set_to(tostring(event.COUNTER))
|
||||
self.text_events_amount:set_text("unsupported")
|
||||
|
||||
local width = helper.centrate_nodes(2, unpack(self.nodes_events))
|
||||
for index = 1, #self.nodes_events do
|
||||
|
@ -33,7 +33,7 @@ end
|
||||
---@param callback fun(value:number):string
|
||||
function M:set_text_function(callback)
|
||||
self._text_function = callback
|
||||
self.text_value:set_to(self._text_function(self._value))
|
||||
self.text_value:set_text(self._text_function(self._value))
|
||||
end
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ function M:set_value(value, is_instant)
|
||||
|
||||
self._value = value
|
||||
self.slider:set(value, true)
|
||||
self.text_value:set_to(self._text_function(value))
|
||||
self.text_value:set_text(self._text_function(value))
|
||||
|
||||
if not is_instant then
|
||||
gui.set_alpha(self.selected, 1)
|
||||
@ -62,7 +62,7 @@ end
|
||||
|
||||
function M:_on_slider_change_by_user(value)
|
||||
self._value = value
|
||||
self.text_value:set_to(self._text_function(value))
|
||||
self.text_value:set_text(self._text_function(value))
|
||||
|
||||
gui.set_alpha(self.selected, 1)
|
||||
gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16)
|
||||
|
@ -51,7 +51,7 @@ end
|
||||
---@param instance button_component
|
||||
---@param data table
|
||||
function M:on_element_add(index, node, instance, data)
|
||||
instance.text:set_to("Data Item " .. index)
|
||||
instance.text:set_text("Data Item " .. index)
|
||||
instance.button.on_click:subscribe(self.on_button_click, self)
|
||||
instance:set_data(index)
|
||||
end
|
||||
|
@ -88,7 +88,7 @@ end
|
||||
|
||||
---@private
|
||||
function M:refresh_content(node, hint_text, pivot_point, content_pivot)
|
||||
self.text_hint:set_to(hint_text)
|
||||
self.text_hint:set_text(hint_text)
|
||||
local text_width, text_height = self.text_hint:get_text_size()
|
||||
|
||||
local panel_width = math.max(text_width, MIN_PANEL_WIDTH) + PANEL_MARGIN
|
||||
|
@ -3,8 +3,9 @@ local mock = require("deftest.mock.mock")
|
||||
local M = {}
|
||||
|
||||
-- Userdata type instead of script self
|
||||
---@return vector3|vector4
|
||||
function M.get_context()
|
||||
return vmath.vector()
|
||||
return vmath.vector({})
|
||||
end
|
||||
|
||||
|
||||
|
@ -17,6 +17,6 @@ function init(self)
|
||||
deftest.add(tests[i])
|
||||
end
|
||||
|
||||
local is_report = (sys.get_config("test.report") == "1")
|
||||
local is_report = (sys.get_config_int("test.report", 0) == 1)
|
||||
deftest.run({ coverage = { enabled = is_report } })
|
||||
end
|
||||
|
@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
## I am using Ldoc and my own Ldoc -> emmylua generator:
|
||||
## https://github.com/Insality/emmylua-from-ldoc-annotations
|
||||
|
||||
emmylua_generator_path=~/code/lua/emmylua-from-ldoc-annotations
|
||||
|
||||
echo "Update Ldoc"
|
||||
ldoc . --testing
|
||||
|
||||
echo ""
|
||||
echo "Update EmmyLua annotations"
|
||||
original_path=$(pwd)
|
||||
bash $emmylua_generator_path/export.sh $original_path
|
||||
mv $emmylua_generator_path/annotations.lua $original_path/druid/annotations.lua
|
||||
cat ./utils/annotations_manual.lua >> $original_path/druid/annotations.lua
|
||||
cp $original_path/utils/ldoc_fixed.css $original_path/docs/ldoc_fixed.css
|
@ -1,126 +0,0 @@
|
||||
-- Manual Annotations --
|
||||
|
||||
---@class druid.component: druid.base_component
|
||||
|
||||
---@class druid.rich_text.metrics
|
||||
---@field width number
|
||||
---@field height number
|
||||
---@field offset_x number|nil
|
||||
---@field offset_y number|nil
|
||||
---@field max_ascent number
|
||||
---@field max_descent number
|
||||
---@field node_size vector3|nil @For images only
|
||||
|
||||
---@class druid.rich_text.lines_metrics
|
||||
---@field text_width number
|
||||
---@field text_height number
|
||||
---@field lines table<number, druid.rich_text.metrics>
|
||||
|
||||
---@class druid.rich_text.word
|
||||
---@field node node
|
||||
---@field relative_scale number
|
||||
---@field color vector4
|
||||
---@field position vector3
|
||||
---@field offset vector3
|
||||
---@field scale vector3
|
||||
---@field size vector3
|
||||
---@field metrics druid.rich_text.metrics
|
||||
---@field pivot userdata @ The gui.PIVOT_* constant
|
||||
---@field text string
|
||||
---@field shadow vector4
|
||||
---@field outline vector4
|
||||
---@field font string
|
||||
---@field image druid.rich_text.image
|
||||
---@field default_animation string
|
||||
---@field anchor number
|
||||
---@field br boolean
|
||||
---@field nobr boolean
|
||||
---@field source_text string
|
||||
---@field image_color vector4
|
||||
---@field text_color vector4
|
||||
|
||||
---@class druid.rich_text.image
|
||||
---@field texture string
|
||||
---@field anim string
|
||||
---@field width number
|
||||
---@field height number
|
||||
|
||||
---@class druid.rich_text.settings
|
||||
---@field parent node
|
||||
---@field size number
|
||||
---@field fonts table<string, string>
|
||||
---@field scale vector3
|
||||
---@field color vector4
|
||||
---@field shadow vector4
|
||||
---@field outline vector4
|
||||
---@field position vector3
|
||||
---@field image_pixel_grid_snap boolean
|
||||
---@field combine_words boolean
|
||||
---@field default_animation string
|
||||
---@field text_prefab node
|
||||
---@field adjust_scale number
|
||||
---@field default_texture string
|
||||
---@field is_multiline boolean
|
||||
---@field text_leading number
|
||||
---@field font hash
|
||||
---@field width number
|
||||
---@field height number
|
||||
|
||||
---@class GUITextMetrics
|
||||
---@field width number
|
||||
---@field height number
|
||||
---@field max_ascent number
|
||||
---@field max_descent number
|
||||
|
||||
---@class utf8
|
||||
---@field len fun(s: string):number
|
||||
---@field sub fun(s: string, start_index: number, length: number)
|
||||
---@field reverse fun()
|
||||
---@field char fun()
|
||||
---@field unicode fun()
|
||||
---@field gensub fun()
|
||||
---@field byte fun()
|
||||
---@field find fun()
|
||||
---@field match fun(s: string, m: string)
|
||||
---@field gmatch fun(s: string, m: string)
|
||||
---@field gsub fun()
|
||||
---@field dump fun()
|
||||
---@field format fun()
|
||||
---@field lower fun()
|
||||
---@field upper fun()
|
||||
---@field rep fun()
|
||||
|
||||
|
||||
---Add generics to some functions.
|
||||
|
||||
---Create new component.
|
||||
---@generic T: druid.base_component
|
||||
---@param self druid_instance
|
||||
---@param component T Component module
|
||||
---@param ... any Other component params to pass it to component:init function
|
||||
---@return T Component instance
|
||||
function druid_instance.new(self, component, ...) end
|
||||
|
||||
--- Set current component style table.
|
||||
--- Invoke `on_style_change` on component, if exist. Component should handle their style changing and store all style params
|
||||
---@generic T: druid.base_component
|
||||
---@param self T BaseComponent
|
||||
---@param druid_style table|nil Druid style module
|
||||
---@return T BaseComponent
|
||||
function druid__base_component.set_style(self, druid_style) end
|
||||
|
||||
--- Set component template name.
|
||||
--- Use on all your custom components with GUI layouts used as templates. It will check parent template name to build full template name in self:get_node()
|
||||
---@generic T: druid.base_component
|
||||
---@param self T BaseComponent
|
||||
---@param template string BaseComponent template name
|
||||
---@return T BaseComponent
|
||||
function druid__base_component.set_template(self, template) end
|
||||
|
||||
--- Set current component nodes.
|
||||
--- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree.
|
||||
---@generic T: druid.base_component
|
||||
---@param self T BaseComponent
|
||||
---@param nodes table BaseComponent nodes table
|
||||
---@return T BaseComponent
|
||||
function druid__base_component.set_nodes(self, nodes) end
|
@ -1,311 +0,0 @@
|
||||
/* BEGIN RESET
|
||||
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 2.8.2r1
|
||||
*/
|
||||
html {
|
||||
color: #000;
|
||||
background: #FFF;
|
||||
}
|
||||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
fieldset,img {
|
||||
border: 0;
|
||||
}
|
||||
address,caption,cite,code,dfn,em,strong,th,var,optgroup {
|
||||
font-style: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
del,ins {
|
||||
text-decoration: none;
|
||||
}
|
||||
li {
|
||||
margin-left: 20px;
|
||||
}
|
||||
caption,th {
|
||||
text-align: left;
|
||||
}
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
font-size: 100%;
|
||||
font-weight: bold;
|
||||
}
|
||||
q:before,q:after {
|
||||
content: '';
|
||||
}
|
||||
abbr,acronym {
|
||||
border: 0;
|
||||
font-variant: normal;
|
||||
}
|
||||
sup {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
sub {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
legend {
|
||||
color: #000;
|
||||
}
|
||||
input,button,textarea,select,optgroup,option {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
font-style: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
input,button,textarea,select {*font-size:100%;
|
||||
}
|
||||
/* END RESET */
|
||||
|
||||
body {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
font-family: arial, helvetica, geneva, sans-serif;
|
||||
background-color: #ffffff; margin: 0px;
|
||||
}
|
||||
|
||||
code, tt { font-family: monospace; font-size: 1.1em; }
|
||||
span.parameter { font-family:monospace; }
|
||||
span.parameter:after { content:":"; }
|
||||
span.types:before { content:"("; }
|
||||
span.types:after { content:")"; }
|
||||
.type { font-weight: bold; font-style:italic }
|
||||
|
||||
body, p, td, th { font-size: .95em; line-height: 1.2em;}
|
||||
|
||||
p, ul { margin: 10px 0 0 0px;}
|
||||
|
||||
strong { font-weight: bold;}
|
||||
|
||||
em { font-style: italic;}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
margin: 0 0 20px 0;
|
||||
}
|
||||
h2, h3, h4 { margin: 15px 0 10px 0; }
|
||||
h2 { font-size: 1.25em; }
|
||||
h3 { font-size: 1.15em; }
|
||||
h4 { font-size: 1.06em; }
|
||||
|
||||
a:link { font-weight: bold; color: #004080; text-decoration: none; }
|
||||
a:visited { font-weight: bold; color: #006699; text-decoration: none; }
|
||||
a:link:hover { text-decoration: underline; }
|
||||
|
||||
hr {
|
||||
color:#cccccc;
|
||||
background: #00007f;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
blockquote { margin-left: 3em; }
|
||||
|
||||
ul { list-style-type: disc; }
|
||||
|
||||
p.name {
|
||||
font-family: "Andale Mono", monospace;
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: rgb(245, 245, 245);
|
||||
border: 1px solid #C0C0C0; /* silver */
|
||||
padding: 10px;
|
||||
margin: 10px 0 10px 0;
|
||||
overflow: auto;
|
||||
font-family: "Andale Mono", monospace;
|
||||
}
|
||||
|
||||
pre.example {
|
||||
font-size: .85em;
|
||||
}
|
||||
|
||||
table.index { border: 1px #00007f; }
|
||||
table.index td { text-align: left; vertical-align: top; }
|
||||
|
||||
#container {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#product {
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#product big {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#main {
|
||||
background-color:#FFFFFF; // #f0f0f0;
|
||||
border-left: 1px solid #cccccc;
|
||||
}
|
||||
|
||||
#navigation {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
float: left;
|
||||
width: 14em;
|
||||
vertical-align: top;
|
||||
background-color:#FFFFFF; // #f0f0f0;
|
||||
border-right: 2px solid #cccccc;
|
||||
overflow: visible;
|
||||
overflow-y: scroll;
|
||||
height: 100%;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
#navigation h2 {
|
||||
background-color:#FFFFFF;//:#e7e7e7;
|
||||
font-size:1.1em;
|
||||
color:#000000;
|
||||
text-align: left;
|
||||
padding:0.2em;
|
||||
border-bottom:1px solid #dddddd;
|
||||
}
|
||||
|
||||
#navigation ul
|
||||
{
|
||||
font-size:1em;
|
||||
list-style-type: none;
|
||||
margin: 1px 1px 10px 1px;
|
||||
}
|
||||
|
||||
#navigation li {
|
||||
text-indent: -1em;
|
||||
display: block;
|
||||
margin: 3px 0px 0px 22px;
|
||||
}
|
||||
|
||||
#navigation li li a {
|
||||
margin: 0px 3px 0px -1em;
|
||||
}
|
||||
|
||||
#content {
|
||||
margin-left: 14em;
|
||||
padding: 1em;
|
||||
padding-left: 2em;
|
||||
width: 900px;
|
||||
border-left: 2px solid #cccccc;
|
||||
// border-right: 2px solid #cccccc;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#about {
|
||||
clear: both;
|
||||
padding-left: 1em;
|
||||
margin-left: 14em; // avoid the damn sidebar!
|
||||
border-top: 2px solid #cccccc;
|
||||
border-left: 2px solid #cccccc;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body {
|
||||
font: 12pt "Times New Roman", "TimeNR", Times, serif;
|
||||
}
|
||||
a { font-weight: bold; color: #004080; text-decoration: underline; }
|
||||
|
||||
#main {
|
||||
background-color: #ffffff;
|
||||
border-left: 0px;
|
||||
}
|
||||
|
||||
#container {
|
||||
margin-left: 2%;
|
||||
margin-right: 2%;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#content {
|
||||
padding: 1em;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#navigation {
|
||||
display: none;
|
||||
}
|
||||
pre.example {
|
||||
font-family: "Andale Mono", monospace;
|
||||
font-size: 10pt;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
}
|
||||
|
||||
table.module_list {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.module_list td {
|
||||
border-width: 1px;
|
||||
padding: 3px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
}
|
||||
table.module_list td.name { background-color: #f0f0f0; ; min-width: 200px; }
|
||||
table.module_list td.summary { width: 100%; }
|
||||
|
||||
table.function_list {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.function_list td {
|
||||
border-width: 1px;
|
||||
padding: 3px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
}
|
||||
table.function_list td.name { background-color: #f6f6ff; ; min-width: 200px; }
|
||||
table.function_list td.summary { width: 100%; }
|
||||
|
||||
dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;}
|
||||
dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;}
|
||||
dl.table h3, dl.function h3 {font-size: .95em;}
|
||||
|
||||
ul.nowrap {
|
||||
overflow:auto;
|
||||
whitespace:nowrap;
|
||||
}
|
||||
|
||||
/* stop sublists from having initial vertical space */
|
||||
ul ul { margin-top: 0px; }
|
||||
ol ul { margin-top: 0px; }
|
||||
ol ol { margin-top: 0px; }
|
||||
ul ol { margin-top: 0px; }
|
||||
|
||||
/* make the target distinct; helps when we're navigating to a function */
|
||||
a:target + * {
|
||||
background-color: #FF9;
|
||||
}
|
||||
|
||||
|
||||
/* styles for prettification of source */
|
||||
pre .comment { color: #558817; }
|
||||
pre .constant { color: #a8660d; }
|
||||
pre .escape { color: #844631; }
|
||||
pre .keyword { color: #aa5050; font-weight: bold; }
|
||||
pre .library { color: #0e7c6b; }
|
||||
pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
|
||||
pre .string { color: #8080ff; }
|
||||
pre .number { color: #f8660d; }
|
||||
pre .operator { color: #2239a8; font-weight: bold; }
|
||||
pre .preprocessor, pre .prepro { color: #a33243; }
|
||||
pre .global { color: #800080; }
|
||||
pre .user-keyword { color: #800080; }
|
||||
pre .prompt { color: #558817; }
|
||||
pre .url { color: #272fc2; text-decoration: underline; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user