Skip to content

Commit

Permalink
update date when opening world menu panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Jul 16, 2024
1 parent e038fe0 commit 0116f4b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
25 changes: 13 additions & 12 deletions pets-gd/scenes/world.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ libraries = {
"": SubResource("AnimationLibrary_fv7du")
}

[node name="InteractionManager" parent="." instance=ExtResource("2_uh12s")]
unique_name_in_owner = true
visible = false

[node name="BattleLayer" type="CanvasLayer" parent="."]

[node name="YSort" type="Node2D" parent="."]
Expand All @@ -126,8 +122,21 @@ script = ExtResource("4_jple0")

[node name="Room" parent="YSort" instance=ExtResource("10_kug7e")]

[node name="InteractionManager" parent="." instance=ExtResource("2_uh12s")]
unique_name_in_owner = true

[node name="UILayer" type="CanvasLayer" parent="."]

[node name="Inventory" parent="UILayer" instance=ExtResource("3_jwkdy")]
unique_name_in_owner = true
visible = false

[node name="DialogBox" parent="UILayer" instance=ExtResource("2_lgtmm")]
offset_left = -704.0
offset_right = 704.0

[node name="WorldMenu" parent="UILayer" instance=ExtResource("2_6orff")]

[node name="BeaconFade" type="ColorRect" parent="UILayer"]
unique_name_in_owner = true
top_level = true
Expand All @@ -137,14 +146,6 @@ offset_bottom = 1080.0
color = Color(0, 0, 0, 1)
metadata/_edit_lock_ = true

[node name="Inventory" parent="UILayer" instance=ExtResource("3_jwkdy")]
unique_name_in_owner = true
visible = false

[node name="DialogBox" parent="UILayer" instance=ExtResource("2_lgtmm")]

[node name="WorldMenu" parent="UILayer" instance=ExtResource("2_6orff")]

[node name="Quests" type="Node" parent="."]
process_mode = 4

Expand Down
2 changes: 1 addition & 1 deletion pets-gd/scenes/world_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ offset_right = 328.0
offset_bottom = 128.0
theme_override_fonts/normal_font = ExtResource("2_iwgvb")
theme_override_font_sizes/normal_font_size = 90
text = "09/01/2037"
text = "Date"
fit_content = true
18 changes: 18 additions & 0 deletions pets-lib/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ use crate::prelude::*;
use godot::engine::{Engine, GDScript, SceneTreeTimer};
use godot::prelude::*;

pub fn month_string_3letter(month: u32) -> &'static str {
match month {
1 => "Jan",
2 => "Feb",
3 => "Mar",
4 => "Apr",
5 => "May",
6 => "Jun",
7 => "Jul",
8 => "Aug",
9 => "Sep",
10 => "Oct",
11 => "Nov",
12 => "Dec",
_ => panic!("Invalid month"),
}
}

// this is a macro so we can easily expand it and delete the definition
// when `gdext` adds new methods for allowing zero vectors
pub use crate::normalized;
Expand Down
9 changes: 8 additions & 1 deletion pets-lib/src/world/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ pub struct WorldMenu {
#[godot_api]
impl WorldMenu {
fn set_date_txt(&self, date: NaiveDate) {
let txt = date.to_string().replace("-", "/");
let txt = format!(
"{} {}, {}",
month_string_3letter(date.month()),
date.day(),
date.year()
);

self.base()
.get_node_as::<RichTextLabel>("%DatePanel/RichTextLabel")
Expand All @@ -37,6 +42,8 @@ impl WorldMenu {
}

fn open_or_close(&mut self, open: bool) {
self.set_date_txt(si().bind().save.date);

self.opened = open;

self.anim_player().play_animation_forwards("open", open);
Expand Down

0 comments on commit 0116f4b

Please sign in to comment.