diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 3ae47b4..d4c07fb 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -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::().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,15 +795,19 @@ 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) { - return ( - ItemMenuResult::Selected, - Some( - player_inventory - .iter() - .nth(selection as usize) - .unwrap().1.0 - ), - ); + if on_overmap { + gamelog::Logger::new().append("You can't use items on the overmap.").log(); + } else { + return ( + ItemMenuResult::Selected, + Some( + player_inventory + .iter() + .nth(selection as usize) + .unwrap().1.0 + ), + ); + } } (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::().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,15 +840,19 @@ 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) { - return ( - ItemMenuResult::Selected, - Some( - player_inventory - .iter() - .nth(selection as usize) - .unwrap().1.0 - ), - ); + if on_overmap { + gamelog::Logger::new().append("You can't drop items on the overmap.").log(); + } else { + return ( + ItemMenuResult::Selected, + Some( + player_inventory + .iter() + .nth(selection as usize) + .unwrap().1.0 + ), + ); + } } (ItemMenuResult::NoResponse, None) } diff --git a/src/main.rs b/src/main.rs index b99a7a2..77abeeb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -263,7 +263,8 @@ impl GameState for State { } } if can_act { - new_runstate = player_input(self, ctx); + let on_overmap = self.ecs.fetch::().overmap; + new_runstate = player_input(self, ctx, on_overmap); } else { new_runstate = RunState::Ticking; } diff --git a/src/player.rs b/src/player.rs index f540af8..7ff056e 100644 --- a/src/player.rs +++ b/src/player.rs @@ -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,13 +662,19 @@ pub fn player_input(gs: &mut State, ctx: &mut Rltk) -> RunState { // Items VirtualKeyCode::C => { - return RunState::ActionWithDirection { function: try_door }; + if !on_overmap { + return RunState::ActionWithDirection { function: try_door }; + } } VirtualKeyCode::O => { - return RunState::ActionWithDirection { function: open }; + if !on_overmap { + return RunState::ActionWithDirection { function: open }; + } } VirtualKeyCode::F => { - return RunState::ActionWithDirection { function: kick }; + if !on_overmap { + return RunState::ActionWithDirection { function: kick }; + } } VirtualKeyCode::G => { return get_item(&mut gs.ecs);