Переглянути джерело

Export format string variables

In order to make them editable from the editor.
DricomDragon 3 роки тому
батько
коміт
a4eb4ff197
2 змінених файлів з 7 додано та 4 видалено
  1. 1 1
      godot/Scenes/Game.tscn
  2. 6 3
      godot/Scripts/Hub.gd

+ 1 - 1
godot/Scenes/Game.tscn

@@ -64,6 +64,6 @@ __meta__ = {
 
 [node name="LevelSwap" type="Tween" parent="."]
 script = ExtResource( 2 )
-[connection signal="timeout" from="StartTimer" to="Ui" method="hide"]
 [connection signal="timeout" from="StartTimer" to="." method="_on_start_game"]
+[connection signal="timeout" from="StartTimer" to="Ui" method="hide"]
 [connection signal="input_list_updated" from="Hub" to="Ui" method="_on_Hub_input_list_updated"]

+ 6 - 3
godot/Scripts/Hub.gd

@@ -2,6 +2,7 @@ class_name Hub
 extends Node2D
 # User interface to create liners
 
+
 signal hub_finished
 signal input_list_updated
 
@@ -9,7 +10,9 @@ const ACTION_PLAYER_PREFIX = "p"
 const ACTION_LEFT_SUFFIX = "_left"
 const ACTION_RIGHT_SUFFIX = "_right"
 const MAX_PLAYERS = 8
-const TXT_FORMAT_INPUT_LINE = "Player %d > left : %s | right : %s"
+
+export var format_player_control = "Player %d > left : %s | right : %s"
+export var format_mouse_button = "MB %s"
 
 export (Array, Color) var playerColors = [
 	Color.red,
@@ -76,7 +79,7 @@ func _update_input_list_text():
 		var values = [k]
 		values.append(_get_label_from_action_name(_playerActionsLeft[k]))
 		values.append(_get_label_from_action_name(_playerActionsRight[k]))
-		input_text_array.append(TXT_FORMAT_INPUT_LINE % values)
+		input_text_array.append(format_player_control % values)
 	_input_list_text = input_text_array.join("\n")
 	emit_signal("input_list_updated", _input_list_text)
 
@@ -85,7 +88,7 @@ func _get_label_from_action_name(action:String):
 	var input_label_array = PoolStringArray()
 	for event in InputMap.get_action_list(action):
 		if event is InputEventMouseButton:
-			input_label_array.append("MB%s" % event.button_index)
+			input_label_array.append(format_mouse_button % event.button_index)
 		else:
 			input_label_array.append(event.as_text())
 	return input_label_array.join(", ")