Skip to content

Commit

Permalink
autotranslate bbcode stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Jan 18, 2025
1 parent c9e1dde commit 0faefe0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
4 changes: 4 additions & 0 deletions pets-gd/i18n/translations.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
keys,en_US,pr,tlh_US
MAINMENU_OPTION_PLAY,Play,Set Sail,Play
MAINMENU_OPTION_OPTIONS,Options,Fiddle 'round,Options
MAINMENU_OPTION_CREDITS,Credits,Th' Crew,Credits
MAINMENU_OPTION_QUIT,Quit,Avast!,Touch Grass
IZ_INTERACT_INTERACT,Interact,Interact,Interact
IZ_INTERACT_CHECK,Check,Peer,Critique
IZ_INTERACT_PRESS,Press,Push,Press
Expand Down
28 changes: 14 additions & 14 deletions pets-gd/scenes/title_screen.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ tracks/7/keys = {
"times": PackedFloat32Array(1.92, 3.2),
"transitions": PackedFloat32Array(0.307786, 1),
"update": 0,
"values": [Vector2(-400, 320), Vector2(64, 320)]
"values": [Vector2(-700, 320), Vector2(64, 320)]
}

[sub_resource type="Animation" id="Animation_m5j65"]
Expand Down Expand Up @@ -354,7 +354,7 @@ tracks/7/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(64, 320), Vector2(-2400, 320)]
"values": [Vector2(64, 320), Vector2(-3000, 320)]
}
tracks/8/type = "value"
tracks/8/imported = false
Expand Down Expand Up @@ -574,65 +574,65 @@ offset_bottom = 360.0
[node name="Play" type="RichTextLabel" parent="MoveRight/MenuChoices"]
clip_contents = false
layout_mode = 0
offset_right = 456.0
offset_right = 720.0
offset_bottom = 136.0
focus_neighbor_top = NodePath("../Quit")
focus_neighbor_bottom = NodePath("../Options")
focus_next = NodePath("../Options")
focus_previous = NodePath("../Quit")
focus_mode = 2
theme_override_colors/default_color = Color(0.803922, 0.839216, 0.956863, 1)
theme_override_font_sizes/normal_font_size = 80
theme_override_font_sizes/normal_font_size = 68
bbcode_enabled = true
text = "Play"
text = "MAINMENU_OPTION_PLAY"

[node name="Options" type="RichTextLabel" parent="MoveRight/MenuChoices"]
clip_contents = false
layout_mode = 0
offset_top = 128.0
offset_right = 456.0
offset_right = 720.0
offset_bottom = 264.0
focus_neighbor_top = NodePath("../Play")
focus_neighbor_bottom = NodePath("../Credits")
focus_next = NodePath("../Credits")
focus_previous = NodePath("../Play")
focus_mode = 2
theme_override_colors/default_color = Color(0.803922, 0.839216, 0.956863, 1)
theme_override_font_sizes/normal_font_size = 80
theme_override_font_sizes/normal_font_size = 68
bbcode_enabled = true
text = "Options"
text = "MAINMENU_OPTION_OPTIONS"

[node name="Credits" type="RichTextLabel" parent="MoveRight/MenuChoices"]
clip_contents = false
layout_mode = 0
offset_top = 256.0
offset_right = 456.0
offset_right = 720.0
offset_bottom = 392.0
focus_neighbor_top = NodePath("../Options")
focus_neighbor_bottom = NodePath("../Quit")
focus_next = NodePath("../Quit")
focus_previous = NodePath("../Options")
focus_mode = 2
theme_override_colors/default_color = Color(0.803922, 0.839216, 0.956863, 1)
theme_override_font_sizes/normal_font_size = 80
theme_override_font_sizes/normal_font_size = 68
bbcode_enabled = true
text = "Credits"
text = "MAINMENU_OPTION_CREDITS"

[node name="Quit" type="RichTextLabel" parent="MoveRight/MenuChoices"]
clip_contents = false
layout_mode = 0
offset_top = 384.0
offset_right = 456.0
offset_right = 720.0
offset_bottom = 520.0
focus_neighbor_top = NodePath("../Credits")
focus_neighbor_bottom = NodePath("../Play")
focus_next = NodePath("../Play")
focus_previous = NodePath("../Credits")
focus_mode = 2
theme_override_colors/default_color = Color(0.803922, 0.839216, 0.956863, 1)
theme_override_font_sizes/normal_font_size = 80
theme_override_font_sizes/normal_font_size = 68
bbcode_enabled = true
text = "Quit"
text = "MAINMENU_OPTION_QUIT"

[node name="BlackFade" type="ColorRect" parent="MoveRight"]
unique_name_in_owner = true
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/util/choices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl ChoiceAgent {
)
.unwrap();

bbcode_toggle(label, CHOICE_WAVE_BBCODE, is_picked);
bbcode_toggle(label, CHOICE_WAVE_BBCODE, is_picked, true);
}

if !self.tween_property.is_empty() {
Expand Down
15 changes: 12 additions & 3 deletions pets-lib/src/util/node_stuff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,18 @@ pub fn si() -> Gd<StatsInterface> {
pub struct GdW<T: GodotClass>(pub Gd<T>);

/// takes a bbcode string and prepends or removes it from the label text
pub fn bbcode_toggle(mut node: Gd<RichTextLabel>, bbcode: &str, active: bool) {
let old_text = node.get_text().to_string();
let new_text = prefix_mod(&old_text, bbcode, active);
pub fn bbcode_toggle(
mut node: Gd<RichTextLabel>,
bbcode: &str,
active: bool,
autotranslate: bool,
) {
let mut old_text = node.get_text();
if autotranslate {
old_text = tr(old_text.arg());
}

let new_text = prefix_mod(old_text.to_string().as_str(), bbcode, active);

node.set_text(&new_text);
}
Expand Down

0 comments on commit 0faefe0

Please sign in to comment.