mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2025-02-04 12:28:35 +00:00
Added Dark and Light Themes
This commit is contained in:
@@ -5,6 +5,9 @@ class ShipData:
|
||||
var Length: int
|
||||
var Orientation: bool #vertical is true, (Trueship = vertical) (Falseship = horizontal)
|
||||
|
||||
var light_theme = load("res://light_theme.tres")
|
||||
var dark_theme = load("res://dark_theme.tres")
|
||||
|
||||
# Preloaded assets, to be used later
|
||||
# TODO: Move Setup into the Player. It's just here, for now, so that it can be tested and the game doesn't appear broken
|
||||
onready var Setup = preload("res://scenes/Game/Setup.tscn")
|
||||
@@ -27,6 +30,7 @@ var hit = false
|
||||
# TODO: Multiplayer
|
||||
var is_multiplayer = false
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
# TODO: Move Setup into the Player.
|
||||
@@ -36,6 +40,12 @@ func _ready():
|
||||
|
||||
get_node("ConfirmationDialog").get_ok().text = "Yes"
|
||||
get_node("ConfirmationDialog").get_cancel().text = "No"
|
||||
get_node("ConfirmationDialog").get_ok().rect_min_size.x = 100
|
||||
get_node("ConfirmationDialog").get_cancel().rect_min_size.x = 100
|
||||
|
||||
var _errno = 0;
|
||||
_errno += OptionsController.connect("change_theme", self, "_on_change_theme")
|
||||
_on_change_theme(OptionsController.get_theme())
|
||||
|
||||
# TODO: Move Setup into the Player.
|
||||
func game_setup(_ships):
|
||||
@@ -73,3 +83,9 @@ func _on_Button_button_down():
|
||||
|
||||
func _on_ConfirmationDialog_confirmed():
|
||||
end()
|
||||
|
||||
func _on_change_theme(theme):
|
||||
if theme == "light":
|
||||
get_node("Buttons").set_theme(light_theme)
|
||||
elif theme == "dark":
|
||||
get_node("Buttons").set_theme(dark_theme)
|
||||
|
||||
@@ -6,6 +6,9 @@ onready var Ships = ["2Ship", "3ShipA", "3ShipB", "4Ship", "5Ship"]
|
||||
|
||||
onready var Victory = preload("res://scenes/Game/Player.tscn")
|
||||
|
||||
var light_theme = load("res://light_theme.tres")
|
||||
var dark_theme = load("res://dark_theme.tres")
|
||||
|
||||
class ShipData:
|
||||
var Position: Vector2
|
||||
var Length: int
|
||||
@@ -15,7 +18,12 @@ class ShipData:
|
||||
func _ready():
|
||||
# Moves the focus to this menu
|
||||
if find_next_valid_focus(): find_next_valid_focus().grab_focus()
|
||||
|
||||
|
||||
get_node("PlaceShipDialog").get_ok().rect_min_size.x = 50
|
||||
|
||||
var _errno = 0;
|
||||
_errno += OptionsController.connect("change_theme", self, "_on_change_theme")
|
||||
_on_change_theme(OptionsController.get_theme())
|
||||
|
||||
func _on_Confirm_Placement_pressed():
|
||||
# Make the button noise
|
||||
@@ -53,3 +61,9 @@ func _on_Clear_pressed():
|
||||
for ship in Ships:
|
||||
get_node(ship).clear()
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_change_theme(theme):
|
||||
if theme == "light":
|
||||
self.set_theme(light_theme)
|
||||
elif theme == "dark":
|
||||
self.set_theme(dark_theme)
|
||||
|
||||
Reference in New Issue
Block a user