Add vehicle and track selection menu to start menu
parent
0adeb40d0b
commit
ab209ad1c5
|
@ -1,7 +1,5 @@
|
||||||
extends PopupDialog
|
extends PopupDialog
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
$MarginContainer/VSplitContainer/VBoxContainer/ContinueButton.grab_focus()
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if Input.is_action_just_pressed("ui_cancel"):
|
if Input.is_action_just_pressed("ui_cancel"):
|
||||||
|
@ -12,10 +10,12 @@ func _process(_delta: float) -> void:
|
||||||
show()
|
show()
|
||||||
get_tree().paused = true
|
get_tree().paused = true
|
||||||
|
|
||||||
|
|
||||||
func _on_ContinueButton_pressed():
|
func _on_ContinueButton_pressed():
|
||||||
hide()
|
hide()
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
|
|
||||||
|
|
||||||
func _on_ExitButton_pressed():
|
func _on_ExitButton_pressed():
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
get_tree().change_scene("res://scenes/menu/main_menu.tscn")
|
get_tree().change_scene("res://scenes/menu/main_menu.tscn")
|
||||||
|
|
|
@ -6,26 +6,38 @@ const bugmobile = preload("res://vehicles/bugmobile.tscn")
|
||||||
const test_scene = preload("res://scenes/test_level.tscn")
|
const test_scene = preload("res://scenes/test_level.tscn")
|
||||||
const gui_scene = preload("res://player/gui.tscn")
|
const gui_scene = preload("res://player/gui.tscn")
|
||||||
|
|
||||||
|
onready var vehicle_selector = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/VehicleSelector
|
||||||
|
onready var track_selector = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/TrackSelector
|
||||||
|
|
||||||
|
var vehicles = [beetle, buggy, bugmobile]
|
||||||
|
var tracks = [test_scene]
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/BeetleButton.grab_focus()
|
vehicle_selector.grab_focus()
|
||||||
|
vehicle_selector.add_item("Beetlecar")
|
||||||
|
vehicle_selector.add_item("Buggy")
|
||||||
|
vehicle_selector.add_item("Bugmobile")
|
||||||
|
|
||||||
func _on_BuggyButton_pressed() -> void:
|
track_selector.add_item("Test track")
|
||||||
_start_with_vehicle(buggy.instance())
|
|
||||||
|
|
||||||
func _on_BeetleButton_pressed() -> void:
|
func _on_StartButton_pressed() -> void:
|
||||||
_start_with_vehicle(beetle.instance())
|
print(vehicle_selector.get_selected_id())
|
||||||
|
print(track_selector.get_selected_id())
|
||||||
|
if vehicle_selector.get_selected_id() < 0:
|
||||||
|
return
|
||||||
|
if track_selector.get_selected_id() < 0:
|
||||||
|
return
|
||||||
|
var vehicle = vehicles[vehicle_selector.get_selected_id()]
|
||||||
|
var track = tracks[track_selector.get_selected_id()]
|
||||||
|
_start_track_with_vehicle(track.instance(), vehicle.instance())
|
||||||
|
|
||||||
func _on_BugmobileButton_pressed() -> void:
|
func _start_track_with_vehicle(track: Node, vehicle: Node) -> void:
|
||||||
_start_with_vehicle(bugmobile.instance())
|
|
||||||
|
|
||||||
func _start_with_vehicle(vehicle: Node) -> void:
|
|
||||||
var gui = gui_scene.instance()
|
var gui = gui_scene.instance()
|
||||||
var scene = test_scene.instance()
|
|
||||||
vehicle.connect("speed_updated", gui, "update_speed")
|
vehicle.connect("speed_updated", gui, "update_speed")
|
||||||
vehicle.connect("rpm_updated", gui, "update_rpm")
|
vehicle.connect("rpm_updated", gui, "update_rpm")
|
||||||
vehicle.connect("gear_updated", gui, "update_gear")
|
vehicle.connect("gear_updated", gui, "update_gear")
|
||||||
scene.call_deferred("spawn_player", vehicle, gui)
|
track.call_deferred("spawn_player", vehicle, gui)
|
||||||
get_tree().root.call_deferred("add_child", scene)
|
get_tree().root.call_deferred("add_child", track)
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
func _on_BackButton_pressed() -> void:
|
func _on_BackButton_pressed() -> void:
|
||||||
|
|
|
@ -26,6 +26,9 @@ margin_left = 20.0
|
||||||
margin_top = 20.0
|
margin_top = 20.0
|
||||||
margin_right = -20.0
|
margin_right = -20.0
|
||||||
margin_bottom = -20.0
|
margin_bottom = -20.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer"]
|
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer"]
|
||||||
margin_right = 984.0
|
margin_right = 984.0
|
||||||
|
@ -38,12 +41,12 @@ margin_bottom = 72.0
|
||||||
dragger_visibility = 1
|
dragger_visibility = 1
|
||||||
|
|
||||||
[node name="BackButton" type="Button" parent="MarginContainer/VSplitContainer/HSplitContainer"]
|
[node name="BackButton" type="Button" parent="MarginContainer/VSplitContainer/HSplitContainer"]
|
||||||
margin_right = 42.0
|
margin_right = 75.0
|
||||||
margin_bottom = 72.0
|
margin_bottom = 72.0
|
||||||
text = "Back"
|
text = "Back"
|
||||||
|
|
||||||
[node name="Title" type="Label" parent="MarginContainer/VSplitContainer/HSplitContainer"]
|
[node name="Title" type="Label" parent="MarginContainer/VSplitContainer/HSplitContainer"]
|
||||||
margin_left = 54.0
|
margin_left = 99.0
|
||||||
margin_right = 984.0
|
margin_right = 984.0
|
||||||
margin_bottom = 72.0
|
margin_bottom = 72.0
|
||||||
custom_fonts/font = SubResource( 1 )
|
custom_fonts/font = SubResource( 1 )
|
||||||
|
@ -52,40 +55,43 @@ align = 1
|
||||||
valign = 1
|
valign = 1
|
||||||
|
|
||||||
[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VSplitContainer"]
|
[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VSplitContainer"]
|
||||||
margin_top = 84.0
|
margin_top = 96.0
|
||||||
margin_right = 984.0
|
margin_right = 984.0
|
||||||
margin_bottom = 560.0
|
margin_bottom = 560.0
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer/CenterContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer/CenterContainer"]
|
||||||
margin_left = 386.0
|
margin_left = 317.0
|
||||||
margin_top = 171.0
|
margin_top = 152.0
|
||||||
margin_right = 597.0
|
margin_right = 666.0
|
||||||
margin_bottom = 305.0
|
margin_bottom = 312.0
|
||||||
|
|
||||||
[node name="BeetleButton" type="Button" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
|
[node name="VehicleSelector" type="OptionButton" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
|
||||||
margin_right = 211.0
|
margin_right = 349.0
|
||||||
margin_bottom = 42.0
|
margin_bottom = 48.0
|
||||||
custom_fonts/font = SubResource( 2 )
|
custom_fonts/font = SubResource( 2 )
|
||||||
text = "Beetle"
|
text = "Select vehicle"
|
||||||
|
align = 1
|
||||||
|
|
||||||
[node name="BuggyButton" type="Button" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
|
[node name="TrackSelector" type="OptionButton" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
|
||||||
margin_top = 46.0
|
margin_top = 56.0
|
||||||
margin_right = 211.0
|
margin_right = 349.0
|
||||||
margin_bottom = 88.0
|
margin_bottom = 104.0
|
||||||
custom_fonts/font = SubResource( 2 )
|
custom_fonts/font = SubResource( 2 )
|
||||||
text = "Buggy"
|
text = "Select Track"
|
||||||
|
align = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="BugmobileButton" type="Button" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
|
[node name="StartButton" type="Button" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
|
||||||
margin_top = 92.0
|
margin_top = 112.0
|
||||||
margin_right = 211.0
|
margin_right = 349.0
|
||||||
margin_bottom = 134.0
|
margin_bottom = 160.0
|
||||||
custom_fonts/font = SubResource( 2 )
|
custom_fonts/font = SubResource( 2 )
|
||||||
text = "Bugmobile"
|
text = "Start"
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[connection signal="pressed" from="MarginContainer/VSplitContainer/HSplitContainer/BackButton" to="." method="_on_BackButton_pressed"]
|
[connection signal="pressed" from="MarginContainer/VSplitContainer/HSplitContainer/BackButton" to="." method="_on_BackButton_pressed"]
|
||||||
[connection signal="pressed" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/BeetleButton" to="." method="_on_BeetleButton_pressed"]
|
[connection signal="pressed" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/StartButton" to="." method="_on_StartButton_pressed"]
|
||||||
[connection signal="pressed" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/BuggyButton" to="." method="_on_BuggyButton_pressed"]
|
|
||||||
[connection signal="pressed" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/BugmobileButton" to="." method="_on_BugmobileButton_pressed"]
|
|
||||||
|
|
Loading…
Reference in New Issue