Browse Source

Add todos

master
Garrit Franke 3 years ago
parent
commit
ea6c60db62
  1. 4
      src/inventory.rs
  2. 8
      src/main.rs
  3. 2
      src/traits.rs

4
src/inventory.rs

@ -57,7 +57,7 @@ impl InventoryView {
let item = &self.inv[self.selected_item];
let mut menu = Vec::new();
// @todo: cloning here might lead to problems later.
// TODO: cloning here might lead to problems later.
// We should probably use a lifetime instead
menu.push(Action::EquipLeft(item.clone()));
menu.push(Action::EquipRight(item.clone()));
@ -97,7 +97,7 @@ impl Render for InventoryView {
for (i, item) in self.inv.iter().enumerate() {
// Set color, based on if the item is selected
let color = match self.selected_item {
// @cleanup: self.detail_menu.is_none gets checked twice in this method
// CLEANUP: self.detail_menu.is_none gets checked twice in this method
j if j == i && self.detail_menu.is_none() => {
ColorPair::new(rltk::BLACK, rltk::WHITE)
}

8
src/main.rs

@ -24,7 +24,7 @@ pub struct State {
loaded_chunks: Box<HashMap<(i32, i32), Chunk>>,
world_pos: (i32, i32),
seed: u64,
// @cleanup: Move to player struct
// CLEANUP: Move to player struct
player_inventory: InventoryView,
player_position: usize,
selected_object: Option<TileType>,
@ -153,7 +153,7 @@ impl GameState for State {
None => {} // Nothing happened
Some(key) => {
// A key is pressed or held
// @cleanup: Move to update trait
// CLEANUP: Move to update trait
match self.mode {
DisplayMode::Game => {
match key {
@ -180,7 +180,7 @@ impl GameState for State {
// Views
VirtualKeyCode::I => {
self.mode = DisplayMode::Inventory;
// @cleanup: This really isn't the right place to reset the inventory view. Also: Cloning!
// CLEANUP: This really isn't the right place to reset the inventory view. Also: Cloning!
self.player_inventory =
InventoryView::new(self.player_inventory.inv.clone())
}
@ -210,7 +210,7 @@ impl GameState for State {
self.select_object(Point::from(mouse_pos));
}
// @cleanup: We shouldn't be cloning the state on each frame
// CLEANUP: We shouldn't be cloning the state on each frame
match self.mode {
DisplayMode::Game => self.view.render(&mut self.clone(), ctx),
DisplayMode::Inventory => self.player_inventory.render(&mut self.clone(), ctx),

2
src/traits.rs

@ -1,6 +1,8 @@
use crate::State;
use rltk::Rltk;
// TODO: Add update trait
pub trait Render {
fn render(&mut self, gs: &mut State, ctx: &mut Rltk);
}

Loading…
Cancel
Save