started Prog implmentation
This commit is contained in:
parent
78098b1a69
commit
27f99cd5ac
9 changed files with 354 additions and 5 deletions
|
|
@ -31,8 +31,8 @@ func _ready():
|
|||
func initialize(options = null):
|
||||
# Process options if provided
|
||||
if options:
|
||||
if options.has("maxDeckSize") and options.maxDeckSize is int:
|
||||
maxDeckSize = options.maxDeckSize
|
||||
if options.has("max_deck_size") and options.max_deck_size is int:
|
||||
maxDeckSize = options.max_deck_size
|
||||
|
||||
|
||||
# Find the DeckManager instance
|
||||
|
|
|
|||
|
|
@ -113,6 +113,8 @@ func generate_map():
|
|||
# Clear existing map
|
||||
map_nodes.clear()
|
||||
map_connections.clear()
|
||||
connection_lines.clear()
|
||||
traversed_map.clear()
|
||||
var mapGen = MapGenerator.new().generate_map()
|
||||
# Create starting node
|
||||
# var start_node = {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ signal card_purchased(card, price)
|
|||
@onready var mapScreen = get_node("/root/Board/MapScreen")
|
||||
@onready var stateMachine = get_node("/root/Board/StateMachine")
|
||||
@onready var shopScreen = get_node("/root/Board/ShopScreen")
|
||||
# @onready var progressionScreen = get_node("/root/Board/ProgressionScreen")
|
||||
@onready var rewardScreen = get_node("/root/Board/RewardScreen")
|
||||
@onready var game = get_node_or_null("/root/Board") as ChessGame
|
||||
# back up if game isn't loaded yet?
|
||||
|
|
@ -54,6 +55,9 @@ func _ready():
|
|||
deckManagerScreen.connect("back_pressed", Callable(self, "_on_deck_manager_back_pressed"))
|
||||
deckManagerScreen.visible = false
|
||||
|
||||
# if progressionScreen:
|
||||
# progressionScreen.connect("save_pressed", Callable(self, "_on_progression_save_pressed"))
|
||||
# progressionScreen.visible = false
|
||||
if mapScreen:
|
||||
mapScreen.connect("back_pressed", Callable(self, "_on_map_back_pressed"))
|
||||
mapScreen.connect("deckmanager_open_requested", Callable(self, "_on_deckmanager_open_requested_from_map"))
|
||||
|
|
@ -253,6 +257,12 @@ func _on_deck_manager_back_pressed():
|
|||
else:
|
||||
mapScreen.visible = true
|
||||
|
||||
|
||||
# func _on_progression_save_pressed():
|
||||
# progressionScreen.visible = false
|
||||
# gameMenuScreen.visible = true
|
||||
|
||||
|
||||
|
||||
func _on_map_open_requested(options):
|
||||
print("Map requested with options:", options)
|
||||
|
|
@ -327,7 +337,7 @@ func _on_node_completed(options):
|
|||
print("**********************************")
|
||||
print("**************GAME****************")
|
||||
print("**************OVER****************")
|
||||
print("**********************************")
|
||||
print("*************GITGUD***************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
|
|
|
|||
223
Systems/Game/ProgressionScreen.gd
Normal file
223
Systems/Game/ProgressionScreen.gd
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
extends Control
|
||||
class_name ProgressionScreen
|
||||
|
||||
signal save_pressed
|
||||
signal deck_manager_visibility_changed(isvisible)
|
||||
|
||||
@onready var deckGrid = $MainContainer/GridScrollContainer/GridContainer
|
||||
@onready var bankContainer = $MainContainer/BankContainer/ScrollContainer/VBoxContainer
|
||||
@onready var saveButton = $SaveButton
|
||||
@onready var card_preview = $CardPreviewPanel
|
||||
|
||||
var maxDeckSize = 10
|
||||
var deckManager = null
|
||||
var bankCards = [] # All Users card
|
||||
|
||||
# The current deck
|
||||
var currentDeck = []
|
||||
var current_preview_card = null
|
||||
|
||||
func _ready():
|
||||
# Connect back button
|
||||
if saveButton:
|
||||
saveButton.connect("pressed", Callable(self, "_on_save_button_pressed"))
|
||||
|
||||
if card_preview:
|
||||
card_preview.visible = false
|
||||
|
||||
|
||||
func initialize(options = null):
|
||||
if options:
|
||||
if options.has("max_deck_size") and options.max_deck_size is int:
|
||||
maxDeckSize = options.max_deck_size
|
||||
|
||||
|
||||
# Find the DeckManager instance
|
||||
var board = get_node_or_null("/root/Board") as ChessGame
|
||||
if board and "deckManager" in board:
|
||||
deckManager = board.deckManager
|
||||
print("Found deck manager:", deckManager)
|
||||
# if(!deckManager.deck):
|
||||
# deckManager.initializeStartingDeck()
|
||||
else:
|
||||
print("DeckManager not found on Board node")
|
||||
print("DECK MANAGER")
|
||||
|
||||
# Load cards from deck and bank
|
||||
loadCards()
|
||||
|
||||
# Set up the grid with empty card containers
|
||||
setupDeckGrid()
|
||||
|
||||
# Populate the bank with available cards
|
||||
populateBank()
|
||||
|
||||
func loadCards():
|
||||
var board = get_node_or_null("/root/Board") as ChessGame
|
||||
if board and "deckManager" in board:
|
||||
deckManager = board.deckManager
|
||||
print("Found deck manager:", deckManager)
|
||||
if deckManager:
|
||||
# Clone the deck to work with
|
||||
currentDeck = []
|
||||
bankCards = deckManager.bank.duplicate().append_array(deckManager.deck.duplicate())
|
||||
else:
|
||||
# Fallback with empty collections if deck manager not found
|
||||
currentDeck = []
|
||||
bankCards = []
|
||||
print("Warning: DeckManager not found")
|
||||
|
||||
|
||||
func setupDeckGrid():
|
||||
# Clear existing children
|
||||
for child in deckGrid.get_children():
|
||||
child.queue_free()
|
||||
|
||||
# Calculate grid dimensions
|
||||
var cols = 4 #check screen to deteremine
|
||||
var rows = maxDeckSize / cols
|
||||
deckGrid.columns = cols
|
||||
|
||||
# Create card slots
|
||||
for i in range(maxDeckSize):
|
||||
var card_slot = preload("res://card_slot.tscn").instantiate()
|
||||
deckGrid.add_child(card_slot)
|
||||
|
||||
# Connect signals
|
||||
card_slot.connect("card_selected", Callable(self, "_on_deck_card_selected"))
|
||||
_connect_hover_signals(card_slot)
|
||||
|
||||
# Set card if available
|
||||
if i < currentDeck.size():
|
||||
card_slot.set_card(currentDeck[i])
|
||||
else:
|
||||
card_slot.clear()
|
||||
|
||||
func _connect_hover_signals(node):
|
||||
# Add hover signals for preview functionality
|
||||
if node.is_class("Control"):
|
||||
node.mouse_entered.connect(Callable(self, "_on_card_mouse_entered").bind(node))
|
||||
# node.mouse_exited.connect(Callable(self, "_on_card_mouse_exited").bind(node))
|
||||
|
||||
|
||||
func populateBank():
|
||||
# Clear existing children
|
||||
for child in bankContainer.get_children():
|
||||
child.queue_free()
|
||||
|
||||
# Add each bank card to the list
|
||||
for card in bankCards:
|
||||
var card_item = preload("res://card_bank_item.tscn").instantiate()
|
||||
bankContainer.add_child(card_item)
|
||||
card_item.set_card(card)
|
||||
card_item.connect("card_selected", Callable(self, "_on_bank_card_selected"))
|
||||
_connect_hover_signals(card_item)
|
||||
|
||||
func _on_deck_card_selected(card_slot, card):
|
||||
if card:
|
||||
# Remove card from deck
|
||||
var index = currentDeck.find(card)
|
||||
if index >= 0:
|
||||
currentDeck.remove_at(index)
|
||||
|
||||
# Add to bank
|
||||
bankCards.append(card)
|
||||
|
||||
# Update UI
|
||||
card_slot.clear()
|
||||
populateBank()
|
||||
if current_preview_card == card:
|
||||
hide_card_preview()
|
||||
|
||||
func _on_bank_card_selected(card_item, card):
|
||||
print("_on_bank_card_selected")
|
||||
# Find first empty slot in deck
|
||||
var empty_slot_index = -1
|
||||
for i in range(deckGrid.get_child_count()):
|
||||
var slot = deckGrid.get_child(i)
|
||||
if !slot.has_card():
|
||||
empty_slot_index = i
|
||||
break
|
||||
|
||||
if empty_slot_index >= 0 and currentDeck.size() < maxDeckSize:
|
||||
# Remove from bank
|
||||
var bank_index = bankCards.find(card)
|
||||
if bank_index >= 0:
|
||||
bankCards.remove_at(bank_index)
|
||||
|
||||
# Add to deck
|
||||
currentDeck.append(card)
|
||||
|
||||
# Update UI
|
||||
deckGrid.get_child(empty_slot_index).set_card(card)
|
||||
populateBank()
|
||||
|
||||
func _on_card_mouse_entered(node):
|
||||
var card = null
|
||||
|
||||
# Get the card from the node
|
||||
if node.has_method("has_card") and node.has_card():
|
||||
# This is a CardSlot
|
||||
card = node.current_card
|
||||
elif node.has_method("set_card") and node.current_card:
|
||||
# This is a CardBankItem
|
||||
card = node.current_card
|
||||
|
||||
if card:
|
||||
show_card_preview(card)
|
||||
|
||||
# func _on_card_mouse_exited(node):
|
||||
# # Add a short delay before hiding the preview
|
||||
# # This prevents flickering when moving between cards
|
||||
# await get_tree().create_timer(0.1).timeout
|
||||
|
||||
# # Only hide if we're not hovering over another card that shows the same preview
|
||||
# if current_preview_card:
|
||||
# hide_card_preview()
|
||||
|
||||
func show_card_preview(card):
|
||||
if card_preview and card:
|
||||
current_preview_card = card
|
||||
card_preview.preview_card(card)
|
||||
|
||||
func hide_card_preview():
|
||||
if card_preview:
|
||||
current_preview_card = null
|
||||
card_preview.hide_preview()
|
||||
|
||||
func saveDeck():
|
||||
if deckManager:
|
||||
# Save the current deck to the deck manager
|
||||
deckManager.deck = currentDeck.duplicate()
|
||||
deckManager.bank = []
|
||||
|
||||
print("Deck saved with ", currentDeck.size(), " cards")
|
||||
|
||||
func _on_save_button_pressed():
|
||||
# Save changes before returning
|
||||
saveDeck()
|
||||
|
||||
# Emit signal to go back
|
||||
emit_signal("save_pressed")
|
||||
|
||||
# Hide this screen
|
||||
visible = false
|
||||
|
||||
|
||||
|
||||
|
||||
# Notification
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_VISIBILITY_CHANGED:
|
||||
_on_visibility_changed(visible)
|
||||
|
||||
func _on_visibility_changed(is_visible):
|
||||
|
||||
print("DeckManager visibility changed to: ", is_visible)
|
||||
if is_visible:
|
||||
loadCards()
|
||||
setupDeckGrid()
|
||||
else:
|
||||
print("DeckManager is now invisible")
|
||||
|
||||
emit_signal("deck_manager_visibility_changed", is_visible)
|
||||
1
Systems/Game/ProgressionScreen.gd.uid
Normal file
1
Systems/Game/ProgressionScreen.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dbohdt174pual
|
||||
|
|
@ -28,6 +28,7 @@ var card_instance_map = {}
|
|||
var hovering_card_index = -1
|
||||
var mouse_over_any_card = false
|
||||
var deckManager: DeckManager
|
||||
var selected_node = null
|
||||
|
||||
|
||||
func _ready():
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=32 format=3 uid="uid://d0qyk6v20uief"]
|
||||
[gd_scene load_steps=33 format=3 uid="uid://d0qyk6v20uief"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cbcu68o863pfp" path="res://Systems/Game/ChessGame.gd" id="1_fkb2r"]
|
||||
[ext_resource type="Script" uid="uid://d2bfw6edgkhfa" path="res://Systems/StateMachine/GameStates/WhiteTurn.gd" id="3_276ip"]
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://dxiw67f3rrwue" path="res://map_screen.tscn" id="29_y7cv2"]
|
||||
[ext_resource type="PackedScene" uid="uid://djw7jhwtnycxq" path="res://shop_screen.tscn" id="30_5rfmq"]
|
||||
[ext_resource type="PackedScene" uid="uid://tmrvgfwodpno" path="res://reward_screen.tscn" id="31_d2oob"]
|
||||
[ext_resource type="PackedScene" uid="uid://b27kmjovgmm5y" path="res://progression_screen.tscn" id="32_eq1pg"]
|
||||
|
||||
[node name="Board" type="Control"]
|
||||
layout_mode = 3
|
||||
|
|
@ -409,3 +410,7 @@ anchors_preset = 0
|
|||
[node name="RewardScreen" parent="." instance=ExtResource("31_d2oob")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="ProgressionScreen" parent="." instance=ExtResource("32_eq1pg")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://c7uqbcxdjoais"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://vxufsih5pgeu" path="res://Systems/Game/DeckManagerScreen.gd" id="1_gokg4"]
|
||||
[ext_resource type="PackedScene" uid="uid://xxxxxxxx" path="res://card_preview_panel.tscn" id="3_abcde"]
|
||||
[ext_resource type="PackedScene" uid="uid://2xcreiq6lhe2" path="res://card_preview_panel.tscn" id="3_abcde"]
|
||||
[ext_resource type="Script" uid="uid://bfjmon81nckns" path="res://Systems/Game/GameMenuButton.gd" id="4_gokg4"]
|
||||
|
||||
[node name="DeckManagerScreen" type="Control"]
|
||||
|
|
|
|||
107
progression_screen.tscn
Normal file
107
progression_screen.tscn
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://b27kmjovgmm5y"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dbohdt174pual" path="res://Systems/Game/ProgressionScreen.gd" id="1_gokg4"]
|
||||
[ext_resource type="PackedScene" uid="uid://xxxxxxxx" path="res://card_preview_panel.tscn" id="2_srvl8"]
|
||||
[ext_resource type="Script" uid="uid://bfjmon81nckns" path="res://Systems/Game/GameMenuButton.gd" id="4_gokg4"]
|
||||
|
||||
[node name="ProgressionScreen" 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_gokg4")
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.08, 0.08, 0.12, 1)
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_top = 20.0
|
||||
offset_bottom = 72.0
|
||||
grow_horizontal = 2
|
||||
theme_override_font_sizes/font_size = 36
|
||||
text = "SELECT YOUR CARDS"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="CardPreviewPanel" parent="." instance=ExtResource("2_srvl8")]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_left = 20.0
|
||||
offset_top = 100.0
|
||||
offset_right = 320.0
|
||||
offset_bottom = 588.0
|
||||
grow_horizontal = 1
|
||||
grow_vertical = 1
|
||||
|
||||
[node name="MainContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 325.0
|
||||
offset_top = 100.0
|
||||
offset_right = -20.0
|
||||
offset_bottom = -60.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="GridScrollContainer" type="ScrollContainer" parent="MainContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 3.0
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="MainContainer/GridScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/h_separation = 10
|
||||
theme_override_constants/v_separation = 10
|
||||
columns = 5
|
||||
|
||||
[node name="BankContainer" type="VBoxContainer" parent="MainContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="MainContainer/BankContainer"]
|
||||
layout_mode = 2
|
||||
text = "AVAILABLE CARDS"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="MainContainer/BankContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="MainContainer/BankContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MainContainer/BankContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 5
|
||||
|
||||
[node name="SaveButton" type="RichTextLabel" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 20.0
|
||||
offset_top = -50.0
|
||||
offset_right = 155.0
|
||||
offset_bottom = -20.0
|
||||
grow_vertical = 0
|
||||
text = "Save"
|
||||
script = ExtResource("4_gokg4")
|
||||
Loading…
Reference in a new issue