Stubbed out screen functions, not working yet...
Because lua doesn't have the screen, which it gets from the client or
from the mouse. So I need to implement it for mouse because that's the
easiest way. yay.
@@ -4,7 +4,8 @@ use std::fmt::{self, Display, Formatter};
use std::default::Default;
use std::rc::Rc;
use rlua::{self, Table, Lua, UserData, ToLua, Value};
-use super::object::{Object, Objectable};
+use super::object::{Object, Objectable, ObjectBuilder};
+use super::property::Property;
use super::class::{self, Class, ClassBuilder};
#[derive(Clone, Debug)]
@@ -15,20 +16,7 @@ pub struct ScreenState {
pub struct Screen<'lua>(Table<'lua>);
-impl Default for ScreenState {
- fn default() -> Self {
- ScreenState {
- dummy: 0
- }
- }
-}
-
-impl <'lua> Screen<'lua> {
- fn new(lua: &Lua) -> rlua::Result<Object> {
- let class = class::class_setup(lua, "screen")?;
- Ok(Screen::allocate(lua, class)?.build())
- }
-}
+impl_objectable!(Screen, ScreenState);
impl Display for ScreenState {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
@@ -44,6 +32,21 @@ impl <'lua> ToLua<'lua> for Screen<'lua> {
impl UserData for ScreenState {}
+impl Default for ScreenState {
+ fn default() -> Self {
+ ScreenState {
+ dummy: 0
+ }
+ }
+}
+
+impl <'lua> Screen<'lua> {
+ fn new(lua: &Lua) -> rlua::Result<Object> {
+ let class = class::class_setup(lua, "screen")?;
+ Ok(object_setup(lua, Screen::allocate(lua, class)?)?.build())
+ }
+}
+
pub fn init(lua: &Lua) -> rlua::Result<Class> {
method_setup(lua, Class::builder(lua, Some(Rc::new(Screen::new)), None, None)?)?
.save_class("screen")?
@@ -57,4 +60,27 @@ fn method_setup<'lua>(lua: &'lua Lua, builder: ClassBuilder<'lua>) -> rlua::Resu
.method("__call".into(), lua.create_function(dummy))
}
-impl_objectable!(Screen, ScreenState);
+fn object_setup<'lua>(lua: &'lua Lua, builder: ObjectBuilder<'lua>) -> rlua::Result<ObjectBuilder<'lua>> {
+ let table = lua.create_table();
+ // TODO Make sure I'm doing this right...
+ let screen_table = Screen::new(lua)?.to_lua(lua)?;
+ table.set("screen", screen_table)?;
+ builder.add_to_meta(table)?
+ .property(Property::new("screen".into(),
+ // TODO
+ Some(lua.create_function(screen_new)),
+ Some(lua.create_function(get_visible)),
+ Some(lua.create_function(set_visible))))
+}
+
+fn screen_new<'lua>(lua: &'lua Lua, _: ()) -> rlua::Result<()> {
+ unimplemented!()
+}
+
+fn get_visible<'lua>(lua: &'lua Lua, _: ()) -> rlua::Result<()> {
+ unimplemented!()
+}
+
+fn set_visible<'lua>(lua: &'lua Lua, _: ()) -> rlua::Result<()> {
+ unimplemented!()
+}
