add search engine - ringle
This commit is contained in:
@@ -195,12 +195,42 @@ static func setup_panel_hover_support(panel: PanelContainer, normal_styles: Dict
|
||||
panel.set_meta("hover_stylebox", hover_stylebox)
|
||||
panel.set_meta("normal_styles", normal_styles.duplicate(true))
|
||||
panel.set_meta("hover_styles", merged_hover_styles.duplicate(true))
|
||||
panel.set_meta("is_hovering", false)
|
||||
|
||||
# Connect mouse events
|
||||
panel.mouse_entered.connect(_on_panel_mouse_entered.bind(panel))
|
||||
panel.mouse_exited.connect(_on_panel_mouse_exited.bind(panel))
|
||||
panel.mouse_exited.connect(_on_panel_mouse_exited_with_delay.bind(panel))
|
||||
|
||||
_setup_child_hover_listeners(panel)
|
||||
|
||||
static func _setup_child_hover_listeners(panel: PanelContainer):
|
||||
for child in panel.get_children():
|
||||
_connect_child_hover_events(child, panel)
|
||||
|
||||
panel.child_entered_tree.connect(_on_child_added.bind(panel))
|
||||
|
||||
static func _connect_child_hover_events(child: Node, panel: PanelContainer):
|
||||
if child is Control:
|
||||
# Only connect if not already connected
|
||||
if not child.mouse_entered.is_connected(_on_child_mouse_entered.bind(panel)):
|
||||
child.mouse_entered.connect(_on_child_mouse_entered.bind(panel))
|
||||
if not child.mouse_exited.is_connected(_on_child_mouse_exited.bind(panel)):
|
||||
child.mouse_exited.connect(_on_child_mouse_exited.bind(panel))
|
||||
|
||||
for grandchild in child.get_children():
|
||||
_connect_child_hover_events(grandchild, panel)
|
||||
|
||||
static func _on_child_added(child: Node, panel: PanelContainer):
|
||||
_connect_child_hover_events(child, panel)
|
||||
|
||||
static func _on_child_mouse_entered(panel: PanelContainer):
|
||||
_on_panel_mouse_entered(panel)
|
||||
|
||||
static func _on_child_mouse_exited(panel: PanelContainer):
|
||||
panel.get_tree().create_timer(0.01).timeout.connect(func(): _check_panel_hover(panel))
|
||||
|
||||
static func _on_panel_mouse_entered(panel: PanelContainer):
|
||||
panel.set_meta("is_hovering", true)
|
||||
if panel.has_meta("hover_stylebox"):
|
||||
var hover_stylebox = panel.get_meta("hover_stylebox")
|
||||
panel.add_theme_stylebox_override("panel", hover_stylebox)
|
||||
@@ -210,15 +240,27 @@ static func _on_panel_mouse_entered(panel: PanelContainer):
|
||||
var transform_target = find_transform_target_for_panel(panel)
|
||||
StyleManager.apply_transform_properties_direct(transform_target, hover_styles)
|
||||
|
||||
static func _on_panel_mouse_exited(panel: PanelContainer):
|
||||
if panel.has_meta("normal_stylebox"):
|
||||
var normal_stylebox = panel.get_meta("normal_stylebox")
|
||||
panel.add_theme_stylebox_override("panel", normal_stylebox)
|
||||
static func _on_panel_mouse_exited_with_delay(panel: PanelContainer):
|
||||
panel.get_tree().create_timer(0.01).timeout.connect(func(): _check_panel_hover(panel))
|
||||
|
||||
static func _check_panel_hover(panel: PanelContainer):
|
||||
if not panel or not is_instance_valid(panel):
|
||||
return
|
||||
|
||||
if panel.has_meta("normal_styles"):
|
||||
var normal_styles = panel.get_meta("normal_styles")
|
||||
var transform_target = find_transform_target_for_panel(panel)
|
||||
StyleManager.apply_transform_properties_direct(transform_target, normal_styles)
|
||||
var mouse_pos = panel.get_global_mouse_position()
|
||||
var panel_rect = panel.get_global_rect()
|
||||
var is_mouse_over = panel_rect.has_point(mouse_pos)
|
||||
|
||||
if not is_mouse_over and panel.get_meta("is_hovering", false):
|
||||
panel.set_meta("is_hovering", false)
|
||||
if panel.has_meta("normal_stylebox"):
|
||||
var normal_stylebox = panel.get_meta("normal_stylebox")
|
||||
panel.add_theme_stylebox_override("panel", normal_stylebox)
|
||||
|
||||
if panel.has_meta("normal_styles"):
|
||||
var normal_styles = panel.get_meta("normal_styles")
|
||||
var transform_target = find_transform_target_for_panel(panel)
|
||||
StyleManager.apply_transform_properties_direct(transform_target, normal_styles)
|
||||
|
||||
static func find_transform_target_for_panel(panel: PanelContainer) -> Control:
|
||||
var parent = panel.get_parent()
|
||||
|
||||
@@ -64,6 +64,7 @@ static func apply_flex_container_properties(node, styles: Dictionary) -> void:
|
||||
if width_val == "full" or width_val == "100%":
|
||||
# For flex containers, w-full should expand to fill parent
|
||||
node.set_meta("should_fill_horizontal", true)
|
||||
node.set_meta("size_flags_set_by_style_manager", true)
|
||||
elif typeof(width_val) == TYPE_STRING and width_val.ends_with("%"):
|
||||
node.set_meta("custom_css_width_percentage", width_val)
|
||||
else:
|
||||
@@ -73,6 +74,7 @@ static func apply_flex_container_properties(node, styles: Dictionary) -> void:
|
||||
if height_val == "full":
|
||||
# For flex containers, h-full should expand to fill parent
|
||||
node.set_meta("should_fill_vertical", true)
|
||||
node.set_meta("size_flags_set_by_style_manager", true)
|
||||
elif typeof(height_val) == TYPE_STRING and height_val.ends_with("%"):
|
||||
node.set_meta("custom_css_height_percentage", height_val)
|
||||
else:
|
||||
|
||||
@@ -278,7 +278,7 @@ static func update_div_hover_styles(dom_node: Control, element: HTMLParser.HTMLE
|
||||
|
||||
if dom_node.mouse_entered.is_connected(BackgroundUtils._on_panel_mouse_entered):
|
||||
dom_node.mouse_entered.disconnect(BackgroundUtils._on_panel_mouse_entered)
|
||||
if dom_node.mouse_exited.is_connected(BackgroundUtils._on_panel_mouse_exited):
|
||||
dom_node.mouse_exited.disconnect(BackgroundUtils._on_panel_mouse_exited)
|
||||
if dom_node.mouse_exited.is_connected(BackgroundUtils._on_panel_mouse_exited_with_delay):
|
||||
dom_node.mouse_exited.disconnect(BackgroundUtils._on_panel_mouse_exited_with_delay)
|
||||
|
||||
update_element_text_content(dom_node, element, dom_parser)
|
||||
|
||||
@@ -640,6 +640,12 @@ static func add_element_methods(vm: LuauVM, lua_api: LuaAPI) -> void:
|
||||
vm.lua_pushcallable(LuaDOMUtils._element_hide_wrapper, "element.hide")
|
||||
vm.lua_setfield(-2, "hide")
|
||||
|
||||
vm.lua_pushcallable(LuaDOMUtils._element_focus_wrapper, "element.focus")
|
||||
vm.lua_setfield(-2, "focus")
|
||||
|
||||
vm.lua_pushcallable(LuaDOMUtils._element_unfocus_wrapper, "element.unfocus")
|
||||
vm.lua_setfield(-2, "unfocus")
|
||||
|
||||
_add_classlist_support(vm, lua_api)
|
||||
|
||||
vm.lua_newtable()
|
||||
@@ -1420,6 +1426,48 @@ static func _element_hide_wrapper(vm: LuauVM) -> int:
|
||||
|
||||
return 0
|
||||
|
||||
static func _element_focus_wrapper(vm: LuauVM) -> int:
|
||||
var lua_api = vm.get_meta("lua_api") as LuaAPI
|
||||
if not lua_api:
|
||||
vm.lua_pushboolean(false)
|
||||
return 1
|
||||
|
||||
vm.luaL_checktype(1, vm.LUA_TTABLE)
|
||||
|
||||
vm.lua_getfield(1, "_element_id")
|
||||
var element_id: String = vm.lua_tostring(-1)
|
||||
vm.lua_pop(1)
|
||||
|
||||
var operation = {
|
||||
"type": "focus_element",
|
||||
"element_id": element_id
|
||||
}
|
||||
|
||||
emit_dom_operation(lua_api, operation)
|
||||
vm.lua_pushboolean(true)
|
||||
return 1
|
||||
|
||||
static func _element_unfocus_wrapper(vm: LuauVM) -> int:
|
||||
var lua_api = vm.get_meta("lua_api") as LuaAPI
|
||||
if not lua_api:
|
||||
vm.lua_pushboolean(false)
|
||||
return 1
|
||||
|
||||
vm.luaL_checktype(1, vm.LUA_TTABLE)
|
||||
|
||||
vm.lua_getfield(1, "_element_id")
|
||||
var element_id: String = vm.lua_tostring(-1)
|
||||
vm.lua_pop(1)
|
||||
|
||||
var operation = {
|
||||
"type": "unfocus_element",
|
||||
"element_id": element_id
|
||||
}
|
||||
|
||||
emit_dom_operation(lua_api, operation)
|
||||
vm.lua_pushboolean(true)
|
||||
return 1
|
||||
|
||||
static func _element_create_tween_wrapper(vm: LuauVM) -> int:
|
||||
var lua_api = vm.get_meta("lua_api") as LuaAPI
|
||||
if not lua_api:
|
||||
|
||||
@@ -118,6 +118,12 @@ static func string_replace_all_handler(vm: LuauVM) -> int:
|
||||
|
||||
return 1
|
||||
|
||||
static func string_trim_handler(vm: LuauVM) -> int:
|
||||
var subject: String = vm.luaL_checkstring(1)
|
||||
var trimmed = subject.strip_edges()
|
||||
vm.lua_pushstring(trimmed)
|
||||
return 1
|
||||
|
||||
static func setup_regex_api(vm: LuauVM) -> void:
|
||||
vm.lua_newtable()
|
||||
|
||||
@@ -139,4 +145,7 @@ static func setup_regex_api(vm: LuauVM) -> void:
|
||||
vm.lua_pushcallable(string_replace_all_handler, "string.replaceAll")
|
||||
vm.lua_setfield(-2, "replaceAll")
|
||||
|
||||
vm.lua_pushcallable(string_trim_handler, "string.trim")
|
||||
vm.lua_setfield(-2, "trim")
|
||||
|
||||
vm.lua_pop(1)
|
||||
|
||||
@@ -53,6 +53,7 @@ func stop_lua_thread():
|
||||
while lua_thread.is_alive() and (Time.get_ticks_msec() - timeout_start) < 500:
|
||||
OS.delay_msec(10)
|
||||
|
||||
lua_thread.wait_to_finish()
|
||||
lua_thread = null
|
||||
|
||||
func execute_script_async(script_code: String):
|
||||
@@ -356,6 +357,7 @@ func _setup_additional_lua_apis():
|
||||
LuaAudioUtils.setup_audio_api(lua_vm)
|
||||
LuaCrumbsUtils.setup_crumbs_api(lua_vm)
|
||||
LuaRegexUtils.setup_regex_api(lua_vm)
|
||||
LuaURLUtils.setup_url_api(lua_vm)
|
||||
|
||||
func _table_tostring_handler(vm: LuauVM) -> int:
|
||||
vm.luaL_checktype(1, vm.LUA_TTABLE)
|
||||
|
||||
21
flumi/Scripts/Utils/Lua/URL.gd
Normal file
21
flumi/Scripts/Utils/Lua/URL.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
class_name LuaURLUtils
|
||||
extends RefCounted
|
||||
|
||||
static func url_encode_handler(vm: LuauVM) -> int:
|
||||
var input: String = vm.luaL_checkstring(1)
|
||||
var encoded = input.uri_encode()
|
||||
vm.lua_pushstring(encoded)
|
||||
return 1
|
||||
|
||||
static func url_decode_handler(vm: LuauVM) -> int:
|
||||
var input: String = vm.luaL_checkstring(1)
|
||||
var decoded = input.uri_decode()
|
||||
vm.lua_pushstring(decoded)
|
||||
return 1
|
||||
|
||||
static func setup_url_api(vm: LuauVM) -> void:
|
||||
vm.lua_pushcallable(url_encode_handler, "urlEncode")
|
||||
vm.lua_setglobal("urlEncode")
|
||||
|
||||
vm.lua_pushcallable(url_decode_handler, "urlDecode")
|
||||
vm.lua_setglobal("urlDecode")
|
||||
1
flumi/Scripts/Utils/Lua/URL.gd.uid
Normal file
1
flumi/Scripts/Utils/Lua/URL.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bjiiw0qfqg2he
|
||||
Reference in New Issue
Block a user