commit 994fca9f45e06a365f74dc203beb7169bf2ead84 Author: David J. Allen Date: Mon Oct 21 22:57:51 2024 -0600 initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/Slideshow.gd b/Slideshow.gd new file mode 100644 index 0000000..3b1182f --- /dev/null +++ b/Slideshow.gd @@ -0,0 +1,110 @@ +extends Control + +@onready var button_next := %Next +@onready var button_previous := %Previous +@onready var content := %Content +@onready var frame := %Frame + +var current_index := 0 +var duration := 0.5 + +func _ready() -> void: + _initialize() + + +func _initialize() -> void: + button_next.pressed.connect(_cycle_next) + button_previous.pressed.connect(_cycle_previous) + + # move all slides off screen and fit to content frame (if not ignoring sizes) + _content_fit_size() + _content_reset_positions() + var initial_slide := content.get_child(0) + initial_slide.set_position(content.get_position()) + + +func _content_fit_size() -> void: + for slide in content.get_children(): + slide.set_size(content.get_size()) + + +func _content_reset_positions() -> void: + for slide in content.get_children(): + slide.set_position( + Vector2( + frame.get_position().x - slide.get_size().x, + frame.get_position().y + ) + ) + + +func _cycle_next() -> void: + # get the index of the next node + var next_index := current_index + 1 + var slide_count := content.get_child_count() + if next_index >= slide_count: + next_index = 0 + + # set the initial position of next slide to the left of content before moving + var next_node := content.get_child(next_index) + next_node.set_position( + Vector2( + frame.get_position().x - content.get_size().x, + content.get_position().y + ) + ) + + # slide the current and next nodes to the right simultaneously + var current_slide := content.get_child(current_index) + var tween := get_tree().create_tween().set_parallel(true) + tween.tween_property( + current_slide, + "position:x", + frame.get_position().x + frame.get_size().x, # at end of frame + duration + ).set_trans(Tween.TRANS_CUBIC) + tween.tween_property( + next_node, + "position:x", + content.get_position().x, # at beginning of content + duration + ).set_trans(Tween.TRANS_CUBIC) + + # set the current index to the next one + current_index = next_index + + +func _cycle_previous() -> void: + # get the index of the previous node + var previous_index := current_index - 1 + var slide_count := content.get_child_count() + if previous_index < 0: + previous_index = slide_count - 1 + + # set the initial position of previous slide to the right of content before moving + var previous_node := content.get_child(previous_index) + previous_node.set_position( + Vector2( + content.get_position().x + content.get_size().x, + content.get_position().y + ) + ) + + # slide the current and previous nodes to the left simultaneously + var current_slide := content.get_child(current_index) + var tween := get_tree().create_tween().set_parallel(true) + tween.tween_property( + current_slide, + "position:x", + frame.get_position().x - frame.get_size().x, # at left of frame + duration + ).set_trans(Tween.TRANS_CUBIC) + tween.tween_property( + previous_node, + "position:x", + content.get_position().x, # at beginning of content + duration + ).set_trans(Tween.TRANS_CUBIC) + + # set the current index to the previous one + current_index = previous_index diff --git a/Slideshow.tscn b/Slideshow.tscn new file mode 100644 index 0000000..6539092 --- /dev/null +++ b/Slideshow.tscn @@ -0,0 +1,110 @@ +[gd_scene load_steps=7 format=3 uid="uid://gxkftwihyaeb"] + +[ext_resource type="Script" path="res://Slideshow.gd" id="1_c4yco"] +[ext_resource type="Texture2D" uid="uid://hae3xxu5gi1j" path="res://assets/textures/left.png" id="2_ipc81"] +[ext_resource type="Texture2D" uid="uid://htlpmfnfxo0p" path="res://assets/textures/airplanecomercial.png" id="3_r020g"] +[ext_resource type="Texture2D" uid="uid://cq85cp58w2yo" path="res://assets/textures/coin.png" id="4_k2rtf"] +[ext_resource type="Texture2D" uid="uid://b0clm03ld3sqt" path="res://assets/textures/checkmark.png" id="5_drrg7"] +[ext_resource type="Texture2D" uid="uid://bj1lt3rs788c0" path="res://assets/textures/right.png" id="6_07ka3"] + +[node name="Slideshow" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_c4yco") + +[node name="Container" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="ScrollContainer" type="ScrollContainer" parent="Container"] +layout_mode = 2 +vertical_scroll_mode = 0 + +[node name="Frame" type="HBoxContainer" parent="Container/ScrollContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +alignment = 1 + +[node name="Previous" type="TextureButton" parent="Container/ScrollContainer/Frame"] +unique_name_in_owner = true +layout_mode = 2 +keep_pressed_outside = true +texture_normal = ExtResource("2_ipc81") +stretch_mode = 3 + +[node name="ContentFrame" type="PanelContainer" parent="Container/ScrollContainer/Frame"] +clip_children = 1 +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="MarginContainer" type="MarginContainer" parent="Container/ScrollContainer/Frame/ContentFrame"] +layout_mode = 2 +theme_override_constants/margin_left = 16 +theme_override_constants/margin_top = 16 +theme_override_constants/margin_right = 16 +theme_override_constants/margin_bottom = 16 + +[node name="Content" type="Control" parent="Container/ScrollContainer/Frame/ContentFrame/MarginContainer"] +unique_name_in_owner = true +layout_mode = 2 + +[node name="TextureRect" type="TextureRect" parent="Container/ScrollContainer/Frame/ContentFrame/MarginContainer/Content"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +texture = ExtResource("3_r020g") +expand_mode = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="Container/ScrollContainer/Frame/ContentFrame/MarginContainer/Content"] +layout_mode = 0 +offset_right = 914.0 +offset_bottom = 392.0 + +[node name="TextureRect2" type="TextureRect" parent="Container/ScrollContainer/Frame/ContentFrame/MarginContainer/Content/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +texture = ExtResource("4_k2rtf") + +[node name="TextureRect3" type="TextureRect" parent="Container/ScrollContainer/Frame/ContentFrame/MarginContainer/Content/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +texture = ExtResource("4_k2rtf") + +[node name="TextureRect4" type="TextureRect" parent="Container/ScrollContainer/Frame/ContentFrame/MarginContainer/Content/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +texture = ExtResource("4_k2rtf") + +[node name="TextureRect3" type="TextureRect" parent="Container/ScrollContainer/Frame/ContentFrame/MarginContainer/Content"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +texture = ExtResource("5_drrg7") +stretch_mode = 5 + +[node name="Next" type="TextureButton" parent="Container/ScrollContainer/Frame"] +unique_name_in_owner = true +layout_mode = 2 +keep_pressed_outside = true +texture_normal = ExtResource("6_07ka3") +stretch_mode = 3 diff --git a/assets/textures/airplanecomercial.png b/assets/textures/airplanecomercial.png new file mode 100644 index 0000000..82ab743 Binary files /dev/null and b/assets/textures/airplanecomercial.png differ diff --git a/assets/textures/airplanecomercial.png.import b/assets/textures/airplanecomercial.png.import new file mode 100644 index 0000000..0b9ebdd --- /dev/null +++ b/assets/textures/airplanecomercial.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://htlpmfnfxo0p" +path="res://.godot/imported/airplanecomercial.png-3604b65d4ac6f1ad581f4e92ef3402ff.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/airplanecomercial.png" +dest_files=["res://.godot/imported/airplanecomercial.png-3604b65d4ac6f1ad581f4e92ef3402ff.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/textures/checkmark.png b/assets/textures/checkmark.png new file mode 100644 index 0000000..f912260 Binary files /dev/null and b/assets/textures/checkmark.png differ diff --git a/assets/textures/checkmark.png.import b/assets/textures/checkmark.png.import new file mode 100644 index 0000000..7da1a48 --- /dev/null +++ b/assets/textures/checkmark.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b0clm03ld3sqt" +path="res://.godot/imported/checkmark.png-90bf058668dc6a15e6471f7d8f9eb18b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/checkmark.png" +dest_files=["res://.godot/imported/checkmark.png-90bf058668dc6a15e6471f7d8f9eb18b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/textures/coin.png b/assets/textures/coin.png new file mode 100644 index 0000000..712ddbd Binary files /dev/null and b/assets/textures/coin.png differ diff --git a/assets/textures/coin.png.import b/assets/textures/coin.png.import new file mode 100644 index 0000000..4f65b82 --- /dev/null +++ b/assets/textures/coin.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cq85cp58w2yo" +path="res://.godot/imported/coin.png-a2185d81c51e3615d0293c91c41f2138.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/coin.png" +dest_files=["res://.godot/imported/coin.png-a2185d81c51e3615d0293c91c41f2138.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/textures/exclamation.png b/assets/textures/exclamation.png new file mode 100644 index 0000000..951d06f Binary files /dev/null and b/assets/textures/exclamation.png differ diff --git a/assets/textures/exclamation.png.import b/assets/textures/exclamation.png.import new file mode 100644 index 0000000..a717528 --- /dev/null +++ b/assets/textures/exclamation.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://gq2e4nsmxvgv" +path="res://.godot/imported/exclamation.png-12d4abaa636464265fe9bf460e2c4bc3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/exclamation.png" +dest_files=["res://.godot/imported/exclamation.png-12d4abaa636464265fe9bf460e2c4bc3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/textures/left.png b/assets/textures/left.png new file mode 100644 index 0000000..ebfb42a Binary files /dev/null and b/assets/textures/left.png differ diff --git a/assets/textures/left.png.import b/assets/textures/left.png.import new file mode 100644 index 0000000..0d08447 --- /dev/null +++ b/assets/textures/left.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://hae3xxu5gi1j" +path="res://.godot/imported/left.png-bd97b939cfc653e64b2698a809562f8d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/left.png" +dest_files=["res://.godot/imported/left.png-bd97b939cfc653e64b2698a809562f8d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/textures/right.png b/assets/textures/right.png new file mode 100644 index 0000000..d0a2528 Binary files /dev/null and b/assets/textures/right.png differ diff --git a/assets/textures/right.png.import b/assets/textures/right.png.import new file mode 100644 index 0000000..9430daa --- /dev/null +++ b/assets/textures/right.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bj1lt3rs788c0" +path="res://.godot/imported/right.png-e73bbacd62879aa4c672f3bc1e84ca8e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/right.png" +dest_files=["res://.godot/imported/right.png-e73bbacd62879aa4c672f3bc1e84ca8e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..9d8b7fa --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..a135e65 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://64vwvssqlvbo" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..a2889bd --- /dev/null +++ b/project.godot @@ -0,0 +1,16 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Slideshow" +run/main_scene="res://Slideshow.tscn" +config/features=PackedStringArray("4.3", "Forward Plus") +config/icon="res://icon.svg"