#22: Now block add player if player name is empty
All checks were successful
Build / build (push) Successful in 1m21s
All checks were successful
Build / build (push) Successful in 1m21s
#23: Add a log for when points are given to players #25: Fixed some graphical stuff #26: Changed so the same character can be on a song multiple times #27: Turning off statistics after win
This commit is contained in:
@@ -16,6 +16,7 @@ var close_button: Button = $CloseButton
|
||||
var search_bar: TextEdit = $Searchbar
|
||||
|
||||
var games: Array = []
|
||||
var regex: RegEx
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
@@ -24,6 +25,7 @@ func _ready() -> void:
|
||||
search_bar.grab_focus()
|
||||
search_bar.text_changed.connect(search)
|
||||
visibility_changed.connect(focus)
|
||||
regex = RegEx.new()
|
||||
|
||||
func focus() -> void:
|
||||
if self.visible == true:
|
||||
@@ -37,21 +39,25 @@ func close() -> void:
|
||||
func search() -> void:
|
||||
print(search_bar.text)
|
||||
Settings.delete_children(search_list)
|
||||
var search_text: String = search_bar.text.to_lower()
|
||||
for game: String in games:
|
||||
if is_match_exact(search_bar.text, game):
|
||||
if is_match_exact(search_text, game):
|
||||
add_game(game)
|
||||
var clean_search_text: String = clean_search_term(search_text)
|
||||
for game: String in games:
|
||||
if is_match_contains(clean_search_text, clean_game(game)):
|
||||
add_game(game)
|
||||
for game: String in games:
|
||||
if is_match_contains(clean_term(search_bar.text), clean_term(game)):
|
||||
add_game(game)
|
||||
for game: String in games:
|
||||
if is_match_regex(clean_term(search_bar.text), clean_term(game)):
|
||||
if is_match_regex(clean_search_text, clean_game(game)):
|
||||
add_game(game)
|
||||
|
||||
func clean_term(term: String) -> String:
|
||||
func clean_search_term(term: String) -> String:
|
||||
return term.replace(" ", "").replace("é", "e").replace("+", "plus").replace("&", "and").replace("'n", "and")
|
||||
|
||||
func clean_game(term: String) -> String:
|
||||
return term.replace(" ", "").replace("é", "e").replace("+", "plus").replace("&", "and").replace("'n", "and").to_lower()
|
||||
|
||||
func is_match_exact(search_term: String, game_name: String) -> bool:
|
||||
search_term = search_term.to_lower()
|
||||
game_name = game_name.to_lower()
|
||||
|
||||
if search_term == "":
|
||||
@@ -78,7 +84,7 @@ func is_match_regex(search_term: String, game_name: String) -> bool:
|
||||
return false
|
||||
|
||||
func add_game(game: String) -> void:
|
||||
var label := Label.new()
|
||||
var label: Label = Label.new()
|
||||
label.text = game
|
||||
print("game: " + game)
|
||||
label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
@@ -93,22 +99,21 @@ func check_if_game_exists(game: String) -> bool:
|
||||
return game_exists
|
||||
|
||||
func compile_regex(search_term: String) -> RegEx:
|
||||
var regex = RegEx.new()
|
||||
var regText: String = ".*"
|
||||
for letter in search_term:
|
||||
for letter: String in search_term:
|
||||
regText += letter + ".*"
|
||||
regex.compile(regText)
|
||||
return regex
|
||||
|
||||
func get_list_of_games() -> void:
|
||||
print("get_list_of_games")
|
||||
var handle_games: Callable = func handle_games(array) -> void:
|
||||
var handle_games: Callable = func handle_games(array: Array) -> void:
|
||||
if typeof(array) == TYPE_ARRAY:
|
||||
games = []
|
||||
Settings.delete_children(search_list)
|
||||
games.append_array(array)
|
||||
for game in games:
|
||||
var label := Label.new()
|
||||
for game: String in games:
|
||||
var label: Label = Label.new()
|
||||
label.text = game
|
||||
label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
search_list.add_child(label)
|
||||
@@ -128,3 +133,46 @@ func clear() -> void:
|
||||
search()
|
||||
search_bar.grab_focus()
|
||||
|
||||
func old_search() -> void:
|
||||
print(search_bar.text)
|
||||
Settings.delete_children(search_list)
|
||||
for game: String in games:
|
||||
if old_is_match_exact(search_bar.text, game):
|
||||
add_game(game)
|
||||
for game: String in games:
|
||||
if is_match_contains(clean_term(search_bar.text), clean_term(game)):
|
||||
add_game(game)
|
||||
for game: String in games:
|
||||
if old_is_match_regex(clean_term(search_bar.text), clean_term(game)):
|
||||
add_game(game)
|
||||
|
||||
func clean_term(term: String) -> String:
|
||||
return term.replace(" ", "").replace("é", "e").replace("+", "plus").replace("&", "and").replace("'n", "and").to_lower()
|
||||
|
||||
|
||||
func old_is_match_exact(search_term: String, game_name: String) -> bool:
|
||||
search_term = search_term.to_lower()
|
||||
game_name = game_name.to_lower()
|
||||
|
||||
if search_term == "":
|
||||
return true
|
||||
elif game_name.contains(search_term):
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
func old_is_match_regex(search_term: String, game_name: String) -> bool:
|
||||
if search_term == "":
|
||||
return true
|
||||
elif compile_regex(search_term).search(game_name):
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
func old_compile_regex(search_term: String) -> RegEx:
|
||||
var regex = RegEx.new()
|
||||
var regText: String = ".*"
|
||||
for letter in search_term:
|
||||
regText += letter + ".*"
|
||||
regex.compile(regText)
|
||||
return regex
|
||||
|
||||
Reference in New Issue
Block a user