-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue-141: Added Art and Cards to Gallery
- Loading branch information
1 parent
60a6354
commit bb61ffa
Showing
7 changed files
with
145 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extends GalleryInfo | ||
class_name GalleryCardInfo | ||
|
||
@export var card_resource: Resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
extends Resource | ||
class_name GalleryInfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |