Added class documentation + renamed size_* (->msg)
I also renamed all 'size_*' variables in SuiScroller.gd to 'thickness_*' as it's a much better fitting name.
This commit is contained in:
parent
3e036096b0
commit
0828d019b6
7 changed files with 77 additions and 18 deletions
|
@ -55,6 +55,9 @@ offset_left = 11.0
|
|||
offset_top = 8.0
|
||||
offset_right = -1124.0
|
||||
offset_bottom = -576.0
|
||||
thickness_mode = null
|
||||
thickness_multiplier = null
|
||||
thickness_value = null
|
||||
|
||||
[node name="Control" type="Control" parent="SuiScroller"]
|
||||
anchors_preset = 0
|
||||
|
@ -111,6 +114,9 @@ offset_left = 338.0
|
|||
offset_top = 20.0
|
||||
offset_right = -814.0
|
||||
offset_bottom = -577.0
|
||||
thickness_mode = null
|
||||
thickness_multiplier = null
|
||||
thickness_value = null
|
||||
|
||||
[node name="Control" type="Control" parent="SuiScroller2"]
|
||||
anchors_preset = 0
|
||||
|
|
|
@ -2,28 +2,38 @@
|
|||
extends Control
|
||||
class_name SuiBaseClass
|
||||
|
||||
## Reference to the [CORE] Object.
|
||||
var core: Core
|
||||
## Reference to a [CoreLoggerInstance]
|
||||
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
|
||||
func _ready() -> void:
|
||||
if !in_editor(): core = get_node("/root/CORE")
|
||||
|
||||
# Calls 'update_element()' if allowed to execute
|
||||
func _process(_delta: float):
|
||||
if execute_process(): update_element()
|
||||
|
||||
# +++ element updating +++
|
||||
# This should be used by the element extending this script
|
||||
# to provide their own update logic.
|
||||
func update_element() -> void: pass
|
||||
|
||||
# +++ etc +++
|
||||
# Determines if '_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 the editor
|
||||
func in_editor() -> bool:
|
||||
return get_node_or_null("/root/CORE") == null
|
||||
|
|
|
@ -3,8 +3,11 @@ 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 font should have.
|
||||
@export var font_size: int = 35
|
||||
|
||||
func update_element() -> void:
|
||||
|
|
|
@ -3,12 +3,18 @@ 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 overwritten with the internal button's value, any manual 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")
|
||||
|
@ -22,12 +28,18 @@ extends SuiBaseClass
|
|||
@export var pm_right: int = 0
|
||||
@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
|
||||
|
||||
## 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:
|
||||
|
|
|
@ -3,20 +3,32 @@ 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
|
||||
## The speed value, used for [constant SuiTypes.ScrollMode.MULTIPLY_CUSTOM_VALUE] and [constant SuiTypes.ScrollMode.CUSTOM_VALUE].
|
||||
@export var speed_value: float = 1
|
||||
@export_subgroup("Scroller speed (wheel)")
|
||||
## Determines how much the scrolling speed should be multiplied by when scrolling with the scroll wheel.
|
||||
## Using a lower value results in more mouse scrolling, higher values result in less mouse scrolling.
|
||||
@export var speed_wheel_multiplier: float = 50
|
||||
@export_subgroup("Scroller size")
|
||||
@export var size_mode: SuiTypes.ScrollMode = SuiTypes.ScrollMode.MULTIPLY_VIEWPORT
|
||||
@export var size_multiplier: float = 0.025
|
||||
@export var size_value: float = 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
|
||||
@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
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -29,7 +41,7 @@ func update_element() -> void:
|
|||
else: clip_contents = true
|
||||
|
||||
# Update sizes and positions
|
||||
match(size_mode):
|
||||
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
|
||||
|
@ -37,14 +49,14 @@ func update_element() -> void:
|
|||
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*size_multiplier
|
||||
$VScrollBar.size.x = scale_size*size_multiplier
|
||||
$HScrollBar.size.y = scale_size*thickness_multiplier
|
||||
$VScrollBar.size.x = scale_size*thickness_multiplier
|
||||
SuiTypes.ScrollMode.MULTIPLY_CUSTOM_VALUE:
|
||||
$HScrollBar.size.y = size_value*size_multiplier
|
||||
$VScrollBar.size.x = size_value*size_multiplier
|
||||
$HScrollBar.size.y = thickness_value*thickness_multiplier
|
||||
$VScrollBar.size.x = thickness_value*thickness_multiplier
|
||||
SuiTypes.ScrollMode.CUSTOM_VALUE:
|
||||
$HScrollBar.size.y = size_value
|
||||
$VScrollBar.size.x = size_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
|
||||
|
@ -151,7 +163,7 @@ func update_element() -> void:
|
|||
$HScrollBar.max_value = size.x
|
||||
$VScrollBar.max_value = size.y
|
||||
|
||||
func scroll(direction: SuiTypes.ScrollDirection) -> void:
|
||||
func _scroll(direction: SuiTypes.ScrollDirection) -> void:
|
||||
var bar: ScrollBar
|
||||
var dsign: int = 0
|
||||
|
||||
|
@ -177,13 +189,13 @@ func _input(event: InputEvent):
|
|||
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)
|
||||
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)
|
||||
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:
|
||||
|
|
|
@ -3,12 +3,18 @@ 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 font should have.
|
||||
@export var font_size: int = 25
|
||||
|
||||
## 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():
|
||||
|
|
|
@ -3,17 +3,27 @@ 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 overwritten with the internal button's value, any manual 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 font should have.
|
||||
@export var font_size: int = 35
|
||||
|
||||
## 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:
|
||||
|
|
Loading…
Reference in a new issue