Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add decipher shop #21

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions assets/UI/energy_orb.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dyx76tn885md3"
path="res://.godot/imported/energy_orb.png-2cbe75b8af4388a02af2b14d7f4c3fa2.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/UI/energy_orb.png"
dest_files=["res://.godot/imported/energy_orb.png-2cbe75b8af4388a02af2b14d7f4c3fa2.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
34 changes: 34 additions & 0 deletions assets/UI/scroll_base.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://df58t5bfmj70a"
path="res://.godot/imported/scroll_base.png-693a0b068424563664384c6eb0209196.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/UI/scroll_base.png"
dest_files=["res://.godot/imported/scroll_base.png-693a0b068424563664384c6eb0209196.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
34 changes: 34 additions & 0 deletions assets/UI/tilemap.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dmvsmadpgt07f"
path="res://.godot/imported/tilemap.png-083a8bbebe37cff77c4a1b9df77bc47f.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/UI/tilemap.png"
dest_files=["res://.godot/imported/tilemap.png-083a8bbebe37cff77c4a1b9df77bc47f.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
34 changes: 34 additions & 0 deletions assets/UI/tilemap_packed.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://b27cwck0oyrc"
path="res://.godot/imported/tilemap_packed.png-42b0b930e1378971414a5562b18c2f23.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/UI/tilemap_packed.png"
dest_files=["res://.godot/imported/tilemap_packed.png-42b0b930e1378971414a5562b18c2f23.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
Binary file added assets/backgrounds/scroll_shop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/backgrounds/scroll_shop.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://d0e0habrx3lmx"
path="res://.godot/imported/scroll_shop.png-6c62852703f1bf6b927ce6a799fdfcdf.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/backgrounds/scroll_shop.png"
dest_files=["res://.godot/imported/scroll_shop.png-6c62852703f1bf6b927ce6a799fdfcdf.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
28 changes: 28 additions & 0 deletions resources/shaders/card_glow.gdshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
shader_type canvas_item;

uniform vec4 glow_color : source_color = vec4(1.0, 0.85, 0.4, 1.0); // Warm yellow glow
uniform float glow_strength : hint_range(0.0, 1.0) = 0.0;
uniform float outline_width : hint_range(0.0, 10.0) = 1.2;

void fragment() {
vec4 texture_color = texture(TEXTURE, UV);

// Calculate outline
float outline = 0.0;
for(float x = -outline_width; x <= outline_width; x++) {
for(float y = -outline_width; y <= outline_width; y++) {
vec2 offset = vec2(x, y) * TEXTURE_PIXEL_SIZE;
if(texture(TEXTURE, UV + offset).a > 0.0) {
outline = 1.0;
break;
}
}
}

// Only show outline on the edges (where the original texture is transparent)
outline *= (1.0 - texture_color.a);

// Add glow to the original color
vec4 glow = glow_color * outline * glow_strength;
COLOR = texture_color + glow;
}
2 changes: 1 addition & 1 deletion scenes/home_base.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=3 format=3 uid="uid://bnk32gyp3bsir"]
[gd_scene load_steps=3 format=3 uid="uid://bavbb08gmox7b"]

[ext_resource type="Script" path="res://scripts/scenes/home_base.gd" id="1_07xob"]
[ext_resource type="Script" path="res://scripts/managers/pause_manager.gd" id="2_5cg8f"]
Expand Down
52 changes: 52 additions & 0 deletions scenes/shop.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[gd_scene load_steps=4 format=3 uid="uid://cndnjigot1as7"]

[ext_resource type="Script" path="res://scripts/decipher_shop.gd" id="1_10ejr"]
[ext_resource type="Texture2D" uid="uid://d0e0habrx3lmx" path="res://assets/backgrounds/scroll_shop.png" id="1_56d1j"]
[ext_resource type="Script" path="res://scripts/managers/decoder_manager.gd" id="3_bo20c"]

[node name="DecipherUI" 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_10ejr")

[node name="ScrollShop" type="Sprite2D" parent="."]
position = Vector2(780, 613)
scale = Vector2(1.89022, 1.49542)
texture = ExtResource("1_56d1j")

[node name="ScrollContainer" type="ScrollContainer" parent="ScrollShop"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -370.0
offset_top = -316.0
offset_right = -1021.0
offset_bottom = -464.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
horizontal_scroll_mode = 0
vertical_scroll_mode = 3

[node name="GridContainer" type="GridContainer" parent="ScrollShop/ScrollContainer"]
clip_contents = true
layout_mode = 2
columns = 3

[node name="DecipherPointsLabel" type="Label" parent="."]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -170.0
offset_top = 50.0
offset_right = -111.0
offset_bottom = 86.0
grow_horizontal = 0

[node name="DecoderManager" type="Node" parent="."]
script = ExtResource("3_bo20c")
85 changes: 85 additions & 0 deletions scripts/decipher_shop.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
extends Control

# First, move the shop card script to a constant reference
const ShopCardScript = preload("res://scripts/scenes/decipher_shop_card.gd")

@onready var grid_container = $ScrollShop/ScrollContainer/GridContainer
@onready var scroll_container = $ScrollShop/ScrollContainer
@onready var card_scene = preload("res://scenes/card.tscn")
@onready var points_label = $DecipherPointsLabel
@onready var decoder_manager = $DecoderManager

# Cards available for deciphering
var available_cards = GameState.current_deck

var card_size: Vector2

func _ready() -> void:
setup_grid_container()
populate_shop_cards()
update_points_display()

# Connect to decoder manager signals
decoder_manager.points_changed.connect(_on_points_changed)
decoder_manager.aspect_decoded.connect(_on_aspect_decoded)

func setup_grid_container() -> void:
# Configure grid layout
grid_container.columns = 3
grid_container.add_theme_constant_override("h_separation", 20)
grid_container.add_theme_constant_override("v_separation", 20)

# Make GridContainer take full width
grid_container.size_flags_horizontal = Control.SIZE_EXPAND | Control.SIZE_FILL

# Calculate card sizes based on scroll container width
var available_width = scroll_container.size.x
var card_width = (available_width - (grid_container.columns - 1) * grid_container.get_theme_constant("h_separation")) / grid_container.columns
card_size = Vector2(card_width, card_width * 1.5)

# Calculate total height needed
var rows = ceil(float(available_cards.size()) / grid_container.columns)
var total_height = (card_size.y * rows) + ((rows - 1) * grid_container.get_theme_constant("v_separation"))

# Set GridContainer size
grid_container.custom_minimum_size = Vector2(available_width, total_height)

func populate_shop_cards() -> void:
# Clear existing cards
for child in grid_container.get_children():
child.queue_free()

# Add available cards to the shop
for card_path in available_cards:
var card_resource = load(card_path)
if card_resource:
var card_instance = card_scene.instantiate()

# Set the script before setup
card_instance.set_script(ShopCardScript)

grid_container.add_child(card_instance)

# Set the card's custom minimum size
card_instance.custom_minimum_size = card_size - Vector2(-10, -30)

# Make the card expand to fill its cell
card_instance.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
card_instance.size_flags_vertical = Control.SIZE_SHRINK_CENTER

# Get decoded aspects for this card from GameState
var decoded_aspects = GameState.decoded_aspects.get(card_path, {})

# Set up the card with both resource and decoder manager
if card_instance.has_method("setup_shop_card"):
card_instance.setup_shop_card(card_resource, decoded_aspects, decoder_manager)

func update_points_display() -> void:
points_label.text = "Decipher Points: " + str(decoder_manager.available_points)

func _on_points_changed(new_amount: int) -> void:
update_points_display()

func _on_aspect_decoded(_card_id: String, _aspect: String) -> void:
# Refresh the cards to show updated decode status
populate_shop_cards()
4 changes: 2 additions & 2 deletions scripts/managers/decoder_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func decode_aspect(card: Node, aspect: String) -> void:
aspect_decoded.emit(card_id, aspect)

# Update decode UI if it's visible
var decode_ui = get_node("/root/Main/Combat/UI/DecodeUI")
if decode_ui and decode_ui.visible:
var decode_ui = get_node_or_null("/root/Main/Combat/UI/DecodeUI")
if decode_ui and decode_ui.visible and decode_ui.has_method("update_points"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De decode_ui best ook nog even in de UI folder steken, i.p.v. rechtstreeks in de scripts folder. Ik ben aan het proberen om geen .gd files meer rechtstreeks onder de scripts folder te hebben staan.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

decode_ui.update_points()

func add_points(amount: int) -> void:
Expand Down
Loading
Loading