Compare commits

...

2 commits

4 changed files with 206 additions and 63 deletions

View file

@ -23,7 +23,7 @@ boot_splash/fullsize=false
window/size/viewport_width=1440 window/size/viewport_width=1440
window/size/viewport_height=810 window/size/viewport_height=810
window/size/resizable=false window/stretch/mode="canvas_items"
[editor] [editor]
@ -32,7 +32,7 @@ export/convert_text_resources_to_binary=false
[editor_plugins] [editor_plugins]
enabled=PackedStringArray() enabled=PackedStringArray("res://addons/SUI/plugin.cfg")
[filesystem] [filesystem]

View file

@ -1,10 +1,164 @@
[gd_scene load_steps=3 format=3 uid="uid://cbqdxkaq5m44g"] [gd_scene load_steps=10 format=3 uid="uid://cbqdxkaq5m44g"]
[ext_resource type="Shader" path="res://assets/shaders/blur.gdshader" id="1_6kunn"]
[ext_resource type="Script" path="res://src/userinterface.gd" id="1_7rse1"] [ext_resource type="Script" path="res://src/userinterface.gd" id="1_7rse1"]
[ext_resource type="Texture2D" uid="uid://485ypkeljwca" path="res://assets/images/WallpaperResized.png" id="1_kfnw8"] [ext_resource type="Texture2D" uid="uid://485ypkeljwca" path="res://assets/images/WallpaperResized.png" id="1_kfnw8"]
[ext_resource type="Texture2D" uid="uid://b23f0o450c2xl" path="res://assets/images/IconText.png" id="3_hxo5p"]
[ext_resource type="PackedScene" uid="uid://bso65vpjqc4g4" path="res://addons/SUI/scenesrc/SuiText.tscn" id="5_lpbss"]
[ext_resource type="PackedScene" uid="uid://4hi8y7pu3w0v" path="res://addons/SUI/scenesrc/SuiTextButton.tscn" id="6_xj8q1"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tg5oh"]
shader = ExtResource("1_6kunn")
shader_parameter/radius = 4.0
shader_parameter/steps = 32
shader_parameter/vertex_expand = 1.0
[sub_resource type="Animation" id="Animation_8cqjd"]
resource_name = "anim"
length = 0.5
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.3, 0.5),
"transitions": PackedFloat32Array(3, 1, 1),
"update": 0,
"values": [Vector2(1, 1), Vector2(1.063, 1.063), Vector2(1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_hqqk1"]
_data = {
"anim": SubResource("Animation_8cqjd")
}
[node name="UserInterface" type="NinePatchRect"] [node name="UserInterface" type="NinePatchRect"]
material = SubResource("ShaderMaterial_tg5oh")
offset_right = 1440.0 offset_right = 1440.0
offset_bottom = 810.0 offset_bottom = 810.0
texture = ExtResource("1_kfnw8") texture = ExtResource("1_kfnw8")
script = ExtResource("1_7rse1") script = ExtResource("1_7rse1")
[node name="Logo" type="NinePatchRect" parent="."]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -480.0
offset_top = 80.0
offset_right = 480.0
offset_bottom = 260.0
grow_horizontal = 2
texture = ExtResource("3_hxo5p")
[node name="Splash" parent="." instance=ExtResource("5_lpbss")]
modulate = Color(1, 1, 0, 1)
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
anchor_bottom = 0.0
offset_left = 177.0
offset_top = 210.0
offset_right = 619.0
offset_bottom = 300.0
grow_vertical = 1
rotation = -0.366519
pivot_offset = Vector2(221, 45)
text = "[center]Hmm... something went wrong.[/center]"
font_size = 30
[node name="AnimPlayer" type="AnimationPlayer" parent="Splash"]
libraries = {
"": SubResource("AnimationLibrary_hqqk1")
}
autoplay = "anim"
[node name="Switcher" type="Button" parent="Splash"]
self_modulate = Color(1, 1, 1, 0)
layout_mode = 0
offset_right = 442.0
offset_bottom = 90.0
[node name="Buttons" type="Control" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -179.0
offset_top = -88.5
offset_right = 179.0
offset_bottom = 88.5
grow_horizontal = 2
grow_vertical = 2
[node name="Present" parent="Buttons" instance=ExtResource("6_xj8q1")]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
anchor_bottom = 0.0
offset_left = -175.0
offset_right = 175.0
offset_bottom = 53.0
grow_vertical = 1
text = "[center]Open presentation[/center]"
[node name="Docs" parent="Buttons" instance=ExtResource("6_xj8q1")]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -175.0
offset_top = -26.5
offset_right = 175.0
offset_bottom = 26.5
text = "[center]View documentation[/center]"
[node name="ClosePresencode" parent="Buttons" instance=ExtResource("6_xj8q1")]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
offset_left = -175.0
offset_top = -53.0
offset_right = 175.0
offset_bottom = 0.0
grow_vertical = 0
text = "[center]Close Presencode[/center]"
[node name="CopyrightLicense" parent="." instance=ExtResource("5_lpbss")]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
offset_left = -481.5
offset_top = -114.0
offset_right = 481.5
offset_bottom = -40.0
grow_vertical = 0
text = "[center]Copyright (c) 2024 JeremyStarTM & Contributors.
Licensed under the GNU Affero General Public License v3 WITHOUT ANY WARRANTY.[/center]"
[node name="WallpaperAttribution" parent="." instance=ExtResource("5_lpbss")]
modulate = Color(0, 0, 0, 1)
layout_mode = 1
anchors_preset = 0
anchor_right = 0.0
anchor_bottom = 0.0
offset_left = 5.0
offset_top = 5.0
offset_right = 653.0
offset_bottom = 46.0
grow_horizontal = 1
grow_vertical = 1
text = "Copyright (c) Thomas Wolf, www.foto-tw.de (CC BY-SA 3.0)"

View file

@ -72,7 +72,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.""")
var userinterface: NinePatchRect = load("res://scenesrc/UserInterface.tscn").instantiate() var userinterface: NinePatchRect = load("res://scenesrc/UserInterface.tscn").instantiate()
userinterface.name = "UserInterface" userinterface.name = "UserInterface"
userinterface.core_config = core_config.duplicate() userinterface.core_config = core_config.duplicate()
userinterface.ui_scale = args["ui_scale"]
get_tree().root.add_child.call_deferred(userinterface) get_tree().root.add_child.call_deferred(userinterface)
# Perform cleanup # Perform cleanup
@ -90,8 +89,8 @@ func cleanup() -> void:
# Parses all arguments # Parses all arguments
func parse_cmdline() -> Dictionary: func parse_cmdline() -> Dictionary:
logger.verb("Parsing command line arguments") logger.verb("Parsing command line arguments")
var args: Dictionary = { "shutdown": false, "load_presentation": false, "presentation_path": "", "logger_level": core_config.logger_level, "ui_scale": 1.0, "allow_high_ui_scale": false } var args: Dictionary = { "shutdown": false, "load_presentation": false, "presentation_path": "", "logger_level": core_config.logger_level }
var processed: Dictionary = { "presentation": false, "logger_level": false, "ui_scale": false, "allow_high_ui_scale": false } var processed: Dictionary = { "presentation": false, "logger_level": false }
for arg in OS.get_cmdline_user_args(): for arg in OS.get_cmdline_user_args():
logger.diag(core.misc.stringify_variables("Parsing cmdline argument %arg%", { "arg": arg })) logger.diag(core.misc.stringify_variables("Parsing cmdline argument %arg%", { "arg": arg }))
@ -112,11 +111,6 @@ Usage (development setup): /path/to/godot.binary -d -v --path . ++ <further argu
Further arguments: Further arguments:
--logger-level=<DIAG|VERB|INFO|WARN|ERROR> Sets the logger level, defaults to DIAG in debug --logger-level=<DIAG|VERB|INFO|WARN|ERROR> Sets the logger level, defaults to DIAG in debug
                                              builds and INFO in release builds.                                               builds and INFO in release builds.
--allow-high-ui-scale Allows setting the ui scale above 5.
                                              Please note that higher --ui-scale values
                                              can cause freezes.
--ui-scale=<float> Sets how large ui elements should be.
                                              Does not affect presentations.
/path/to/presentation.pcar Path to the presentation Presencode should open. /path/to/presentation.pcar Path to the presentation Presencode should open.
                                              If not supplied, a user interface will appear.                                               If not supplied, a user interface will appear.
+++ PRESENCODE HELP +++""") +++ PRESENCODE HELP +++""")
@ -144,36 +138,6 @@ Further arguments:
"WARN": args["logger_level"] = CoreTypes.LoggerLevel.WARN "WARN": args["logger_level"] = CoreTypes.LoggerLevel.WARN
"ERROR": args["logger_level"] = CoreTypes.LoggerLevel.ERROR "ERROR": args["logger_level"] = CoreTypes.LoggerLevel.ERROR
_: logger.error(core.misc.stringify_variables("Unable to parse argument %arg%: Can't match logger level %got%, possible are: %expected%", { "arg": arg, "got": arg.replace("--logger-level=", ""), "expected": [ "DIAG", "VERB", "INFO", "WARN", "ERROR" ] })) _: logger.error(core.misc.stringify_variables("Unable to parse argument %arg%: Can't match logger level %got%, possible are: %expected%", { "arg": arg, "got": arg.replace("--logger-level=", ""), "expected": [ "DIAG", "VERB", "INFO", "WARN", "ERROR" ] }))
elif arg.contains("--ui-scale="):
# Ensure this argument is not overridden
if processed["ui_scale"]:
logger.error(core.misc.stringify_variables("Unable to parse argument %arg%: Already set", { "arg": arg }))
continue
processed["ui_scale"] = true
# Run checks
if !arg.replace("--ui-scale=", "").is_valid_float() or arg.replace("--ui-scale=", "").to_float() < 1.0:
logger.error(core.misc.stringify_variables("Unable to parse argument %arg%: Must be a float above 1", { "arg": arg }))
continue
var argf: float = arg.replace("--ui-scale=", "").to_float()
# Check if allowed
if argf > 5.0 and !args["allow_high_ui_scale"]:
logger.error(core.misc.stringify_variables("Unable to parse argument %arg%: High ui scale values (> 5) are not allowed.\nPlease pass --allow-high-ui-scale before --ui-scale= to Presencode if you want high ui scale values.", { "arg": arg }))
continue
# Update 'args'
args["ui_scale"] = argf
elif arg.contains("--allow-high-ui-scale"):
# Ensure this argument is not overridden
if processed["allow_high_ui_scale"]:
logger.error(core.misc.stringify_variables("Unable to parse argument %arg%: Already set", { "arg": arg }))
continue
processed["allow_high_ui_scale"] = true
# Update 'args'
args["allow_high_ui_scale"] = true
else: else:
if arg.begins_with("--"): logger.error(core.misc.stringify_variables("Unable to parse argument %arg%: Option not recognized", { "arg": arg })) if arg.begins_with("--"): logger.error(core.misc.stringify_variables("Unable to parse argument %arg%: Option not recognized", { "arg": arg }))
else: else:

View file

@ -5,36 +5,55 @@ var core_config: CoreConfiguration
@onready var core: Core = get_node("/root/CORE") @onready var core: Core = get_node("/root/CORE")
@onready var logger: CoreLoggerInstance = core.logger.get_instance("src/userinterface.gd", self) @onready var logger: CoreLoggerInstance = core.logger.get_instance("src/userinterface.gd", self)
# CORE-related # Variables
var shutdown: bool = false var shutdown: bool = false
var cleanup_hook: int var cleanup_hook: int
var splashes: Array[String] = [
"Made in Godot 4.2!",
"Made with the CORE Framework!",
"Awesome!",
"Cute!",
"Dangerous.",
"Dangerously explosive!",
"Made in Germany",
": Godot Edition",
"this was blatantly ripped off from Minecraft",
"Trans rights are human rights!",
"// TODO",
"UwU",
"open source :)",
"i use presencode btw",
"i use arch btw",
"69 haha funny number",
"<3 neofox",
"<3 blobfox",
"<3",
"Coin Score % 256 = Saved Coin Score",
"xD",
"Now in 2D!",
"very bad",
"beta and alpha males are overrated, i'm a release male"
]
# Threads # Threads
var thread_wallpaper: Thread = Thread.new() var thread_wallpaper: Thread = Thread.new()
# UI settings
var ui_scale: float = 1.0
# +++ initialization +++ # +++ initialization +++
func _ready() -> void: func _ready() -> void:
# Register cleanup hook # Register cleanup hook
cleanup_hook = core.register_cleanup_hook(Callable(self, "cleanup")) cleanup_hook = core.register_cleanup_hook(Callable(self, "cleanup"))
# Call update methods # Call update methods
update_scale()
update_splash() update_splash()
add_connections()
logger.info("User Interface is ready") logger.info("User Interface is ready")
# Load higher quality wallpaper # Load higher quality wallpaper in a thread.
# This has been done to decrease loading
# times and make the UX/DX much better.
await get_tree().process_frame await get_tree().process_frame
thread_wallpaper.start(func() -> void: thread_wallpaper.start(func() -> void:
# Skip loading a higher quality version of the wallpaper
# if 'ui_scale' is under two (because it looks like shit)
if ui_scale < 2.0:
logger.warn.call_deferred("Not loading higher quality wallpaper")
return
logger.info.call_deferred("Loading higher quality wallpaper") logger.info.call_deferred("Loading higher quality wallpaper")
var path: String = "res://docs/static/assets/images/Wallpaper.png" var path: String = "res://docs/static/assets/images/Wallpaper.png"
@ -74,17 +93,23 @@ func cleanup() -> void:
get_parent().remove_child(self) get_parent().remove_child(self)
queue_free() queue_free()
# +++ update methods +++ # Adds connections
# Updates the scale of all UI elements func add_connections() -> void:
func update_scale() -> void: # Splash update button
logger.diag(core.misc.stringify_variables("Updating UI scale to %scale%x", { "scale": ui_scale })) $Splash/Switcher.connect("pressed", func() -> void: update_splash())
size.x = 1440*ui_scale
size.y = 810*ui_scale
logger.diag(core.misc.stringify_variables("Updating window size to %size%", { "size": Vector2i(size)})) # Buttons
DisplayServer.window_set_size(size) $Buttons/Present.connect("pressed", func() -> void:
DisplayServer.window_set_position(core.misc.get_center(DisplayServer.screen_get_size(), Vector2i(size))) logger.error("Not implemented.")
)
$Buttons/Docs.connect("pressed", func() -> void: OS.shell_open("https://presencode.jstm.staropensource.de"))
$Buttons/ClosePresencode.connect("pressed", func() -> void: core.quit_safely(0))
# Updates the splash text # Updates the splash text
func update_splash() -> void: func update_splash() -> void:
return var new_splash: String = splashes.pick_random()
while true:
if new_splash != $Splash.text:
break
$Splash.text = "[center]" + new_splash + "[/center]"