added secondary menu layer
This commit is contained in:
parent
6797935834
commit
238c2690c3
6 changed files with 326 additions and 28 deletions
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="Theme" format=3 uid="uid://cuq0xndnachqb"]
|
||||
|
||||
[resource]
|
||||
default_font_size = 71
|
||||
default_font_size = 80
|
||||
|
|
|
|||
|
|
@ -93,8 +93,8 @@ func _ready() -> void:
|
|||
print("MenuContainer not found, will initialize game now")
|
||||
call_deferred("initialize_game_system")
|
||||
turnIndicator.visible = false
|
||||
|
||||
func _on_new_game_requested():
|
||||
# 2rnbqkbnr1R/2ppp1pppp2/5p6/75/66/66/66/66/66/66/2PPPPPPPP2/2RNBQKBN3 b KQkq - 0 3
|
||||
func _on_new_game_requested(options = {}):
|
||||
print("ChessGame received new_game_requested signal ", is_initialized)
|
||||
turnIndicator.visible = true
|
||||
if is_initialized:
|
||||
|
|
@ -705,11 +705,11 @@ func getCurrentFen() -> String:
|
|||
|
||||
if tileManager.active_tiles.has(str(x) + "-" + str(y)):
|
||||
|
||||
if emptySquares > 0:
|
||||
fen += str(emptySquares)
|
||||
emptySquares = 0
|
||||
var tile = tileManager.active_tiles[str(x) + "-" + str(y)]
|
||||
if tile is WallTile or tile is DoubleWallTile:
|
||||
if emptySquares > 0:
|
||||
fen += str(emptySquares)
|
||||
emptySquares = 0
|
||||
if tile.tile_name == "Double Wall":
|
||||
fen += "*"
|
||||
else:
|
||||
|
|
|
|||
66
Systems/Game/GameMenuButton.gd
Normal file
66
Systems/Game/GameMenuButton.gd
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
extends RichTextLabel
|
||||
class_name GameMenuButton
|
||||
|
||||
signal pressed
|
||||
|
||||
# Style properties
|
||||
var normal_color: Color = Color(1, 1, 1, 1) # White
|
||||
var hover_color: Color = Color(1, 1, 0, 1) # Yellow
|
||||
var font_size: int = 28
|
||||
|
||||
func _ready():
|
||||
# Make this label clickable
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
|
||||
# Prevent text wrapping
|
||||
autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||
fit_content = true
|
||||
|
||||
# Set size flags to expand horizontally
|
||||
size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
|
||||
# Remove default padding/margin
|
||||
add_theme_constant_override("margin_top", 0)
|
||||
add_theme_constant_override("margin_bottom", 0)
|
||||
add_theme_constant_override("margin_left", 0)
|
||||
add_theme_constant_override("margin_right", 0)
|
||||
|
||||
# Remove line spacing
|
||||
add_theme_constant_override("line_separation", 0)
|
||||
|
||||
# Set up base styling
|
||||
add_theme_font_size_override("normal_font_size", font_size)
|
||||
add_theme_color_override("default_color", normal_color)
|
||||
|
||||
# Make text bold
|
||||
bbcode_enabled = true
|
||||
text = "[b]" + text + "[/b]"
|
||||
|
||||
# Connect the gui_input signal to our own handler
|
||||
connect("gui_input", Callable(self, "_on_gui_input"))
|
||||
|
||||
# Connect hover signals for better user experience
|
||||
connect("mouse_entered", Callable(self, "_on_mouse_entered"))
|
||||
connect("mouse_exited", Callable(self, "_on_mouse_exited"))
|
||||
|
||||
func _on_gui_input(event):
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
emit_signal("pressed")
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _on_mouse_entered():
|
||||
# Change appearance when mouse hovers
|
||||
add_theme_color_override("default_color", hover_color)
|
||||
|
||||
# Scale up slightly on hover (optional)
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "scale", Vector2(1.05, 1.05), 0.1)
|
||||
|
||||
func _on_mouse_exited():
|
||||
# Restore original appearance
|
||||
add_theme_color_override("default_color", normal_color)
|
||||
|
||||
# Scale back to normal (optional)
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "scale", Vector2(1.0, 1.0), 0.1)
|
||||
82
Systems/Game/GameMenuScreen.gd
Normal file
82
Systems/Game/GameMenuScreen.gd
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
extends Control
|
||||
class_name GameMenuScreen
|
||||
|
||||
# Signals with optional parameters
|
||||
signal shop_open_requested(options)
|
||||
signal deckmanager_open_requested(options)
|
||||
signal map_open_requested(options)
|
||||
signal new_game_requested(options)
|
||||
|
||||
|
||||
# @onready var newGameButton = $HBoxContainer/VBoxContainer/MenuOptions/NewGameText
|
||||
# @onready var continueButton = $HBoxContainer/VBoxContainer/MenuOptions/Continue
|
||||
# @onready var optionsButton = $HBoxContainer/VBoxContainer/MenuOptions/Options
|
||||
# @onready var versionText = $HBoxContainer/VBoxContainer/VersionText
|
||||
# @onready var titleText = $HBoxContainer/VBoxContainer/TitleText
|
||||
# @onready var developerText = $HBoxContainer/VBoxContainer/DeveloperText
|
||||
|
||||
# Node references
|
||||
@onready var shopButton = $HBoxContainer/VBoxContainer/GameOptions/ShopText
|
||||
@onready var deckButton = $HBoxContainer/VBoxContainer/GameOptions/ManageDeckText
|
||||
@onready var mapButton = $HBoxContainer/VBoxContainer/GameOptions/MapText
|
||||
@onready var startButton = $HBoxContainer/VBoxContainer/GameOptions/StartText
|
||||
@onready var backButton = $HBoxContainer/VBoxContainer/GameOptions/BackText
|
||||
|
||||
# Reference to main menu container
|
||||
var main_menu_container = null
|
||||
|
||||
func _ready():
|
||||
# Setup button signals
|
||||
if shopButton:
|
||||
shopButton.connect("pressed", Callable(self, "_on_shop_button_pressed"))
|
||||
|
||||
if deckButton:
|
||||
deckButton.connect("pressed", Callable(self, "_on_deck_button_pressed"))
|
||||
|
||||
if mapButton:
|
||||
mapButton.connect("pressed", Callable(self, "_on_map_button_pressed"))
|
||||
|
||||
if startButton:
|
||||
startButton.connect("pressed", Callable(self, "_on_start_button_pressed"))
|
||||
|
||||
if backButton:
|
||||
backButton.connect("pressed", Callable(self, "_on_back_button_pressed"))
|
||||
|
||||
|
||||
func setup(menu_container):
|
||||
main_menu_container = menu_container
|
||||
|
||||
func _on_shop_button_pressed():
|
||||
print("Shop button pressed")
|
||||
# Emit signal with null options
|
||||
emit_signal("shop_open_requested", null)
|
||||
|
||||
func _on_deck_button_pressed():
|
||||
print("Manage Deck button pressed")
|
||||
# Emit signal with null options
|
||||
emit_signal("deckmanager_open_requested", null)
|
||||
|
||||
func _on_map_button_pressed():
|
||||
print("Map button pressed")
|
||||
# Emit signal with null options
|
||||
emit_signal("map_open_requested", null)
|
||||
|
||||
func _on_start_button_pressed():
|
||||
print("Start button pressed")
|
||||
# Emit signal with empty options dictionary
|
||||
emit_signal("new_game_requested", {})
|
||||
|
||||
# emit_signal("new_game_requested")
|
||||
# Hide this menu
|
||||
self.visible = false
|
||||
|
||||
func _on_back_button_pressed():
|
||||
print("Back button pressed")
|
||||
# Return to main menu
|
||||
if main_menu_container:
|
||||
main_menu_container.visible = true
|
||||
# Hide this menu
|
||||
self.visible = false
|
||||
|
||||
func show_menu():
|
||||
self.visible = true
|
||||
|
|
@ -6,14 +6,18 @@ const ChessGame = preload("res://Systems/Game/ChessGame.gd")
|
|||
|
||||
const VERSION_FILE_PATH = "res://Game.json"
|
||||
# Signal to notify parent when a new game is requested
|
||||
signal new_game_requested
|
||||
|
||||
# signal new_game_requested
|
||||
signal new_game_requested(options)
|
||||
signal shop_open_requested(options)
|
||||
signal deckmanager_open_requested(options)
|
||||
signal map_open_requested(options)
|
||||
@onready var newGameButton = $HBoxContainer/VBoxContainer/MenuOptions/NewGameText
|
||||
@onready var continueButton = $HBoxContainer/VBoxContainer/MenuOptions/Continue
|
||||
@onready var optionsButton = $HBoxContainer/VBoxContainer/MenuOptions/Options
|
||||
@onready var versionText = $HBoxContainer/VBoxContainer/VersionText
|
||||
@onready var titleText = $HBoxContainer/VBoxContainer/TitleText
|
||||
@onready var developerText = $HBoxContainer/VBoxContainer/DeveloperText
|
||||
@onready var developerText = $HBoxContainer/VBoxContainer/DeveloperText
|
||||
@onready var gameMenuScreen = get_node("/root/Board/GameMenuScreen")
|
||||
|
||||
@onready var stateMachine = get_node("/root/Board/StateMachine")
|
||||
func _ready():
|
||||
|
|
@ -21,6 +25,13 @@ func _ready():
|
|||
_connect_button(newGameButton, "_on_new_game_pressed")
|
||||
_connect_button(continueButton, "_on_continue_pressed")
|
||||
_connect_button(optionsButton, "_on_options_pressed")
|
||||
if gameMenuScreen:
|
||||
gameMenuScreen.setup(self)
|
||||
gameMenuScreen.connect("shop_open_requested", Callable(self, "_on_shop_open_requested"))
|
||||
gameMenuScreen.connect("deckmanager_open_requested", Callable(self, "_on_deckmanager_open_requested"))
|
||||
gameMenuScreen.connect("map_open_requested", Callable(self, "_on_map_open_requested"))
|
||||
gameMenuScreen.connect("new_game_requested", Callable(self, "_on_start_game_pressed"))
|
||||
gameMenuScreen.visible = false
|
||||
load_version()
|
||||
|
||||
|
||||
|
|
@ -63,12 +74,44 @@ func _connect_button(button, method_name):
|
|||
|
||||
# Handle New Game button press
|
||||
func _on_new_game_pressed():
|
||||
print("New Game pressed, initializing game...")
|
||||
|
||||
# Hide the menu container
|
||||
print("New Game pressed, showing game menu")
|
||||
self.visible = false
|
||||
if gameMenuScreen:
|
||||
gameMenuScreen.visible = true
|
||||
# self.visible = false
|
||||
|
||||
# # Find the ChessGame instance or create one if needed
|
||||
# emit_signal("new_game_requested")
|
||||
|
||||
# Handle Continue button press
|
||||
func _on_continue_pressed():
|
||||
print("Continue pressed")
|
||||
# Implement continue game logic here
|
||||
# self.visible = false
|
||||
# You can add logic to load a saved game if needed
|
||||
|
||||
# Handle Options button press
|
||||
func _on_options_pressed():
|
||||
print("Options pressed")
|
||||
# Implement options menu logic here
|
||||
# You could show an options panel or switch to an options menu
|
||||
|
||||
# Game Menu Screen Signals
|
||||
func _on_shop_open_requested(options):
|
||||
print("Shop requested with options:", options)
|
||||
emit_signal("shop_open_requested", options)
|
||||
|
||||
func _on_deckmanager_open_requested(options):
|
||||
print("Deck Manager requested with options:", options)
|
||||
emit_signal("deckmanager_open_requested", options)
|
||||
|
||||
func _on_map_open_requested(options):
|
||||
print("Map requested with options:", options)
|
||||
emit_signal("map_open_requested", options)
|
||||
|
||||
func _on_start_game_pressed(options):
|
||||
print("Starting game with options:", options)
|
||||
|
||||
# Find the ChessGame instance
|
||||
# var chess_game = _find_chess_game()
|
||||
|
||||
# if chess_game:
|
||||
|
|
@ -83,21 +126,9 @@ func _on_new_game_pressed():
|
|||
# else:
|
||||
# print("Error: ChessGame not found")
|
||||
|
||||
# Emit signal for parent to handle
|
||||
emit_signal("new_game_requested")
|
||||
# Emit signal for parent to handle with options
|
||||
emit_signal("new_game_requested", options)
|
||||
|
||||
# Handle Continue button press
|
||||
func _on_continue_pressed():
|
||||
print("Continue pressed")
|
||||
# Implement continue game logic here
|
||||
# self.visible = false
|
||||
# You can add logic to load a saved game if needed
|
||||
|
||||
# Handle Options button press
|
||||
func _on_options_pressed():
|
||||
print("Options pressed")
|
||||
# Implement options menu logic here
|
||||
# You could show an options panel or switch to an options menu
|
||||
|
||||
# Find the ChessGame node
|
||||
func _find_chess_game():
|
||||
|
|
@ -117,3 +148,5 @@ func _find_chess_game():
|
|||
# Public method to show the menu
|
||||
func show_menu():
|
||||
self.visible = true
|
||||
if gameMenuScreen:
|
||||
gameMenuScreen.visible = false
|
||||
|
|
|
|||
119
board.tscn
119
board.tscn
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=26 format=3 uid="uid://d0qyk6v20uief"]
|
||||
[gd_scene load_steps=28 format=3 uid="uid://d0qyk6v20uief"]
|
||||
|
||||
[ext_resource type="Script" path="res://Systems/Game/ChessGame.gd" id="1_fkb2r"]
|
||||
[ext_resource type="Script" path="res://Systems/StateMachine/GameStates/WhiteTurn.gd" id="3_276ip"]
|
||||
|
|
@ -25,6 +25,8 @@
|
|||
[ext_resource type="Texture2D" uid="uid://bexpni52h8527" path="res://Assets/main_menu/characters.png" id="23_vmvai"]
|
||||
[ext_resource type="Theme" uid="uid://btgbiqdc4kf15" path="res://Assets/Themes/SimpleMenuText.tres" id="24_4y4dr"]
|
||||
[ext_resource type="Script" path="res://Systems/Game/Menu/MenuTextOption.gd" id="24_aslgu"]
|
||||
[ext_resource type="Script" path="res://Systems/Game/GameMenuScreen.gd" id="26_pb4ja"]
|
||||
[ext_resource type="Script" path="res://Systems/Game/GameMenuButton.gd" id="26_t2e38"]
|
||||
|
||||
[node name="Board" type="Control"]
|
||||
layout_mode = 3
|
||||
|
|
@ -69,6 +71,7 @@ offset_bottom = 136.0
|
|||
grow_horizontal = 0
|
||||
|
||||
[node name="TurnIndicator" type="ColorRect" parent="."]
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(50, 50)
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
|
|
@ -265,3 +268,117 @@ size_flags_horizontal = 3
|
|||
[node name="GameImage" type="TextureRect" parent="MenuContainer/HBoxContainer/CenterContainer"]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("23_vmvai")
|
||||
|
||||
[node name="GameMenuScreen" type="MarginContainer" parent="."]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 120
|
||||
theme_override_constants/margin_top = 80
|
||||
theme_override_constants/margin_right = 120
|
||||
theme_override_constants/margin_bottom = 80
|
||||
script = ExtResource("26_pb4ja")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="GameMenuScreen"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="GameMenuScreen/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TitleText" type="RichTextLabel" parent="GameMenuScreen/HBoxContainer/VBoxContainer"]
|
||||
clip_contents = false
|
||||
layout_mode = 2
|
||||
size_flags_stretch_ratio = 0.0
|
||||
theme = ExtResource("19_enj45")
|
||||
text = "ChessBuilder"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 0
|
||||
tab_size = 1
|
||||
shortcut_keys_enabled = false
|
||||
deselect_on_focus_loss_enabled = false
|
||||
drag_and_drop_selection_enabled = false
|
||||
script = ExtResource("24_aslgu")
|
||||
|
||||
[node name="GameOptions" type="VBoxContainer" parent="GameMenuScreen/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 30
|
||||
alignment = 1
|
||||
|
||||
[node name="ShopText" type="RichTextLabel" parent="GameMenuScreen/HBoxContainer/VBoxContainer/GameOptions"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("24_4y4dr")
|
||||
text = "Dungeon Test Shop"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 0
|
||||
tab_size = 1
|
||||
shortcut_keys_enabled = false
|
||||
deselect_on_focus_loss_enabled = false
|
||||
drag_and_drop_selection_enabled = false
|
||||
script = ExtResource("26_t2e38")
|
||||
|
||||
[node name="ManageDeckText" type="RichTextLabel" parent="GameMenuScreen/HBoxContainer/VBoxContainer/GameOptions"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("24_4y4dr")
|
||||
text = "Manage Deck"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 0
|
||||
tab_size = 1
|
||||
shortcut_keys_enabled = false
|
||||
deselect_on_focus_loss_enabled = false
|
||||
drag_and_drop_selection_enabled = false
|
||||
script = ExtResource("26_t2e38")
|
||||
|
||||
[node name="MapText" type="RichTextLabel" parent="GameMenuScreen/HBoxContainer/VBoxContainer/GameOptions"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("24_4y4dr")
|
||||
text = "Map"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 0
|
||||
tab_size = 1
|
||||
shortcut_keys_enabled = false
|
||||
deselect_on_focus_loss_enabled = false
|
||||
drag_and_drop_selection_enabled = false
|
||||
script = ExtResource("26_t2e38")
|
||||
|
||||
[node name="StartText" type="RichTextLabel" parent="GameMenuScreen/HBoxContainer/VBoxContainer/GameOptions"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("24_4y4dr")
|
||||
text = "Start"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 0
|
||||
tab_size = 1
|
||||
shortcut_keys_enabled = false
|
||||
deselect_on_focus_loss_enabled = false
|
||||
drag_and_drop_selection_enabled = false
|
||||
script = ExtResource("26_t2e38")
|
||||
|
||||
[node name="BackText" type="RichTextLabel" parent="GameMenuScreen/HBoxContainer/VBoxContainer/GameOptions"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("24_4y4dr")
|
||||
text = "Back"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 0
|
||||
tab_size = 1
|
||||
shortcut_keys_enabled = false
|
||||
deselect_on_focus_loss_enabled = false
|
||||
drag_and_drop_selection_enabled = false
|
||||
script = ExtResource("26_t2e38")
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="GameMenuScreen/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="GameImage" type="TextureRect" parent="GameMenuScreen/HBoxContainer/CenterContainer"]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("23_vmvai")
|
||||
|
|
|
|||
Loading…
Reference in a new issue