mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-20 16:20:18 +01:00
Convert level dropdowns to OptionButtons
This commit is contained in:
parent
5a0ff96324
commit
f6ec691ece
3 changed files with 28 additions and 29 deletions
22
main.gd
22
main.gd
|
@ -19,12 +19,14 @@ onready var level_congrats = $HBoxContainer/RightSide/TopStuff/LevelPanel/Text/L
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# Initialize level select.
|
# Initialize level select.
|
||||||
var options = level_select.get_popup()
|
level_select.connect("item_selected", self, "load_level")
|
||||||
options.connect("id_pressed", self, "load_level")
|
repopulate_levels()
|
||||||
|
level_select.select(0)
|
||||||
|
|
||||||
# Initialize chapter select.
|
# Initialize chapter select.
|
||||||
options = chapter_select.get_popup()
|
chapter_select.connect("item_selected", self, "load_chapter")
|
||||||
options.connect("id_pressed", self, "load_chapter")
|
repopulate_chapters()
|
||||||
|
chapter_select.select(0)
|
||||||
|
|
||||||
# Load first level.
|
# Load first level.
|
||||||
load_level(0)
|
load_level(0)
|
||||||
|
@ -82,7 +84,7 @@ func list_levels():
|
||||||
func load_chapter(id):
|
func load_chapter(id):
|
||||||
var chapters = list_chapters()
|
var chapters = list_chapters()
|
||||||
chapter = chapters[id]
|
chapter = chapters[id]
|
||||||
chapter_select.text = chapter
|
load_level(0)
|
||||||
|
|
||||||
func load_level(id):
|
func load_level(id):
|
||||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), true)
|
AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), true)
|
||||||
|
@ -184,13 +186,11 @@ func show_win_status():
|
||||||
level_congrats.show()
|
level_congrats.show()
|
||||||
|
|
||||||
func repopulate_levels():
|
func repopulate_levels():
|
||||||
var options = level_select.get_popup()
|
level_select.clear()
|
||||||
options.clear()
|
|
||||||
for level in list_levels():
|
for level in list_levels():
|
||||||
options.add_item(level)
|
level_select.add_item(level)
|
||||||
|
|
||||||
func repopulate_chapters():
|
func repopulate_chapters():
|
||||||
var options = chapter_select.get_popup()
|
chapter_select.clear()
|
||||||
options.clear()
|
|
||||||
for chapter in list_chapters():
|
for chapter in list_chapters():
|
||||||
options.add_item(chapter)
|
chapter_select.add_item(chapter)
|
||||||
|
|
27
main.tscn
27
main.tscn
|
@ -97,30 +97,21 @@ size_flags_vertical = 3
|
||||||
margin_right = 631.0
|
margin_right = 631.0
|
||||||
margin_bottom = 35.0
|
margin_bottom = 35.0
|
||||||
|
|
||||||
[node name="ChapterSelect" type="MenuButton" parent="HBoxContainer/RightSide/TopStuff/Menu"]
|
[node name="ChapterSelect" type="OptionButton" parent="HBoxContainer/RightSide/TopStuff/Menu"]
|
||||||
margin_right = 154.0
|
margin_right = 168.0
|
||||||
margin_bottom = 35.0
|
margin_bottom = 35.0
|
||||||
text = "Select chapter..."
|
text = "Select chapter..."
|
||||||
flat = false
|
|
||||||
expand_icon = true
|
|
||||||
__meta__ = {
|
|
||||||
"_edit_use_anchors_": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="LevelSelect" type="MenuButton" parent="HBoxContainer/RightSide/TopStuff/Menu"]
|
[node name="LevelSelect" type="OptionButton" parent="HBoxContainer/RightSide/TopStuff/Menu"]
|
||||||
margin_left = 159.0
|
margin_left = 173.0
|
||||||
margin_right = 289.0
|
margin_right = 317.0
|
||||||
margin_bottom = 35.0
|
margin_bottom = 35.0
|
||||||
text = "Select level..."
|
text = "Select level..."
|
||||||
flat = false
|
|
||||||
expand_icon = true
|
expand_icon = true
|
||||||
__meta__ = {
|
|
||||||
"_edit_use_anchors_": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="ReloadButton" type="Button" parent="HBoxContainer/RightSide/TopStuff/Menu"]
|
[node name="ReloadButton" type="Button" parent="HBoxContainer/RightSide/TopStuff/Menu"]
|
||||||
margin_left = 294.0
|
margin_left = 322.0
|
||||||
margin_right = 373.0
|
margin_right = 401.0
|
||||||
margin_bottom = 35.0
|
margin_bottom = 35.0
|
||||||
focus_mode = 0
|
focus_mode = 0
|
||||||
enabled_focus_mode = 0
|
enabled_focus_mode = 0
|
||||||
|
@ -130,8 +121,8 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="NextLevelButton" type="Button" parent="HBoxContainer/RightSide/TopStuff/Menu"]
|
[node name="NextLevelButton" type="Button" parent="HBoxContainer/RightSide/TopStuff/Menu"]
|
||||||
margin_left = 378.0
|
margin_left = 406.0
|
||||||
margin_right = 488.0
|
margin_right = 516.0
|
||||||
margin_bottom = 35.0
|
margin_bottom = 35.0
|
||||||
focus_mode = 0
|
focus_mode = 0
|
||||||
custom_styles/hover = SubResource( 1 )
|
custom_styles/hover = SubResource( 1 )
|
||||||
|
|
|
@ -23,6 +23,10 @@ corner_radius_bottom_right = 5
|
||||||
corner_radius_bottom_left = 5
|
corner_radius_bottom_left = 5
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id=3]
|
[sub_resource type="StyleBoxFlat" id=3]
|
||||||
|
content_margin_left = 10.0
|
||||||
|
content_margin_right = 10.0
|
||||||
|
content_margin_top = 5.0
|
||||||
|
content_margin_bottom = 5.0
|
||||||
bg_color = Color( 0.278431, 0.278431, 0.278431, 1 )
|
bg_color = Color( 0.278431, 0.278431, 0.278431, 1 )
|
||||||
corner_radius_top_left = 5
|
corner_radius_top_left = 5
|
||||||
corner_radius_top_right = 5
|
corner_radius_top_right = 5
|
||||||
|
@ -41,6 +45,10 @@ corner_radius_bottom_right = 5
|
||||||
corner_radius_bottom_left = 5
|
corner_radius_bottom_left = 5
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id=5]
|
[sub_resource type="StyleBoxFlat" id=5]
|
||||||
|
content_margin_left = 10.0
|
||||||
|
content_margin_right = 10.0
|
||||||
|
content_margin_top = 5.0
|
||||||
|
content_margin_bottom = 5.0
|
||||||
bg_color = Color( 0.333333, 0.333333, 0.333333, 1 )
|
bg_color = Color( 0.333333, 0.333333, 0.333333, 1 )
|
||||||
corner_radius_top_left = 5
|
corner_radius_top_left = 5
|
||||||
corner_radius_top_right = 5
|
corner_radius_top_right = 5
|
||||||
|
|
Loading…
Reference in a new issue