From 33fa5e87bfa7d68c77782072044ec440ae1693ab Mon Sep 17 00:00:00 2001 From: Cherry Date: Sun, 18 Aug 2024 21:49:55 -0400 Subject: [PATCH] prelude cleanup + renamed to `common` since it's not actually public outside the crate --- pets-lib/src/battle/affinities.rs | 2 +- pets-lib/src/battle/midi/mod.rs | 3 +-- pets-lib/src/battle/mod.rs | 6 +++--- pets-lib/src/battle/player.rs | 2 +- pets-lib/src/battle/rhythm.rs | 4 ++-- pets-lib/src/battle/skills/mod.rs | 2 +- pets-lib/src/battle/skills/registry.rs | 2 +- pets-lib/src/battle/stat_translation.rs | 2 +- pets-lib/src/dialogue/dbox/dchoice.rs | 2 +- pets-lib/src/dialogue/dbox/mod.rs | 2 +- pets-lib/src/dialogue/dbox/placeholders.rs | 2 +- pets-lib/src/functions.rs | 2 +- pets-lib/src/items/mod.rs | 2 +- pets-lib/src/lib.rs | 17 ++++++++--------- pets-lib/src/stats/autoload.rs | 2 +- pets-lib/src/stats/charmap.rs | 2 +- pets-lib/src/stats/mod.rs | 2 +- pets-lib/src/stats/pchars.rs | 2 +- pets-lib/src/stats/quests.rs | 2 +- pets-lib/src/stats/savefiles.rs | 2 +- pets-lib/src/stats/scrapbook/mod.rs | 2 +- pets-lib/src/stats/statcalc.rs | 2 +- pets-lib/src/title_screen.rs | 2 +- pets-lib/src/util/choices.rs | 2 +- pets-lib/src/util/limiq.rs | 2 +- pets-lib/src/util/node_stuff.rs | 2 +- pets-lib/src/util/registry.rs | 4 ++-- pets-lib/src/world/enemy_node.rs | 2 +- pets-lib/src/world/interaction/manager.rs | 2 +- pets-lib/src/world/interaction/zone.rs | 2 +- pets-lib/src/world/inv_node.rs | 2 +- pets-lib/src/world/menu.rs | 2 +- pets-lib/src/world/mod.rs | 2 +- pets-lib/src/world/pchar_node.rs | 2 +- pets-lib/src/world/playercb.rs | 2 +- 35 files changed, 46 insertions(+), 48 deletions(-) diff --git a/pets-lib/src/battle/affinities.rs b/pets-lib/src/battle/affinities.rs index aa0a052b..2e81245b 100644 --- a/pets-lib/src/battle/affinities.rs +++ b/pets-lib/src/battle/affinities.rs @@ -1,5 +1,5 @@ use super::skills::Element; -use crate::prelude::*; +use crate::common::*; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub enum AffinityPower { diff --git a/pets-lib/src/battle/midi/mod.rs b/pets-lib/src/battle/midi/mod.rs index 2cb7fe6d..2226b711 100644 --- a/pets-lib/src/battle/midi/mod.rs +++ b/pets-lib/src/battle/midi/mod.rs @@ -4,12 +4,11 @@ //! game-related code. //! -use crate::prelude::*; +use crate::common::*; mod accurate_timer; use accurate_timer::AccurateTimer; -use ribbons::unwrap_fmt; use std::io::Read; use godot::classes::file_access::ModeFlags; diff --git a/pets-lib/src/battle/mod.rs b/pets-lib/src/battle/mod.rs index 3d96e363..2d724005 100644 --- a/pets-lib/src/battle/mod.rs +++ b/pets-lib/src/battle/mod.rs @@ -12,8 +12,8 @@ use godot::classes::{ use godot::prelude::*; use skills::SKILL_REGISTRY; +use crate::common::*; use crate::consts::battle::*; -use crate::prelude::*; mod affinities; mod midi; @@ -254,7 +254,7 @@ impl BattleEngine { #[func] pub fn cast_skill(&mut self, skill_id: String) { godot_print!("Casting skill: {}", skill_id); - let skill = ribbons::unwrap_fmt!( + let skill = unwrap_fmt!( SKILL_REGISTRY.get().unwrap().get(&skill_id), "skill not found: {skill_id}", ); @@ -269,7 +269,7 @@ impl BattleEngine { #[func] pub fn describe_skill(&self, skill_id: String) -> String { - let skill = ribbons::unwrap_fmt!( + let skill = unwrap_fmt!( SKILL_REGISTRY.get().unwrap().get(&skill_id), "skill not found: {skill_id}", ); diff --git a/pets-lib/src/battle/player.rs b/pets-lib/src/battle/player.rs index 0e93df9a..bc2e3370 100644 --- a/pets-lib/src/battle/player.rs +++ b/pets-lib/src/battle/player.rs @@ -8,7 +8,7 @@ use godot::classes::{CharacterBody2D, ICharacterBody2D, Sprite2D}; use godot::prelude::*; use super::stat_translation; -use crate::prelude::*; +use crate::common::*; const BATTLE_DIRECTIONS: LazyCell<[(StringName, Vector2); 4]> = LazyCell::new(|| { diff --git a/pets-lib/src/battle/rhythm.rs b/pets-lib/src/battle/rhythm.rs index 4f6f2bd8..cace6295 100644 --- a/pets-lib/src/battle/rhythm.rs +++ b/pets-lib/src/battle/rhythm.rs @@ -7,7 +7,7 @@ use godot::prelude::*; use super::midi::{BattleTrack, MidiReceiver}; use super::AttackFlopReason; -use crate::prelude::*; +use crate::common::*; /// How long before/after a beat to still consider clicks valid const LENIENCY_PRE: f64 = 0.08; @@ -29,7 +29,7 @@ impl NoteType { /// Panics if the note is invalid, for ergonomics. /// Use `try_from_note` if you want to handle the error. pub fn from_note(note: u8) -> Self { - ribbons::unwrap_fmt!( + unwrap_fmt!( Self::try_from_note(note), "invalid midi note with code {}", note diff --git a/pets-lib/src/battle/skills/mod.rs b/pets-lib/src/battle/skills/mod.rs index df229fc9..5cb5b1e5 100644 --- a/pets-lib/src/battle/skills/mod.rs +++ b/pets-lib/src/battle/skills/mod.rs @@ -1,5 +1,5 @@ +use crate::common::*; use crate::consts::battle::*; -use crate::prelude::*; use std::fmt; diff --git a/pets-lib/src/battle/skills/registry.rs b/pets-lib/src/battle/skills/registry.rs index ce8e9e8c..fd1edcd9 100644 --- a/pets-lib/src/battle/skills/registry.rs +++ b/pets-lib/src/battle/skills/registry.rs @@ -1,5 +1,5 @@ use super::*; -use crate::prelude::*; +use crate::common::*; use crate::util::registry::*; use std::io::Read as _; diff --git a/pets-lib/src/battle/stat_translation.rs b/pets-lib/src/battle/stat_translation.rs index cdb5682b..eb9652da 100644 --- a/pets-lib/src/battle/stat_translation.rs +++ b/pets-lib/src/battle/stat_translation.rs @@ -4,7 +4,7 @@ //! to the battle engine. //! -use crate::prelude::*; +use crate::common::*; const SPEED_STAT_MULTIPLIER: FloatStat = 800.0; pub fn speed(speed: IntegralStat) -> FloatStat { diff --git a/pets-lib/src/dialogue/dbox/dchoice.rs b/pets-lib/src/dialogue/dbox/dchoice.rs index a86d0cd0..b853482f 100644 --- a/pets-lib/src/dialogue/dbox/dchoice.rs +++ b/pets-lib/src/dialogue/dbox/dchoice.rs @@ -10,8 +10,8 @@ use godot::classes::notify::ContainerNotification; use godot::classes::{IMarginContainer, MarginContainer, RichTextLabel, Tween}; use godot::prelude::*; +use crate::common::*; use crate::consts::dialogue::*; -use crate::prelude::*; #[derive(GodotClass)] #[class(init, base=MarginContainer)] diff --git a/pets-lib/src/dialogue/dbox/mod.rs b/pets-lib/src/dialogue/dbox/mod.rs index a7757bbc..5efe79c1 100644 --- a/pets-lib/src/dialogue/dbox/mod.rs +++ b/pets-lib/src/dialogue/dbox/mod.rs @@ -8,8 +8,8 @@ use godot::classes::{ }; use godot::prelude::*; +use crate::common::*; use crate::consts::dialogue::*; -use crate::prelude::*; mod dchoice; mod placeholders; diff --git a/pets-lib/src/dialogue/dbox/placeholders.rs b/pets-lib/src/dialogue/dbox/placeholders.rs index bbc4a5a2..d14ebfe5 100644 --- a/pets-lib/src/dialogue/dbox/placeholders.rs +++ b/pets-lib/src/dialogue/dbox/placeholders.rs @@ -2,7 +2,7 @@ //! This module is for processing placeholders in dialogue strings. //! -use crate::prelude::*; +use crate::common::*; pub fn party_leader() -> PChar { *pcb().bind().party_pchars().first().unwrap() diff --git a/pets-lib/src/functions.rs b/pets-lib/src/functions.rs index 667722a8..7791b5e7 100644 --- a/pets-lib/src/functions.rs +++ b/pets-lib/src/functions.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use crate::common::*; use godot::classes::{GDScript, Sprite2D, Texture2D}; use godot::prelude::*; diff --git a/pets-lib/src/items/mod.rs b/pets-lib/src/items/mod.rs index 68d4fa6b..0ca861dd 100644 --- a/pets-lib/src/items/mod.rs +++ b/pets-lib/src/items/mod.rs @@ -3,7 +3,7 @@ //! For inventory-related types, check out `inv.rs` //! -use crate::prelude::*; +use crate::common::*; use crate::util::registry::*; use std::sync::OnceLock; diff --git a/pets-lib/src/lib.rs b/pets-lib/src/lib.rs index 5af85796..ec0a6830 100644 --- a/pets-lib/src/lib.rs +++ b/pets-lib/src/lib.rs @@ -17,7 +17,7 @@ use godot::prelude::*; -use prelude::*; +use common::*; mod consts; mod util; @@ -31,8 +31,7 @@ mod title_screen; mod world; // mod llm; -#[allow(unused)] -mod prelude { +mod common { pub use crate::consts::type_aliases::*; pub use crate::items::*; @@ -40,10 +39,10 @@ mod prelude { pub use crate::stats::*; pub use crate::util::*; - pub use crate::battle::{Affinities, AffinityPower, BattleEngine}; + pub use crate::battle::{Affinities, BattleEngine}; pub use crate::dialogue::DialogBox; pub use crate::world::{ - InteractionManager, InteractionZone, PlayerCB, World, WorldMenu, + InteractionManager, InteractionZone, PlayerCB, World, }; pub use crate::choices::ChoiceAgent; @@ -54,19 +53,19 @@ mod prelude { // is this bad practice? no clue and idc honestly // it's convenient with no real caveat, therefore... - pub use anyhow::{anyhow, Result}; + pub use anyhow::Result; pub use chrono::{Datelike, NaiveDate}; pub use derived_deref::{Deref, DerefMut}; - pub use indoc::indoc; - pub use rand::Rng; + // pub use indoc::indoc; pub use ribbons::unwrap_fmt; + // pub use rand::Rng; pub use serde::de::DeserializeOwned; pub use serde::{Deserialize, Serialize}; pub use std::cell::RefCell; pub use std::collections::{HashMap, HashSet}; pub use std::fmt::{self, Debug, Display}; - pub use std::path::{Path, PathBuf}; + // pub use std::path::{Path, PathBuf}; pub use std::rc::Rc; pub use std::{io, thread}; } diff --git a/pets-lib/src/stats/autoload.rs b/pets-lib/src/stats/autoload.rs index ade4de1c..e2dace05 100644 --- a/pets-lib/src/stats/autoload.rs +++ b/pets-lib/src/stats/autoload.rs @@ -6,7 +6,7 @@ use godot::global::randomize; use godot::prelude::*; use crate::battle::skills::load_skill_registry; -use crate::prelude::*; +use crate::common::*; #[derive(GodotClass)] #[class(base=Object)] diff --git a/pets-lib/src/stats/charmap.rs b/pets-lib/src/stats/charmap.rs index 8ac621b1..e576591f 100644 --- a/pets-lib/src/stats/charmap.rs +++ b/pets-lib/src/stats/charmap.rs @@ -2,7 +2,7 @@ use godot::classes::file_access::ModeFlags; use godot::prelude::*; use io::Read as _; -use crate::prelude::*; +use crate::common::*; const CHARMAP_PATH: &str = "res://assets/charmap.json"; diff --git a/pets-lib/src/stats/mod.rs b/pets-lib/src/stats/mod.rs index 55e0b7b0..c5b158c8 100644 --- a/pets-lib/src/stats/mod.rs +++ b/pets-lib/src/stats/mod.rs @@ -2,7 +2,7 @@ //! This module is for character/enemy stat type definitions //! -use crate::prelude::*; +use crate::common::*; // stat-related submodules mod autoload; diff --git a/pets-lib/src/stats/pchars.rs b/pets-lib/src/stats/pchars.rs index e404da73..81bd93ed 100644 --- a/pets-lib/src/stats/pchars.rs +++ b/pets-lib/src/stats/pchars.rs @@ -6,7 +6,7 @@ //! the old code, and I'm already used to calling them that. //! tl;dr get used to it. -use crate::prelude::*; +use crate::common::*; use godot::prelude::*; use strum::EnumIter; diff --git a/pets-lib/src/stats/quests.rs b/pets-lib/src/stats/quests.rs index f833080f..0baa5abd 100644 --- a/pets-lib/src/stats/quests.rs +++ b/pets-lib/src/stats/quests.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use crate::common::*; use godot::prelude::*; pub type QuestPhase = i32; diff --git a/pets-lib/src/stats/savefiles.rs b/pets-lib/src/stats/savefiles.rs index 5e368160..fb39902e 100644 --- a/pets-lib/src/stats/savefiles.rs +++ b/pets-lib/src/stats/savefiles.rs @@ -9,7 +9,7 @@ use godot::prelude::*; use super::charmap::default_charmap; use super::scrapbook::Scrapbook; -use crate::prelude::*; +use crate::common::*; fn save_path(slot: u8) -> String { format!("user://save{}.json", slot) diff --git a/pets-lib/src/stats/scrapbook/mod.rs b/pets-lib/src/stats/scrapbook/mod.rs index 2d7ad065..c955e2db 100644 --- a/pets-lib/src/stats/scrapbook/mod.rs +++ b/pets-lib/src/stats/scrapbook/mod.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use crate::common::*; use std::collections::{HashMap, HashSet}; diff --git a/pets-lib/src/stats/statcalc.rs b/pets-lib/src/stats/statcalc.rs index 507b8a60..9032dc87 100644 --- a/pets-lib/src/stats/statcalc.rs +++ b/pets-lib/src/stats/statcalc.rs @@ -4,7 +4,7 @@ // For all these functions, the doc comment is the // mathematical function. The variable `x` represents // the variable `lvl` in our code. -use crate::prelude::*; +use crate::common::*; pub fn level_to_stats(lvl: IntegralStat) -> InherentStats { InherentStats { diff --git a/pets-lib/src/title_screen.rs b/pets-lib/src/title_screen.rs index bb82b0ef..17a8c22a 100644 --- a/pets-lib/src/title_screen.rs +++ b/pets-lib/src/title_screen.rs @@ -13,7 +13,7 @@ use godot::classes::{ use godot::obj::WithBaseField; use godot::prelude::*; -use crate::prelude::*; +use crate::common::*; const CREDITS_TWEEN_TIME: f64 = 0.5; const BLACK_FADE_TIME: f64 = 1.0; diff --git a/pets-lib/src/util/choices.rs b/pets-lib/src/util/choices.rs index c355c37e..4ef435a3 100644 --- a/pets-lib/src/util/choices.rs +++ b/pets-lib/src/util/choices.rs @@ -3,8 +3,8 @@ //! lists of stuff //! +use crate::common::*; use crate::consts::choice_lists::*; -use crate::prelude::*; use godot::classes::control::FocusMode; use godot::classes::{Control, InputEvent, RichTextLabel}; diff --git a/pets-lib/src/util/limiq.rs b/pets-lib/src/util/limiq.rs index 8286eb69..03be6d26 100644 --- a/pets-lib/src/util/limiq.rs +++ b/pets-lib/src/util/limiq.rs @@ -2,7 +2,7 @@ //! Limited Queue stuff //! -use crate::prelude::*; +use crate::common::*; use std::collections::VecDeque; /// "Limited Queue" diff --git a/pets-lib/src/util/node_stuff.rs b/pets-lib/src/util/node_stuff.rs index 7a17a2b6..08d82e00 100644 --- a/pets-lib/src/util/node_stuff.rs +++ b/pets-lib/src/util/node_stuff.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use crate::common::*; use derived_deref::{Deref, DerefMut}; use godot::classes::object::ConnectFlags; diff --git a/pets-lib/src/util/registry.rs b/pets-lib/src/util/registry.rs index 08344031..94515727 100644 --- a/pets-lib/src/util/registry.rs +++ b/pets-lib/src/util/registry.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use crate::common::*; use std::collections::HashMap; use godot::classes::file_access::ModeFlags; @@ -23,7 +23,7 @@ where } let content = String::from_utf8(content).ok()?; - let res: Registry = ribbons::unwrap_fmt!( + let res: Registry = unwrap_fmt!( serde_json::from_str(&content), "skills file {} has wrong JSON contents", path diff --git a/pets-lib/src/world/enemy_node.rs b/pets-lib/src/world/enemy_node.rs index 1860bb78..c4f5cc17 100644 --- a/pets-lib/src/world/enemy_node.rs +++ b/pets-lib/src/world/enemy_node.rs @@ -3,7 +3,7 @@ use godot::classes::{ }; use godot::prelude::*; -use crate::prelude::*; +use crate::common::*; #[derive(Clone, Copy, Debug, Default, PartialEq)] struct AnimOptions { diff --git a/pets-lib/src/world/interaction/manager.rs b/pets-lib/src/world/interaction/manager.rs index 10e54e6c..66da9508 100644 --- a/pets-lib/src/world/interaction/manager.rs +++ b/pets-lib/src/world/interaction/manager.rs @@ -6,8 +6,8 @@ use godot::classes::{Control, InputEvent, RichTextLabel}; use godot::prelude::*; +use crate::common::*; use crate::consts::dialogue::INTERACT_PROMPT_HEIGHT_OFFSET; -use crate::prelude::*; #[derive(GodotClass)] #[class(init, base=Node2D)] diff --git a/pets-lib/src/world/interaction/zone.rs b/pets-lib/src/world/interaction/zone.rs index cc4a527e..ffebc772 100644 --- a/pets-lib/src/world/interaction/zone.rs +++ b/pets-lib/src/world/interaction/zone.rs @@ -6,9 +6,9 @@ use godot::classes::{Area2D, ColorRect, GDScript, IArea2D}; use godot::prelude::*; +use crate::common::*; use crate::consts::playercb::*; use crate::functions::DialogueScriptBase; -use crate::prelude::*; #[derive(GodotClass)] #[class(init, base=Area2D)] diff --git a/pets-lib/src/world/inv_node.rs b/pets-lib/src/world/inv_node.rs index 8ba8819e..6bda254a 100644 --- a/pets-lib/src/world/inv_node.rs +++ b/pets-lib/src/world/inv_node.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use crate::common::*; use godot::classes::object::ConnectFlags; use godot::classes::{ AnimationPlayer, BoxContainer, Control, HBoxContainer, IControl, diff --git a/pets-lib/src/world/menu.rs b/pets-lib/src/world/menu.rs index 30cd2344..c95890ea 100644 --- a/pets-lib/src/world/menu.rs +++ b/pets-lib/src/world/menu.rs @@ -9,8 +9,8 @@ use godot::classes::{ }; use godot::prelude::*; +use crate::common::*; use crate::functions::DialogueScriptBase; -use crate::prelude::*; use super::inv_node::InventoryNode; diff --git a/pets-lib/src/world/mod.rs b/pets-lib/src/world/mod.rs index 8b2ace10..7dc1c63f 100644 --- a/pets-lib/src/world/mod.rs +++ b/pets-lib/src/world/mod.rs @@ -2,8 +2,8 @@ //! Overworld Stuff //! +use crate::common::*; use crate::consts::battle::*; -use crate::prelude::*; use enemy_node::WalkingEnemy; use godot::classes::{AnimationPlayer, AudioServer, AudioStream, CanvasLayer}; diff --git a/pets-lib/src/world/pchar_node.rs b/pets-lib/src/world/pchar_node.rs index a5a3a420..6e0392ee 100644 --- a/pets-lib/src/world/pchar_node.rs +++ b/pets-lib/src/world/pchar_node.rs @@ -4,7 +4,7 @@ use godot::classes::{ }; use godot::prelude::*; -use crate::prelude::*; +use crate::common::*; #[derive(GodotClass)] #[class(init, base=Node2D)] diff --git a/pets-lib/src/world/playercb.rs b/pets-lib/src/world/playercb.rs index 78d50f87..069ac85f 100644 --- a/pets-lib/src/world/playercb.rs +++ b/pets-lib/src/world/playercb.rs @@ -5,8 +5,8 @@ use godot::classes::{ }; use godot::prelude::*; +use crate::common::*; use crate::consts::playercb::*; -use crate::prelude::*; use super::inv_node::InventoryNode; use super::pchar_node::PCharNode;