From 4cd369013fcd14221a08c889aacb4041c270f287 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Thu, 21 Jan 2021 19:47:21 +1030 Subject: [PATCH] Chart language selection --- main.tscn | 20 ++++++++++++++++++++ scripts/Menu.gd | 6 +++--- singletons/GameTheme.gd | 2 ++ singletons/Library.gd | 12 ++++-------- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/main.tscn b/main.tscn index 4d3ddb2..657e255 100644 --- a/main.tscn +++ b/main.tscn @@ -242,6 +242,26 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Label4" type="Label" parent="InputHandler"] +margin_top = 293.0 +margin_right = 133.0 +margin_bottom = 254.0 +text = "Language" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="BtnLanguage" type="OptionButton" parent="InputHandler"] +margin_left = 65.0 +margin_top = 290.0 +margin_right = 200.0 +margin_bottom = 310.0 +text = "Native" +align = 1 +__meta__ = { +"_edit_use_anchors_": false +} + [node name="VsyncButton" type="CheckButton" parent="InputHandler"] margin_top = 90.0 margin_right = 117.0 diff --git a/scripts/Menu.gd b/scripts/Menu.gd index e234d80..4abb83d 100644 --- a/scripts/Menu.gd +++ b/scripts/Menu.gd @@ -159,7 +159,7 @@ func draw_songtile(song_key, position, size, title_text:=false, difficulty=selec if disabled: draw_string_centered(DiffNumFont, Vector2(position.x+size/2, position.y+size/2-16), 'No Chart!', diff_color) if title_text: - draw_string_centered(TitleFont, Vector2(position.x+size/2.0, position.y+size), Library.all_songs[song_key].title.n, diff_color.lightened(0.33)) + draw_string_centered(TitleFont, Vector2(position.x+size/2.0, position.y+size), str(Library.all_songs[song_key].title), diff_color.lightened(0.33)) return rect func diff_f2str(difficulty: float): # Convert .5 to + @@ -230,7 +230,7 @@ func _draw_chart_select(center: Vector2) -> Array: var r = draw_songtile(selected_song_key, Vector2(x, center.y), size, false, i_diff, width, not chart_exists) touchrects.append({rect=r, chart_idx=i_diff, enabled=chart_exists}) x += size + spacer_x - draw_string_centered(TitleFont, Vector2(center.x, center.y+size+32), Library.all_songs[selected_song_key].title.n) + draw_string_centered(TitleFont, Vector2(center.x, center.y+size+32), str(Library.all_songs[selected_song_key].title)) draw_string_centered(TitleFont, Vector2(center.x-50, center.y+size+80), 'BPM:') draw_string_centered(TitleFont, Vector2(center.x+50, center.y+size+80), str(song_data.BPM)) @@ -278,7 +278,7 @@ func _draw_score_screen(center: Vector2) -> Array: var judgement_text_height = 64 * judgement_text_scale draw_songtile(song_key, Vector2(x_songtile-size/2.0, y), size, false, selected_difficulty, 3) - draw_string_centered(TitleFont, Vector2(x_songtile, y+size), Library.all_songs[song_key].title.n) + draw_string_centered(TitleFont, Vector2(x_songtile, y+size), str(Library.all_songs[song_key].title)) var notestrs = ['Taps (%d):'%meta.num_taps, 'Holds (%d) Hit:'%meta.num_holds, 'Released:', 'Stars (%d):'%meta.num_slides, 'Slides:'] var notetypes = [0, 1, -1, 2, -2] var note_spacing = [0.0, 1.25, 2.25, 3.5, 4.5] diff --git a/singletons/GameTheme.gd b/singletons/GameTheme.gd index 4a1c50d..ed5bfbf 100644 --- a/singletons/GameTheme.gd +++ b/singletons/GameTheme.gd @@ -145,6 +145,8 @@ const NORMAL_ARRAY_8 := PoolVector3Array([ DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL ]) +var display_language = 'n' + var screen_filter_min_alpha := 0.2 var screen_filter := Color(0.0, 0.0, 0.0, screen_filter_min_alpha) signal screen_filter_changed() diff --git a/singletons/Library.gd b/singletons/Library.gd index 6fa9dd9..32b7037 100644 --- a/singletons/Library.gd +++ b/singletons/Library.gd @@ -15,22 +15,18 @@ class MultilangStr: self.tl = translit if english and not english.empty(): self.en = english -# func get_native() -> String: -# return n -# func get_translit() -> String: -# return tl if tl else n -# func get_english() -> String: -# return en if en else self.tl func set_native(native) -> void: n = native if tl.empty(): - tl = native + set_translit(native) func set_translit(translit) -> void: tl = translit if en.empty(): - en = translit + set_english(translit) func set_english(english) -> void: en = english + func _to_string() -> String: + return self[GameTheme.display_language] class Song: var title: MultilangStr