restricts overmap actions (item use/drop/kick/open/close)
This commit is contained in:
parent
45461495fd
commit
568df55795
3 changed files with 49 additions and 36 deletions
|
|
@ -772,13 +772,14 @@ pub fn show_inventory(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||
|
||||
let (x_offset, y_offset) = (1, 10);
|
||||
|
||||
ctx.print_color(
|
||||
1 + x_offset,
|
||||
1 + y_offset,
|
||||
RGB::named(rltk::WHITE),
|
||||
RGB::named(rltk::BLACK),
|
||||
let on_overmap = gs.ecs.fetch::<Map>().overmap;
|
||||
let message = if !on_overmap {
|
||||
"Interact with what item? [aA-zZ][Esc.]"
|
||||
);
|
||||
} else {
|
||||
"You can't use items on the overmap [Esc.]"
|
||||
};
|
||||
|
||||
ctx.print_color(1 + x_offset, 1 + y_offset, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK), message);
|
||||
|
||||
let x = 1 + x_offset;
|
||||
let y = 3 + y_offset;
|
||||
|
|
@ -794,6 +795,9 @@ pub fn show_inventory(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||
_ => {
|
||||
let selection = letter_to_option::letter_to_option(key, ctx.shift);
|
||||
if selection > -1 && selection < (count as i32) {
|
||||
if on_overmap {
|
||||
gamelog::Logger::new().append("You can't use items on the overmap.").log();
|
||||
} else {
|
||||
return (
|
||||
ItemMenuResult::Selected,
|
||||
Some(
|
||||
|
|
@ -804,6 +808,7 @@ pub fn show_inventory(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
(ItemMenuResult::NoResponse, None)
|
||||
}
|
||||
}
|
||||
|
|
@ -816,13 +821,10 @@ pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||
|
||||
let (x_offset, y_offset) = (1, 10);
|
||||
|
||||
ctx.print_color(
|
||||
1 + x_offset,
|
||||
1 + y_offset,
|
||||
RGB::named(rltk::WHITE),
|
||||
RGB::named(rltk::BLACK),
|
||||
"Drop what? [aA-zZ][Esc.]"
|
||||
);
|
||||
let on_overmap = gs.ecs.fetch::<Map>().overmap;
|
||||
let message = if !on_overmap { "Drop what? [aA-zZ][Esc.]" } else { "You can't drop items on the overmap [Esc.]" };
|
||||
|
||||
ctx.print_color(1 + x_offset, 1 + y_offset, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK), message);
|
||||
|
||||
let x = 1 + x_offset;
|
||||
let y = 3 + y_offset;
|
||||
|
|
@ -838,6 +840,9 @@ pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||
_ => {
|
||||
let selection = rltk::letter_to_option(key);
|
||||
if selection > -1 && selection < (count as i32) {
|
||||
if on_overmap {
|
||||
gamelog::Logger::new().append("You can't drop items on the overmap.").log();
|
||||
} else {
|
||||
return (
|
||||
ItemMenuResult::Selected,
|
||||
Some(
|
||||
|
|
@ -848,6 +853,7 @@ pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
(ItemMenuResult::NoResponse, None)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,7 +263,8 @@ impl GameState for State {
|
|||
}
|
||||
}
|
||||
if can_act {
|
||||
new_runstate = player_input(self, ctx);
|
||||
let on_overmap = self.ecs.fetch::<Map>().overmap;
|
||||
new_runstate = player_input(self, ctx, on_overmap);
|
||||
} else {
|
||||
new_runstate = RunState::Ticking;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -586,7 +586,7 @@ fn get_item(ecs: &mut World) -> RunState {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn player_input(gs: &mut State, ctx: &mut Rltk) -> RunState {
|
||||
pub fn player_input(gs: &mut State, ctx: &mut Rltk, on_overmap: bool) -> RunState {
|
||||
match ctx.key {
|
||||
None => {
|
||||
return RunState::AwaitingInput;
|
||||
|
|
@ -662,14 +662,20 @@ pub fn player_input(gs: &mut State, ctx: &mut Rltk) -> RunState {
|
|||
|
||||
// Items
|
||||
VirtualKeyCode::C => {
|
||||
if !on_overmap {
|
||||
return RunState::ActionWithDirection { function: try_door };
|
||||
}
|
||||
}
|
||||
VirtualKeyCode::O => {
|
||||
if !on_overmap {
|
||||
return RunState::ActionWithDirection { function: open };
|
||||
}
|
||||
}
|
||||
VirtualKeyCode::F => {
|
||||
if !on_overmap {
|
||||
return RunState::ActionWithDirection { function: kick };
|
||||
}
|
||||
}
|
||||
VirtualKeyCode::G => {
|
||||
return get_item(&mut gs.ecs);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue