Skip to content

Commit

Permalink
prelude cleanup + renamed to common since it's not actually public …
Browse files Browse the repository at this point in the history
…outside the crate
  • Loading branch information
Lamby777 committed Aug 19, 2024
1 parent 01f6ee6 commit 33fa5e8
Show file tree
Hide file tree
Showing 35 changed files with 46 additions and 48 deletions.
2 changes: 1 addition & 1 deletion pets-lib/src/battle/affinities.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::skills::Element;
use crate::prelude::*;
use crate::common::*;

#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum AffinityPower {
Expand Down
3 changes: 1 addition & 2 deletions pets-lib/src/battle/midi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions pets-lib/src/battle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}",
);
Expand All @@ -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}",
);
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/battle/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|| {
Expand Down
4 changes: 2 additions & 2 deletions pets-lib/src/battle/rhythm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/battle/skills/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::common::*;
use crate::consts::battle::*;
use crate::prelude::*;

use std::fmt;

Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/battle/skills/registry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::prelude::*;
use crate::common::*;
use crate::util::registry::*;

use std::io::Read as _;
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/battle/stat_translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/dialogue/dbox/dchoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/dialogue/dbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use godot::classes::{
};
use godot::prelude::*;

use crate::common::*;
use crate::consts::dialogue::*;
use crate::prelude::*;

mod dchoice;
mod placeholders;
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/dialogue/dbox/placeholders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/functions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use crate::common::*;
use godot::classes::{GDScript, Sprite2D, Texture2D};
use godot::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/items/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 8 additions & 9 deletions pets-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use godot::prelude::*;

use prelude::*;
use common::*;

mod consts;
mod util;
Expand All @@ -31,19 +31,18 @@ mod title_screen;
mod world;
// mod llm;

#[allow(unused)]
mod prelude {
mod common {
pub use crate::consts::type_aliases::*;

pub use crate::items::*;
pub use crate::limiq::*;
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;
Expand All @@ -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};
}
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/stats/autoload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/stats/charmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/stats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! This module is for character/enemy stat type definitions
//!
use crate::prelude::*;
use crate::common::*;

// stat-related submodules
mod autoload;
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/stats/pchars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/stats/quests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use crate::common::*;
use godot::prelude::*;

pub type QuestPhase = i32;
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/stats/savefiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/stats/scrapbook/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use crate::common::*;

use std::collections::{HashMap, HashSet};

Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/stats/statcalc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/title_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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 @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/util/limiq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! Limited Queue stuff
//!
use crate::prelude::*;
use crate::common::*;
use std::collections::VecDeque;

/// "Limited Queue"
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/util/node_stuff.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use crate::common::*;

use derived_deref::{Deref, DerefMut};
use godot::classes::object::ConnectFlags;
Expand Down
4 changes: 2 additions & 2 deletions pets-lib/src/util/registry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use crate::common::*;
use std::collections::HashMap;

use godot::classes::file_access::ModeFlags;
Expand All @@ -23,7 +23,7 @@ where
}

let content = String::from_utf8(content).ok()?;
let res: Registry<T> = ribbons::unwrap_fmt!(
let res: Registry<T> = unwrap_fmt!(
serde_json::from_str(&content),
"skills file {} has wrong JSON contents",
path
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/world/enemy_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use godot::classes::{
};
use godot::prelude::*;

use crate::prelude::*;
use crate::common::*;

#[derive(Clone, Copy, Debug, Default, PartialEq)]
struct AnimOptions {
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/world/interaction/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/world/interaction/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/world/inv_node.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use crate::common::*;
use godot::classes::object::ConnectFlags;
use godot::classes::{
AnimationPlayer, BoxContainer, Control, HBoxContainer, IControl,
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/world/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/world/pchar_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use godot::classes::{
};
use godot::prelude::*;

use crate::prelude::*;
use crate::common::*;

#[derive(GodotClass)]
#[class(init, base=Node2D)]
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/world/playercb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 33fa5e8

Please sign in to comment.