charcreation runstate
This commit is contained in:
parent
f4d4b414d5
commit
c80cb01816
4 changed files with 1873 additions and 3025 deletions
4700
resources/td.json
4700
resources/td.json
File diff suppressed because it is too large
Load diff
BIN
resources/td.png
BIN
resources/td.png
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 27 KiB |
|
|
@ -190,143 +190,50 @@ fn get_colour<T>(selected: T, desired: T) -> Color where T: PartialEq {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles the player character creation screen.
|
/// Handles the player character creation screen.
|
||||||
pub fn character_creation(gs: &mut State, ctx: &mut BTerm) -> CharCreateResult {
|
pub fn character_creation(gs: &mut State, ctx: &mut App) -> CharCreateResult {
|
||||||
ctx.set_active_console(TEXT_LAYER);
|
|
||||||
let runstate = gs.ecs.fetch::<RunState>();
|
let runstate = gs.ecs.fetch::<RunState>();
|
||||||
|
let (ancestry, class) = match *runstate {
|
||||||
|
RunState::CharacterCreation { ancestry, class } => (ancestry, class),
|
||||||
|
_ => unreachable!("character_creation() called outside of CharacterCreation runstate."),
|
||||||
|
};
|
||||||
|
|
||||||
let mut x = 2;
|
let key = &ctx.keyboard;
|
||||||
let mut y = 11;
|
for keycode in key.pressed.iter() {
|
||||||
let column_width = 20;
|
match *keycode {
|
||||||
|
KeyCode::Escape => {
|
||||||
ctx.print_color(x, y, RGB::named(WHITE), RGB::named(BLACK), CHAR_CREATE_HEADER);
|
return CharCreateResult::Selected { ancestry: Ancestry::Unset, class };
|
||||||
y += 2;
|
|
||||||
|
|
||||||
if let RunState::CharacterCreation { ancestry, class } = *runstate {
|
|
||||||
let selected_fg = RGB::named(GREEN);
|
|
||||||
let unselected_fg = RGB::named(WHITE);
|
|
||||||
let mut fg;
|
|
||||||
let bg = RGB::named(BLACK);
|
|
||||||
|
|
||||||
// Ancestry
|
|
||||||
ctx.print_color(x, y, bg, unselected_fg, "Ancestry");
|
|
||||||
ctx.print_color(x + column_width, y, bg, unselected_fg, "Class");
|
|
||||||
y += 1;
|
|
||||||
let mut race_str = "human";
|
|
||||||
if ancestry == Ancestry::Human {
|
|
||||||
fg = selected_fg;
|
|
||||||
} else {
|
|
||||||
fg = unselected_fg;
|
|
||||||
}
|
|
||||||
ctx.print_color(x, y, fg, bg, "h. Human");
|
|
||||||
if ancestry == Ancestry::Elf {
|
|
||||||
fg = selected_fg;
|
|
||||||
race_str = "elf";
|
|
||||||
} else {
|
|
||||||
fg = unselected_fg;
|
|
||||||
}
|
|
||||||
ctx.print_color(x, y + 1, fg, bg, "e. Elf");
|
|
||||||
if ancestry == Ancestry::Dwarf {
|
|
||||||
fg = selected_fg;
|
|
||||||
race_str = "dwarf";
|
|
||||||
} else {
|
|
||||||
fg = unselected_fg;
|
|
||||||
}
|
|
||||||
ctx.print_color(x, y + 2, fg, bg, "d. Dwarf");
|
|
||||||
if ancestry == Ancestry::Catfolk {
|
|
||||||
fg = selected_fg;
|
|
||||||
race_str = "catfolk";
|
|
||||||
} else {
|
|
||||||
fg = unselected_fg;
|
|
||||||
}
|
|
||||||
ctx.print_color(x, y + 3, fg, bg, "c. Catfolk");
|
|
||||||
// Class
|
|
||||||
let mut class_str = "fighter";
|
|
||||||
x += column_width;
|
|
||||||
if class == Class::Fighter {
|
|
||||||
fg = selected_fg;
|
|
||||||
} else {
|
|
||||||
fg = unselected_fg;
|
|
||||||
}
|
|
||||||
ctx.print_color(x, y, fg, bg, "f. Fighter");
|
|
||||||
if class == Class::Rogue {
|
|
||||||
fg = selected_fg;
|
|
||||||
class_str = "rogue";
|
|
||||||
} else {
|
|
||||||
fg = unselected_fg;
|
|
||||||
}
|
|
||||||
ctx.print_color(x, y + 1, fg, bg, "r. Rogue");
|
|
||||||
if class == Class::Wizard {
|
|
||||||
fg = selected_fg;
|
|
||||||
class_str = "wizard";
|
|
||||||
} else {
|
|
||||||
fg = unselected_fg;
|
|
||||||
}
|
|
||||||
ctx.print_color(x, y + 2, fg, bg, "w. Wizard");
|
|
||||||
if class == Class::Villager {
|
|
||||||
fg = selected_fg;
|
|
||||||
class_str = "villager";
|
|
||||||
} else {
|
|
||||||
fg = unselected_fg;
|
|
||||||
}
|
|
||||||
ctx.print_color(x, y + 3, fg, bg, "v. Villager");
|
|
||||||
// Selected ancestry/class benefits
|
|
||||||
x += column_width;
|
|
||||||
ctx.print_color(x, y, selected_fg, bg, ANCESTRY_INFO_HEADER);
|
|
||||||
/*for line in ANCESTRY_CLASS_DATA.get(race_str).unwrap().iter() {
|
|
||||||
y += 1;
|
|
||||||
ctx.print_color(x + 1, y, unselected_fg, bg, line);
|
|
||||||
}
|
|
||||||
y += 2;
|
|
||||||
ctx.print_color(x, y, selected_fg, bg, CLASS_INFO_HEADER);
|
|
||||||
for line in ANCESTRY_CLASS_DATA.get(class_str).unwrap().iter() {
|
|
||||||
y += 1;
|
|
||||||
ctx.print_color(x + 1, y, unselected_fg, bg, line);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
match ctx.key {
|
|
||||||
None => {
|
|
||||||
return CharCreateResult::NoSelection { ancestry, class };
|
|
||||||
}
|
}
|
||||||
Some(key) =>
|
KeyCode::Return => {
|
||||||
match key {
|
return CharCreateResult::Selected { ancestry, class };
|
||||||
VirtualKeyCode::Escape => {
|
}
|
||||||
return CharCreateResult::Selected { ancestry: Ancestry::Unset, class };
|
KeyCode::H => {
|
||||||
}
|
return CharCreateResult::NoSelection { ancestry: Ancestry::Human, class };
|
||||||
VirtualKeyCode::Return => {
|
}
|
||||||
return CharCreateResult::Selected { ancestry, class };
|
KeyCode::E => {
|
||||||
}
|
return CharCreateResult::NoSelection { ancestry: Ancestry::Elf, class };
|
||||||
VirtualKeyCode::H => {
|
}
|
||||||
return CharCreateResult::NoSelection { ancestry: Ancestry::Human, class };
|
KeyCode::D => {
|
||||||
}
|
return CharCreateResult::NoSelection { ancestry: Ancestry::Dwarf, class };
|
||||||
VirtualKeyCode::E => {
|
}
|
||||||
return CharCreateResult::NoSelection { ancestry: Ancestry::Elf, class };
|
KeyCode::C => {
|
||||||
}
|
return CharCreateResult::NoSelection { ancestry: Ancestry::Catfolk, class };
|
||||||
VirtualKeyCode::D => {
|
}
|
||||||
return CharCreateResult::NoSelection { ancestry: Ancestry::Dwarf, class };
|
KeyCode::F => {
|
||||||
}
|
return CharCreateResult::NoSelection { ancestry, class: Class::Fighter };
|
||||||
VirtualKeyCode::C => {
|
}
|
||||||
return CharCreateResult::NoSelection { ancestry: Ancestry::Catfolk, class };
|
KeyCode::R => {
|
||||||
}
|
return CharCreateResult::NoSelection { ancestry, class: Class::Rogue };
|
||||||
VirtualKeyCode::F => {
|
}
|
||||||
return CharCreateResult::NoSelection { ancestry, class: Class::Fighter };
|
KeyCode::W => {
|
||||||
}
|
return CharCreateResult::NoSelection { ancestry, class: Class::Wizard };
|
||||||
VirtualKeyCode::R => {
|
}
|
||||||
return CharCreateResult::NoSelection { ancestry, class: Class::Rogue };
|
KeyCode::V => {
|
||||||
}
|
return CharCreateResult::NoSelection { ancestry, class: Class::Villager };
|
||||||
VirtualKeyCode::W => {
|
}
|
||||||
return CharCreateResult::NoSelection { ancestry, class: Class::Wizard };
|
_ => {}
|
||||||
}
|
};
|
||||||
VirtualKeyCode::V => {
|
|
||||||
return CharCreateResult::NoSelection { ancestry, class: Class::Villager };
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
return CharCreateResult::NoSelection { ancestry, class };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ctx.set_active_console(TILE_LAYER);
|
return CharCreateResult::NoSelection { ancestry, class };
|
||||||
return CharCreateResult::NoSelection { ancestry: Ancestry::Human, class: Class::Fighter };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles player ancestry setup.
|
/// Handles player ancestry setup.
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,25 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// RunState::CharacterCreation
|
RunState::CharacterCreation { .. } => {
|
||||||
|
let result = gui::character_creation(self, ctx);
|
||||||
|
match result {
|
||||||
|
gui::CharCreateResult::NoSelection { ancestry, class } => {
|
||||||
|
new_runstate = RunState::CharacterCreation { ancestry, class };
|
||||||
|
}
|
||||||
|
gui::CharCreateResult::Selected { ancestry, class } => {
|
||||||
|
if ancestry == gui::Ancestry::Unset {
|
||||||
|
new_runstate = RunState::MainMenu {
|
||||||
|
menu_selection: gui::MainMenuSelection::NewGame,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
gui::setup_player_ancestry(&mut self.ecs, ancestry);
|
||||||
|
gui::setup_player_class(&mut self.ecs, class, ancestry);
|
||||||
|
new_runstate = RunState::PreRun;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
RunState::SaveGame => {
|
RunState::SaveGame => {
|
||||||
saveload_system::save_game(&mut self.ecs);
|
saveload_system::save_game(&mut self.ecs);
|
||||||
new_runstate = RunState::MainMenu {
|
new_runstate = RunState::MainMenu {
|
||||||
|
|
@ -720,7 +738,10 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RunState::CharacterCreation { .. } => {
|
RunState::CharacterCreation { .. } => {
|
||||||
let result = gui::character_creation(self, ctx);
|
let result = gui::CharCreateResult::NoSelection {
|
||||||
|
ancestry: gui::Ancestry::Human,
|
||||||
|
class: gui::Class::Fighter,
|
||||||
|
}; //gui::character_creation(self, ctx);
|
||||||
match result {
|
match result {
|
||||||
gui::CharCreateResult::NoSelection { ancestry, class } => {
|
gui::CharCreateResult::NoSelection { ancestry, class } => {
|
||||||
new_runstate = RunState::CharacterCreation { ancestry, class };
|
new_runstate = RunState::CharacterCreation { ancestry, class };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue