small racing game im working on
Diffstat (limited to 'ui/mc-ls.gd')
| -rw-r--r-- | ui/mc-ls.gd | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/ui/mc-ls.gd b/ui/mc-ls.gd deleted file mode 100644 index 417db4e..0000000 --- a/ui/mc-ls.gd +++ /dev/null @@ -1,53 +0,0 @@ -extends VBoxContainer - -var players: Dictionary = {} -var pictures: Dictionary = {} - -@export var ls: LabelSettings -@export var pad: Texture2D -@export var kbd: Texture2D - -func on_change() -> void: - var ks := pictures.keys() - for i in pictures.size(): - (pictures[ks[i]].get_child(0) as Label).text = str(i + 1) - -func _input(event: InputEvent) -> void: - if not event.is_pressed(): - return - if event.is_action("ui_cancel") and players.has(event.device): - players.erase(event.device) - var t := get_tree().create_tween().set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_BACK) - var p: TextureRect = pictures[event.device] - pictures.erase(event.device) - var gp := p.global_position - remove_child(p) # move out to free space - owner.add_child(p) - p.global_position = gp - t.tween_property(p, ^"position", Vector2(-130, p.position.y), .3) - t.tween_callback(p.queue_free) - on_change() - elif good(event) and !players.has(event.device): - pictures[event.device] = maketex(pad if event is InputEventJoypadButton else kbd) - players[event.device] = true - on_change() - -func good(e: InputEvent) -> bool: - var bads := [InputEventJoypadMotion, InputEventMIDI, InputEventMouseButton, InputEventMouseMotion, InputEventScreenTouch, InputEventScreenDrag, InputEventGesture] - for bad in bads: - if e == bad: - return false - return true - -func maketex(t: Texture2D) -> TextureRect: - @warning_ignore("shadowed_variable_base_class") - var tr := TextureRect.new() - tr.texture = t - tr.expand_mode = TextureRect.EXPAND_KEEP_SIZE - tr.stretch_mode = TextureRect.STRETCH_KEEP - var l := Label.new() - l.label_settings = ls - l.position.x = 100 - tr.add_child(l) - add_child(tr) - return tr |