Skip to content

Commit

Permalink
Issue-141: Added Art and Cards to Gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
Tysterman74 committed Dec 24, 2024
1 parent 60a6354 commit bb61ffa
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 21 deletions.
20 changes: 15 additions & 5 deletions #Scenes/GalleryItem.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://nr0k304sanb1"]

[ext_resource type="Script" path="res://#Scenes/SceneScripts/GalleryItem.gd" id="1_c4r4u"]
[ext_resource type="Texture2D" uid="uid://dvr6ky4vqv4lf" path="res://Art/Enemies/golden_cauldron-finished.png" id="1_lq7eu"]
[ext_resource type="PackedScene" uid="uid://caxbd2ppk3ans" path="res://Cards/Card.tscn" id="2_3mqsx"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_a8tpm"]
bg_color = Color(0.6, 0.6, 0.6, 0)
Expand All @@ -11,8 +11,10 @@ border_width_right = 5
border_width_bottom = 5
border_color = Color(0, 0, 0, 1)

[node name="GalleryItem" type="Node2D"]
[node name="GalleryItem" type="Node2D" node_paths=PackedStringArray("art_texture_node", "art_scroll_container")]
script = ExtResource("1_c4r4u")
art_texture_node = NodePath("ArtScrollContainer/Art")
art_scroll_container = NodePath("ArtScrollContainer")

[node name="ColorRect" type="ColorRect" parent="."]
anchors_preset = 15
Expand All @@ -32,17 +34,25 @@ offset_bottom = 68.0
text = "Back
"

[node name="ScrollContainer" type="ScrollContainer" parent="."]
[node name="Card" parent="." instance=ExtResource("2_3mqsx")]
visible = false
offset_left = 590.0
offset_top = 60.0
offset_right = 940.0
offset_bottom = 530.0
scale = Vector2(2, 2)

[node name="ArtScrollContainer" type="ScrollContainer" parent="."]
visible = false
offset_left = 114.0
offset_top = 104.0
offset_right = 1814.0
offset_bottom = 1004.0
theme_override_styles/panel = SubResource("StyleBoxFlat_a8tpm")

[node name="TextureRect" type="TextureRect" parent="ScrollContainer"]
[node name="Art" type="TextureRect" parent="ArtScrollContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("1_lq7eu")

[connection signal="pressed" from="Back" to="." method="_back_to_gallery"]
75 changes: 63 additions & 12 deletions #Scenes/GalleryScene.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
[gd_scene load_steps=3 format=3 uid="uid://budiktemb6mck"]
[gd_scene load_steps=11 format=3 uid="uid://budiktemb6mck"]

[ext_resource type="Script" path="res://#Scenes/SceneScripts/GalleryMenu.gd" id="1_87kxa"]
[ext_resource type="Texture2D" uid="uid://dvr6ky4vqv4lf" path="res://Art/Enemies/golden_cauldron-finished.png" id="2_nwnkr"]
[ext_resource type="Script" path="res://#Scenes/SceneScripts/GalleryArtInfo.gd" id="2_q254t"]
[ext_resource type="Texture2D" uid="uid://ua4ml58lwg4r" path="res://Art/Enemies/motorized_bears/motorized_bear_leader-finished.png" id="4_5lusa"]
[ext_resource type="Texture2D" uid="uid://qwjhfnceugt0" path="res://Art/Enemies/motorized_bears/motorized_bear_underlings_1-finished.png" id="5_wt8jc"]
[ext_resource type="Texture2D" uid="uid://cw0id8n5qemg8" path="res://Art/Enemies/motorized_bears/motorized_bear_underlings_2-finished.png" id="6_ylaeb"]

[node name="GalleryScene" type="Node2D"]
[sub_resource type="Resource" id="Resource_pomo2"]
script = ExtResource("2_q254t")
art_name = "Golden Cauldron"
author = "Ceres Fauna?"
texture = ExtResource("2_nwnkr")

[sub_resource type="Resource" id="Resource_j3yf8"]
script = ExtResource("2_q254t")
art_name = "Motorized Bear Leader"
author = "Ceres Fauna?"
texture = ExtResource("4_5lusa")

[sub_resource type="Resource" id="Resource_o5tj0"]
script = ExtResource("2_q254t")
art_name = "Motorized Bear Underling 1"
author = "Ceres Fauna?"
texture = ExtResource("5_wt8jc")

[sub_resource type="Resource" id="Resource_6yf4y"]
script = ExtResource("2_q254t")
art_name = "Motorized Bear Underling 2"
author = "Ceres Fauna?"
texture = ExtResource("6_ylaeb")

[node name="GalleryScene" type="Node2D" node_paths=PackedStringArray("mobs_box_tab", "cards_box_tab")]
script = ExtResource("1_87kxa")
mobs_box_tab = NodePath("TabContainer/Mobs/ScrollContainer/MobsGridContainer")
mobs_list = Array[ExtResource("2_q254t")]([SubResource("Resource_pomo2"), SubResource("Resource_j3yf8"), SubResource("Resource_o5tj0"), SubResource("Resource_6yf4y")])
cards_box_tab = NodePath("TabContainer/Cards/ScrollContainer/CardsGridContainer")

[node name="BackToMainMenu" type="Button" parent="."]
offset_left = 20.0
Expand All @@ -13,32 +44,52 @@ offset_right = 270.0
offset_bottom = 115.0
text = "Back to Main Menu"

[node name="TextureButton" type="TextureButton" parent="."]
visible = false
offset_left = 160.0
offset_top = 218.0
offset_right = 360.0
offset_bottom = 418.0
texture_normal = ExtResource("2_nwnkr")
ignore_texture_size = true
stretch_mode = 0

[node name="TabContainer" type="TabContainer" parent="."]
offset_left = 160.0
offset_top = 187.0
offset_right = 1760.0
offset_bottom = 987.0
all_tabs_in_front = true

[node name="Mobs" type="TabBar" parent="TabContainer"]
layout_mode = 2

[node name="TextureButton" type="TextureButton" parent="TabContainer/Mobs"]
[node name="ScrollContainer" type="ScrollContainer" parent="TabContainer/Mobs"]
layout_mode = 0
offset_left = 46.0
offset_top = 40.0
offset_right = 246.0
offset_bottom = 240.0
texture_normal = ExtResource("2_nwnkr")
ignore_texture_size = true
stretch_mode = 0
offset_right = 1601.0
offset_bottom = 768.0

[node name="MobsGridContainer" type="GridContainer" parent="TabContainer/Mobs/ScrollContainer"]
layout_mode = 2
size_flags_horizontal = 6
columns = 4

[node name="Cards" type="TabBar" parent="TabContainer"]
visible = false
layout_mode = 2

[node name="ScrollContainer" type="ScrollContainer" parent="TabContainer/Cards"]
layout_mode = 0
offset_right = 1598.0
offset_bottom = 771.0

[node name="CardsGridContainer" type="GridContainer" parent="TabContainer/Cards/ScrollContainer"]
layout_mode = 2
size_flags_horizontal = 6
columns = 4

[node name="Music" type="TabBar" parent="TabContainer"]
visible = false
layout_mode = 2

[connection signal="pressed" from="BackToMainMenu" to="." method="_back_to_main_menu_pressed"]
[connection signal="pressed" from="TabContainer/Mobs/TextureButton" to="." method="_go_to_gallery_item"]
[connection signal="pressed" from="TextureButton" to="." method="_go_to_gallery_item"]
6 changes: 6 additions & 0 deletions #Scenes/SceneScripts/GalleryArtInfo.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends GalleryInfo
class_name GalleryArtInfo

@export var art_name: String
@export var author: String
@export var texture: Texture2D
4 changes: 4 additions & 0 deletions #Scenes/SceneScripts/GalleryCardInfo.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends GalleryInfo
class_name GalleryCardInfo

@export var card_resource: Resource
2 changes: 2 additions & 0 deletions #Scenes/SceneScripts/GalleryInfo.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends Resource
class_name GalleryInfo
21 changes: 20 additions & 1 deletion #Scenes/SceneScripts/GalleryItem.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
extends Node
extends Node2D
class_name GalleryItem

@onready var card: PackedScene = preload("res://Cards/Card.tscn")

# Take in information of type of material to show
# Card, Art, or Sapling Message
# Create Different objects for the different materials, then show/hide based on the material we want to show
@export var art_texture_node: TextureRect

@export var art_scroll_container: Control

var gallery_info: GalleryInfo = null

func _ready() -> void:
if gallery_info is GalleryArtInfo:
art_scroll_container.visible = true
art_texture_node.texture = gallery_info.texture
elif gallery_info is GalleryCardInfo:
var card_world: CardWorld = card.instantiate()
card_world.card_data = load(gallery_info.card_resource.resource_path)
card_world.position = Vector2(590, 60)
card_world.scale = Vector2(2, 2)
add_child(card_world)

func _back_to_gallery() -> void:
queue_free()
38 changes: 35 additions & 3 deletions #Scenes/SceneScripts/GalleryMenu.gd
Original file line number Diff line number Diff line change
@@ -1,14 +1,46 @@
extends Node

@onready var gallery_item_scene: PackedScene = preload("res://#Scenes/GalleryItem.tscn")
@onready var card: PackedScene = preload("res://Cards/Card.tscn")

@export var mobs_box_tab: Control
@export var mobs_list: Array[GalleryArtInfo]

@export var cards_box_tab: Control

func _ready() -> void:
pass
_populate_mobs_tab()
_populate_cards_tab()

func _back_to_main_menu_pressed() -> void:
SceneManager.goto_scene("res://#Scenes/MainMenu.tscn")

func _go_to_gallery_item() -> void:
var gallery_item: Node2D = gallery_item_scene.instantiate()
func _go_to_gallery_item(gallery_info: GalleryInfo) -> void:
var gallery_item: GalleryItem = gallery_item_scene.instantiate()
gallery_item.gallery_info = gallery_info

get_parent().add_child(gallery_item)

func _populate_mobs_tab() -> void:
var mob_texture_button_size: Vector2 = Vector2(400, 400)
for mobs in mobs_list:
var texture_button: TextureButton = TextureButton.new()
texture_button.ignore_texture_size = true
texture_button.stretch_mode = TextureButton.STRETCH_SCALE
texture_button.custom_minimum_size = mob_texture_button_size
texture_button.texture_normal = mobs.texture
texture_button.pressed.connect(_go_to_gallery_item.bind(mobs))
mobs_box_tab.add_child(texture_button)

func _populate_cards_tab() -> void:
var cards_list: Array[GalleryCardInfo]
for card_resource_file in DirAccess.get_files_at("res://Cards/Resource/"):
var gallery_card_info: GalleryCardInfo = GalleryCardInfo.new()
gallery_card_info.card_resource = load("res://Cards/Resource/" + card_resource_file)
cards_list.append(gallery_card_info)

for cards in cards_list:
var card_world: CardWorld = card.instantiate()
card_world.card_data = load(cards.card_resource.resource_path)
card_world.get_click_handler().on_click.connect(_go_to_gallery_item.bind(cards))
cards_box_tab.add_child(card_world)

0 comments on commit bb61ffa

Please sign in to comment.