Merge branch 'master' into switching_to_draw_batches
This commit is contained in:
commit
441b22439f
119 changed files with 1851 additions and 3612 deletions
|
|
@ -24,7 +24,7 @@ use crate::{
|
|||
Telepath,
|
||||
BUC,
|
||||
};
|
||||
use rltk::prelude::*;
|
||||
use bracket_lib::prelude::*;
|
||||
use serde::{ Deserialize, Serialize };
|
||||
use specs::prelude::*;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -119,7 +119,7 @@ pub fn character_creation(gs: &mut State, ctx: &mut Rltk) -> CharCreateResult {
|
|||
let mut y = 11;
|
||||
let column_width = 20;
|
||||
|
||||
ctx.print_color(x, y, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK), CHAR_CREATE_HEADER);
|
||||
ctx.print_color(x, y, RGB::named(WHITE), RGB::named(BLACK), CHAR_CREATE_HEADER);
|
||||
y += 2;
|
||||
|
||||
if let RunState::CharacterCreation { ancestry, class } = *runstate {
|
||||
|
|
@ -271,9 +271,9 @@ pub fn setup_player_ancestry(ecs: &mut World, ancestry: Ancestry) {
|
|||
Ancestry::Dwarf => {
|
||||
renderables
|
||||
.insert(*player, Renderable {
|
||||
glyph: rltk::to_cp437(DWARF_GLYPH),
|
||||
glyph: to_cp437(DWARF_GLYPH),
|
||||
fg: RGB::named(DWARF_COLOUR),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
bg: RGB::named(BLACK),
|
||||
render_order: 0,
|
||||
})
|
||||
.expect("Unable to insert renderable component");
|
||||
|
|
@ -282,9 +282,9 @@ pub fn setup_player_ancestry(ecs: &mut World, ancestry: Ancestry) {
|
|||
Ancestry::Elf => {
|
||||
renderables
|
||||
.insert(*player, Renderable {
|
||||
glyph: rltk::to_cp437(ELF_GLYPH),
|
||||
glyph: to_cp437(ELF_GLYPH),
|
||||
fg: RGB::named(ELF_COLOUR),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
bg: RGB::named(BLACK),
|
||||
render_order: 0,
|
||||
})
|
||||
.expect("Unable to insert renderable component");
|
||||
|
|
@ -307,9 +307,9 @@ pub fn setup_player_ancestry(ecs: &mut World, ancestry: Ancestry) {
|
|||
Ancestry::Catfolk => {
|
||||
renderables
|
||||
.insert(*player, Renderable {
|
||||
glyph: rltk::to_cp437(CATFOLK_GLYPH),
|
||||
glyph: to_cp437(CATFOLK_GLYPH),
|
||||
fg: RGB::named(CATFOLK_COLOUR),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
bg: RGB::named(BLACK),
|
||||
render_order: 0,
|
||||
})
|
||||
.expect("Unable to insert renderable component");
|
||||
|
|
@ -453,11 +453,11 @@ fn pick_random_table_item(
|
|||
rng: &mut RandomNumberGenerator,
|
||||
push_to: &mut Vec<String>,
|
||||
table: &'static str,
|
||||
dice: &'static str,
|
||||
dice_str: &'static str,
|
||||
difficulty: Option<i32>
|
||||
) {
|
||||
let (n, d, m) = raws::parse_dice_string(dice);
|
||||
for _i in 0..rng.roll_dice(n, d) + m {
|
||||
let dice = parse_dice_string(dice_str).expect("Error parsing dice");
|
||||
for _i in 0..rng.roll_dice(dice.n_dice, dice.die_type) + dice.bonus {
|
||||
push_to.push(raws::table_by_name(&raws::RAWS.lock().unwrap(), table, difficulty).roll(rng));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use super::State;
|
||||
use rltk::prelude::*;
|
||||
use bracket_lib::prelude::*;
|
||||
|
||||
#[derive(PartialEq, Copy, Clone)]
|
||||
pub enum CheatMenuResult {
|
||||
|
|
@ -12,13 +12,13 @@ pub enum CheatMenuResult {
|
|||
GodMode,
|
||||
}
|
||||
|
||||
pub fn show_cheat_menu(_gs: &mut State, ctx: &mut Rltk) -> CheatMenuResult {
|
||||
pub fn show_cheat_menu(_gs: &mut State, ctx: &mut BTerm) -> CheatMenuResult {
|
||||
let (x_offset, y_offset) = (1, 10);
|
||||
ctx.print_color(
|
||||
1 + x_offset,
|
||||
1 + y_offset,
|
||||
RGB::named(rltk::RED),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(RED),
|
||||
RGB::named(BLACK),
|
||||
"DEBUG MENU! [aA-zZ][Esc.]"
|
||||
);
|
||||
let x = 1 + x_offset;
|
||||
|
|
@ -26,26 +26,26 @@ pub fn show_cheat_menu(_gs: &mut State, ctx: &mut Rltk) -> CheatMenuResult {
|
|||
let count = 5;
|
||||
let width = 19;
|
||||
|
||||
ctx.draw_box(x, y, width, (count + 1) as i32, RGB::named(rltk::RED), RGB::named(rltk::BLACK));
|
||||
ctx.draw_box(x, y, width, (count + 1) as i32, RGB::named(RED), RGB::named(BLACK));
|
||||
y += 1;
|
||||
// Asc
|
||||
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('a'));
|
||||
ctx.set(x_offset + 2, y, RGB::named(YELLOW), RGB::named(BLACK), to_cp437('a'));
|
||||
ctx.print(x_offset + 4, y, "ASCEND A FLOOR");
|
||||
y += 1;
|
||||
// Desc
|
||||
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('d'));
|
||||
ctx.set(x_offset + 2, y, RGB::named(YELLOW), RGB::named(BLACK), to_cp437('d'));
|
||||
ctx.print(x_offset + 4, y, "DESCEND A FLOOR");
|
||||
y += 1;
|
||||
// Heal
|
||||
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('h'));
|
||||
ctx.set(x_offset + 2, y, RGB::named(YELLOW), RGB::named(BLACK), to_cp437('h'));
|
||||
ctx.print(x_offset + 4, y, "HEAL TO FULL");
|
||||
y += 1;
|
||||
// Reveal map
|
||||
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('m'));
|
||||
ctx.set(x_offset + 2, y, RGB::named(YELLOW), RGB::named(BLACK), to_cp437('m'));
|
||||
ctx.print(x_offset + 4, y, "MAGIC MAP REVEAL");
|
||||
y += 1;
|
||||
// Godmode
|
||||
ctx.set(x_offset + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), rltk::to_cp437('g'));
|
||||
ctx.set(x_offset + 2, y, RGB::named(YELLOW), RGB::named(BLACK), to_cp437('g'));
|
||||
ctx.print(x_offset + 4, y, "GOD MODE");
|
||||
// Match keys
|
||||
match ctx.key {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use super::{ State, RunState, tooltip::draw_tooltips, camera::get_screen_bounds };
|
||||
use rltk::prelude::*;
|
||||
use bracket_lib::prelude::*;
|
||||
|
||||
#[derive(PartialEq, Copy, Clone)]
|
||||
pub enum FarlookResult {
|
||||
|
|
@ -10,7 +10,7 @@ pub enum FarlookResult {
|
|||
Cancel,
|
||||
}
|
||||
|
||||
pub fn show_farlook(gs: &mut State, ctx: &mut Rltk) -> FarlookResult {
|
||||
pub fn show_farlook(gs: &mut State, ctx: &mut BTerm) -> FarlookResult {
|
||||
let runstate = gs.ecs.fetch::<RunState>();
|
||||
let (_min_x, _max_x, _min_y, _max_y, x_offset, y_offset) = get_screen_bounds(&gs.ecs, ctx);
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ pub fn show_farlook(gs: &mut State, ctx: &mut Rltk) -> FarlookResult {
|
|||
let x = x.clamp(x_offset, x_offset - 1 + (screen_x as i32));
|
||||
let y = y.clamp(y_offset, y_offset - 1 + (screen_y as i32));
|
||||
|
||||
ctx.set(x, y, RGB::named(WHITE), RGB::named(BLACK), rltk::to_cp437('X'));
|
||||
ctx.set(x, y, RGB::named(WHITE), RGB::named(BLACK), to_cp437('X'));
|
||||
draw_tooltips(&gs.ecs, ctx, Some((x, y)));
|
||||
|
||||
return match ctx.key {
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ use crate::{
|
|||
Renderable,
|
||||
states::state::*,
|
||||
};
|
||||
use rltk::prelude::*;
|
||||
use bracket_lib::prelude::*;
|
||||
use specs::prelude::*;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// Handles the Identify menu.
|
||||
pub fn identify(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<Entity>) {
|
||||
pub fn identify(gs: &mut State, ctx: &mut BTerm) -> (ItemMenuResult, Option<Entity>) {
|
||||
let player_entity = gs.ecs.fetch::<Entity>();
|
||||
let equipped = gs.ecs.read_storage::<Equipped>();
|
||||
let backpack = gs.ecs.read_storage::<InBackpack>();
|
||||
|
|
@ -58,7 +58,8 @@ pub fn identify(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<Entit
|
|||
}
|
||||
// If not obfuscated, or already identified, return false.
|
||||
if
|
||||
(!obfuscated.get(*item_entity).is_some() || dm.identified_items.contains(&n.name)) &&
|
||||
(!obfuscated.get(*item_entity).is_some() ||
|
||||
dm.identified_items.contains(&n.name)) &&
|
||||
beatitudes
|
||||
.get(*item_entity)
|
||||
.map(|beatitude| beatitude.known)
|
||||
|
|
@ -93,7 +94,9 @@ pub fn identify(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<Entit
|
|||
let mut player_inventory: super::PlayerInventory = BTreeMap::new();
|
||||
for (entity, _i, renderable, name) in build_identify_iterator() {
|
||||
let (singular, plural) = obfuscate_name_ecs(&gs.ecs, entity);
|
||||
let beatitude_status = if let Some(beatitude) = gs.ecs.read_storage::<Beatitude>().get(entity) {
|
||||
let beatitude_status = if
|
||||
let Some(beatitude) = gs.ecs.read_storage::<Beatitude>().get(entity)
|
||||
{
|
||||
match beatitude.buc {
|
||||
BUC::Blessed => 1,
|
||||
BUC::Uncursed => 2,
|
||||
|
|
@ -125,8 +128,8 @@ pub fn identify(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<Entit
|
|||
ctx.print_color(
|
||||
1 + x_offset,
|
||||
1 + y_offset,
|
||||
RGB::named(rltk::WHITE),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(WHITE),
|
||||
RGB::named(BLACK),
|
||||
"Identify which item? [aA-zZ][Esc.]"
|
||||
);
|
||||
ctx.draw_box(x, y, width + 2, count + 1, RGB::named(WHITE), RGB::named(BLACK));
|
||||
|
|
@ -138,7 +141,7 @@ pub fn identify(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<Entit
|
|||
match key {
|
||||
VirtualKeyCode::Escape => (ItemMenuResult::Cancel, None),
|
||||
_ => {
|
||||
let selection = rltk::letter_to_option(key);
|
||||
let selection = letter_to_option(key);
|
||||
if selection > -1 && selection < (count as i32) {
|
||||
let item = player_inventory
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use rltk::prelude::*;
|
||||
use bracket_lib::prelude::*;
|
||||
|
||||
pub fn letter_to_option(key: VirtualKeyCode, shift: bool) -> i32 {
|
||||
if shift {
|
||||
|
|
|
|||
112
src/gui/mod.rs
112
src/gui/mod.rs
|
|
@ -62,9 +62,9 @@ pub use farlook::*;
|
|||
|
||||
/// Gives a popup box with a message and a title, and waits for a keypress.
|
||||
#[allow(unused)]
|
||||
pub fn yes_no(ctx: &mut Rltk, question: String) -> Option<bool> {
|
||||
ctx.print_color_centered(15, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), question);
|
||||
ctx.print_color_centered(17, RGB::named(rltk::CYAN), RGB::named(rltk::BLACK), "(y)es or (n)o");
|
||||
pub fn yes_no(ctx: &mut BTerm, question: String) -> Option<bool> {
|
||||
ctx.print_color_centered(15, RGB::named(YELLOW), RGB::named(BLACK), question);
|
||||
ctx.print_color_centered(17, RGB::named(CYAN), RGB::named(BLACK), "(y)es or (n)o");
|
||||
match ctx.key {
|
||||
None => None,
|
||||
Some(key) =>
|
||||
|
|
@ -77,7 +77,7 @@ pub fn yes_no(ctx: &mut Rltk, question: String) -> Option<bool> {
|
|||
}
|
||||
|
||||
pub fn draw_lerping_bar(
|
||||
ctx: &mut Rltk,
|
||||
ctx: &mut BTerm,
|
||||
sx: i32,
|
||||
sy: i32,
|
||||
width: i32,
|
||||
|
|
@ -181,8 +181,8 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||
ctx.print_color(
|
||||
26 * TEXT_FONT_MOD,
|
||||
54,
|
||||
RGB::named(rltk::WHITE),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(WHITE),
|
||||
RGB::named(BLACK),
|
||||
format!("XP{}/{}", stats.level, stats.xp)
|
||||
);
|
||||
// Draw attributes
|
||||
|
|
@ -327,7 +327,7 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||
}
|
||||
// Draw equipment
|
||||
let renderables = ecs.read_storage::<Renderable>();
|
||||
let mut equipment: Vec<(String, RGB, RGB, rltk::FontCharType)> = Vec::new();
|
||||
let mut equipment: Vec<(String, RGB, RGB, FontCharType)> = Vec::new();
|
||||
let entities = ecs.entities();
|
||||
for (entity, _equipped, renderable) in (&entities, &equipped, &renderables)
|
||||
.join()
|
||||
|
|
@ -472,7 +472,7 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||
let (render_fg, glyph) = if let Some(renderable) = renderables.get(entity) {
|
||||
(renderable.fg, renderable.glyph)
|
||||
} else {
|
||||
(RGB::named(rltk::WHITE), rltk::to_cp437('-'))
|
||||
(RGB::named(WHITE), to_cp437('-'))
|
||||
};
|
||||
seen_entities.push((
|
||||
obfuscate_name_ecs(ecs, entity).0,
|
||||
|
|
@ -587,7 +587,7 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||
|
||||
pub fn get_input_direction(
|
||||
ecs: &mut World,
|
||||
ctx: &mut Rltk,
|
||||
ctx: &mut BTerm,
|
||||
function: fn(i: i32, j: i32, ecs: &mut World) -> RunState
|
||||
) -> RunState {
|
||||
let (_, _, _, _, x_offset, y_offset) = camera::get_screen_bounds(ecs, ctx);
|
||||
|
|
@ -595,8 +595,8 @@ pub fn get_input_direction(
|
|||
ctx.print_color(
|
||||
1 + x_offset,
|
||||
1 + y_offset,
|
||||
RGB::named(rltk::WHITE),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(WHITE),
|
||||
RGB::named(BLACK),
|
||||
"In what direction? [0-9]/[YUHJKLBN]"
|
||||
);
|
||||
match ctx.key {
|
||||
|
|
@ -681,14 +681,14 @@ pub fn print_options(
|
|||
|
||||
x += 2;
|
||||
let fg = RGB::from_u8(item.renderables.0, item.renderables.1, item.renderables.2);
|
||||
ctx.set(x, y, fg, RGB::named(rltk::BLACK), item.glyph);
|
||||
ctx.set(x, y, fg, RGB::named(BLACK), item.glyph);
|
||||
x += 2;
|
||||
|
||||
let fg = RGB::from_u8(item.rgb.0, item.rgb.1, item.rgb.2);
|
||||
if item_count > &1 {
|
||||
// If more than one, print the number and pluralise
|
||||
// i.e. (a) 3 daggers
|
||||
ctx.print_color(x, y, fg, RGB::named(rltk::BLACK), item_count);
|
||||
ctx.print_color(x, y, fg, RGB::named(BLACK), item_count);
|
||||
x += 2;
|
||||
ctx.print_color(
|
||||
x,
|
||||
|
|
@ -701,7 +701,7 @@ pub fn print_options(
|
|||
width = if width > this_width { width } else { this_width };
|
||||
} else {
|
||||
if item.display_name.singular.to_lowercase().ends_with("s") {
|
||||
ctx.print_color(x, y, fg, RGB::named(rltk::BLACK), "some");
|
||||
ctx.print_color(x, y, fg, RGB::named(BLACK), "some");
|
||||
x += 5;
|
||||
} else if
|
||||
['a', 'e', 'i', 'o', 'u']
|
||||
|
|
@ -710,12 +710,12 @@ pub fn print_options(
|
|||
{
|
||||
// If one and starts with a vowel, print 'an'
|
||||
// i.e. (a) an apple
|
||||
ctx.print_color(x, y, fg, RGB::named(rltk::BLACK), "an");
|
||||
ctx.print_color(x, y, fg, RGB::named(BLACK), "an");
|
||||
x += 3;
|
||||
} else {
|
||||
// If one and not a vowel, print 'a'
|
||||
// i.e. (a) a dagger
|
||||
ctx.print_color(x, y, fg, RGB::named(rltk::BLACK), "a");
|
||||
ctx.print_color(x, y, fg, RGB::named(BLACK), "a");
|
||||
x += 2;
|
||||
}
|
||||
ctx.print_color(
|
||||
|
|
@ -951,7 +951,7 @@ pub fn item_colour(item: Entity, beatitudes: &ReadStorage<Beatitude>) -> (u8, u8
|
|||
return WHITE;
|
||||
}
|
||||
|
||||
pub fn show_help(ctx: &mut Rltk) -> YesNoResult {
|
||||
pub fn show_help(ctx: &mut BTerm) -> YesNoResult {
|
||||
let mut x = 3;
|
||||
let mut y = 12;
|
||||
let height = 22;
|
||||
|
|
@ -967,7 +967,7 @@ pub fn show_help(ctx: &mut Rltk) -> YesNoResult {
|
|||
);
|
||||
x += 2;
|
||||
y += 2;
|
||||
ctx.print_color(x, y, RGB::named(rltk::GREEN), RGB::named(rltk::BLACK), "MOVE COMMANDS");
|
||||
ctx.print_color(x, y, RGB::named(GREEN), RGB::named(BLACK), "MOVE COMMANDS");
|
||||
y += 2;
|
||||
ctx.print(x, y, "y k u 7 8 9 > down");
|
||||
ctx.print(x, y + 1, " \\|/ \\|/");
|
||||
|
|
@ -975,7 +975,7 @@ pub fn show_help(ctx: &mut Rltk) -> YesNoResult {
|
|||
ctx.print(x, y + 3, " /|\\ /|\\");
|
||||
ctx.print(x, y + 4, "b j n 1 2 3 . wait");
|
||||
y += 7;
|
||||
ctx.print_color(x, y, RGB::named(rltk::GREEN), RGB::named(rltk::BLACK), "OBJECT INTERACTION");
|
||||
ctx.print_color(x, y, RGB::named(GREEN), RGB::named(BLACK), "OBJECT INTERACTION");
|
||||
y += 2;
|
||||
ctx.print(x, y, "g get d drop");
|
||||
y += 1;
|
||||
|
|
@ -985,7 +985,7 @@ pub fn show_help(ctx: &mut Rltk) -> YesNoResult {
|
|||
y += 1;
|
||||
ctx.print(x, y, "f force x farlook");
|
||||
y += 2;
|
||||
ctx.print_color(x, y, RGB::named(rltk::GREEN), RGB::named(rltk::BLACK), "MOUSE CONTROL");
|
||||
ctx.print_color(x, y, RGB::named(GREEN), RGB::named(BLACK), "MOUSE CONTROL");
|
||||
y += 2;
|
||||
ctx.print(x, y, "hover for tooltips");
|
||||
|
||||
|
|
@ -1139,7 +1139,7 @@ pub fn show_inventory(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||
}
|
||||
}
|
||||
|
||||
pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<Entity>) {
|
||||
pub fn drop_item_menu(gs: &mut State, ctx: &mut BTerm) -> (ItemMenuResult, Option<Entity>) {
|
||||
let player_inventory = get_player_inventory(&gs.ecs);
|
||||
let count = player_inventory.len();
|
||||
|
||||
|
|
@ -1179,7 +1179,7 @@ pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||
match key {
|
||||
VirtualKeyCode::Escape => (ItemMenuResult::Cancel, None),
|
||||
_ => {
|
||||
let selection = rltk::letter_to_option(key);
|
||||
let selection = letter_to_option(key);
|
||||
if selection > -1 && selection < (count as i32) {
|
||||
if on_overmap {
|
||||
gamelog::Logger
|
||||
|
|
@ -1204,7 +1204,7 @@ pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||
}
|
||||
}
|
||||
|
||||
pub fn remove_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<Entity>) {
|
||||
pub fn remove_item_menu(gs: &mut State, ctx: &mut BTerm) -> (ItemMenuResult, Option<Entity>) {
|
||||
let player_entity = gs.ecs.fetch::<Entity>();
|
||||
let backpack = gs.ecs.read_storage::<Equipped>();
|
||||
let entities = gs.ecs.entities();
|
||||
|
|
@ -1216,8 +1216,8 @@ pub fn remove_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Opti
|
|||
ctx.print_color(
|
||||
1 + x_offset,
|
||||
1 + y_offset,
|
||||
RGB::named(rltk::WHITE),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(WHITE),
|
||||
RGB::named(BLACK),
|
||||
"Unequip what? [aA-zZ][Esc.]"
|
||||
);
|
||||
|
||||
|
|
@ -1235,7 +1235,7 @@ pub fn remove_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Opti
|
|||
let x = 1 + x_offset;
|
||||
let mut y = 3 + y_offset;
|
||||
|
||||
ctx.draw_box(x, y, width, (count + 1) as i32, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
|
||||
ctx.draw_box(x, y, width, (count + 1) as i32, RGB::named(WHITE), RGB::named(BLACK));
|
||||
y += 1;
|
||||
|
||||
let mut j = 0;
|
||||
|
|
@ -1244,7 +1244,7 @@ pub fn remove_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Opti
|
|||
let (mut fg, glyph) = if let Some(renderable) = renderables.get(*e) {
|
||||
(renderable.fg, renderable.glyph)
|
||||
} else {
|
||||
(RGB::named(rltk::WHITE), rltk::to_cp437('-'))
|
||||
(RGB::named(WHITE), to_cp437('-'))
|
||||
};
|
||||
ctx.set(
|
||||
x + 1,
|
||||
|
|
@ -1255,7 +1255,7 @@ pub fn remove_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Opti
|
|||
);
|
||||
ctx.set(x + 3, y, fg, RGB::named(rltk::BLACK), glyph);
|
||||
fg = RGB::named(item_colour_ecs(&gs.ecs, *e));
|
||||
ctx.print_color(x + 5, y, fg, RGB::named(rltk::BLACK), name);
|
||||
ctx.print_color(x + 5, y, fg, RGB::named(BLACK), name);
|
||||
y += 1;
|
||||
j += 1;
|
||||
}
|
||||
|
|
@ -1266,7 +1266,7 @@ pub fn remove_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Opti
|
|||
match key {
|
||||
VirtualKeyCode::Escape => (ItemMenuResult::Cancel, None),
|
||||
_ => {
|
||||
let selection = rltk::letter_to_option(key);
|
||||
let selection = letter_to_option(key);
|
||||
if selection > -1 && selection < (count as i32) {
|
||||
return (ItemMenuResult::Selected, Some(equippable[selection as usize].0));
|
||||
}
|
||||
|
|
@ -1288,7 +1288,7 @@ pub enum TargetResult {
|
|||
|
||||
pub fn ranged_target(
|
||||
gs: &mut State,
|
||||
ctx: &mut Rltk,
|
||||
ctx: &mut BTerm,
|
||||
x: i32,
|
||||
y: i32,
|
||||
range: i32,
|
||||
|
|
@ -1302,8 +1302,8 @@ pub fn ranged_target(
|
|||
ctx.print_color(
|
||||
1 + x_offset,
|
||||
1 + y_offset,
|
||||
RGB::named(rltk::WHITE),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(WHITE),
|
||||
RGB::named(BLACK),
|
||||
"Targeting which tile? [mouse input]"
|
||||
);
|
||||
|
||||
|
|
@ -1313,7 +1313,7 @@ pub fn ranged_target(
|
|||
if let Some(visible) = visible {
|
||||
// We have a viewshed
|
||||
for idx in visible.visible_tiles.iter() {
|
||||
let distance = rltk::DistanceAlg::Pythagoras.distance2d(*player_pos, *idx);
|
||||
let distance = DistanceAlg::Pythagoras.distance2d(*player_pos, *idx);
|
||||
if distance <= (range as f32) {
|
||||
let screen_x = idx.x - min_x;
|
||||
let screen_y = idx.y - min_y;
|
||||
|
|
@ -1354,7 +1354,7 @@ pub fn ranged_target(
|
|||
}
|
||||
let mut result = (TargetResult::NoResponse { x, y }, None);
|
||||
if valid_target {
|
||||
let path = rltk::line2d(
|
||||
let path = line2d(
|
||||
LineAlg::Bresenham,
|
||||
Point::new(player_pos.x, player_pos.y),
|
||||
Point::new(mouse_pos_adjusted.0, mouse_pos_adjusted.1)
|
||||
|
|
@ -1374,7 +1374,7 @@ pub fn ranged_target(
|
|||
if aoe > 0 {
|
||||
// We adjust for camera position when getting FOV, but then we need to adjust back
|
||||
// when iterating through the tiles themselves, by taking away min_x/min_y.
|
||||
let mut blast_tiles = rltk::field_of_view(
|
||||
let mut blast_tiles = field_of_view(
|
||||
Point::new(mouse_pos_adjusted.0, mouse_pos_adjusted.1),
|
||||
aoe,
|
||||
&*map
|
||||
|
|
@ -1411,7 +1411,7 @@ pub fn ranged_target(
|
|||
}
|
||||
};
|
||||
} else {
|
||||
ctx.set_bg(mouse_pos.0, mouse_pos.1, RGB::named(rltk::RED));
|
||||
ctx.set_bg(mouse_pos.0, mouse_pos.1, RGB::named(RED));
|
||||
}
|
||||
|
||||
result = match ctx.key {
|
||||
|
|
@ -1450,7 +1450,7 @@ pub enum MainMenuResult {
|
|||
},
|
||||
}
|
||||
|
||||
pub fn main_menu(gs: &mut State, ctx: &mut Rltk) -> MainMenuResult {
|
||||
pub fn main_menu(gs: &mut State, ctx: &mut BTerm) -> MainMenuResult {
|
||||
let save_exists = super::saveload_system::does_save_exist();
|
||||
let runstate = gs.ecs.fetch::<RunState>();
|
||||
let assets = gs.ecs.fetch::<RexAssets>();
|
||||
|
|
@ -1464,8 +1464,8 @@ pub fn main_menu(gs: &mut State, ctx: &mut Rltk) -> MainMenuResult {
|
|||
height -= 1;
|
||||
}
|
||||
|
||||
ctx.draw_box_double(x, y - 4, 13, height, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
|
||||
ctx.print_color(x + 3, y - 2, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "RUST-RL!");
|
||||
ctx.draw_box_double(x, y - 4, 13, height, RGB::named(WHITE), RGB::named(BLACK));
|
||||
ctx.print_color(x + 3, y - 2, RGB::named(YELLOW), RGB::named(BLACK), "RUST-RL!");
|
||||
|
||||
if let RunState::MainMenu { menu_selection: selection } = *runstate {
|
||||
if save_exists {
|
||||
|
|
@ -1491,19 +1491,19 @@ pub fn main_menu(gs: &mut State, ctx: &mut Rltk) -> MainMenuResult {
|
|||
y += 1;
|
||||
}
|
||||
if selection == MainMenuSelection::NewGame {
|
||||
ctx.print_color(x + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "[");
|
||||
ctx.print_color(x + 3, y, RGB::named(rltk::GREEN), RGB::named(rltk::BLACK), "new game");
|
||||
ctx.print_color(x + 11, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "]");
|
||||
ctx.print_color(x + 2, y, RGB::named(YELLOW), RGB::named(BLACK), "[");
|
||||
ctx.print_color(x + 3, y, RGB::named(GREEN), RGB::named(BLACK), "new game");
|
||||
ctx.print_color(x + 11, y, RGB::named(YELLOW), RGB::named(BLACK), "]");
|
||||
} else {
|
||||
ctx.print_color(x + 3, y, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK), "new game");
|
||||
ctx.print_color(x + 3, y, RGB::named(WHITE), RGB::named(BLACK), "new game");
|
||||
}
|
||||
y += 1;
|
||||
if selection == MainMenuSelection::Quit {
|
||||
ctx.print_color(x + 2, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "[");
|
||||
ctx.print_color(x + 3, y, RGB::named(rltk::GREEN), RGB::named(rltk::BLACK), "goodbye!");
|
||||
ctx.print_color(x + 11, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "]");
|
||||
ctx.print_color(x + 2, y, RGB::named(YELLOW), RGB::named(BLACK), "[");
|
||||
ctx.print_color(x + 3, y, RGB::named(GREEN), RGB::named(BLACK), "goodbye!");
|
||||
ctx.print_color(x + 11, y, RGB::named(YELLOW), RGB::named(BLACK), "]");
|
||||
} else {
|
||||
ctx.print_color(x + 5, y, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK), "quit");
|
||||
ctx.print_color(x + 5, y, RGB::named(WHITE), RGB::named(BLACK), "quit");
|
||||
}
|
||||
|
||||
match ctx.key {
|
||||
|
|
@ -1578,18 +1578,18 @@ pub enum YesNoResult {
|
|||
No,
|
||||
}
|
||||
|
||||
pub fn game_over(ctx: &mut Rltk) -> YesNoResult {
|
||||
pub fn game_over(ctx: &mut BTerm) -> YesNoResult {
|
||||
let mut x = 3;
|
||||
let mut y = 12;
|
||||
let width = 45;
|
||||
let height = 20;
|
||||
ctx.draw_box(x, y, width, height, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
|
||||
ctx.print_color(x + 3, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "You died!");
|
||||
ctx.draw_box(x, y, width, height, RGB::named(WHITE), RGB::named(BLACK));
|
||||
ctx.print_color(x + 3, y, RGB::named(YELLOW), RGB::named(BLACK), "You died!");
|
||||
ctx.print_color(
|
||||
x + 3,
|
||||
y + height,
|
||||
RGB::named(rltk::YELLOW),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(YELLOW),
|
||||
RGB::named(BLACK),
|
||||
" Write a morgue file? [y/n] "
|
||||
);
|
||||
x += 2;
|
||||
|
|
@ -1597,8 +1597,8 @@ pub fn game_over(ctx: &mut Rltk) -> YesNoResult {
|
|||
ctx.print_color(
|
||||
x,
|
||||
y,
|
||||
RGB::named(rltk::GREEN),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(GREEN),
|
||||
RGB::named(BLACK),
|
||||
format!("You survived for {} turns.", crate::gamelog::get_event_count(EVENT::COUNT_TURN))
|
||||
);
|
||||
y += 2;
|
||||
|
|
@ -1627,8 +1627,8 @@ pub fn game_over(ctx: &mut Rltk) -> YesNoResult {
|
|||
ctx.print_color(
|
||||
x + 1,
|
||||
y,
|
||||
RGB::named(rltk::WHITE),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(WHITE),
|
||||
RGB::named(BLACK),
|
||||
format!(
|
||||
"- kicked {} time(s), breaking {} object(s)",
|
||||
crate::gamelog::get_event_count(EVENT::COUNT_KICK),
|
||||
|
|
|
|||
|
|
@ -7,13 +7,24 @@ use super::{
|
|||
ItemMenuResult,
|
||||
UniqueInventoryItem,
|
||||
};
|
||||
use crate::{ gamelog, Beatitude, Entity, Equipped, InBackpack, Item, Name, Renderable, states::state::*, BUC };
|
||||
use rltk::prelude::*;
|
||||
use crate::{
|
||||
gamelog,
|
||||
Beatitude,
|
||||
Entity,
|
||||
Equipped,
|
||||
InBackpack,
|
||||
Item,
|
||||
Name,
|
||||
Renderable,
|
||||
states::state::*,
|
||||
BUC,
|
||||
};
|
||||
use bracket_lib::prelude::*;
|
||||
use specs::prelude::*;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// Handles the Remove Curse menu.
|
||||
pub fn remove_curse(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<Entity>) {
|
||||
pub fn remove_curse(gs: &mut State, ctx: &mut BTerm) -> (ItemMenuResult, Option<Entity>) {
|
||||
let player_entity = gs.ecs.fetch::<Entity>();
|
||||
let equipped = gs.ecs.read_storage::<Equipped>();
|
||||
let backpack = gs.ecs.read_storage::<InBackpack>();
|
||||
|
|
@ -24,33 +35,35 @@ pub fn remove_curse(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<E
|
|||
let renderables = gs.ecs.read_storage::<Renderable>();
|
||||
|
||||
let build_cursed_iterator = || {
|
||||
(&entities, &items, &beatitudes, &renderables, &names).join().filter(|(item_entity, _i, b, _r, _n)| {
|
||||
// Set all items to FALSE initially.
|
||||
let mut keep = false;
|
||||
// If found in the player's backpack, set to TRUE
|
||||
if let Some(bp) = backpack.get(*item_entity) {
|
||||
if bp.owner == *player_entity {
|
||||
keep = true;
|
||||
(&entities, &items, &beatitudes, &renderables, &names)
|
||||
.join()
|
||||
.filter(|(item_entity, _i, b, _r, _n)| {
|
||||
// Set all items to FALSE initially.
|
||||
let mut keep = false;
|
||||
// If found in the player's backpack, set to TRUE
|
||||
if let Some(bp) = backpack.get(*item_entity) {
|
||||
if bp.owner == *player_entity {
|
||||
keep = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If found in the player's equipslot, set to TRUE
|
||||
if let Some(equip) = equipped.get(*item_entity) {
|
||||
if equip.owner == *player_entity {
|
||||
keep = true;
|
||||
// If found in the player's equipslot, set to TRUE
|
||||
if let Some(equip) = equipped.get(*item_entity) {
|
||||
if equip.owner == *player_entity {
|
||||
keep = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If it's not OUR item, RETURN FALSE.
|
||||
if !keep {
|
||||
return false;
|
||||
}
|
||||
// If it's identified as noncursed, RETURN FALSE.
|
||||
if b.known && b.buc != BUC::Cursed {
|
||||
return false;
|
||||
}
|
||||
// Otherwise, return: returns any items that are unidentified,
|
||||
// or identified as being cursed.
|
||||
return true;
|
||||
})
|
||||
// If it's not OUR item, RETURN FALSE.
|
||||
if !keep {
|
||||
return false;
|
||||
}
|
||||
// If it's identified as noncursed, RETURN FALSE.
|
||||
if b.known && b.buc != BUC::Cursed {
|
||||
return false;
|
||||
}
|
||||
// Otherwise, return: returns any items that are unidentified,
|
||||
// or identified as being cursed.
|
||||
return true;
|
||||
})
|
||||
};
|
||||
|
||||
// Build list of items to display
|
||||
|
|
@ -76,7 +89,9 @@ pub fn remove_curse(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<E
|
|||
let mut player_inventory: super::PlayerInventory = BTreeMap::new();
|
||||
for (entity, _i, _b, renderable, name) in build_cursed_iterator() {
|
||||
let (singular, plural) = obfuscate_name_ecs(&gs.ecs, entity);
|
||||
let beatitude_status = if let Some(beatitude) = gs.ecs.read_storage::<Beatitude>().get(entity) {
|
||||
let beatitude_status = if
|
||||
let Some(beatitude) = gs.ecs.read_storage::<Beatitude>().get(entity)
|
||||
{
|
||||
match beatitude.buc {
|
||||
BUC::Blessed => 1,
|
||||
BUC::Uncursed => 2,
|
||||
|
|
@ -108,8 +123,8 @@ pub fn remove_curse(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<E
|
|||
ctx.print_color(
|
||||
1 + x_offset,
|
||||
1 + y_offset,
|
||||
RGB::named(rltk::WHITE),
|
||||
RGB::named(rltk::BLACK),
|
||||
RGB::named(WHITE),
|
||||
RGB::named(BLACK),
|
||||
"Decurse which item? [aA-zZ][Esc.]"
|
||||
);
|
||||
ctx.draw_box(x, y, width + 2, count + 1, RGB::named(WHITE), RGB::named(BLACK));
|
||||
|
|
@ -121,7 +136,7 @@ pub fn remove_curse(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option<E
|
|||
match key {
|
||||
VirtualKeyCode::Escape => (ItemMenuResult::Cancel, None),
|
||||
_ => {
|
||||
let selection = rltk::letter_to_option(key);
|
||||
let selection = letter_to_option(key);
|
||||
if selection > -1 && selection < (count as i32) {
|
||||
let item = player_inventory
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -7,13 +7,12 @@ use super::{
|
|||
Pools,
|
||||
Position,
|
||||
Renderable,
|
||||
Rltk,
|
||||
World,
|
||||
RGB,
|
||||
};
|
||||
use crate::TileType;
|
||||
use crate::data::ids::*;
|
||||
use rltk::prelude::*;
|
||||
use bracket_lib::prelude::*;
|
||||
use specs::prelude::*;
|
||||
|
||||
struct Tooltip {
|
||||
|
|
@ -63,7 +62,7 @@ impl Tooltip {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub fn draw_tooltips(ecs: &World, ctx: &mut Rltk, xy: Option<(i32, i32)>) {
|
||||
pub fn draw_tooltips(ecs: &World, ctx: &mut BTerm, xy: Option<(i32, i32)>) {
|
||||
let (min_x, _max_x, min_y, _max_y, x_offset, y_offset) = get_screen_bounds(ecs, ctx);
|
||||
let map = ecs.fetch::<Map>();
|
||||
let names = ecs.read_storage::<Name>();
|
||||
|
|
@ -164,7 +163,7 @@ pub fn draw_tooltips(ecs: &World, ctx: &mut Rltk, xy: Option<(i32, i32)>) {
|
|||
|
||||
if tooltips.is_empty() { return ; }
|
||||
|
||||
let white = RGB::named(rltk::WHITE);
|
||||
let white = RGB::named(WHITE);
|
||||
|
||||
let arrow;
|
||||
let arrow_x;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue