Add buttons for random words of different lengths
This commit is contained in:
parent
cde8565f5d
commit
b90fbb5e7c
4 changed files with 70 additions and 7 deletions
|
@ -9,6 +9,7 @@ enum GameMode {
|
|||
|
||||
const MIN_WORD_LENGTH := 3
|
||||
const MAX_WORD_LENGTH := 8
|
||||
const DEFAULT_WORD_LENGTH := 5
|
||||
const GENERABLE_WORDS_FILENAME = "res://words/popular-filtered.txt"
|
||||
const ALL_WORDS_FILENAME := "res://words/enable1.txt"
|
||||
|
||||
|
@ -22,6 +23,7 @@ var date_regex = RegEx.create_from_string("^[0-9]+-[0-9]+-[0-9]+$")
|
|||
var game_mode := GameMode.DAILY
|
||||
var custom_word := ""
|
||||
var custom_date_str := ""
|
||||
var custom_word_length := -1
|
||||
|
||||
var generable_words: Dictionary
|
||||
var all_words: Dictionary
|
||||
|
@ -162,7 +164,7 @@ func parse_custom(value: String) -> bool:
|
|||
if new_time > current_time:
|
||||
valid = false
|
||||
if valid:
|
||||
custom_word = generate_word(5, new_time)
|
||||
custom_word = generate_word(DEFAULT_WORD_LENGTH, new_time)
|
||||
custom_date_str = Time.get_date_string_from_unix_time(new_time)
|
||||
return true
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ const Letter := preload("res://src/letter.tscn")
|
|||
# An array of arrays of the letter nodes
|
||||
var letters := []
|
||||
var keyboard_buttons := {}
|
||||
var letter_count := 5
|
||||
var letter_count := Global.DEFAULT_WORD_LENGTH
|
||||
|
||||
var target_word: String
|
||||
var current_guess: int
|
||||
|
@ -60,6 +60,8 @@ func _ready() -> void:
|
|||
elif Global.game_mode == Global.GameMode.RANDOM:
|
||||
title.text = "Random " + title.text
|
||||
|
||||
if Global.custom_word_length > 0:
|
||||
letter_count = Global.custom_word_length
|
||||
target_word = Global.generate_word(letter_count, random_seed)
|
||||
|
||||
if Global.game_mode != Global.GameMode.DAILY:
|
||||
|
|
17
src/menu.gd
17
src/menu.gd
|
@ -4,22 +4,33 @@ extends Control
|
|||
@onready var quit_button: Button = %QuitButton
|
||||
@onready var credits: ColorRect = %Credits
|
||||
|
||||
@onready var random_buttons = [%Random3, %Random4, %Random6, %Random7, %Random8]
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if OS.has_feature("web"):
|
||||
quit_button.hide()
|
||||
|
||||
for button in random_buttons:
|
||||
button.pressed.connect(start_random_game.bind(int(button.text[0])))
|
||||
|
||||
|
||||
func start_random_game(length := -1) -> void:
|
||||
Global.game_mode = Global.GameMode.RANDOM
|
||||
Global.custom_word_length = length
|
||||
var error := get_tree().change_scene_to_file("res://src/main.tscn")
|
||||
assert(not error)
|
||||
|
||||
|
||||
func _on_DailyButton_pressed() -> void:
|
||||
Global.game_mode = Global.GameMode.DAILY
|
||||
Global.custom_word_length = -1
|
||||
var error := get_tree().change_scene_to_file("res://src/main.tscn")
|
||||
assert(not error)
|
||||
|
||||
|
||||
func _on_RandomButton_pressed() -> void:
|
||||
Global.game_mode = Global.GameMode.RANDOM
|
||||
var error := get_tree().change_scene_to_file("res://src/main.tscn")
|
||||
assert(not error)
|
||||
start_random_game()
|
||||
|
||||
|
||||
func _on_custom_button_pressed() -> void:
|
||||
|
|
|
@ -92,20 +92,22 @@ horizontal_alignment = 1
|
|||
|
||||
[node name="V2" type="VBoxContainer" parent="C/V"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
theme_override_constants/separation = 30
|
||||
|
||||
[node name="V" type="VBoxContainer" parent="C/V/V2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DailyButton" type="Button" parent="C/V/V2/V"]
|
||||
custom_minimum_size = Vector2(280, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Daily Gordle"
|
||||
|
||||
[node name="Label" type="Label" parent="C/V/V2/V"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = SubResource("2")
|
||||
text = "Changes every day
|
||||
at midnight GMT"
|
||||
text = "Changes at midnight UTC"
|
||||
label_settings = SubResource("LabelSettings_17upj")
|
||||
horizontal_alignment = 1
|
||||
|
||||
|
@ -114,9 +116,49 @@ custom_minimum_size = Vector2(310, 0)
|
|||
layout_mode = 2
|
||||
|
||||
[node name="RandomButton" type="Button" parent="C/V/V2/V2"]
|
||||
custom_minimum_size = Vector2(280, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Random Gordle"
|
||||
|
||||
[node name="H2" type="HBoxContainer" parent="C/V/V2/V2"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Random3" type="Button" parent="C/V/V2/V2/H2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "3dle"
|
||||
|
||||
[node name="Random4" type="Button" parent="C/V/V2/V2/H2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "4dle"
|
||||
|
||||
[node name="Spacer" type="Control" parent="C/V/V2/V2/H2"]
|
||||
custom_minimum_size = Vector2(20, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Random6" type="Button" parent="C/V/V2/V2/H2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "6dle"
|
||||
|
||||
[node name="Random7" type="Button" parent="C/V/V2/V2/H2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "7dle"
|
||||
|
||||
[node name="Random8" type="Button" parent="C/V/V2/V2/H2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "8dle"
|
||||
|
||||
[node name="Label" type="Label" parent="C/V/V2/V2"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = SubResource("2")
|
||||
|
@ -129,7 +171,9 @@ custom_minimum_size = Vector2(310, 0)
|
|||
layout_mode = 2
|
||||
|
||||
[node name="CustomButton" type="Button" parent="C/V/V2/V3"]
|
||||
custom_minimum_size = Vector2(280, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Custom Gordle"
|
||||
|
||||
[node name="Label" type="Label" parent="C/V/V2/V3"]
|
||||
|
@ -140,12 +184,16 @@ label_settings = SubResource("LabelSettings_cdviw")
|
|||
horizontal_alignment = 1
|
||||
|
||||
[node name="CreditsButton" type="Button" parent="C/V/V2"]
|
||||
custom_minimum_size = Vector2(280, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Licenses"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="C/V/V2"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(280, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Quit"
|
||||
|
||||
[node name="Credits" type="ColorRect" parent="."]
|
||||
|
|
Loading…
Reference in a new issue