Skip to content

Commit

Permalink
Moved set_window__size to library
Browse files Browse the repository at this point in the history
- Bumped to 0.15.0
  • Loading branch information
bvssvni committed Feb 22, 2018
1 parent 20bec1b commit e3d171f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions interactive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "piston-dyon_interactive"
version = "0.14.0"
version = "0.15.0"
authors = ["Sven Nilsen <bvssvni@gmail.com>"]
description = "A library for interactive coding with the Piston game engine"
keywords = ["script", "scripting", "game", "language", "piston"]
Expand All @@ -16,7 +16,7 @@ version = "0.31.0"
path = ".."

[dependencies]
piston = "0.35.0"
piston = "0.36.0"
current = "0.1.2"
piston-texture = "0.6.0"
image = "0.18.0"
Expand All @@ -26,6 +26,6 @@ version = "0.25.0"
features = ["glyph_cache_rusttype"]

[dev-dependencies]
pistoncore-sdl2_window = "0.48.0"
pistoncore-sdl2_window = "0.49.1"
piston2d-opengl_graphics = "0.51.0"
piston-music = "0.24.0"
13 changes: 0 additions & 13 deletions interactive/examples/dyongame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ fn load_module(file: &str) -> Option<Module> {
tys: vec![Type::array()],
ret: Type::Void
});
module.add(Arc::new("set_window__size".into()), set_window__size, Dfn {
lts: vec![Lt::Default],
tys: vec![Type::Vec4],
ret: Type::Void
});
module.add(Arc::new("next_event".into()),
next_event, Dfn {
lts: vec![],
Expand Down Expand Up @@ -281,14 +276,6 @@ mod dyon_functions {
Ok(())
}

#[allow(non_snake_case)]
pub fn set_window__size(rt: &mut Runtime) -> Result<(), String> {
let window = unsafe { &mut *Current::<Sdl2Window>::new() };
let size: [f32; 2] = rt.pop_vec4()?;
let _ = window.window.set_size(size[0] as u32, size[1] as u32);
Ok(())
}

pub fn next_event(rt: &mut Runtime) -> Result<(), String> {
let window = unsafe { &mut *Current::<Sdl2Window>::new() };
let events = unsafe { &mut *Current::<Events>::new() };
Expand Down
13 changes: 13 additions & 0 deletions interactive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ pub fn add_functions<W, F, C>(module: &mut Module)
tys: vec![],
ret: Type::Vec4
});
module.add(Arc::new("set_window__size".into()), set_window__size::<W>, Dfn {
lts: vec![Lt::Default],
tys: vec![Type::Vec4],
ret: Type::Void
});
module.add(Arc::new("window_draw_size".into()), window_draw_size::<W>, Dfn {
lts: vec![],
tys: vec![],
Expand Down Expand Up @@ -339,6 +344,14 @@ pub fn window_draw_size<W: Any + Window>(rt: &mut Runtime) -> Result<(), String>
Ok(())
}

#[allow(non_snake_case)]
pub fn set_window__size<W: Any + AdvancedWindow>(rt: &mut Runtime) -> Result<(), String> {
let size: [f32; 2] = rt.pop_vec4()?;
let size: [u32; 2] = [size[0] as u32, size[1] as u32];
unsafe { Current::<W>::new() }.set_size(size);
Ok(())
}

pub fn window_position<W: Any + AdvancedWindow>(rt: &mut Runtime) -> Result<(), String> {
if let Some(pos) = unsafe { Current::<W>::new() }.get_position() {
rt.push_vec4([pos.x as f32, pos.y as f32]);
Expand Down

0 comments on commit e3d171f

Please sign in to comment.