diff --git a/project.godot b/project.godot index 449e60a..8cd7de2 100644 --- a/project.godot +++ b/project.godot @@ -23,7 +23,7 @@ boot_splash/fullsize=false window/size/viewport_width=1440 window/size/viewport_height=810 -window/size/resizable=false +window/stretch/mode="canvas_items" [editor] diff --git a/scenesrc/UserInterface.tscn b/scenesrc/UserInterface.tscn index 44f7039..d4c4613 100644 --- a/scenesrc/UserInterface.tscn +++ b/scenesrc/UserInterface.tscn @@ -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="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"] +material = SubResource("ShaderMaterial_tg5oh") offset_right = 1440.0 offset_bottom = 810.0 texture = ExtResource("1_kfnw8") 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)" diff --git a/src/userinterface.gd b/src/userinterface.gd index 55be0a3..9e582c3 100644 --- a/src/userinterface.gd +++ b/src/userinterface.gd @@ -5,36 +5,55 @@ var core_config: CoreConfiguration @onready var core: Core = get_node("/root/CORE") @onready var logger: CoreLoggerInstance = core.logger.get_instance("src/userinterface.gd", self) -# CORE-related +# Variables var shutdown: bool = false 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 var thread_wallpaper: Thread = Thread.new() -# UI settings -var ui_scale: float = 1.0 - # +++ initialization +++ func _ready() -> void: # Register cleanup hook cleanup_hook = core.register_cleanup_hook(Callable(self, "cleanup")) # Call update methods - update_scale() update_splash() + add_connections() 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 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") var path: String = "res://docs/static/assets/images/Wallpaper.png" @@ -74,17 +93,23 @@ func cleanup() -> void: get_parent().remove_child(self) queue_free() -# +++ update methods +++ -# Updates the scale of all UI elements -func update_scale() -> void: - logger.diag(core.misc.stringify_variables("Updating UI scale to %scale%x", { "scale": ui_scale })) - size.x = 1440*ui_scale - size.y = 810*ui_scale +# Adds connections +func add_connections() -> void: + # Splash update button + $Splash/Switcher.connect("pressed", func() -> void: update_splash()) - logger.diag(core.misc.stringify_variables("Updating window size to %size%", { "size": Vector2i(size)})) - DisplayServer.window_set_size(size) - DisplayServer.window_set_position(core.misc.get_center(DisplayServer.screen_get_size(), Vector2i(size))) + # Buttons + $Buttons/Present.connect("pressed", func() -> void: + 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 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]"