From 5105182453fce93e3b8e49bec2efce4cbc1248f8 Mon Sep 17 00:00:00 2001 From: ObaniGemini Date: Tue, 28 Jul 2020 17:24:59 +0200 Subject: [PATCH] Fix Ms/S button not setting properly at startup --- Main.gd | 8 +++++--- Window.tscn | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Main.gd b/Main.gd index f4d17d7..013eafd 100644 --- a/Main.gd +++ b/Main.gd @@ -7,6 +7,7 @@ onready var BPM = $Container/BPM/LineEdit onready var Time = $Container/Time/LineEdit onready var Hz = $Container/Hz/LineEdit onready var Speed = $Speed/current +onready var TimeUnitButton = $Container/Time/HBoxContainer/Button var speed = 1 var timeUnit = 1 @@ -28,7 +29,8 @@ func _ready(): SM.load_config() set_speed( SM.config.speedIndex ) - timeUnit = SM.config.timeUnit + if( timeUnit != SM.config.timeUnit ): + switchTimeUnit() BPM.text = SM.config.BPM Time.text = SM.config.Time Hz.text = SM.config.Hz @@ -113,11 +115,11 @@ func set_speed( value ): func switchTimeUnit(): if( timeUnit == 1 ): - $Container/Time/HBoxContainer/Button.text = "Ms" + TimeUnitButton.text = "Ms" $Container/Time/Sub.text = "Milliseconds" timeUnit = 1000 else: - $Container/Time/HBoxContainer/Button.text = "S" + TimeUnitButton.text = "S" $Container/Time/Sub.text = "Seconds" timeUnit = 1 diff --git a/Window.tscn b/Window.tscn index 044d16b..d46db12 100644 --- a/Window.tscn +++ b/Window.tscn @@ -65,7 +65,7 @@ margin_left = 39.0 margin_right = 85.0 margin_bottom = 40.0 rect_min_size = Vector2( 46, 40 ) -text = "Ms" +text = "S" [node name="Sub" type="Label" parent="Container/Time"] modulate = Color( 1, 1, 1, 0.784314 ) @@ -73,7 +73,7 @@ margin_top = 74.0 margin_right = 125.0 margin_bottom = 91.0 custom_fonts/font = ExtResource( 2 ) -text = "Milliseconds" +text = "Seconds" align = 1 [node name="LineEdit" type="LineEdit" parent="Container/Time"]