Skip to content

Commit

Permalink
improve manual train control ui somewhat
Browse files Browse the repository at this point in the history
  • Loading branch information
Novakasa committed Oct 1, 2023
1 parent 1e0ba6f commit 648d14c
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 45 deletions.
94 changes: 79 additions & 15 deletions brickrail-gui/brickrail-layouts/ble_test.brl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "1.0.0",
"devices": {
"trains": [
{
Expand Down Expand Up @@ -148,8 +149,7 @@
},
"switches": {
"E": {
"motor1_inverted": false,
"motor2_inverted": false

}
}
},
Expand Down Expand Up @@ -485,10 +485,13 @@
"W": {
"motor1": {
"controller": "blue",
"port": 0
},
"motor1_inverted": false,
"motor2_inverted": false
"port": 0,
"storage": {
"0": 100,
"1": 600,
"2": 0
}
}
}
}
},
Expand Down Expand Up @@ -613,7 +616,7 @@
],
"blocks": [
{
"name": "block0",
"block_name": "block0",
"section": {
"tracks": [
{
Expand Down Expand Up @@ -649,10 +652,22 @@
"can_flip": {
"0": true,
"1": true
},
"random_target": {
"0": true,
"1": true
},
"wait_time": {
"0": 4,
"1": 4
},
"disable_train": {
"0": false,
"1": false
}
},
{
"name": "block1",
"block_name": "block1",
"section": {
"tracks": [
{
Expand Down Expand Up @@ -688,10 +703,22 @@
"can_flip": {
"0": true,
"1": true
},
"random_target": {
"0": true,
"1": true
},
"wait_time": {
"0": 4,
"1": 4
},
"disable_train": {
"0": false,
"1": false
}
},
{
"name": "block2",
"block_name": "block2",
"section": {
"tracks": [
{
Expand Down Expand Up @@ -727,10 +754,22 @@
"can_flip": {
"0": true,
"1": true
},
"random_target": {
"0": true,
"1": true
},
"wait_time": {
"0": 4,
"1": 4
},
"disable_train": {
"0": false,
"1": false
}
},
{
"name": "block3",
"block_name": "block3",
"section": {
"tracks": [
{
Expand Down Expand Up @@ -766,10 +805,22 @@
"can_flip": {
"0": true,
"1": true
},
"random_target": {
"0": true,
"1": true
},
"wait_time": {
"0": 4,
"1": 4
},
"disable_train": {
"0": false,
"1": false
}
},
{
"name": "block4",
"block_name": "block4",
"section": {
"tracks": [
{
Expand Down Expand Up @@ -805,17 +856,30 @@
"can_flip": {
"0": true,
"1": true
},
"random_target": {
"0": true,
"1": true
},
"wait_time": {
"0": 4,
"1": 4
},
"disable_train": {
"0": false,
"1": false
}
}
],
"trains": [
{
"name": "train0",
"train_name": "train0",
"facing": 1,
"fixed_facing": true,
"color": "ff000000",
"reversing_behavior": "off",
"color": "ffc7ff00",
"num_wagons": 4,
"blockname": "block2",
"random_targets": true,
"block_id": "block2",
"blockindex": 0,
"ble_train": "city-blue"
}
Expand Down
20 changes: 18 additions & 2 deletions brickrail-gui/devices/train/train_control_gui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ func update_controls_enabled(_dummy=null):
func set_controls_disabled(mode):
for child in get_node(control_container).get_children():
child.disabled=mode
$VBoxContainer/change_heading_button.disabled=mode

if not mode:
get_node(control_container).get_node("stop_button").pressed=true
get_node(control_container).get_node("slow_button").pressed=false
get_node(control_container).get_node("start_button").pressed=false
get_node(control_container).get_node("fast_button").pressed=false

func _on_train_name_changed(_old_name, new_name):
set_train_name(new_name)

Expand All @@ -49,18 +53,30 @@ func get_train():
return Devices.trains[train_name]

func _on_start_button_pressed():
get_node(control_container).get_node("slow_button").pressed=false
get_node(control_container).get_node("stop_button").pressed=false
get_node(control_container).get_node("fast_button").pressed=false
get_train().start()

func _on_stop_button_pressed():
get_node(control_container).get_node("slow_button").pressed=false
get_node(control_container).get_node("start_button").pressed=false
get_node(control_container).get_node("fast_button").pressed=false
get_train().stop()

func _on_slow_button_pressed():
get_node(control_container).get_node("stop_button").pressed=false
get_node(control_container).get_node("start_button").pressed=false
get_node(control_container).get_node("fast_button").pressed=false
get_train().slow()

func _on_change_heading_button_pressed():
get_train().flip_heading()

func _on_fast_button_pressed():
get_node(control_container).get_node("slow_button").pressed=false
get_node(control_container).get_node("start_button").pressed=false
get_node(control_container).get_node("stop_button").pressed=false
get_train().fast()

func _on_RemoveButton_pressed():
Expand Down
64 changes: 37 additions & 27 deletions brickrail-gui/devices/train/train_control_gui.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ hub_controls = NodePath("VBoxContainer/HubControl")

[node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_right = 199.0
margin_bottom = 120.0
margin_bottom = 116.0
rect_min_size = Vector2( 0, 44 )
size_flags_horizontal = 3

Expand Down Expand Up @@ -47,68 +47,78 @@ text = "Remove"

[node name="HubControl" parent="VBoxContainer" instance=ExtResource( 2 )]
margin_right = 199.0
margin_bottom = 72.0
margin_bottom = 92.0

[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 76.0
margin_top = 96.0
margin_right = 199.0
margin_bottom = 96.0
margin_bottom = 116.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}

[node name="change_heading_button" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_right = 28.0
margin_bottom = 20.0
hint_tooltip = "Change direction"
text = "<>"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="stop_button" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_right = 40.0
margin_left = 32.0
margin_right = 58.0
margin_bottom = 20.0
text = "Stop"
hint_tooltip = "Stop train"
toggle_mode = true
pressed = true
text = "||"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="slow_button" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 44.0
margin_right = 85.0
margin_left = 62.0
margin_right = 82.0
margin_bottom = 20.0
text = "Slow"
hint_tooltip = "Slow speed"
toggle_mode = true
text = ">"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="start_button" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 89.0
margin_right = 141.0
margin_left = 86.0
margin_right = 114.0
margin_bottom = 20.0
rect_min_size = Vector2( 0, 20 )
text = "Cruise"
hint_tooltip = "Cruise speed"
toggle_mode = true
text = ">>"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="fast_button" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 145.0
margin_right = 183.0
margin_left = 118.0
margin_right = 154.0
margin_bottom = 20.0
text = "Fast"

[node name="change_heading_button" type="Button" parent="VBoxContainer"]
margin_top = 100.0
margin_right = 199.0
margin_bottom = 120.0
text = "Turn"
__meta__ = {
"_edit_use_anchors_": false
}
hint_tooltip = "Fast speed"
toggle_mode = true
text = ">>>"

[node name="HSeparator" type="HSeparator" parent="."]
margin_top = 124.0
margin_top = 120.0
margin_right = 199.0
margin_bottom = 128.0
margin_bottom = 124.0

[connection signal="pressed" from="VBoxContainer/HBoxContainer2/RemoveButton" to="." method="_on_RemoveButton_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/change_heading_button" to="." method="_on_change_heading_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/stop_button" to="." method="_on_stop_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/slow_button" to="." method="_on_slow_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/start_button" to="." method="_on_start_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/fast_button" to="." method="_on_fast_button_pressed"]
[connection signal="pressed" from="VBoxContainer/change_heading_button" to="." method="_on_change_heading_button_pressed"]
2 changes: 1 addition & 1 deletion brickrail-gui/layout/grid/new_shader.tres
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ vec4 cell_composite(vec2 position) {

float num = 3.0;
float pointiness = 1.0;
float thickness = 0.3;
float thickness = 0.8;
float segment = 1.0/num;
float tscale_p = 0.0;
float tscale_n = 0.0;
Expand Down

0 comments on commit 648d14c

Please sign in to comment.