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);
|
let (x_offset, y_offset) = (1, 10);
|
||||||
|
|
||||||
ctx.print_color(
|
let on_overmap = gs.ecs.fetch::<Map>().overmap;
|
||||||
1 + x_offset,
|
let message = if !on_overmap {
|
||||||
1 + y_offset,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Interact with what item? [aA-zZ][Esc.]"
|
"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 x = 1 + x_offset;
|
||||||
let y = 3 + y_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);
|
let selection = letter_to_option::letter_to_option(key, ctx.shift);
|
||||||
if selection > -1 && selection < (count as i32) {
|
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 (
|
return (
|
||||||
ItemMenuResult::Selected,
|
ItemMenuResult::Selected,
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -804,6 +808,7 @@ pub fn show_inventory(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
(ItemMenuResult::NoResponse, None)
|
(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);
|
let (x_offset, y_offset) = (1, 10);
|
||||||
|
|
||||||
ctx.print_color(
|
let on_overmap = gs.ecs.fetch::<Map>().overmap;
|
||||||
1 + x_offset,
|
let message = if !on_overmap { "Drop what? [aA-zZ][Esc.]" } else { "You can't drop items on the overmap [Esc.]" };
|
||||||
1 + y_offset,
|
|
||||||
RGB::named(rltk::WHITE),
|
ctx.print_color(1 + x_offset, 1 + y_offset, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK), message);
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Drop what? [aA-zZ][Esc.]"
|
|
||||||
);
|
|
||||||
|
|
||||||
let x = 1 + x_offset;
|
let x = 1 + x_offset;
|
||||||
let y = 3 + y_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);
|
let selection = rltk::letter_to_option(key);
|
||||||
if selection > -1 && selection < (count as i32) {
|
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 (
|
return (
|
||||||
ItemMenuResult::Selected,
|
ItemMenuResult::Selected,
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -848,6 +853,7 @@ pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
(ItemMenuResult::NoResponse, None)
|
(ItemMenuResult::NoResponse, None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,8 @@ impl GameState for State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if can_act {
|
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 {
|
} else {
|
||||||
new_runstate = RunState::Ticking;
|
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 {
|
match ctx.key {
|
||||||
None => {
|
None => {
|
||||||
return RunState::AwaitingInput;
|
return RunState::AwaitingInput;
|
||||||
|
|
@ -662,14 +662,20 @@ pub fn player_input(gs: &mut State, ctx: &mut Rltk) -> RunState {
|
||||||
|
|
||||||
// Items
|
// Items
|
||||||
VirtualKeyCode::C => {
|
VirtualKeyCode::C => {
|
||||||
|
if !on_overmap {
|
||||||
return RunState::ActionWithDirection { function: try_door };
|
return RunState::ActionWithDirection { function: try_door };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
VirtualKeyCode::O => {
|
VirtualKeyCode::O => {
|
||||||
|
if !on_overmap {
|
||||||
return RunState::ActionWithDirection { function: open };
|
return RunState::ActionWithDirection { function: open };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
VirtualKeyCode::F => {
|
VirtualKeyCode::F => {
|
||||||
|
if !on_overmap {
|
||||||
return RunState::ActionWithDirection { function: kick };
|
return RunState::ActionWithDirection { function: kick };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
VirtualKeyCode::G => {
|
VirtualKeyCode::G => {
|
||||||
return get_item(&mut gs.ecs);
|
return get_item(&mut gs.ecs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue