From 4ecacaec904cda56ee67c311a00333dcf36722d6 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 10 May 2024 15:45:09 +0200 Subject: [PATCH] Update to c08687556803f36dc8116a82eae87cd3cdac5fd8 --- dist/example.png.import | 6 +- dist/sui.png.import | 6 +- fonts/FiraCode/Bold.ttf.import | 6 +- fonts/FiraCode/Light.ttf.import | 6 +- fonts/FiraCode/Medium.ttf.import | 6 +- fonts/FiraCode/Regular.ttf.import | 6 +- fonts/FiraCode/Retina.ttf.import | 6 +- fonts/Jost/Jost-Black.ttf.import | 6 +- fonts/Jost/Jost-BlackItalic.ttf.import | 6 +- fonts/Jost/Jost-Bold.ttf.import | 6 +- fonts/Jost/Jost-BoldItalic.ttf.import | 6 +- fonts/Jost/Jost-Book.ttf.import | 6 +- fonts/Jost/Jost-BookItalic.ttf.import | 6 +- fonts/Jost/Jost-Hairline.ttf.import | 6 +- fonts/Jost/Jost-HairlineItalic.ttf.import | 6 +- fonts/Jost/Jost-Heavy.ttf.import | 6 +- fonts/Jost/Jost-HeavyItalic.ttf.import | 6 +- fonts/Jost/Jost-Light.ttf.import | 6 +- fonts/Jost/Jost-LightItalic.ttf.import | 6 +- fonts/Jost/Jost-Medium.ttf.import | 6 +- fonts/Jost/Jost-MediumItalic.ttf.import | 6 +- fonts/Jost/Jost-Semi.ttf.import | 6 +- fonts/Jost/Jost-SemiItalic.ttf.import | 6 +- fonts/Jost/Jost-Thin.ttf.import | 6 +- fonts/Jost/Jost-ThinItalic.ttf.import | 6 +- plugin.cfg | 7 + plugin.gd | 10 + scenesrc/SuiHeader.tscn | 18 +- scenesrc/SuiIconButton.tscn | 27 +-- scenesrc/SuiScroller.tscn | 41 +++++ scenesrc/SuiText.tscn | 16 +- scenesrc/SuiTextButton.tscn | 24 +-- src/SuiBaseClass.gd | 45 +++++ src/SuiHeader.gd | 20 +- src/SuiHeaderTool.gd | 19 -- src/SuiIconButton.gd | 51 ++++-- src/SuiIconButtonTool.gd | 34 ---- src/SuiScroller.gd | 213 ++++++++++++++++++++++ src/SuiText.gd | 34 ++-- src/SuiTextButton.gd | 41 +++-- src/SuiTextButtonTool.gd | 26 --- src/SuiTextTool.gd | 19 -- src/SuiTypes.gd | 22 +++ themes/ScrollBar.tres | 3 + 44 files changed, 520 insertions(+), 300 deletions(-) create mode 100644 plugin.cfg create mode 100644 plugin.gd create mode 100644 scenesrc/SuiScroller.tscn create mode 100644 src/SuiBaseClass.gd delete mode 100644 src/SuiHeaderTool.gd delete mode 100644 src/SuiIconButtonTool.gd create mode 100644 src/SuiScroller.gd delete mode 100644 src/SuiTextButtonTool.gd delete mode 100644 src/SuiTextTool.gd create mode 100644 src/SuiTypes.gd create mode 100644 themes/ScrollBar.tres diff --git a/dist/example.png.import b/dist/example.png.import index 758258d..f52c485 100644 --- a/dist/example.png.import +++ b/dist/example.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://beqhfqbyme6in" -path="res://.godot/imported/example.png-47be253adf4d5d94d259a060339b95e0.ctex" +path="res://.godot/imported/example.png-79ae4e30d20a5d2033286350990a93fe.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://SUI/dist/example.png" -dest_files=["res://.godot/imported/example.png-47be253adf4d5d94d259a060339b95e0.ctex"] +source_file="res://addons/SUI/dist/example.png" +dest_files=["res://.godot/imported/example.png-79ae4e30d20a5d2033286350990a93fe.ctex"] [params] diff --git a/dist/sui.png.import b/dist/sui.png.import index d9473d2..89b506f 100644 --- a/dist/sui.png.import +++ b/dist/sui.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://db6wn76fb2bnu" -path="res://.godot/imported/sui.png-06a43b445987005f6f28d7a54ee82d35.ctex" +path="res://.godot/imported/sui.png-c2630d6c0f48be3e5128a131222590e3.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://SUI/dist/sui.png" -dest_files=["res://.godot/imported/sui.png-06a43b445987005f6f28d7a54ee82d35.ctex"] +source_file="res://addons/SUI/dist/sui.png" +dest_files=["res://.godot/imported/sui.png-c2630d6c0f48be3e5128a131222590e3.ctex"] [params] diff --git a/fonts/FiraCode/Bold.ttf.import b/fonts/FiraCode/Bold.ttf.import index 8a9d76a..06d0927 100644 --- a/fonts/FiraCode/Bold.ttf.import +++ b/fonts/FiraCode/Bold.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://bvg3rkn8w7apl" -path="res://.godot/imported/Bold.ttf-22cba54e4f49541df0f88d22919fa43c.fontdata" +path="res://.godot/imported/Bold.ttf-9d02378de508f6c4574455afb9e0f76f.fontdata" [deps] -source_file="res://SUI/fonts/FiraCode/Bold.ttf" -dest_files=["res://.godot/imported/Bold.ttf-22cba54e4f49541df0f88d22919fa43c.fontdata"] +source_file="res://addons/SUI/fonts/FiraCode/Bold.ttf" +dest_files=["res://.godot/imported/Bold.ttf-9d02378de508f6c4574455afb9e0f76f.fontdata"] [params] diff --git a/fonts/FiraCode/Light.ttf.import b/fonts/FiraCode/Light.ttf.import index 379b536..f68ae45 100644 --- a/fonts/FiraCode/Light.ttf.import +++ b/fonts/FiraCode/Light.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://bvluo6uibvwwo" -path="res://.godot/imported/Light.ttf-b7c03199b472b55574b9b45080c68c17.fontdata" +path="res://.godot/imported/Light.ttf-5358520cff11f8deca184a7167eaf2b7.fontdata" [deps] -source_file="res://SUI/fonts/FiraCode/Light.ttf" -dest_files=["res://.godot/imported/Light.ttf-b7c03199b472b55574b9b45080c68c17.fontdata"] +source_file="res://addons/SUI/fonts/FiraCode/Light.ttf" +dest_files=["res://.godot/imported/Light.ttf-5358520cff11f8deca184a7167eaf2b7.fontdata"] [params] diff --git a/fonts/FiraCode/Medium.ttf.import b/fonts/FiraCode/Medium.ttf.import index cc3a6b0..d5119ff 100644 --- a/fonts/FiraCode/Medium.ttf.import +++ b/fonts/FiraCode/Medium.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://b1pxod4r5puw8" -path="res://.godot/imported/Medium.ttf-40e43fa0b24d32cf56e9d3d649b2df2c.fontdata" +path="res://.godot/imported/Medium.ttf-86d1745537123a429e6bccd6d86eb8b0.fontdata" [deps] -source_file="res://SUI/fonts/FiraCode/Medium.ttf" -dest_files=["res://.godot/imported/Medium.ttf-40e43fa0b24d32cf56e9d3d649b2df2c.fontdata"] +source_file="res://addons/SUI/fonts/FiraCode/Medium.ttf" +dest_files=["res://.godot/imported/Medium.ttf-86d1745537123a429e6bccd6d86eb8b0.fontdata"] [params] diff --git a/fonts/FiraCode/Regular.ttf.import b/fonts/FiraCode/Regular.ttf.import index 5ab9fc1..1d0be63 100644 --- a/fonts/FiraCode/Regular.ttf.import +++ b/fonts/FiraCode/Regular.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://dmyes0lwt4sgw" -path="res://.godot/imported/Regular.ttf-04045b5ea8a54f2ef953f12106a268da.fontdata" +path="res://.godot/imported/Regular.ttf-52cf847b22463b3df20f23164c25ab4e.fontdata" [deps] -source_file="res://SUI/fonts/FiraCode/Regular.ttf" -dest_files=["res://.godot/imported/Regular.ttf-04045b5ea8a54f2ef953f12106a268da.fontdata"] +source_file="res://addons/SUI/fonts/FiraCode/Regular.ttf" +dest_files=["res://.godot/imported/Regular.ttf-52cf847b22463b3df20f23164c25ab4e.fontdata"] [params] diff --git a/fonts/FiraCode/Retina.ttf.import b/fonts/FiraCode/Retina.ttf.import index 4913723..f59a8ad 100644 --- a/fonts/FiraCode/Retina.ttf.import +++ b/fonts/FiraCode/Retina.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://c2qswgll1vpc6" -path="res://.godot/imported/Retina.ttf-3255d7691679a4e571c84d2485e39ad1.fontdata" +path="res://.godot/imported/Retina.ttf-1b39772f452475d30e5a51f5e07cc1ae.fontdata" [deps] -source_file="res://SUI/fonts/FiraCode/Retina.ttf" -dest_files=["res://.godot/imported/Retina.ttf-3255d7691679a4e571c84d2485e39ad1.fontdata"] +source_file="res://addons/SUI/fonts/FiraCode/Retina.ttf" +dest_files=["res://.godot/imported/Retina.ttf-1b39772f452475d30e5a51f5e07cc1ae.fontdata"] [params] diff --git a/fonts/Jost/Jost-Black.ttf.import b/fonts/Jost/Jost-Black.ttf.import index 43d7940..58cf2fa 100644 --- a/fonts/Jost/Jost-Black.ttf.import +++ b/fonts/Jost/Jost-Black.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://m6urwfj4pmcw" -path="res://.godot/imported/Jost-Black.ttf-d2b76427d7ff73b7de9d6cb2ebbbffd9.fontdata" +path="res://.godot/imported/Jost-Black.ttf-2c635ee32d5da5865ec199bd682a2d50.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-Black.ttf" -dest_files=["res://.godot/imported/Jost-Black.ttf-d2b76427d7ff73b7de9d6cb2ebbbffd9.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-Black.ttf" +dest_files=["res://.godot/imported/Jost-Black.ttf-2c635ee32d5da5865ec199bd682a2d50.fontdata"] [params] diff --git a/fonts/Jost/Jost-BlackItalic.ttf.import b/fonts/Jost/Jost-BlackItalic.ttf.import index e911be3..f2ee6ec 100644 --- a/fonts/Jost/Jost-BlackItalic.ttf.import +++ b/fonts/Jost/Jost-BlackItalic.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://c8pq1wpbkpcaj" -path="res://.godot/imported/Jost-BlackItalic.ttf-c46f41f0d59e6636f3e254b2a526b666.fontdata" +path="res://.godot/imported/Jost-BlackItalic.ttf-7c2c0ed51407347a2a6fdca6b6852845.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-BlackItalic.ttf" -dest_files=["res://.godot/imported/Jost-BlackItalic.ttf-c46f41f0d59e6636f3e254b2a526b666.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-BlackItalic.ttf" +dest_files=["res://.godot/imported/Jost-BlackItalic.ttf-7c2c0ed51407347a2a6fdca6b6852845.fontdata"] [params] diff --git a/fonts/Jost/Jost-Bold.ttf.import b/fonts/Jost/Jost-Bold.ttf.import index d0f576f..07c43de 100644 --- a/fonts/Jost/Jost-Bold.ttf.import +++ b/fonts/Jost/Jost-Bold.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://b6kyv4fqc0h0r" -path="res://.godot/imported/Jost-Bold.ttf-530330f4d453cedaf0fa5c530f0e9499.fontdata" +path="res://.godot/imported/Jost-Bold.ttf-89758df4d1e4651df1f9f59f663b9998.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-Bold.ttf" -dest_files=["res://.godot/imported/Jost-Bold.ttf-530330f4d453cedaf0fa5c530f0e9499.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-Bold.ttf" +dest_files=["res://.godot/imported/Jost-Bold.ttf-89758df4d1e4651df1f9f59f663b9998.fontdata"] [params] diff --git a/fonts/Jost/Jost-BoldItalic.ttf.import b/fonts/Jost/Jost-BoldItalic.ttf.import index a9fbeae..eb0f133 100644 --- a/fonts/Jost/Jost-BoldItalic.ttf.import +++ b/fonts/Jost/Jost-BoldItalic.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://dyie3a0vo05m6" -path="res://.godot/imported/Jost-BoldItalic.ttf-ce61bd5c22a68649a11234fc3f5045a4.fontdata" +path="res://.godot/imported/Jost-BoldItalic.ttf-5c2bdb46e5980b65ed9ca1075638d114.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-BoldItalic.ttf" -dest_files=["res://.godot/imported/Jost-BoldItalic.ttf-ce61bd5c22a68649a11234fc3f5045a4.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-BoldItalic.ttf" +dest_files=["res://.godot/imported/Jost-BoldItalic.ttf-5c2bdb46e5980b65ed9ca1075638d114.fontdata"] [params] diff --git a/fonts/Jost/Jost-Book.ttf.import b/fonts/Jost/Jost-Book.ttf.import index 608465c..6b98488 100644 --- a/fonts/Jost/Jost-Book.ttf.import +++ b/fonts/Jost/Jost-Book.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://dmal2c285wyd5" -path="res://.godot/imported/Jost-Book.ttf-fcca27ee59160551b9f968d4a28f3094.fontdata" +path="res://.godot/imported/Jost-Book.ttf-e796e63ee3da21fdf38d9a3c4b3b676b.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-Book.ttf" -dest_files=["res://.godot/imported/Jost-Book.ttf-fcca27ee59160551b9f968d4a28f3094.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-Book.ttf" +dest_files=["res://.godot/imported/Jost-Book.ttf-e796e63ee3da21fdf38d9a3c4b3b676b.fontdata"] [params] diff --git a/fonts/Jost/Jost-BookItalic.ttf.import b/fonts/Jost/Jost-BookItalic.ttf.import index 382d484..0c49b74 100644 --- a/fonts/Jost/Jost-BookItalic.ttf.import +++ b/fonts/Jost/Jost-BookItalic.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://cbwek1bifl4ug" -path="res://.godot/imported/Jost-BookItalic.ttf-1620829af2a0daf59631f59a0bbfa89e.fontdata" +path="res://.godot/imported/Jost-BookItalic.ttf-b20af08f46b9a9385e74f352e8542f31.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-BookItalic.ttf" -dest_files=["res://.godot/imported/Jost-BookItalic.ttf-1620829af2a0daf59631f59a0bbfa89e.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-BookItalic.ttf" +dest_files=["res://.godot/imported/Jost-BookItalic.ttf-b20af08f46b9a9385e74f352e8542f31.fontdata"] [params] diff --git a/fonts/Jost/Jost-Hairline.ttf.import b/fonts/Jost/Jost-Hairline.ttf.import index e1bd038..ea4aa90 100644 --- a/fonts/Jost/Jost-Hairline.ttf.import +++ b/fonts/Jost/Jost-Hairline.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://ojsgind3ered" -path="res://.godot/imported/Jost-Hairline.ttf-60a860c6f046fc64490aa060536a6c96.fontdata" +path="res://.godot/imported/Jost-Hairline.ttf-d1dd71e771c1b42e0258e87923e65831.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-Hairline.ttf" -dest_files=["res://.godot/imported/Jost-Hairline.ttf-60a860c6f046fc64490aa060536a6c96.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-Hairline.ttf" +dest_files=["res://.godot/imported/Jost-Hairline.ttf-d1dd71e771c1b42e0258e87923e65831.fontdata"] [params] diff --git a/fonts/Jost/Jost-HairlineItalic.ttf.import b/fonts/Jost/Jost-HairlineItalic.ttf.import index 3a2d945..b6554dc 100644 --- a/fonts/Jost/Jost-HairlineItalic.ttf.import +++ b/fonts/Jost/Jost-HairlineItalic.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://qni4pu0bm308" -path="res://.godot/imported/Jost-HairlineItalic.ttf-1f22e8ae5a4c4ea3cdc6663fef01e37c.fontdata" +path="res://.godot/imported/Jost-HairlineItalic.ttf-fb69b6a296010f64da381646abf766ae.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-HairlineItalic.ttf" -dest_files=["res://.godot/imported/Jost-HairlineItalic.ttf-1f22e8ae5a4c4ea3cdc6663fef01e37c.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-HairlineItalic.ttf" +dest_files=["res://.godot/imported/Jost-HairlineItalic.ttf-fb69b6a296010f64da381646abf766ae.fontdata"] [params] diff --git a/fonts/Jost/Jost-Heavy.ttf.import b/fonts/Jost/Jost-Heavy.ttf.import index 575138b..2807ca6 100644 --- a/fonts/Jost/Jost-Heavy.ttf.import +++ b/fonts/Jost/Jost-Heavy.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://c6pvexxexmc7r" -path="res://.godot/imported/Jost-Heavy.ttf-b0c23db38ef7e5d8579dac98f7f0e1bc.fontdata" +path="res://.godot/imported/Jost-Heavy.ttf-13a86b042195fc082920b8b1790b2121.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-Heavy.ttf" -dest_files=["res://.godot/imported/Jost-Heavy.ttf-b0c23db38ef7e5d8579dac98f7f0e1bc.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-Heavy.ttf" +dest_files=["res://.godot/imported/Jost-Heavy.ttf-13a86b042195fc082920b8b1790b2121.fontdata"] [params] diff --git a/fonts/Jost/Jost-HeavyItalic.ttf.import b/fonts/Jost/Jost-HeavyItalic.ttf.import index 05c44a0..b019e75 100644 --- a/fonts/Jost/Jost-HeavyItalic.ttf.import +++ b/fonts/Jost/Jost-HeavyItalic.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://dv5eppfnp0g1p" -path="res://.godot/imported/Jost-HeavyItalic.ttf-e7fcb33dfb4a18e0f2c41c8c1568acf0.fontdata" +path="res://.godot/imported/Jost-HeavyItalic.ttf-53870a664183e8ede629796746926a7d.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-HeavyItalic.ttf" -dest_files=["res://.godot/imported/Jost-HeavyItalic.ttf-e7fcb33dfb4a18e0f2c41c8c1568acf0.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-HeavyItalic.ttf" +dest_files=["res://.godot/imported/Jost-HeavyItalic.ttf-53870a664183e8ede629796746926a7d.fontdata"] [params] diff --git a/fonts/Jost/Jost-Light.ttf.import b/fonts/Jost/Jost-Light.ttf.import index 94b3eec..cefca92 100644 --- a/fonts/Jost/Jost-Light.ttf.import +++ b/fonts/Jost/Jost-Light.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://lgdhrfvuirc8" -path="res://.godot/imported/Jost-Light.ttf-ba510b840fdc146937673fd2582f4389.fontdata" +path="res://.godot/imported/Jost-Light.ttf-2dbed4b0da6ce9f06416069dec6915ed.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-Light.ttf" -dest_files=["res://.godot/imported/Jost-Light.ttf-ba510b840fdc146937673fd2582f4389.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-Light.ttf" +dest_files=["res://.godot/imported/Jost-Light.ttf-2dbed4b0da6ce9f06416069dec6915ed.fontdata"] [params] diff --git a/fonts/Jost/Jost-LightItalic.ttf.import b/fonts/Jost/Jost-LightItalic.ttf.import index 039976d..d561d4b 100644 --- a/fonts/Jost/Jost-LightItalic.ttf.import +++ b/fonts/Jost/Jost-LightItalic.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://b71mb2nm3qhpc" -path="res://.godot/imported/Jost-LightItalic.ttf-7f878179a0fd0bc18ca1d551eac1268b.fontdata" +path="res://.godot/imported/Jost-LightItalic.ttf-702988867a5b4796d468dce0ad421d3a.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-LightItalic.ttf" -dest_files=["res://.godot/imported/Jost-LightItalic.ttf-7f878179a0fd0bc18ca1d551eac1268b.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-LightItalic.ttf" +dest_files=["res://.godot/imported/Jost-LightItalic.ttf-702988867a5b4796d468dce0ad421d3a.fontdata"] [params] diff --git a/fonts/Jost/Jost-Medium.ttf.import b/fonts/Jost/Jost-Medium.ttf.import index 513eee0..7bbd977 100644 --- a/fonts/Jost/Jost-Medium.ttf.import +++ b/fonts/Jost/Jost-Medium.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://d3cdnrnmplqa2" -path="res://.godot/imported/Jost-Medium.ttf-18a1c5f1f46710985bb7bd431a626c3b.fontdata" +path="res://.godot/imported/Jost-Medium.ttf-f161b5eb0d0dc3093b24164ab7b49c5c.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-Medium.ttf" -dest_files=["res://.godot/imported/Jost-Medium.ttf-18a1c5f1f46710985bb7bd431a626c3b.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-Medium.ttf" +dest_files=["res://.godot/imported/Jost-Medium.ttf-f161b5eb0d0dc3093b24164ab7b49c5c.fontdata"] [params] diff --git a/fonts/Jost/Jost-MediumItalic.ttf.import b/fonts/Jost/Jost-MediumItalic.ttf.import index 730779f..e5cca98 100644 --- a/fonts/Jost/Jost-MediumItalic.ttf.import +++ b/fonts/Jost/Jost-MediumItalic.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://c8pypsury6pp0" -path="res://.godot/imported/Jost-MediumItalic.ttf-74fab0e71b9d6a783a4c23d09e5a8bc2.fontdata" +path="res://.godot/imported/Jost-MediumItalic.ttf-01b4f8b1311e6c370cf8956be27a4d92.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-MediumItalic.ttf" -dest_files=["res://.godot/imported/Jost-MediumItalic.ttf-74fab0e71b9d6a783a4c23d09e5a8bc2.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-MediumItalic.ttf" +dest_files=["res://.godot/imported/Jost-MediumItalic.ttf-01b4f8b1311e6c370cf8956be27a4d92.fontdata"] [params] diff --git a/fonts/Jost/Jost-Semi.ttf.import b/fonts/Jost/Jost-Semi.ttf.import index 93c7cb4..1c0f350 100644 --- a/fonts/Jost/Jost-Semi.ttf.import +++ b/fonts/Jost/Jost-Semi.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://gnouta0qju0p" -path="res://.godot/imported/Jost-Semi.ttf-0d5b54fce18b66b9a3efd1947bd643ee.fontdata" +path="res://.godot/imported/Jost-Semi.ttf-9377052d79aeca7e001c2ca77cfcbe8e.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-Semi.ttf" -dest_files=["res://.godot/imported/Jost-Semi.ttf-0d5b54fce18b66b9a3efd1947bd643ee.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-Semi.ttf" +dest_files=["res://.godot/imported/Jost-Semi.ttf-9377052d79aeca7e001c2ca77cfcbe8e.fontdata"] [params] diff --git a/fonts/Jost/Jost-SemiItalic.ttf.import b/fonts/Jost/Jost-SemiItalic.ttf.import index 1de902e..7527ce0 100644 --- a/fonts/Jost/Jost-SemiItalic.ttf.import +++ b/fonts/Jost/Jost-SemiItalic.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://d2iwusq4f7oql" -path="res://.godot/imported/Jost-SemiItalic.ttf-c0398693734e1f928de1f3d879cec4ca.fontdata" +path="res://.godot/imported/Jost-SemiItalic.ttf-68daaa58429e6ae8bd8151fd1bf4b7c6.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-SemiItalic.ttf" -dest_files=["res://.godot/imported/Jost-SemiItalic.ttf-c0398693734e1f928de1f3d879cec4ca.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-SemiItalic.ttf" +dest_files=["res://.godot/imported/Jost-SemiItalic.ttf-68daaa58429e6ae8bd8151fd1bf4b7c6.fontdata"] [params] diff --git a/fonts/Jost/Jost-Thin.ttf.import b/fonts/Jost/Jost-Thin.ttf.import index 1e59d88..f6cfba1 100644 --- a/fonts/Jost/Jost-Thin.ttf.import +++ b/fonts/Jost/Jost-Thin.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://cgcmctm1yk74f" -path="res://.godot/imported/Jost-Thin.ttf-e0ab4e7fb89f79107d9e4dd6035aa171.fontdata" +path="res://.godot/imported/Jost-Thin.ttf-cf88a1c2ba9d17fec2aa86a24e8ff592.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-Thin.ttf" -dest_files=["res://.godot/imported/Jost-Thin.ttf-e0ab4e7fb89f79107d9e4dd6035aa171.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-Thin.ttf" +dest_files=["res://.godot/imported/Jost-Thin.ttf-cf88a1c2ba9d17fec2aa86a24e8ff592.fontdata"] [params] diff --git a/fonts/Jost/Jost-ThinItalic.ttf.import b/fonts/Jost/Jost-ThinItalic.ttf.import index 4b4cff6..463a541 100644 --- a/fonts/Jost/Jost-ThinItalic.ttf.import +++ b/fonts/Jost/Jost-ThinItalic.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://boi4bwfisvegs" -path="res://.godot/imported/Jost-ThinItalic.ttf-8c39a4954eac56e794cf73949a2e807e.fontdata" +path="res://.godot/imported/Jost-ThinItalic.ttf-7838f2160d46284d888598d15fd30dc0.fontdata" [deps] -source_file="res://SUI/fonts/Jost/Jost-ThinItalic.ttf" -dest_files=["res://.godot/imported/Jost-ThinItalic.ttf-8c39a4954eac56e794cf73949a2e807e.fontdata"] +source_file="res://addons/SUI/fonts/Jost/Jost-ThinItalic.ttf" +dest_files=["res://.godot/imported/Jost-ThinItalic.ttf-7838f2160d46284d888598d15fd30dc0.fontdata"] [params] diff --git a/plugin.cfg b/plugin.cfg new file mode 100644 index 0000000..ee75a2d --- /dev/null +++ b/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="StarOpenSource UI" +description="StarOpenSource UI (SUI for short) is a collection of common ui elements for the Godot Engine." +author="The StarOpenSource Project & Contributors" +version="" +script="plugin.gd" diff --git a/plugin.gd b/plugin.gd new file mode 100644 index 0000000..8230598 --- /dev/null +++ b/plugin.gd @@ -0,0 +1,10 @@ +@tool +extends EditorPlugin + +func _enter_tree(): + if !FileAccess.file_exists("res://CORE/.corebasepath") and !FileAccess.file_exists("res://addons/CORE/.corebasepath"): + printerr("The CORE Framework is not installed in your project.\nPlease install the CORE Framework for StarOpenSource UI to work.\nSee https://core.staropensource.de/category/getting-started/") + + +func _exit_tree(): + print("Thank you for using StarOpenSource UI") diff --git a/scenesrc/SuiHeader.tscn b/scenesrc/SuiHeader.tscn index a663ee3..39d161f 100644 --- a/scenesrc/SuiHeader.tscn +++ b/scenesrc/SuiHeader.tscn @@ -1,27 +1,23 @@ -[gd_scene load_steps=4 format=3 uid="uid://1r7pvm0biuk7"] +[gd_scene load_steps=3 format=3 uid="uid://1r7pvm0biuk7"] -[ext_resource type="Script" path="res://SUI/src/SuiHeader.gd" id="1_b3qg3"] -[ext_resource type="Script" path="res://SUI/src/SuiHeaderTool.gd" id="2_bnj46"] -[ext_resource type="Theme" uid="uid://c08yxv1cirbxe" path="res://SUI/themes/RichTextLabel.tres" id="3_877pi"] +[ext_resource type="Script" path="res://addons/SUI/src/SuiHeader.gd" id="2_bnj46"] +[ext_resource type="Theme" uid="uid://c08yxv1cirbxe" path="res://addons/SUI/themes/RichTextLabel.tres" id="3_877pi"] [node name="SuiHeader" type="Control"] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -780.0 -offset_bottom = -490.0 +offset_right = -1278.0 +offset_bottom = -765.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_b3qg3") - -[node name="ToolScript" type="Node" parent="."] script = ExtResource("2_bnj46") [node name="Text" type="RichTextLabel" parent="."] layout_mode = 0 -offset_right = 170.0 -offset_bottom = 50.0 +offset_right = 162.0 +offset_bottom = 45.0 theme = ExtResource("3_877pi") theme_override_font_sizes/normal_font_size = 35 theme_override_font_sizes/bold_font_size = 35 diff --git a/scenesrc/SuiIconButton.tscn b/scenesrc/SuiIconButton.tscn index 2eabca8..4db2a8e 100644 --- a/scenesrc/SuiIconButton.tscn +++ b/scenesrc/SuiIconButton.tscn @@ -1,39 +1,32 @@ -[gd_scene load_steps=5 format=3 uid="uid://cxg471hoqg6mr"] +[gd_scene load_steps=3 format=3 uid="uid://cxg471hoqg6mr"] -[ext_resource type="Script" path="res://SUI/src/SuiIconButton.gd" id="1_ekv73"] -[ext_resource type="Texture2D" uid="uid://beqhfqbyme6in" path="res://SUI/dist/example.png" id="2_c5w38"] -[ext_resource type="Script" path="res://SUI/src/SuiIconButtonTool.gd" id="2_g6elc"] -[ext_resource type="Theme" uid="uid://prqv77t23rsq" path="res://SUI/themes/Button.tres" id="3_knxki"] +[ext_resource type="Script" path="res://addons/SUI/src/SuiIconButton.gd" id="2_g6elc"] +[ext_resource type="Theme" uid="uid://prqv77t23rsq" path="res://addons/SUI/themes/Button.tres" id="3_knxki"] [node name="SuiIconButton" type="Control"] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -900.0 -offset_bottom = -490.0 +offset_right = -1290.0 +offset_bottom = -660.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_ekv73") -image = ExtResource("2_c5w38") +script = ExtResource("2_g6elc") ip_left = 8 ip_top = 5 ip_right = 8 ip_bottom = 5 -[node name="ToolScript" type="Node" parent="."] -script = ExtResource("2_g6elc") - [node name="Button" type="Button" parent="."] layout_mode = 0 -offset_right = 50.0 -offset_bottom = 50.0 +offset_right = 150.0 +offset_bottom = 150.0 theme = ExtResource("3_knxki") [node name="Icon" type="NinePatchRect" parent="."] layout_mode = 0 offset_left = 8.0 offset_top = 5.0 -offset_right = 42.0 -offset_bottom = 45.0 -texture = ExtResource("2_c5w38") +offset_right = 150.0 +offset_bottom = 150.0 diff --git a/scenesrc/SuiScroller.tscn b/scenesrc/SuiScroller.tscn new file mode 100644 index 0000000..e0b349a --- /dev/null +++ b/scenesrc/SuiScroller.tscn @@ -0,0 +1,41 @@ +[gd_scene load_steps=3 format=3 uid="uid://b31tqrkh73to2"] + +[ext_resource type="Script" path="res://addons/SUI/src/SuiScroller.gd" id="1_dcfql"] +[ext_resource type="Theme" uid="uid://jg7l68yqa6n2" path="res://addons/SUI/themes/ScrollBar.tres" id="2_4lteo"] + +[node name="SuiScroller" type="Control"] +clip_contents = true +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -1053.33 +offset_bottom = -563.333 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_dcfql") + +[node name="HScrollBar" type="HScrollBar" parent="."] +modulate = Color(1, 1, 1, 0.501961) +layout_mode = 1 +offset_top = 226.417 +offset_right = 366.42 +offset_bottom = 246.667 +theme = ExtResource("2_4lteo") +max_value = 386.67 +step = 1.0 +page = 1.0 + +[node name="VScrollBar" type="VScrollBar" parent="."] +modulate = Color(1, 1, 1, 0.501961) +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -20.25 +offset_bottom = 226.417 +grow_horizontal = 0 +theme = ExtResource("2_4lteo") +max_value = 246.667 +step = 1.0 +page = 1.0 diff --git a/scenesrc/SuiText.tscn b/scenesrc/SuiText.tscn index c92238f..868b12b 100644 --- a/scenesrc/SuiText.tscn +++ b/scenesrc/SuiText.tscn @@ -1,26 +1,22 @@ -[gd_scene load_steps=4 format=3 uid="uid://bso65vpjqc4g4"] +[gd_scene load_steps=3 format=3 uid="uid://bso65vpjqc4g4"] -[ext_resource type="Script" path="res://SUI/src/SuiText.gd" id="1_1jc62"] -[ext_resource type="Script" path="res://SUI/src/SuiTextTool.gd" id="2_87ovr"] -[ext_resource type="Theme" uid="uid://c08yxv1cirbxe" path="res://SUI/themes/RichTextLabel.tres" id="3_fttgr"] +[ext_resource type="Script" path="res://addons/SUI/src/SuiText.gd" id="2_87ovr"] +[ext_resource type="Theme" uid="uid://c08yxv1cirbxe" path="res://addons/SUI/themes/RichTextLabel.tres" id="3_fttgr"] [node name="SuiText" type="Control"] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -850.0 -offset_bottom = -503.0 +offset_right = -1345.0 +offset_bottom = -773.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_1jc62") - -[node name="ToolScript" type="Node" parent="."] script = ExtResource("2_87ovr") [node name="Text" type="RichTextLabel" parent="."] layout_mode = 0 -offset_right = 100.0 +offset_right = 95.0 offset_bottom = 37.0 theme = ExtResource("3_fttgr") theme_override_font_sizes/normal_font_size = 25 diff --git a/scenesrc/SuiTextButton.tscn b/scenesrc/SuiTextButton.tscn index ba3a4fe..77e5e4e 100644 --- a/scenesrc/SuiTextButton.tscn +++ b/scenesrc/SuiTextButton.tscn @@ -1,34 +1,30 @@ -[gd_scene load_steps=5 format=3 uid="uid://4hi8y7pu3w0v"] +[gd_scene load_steps=4 format=3 uid="uid://4hi8y7pu3w0v"] -[ext_resource type="Script" path="res://SUI/src/SuiTextButton.gd" id="1_tjgbd"] -[ext_resource type="Script" path="res://SUI/src/SuiTextButtonTool.gd" id="2_43xd1"] -[ext_resource type="Theme" uid="uid://prqv77t23rsq" path="res://SUI/themes/Button.tres" id="3_u0br7"] -[ext_resource type="Theme" uid="uid://c08yxv1cirbxe" path="res://SUI/themes/RichTextLabel.tres" id="4_vp57w"] +[ext_resource type="Script" path="res://addons/SUI/src/SuiTextButton.gd" id="2_43xd1"] +[ext_resource type="Theme" uid="uid://prqv77t23rsq" path="res://addons/SUI/themes/Button.tres" id="3_u0br7"] +[ext_resource type="Theme" uid="uid://c08yxv1cirbxe" path="res://addons/SUI/themes/RichTextLabel.tres" id="4_vp57w"] [node name="SuiTextButton" type="Control"] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -700.0 -offset_bottom = -490.0 +offset_right = -1224.0 +offset_bottom = -757.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_tjgbd") - -[node name="ToolScript" type="Node" parent="."] script = ExtResource("2_43xd1") [node name="Button" type="Button" parent="."] layout_mode = 0 -offset_right = 250.0 -offset_bottom = 50.0 +offset_right = 216.0 +offset_bottom = 53.0 theme = ExtResource("3_u0br7") [node name="Text" type="RichTextLabel" parent="."] layout_mode = 0 -offset_right = 250.0 -offset_bottom = 50.0 +offset_right = 216.0 +offset_bottom = 53.0 mouse_filter = 2 theme = ExtResource("4_vp57w") theme_override_font_sizes/normal_font_size = 35 diff --git a/src/SuiBaseClass.gd b/src/SuiBaseClass.gd new file mode 100644 index 0000000..9f74d32 --- /dev/null +++ b/src/SuiBaseClass.gd @@ -0,0 +1,45 @@ +@tool +extends Control +class_name SuiBaseClass + +## Reference to the [CORE] Object. Set by [method _ready]. +var core: Core +## Reference to a [CoreLoggerInstance]. Must be set manually. +var logger: CoreLoggerInstance = null + +@export_category("Debugging") +## Determines if the element should be updated automatically [b]while running in the editor[/b]. +@export var editor_process: bool = true +## Determines if the element should be updated automatically [b]during your game/application's runtime[/b]. +@export var runtime_process: bool = true + +# +++ initialization and process methods +++ +## Initializes the base class.[br] +## To run additional code in `_ready()`, use this example: +## [/codeblock] +## func _ready() -> void: +## super() +## # Your code here +## [/codeblock] +func _ready() -> void: + if !in_editor(): core = get_node("/root/CORE") + +## Calls [method update_element] if allowed to execute +func _process(_delta: float): + if execute_process(): update_element() + +# +++ element updating +++ +## This method is intended to be extended by a child script.[br] +## Use this to implement your own element update logic. +func update_element() -> void: pass + +# +++ etc +++ +## Determines if [method _process] is allowed to execute- +func execute_process() -> bool: + if in_editor() and !editor_process: return false + elif !in_editor() and !runtime_process: return false + else: return true + +## Determines if running inside or outside the editor- +func in_editor() -> bool: + return get_node_or_null("/root/CORE") == null diff --git a/src/SuiHeader.gd b/src/SuiHeader.gd index e177332..6830651 100644 --- a/src/SuiHeader.gd +++ b/src/SuiHeader.gd @@ -1,24 +1,14 @@ -extends Control - -@onready var logger: CoreLoggerInstance = get_node("/root/CORE").logger.get_instance("SUI/src/SuiHeader.gd") +@tool +extends SuiBaseClass @export_category("Base Configuration") @export_subgroup("RichTextLabel") +## Enables support for BBCode. @export var bbcode_support: bool = true +## The text you want to display. @export_multiline var text: String = "[center]SuiHeader[/center]" +## The size your text should have. @export var font_size: int = 35 -@export_category("Debugging") -@export var editor_process: bool = true -@export var runtime_process: bool = true - -func _ready() -> void: - # Free unused children - logger.diag("<" + name + "> Freeing ToolScript") - get_child(0).queue_free() - -func _process(_delta: float) -> void: - if !runtime_process: return - update_element() func update_element() -> void: # Update sizes diff --git a/src/SuiHeaderTool.gd b/src/SuiHeaderTool.gd deleted file mode 100644 index 1c5a6a8..0000000 --- a/src/SuiHeaderTool.gd +++ /dev/null @@ -1,19 +0,0 @@ -@tool -extends Node - -func _process(_delta: float): - if !get_parent().editor_process: return - var parent: Control = get_parent() - var text: RichTextLabel = parent.get_node("Text") - - # Update sizes - text.size = parent.size - - # Update RichTextLabel stuff - text.bbcode_enabled = parent.bbcode_support - text.text = parent.text - text.add_theme_font_size_override("normal_font_size", parent.font_size) - text.add_theme_font_size_override("bold_font_size", parent.font_size) - text.add_theme_font_size_override("italics_font_size", parent.font_size) - text.add_theme_font_size_override("bold_italics_font_size", parent.font_size) - text.add_theme_font_size_override("mono_font_size", parent.font_size) diff --git a/src/SuiIconButton.gd b/src/SuiIconButton.gd index cc76157..2649443 100644 --- a/src/SuiIconButton.gd +++ b/src/SuiIconButton.gd @@ -1,54 +1,62 @@ -extends Control - -@onready var logger: CoreLoggerInstance = get_node("/root/CORE").logger.get_instance("SUI/src/SuiIconButton.gd") +@tool +extends SuiBaseClass @export_category("Base Configuration") @export_subgroup("Button") +## Makes the button unable to be interacted with. @export var disabled: bool = false +## Makes the button toggleable. @export var toggle_mode: bool = false +## Forwarded from the internal [Button]. Will be overriden with the internal button's value, any changes to this variable will not be reflected. @export var button_pressed: bool = false @export_subgroup("Icon") +## The image you want to display. @export var image: Texture2D +## See [member NinePatchRect.region_rect]. @export var region_rect: Rect2 = Rect2(0, 0, 0, 0) +## See [member NinePatchRect.draw_center]. @export var draw_center: bool = true @export_category("Advanced Configuration") @export_subgroup("Icon Padding") +## Icon padding (left side) @export var ip_left: int = 0 +## Icon padding (top side) @export var ip_top: int = 0 +## Icon padding (right side) @export var ip_right: int = 0 +## Icon padding (bottom side) @export var ip_bottom: int = 0 @export_subgroup("Patch Margin") +## See [member NinePatchRect.patch_margin_left]. @export var pm_left: int = 0 +## See [member NinePatchRect.patch_margin_top]. @export var pm_top: int = 0 +## See [member NinePatchRect.patch_margin_right]. @export var pm_right: int = 0 +## See [member NinePatchRect.patch_margin_bottom]. @export var pm_bottom: int = 0 @export_subgroup("Axis Stretch") +## See [member NinePathRect.axis_stretch_horizontal]. @export var as_horizontal: NinePatchRect.AxisStretchMode = NinePatchRect.AxisStretchMode.AXIS_STRETCH_MODE_STRETCH +## See [member NinePathRect.axis_stretch_vertical]. @export var as_vertical: NinePatchRect.AxisStretchMode = NinePatchRect.AxisStretchMode.AXIS_STRETCH_MODE_STRETCH -@export_category("Debugging") -@export var editor_process: bool = true -@export var runtime_process: bool = true +## Emitted when the button is pressed. signal down +## Emitted when the button is released. signal up +## Emitted when the button has been pressed. signal pressed +## Emitted when the button has been toggled. signal toggled func _ready() -> void: - # Free unused children - logger.diag("<" + name + "> Freeing ToolScript") - get_child(0).queue_free() - - # Add signals - logger.diag("<" + name + "> Adding signals") - $Button.connect("button_down", func() -> void: emit_signal("down")) - $Button.connect("button_up", func() -> void: emit_signal("up")) - $Button.connect("pressed", func() -> void: emit_signal("pressed")) - $Button.connect("toggled", func(toggled_on: bool) -> void: emit_signal("toggled", toggled_on)) - -func _process(_delta: float) -> void: - if !runtime_process: return - update_element() + super() + if !in_editor(): + $Button.connect("button_down", func() -> void: emit_signal("down")) + $Button.connect("button_up", func() -> void: emit_signal("up")) + $Button.connect("pressed", func() -> void: emit_signal("pressed")) + $Button.connect("toggled", func(toggled_on: bool) -> void: emit_signal("toggled", toggled_on)) func update_element() -> void: # Update button size @@ -76,3 +84,6 @@ func update_element() -> void: $Icon.patch_margin_bottom = pm_bottom $Icon.axis_stretch_horizontal = as_horizontal $Icon.axis_stretch_vertical = as_vertical + +func update_pressed_state(is_pressed: bool) -> void: + $Button.button_pressed = is_pressed diff --git a/src/SuiIconButtonTool.gd b/src/SuiIconButtonTool.gd deleted file mode 100644 index 1057e44..0000000 --- a/src/SuiIconButtonTool.gd +++ /dev/null @@ -1,34 +0,0 @@ -@tool -extends Node - -func _process(_delta: float): - if !get_parent().editor_process: return - var parent: Control = get_parent() - var button: Button = parent.get_node("Button") - var icon: NinePatchRect = parent.get_node("Icon") - - # Update button size - button.size = parent.size - - # Update icon size + padding - icon.size = parent.size - icon.position.x = parent.ip_left - icon.position.y = parent.ip_top - icon.size.x -= parent.ip_right + parent.ip_left - icon.size.y -= parent.ip_bottom + parent.ip_top - - # Update Button stuff - button.disabled = parent.disabled - button.toggle_mode = parent.toggle_mode - button.button_pressed = parent.button_pressed - - # Update NinePatchRect stuff - icon.texture = parent.image - icon.region_rect = parent.region_rect - icon.draw_center = parent.draw_center - icon.patch_margin_left = parent.pm_left - icon.patch_margin_top = parent.pm_top - icon.patch_margin_right = parent.pm_right - icon.patch_margin_bottom = parent.pm_bottom - icon.axis_stretch_horizontal = parent.as_horizontal - icon.axis_stretch_vertical = parent.as_vertical diff --git a/src/SuiScroller.gd b/src/SuiScroller.gd new file mode 100644 index 0000000..c3f786b --- /dev/null +++ b/src/SuiScroller.gd @@ -0,0 +1,213 @@ +@tool +extends SuiBaseClass + +@export_category("Base Configuration") +@export_subgroup("Visibility") +## Controls the visibility of the horizontal scroll bar. +@export var hscroll_visibility: SuiTypes.ScrollVisibility = SuiTypes.ScrollVisibility.AUTO +## Controls the visibility of the vertical scroll bar. +@export var vscroll_visibility: SuiTypes.ScrollVisibility = SuiTypes.ScrollVisibility.AUTO +@export_category("Advanced Configuration") +@export_subgroup("Scroller speed") +## Determines how the scrolling speed should be calculated. +@export var speed_mode: SuiTypes.ScrollMode = SuiTypes.ScrollMode.MULTIPLY_CUSTOM_VALUE +## The speed multiplier, used for [constant SuiTypes.ScrollMode.MULTIPLY_VIEWPORT] and [constant SuiTypes.ScrollMode.MULTIPLY_CUSTOM_VALUE]. +@export var speed_multiplier: float = 1.0 +## The speed value, used for [constant SuiTypes.ScrollMode.MULTIPLY_CUSTOM_VALUE] and [constant SuiTypes.ScrollMode.CUSTOM_VALUE]. +@export var speed_value: float = 1.0 +@export_subgroup("Scroller speed (wheel)") +## Determines how much the scrolling speed should be multiplied by when scrolling with the scroll wheel.[br] +## Using a lower value results in more mouse scrolling, higher values result in less mouse scrolling. +@export var speed_wheel_multiplier: float = 50.0 +@export_subgroup("Scroll bar thickness") +## Determines how the thickness of both scroll bars should be calculated. +@export var thickness_mode: SuiTypes.ScrollMode = SuiTypes.ScrollMode.MULTIPLY_VIEWPORT +## The thickness multiplier, used for [constant SuiTypes.ScrollMode.MULTIPLY_VIEWPORT] and [constant SuiTypes.ScrollMode.MULTIPLY_CUSTOM_VALUE]. +@export var thickness_multiplier: float = 0.025 +## The thickness value, used for [constant SuiTypes.ScrollMode.MULTIPLY_CUSTOM_VALUE] and [constant SuiTypes.ScrollMode.CUSTOM_VALUE]. +@export var thickness_value: float = 0.0 +@export_category("Debugging") +## Will cause elements not inside the SuiScroller node to be no longer clipped [i]in editor mode[/i]. +## Useful when editing the contents of a SuiScroller node, but may cause visual chaos. +@export var editor_clip_content: bool = true + +## Internal, don't modify. +var mouse_hovering: bool = false + +func _ready() -> void: + super() + if !in_editor(): logger = core.logger.get_instance("SUI/src/SuiScroller.gd", self) + +func _process(delta): + mouse_hovering = Rect2(Vector2(), size).has_point(get_local_mouse_position()) and !Rect2($HScrollBar.position, $HScrollBar.size).has_point(get_local_mouse_position()) and !Rect2($VScrollBar.position, $VScrollBar.size).has_point(get_local_mouse_position()) + super(delta) + +func update_element() -> void: + # Clip contents + if in_editor() and !editor_clip_content: clip_contents = false + else: clip_contents = true + + # Update sizes and positions + match(thickness_mode): + SuiTypes.ScrollMode.MULTIPLY_VIEWPORT: + var window_size: Vector2i = Vector2i(ProjectSettings.get("display/window/size/viewport_width"), ProjectSettings.get("display/window/size/viewport_height")) + # Find smaller value + var scale_size: int + if window_size.x < window_size.y: scale_size = window_size.x + elif window_size.x > window_size.y: scale_size = window_size.y + + $HScrollBar.size.y = scale_size*thickness_multiplier + $VScrollBar.size.x = scale_size*thickness_multiplier + SuiTypes.ScrollMode.MULTIPLY_CUSTOM_VALUE: + $HScrollBar.size.y = thickness_value*thickness_multiplier + $VScrollBar.size.x = thickness_value*thickness_multiplier + SuiTypes.ScrollMode.CUSTOM_VALUE: + $HScrollBar.size.y = thickness_value + $VScrollBar.size.x = thickness_value + $HScrollBar.size.x = size.x-$VScrollBar.size.x + $VScrollBar.size.y = size.y-$HScrollBar.size.y + $HScrollBar.position.x = 0 + $HScrollBar.position.y = size.y-$HScrollBar.size.y + $VScrollBar.position.x = size.x-$VScrollBar.size.x + $VScrollBar.position.y = 0 + + # Update scrollbar properties + # Determine scroll speed + var speed: float + match(speed_mode): + SuiTypes.ScrollMode.MULTIPLY_VIEWPORT: + # Find smaller value + var scale_size: float + if size.x < size.y: scale_size = size.x + elif size.x > size.y: scale_size = size.y + + speed = scale_size*speed_multiplier + SuiTypes.ScrollMode.MULTIPLY_CUSTOM_VALUE: + speed = speed_value*speed_multiplier + SuiTypes.ScrollMode.CUSTOM_VALUE: + speed = speed_value + # HScrollBar + $HScrollBar.step = speed + $HScrollBar.page = speed + # VScrollBar + $VScrollBar.step = speed + $VScrollBar.page = speed + + # Update visibility + # HScrollBar + match(hscroll_visibility): + SuiTypes.ScrollVisibility.AUTO: + $HScrollBar.visible = true + $HScrollBar.modulate = Color8(255, 255, 255, 128) + SuiTypes.ScrollVisibility.SHOWN: + $HScrollBar.visible = true + $HScrollBar.modulate = Color8(255, 255, 255, 255) + SuiTypes.ScrollVisibility.HIDDEN: $HScrollBar.visible = false + _: + if in_editor(): printerr("Invalid hscroll_visibility value '" + str(hscroll_visibility) + "'") + else: logger.crash("Invalid hscroll_visibility value '" + str(hscroll_visibility) + "'") + # VScrollBar + match(vscroll_visibility): + SuiTypes.ScrollVisibility.AUTO: + $VScrollBar.visible = true + $VScrollBar.modulate = Color8(255, 255, 255, 128) + SuiTypes.ScrollVisibility.SHOWN: + $VScrollBar.visible = true + $VScrollBar.modulate = Color8(255, 255, 255, 255) + SuiTypes.ScrollVisibility.HIDDEN: $VScrollBar.visible = false + _: + if in_editor(): printerr("Invalid vscroll_visibility value '" + str(hscroll_visibility) + "'") + else: logger.crash("Invalid vscroll_visibility value '" + str(hscroll_visibility) + "'") + + if in_editor() and get_child_count() == 3: + var container: Control = get_child(2) + + # Update container position + container.position.x = 0 + container.position.y = 0 + return + + # Move control + if get_child_count() == 3 and get_child(2) != $VScrollBar: move_child(get_child(2), 0) + + # Make scrolling possible + if get_child_count() == 3 and get_child(0).is_class("Control"): + var container: Control = get_child(0) + var max_scrolling_distance: Vector2 = Vector2.ZERO + + # Update container size + if vscroll_visibility == SuiTypes.ScrollVisibility.HIDDEN: container.size.x = size.x + else: container.size.x = size.x-$VScrollBar.size.x + if vscroll_visibility == SuiTypes.ScrollVisibility.HIDDEN: container.size.y = size.y + else: container.size.y = size.y-$HScrollBar.size.y + + # Update container position + container.position.x = -$HScrollBar.value + container.position.y = -$VScrollBar.value + + # Get max scrolling distance + for child in container.get_children(true): + # Ensure 'size' and 'position' variables are either a Vector2 or Vector2i if not of type Control. + if !child.is_class("Control"): + match(typeof(child.get("size"))): + Variant.Type.TYPE_VECTOR2: pass + Variant.Type.TYPE_VECTOR2I: pass + _: continue + match(typeof(child.get("position"))): + Variant.Type.TYPE_VECTOR2: pass + Variant.Type.TYPE_VECTOR2I: pass + _: continue + + if child.size.x+child.position.x > max_scrolling_distance.x: + max_scrolling_distance.x = child.size.x+child.position.x-container.size.x + if child.size.y+child.position.y > max_scrolling_distance.y: + max_scrolling_distance.y = child.size.y+child.position.y-container.size.y + + # Update scroll bar max value + $HScrollBar.max_value = max_scrolling_distance.x + $VScrollBar.max_value = max_scrolling_distance.y + else: + $HScrollBar.max_value = size.x + $VScrollBar.max_value = size.y + +func _scroll(direction: SuiTypes.ScrollDirection) -> void: + var bar: ScrollBar + var dsign: int = 0 + + # Set 'dsign' + match(direction): + SuiTypes.ScrollDirection.UP: dsign = +1 + SuiTypes.ScrollDirection.DOWN: dsign = -1 + SuiTypes.ScrollDirection.LEFT: dsign = -1 + SuiTypes.ScrollDirection.RIGHT: dsign = +1 + + # Set 'bar' + match(direction): + SuiTypes.ScrollDirection.UP: bar = $VScrollBar + SuiTypes.ScrollDirection.DOWN: bar = $VScrollBar + SuiTypes.ScrollDirection.LEFT: bar = $HScrollBar + SuiTypes.ScrollDirection.RIGHT: bar = $HScrollBar + + bar.value = bar.value + bar.step * speed_wheel_multiplier * dsign + +# Credit: https://forum.godotengine.org/t/how-do-i-get-input-from-the-mouse-wheel/27979/2 +func _input(event: InputEvent): + if !mouse_hovering: return + if event is InputEventMouseButton: + if event.is_pressed(): + match(event.button_index): + MouseButton.MOUSE_BUTTON_WHEEL_UP: + if Input.is_key_pressed(Key.KEY_SHIFT): _scroll(SuiTypes.ScrollDirection.LEFT) + else: _scroll(SuiTypes.ScrollDirection.DOWN) + MouseButton.MOUSE_BUTTON_WHEEL_DOWN: + if Input.is_key_pressed(Key.KEY_SHIFT): _scroll(SuiTypes.ScrollDirection.RIGHT) + else: _scroll(SuiTypes.ScrollDirection.UP) + MouseButton.MOUSE_BUTTON_WHEEL_LEFT: _scroll(SuiTypes.ScrollDirection.RIGHT) + MouseButton.MOUSE_BUTTON_WHEEL_RIGHT: _scroll(SuiTypes.ScrollDirection.LEFT) + +func _get_configuration_warnings(): + if get_child_count() != 3: + return ["SuiScroller is intended to operate with one child only."] + elif !get_child(2).is_class("Control"): + return ["SuiScroller only supports Controls."] + return [] diff --git a/src/SuiText.gd b/src/SuiText.gd index 1748ac4..91bcda4 100644 --- a/src/SuiText.gd +++ b/src/SuiText.gd @@ -1,34 +1,28 @@ -extends Control - -@onready var logger: CoreLoggerInstance = get_node("/root/CORE").logger.get_instance("SUI/src/SuiText.gd") +@tool +extends SuiBaseClass @export_category("Base Configuration") @export_subgroup("RichTextLabel") +## Enables support for BBCode. @export var bbcode_support: bool = true +## The text you want to display. @export_multiline var text: String = "[center]SuiText[/center]" +## The size your text should have. @export var font_size: int = 25 -@export_category("Debugging") -@export var editor_process: bool = true -@export var runtime_process: bool = true +## Emitted when some interactive BBCode tag (e.g. url) is clicked signal meta_clicked +## Emitted when some interactive BBCode tag (e.g. url) is hovered over signal meta_hover_started +## Emitted when some interactive BBCode tag (e.g. url) is no longer being hovered over signal meta_hover_ended -func _ready() -> void: - # Free unused children - logger.diag("<" + name + "> Freeing ToolScript") - get_child(0).queue_free() - - # Add signals - logger.diag("<" + name + "> Adding signals") - $Text.connect("meta_clicked", func(meta: Variant) -> void: emit_signal("meta_clicked", meta)) - $Text.connect("meta_hover_started", func(meta: Variant) -> void: emit_signal("meta_hover_started", meta)) - $Text.connect("meta_hover_ended", func(meta: Variant) -> void: emit_signal("meta_hover_ended", meta)) - -func _process(_delta: float) -> void: - if !runtime_process: return - update_element() +func _ready(): + super() + if in_editor(): + $Text.connect("meta_clicked", func(meta: Variant) -> void: emit_signal("meta_clicked", meta)) + $Text.connect("meta_hover_started", func(meta: Variant) -> void: emit_signal("meta_hover_started", meta)) + $Text.connect("meta_hover_ended", func(meta: Variant) -> void: emit_signal("meta_hover_ended", meta)) func update_element() -> void: # Update sizes diff --git a/src/SuiTextButton.gd b/src/SuiTextButton.gd index 310193b..2022c81 100644 --- a/src/SuiTextButton.gd +++ b/src/SuiTextButton.gd @@ -1,40 +1,38 @@ -extends Control - -@onready var logger: CoreLoggerInstance = get_node("/root/CORE").logger.get_instance("SUI/src/SuiTextButton.gd") +@tool +extends SuiBaseClass @export_category("Base Configuration") @export_subgroup("Button") +## Makes the button unable to be interacted with. @export var disabled: bool = false +## Makes the button toggleable. @export var toggle_mode: bool = false +## Forwarded from the internal [Button]. Will be overriden with the internal button's value, any changes to this variable will not be reflected. @export var button_pressed: bool = false @export_subgroup("RichTextLabel") +## Enables support for BBCode. @export var bbcode_support: bool = true +## The text you want to display. @export_multiline var text: String = "[center]SuiTextButton[/center]" +## The size your text should have. @export var font_size: int = 35 -@export_category("Debugging") -@export var editor_process: bool = true -@export var runtime_process: bool = true +## Emitted when the button is pressed. signal down +## Emitted when the button is released. signal up +## Emitted when the button has been pressed. signal pressed +## Emitted when the button has been toggled. signal toggled func _ready() -> void: - # Free unused children - logger.diag("<" + name + "> Freeing ToolScript") - get_child(0).queue_free() - - # Add signals - logger.diag("<" + name + "> Adding signals") - $Button.connect("button_down", func() -> void: emit_signal("down")) - $Button.connect("button_up", func() -> void: emit_signal("up")) - $Button.connect("pressed", func() -> void: emit_signal("pressed")) - $Button.connect("toggled", func(toggled_on: bool) -> void: emit_signal("toggled", toggled_on)) - -func _process(_delta: float) -> void: - if !runtime_process: return - update_element() + super() + if !in_editor(): + $Button.connect("button_down", func() -> void: emit_signal("down")) + $Button.connect("button_up", func() -> void: emit_signal("up")) + $Button.connect("pressed", func() -> void: emit_signal("pressed")) + $Button.connect("toggled", func(toggled_on: bool) -> void: emit_signal("toggled", toggled_on)) func update_element() -> void: # Update sizes @@ -54,3 +52,6 @@ func update_element() -> void: $Text.add_theme_font_size_override("italics_font_size", font_size) $Text.add_theme_font_size_override("bold_italics_font_size", font_size) $Text.add_theme_font_size_override("mono_font_size", font_size) + +func update_pressed_state(is_pressed: bool) -> void: + $Button.button_pressed = is_pressed diff --git a/src/SuiTextButtonTool.gd b/src/SuiTextButtonTool.gd deleted file mode 100644 index bb1a852..0000000 --- a/src/SuiTextButtonTool.gd +++ /dev/null @@ -1,26 +0,0 @@ -@tool -extends Node - -func _process(_delta: float): - if !get_parent().editor_process: return - var parent: Control = get_parent() - var button: Button = parent.get_node("Button") - var text: RichTextLabel = parent.get_node("Text") - - # Update sizes - button.size = parent.size - text.size = parent.size - - # Update Button stuff - button.disabled = parent.disabled - button.toggle_mode = parent.toggle_mode - button.button_pressed = parent.button_pressed - - # Update RichTextLabel stuff - text.bbcode_enabled = parent.bbcode_support - text.text = parent.text - text.add_theme_font_size_override("normal_font_size", parent.font_size) - text.add_theme_font_size_override("bold_font_size", parent.font_size) - text.add_theme_font_size_override("italics_font_size", parent.font_size) - text.add_theme_font_size_override("bold_italics_font_size", parent.font_size) - text.add_theme_font_size_override("mono_font_size", parent.font_size) diff --git a/src/SuiTextTool.gd b/src/SuiTextTool.gd deleted file mode 100644 index 1c5a6a8..0000000 --- a/src/SuiTextTool.gd +++ /dev/null @@ -1,19 +0,0 @@ -@tool -extends Node - -func _process(_delta: float): - if !get_parent().editor_process: return - var parent: Control = get_parent() - var text: RichTextLabel = parent.get_node("Text") - - # Update sizes - text.size = parent.size - - # Update RichTextLabel stuff - text.bbcode_enabled = parent.bbcode_support - text.text = parent.text - text.add_theme_font_size_override("normal_font_size", parent.font_size) - text.add_theme_font_size_override("bold_font_size", parent.font_size) - text.add_theme_font_size_override("italics_font_size", parent.font_size) - text.add_theme_font_size_override("bold_italics_font_size", parent.font_size) - text.add_theme_font_size_override("mono_font_size", parent.font_size) diff --git a/src/SuiTypes.gd b/src/SuiTypes.gd new file mode 100644 index 0000000..7642980 --- /dev/null +++ b/src/SuiTypes.gd @@ -0,0 +1,22 @@ +extends Node +class_name SuiTypes + +## Used for determining the visibility of scroll bars. +enum ScrollVisibility { + AUTO, + SHOWN, + HIDDEN +} +## Used for determining how to get the result of various things. +enum ScrollMode { + MULTIPLY_VIEWPORT, + MULTIPLY_CUSTOM_VALUE, + CUSTOM_VALUE +} +## Indicates some scrolling direction. +enum ScrollDirection { + UP, + DOWN, + LEFT, + RIGHT +} diff --git a/themes/ScrollBar.tres b/themes/ScrollBar.tres new file mode 100644 index 0000000..5fefdb7 --- /dev/null +++ b/themes/ScrollBar.tres @@ -0,0 +1,3 @@ +[gd_resource type="Theme" format=3 uid="uid://jg7l68yqa6n2"] + +[resource]