Update game UI from OptionButton to LineEdit
Replaced multiple OptionButton instances with LineEdit for input fields, including three_of_a_kind, four_of_a_kind, and chance. Updated related scoring logic and adjusted UI themes and assets to reflect the new input method.
This commit is contained in:
59
GameScene.gd
59
GameScene.gd
@ -8,13 +8,13 @@ var three : OptionButton
|
||||
var four : OptionButton
|
||||
var five : OptionButton
|
||||
var six : OptionButton
|
||||
var three_of_a_kind : OptionButton
|
||||
var four_of_a_kind : OptionButton
|
||||
var three_of_a_kind : LineEdit
|
||||
var four_of_a_kind : LineEdit
|
||||
var full_house : OptionButton
|
||||
var small_straight : OptionButton
|
||||
var large_straight : OptionButton
|
||||
var yahtzee : Button
|
||||
var chance : OptionButton
|
||||
var chance : LineEdit
|
||||
var bonus : Label
|
||||
var score : Label
|
||||
|
||||
@ -31,10 +31,8 @@ func _ready():
|
||||
four = get_node("ScrollContainer/VBoxContainer/Four/HBoxContainer/OptionButton")
|
||||
five = get_node("ScrollContainer/VBoxContainer/Five/HBoxContainer/OptionButton")
|
||||
six = get_node("ScrollContainer/VBoxContainer/Six/HBoxContainer/OptionButton")
|
||||
three_of_a_kind = get_node("ScrollContainer/VBoxContainer/Three_of_a_kind/HBoxContainer/OptionButton")
|
||||
add_items(three_of_a_kind)
|
||||
four_of_a_kind = get_node("ScrollContainer/VBoxContainer/Four_of_a_Kind/HBoxContainer/OptionButton")
|
||||
add_items(four_of_a_kind)
|
||||
three_of_a_kind = get_node("ScrollContainer/VBoxContainer/Three_of_a_kind/HBoxContainer/LineEdit")
|
||||
four_of_a_kind = get_node("ScrollContainer/VBoxContainer/Four_of_a_Kind/HBoxContainer/LineEdit")
|
||||
full_house = get_node("ScrollContainer/VBoxContainer/Full_House/HBoxContainer/OptionButton")
|
||||
full_house.add_item("")
|
||||
full_house.add_item("-")
|
||||
@ -45,8 +43,7 @@ func _ready():
|
||||
add_items_to_large_straight(large_straight)
|
||||
yahtzee = get_node("ScrollContainer/VBoxContainer/yahtzee/HBoxContainer/ButtonYahtzee")
|
||||
bonus = get_node("ScrollContainer/VBoxContainer/Bonus/HBoxContainer/LabelScore")
|
||||
chance = get_node("ScrollContainer/VBoxContainer/chance/HBoxContainer/OptionButton")
|
||||
add_items(chance)
|
||||
chance = get_node("ScrollContainer/VBoxContainer/chance/HBoxContainer/LineEdit")
|
||||
score = get_node("ScrollContainer/VBoxContainer/Score/HBoxContainer/LabelScore")
|
||||
pass # Replace with function body.
|
||||
|
||||
@ -90,13 +87,13 @@ func calc_score():
|
||||
int(four.get_item_text(four.get_selected_id())) +
|
||||
int(five.get_item_text(five.get_selected_id())) +
|
||||
int(six.get_item_text(six.get_selected_id())) +
|
||||
int(three_of_a_kind.get_item_text(three_of_a_kind.get_selected_id())) +
|
||||
int(four_of_a_kind.get_item_text(four_of_a_kind.get_selected_id())) +
|
||||
int(three_of_a_kind.get_text()) +
|
||||
int(four_of_a_kind.get_text()) +
|
||||
int(full_house.get_item_text(full_house.get_selected_id())) +
|
||||
int(small_straight.get_item_text(small_straight.get_selected_id())) +
|
||||
int(large_straight.get_item_text(large_straight.get_selected_id())) +
|
||||
int(yahtzee.text) +
|
||||
int(chance.get_item_text(chance.get_selected_id())) +
|
||||
int(chance.get_text()) +
|
||||
int(bonus.text))
|
||||
score.text = str(players[currentPlayer].score)
|
||||
|
||||
@ -108,13 +105,16 @@ func load_stats():
|
||||
four.select(players[currentPlayer].four)
|
||||
five.select(players[currentPlayer].five)
|
||||
six.select(players[currentPlayer].six)
|
||||
three_of_a_kind.select(players[currentPlayer].three_of_a_kind)
|
||||
four_of_a_kind.select(players[currentPlayer].four_of_a_kind)
|
||||
three_of_a_kind.text = str(players[currentPlayer].three_of_a_kind)
|
||||
four_of_a_kind.text = str(players[currentPlayer].four_of_a_kind)
|
||||
full_house.select(players[currentPlayer].full_house)
|
||||
small_straight.select(players[currentPlayer].small_straight)
|
||||
large_straight.select(players[currentPlayer].large_straight)
|
||||
yahtzee.text = str(players[currentPlayer].yahtzee)
|
||||
chance.select(players[currentPlayer].chance)
|
||||
if(players[currentPlayer].yahtzee != 0):
|
||||
yahtzee.text = str(players[currentPlayer].yahtzee)
|
||||
else:
|
||||
yahtzee.text = str("+")
|
||||
chance.text = str(players[currentPlayer].chance)
|
||||
bonus.text = str(players[currentPlayer].bonus)
|
||||
pass
|
||||
|
||||
@ -126,15 +126,28 @@ func save():
|
||||
players[currentPlayer].four = four.get_selected_id()
|
||||
players[currentPlayer].five = five.get_selected_id()
|
||||
players[currentPlayer].six = six.get_selected_id()
|
||||
players[currentPlayer].three_of_a_kind = int(three_of_a_kind.get_selected_id())
|
||||
players[currentPlayer].four_of_a_kind = int(four_of_a_kind.get_selected_id())
|
||||
players[currentPlayer].three_of_a_kind = three_of_a_kind.get_text()
|
||||
players[currentPlayer].four_of_a_kind = four_of_a_kind.get_text()
|
||||
players[currentPlayer].full_house = int(full_house.get_selected_id())
|
||||
players[currentPlayer].small_straight = int(small_straight.get_selected_id())
|
||||
players[currentPlayer].large_straight = int(large_straight.get_selected_id())
|
||||
players[currentPlayer].yahtzee = int(yahtzee.text)
|
||||
players[currentPlayer].bonus = int(bonus.text)
|
||||
players[currentPlayer].chance = int(chance.get_selected_id())
|
||||
players[currentPlayer].score = players[currentPlayer].one + players[currentPlayer].two + players[currentPlayer].three + players[currentPlayer].four + players[currentPlayer].five + players[currentPlayer].six + players[currentPlayer].three_of_a_kind + players[currentPlayer].four_of_a_kind + players[currentPlayer].full_house + players[currentPlayer].small_straight + players[currentPlayer].large_straight + players[currentPlayer].yahtzee + players[currentPlayer].chance + players[currentPlayer].bonus
|
||||
players[currentPlayer].chance = chance.get_text()
|
||||
players[currentPlayer].score = (players[currentPlayer].one +
|
||||
players[currentPlayer].two +
|
||||
players[currentPlayer].three +
|
||||
players[currentPlayer].four +
|
||||
players[currentPlayer].five +
|
||||
players[currentPlayer].six +
|
||||
int(players[currentPlayer].three_of_a_kind) +
|
||||
int(players[currentPlayer].four_of_a_kind) +
|
||||
players[currentPlayer].full_house +
|
||||
players[currentPlayer].small_straight +
|
||||
players[currentPlayer].large_straight +
|
||||
players[currentPlayer].yahtzee +
|
||||
int(players[currentPlayer].chance) +
|
||||
players[currentPlayer].bonus)
|
||||
pass
|
||||
|
||||
func _on_button_left_pressed():
|
||||
@ -158,6 +171,7 @@ func add_items_to_large_straight(oButton: OptionButton):
|
||||
oButton.add_item("-")
|
||||
oButton.add_item("40")
|
||||
pass # Replace with function body.
|
||||
|
||||
func add_items(oButton: OptionButton):
|
||||
oButton.add_item("")
|
||||
oButton.add_item("-")
|
||||
@ -243,7 +257,10 @@ func _on_button_yahtzee_pressed():
|
||||
|
||||
func _on_button_yahtzee_minus_pressed():
|
||||
Player_Manger.get_players()[currentPlayer].yahtzee -= 50
|
||||
yahtzee.text = str(Player_Manger.get_players()[currentPlayer].yahtzee)
|
||||
if(Player_Manger.get_players()[currentPlayer].yahtzee != 0):
|
||||
yahtzee.text = str(Player_Manger.get_players()[currentPlayer].yahtzee)
|
||||
else:
|
||||
yahtzee.text = str("+")
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user