Use rltk prelude import instead of full paths

This commit is contained in:
Timothy Warren 2022-02-03 15:16:41 -05:00
parent fd9f8e7463
commit 30de2cd7ce
31 changed files with 23 additions and 38 deletions

View File

@ -1,6 +1,6 @@
//! Color constants to replace more verbose methods of defining colors in the game. //! Color constants to replace more verbose methods of defining colors in the game.
//! These constants replace the `::rltk::RGB` constructor functions //! These constants replace the `::rltk::RGB` constructor functions
use ::rltk::RGB; use ::rltk::prelude::*;
const fn new(r: f32, g: f32, b: f32) -> RGB { const fn new(r: f32, g: f32, b: f32) -> RGB {
RGB { r, g, b } RGB { r, g, b }

View File

@ -5,7 +5,7 @@ mod tags;
use std::collections::HashMap; use std::collections::HashMap;
use ::rltk::{FontCharType, Point, RGB}; use ::rltk::prelude::*;
use ::serde::{Deserialize, Serialize}; use ::serde::{Deserialize, Serialize};
use ::specs::error::NoError; use ::specs::error::NoError;
use ::specs::prelude::*; use ::specs::prelude::*;

View File

@ -9,7 +9,7 @@ mod triggers;
use std::collections::{HashSet, VecDeque}; use std::collections::{HashSet, VecDeque};
use std::sync::Mutex; use std::sync::Mutex;
use ::rltk::{FontCharType, Point, RGB}; use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
pub use targeting::*; pub use targeting::*;

View File

@ -1,4 +1,4 @@
use ::rltk::Point; use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use super::{add_effect, EffectType, Targets}; use super::{add_effect, EffectType, Targets};
@ -349,8 +349,6 @@ fn event_trigger(
} }
fn spawn_line_particles(ecs: &World, start: i32, end: i32, part: &SpawnParticleLine) { fn spawn_line_particles(ecs: &World, start: i32, end: i32, part: &SpawnParticleLine) {
use ::rltk::LineAlg;
let map = ecs.fetch::<Map>(); let map = ecs.fetch::<Map>();
let start_pt = Point::new(start % map.width, end / map.width); let start_pt = Point::new(start % map.width, end / map.width);
let end_pt = Point::new(end % map.width, end / map.width); let end_pt = Point::new(end % map.width, end / map.width);

View File

@ -5,7 +5,7 @@ mod builder;
mod events; mod events;
mod logstore; mod logstore;
use ::rltk::RGB; use ::rltk::prelude::*;
use ::serde::{Deserialize, Serialize}; use ::serde::{Deserialize, Serialize};
pub use builder::*; pub use builder::*;
pub use events::*; pub use events::*;

View File

@ -1,5 +1,4 @@
use ::rltk::prelude::*; use ::rltk::prelude::*;
use ::rltk::{Rltk, VirtualKeyCode};
use super::{menu_box, menu_option}; use super::{menu_box, menu_option};
use crate::{colors, State}; use crate::{colors, State};

View File

@ -1,5 +1,4 @@
use ::rltk::prelude::*; use ::rltk::prelude::*;
use ::rltk::Rltk;
use ::specs::prelude::*; use ::specs::prelude::*;
use super::{get_item_display_name, item_result_menu, ItemMenuResult}; use super::{get_item_display_name, item_result_menu, ItemMenuResult};

View File

@ -1,7 +1,6 @@
use std::cmp::Ordering; use std::cmp::Ordering;
use ::rltk::prelude::*; use ::rltk::prelude::*;
use ::rltk::{Point, Rltk};
use ::specs::prelude::*; use ::specs::prelude::*;
use super::{draw_tooltips, get_item_color, get_item_display_name}; use super::{draw_tooltips, get_item_color, get_item_display_name};

View File

@ -1,5 +1,4 @@
use ::rltk::prelude::*; use ::rltk::prelude::*;
use ::rltk::Rltk;
use ::specs::prelude::*; use ::specs::prelude::*;
use super::{get_item_display_name, item_result_menu, ItemMenuResult}; use super::{get_item_display_name, item_result_menu, ItemMenuResult};

View File

@ -1,5 +1,4 @@
use ::rltk::prelude::*; use ::rltk::prelude::*;
use ::rltk::Rltk;
use ::specs::prelude::*; use ::specs::prelude::*;
use super::{get_item_display_name, item_result_menu, ItemMenuResult}; use super::{get_item_display_name, item_result_menu, ItemMenuResult};

View File

@ -1,4 +1,4 @@
use ::rltk::RGB; use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use crate::components::{Consumable, CursedItem, MagicItem, MagicItemClass, Name, ObfuscatedName}; use crate::components::{Consumable, CursedItem, MagicItem, MagicItemClass, Name, ObfuscatedName};

View File

@ -1,5 +1,4 @@
use ::rltk::prelude::*; use ::rltk::prelude::*;
use ::rltk::{DistanceAlg, Point, Rltk};
use ::specs::prelude::*; use ::specs::prelude::*;
use super::ItemMenuResult; use super::ItemMenuResult;

View File

@ -1,5 +1,4 @@
use ::rltk::prelude::*; use ::rltk::prelude::*;
use ::rltk::Rltk;
use ::specs::prelude::*; use ::specs::prelude::*;
use super::{get_item_display_name, item_result_menu, ItemMenuResult}; use super::{get_item_display_name, item_result_menu, ItemMenuResult};

View File

@ -1,5 +1,4 @@
use ::rltk::prelude::*; use ::rltk::prelude::*;
use ::rltk::Rltk;
use ::specs::prelude::*; use ::specs::prelude::*;
use super::{get_item_display_name, item_result_menu, ItemMenuResult}; use super::{get_item_display_name, item_result_menu, ItemMenuResult};

View File

@ -25,6 +25,7 @@ mod spawner;
mod state; mod state;
mod systems; mod systems;
use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator}; use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator};
use components::*; use components::*;
@ -154,7 +155,6 @@ fn register_components(state: &mut State) {
/// * Creates the [`Player`](crate::spawner::player) /// * Creates the [`Player`](crate::spawner::player)
/// * Generates the first [`map`](crate::state::State::generate_world_map) /// * Generates the first [`map`](crate::state::State::generate_world_map)
fn init_state() -> State { fn init_state() -> State {
use ::rltk::Point;
use systems::particle_system::ParticleBuilder; use systems::particle_system::ParticleBuilder;
let mut state = State::new(); let mut state = State::new();
@ -185,8 +185,6 @@ fn init_state() -> State {
/// The entry point /// The entry point
fn main() -> ::rltk::BError { fn main() -> ::rltk::BError {
use ::rltk::{main_loop, RltkBuilder};
let context = RltkBuilder::simple(80, 60) let context = RltkBuilder::simple(80, 60)
.unwrap() .unwrap()
.with_title("Roguelike Tutorial") .with_title("Roguelike Tutorial")

View File

@ -6,7 +6,7 @@ mod tiletype;
use std::collections::HashSet; use std::collections::HashSet;
use ::rltk::{Algorithm2D, BaseMap, Point, SmallVec, RGB}; use ::rltk::prelude::*;
use ::serde::{Deserialize, Serialize}; use ::serde::{Deserialize, Serialize};
pub use dungeon::*; pub use dungeon::*;
pub use themes::*; pub use themes::*;

View File

@ -1,6 +1,5 @@
//! Handle rendering of the viewport //! Handle rendering of the viewport
use ::rltk::prelude::*; use ::rltk::prelude::*;
use ::rltk::{Point, Rltk};
use ::specs::prelude::*; use ::specs::prelude::*;
use crate::components::{Hidden, Position, Renderable, Target, TileSize}; use crate::components::{Hidden, Position, Renderable, Target, TileSize};

View File

@ -1,5 +1,5 @@
//! Different looks for the same set of [`TileType`]s //! Different looks for the same set of [`TileType`]s
use ::rltk::{to_cp437, FontCharType, RGB}; use ::rltk::prelude::*;
use super::{Map, TileType}; use super::{Map, TileType};
use crate::colors; use crate::colors;

View File

@ -1,4 +1,4 @@
use ::rltk::{DistanceAlg, Point}; use ::rltk::prelude::*;
use super::{BuilderMap, MetaMapBuilder}; use super::{BuilderMap, MetaMapBuilder};
use crate::{map, TileType}; use crate::{map, TileType};

View File

@ -1,4 +1,4 @@
use ::rltk::{DistanceAlg, Point}; use ::rltk::prelude::*;
use super::{ use super::{
AreaEndingPosition, AreaStartingPosition, BspCorridors, BspDungeonBuilder, BuilderChain, AreaEndingPosition, AreaStartingPosition, BspCorridors, BspDungeonBuilder, BuilderChain,

View File

@ -1,6 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use ::rltk::{CellularDistanceFunction, FastNoise, NoiseType}; use ::rltk::prelude::*;
use crate::map_builders::{BuilderMap, MetaMapBuilder}; use crate::map_builders::{BuilderMap, MetaMapBuilder};
use crate::rng::roll_dice; use crate::rng::roll_dice;

View File

@ -1,8 +1,8 @@
//! Player-related functionality //! Player-related functionality
use std::cmp::{max, min}; use std::cmp::{max, min};
use rltk::{DistanceAlg, Point, Rltk, VirtualKeyCode}; use ::rltk::prelude::*;
use specs::prelude::*; use ::specs::prelude::*;
use crate::components::{ use crate::components::{
Attributes, BlocksTile, BlocksVisibility, Door, EntityMoved, Equipped, Faction, HungerClock, Attributes, BlocksTile, BlocksVisibility, Door, EntityMoved, Equipped, Faction, HungerClock,

View File

@ -11,7 +11,7 @@ mod weapon_traits;
use std::sync::Mutex; use std::sync::Mutex;
use ::rltk::{embedded_resource, link_resource}; use ::rltk::prelude::*;
use ::serde::Deserialize; use ::serde::Deserialize;
pub use faction_structs::*; pub use faction_structs::*;
use item_structs::*; use item_structs::*;

View File

@ -1,7 +1,7 @@
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use ::regex::Regex; use ::regex::Regex;
use ::rltk::{console, RGB}; use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use ::specs::saveload::{MarkedBuilder, SimpleMarker}; use ::specs::saveload::{MarkedBuilder, SimpleMarker};

View File

@ -1,5 +1,5 @@
use ::rltk::prelude::*;
use ::rltk::rex::XpFile; use ::rltk::rex::XpFile;
use ::rltk::{embedded_resource, link_resource};
embedded_resource!(SMALL_DUNGEON, "../resources/SmallDungeon_80x50.xp"); embedded_resource!(SMALL_DUNGEON, "../resources/SmallDungeon_80x50.xp");
embedded_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp"); embedded_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp");

View File

@ -1,5 +1,5 @@
//! Game state //! Game state
use ::rltk::{GameState, Point, Rltk}; use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use crate::components::*; use crate::components::*;

View File

@ -1,4 +1,4 @@
use ::rltk::a_star_search; use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use crate::components::{ApplyMove, MyTurn, Position, WantsToApproach}; use crate::components::{ApplyMove, MyTurn, Position, WantsToApproach};

View File

@ -1,5 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use crate::components::{ApplyMove, Chasing, MyTurn, Position, TileSize}; use crate::components::{ApplyMove, Chasing, MyTurn, Position, TileSize};
@ -20,8 +21,6 @@ impl<'a> System<'a> for ChaseAI {
); );
fn run(&mut self, data: Self::SystemData) { fn run(&mut self, data: Self::SystemData) {
use ::rltk::a_star_search;
let (mut turns, mut chasing, positions, map, entities, mut apply_move, sizes) = data; let (mut turns, mut chasing, positions, map, entities, mut apply_move, sizes) = data;
let mut targets: HashMap<Entity, (i32, i32)> = HashMap::new(); let mut targets: HashMap<Entity, (i32, i32)> = HashMap::new();

View File

@ -1,4 +1,4 @@
use ::rltk::DijkstraMap; use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use crate::components::{ApplyMove, MyTurn, Position, WantsToFlee}; use crate::components::{ApplyMove, MyTurn, Position, WantsToFlee};

View File

@ -1,6 +1,5 @@
use ::rltk::Point; use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use rltk::DistanceAlg;
use crate::components::{LightSource, Position, Viewshed}; use crate::components::{LightSource, Position, Viewshed};
use crate::{colors, Map}; use crate::{colors, Map};

View File

@ -1,4 +1,4 @@
use ::rltk::{Rltk, RGB}; use ::rltk::prelude::*;
use ::specs::prelude::*; use ::specs::prelude::*;
use crate::components::{ParticleLifetime, Position, Renderable}; use crate::components::{ParticleLifetime, Position, Renderable};