action w/ direction, and mapgen ctd fix
This commit is contained in:
parent
030bda215a
commit
093f9df86e
8 changed files with 3995 additions and 3552 deletions
|
|
@ -732,58 +732,46 @@ pub fn draw_ui(ecs: &World, ctx: &mut BTerm) {
|
|||
|
||||
pub fn get_input_direction(
|
||||
ecs: &mut World,
|
||||
ctx: &mut BTerm,
|
||||
ctx: &mut App,
|
||||
function: fn(i: i32, j: i32, ecs: &mut World) -> RunState
|
||||
) -> RunState {
|
||||
let offsets = camera::get_offset();
|
||||
|
||||
ctx.print_color(
|
||||
1 + offsets.x,
|
||||
1 + offsets.y,
|
||||
RGB::named(WHITE),
|
||||
RGB::named(BLACK),
|
||||
"In what direction? [0-9]/[YUHJKLBN]"
|
||||
);
|
||||
match ctx.key {
|
||||
None => {
|
||||
return RunState::ActionWithDirection { function };
|
||||
}
|
||||
Some(key) =>
|
||||
match key {
|
||||
VirtualKeyCode::Escape => {
|
||||
return RunState::AwaitingInput;
|
||||
}
|
||||
// Cardinals
|
||||
VirtualKeyCode::Left | VirtualKeyCode::Numpad4 | VirtualKeyCode::H => {
|
||||
return function(-1, 0, ecs);
|
||||
}
|
||||
VirtualKeyCode::Right | VirtualKeyCode::Numpad6 | VirtualKeyCode::L => {
|
||||
return function(1, 0, ecs);
|
||||
}
|
||||
VirtualKeyCode::Up | VirtualKeyCode::Numpad8 | VirtualKeyCode::K => {
|
||||
return function(0, -1, ecs);
|
||||
}
|
||||
VirtualKeyCode::Down | VirtualKeyCode::Numpad2 | VirtualKeyCode::J => {
|
||||
return function(0, 1, ecs);
|
||||
}
|
||||
// Diagonals
|
||||
VirtualKeyCode::Numpad9 | VirtualKeyCode::U => {
|
||||
return function(1, -1, ecs);
|
||||
}
|
||||
VirtualKeyCode::Numpad7 | VirtualKeyCode::Y => {
|
||||
return function(-1, -1, ecs);
|
||||
}
|
||||
VirtualKeyCode::Numpad3 | VirtualKeyCode::N => {
|
||||
return function(1, 1, ecs);
|
||||
}
|
||||
VirtualKeyCode::Numpad1 | VirtualKeyCode::B => {
|
||||
return function(-1, 1, ecs);
|
||||
}
|
||||
_ => {
|
||||
return RunState::ActionWithDirection { function };
|
||||
}
|
||||
let key = &ctx.keyboard;
|
||||
for keycode in key.pressed.iter() {
|
||||
match *keycode {
|
||||
KeyCode::Escape => {
|
||||
return RunState::AwaitingInput;
|
||||
}
|
||||
KeyCode::Numpad1 | KeyCode::B => {
|
||||
return function(-1, 1, ecs);
|
||||
}
|
||||
KeyCode::Numpad2 | KeyCode::J | KeyCode::Down => {
|
||||
return function(0, 1, ecs);
|
||||
}
|
||||
KeyCode::Numpad3 | KeyCode::N => {
|
||||
return function(1, 1, ecs);
|
||||
}
|
||||
KeyCode::Numpad4 | KeyCode::H | KeyCode::Left => {
|
||||
return function(-1, 0, ecs);
|
||||
}
|
||||
KeyCode::Numpad5 | KeyCode::Period => {
|
||||
return function(0, 0, ecs);
|
||||
}
|
||||
KeyCode::Numpad6 | KeyCode::L | KeyCode::Right => {
|
||||
return function(1, 0, ecs);
|
||||
}
|
||||
KeyCode::Numpad7 | KeyCode::Y => {
|
||||
return function(-1, -1, ecs);
|
||||
}
|
||||
KeyCode::Numpad8 | KeyCode::K | KeyCode::Up => {
|
||||
return function(0, -1, ecs);
|
||||
}
|
||||
KeyCode::Numpad9 | KeyCode::U => {
|
||||
return function(1, -1, ecs);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
RunState::ActionWithDirection { function }
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Copy, Clone)]
|
||||
|
|
|
|||
26
src/main.rs
26
src/main.rs
|
|
@ -440,13 +440,15 @@ fn draw(app: &mut App, gfx: &mut Graphics, gs: &mut State) {
|
|||
| RunState::PreRun { .. } => {}
|
||||
RunState::MapGeneration => {
|
||||
draw_bg(&gs.ecs, &mut draw, &gs.atlas);
|
||||
render_map_in_view(
|
||||
&gs.mapgen_history[gs.mapgen_index],
|
||||
&gs.ecs,
|
||||
&mut draw,
|
||||
&gs.atlas,
|
||||
true
|
||||
);
|
||||
if config::CONFIG.logging.show_mapgen {
|
||||
render_map_in_view(
|
||||
&gs.mapgen_history[gs.mapgen_index],
|
||||
&gs.ecs,
|
||||
&mut draw,
|
||||
&gs.atlas,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
draw_bg(&gs.ecs, &mut draw, &gs.atlas);
|
||||
|
|
@ -457,18 +459,20 @@ fn draw(app: &mut App, gfx: &mut Graphics, gs: &mut State) {
|
|||
}
|
||||
match *gs.ecs.fetch::<RunState>() {
|
||||
RunState::Farlook { x, y } => {
|
||||
draw.text(&gs.font, "RunState::Farlook")
|
||||
.position(((x + 2) as f32) * TILESIZE, (y as f32) * TILESIZE)
|
||||
.size(FONTSIZE);
|
||||
gui::draw_farlook(x, y, &mut draw, &gs.atlas);
|
||||
//draw_tooltips(&gs.ecs, ctx, Some((x, y))); TODO: Put this in draw loop
|
||||
}
|
||||
RunState::ShowCheatMenu => {
|
||||
gui::draw_cheat_menu(&mut draw, &gs.atlas, &gs.font);
|
||||
}
|
||||
RunState::ActionWithDirection { .. } => {
|
||||
let offset = crate::camera::get_offset();
|
||||
draw.text(&gs.font, "In what direction? [0-9]/[YUHJKLBN]")
|
||||
.position(((offset.x + 1) as f32) * TILESIZE, ((offset.y + 1) as f32) * TILESIZE)
|
||||
.size(TILESIZE);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
// Render batch
|
||||
gfx.render(&draw);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -279,7 +279,9 @@ impl State {
|
|||
// RunState::ShowTargeting
|
||||
// RunState::ShowRemoveCurse
|
||||
// RunState::ShowIdentify
|
||||
// RunState::ActionWithDirection
|
||||
RunState::ActionWithDirection { function } => {
|
||||
new_runstate = gui::get_input_direction(&mut self.ecs, ctx, function);
|
||||
}
|
||||
// RunState::MainMenu
|
||||
// RunState::CharacterCreation
|
||||
RunState::SaveGame => {
|
||||
|
|
@ -645,7 +647,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
RunState::ActionWithDirection { function } => {
|
||||
new_runstate = gui::get_input_direction(&mut self.ecs, ctx, function);
|
||||
new_runstate = RunState::AwaitingInput; //gui::get_input_direction(&mut self.ecs, ctx, function);
|
||||
}
|
||||
RunState::MainMenu { .. } => {
|
||||
let result = gui::main_menu(self, ctx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue