Skip to content
This repository has been archived by the owner on Jan 23, 2018. It is now read-only.

Commit

Permalink
Make all mod.rs files only contain mod declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaeroxe committed Mar 18, 2017
1 parent e260189 commit 01c60bf
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 44 deletions.
9 changes: 9 additions & 0 deletions nitro/src/component/component.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use Canvas;
use app::App;
use game_object::GameObject;
use component::Message;

pub trait Component {
fn receive_message(&mut self, app: &mut App, game_object: &mut GameObject, message: &Message);
fn render_gui(&self, canvas: &mut Canvas, game_object: &GameObject);
}
20 changes: 20 additions & 0 deletions nitro/src/component/component_any.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::any::Any;
use component::Component;

pub trait ComponentAny: Component + Any {
fn as_any(&self) -> &Any;
fn as_any_mut(&mut self) -> &mut Any;
}

impl<T> ComponentAny for T
where T: Component + Any
{
fn as_any(&self) -> &Any {
self
}

fn as_any_mut(&mut self) -> &mut Any {
self
}
}

9 changes: 9 additions & 0 deletions nitro/src/component/message.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use std::any::Any;

pub enum Message {
Start { key: i32 },
Update { delta_time: f32 },
OnDestroy,
OnDetach,
UserMessage(Box<Any>),
}
38 changes: 6 additions & 32 deletions nitro/src/component/mod.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,8 @@
use Canvas;
use app::App;
use game_object::GameObject;
use std::any::Any;
mod message;
pub use self::message::Message;

pub trait Component {
fn receive_message(&mut self, app: &mut App, game_object: &mut GameObject, message: &Message);
fn render_gui(&self, canvas: &mut Canvas, game_object: &GameObject);
}
mod component;
pub use self::component::Component;

pub trait ComponentAny: Component + Any {
fn as_any(&self) -> &Any;
fn as_any_mut(&mut self) -> &mut Any;
}

impl<T> ComponentAny for T
where T: Component + Any
{
fn as_any(&self) -> &Any {
self
}

fn as_any_mut(&mut self) -> &mut Any {
self
}
}

pub enum Message {
Start { key: i32 },
Update { delta_time: f32 },
OnDestroy,
OnDetach,
UserMessage(Box<Any>),
}
mod component_any;
pub use self::component_any::ComponentAny;
9 changes: 2 additions & 7 deletions nitro/src/graphics_private/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
pub mod texture;
pub mod sprite_sheet;

use self::texture::Texture;
use self::sprite_sheet::SpriteSheet;
pub enum Sprite {
Texture(Texture),
SpriteSheet(SpriteSheet),
}
mod sprite;
pub use self::sprite::Sprite;
7 changes: 7 additions & 0 deletions nitro/src/graphics_private/sprite.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use graphics::Texture;
use graphics::SpriteSheet;

pub enum Sprite {
Texture(Texture),
SpriteSheet(SpriteSheet),
}
8 changes: 8 additions & 0 deletions nitro/src/input_private/button.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use input::keyboard::Key;
use input::mouse::MouseButton;

#[derive(Eq, PartialEq, Copy, Clone, Debug, Serialize, Deserialize)]
pub enum Button {
Keyboard(Key),
Mouse(MouseButton),
}
7 changes: 2 additions & 5 deletions nitro/src/input_private/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ pub mod input;
pub mod keyboard;
pub mod mouse;

#[derive(Eq, PartialEq, Copy, Clone, Debug, Serialize, Deserialize)]
pub enum Button {
Keyboard(self::keyboard::Key),
Mouse(self::mouse::MouseButton),
}
mod button;
pub use self::button::Button;

0 comments on commit 01c60bf

Please sign in to comment.