Previous 199869 Revisions Next

r34474 Sunday 18th January, 2015 at 19:13:11 UTC by Luca Bruno
luaengine: use visible_area for drawing

Drawing and scripts should use the actual visible_area,
not the maximum declared screen size.

Signed-off-by: Luca Bruno <lucab@debian.org>
[src/emu]luaengine.c luaengine.h

trunk/src/emu/luaengine.c
r242985r242986
537537}
538538
539539//-------------------------------------------------
540//  screen_height - return screen visible height
541//  -> manager:machine().screens[":screen"]:height()
542//-------------------------------------------------
543
544int lua_engine::lua_screen::l_height(lua_State *L)
545{
546   screen_device *sc = luabridge::Stack<screen_device *>::get(L, 1);
547   if(!sc) {
548      return 0;
549   }
550
551   lua_pushunsigned(L, sc->visible_area().height());
552   return 1;
553}
554
555//-------------------------------------------------
556//  screen_width - return screen visible width
557//  -> manager:machine().screens[":screen"]:width()
558//-------------------------------------------------
559
560int lua_engine::lua_screen::l_width(lua_State *L)
561{
562   screen_device *sc = luabridge::Stack<screen_device *>::get(L, 1);
563   if(!sc) {
564      return 0;
565   }
566
567   lua_pushunsigned(L, sc->visible_area().width());
568   return 1;
569}
570
571//-------------------------------------------------
540572//  draw_box - draw a box on a screen container
541573//  -> manager:machine().screens[":screen"]:draw_box(x1, y1, x2, y2, bgcolor, linecolor)
542574//-------------------------------------------------
r242985r242986
558590
559591   // retrieve all parameters
560592   float x1, y1, x2, y2;
561   x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f);
562   y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f);
563   x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->width()) , 1.0f);
564   y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->height()), 1.0f);
593   x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->visible_area().width()) , 1.0f);
594   y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->visible_area().height()), 1.0f);
595   x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->visible_area().width()) , 1.0f);
596   y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->visible_area().height()), 1.0f);
565597   UINT32 bgcolor = lua_tounsigned(L, 6);
566598   UINT32 fgcolor = lua_tounsigned(L, 7);
567599
r242985r242986
594626
595627   // retrieve all parameters
596628   float x1, y1, x2, y2;
597   x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f);
598   y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f);
599   x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->width()) , 1.0f);
600   y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->height()), 1.0f);
629   x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->visible_area().width()) , 1.0f);
630   y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->visible_area().height()), 1.0f);
631   x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->visible_area().width()) , 1.0f);
632   y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->visible_area().height()), 1.0f);
601633   UINT32 color = lua_tounsigned(L, 6);
602634
603635   // draw the line
r242985r242986
623655   luaL_argcheck(L, lua_isstring(L, 4), 4, "message (string) expected");
624656
625657   // retrieve all parameters
626   float x = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f);
627   float y = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f);
658   float x = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->visible_area().width()) , 1.0f);
659   float y = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->visible_area().height()), 1.0f);
628660   const char *msg = luaL_checkstring(L,4);
629661   // TODO: add optional parameters (colors, etc.)
630662
r242985r242986
900932            .addCFunction ("draw_box",  &lua_screen::l_draw_box)
901933            .addCFunction ("draw_line", &lua_screen::l_draw_line)
902934            .addCFunction ("draw_text", &lua_screen::l_draw_text)
935            .addCFunction ("height", &lua_screen::l_height)
936            .addCFunction ("width", &lua_screen::l_width)
903937         .endClass()
904938         .deriveClass <screen_device, lua_screen> ("screen_dev")
905939            .addFunction ("name", &screen_device::name)
906940            .addFunction ("shortname", &screen_device::shortname)
907941            .addFunction ("tag", &screen_device::tag)
908            .addFunction ("height", &screen_device::height)
909            .addFunction ("width", &screen_device::width)
910942         .endClass()
911943         .beginClass <device_state_entry> ("dev_space")
912944            .addFunction ("name", &device_state_entry::symbol)
trunk/src/emu/luaengine.h
r242985r242986
115115   };
116116   static luabridge::LuaRef l_machine_get_screens(const running_machine *r);
117117   struct lua_screen {
118      int l_height(lua_State *L);
119      int l_width(lua_State *L);
118120      int l_draw_box(lua_State *L);
119121      int l_draw_line(lua_State *L);
120122      int l_draw_text(lua_State *L);


Previous 199869 Revisions Next


© 1997-2024 The MAME Team