1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-15 05:25:57 +00:00

Added Dark and Light Themes

This commit is contained in:
tommy-l-ngo 2021-11-14 02:50:39 -06:00
parent 428c59115f
commit de9684d22f
11 changed files with 285 additions and 83 deletions

View File

@ -1,13 +1,33 @@
[gd_resource type="Theme" load_steps=3 format=2] [gd_resource type="Theme" load_steps=6 format=2]
[ext_resource path="res://assets/font/Minecraft.ttf" type="DynamicFontData" id=1]
[sub_resource type="StyleBoxFlat" id=4]
bg_color = Color( 0.239216, 0.211765, 0.317647, 1 )
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
shadow_size = 4
[sub_resource type="StyleBoxFlat" id=1] [sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.239216, 0.227451, 0.270588, 1 ) bg_color = Color( 0.109804, 0.0862745, 0.172549, 1 )
corner_radius_top_left = 2 corner_radius_top_left = 3
corner_radius_top_right = 2 corner_radius_top_right = 3
corner_radius_bottom_right = 2 corner_radius_bottom_right = 3
corner_radius_bottom_left = 2 corner_radius_bottom_left = 3
shadow_size = 3
[sub_resource type="DynamicFont" id=3]
outline_color = Color( 0, 0, 0, 1 )
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=2] [sub_resource type="DynamicFont" id=2]
outline_color = Color( 0, 0, 0, 1 )
extra_spacing_top = 5
extra_spacing_bottom = 3
extra_spacing_char = 1
font_data = ExtResource( 1 )
[resource] [resource]
default_font = SubResource( 2 ) default_font = SubResource( 2 )
@ -19,6 +39,26 @@ Button/constants/hseparation = 2
Button/fonts/font = null Button/fonts/font = null
Button/styles/disabled = null Button/styles/disabled = null
Button/styles/focus = null Button/styles/focus = null
Button/styles/hover = null Button/styles/hover = SubResource( 4 )
Button/styles/normal = SubResource( 1 ) Button/styles/normal = SubResource( 1 )
Button/styles/pressed = null Button/styles/pressed = null
Dialogs/constants/button_margin = 100
Dialogs/constants/margin = 8
Label/colors/font_color = Color( 1, 1, 1, 1 )
Label/colors/font_color_shadow = Color( 0, 0, 0, 0 )
Label/colors/font_outline_modulate = Color( 0, 0, 0, 1 )
Label/constants/line_spacing = 3
Label/constants/shadow_as_outline = 0
Label/constants/shadow_offset_x = 0
Label/constants/shadow_offset_y = 0
Label/fonts/font = SubResource( 3 )
Label/styles/normal = null
WindowDialog/colors/title_color = Color( 0.152941, 0.152941, 0.152941, 1 )
WindowDialog/constants/close_h_ofs = 18
WindowDialog/constants/close_v_ofs = 18
WindowDialog/constants/scaleborder_size = 4
WindowDialog/constants/title_height = 20
WindowDialog/fonts/title_font = null
WindowDialog/icons/close = null
WindowDialog/icons/close_highlight = null
WindowDialog/styles/panel = null

View File

@ -0,0 +1,64 @@
[gd_resource type="Theme" load_steps=6 format=2]
[ext_resource path="res://assets/font/Minecraft.ttf" type="DynamicFontData" id=1]
[sub_resource type="StyleBoxFlat" id=4]
bg_color = Color( 1, 1, 1, 1 )
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
shadow_size = 4
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.847059, 0.921569, 0.964706, 1 )
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
shadow_size = 3
[sub_resource type="DynamicFont" id=2]
outline_color = Color( 0, 0, 0, 1 )
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=3]
outline_color = Color( 0, 0, 0, 1 )
extra_spacing_top = 5
extra_spacing_bottom = 3
extra_spacing_char = 1
font_data = ExtResource( 1 )
[resource]
default_font = SubResource( 3 )
Button/colors/font_color = Color( 0.0784314, 0.0784314, 0.0784314, 1 )
Button/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
Button/colors/font_color_hover = Color( 0, 0, 0, 1 )
Button/colors/font_color_pressed = Color( 0, 0, 0, 1 )
Button/constants/hseparation = 2
Button/fonts/font = null
Button/styles/disabled = null
Button/styles/focus = null
Button/styles/hover = SubResource( 4 )
Button/styles/normal = SubResource( 1 )
Button/styles/pressed = null
Dialogs/constants/button_margin = 100
Dialogs/constants/margin = 8
Label/colors/font_color = Color( 1, 1, 1, 1 )
Label/colors/font_color_shadow = Color( 0, 0, 0, 0 )
Label/colors/font_outline_modulate = Color( 0, 0, 0, 1 )
Label/constants/line_spacing = 3
Label/constants/shadow_as_outline = 0
Label/constants/shadow_offset_x = 0
Label/constants/shadow_offset_y = 0
Label/fonts/font = SubResource( 2 )
Label/styles/normal = null
WindowDialog/colors/title_color = Color( 0.152941, 0.152941, 0.152941, 1 )
WindowDialog/constants/close_h_ofs = 18
WindowDialog/constants/close_v_ofs = 18
WindowDialog/constants/scaleborder_size = 4
WindowDialog/constants/title_height = 20
WindowDialog/fonts/title_font = null
WindowDialog/icons/close = null
WindowDialog/icons/close_highlight = null
WindowDialog/styles/panel = null

View File

@ -16,16 +16,16 @@ anchor_left = 0.912
anchor_top = 0.932 anchor_top = 0.932
anchor_right = 0.912 anchor_right = 0.912
anchor_bottom = 0.932 anchor_bottom = 0.932
margin_left = -3.68005 margin_left = -37.68
margin_top = -4.52002 margin_top = -329.52
margin_right = 49.3199 margin_right = 50.32
margin_bottom = 15.48 margin_bottom = -305.52
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Forfeit" type="Button" parent="Buttons"] [node name="Forfeit" type="Button" parent="Buttons"]
margin_right = 53.0 margin_right = 88.0
margin_bottom = 20.0 margin_bottom = 20.0
text = "Forfeit" text = "Forfeit"
@ -47,10 +47,11 @@ __meta__ = {
} }
[node name="Button" type="Button" parent="."] [node name="Button" type="Button" parent="."]
margin_left = 599.361 visible = false
margin_top = 2.97302 margin_left = 6.4668
margin_right = 636.361 margin_top = 6.14783
margin_bottom = 22.973 margin_right = 43.4668
margin_bottom = 26.1478
text = "Win" text = "Win"
[connection signal="pressed" from="Buttons/Forfeit" to="." method="_on_Forfeit_pressed"] [connection signal="pressed" from="Buttons/Forfeit" to="." method="_on_Forfeit_pressed"]

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://assets/game/board_blue.png" type="Texture" id=1] [ext_resource path="res://assets/game/board_blue.png" type="Texture" id=1]
[ext_resource path="res://dark_theme.tres" type="Theme" id=2]
[ext_resource path="res://scenes/ships/3ShipB.tscn" type="PackedScene" id=4] [ext_resource path="res://scenes/ships/3ShipB.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/ships/3shipA.tscn" type="PackedScene" id=5] [ext_resource path="res://scenes/ships/3shipA.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenes/ships/4Ship.tscn" type="PackedScene" id=6] [ext_resource path="res://scenes/ships/4Ship.tscn" type="PackedScene" id=6]
@ -15,6 +16,7 @@ anchor_bottom = 0.890237
margin_top = -0.445435 margin_top = -0.445435
margin_bottom = 39.5145 margin_bottom = 39.5145
mouse_filter = 2 mouse_filter = 2
theme = ExtResource( 2 )
script = ExtResource( 10 ) script = ExtResource( 10 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
@ -70,20 +72,20 @@ contacts_reported = 1
contact_monitor = true contact_monitor = true
[node name="Confirm Placement" type="Button" parent="."] [node name="Confirm Placement" type="Button" parent="."]
margin_left = 409.0 margin_left = 417.0
margin_top = 331.0 margin_top = 316.0
margin_right = 543.0 margin_right = 608.0
margin_bottom = 351.0 margin_bottom = 340.0
text = "Confirm Placement" text = "Confirm Placement"
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Clear" type="Button" parent="."] [node name="Clear" type="Button" parent="."]
margin_left = 353.0 margin_left = 348.0
margin_top = 331.0 margin_top = 316.0
margin_right = 406.0 margin_right = 408.0
margin_bottom = 351.0 margin_bottom = 340.0
text = "Clear" text = "Clear"
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false

View File

@ -1,24 +1,52 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/font/Minecraft.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://script/options/Options.gd" type="Script" id=2] [ext_resource path="res://script/options/Options.gd" type="Script" id=2]
[ext_resource path="res://light_theme.tres" type="Theme" id=3]
[sub_resource type="DynamicFont" id=1]
size = 44
outline_size = 2
outline_color = Color( 0, 0, 0, 1 )
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=2]
outline_size = 1
outline_color = Color( 0, 0, 0, 1 )
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=3]
outline_size = 1
outline_color = Color( 0, 0, 0, 1 )
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=4]
outline_size = 1
font_data = ExtResource( 1 )
[node name="Options" type="Control"] [node name="Options" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
theme = ExtResource( 3 )
script = ExtResource( 2 ) script = ExtResource( 2 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="MenuLabel" type="RichTextLabel" parent="."] [node name="Options Label" type="Label" parent="."]
margin_left = 294.0 anchor_left = 0.5
margin_top = 68.0 anchor_right = 0.5
margin_right = 346.0 margin_left = -82.0
margin_bottom = 83.0 margin_top = 49.0
custom_colors/default_color = Color( 0, 0, 0, 1 ) margin_right = 82.0
margin_bottom = 93.0
custom_fonts/font = SubResource( 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_constants/shadow_offset_y = 8
text = "Options" text = "Options"
align = 2
valign = 1
__meta__ = { __meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -36,11 +64,11 @@ __meta__ = {
position = Vector2( 0, 8 ) position = Vector2( 0, 8 )
[node name="Master Label" type="Label" parent="Sliders/Master Volume Setting"] [node name="Master Label" type="Label" parent="Sliders/Master Volume Setting"]
margin_left = -0.140289 margin_left = -8.14029
margin_top = -8.0 margin_top = -14.0
margin_right = 63.8597 margin_right = 57.8597
margin_bottom = 8.0 margin_bottom = 10.0
custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_fonts/font = SubResource( 2 )
text = "Volume:" text = "Volume:"
align = 2 align = 2
valign = 1 valign = 1
@ -50,9 +78,9 @@ __meta__ = {
[node name="Master Slider" type="HSlider" parent="Sliders/Master Volume Setting"] [node name="Master Slider" type="HSlider" parent="Sliders/Master Volume Setting"]
margin_left = 64.0 margin_left = 64.0
margin_top = -8.0 margin_top = -10.0
margin_right = 208.0 margin_right = 208.0
margin_bottom = 8.0 margin_bottom = 6.0
focus_neighbour_left = NodePath("../../../Back") focus_neighbour_left = NodePath("../../../Back")
focus_neighbour_top = NodePath("../../../Back") focus_neighbour_top = NodePath("../../../Back")
focus_neighbour_bottom = NodePath("../../Volume Setting/Volume Slider") focus_neighbour_bottom = NodePath("../../Volume Setting/Volume Slider")
@ -61,6 +89,7 @@ focus_previous = NodePath("../../../Back")
max_value = 1.0 max_value = 1.0
step = 0.05 step = 0.05
tick_count = 10 tick_count = 10
ticks_on_borders = true
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -69,10 +98,11 @@ __meta__ = {
position = Vector2( 0, 33 ) position = Vector2( 0, 33 )
[node name="Music Label" type="Label" parent="Sliders/Music Volume Setting"] [node name="Music Label" type="Label" parent="Sliders/Music Volume Setting"]
margin_top = -8.0 margin_left = -6.0
margin_right = 64.0 margin_top = -13.0
margin_bottom = 8.0 margin_right = 58.0
custom_colors/font_color = Color( 0, 0, 0, 1 ) margin_bottom = 11.0
custom_fonts/font = SubResource( 3 )
text = "Music:" text = "Music:"
align = 2 align = 2
valign = 1 valign = 1
@ -81,10 +111,10 @@ __meta__ = {
} }
[node name="Music Slider" type="HSlider" parent="Sliders/Music Volume Setting"] [node name="Music Slider" type="HSlider" parent="Sliders/Music Volume Setting"]
margin_left = 64.0 margin_left = 64.25
margin_top = -8.0 margin_top = -9.0
margin_right = 208.0 margin_right = 208.25
margin_bottom = 8.0 margin_bottom = 7.0
focus_neighbour_top = NodePath("../../SFX Setting/SFX Slider") focus_neighbour_top = NodePath("../../SFX Setting/SFX Slider")
focus_neighbour_bottom = NodePath("../../../Buttons/Dark") focus_neighbour_bottom = NodePath("../../../Buttons/Dark")
focus_next = NodePath("../../../Buttons/Dark") focus_next = NodePath("../../../Buttons/Dark")
@ -92,6 +122,7 @@ focus_previous = NodePath("../../SFX Setting/SFX Slider")
max_value = 1.0 max_value = 1.0
step = 0.05 step = 0.05
tick_count = 10 tick_count = 10
ticks_on_borders = true
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -99,10 +130,11 @@ __meta__ = {
[node name="SFX Volume Setting" type="Node2D" parent="Sliders"] [node name="SFX Volume Setting" type="Node2D" parent="Sliders"]
[node name="SFX Label" type="Label" parent="Sliders/SFX Volume Setting"] [node name="SFX Label" type="Label" parent="Sliders/SFX Volume Setting"]
margin_top = 48.0 margin_left = -6.0
margin_right = 64.0 margin_top = 46.0
margin_bottom = 64.0 margin_right = 58.0
custom_colors/font_color = Color( 0, 0, 0, 1 ) margin_bottom = 70.0
custom_fonts/font = SubResource( 4 )
text = "SFX:" text = "SFX:"
align = 2 align = 2
valign = 1 valign = 1
@ -112,23 +144,27 @@ __meta__ = {
[node name="SFX Slider" type="HSlider" parent="Sliders/SFX Volume Setting"] [node name="SFX Slider" type="HSlider" parent="Sliders/SFX Volume Setting"]
margin_left = 64.0 margin_left = 64.0
margin_top = 48.0 margin_top = 50.0
margin_right = 208.0 margin_right = 208.0
margin_bottom = 64.0 margin_bottom = 66.0
max_value = 1.0 max_value = 1.0
step = 0.05 step = 0.05
tick_count = 10 tick_count = 10
ticks_on_borders = true
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Buttons" type="HBoxContainer" parent="."] [node name="Buttons" type="HBoxContainer" parent="."]
margin_left = 216.0 anchor_left = 0.5
margin_top = 200.0 anchor_top = 0.498036
margin_right = 424.0 anchor_right = 0.5
margin_bottom = 224.0 anchor_bottom = 0.498036
margin_left = -102.0
margin_top = 30.7071
margin_right = 106.0
margin_bottom = 54.7071
__meta__ = { __meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -157,8 +193,8 @@ text = "Dark Mode"
[node name="Back" type="Button" parent="."] [node name="Back" type="Button" parent="."]
margin_left = 16.0 margin_left = 16.0
margin_top = 16.0 margin_top = 16.0
margin_right = 28.0 margin_right = 83.0
margin_bottom = 36.0 margin_bottom = 40.0
focus_neighbour_left = NodePath(".") focus_neighbour_left = NodePath(".")
focus_neighbour_top = NodePath(".") focus_neighbour_top = NodePath(".")
focus_neighbour_right = NodePath("../Sliders/SFX Setting/SFX Slider") focus_neighbour_right = NodePath("../Sliders/SFX Setting/SFX Slider")
@ -167,7 +203,6 @@ focus_next = NodePath("../Sliders/SFX Setting/SFX Slider")
focus_previous = NodePath(".") focus_previous = NodePath(".")
text = "Back" text = "Back"
__meta__ = { __meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }

View File

@ -1,5 +1,6 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://light_theme.tres" type="Theme" id=1]
[ext_resource path="res://script/title screen/Title Screen.gd" type="Script" id=2] [ext_resource path="res://script/title screen/Title Screen.gd" type="Script" id=2]
[ext_resource path="res://assets/font/Minecraft.ttf" type="DynamicFontData" id=3] [ext_resource path="res://assets/font/Minecraft.ttf" type="DynamicFontData" id=3]
@ -12,6 +13,7 @@ font_data = ExtResource( 3 )
[node name="Title Node" type="Control"] [node name="Title Node" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
theme = ExtResource( 1 )
script = ExtResource( 2 ) script = ExtResource( 2 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
@ -22,36 +24,36 @@ anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5
anchor_right = 0.5 anchor_right = 0.5
anchor_bottom = 0.5 anchor_bottom = 0.5
margin_left = -68.077 margin_left = -80.0
margin_top = 10.0 margin_top = 11.0
margin_right = 68.077 margin_right = 80.0
margin_bottom = 102.0 margin_bottom = 119.0
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Singleplayer" type="Button" parent="VBoxContainer"] [node name="Singleplayer" type="Button" parent="VBoxContainer"]
margin_right = 136.0 margin_right = 160.0
margin_bottom = 20.0 margin_bottom = 24.0
focus_neighbour_top = NodePath("../Quit") focus_neighbour_top = NodePath("../Quit")
text = "Single Player" text = "Single Player"
[node name="Multiplayer" type="Button" parent="VBoxContainer"] [node name="Multiplayer" type="Button" parent="VBoxContainer"]
margin_top = 24.0 margin_top = 28.0
margin_right = 136.0 margin_right = 160.0
margin_bottom = 44.0 margin_bottom = 52.0
text = "Multiplayer" text = "Multiplayer"
[node name="Options" type="Button" parent="VBoxContainer"] [node name="Options" type="Button" parent="VBoxContainer"]
margin_top = 48.0 margin_top = 56.0
margin_right = 136.0 margin_right = 160.0
margin_bottom = 68.0 margin_bottom = 80.0
text = "Options" text = "Options"
[node name="Quit" type="Button" parent="VBoxContainer"] [node name="Quit" type="Button" parent="VBoxContainer"]
margin_top = 72.0 margin_top = 84.0
margin_right = 136.0 margin_right = 160.0
margin_bottom = 92.0 margin_bottom = 108.0
focus_neighbour_bottom = NodePath("../Singleplayer") focus_neighbour_bottom = NodePath("../Singleplayer")
text = "Quit" text = "Quit"
@ -61,9 +63,9 @@ anchor_top = 0.5
anchor_right = 0.5 anchor_right = 0.5
anchor_bottom = 0.5 anchor_bottom = 0.5
margin_left = -157.0 margin_left = -157.0
margin_top = -50.0 margin_top = -59.0
margin_right = 157.0 margin_right = 157.0
margin_bottom = -6.0 margin_bottom = -15.0
size_flags_stretch_ratio = 0.0 size_flags_stretch_ratio = 0.0
custom_fonts/font = SubResource( 1 ) custom_fonts/font = SubResource( 1 )
custom_colors/font_outline_modulate = Color( 0, 0, 0, 1 ) custom_colors/font_outline_modulate = Color( 0, 0, 0, 1 )

View File

@ -7,8 +7,10 @@ onready var Options = preload("res://scenes/Options.tscn" )
onready var Debug_Menu = preload("res://scenes/Debug Menu.tscn" ) onready var Debug_Menu = preload("res://scenes/Debug Menu.tscn" )
# Themes # Themes
var lightmode = preload("res://assets/backgrounds/Background_Light.png"); var lightmode = preload("res://assets/backgrounds/Background_Light.png")
var darkmode = preload("res://assets/backgrounds/Background_Dark.png"); var darkmode = preload("res://assets/backgrounds/Background_Dark.png")
var light_theme = load("res://light_theme.tres")
var dark_theme = load("res://dark_theme.tres")
#flags #flags
var power_saving = true var power_saving = true
@ -104,5 +106,7 @@ func _on_title_request():
func _on_change_theme(theme): func _on_change_theme(theme):
if theme == "light": if theme == "light":
get_node("Background").set_texture(lightmode) get_node("Background").set_texture(lightmode)
self.set_theme(light_theme)
elif theme == "dark": elif theme == "dark":
get_node("Background").set_texture(darkmode) get_node("Background").set_texture(darkmode)
self.set_theme(dark_theme)

View File

@ -5,6 +5,9 @@ class ShipData:
var Length: int var Length: int
var Orientation: bool #vertical is true, (Trueship = vertical) (Falseship = horizontal) 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 # 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 # 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") onready var Setup = preload("res://scenes/Game/Setup.tscn")
@ -27,6 +30,7 @@ var hit = false
# TODO: Multiplayer # TODO: Multiplayer
var is_multiplayer = false var is_multiplayer = false
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
# TODO: Move Setup into the Player. # TODO: Move Setup into the Player.
@ -36,6 +40,12 @@ func _ready():
get_node("ConfirmationDialog").get_ok().text = "Yes" get_node("ConfirmationDialog").get_ok().text = "Yes"
get_node("ConfirmationDialog").get_cancel().text = "No" 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. # TODO: Move Setup into the Player.
func game_setup(_ships): func game_setup(_ships):
@ -73,3 +83,9 @@ func _on_Button_button_down():
func _on_ConfirmationDialog_confirmed(): func _on_ConfirmationDialog_confirmed():
end() 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)

View File

@ -6,6 +6,9 @@ onready var Ships = ["2Ship", "3ShipA", "3ShipB", "4Ship", "5Ship"]
onready var Victory = preload("res://scenes/Game/Player.tscn") 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: class ShipData:
var Position: Vector2 var Position: Vector2
var Length: int var Length: int
@ -15,7 +18,12 @@ class ShipData:
func _ready(): func _ready():
# Moves the focus to this menu # Moves the focus to this menu
if find_next_valid_focus(): find_next_valid_focus().grab_focus() 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(): func _on_Confirm_Placement_pressed():
# Make the button noise # Make the button noise
@ -53,3 +61,9 @@ func _on_Clear_pressed():
for ship in Ships: for ship in Ships:
get_node(ship).clear() get_node(ship).clear()
pass # Replace with function body. 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)

View File

@ -5,6 +5,8 @@ onready var music_slider = find_node("Music Slider", true, true)
onready var sound_slider = find_node("SFX Slider", true, true) onready var sound_slider = find_node("SFX Slider", true, true)
onready var theme_buttons = find_node("Buttons", true, true).get_children() onready var theme_buttons = find_node("Buttons", true, true).get_children()
var light_theme = load("res://light_theme.tres")
var dark_theme = load("res://dark_theme.tres")
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
@ -13,6 +15,10 @@ func _ready():
master_slider.value = db2linear(OptionsController.get_mas_volume()) master_slider.value = db2linear(OptionsController.get_mas_volume())
music_slider.value = db2linear(OptionsController.get_mus_volume()) music_slider.value = db2linear(OptionsController.get_mus_volume())
sound_slider.value = db2linear(OptionsController.get_sfx_volume()) sound_slider.value = db2linear(OptionsController.get_sfx_volume())
var _errno = 0;
_errno += OptionsController.connect("change_theme", self, "_on_change_theme")
_on_change_theme(OptionsController.get_theme())
func _on_Button_pressed(): func _on_Button_pressed():
AudioBus.emit_signal("button_clicked") AudioBus.emit_signal("button_clicked")
@ -41,3 +47,9 @@ func _on_Light_pressed():
func _on_Dark_pressed(): func _on_Dark_pressed():
AudioBus.emit_signal("button_clicked") AudioBus.emit_signal("button_clicked")
OptionsController.set_theme("dark") OptionsController.set_theme("dark")
func _on_change_theme(theme):
if theme == "light":
self.set_theme(light_theme)
elif theme == "dark":
self.set_theme(dark_theme)

View File

@ -1,8 +1,14 @@
extends Control extends Control
var light_theme = load("res://light_theme.tres")
var dark_theme = load("res://dark_theme.tres")
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
$VBoxContainer/Singleplayer.grab_focus() $VBoxContainer/Singleplayer.grab_focus()
var _errno = 0;
_errno += OptionsController.connect("change_theme", self, "_on_change_theme")
_on_change_theme(OptionsController.get_theme())
func _on_Singleplayer_pressed(): func _on_Singleplayer_pressed():
AudioBus.emit_signal("button_clicked") AudioBus.emit_signal("button_clicked")
@ -23,3 +29,9 @@ func _on_Quit_pressed():
AudioBus.emit_signal("button_clicked") AudioBus.emit_signal("button_clicked")
MessageBus.emit_signal("quit") MessageBus.emit_signal("quit")
queue_free() queue_free()
func _on_change_theme(theme):
if theme == "light":
self.set_theme(light_theme)
elif theme == "dark":
self.set_theme(dark_theme)