mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 02:17:52 +02:00
Update examples
This commit is contained in:
parent
7640e207a4
commit
b053b5044b
@ -1,18 +1,16 @@
|
||||
local component = require("druid.component")
|
||||
local helper = require("druid.helper")
|
||||
local event = require("event.event")
|
||||
|
||||
---@class examples.rich_text_tags_custom: druid.component
|
||||
---@field druid druid.instance
|
||||
---@field rich_text druid.rich_text
|
||||
local M = component.create("rich_text_tags_custom")
|
||||
---@class examples.rich_text_tags_custom: druid.widget
|
||||
---@field rich_text_link druid.rich_text
|
||||
---@field rich_text_characters druid.rich_text
|
||||
---@field rich_text_custom druid.rich_text
|
||||
---@field position table
|
||||
---@field on_link_click event
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
do -- Init rich text with links example
|
||||
self.rich_text_link = self.druid:new_rich_text("rich_text_link") --[[@as druid.rich_text]]
|
||||
self.rich_text_link:set_text("Hello, I'm a <custom_link><color=A1D7F5>Custom Link</color></custom_link>")
|
||||
|
@ -1,17 +1,15 @@
|
||||
local event = require("event.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class examples.data_list_add_remove_clear: druid.component
|
||||
---@field druid druid.instance
|
||||
---@class examples.data_list_add_remove_clear: druid.widget
|
||||
---@field prefab node
|
||||
---@field scroll druid.scroll
|
||||
---@field grid druid.grid
|
||||
---@field data_list druid.data_list
|
||||
local M = component.create("data_list_add_remove_clear")
|
||||
---@field on_item_click event
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.prefab = self:get_node("prefab")
|
||||
gui.set_enabled(self.prefab, false)
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
local event = require("event.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class examples.data_list_basic: druid.component
|
||||
---@field druid druid.instance
|
||||
local M = component.create("data_list_basic")
|
||||
---@class examples.data_list_basic: druid.widget
|
||||
---@field prefab node
|
||||
---@field scroll druid.scroll
|
||||
---@field grid druid.grid
|
||||
---@field data_list druid.data_list
|
||||
---@field on_item_click event
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.prefab = self:get_node("prefab")
|
||||
gui.set_enabled(self.prefab, false)
|
||||
|
||||
|
@ -1,15 +1,12 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class examples.data_list_horizontal_basic: druid.component
|
||||
---@field druid druid.instance
|
||||
local M = component.create("data_list_horizontal_basic")
|
||||
---@class examples.data_list_horizontal_basic: druid.widget
|
||||
---@field prefab node
|
||||
---@field scroll druid.scroll
|
||||
---@field grid druid.grid
|
||||
---@field data_list druid.data_list
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.prefab = self:get_node("prefab")
|
||||
gui.set_enabled(self.prefab, false)
|
||||
|
||||
|
@ -1,17 +1,12 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class examples.button_component: druid.component
|
||||
---@class examples.button_component: druid.widget
|
||||
---@field root node
|
||||
---@field druid druid.instance
|
||||
---@field text druid.text
|
||||
---@field button druid.button
|
||||
---@field data any
|
||||
local M = component.create("button_component")
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
|
||||
self.button = self.druid:new_button(self.root)
|
||||
|
@ -1,18 +1,17 @@
|
||||
local event = require("event.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
local button_component = require("example.examples.data_list.cache_with_component.button_component")
|
||||
|
||||
---@class examples.data_list_cache_with_component: druid.component
|
||||
---@field druid druid.instance
|
||||
local M = component.create("data_list_cache_with_component")
|
||||
---@class examples.data_list_cache_with_component: druid.widget
|
||||
---@field prefab node
|
||||
---@field scroll druid.scroll
|
||||
---@field grid druid.grid
|
||||
---@field data_list druid.data_list
|
||||
---@field on_item_click event
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.prefab = self:get_node("button_component/root")
|
||||
gui.set_enabled(self.prefab, false)
|
||||
|
||||
@ -39,7 +38,7 @@ end
|
||||
function M:create_item_callback(item_data, index)
|
||||
local nodes = gui.clone_tree(self.prefab)
|
||||
|
||||
local instance = self.druid:new(button_component, "button_component", nodes)
|
||||
local instance = self.druid:new_widget(button_component, "button_component", nodes)
|
||||
gui.set_enabled(instance.root, true)
|
||||
|
||||
return instance.root, instance
|
||||
|
@ -1,21 +1,29 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class examples.gamepad_tester: druid.component
|
||||
---@class examples.gamepad_tester: druid.widget
|
||||
---@field root node
|
||||
---@field buttons druid.button
|
||||
---@field buttons_system druid.button
|
||||
---@field button_left_bump druid.button
|
||||
---@field button_right_bump druid.button
|
||||
---@field druid druid.instance
|
||||
local M = component.create("gamepad_tester")
|
||||
---@field button_left druid.button
|
||||
---@field button_right druid.button
|
||||
---@field button_up druid.button
|
||||
---@field button_down druid.button
|
||||
---@field button_x druid.button
|
||||
---@field button_b druid.button
|
||||
---@field button_y druid.button
|
||||
---@field button_a druid.button
|
||||
---@field button_l1 druid.button
|
||||
---@field button_r1 druid.button
|
||||
---@field button_stick_left druid.button
|
||||
---@field button_stick_right druid.button
|
||||
---@field button_start druid.button
|
||||
---@field button_back druid.button
|
||||
---@field trigger_l2 druid.progress
|
||||
---@field trigger_r2 druid.progress
|
||||
---@field stick_left node
|
||||
---@field stick_right node
|
||||
local M = {}
|
||||
|
||||
local STICK_DISTANCE = 50
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
|
||||
self.button_left = self.druid:new_button("button_left/button"):set_key_trigger("gamepad_lpad_left")
|
||||
|
@ -1,25 +1,24 @@
|
||||
local component = require("druid.component")
|
||||
local on_screen_input = require("example.examples.gamepad.on_screen_control.on_screen_input")
|
||||
|
||||
---@class examples.on_screen_control: druid.component
|
||||
---@field druid druid.instance
|
||||
---@class examples.on_screen_control: druid.widget
|
||||
---@field on_screen_input examples.on_screen_input
|
||||
local M = component.create("on_screen_control")
|
||||
---@field character node
|
||||
---@field character_position vector3
|
||||
---@field character_eye_left node
|
||||
---@field character_eye_right node
|
||||
local M = {}
|
||||
|
||||
local CHARACTER_SPEED = 700
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.character = self:get_node("character")
|
||||
self.character_position = gui.get_position(self.character)
|
||||
|
||||
self.character_eye_left = self:get_node("eye_left")
|
||||
self.character_eye_right = self:get_node("eye_right")
|
||||
|
||||
self.on_screen_input = self.druid:new(on_screen_input, "on_screen_input")
|
||||
self.on_screen_input = self.druid:new_widget(on_screen_input, "on_screen_input")
|
||||
|
||||
self.on_screen_input.on_action:subscribe(self.on_action_button, self)
|
||||
self.on_screen_input.on_movement:subscribe(self.on_movement, self)
|
||||
|
@ -1,22 +1,25 @@
|
||||
local const = require("druid.const")
|
||||
local event = require("event.event")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class examples.on_screen_input: druid.component
|
||||
---@field druid druid.instance
|
||||
---@class examples.on_screen_input: druid.widget
|
||||
---@field button_action node
|
||||
---@field on_screen_control node
|
||||
---@field stick_root node
|
||||
---@field stick_position vector3
|
||||
---@field on_action event @()
|
||||
---@field on_movement event @(x: number, y: number, dt: number) X/Y values are in range -1..1
|
||||
---@field on_movement_stop event @()
|
||||
local M = component.create("on_screen_input")
|
||||
---@field is_multitouch boolean
|
||||
---@field _is_stick_drag boolean|number
|
||||
---@field _prev_x number
|
||||
---@field _prev_y number
|
||||
local M = {}
|
||||
|
||||
local STICK_DISTANCE = 80
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.button_action = self:get_node("on_screen_button")
|
||||
self.on_screen_control = self:get_node("on_screen_stick/root")
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
local layout = require("druid.extended.layout")
|
||||
|
||||
---@class examples.basic_layout: druid.component
|
||||
---@field druid druid.instance
|
||||
---@class examples.basic_layout: druid.widget
|
||||
---@field root node
|
||||
local M = component.create("basic_layout")
|
||||
---@field layout druid.layout
|
||||
---@field prefab node
|
||||
---@field nodes table<number, node>
|
||||
local M = {}
|
||||
|
||||
local PIVOTS = {
|
||||
gui.PIVOT_CENTER,
|
||||
@ -20,11 +21,7 @@ local PIVOTS = {
|
||||
}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
self.layout = self.druid:new(layout, "layout", "horizontal_wrap")
|
||||
|
||||
|
@ -1,28 +1,28 @@
|
||||
local panthera = require("panthera.panthera")
|
||||
local component = require("druid.component")
|
||||
local helper = require("druid.helper")
|
||||
local event = require("event.event")
|
||||
|
||||
local character_animation_blend = require("example.examples.panthera.animation_blend.character_animation_blend")
|
||||
|
||||
---@class examples.animation_blend: druid.component
|
||||
---@class examples.animation_blend: druid.widget
|
||||
---@field root node
|
||||
---@field druid druid.instance
|
||||
local M = component.create("animation_blend")
|
||||
---@field root_size vector3
|
||||
---@field animation_idle panthera.instance
|
||||
---@field animation_vertical panthera.instance
|
||||
---@field animation_horizontal panthera.instance
|
||||
---@field rich_text druid.rich_text
|
||||
---@field on_update event
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
self.root_size = gui.get_size(self.root)
|
||||
self.druid:new_lang_text("text_hint", "ui_example_panthera_animation_blend_hint")
|
||||
|
||||
self.animation_idle = panthera.create_gui(character_animation_blend, self:get_template(), nodes)
|
||||
self.animation_vertical = panthera.create_gui(character_animation_blend, self:get_template(), nodes)
|
||||
self.animation_horizontal = panthera.create_gui(character_animation_blend, self:get_template(), nodes)
|
||||
self.animation_idle = panthera.create_gui(character_animation_blend, self:get_template(), self:get_nodes())
|
||||
self.animation_vertical = panthera.create_gui(character_animation_blend, self:get_template(), self:get_nodes())
|
||||
self.animation_horizontal = panthera.create_gui(character_animation_blend, self:get_template(), self:get_nodes())
|
||||
|
||||
panthera.play(self.animation_idle, "idle", {
|
||||
is_loop = true,
|
||||
|
@ -1,19 +1,15 @@
|
||||
local panthera = require("panthera.panthera")
|
||||
local component = require("druid.component")
|
||||
|
||||
local basic_animation_panthera = require("example.examples.panthera.basic_animation.basic_animation_panthera")
|
||||
|
||||
---@class examples.basic_animation: druid.component
|
||||
---@field druid druid.instance
|
||||
local M = component.create("basic_animation")
|
||||
---@class examples.basic_animation: druid.widget
|
||||
---@field animation panthera.instance
|
||||
---@field button druid.button
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
self.animation = panthera.create_gui(basic_animation_panthera, self:get_template(), nodes)
|
||||
function M:init()
|
||||
self.animation = panthera.create_gui(basic_animation_panthera, self:get_template(), self:get_nodes())
|
||||
|
||||
self.button = self.druid:new_button("button/root", function()
|
||||
panthera.play(self.animation, "on_click", {
|
||||
|
@ -1,23 +1,20 @@
|
||||
local component = require("druid.component")
|
||||
local panthera = require("panthera.panthera")
|
||||
|
||||
local window_animation_panthera = require("example.examples.windows.window_animation_panthera")
|
||||
|
||||
---@class examples.window_confirmation: druid.component
|
||||
---@field druid druid.instance
|
||||
---@class examples.window_confirmation: druid.widget
|
||||
---@field text_header druid.lang_text
|
||||
---@field text_button_accept druid.lang_text
|
||||
---@field text_button_decline druid.lang_text
|
||||
---@field text_description druid.lang_text
|
||||
---@field button_close druid.button
|
||||
local M = component.create("window_confirmation")
|
||||
---@field button_accept druid.button
|
||||
---@field button_decline druid.button
|
||||
---@field animation panthera.instance
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.text_header = self.druid:new_lang_text("text_header", "ui_confirmation") --[[@as druid.lang_text]]
|
||||
self.text_button_accept = self.druid:new_lang_text("button_accept/text", "ui_accept") --[[@as druid.lang_text]]
|
||||
self.text_button_decline = self.druid:new_lang_text("button_decline/text", "ui_decline") --[[@as druid.lang_text]]
|
||||
@ -27,7 +24,7 @@ function M:init(template, nodes)
|
||||
self.button_accept = self.druid:new_button("button_accept/root")
|
||||
self.button_decline = self.druid:new_button("button_decline/root")
|
||||
|
||||
self.animation = panthera.create_gui(window_animation_panthera, self:get_template(), nodes)
|
||||
self.animation = panthera.create_gui(window_animation_panthera, self:get_template(), self:get_nodes())
|
||||
panthera.play(self.animation, "open")
|
||||
end
|
||||
|
||||
|
@ -1,22 +1,18 @@
|
||||
local component = require("druid.component")
|
||||
local panthera = require("panthera.panthera")
|
||||
|
||||
local window_animation_panthera = require("example.examples.windows.window_animation_panthera")
|
||||
|
||||
---@class examples.window_info: druid.component
|
||||
---@class examples.window_info: druid.widget
|
||||
---@field text_header druid.lang_text
|
||||
---@field text_button_accept druid.lang_text
|
||||
---@field text_description druid.lang_text
|
||||
---@field button_close druid.button
|
||||
---@field druid druid.instance
|
||||
local M = component.create("window_info")
|
||||
---@field button_accept druid.button
|
||||
---@field animation panthera.instance
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.text_header = self.druid:new_lang_text("text_header", "ui_information") --[[@as druid.lang_text]]
|
||||
self.text_button_accept = self.druid:new_lang_text("button_accept/text", "ui_accept") --[[@as druid.lang_text]]
|
||||
self.text_description = self.druid:new_lang_text("text") --[[@as druid.lang_text]]
|
||||
@ -24,7 +20,7 @@ function M:init(template, nodes)
|
||||
self.button_close = self.druid:new_button("button_close", self.on_button_close)
|
||||
self.button_accept = self.druid:new_button("button_accept/root")
|
||||
|
||||
self.animation = panthera.create_gui(window_animation_panthera, self:get_template(), nodes)
|
||||
self.animation = panthera.create_gui(window_animation_panthera, self:get_template(), self:get_nodes())
|
||||
panthera.play(self.animation, "open")
|
||||
end
|
||||
|
||||
|
@ -1,30 +1,27 @@
|
||||
local lang = require("lang.lang")
|
||||
local druid = require("druid.druid")
|
||||
local event = require("event.event")
|
||||
local component = require("druid.component")
|
||||
local panthera = require("panthera.panthera")
|
||||
|
||||
local window_animation_panthera = require("example.examples.windows.window_animation_panthera")
|
||||
|
||||
---@class examples.window_language: druid.component
|
||||
---@class examples.window_language: druid.widget
|
||||
---@field text_header druid.text
|
||||
---@field button_close druid.button
|
||||
---@field druid druid.instance
|
||||
---@field lang_buttons table<string, druid.button>
|
||||
---@field grid druid.grid
|
||||
---@field on_language_change event
|
||||
local M = component.create("window_language")
|
||||
---@field animation panthera.instance
|
||||
local M = {}
|
||||
|
||||
|
||||
---Color: #F0FBFF
|
||||
local DEFAULT_LANGUAGE_COLOR = vmath.vector4(240/255, 251/255, 255/255, 1.0)
|
||||
---Color: #E6DF9F
|
||||
local SELECTED_LANGUAGE_COLOR = vmath.vector4(230/255, 223/255, 159/255, 1.0)
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.lang_buttons = {}
|
||||
self.created_nodes = {}
|
||||
self.prefab = self:get_node("button_prefab")
|
||||
|
Loading…
x
Reference in New Issue
Block a user