From fae0c2bfe95a122de0f165791690dc18928a931c Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 14 Nov 2003 17:21:14 +0000 Subject: Started working on widgets. --- src/test.cc | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/test.cc b/src/test.cc index 0ef8a57..91c393b 100644 --- a/src/test.cc +++ b/src/test.cc @@ -3,11 +3,9 @@ #include #include #include -extern "C" { #include #include #include -} #ifdef HAVE_CONFIG_H #include "config.h" #else @@ -18,6 +16,8 @@ extern "C" { #include #include #include +#include +#include #include "glbase.h" #include "texture.h" #include "glfont.h" @@ -25,6 +25,7 @@ extern "C" { #include "engine.h" #include "glsprite.h" #include "glshape.h" +#include "glwidgets.h" #define SPIN .50 #define TILT .20 @@ -273,7 +274,7 @@ CODE_BEGINS void checkluastack(lua_State * L) { int n = lua_gettop(L); - int i; + int i, j; String t; printm(M_INFO, "Inspecting LUA stack\n"); @@ -301,7 +302,16 @@ void checkluastack(lua_State * L) { t.set("(String) %s", lua_tostring(L, i)); break; case LUA_TTABLE: - t.set("(Table)"); + printm(M_INFO, String(i) + ": (Table) Exploring:\n"); + lua_pushnil(L); /* first key */ + j = 0; + while (lua_next(L, -2) != 0) { + /* `key' is at index -2 and `value' at index -1 */ + printm(M_INFO, " %s - %s\n", lua_typename(L, lua_type(L, -2)), + lua_typename(L, lua_type(L, -1))); + lua_pop(L, 1); /* removes `value'; keeps `key' for next iteration */ + } + t = ""; break; case LUA_TFUNCTION: t = "(Function)"; @@ -310,7 +320,8 @@ void checkluastack(lua_State * L) { t = "Unknown"; } - printm(M_INFO, String(i) + ": " + t + "\n"); + if (t != "") + printm(M_INFO, String(i) + ": " + t + "\n"); } } @@ -384,6 +395,7 @@ void initstars() { #ifdef LUA L = lua_open(); luaopen_math(L); + lua_pop(L, 1); lua_atpanic(L, myluaerror); luaL_loadfile(L, "particules.lua"); lua_call(L, 0, 0); @@ -501,7 +513,7 @@ virtual int startup() throw (GeneralException) { verbosity = M_INFO; new Archive("datas.paq"); - bdlload("cl.bdl"); +// bdlload("cl.bdl"); #if 1 mogltk::base * gl = new mogltk::glbase(); @@ -509,18 +521,29 @@ virtual int startup() throw (GeneralException) { mogltk::font * font = new mogltk::glfont(&Input("font-2.bin")); mogltk::Sprite * s = new mogltk::glSprite(&Input("cursor.rgba"), 25, 25); mogltk::Sprite * p = new mogltk::glSprite(&Input("particule.rgba"), 16, 16); + mogltk::widget * w = new mogltk::Root(sh); #else mogltk::base * gl = new mogltk::base(); mogltk::shape * sh = new mogltk::shape(); mogltk::font * font = new mogltk::font(&Input("font-2.bin")); mogltk::Sprite * s = new mogltk::Sprite(&Input("cursor.rgba"), 25, 25); mogltk::Sprite * p = new mogltk::Sprite(&Input("particule.rgba"), 16, 16); + mogltk::widget * w = new mogltk::Root(sh); #endif mogltk::engine::setcursorvisible(true); mogltk::engine::setappactive(true); mogltk::texture * mytex = new mogltk::texture(&Input("pattern6.tex"), true); + + Lua * l = new Lua(); + LuaInput::pushconstruct(l); + LuaOutput::pushconstruct(l); + l->open_math(); + l->declarefunc("print", myprint); + l->load(&Input("particules.lua")); + l->call("testing"); + delete l; Color AlphaBlue(AQUA); AlphaBlue.A = 50; @@ -537,13 +560,15 @@ virtual int startup() throw (GeneralException) { gl->Enter2DMode(); - sh->tbox(mytex, 50, 50, 561, 561, BLACK, RED, LIME, BLUE); + w->fulldraw(); + +/* sh->tbox(mytex, 50, 50, 561, 561, BLACK, RED, LIME, BLUE); */ // sh->box(400, 100, 450, 150, BLACK, RED, LIME, BLUE); // sh->box(5, 5, 150, 80, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY); - mogltk::ColorP::Max.A = 100; +/* mogltk::ColorP::Max.A = 100; sh->box(5, 5, 400, 300, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY); - mogltk::ColorP::Max.A = 255; + mogltk::ColorP::Max.A = 255; */ // font->setshadow(1); // font->putcursor(10, 30); // font->setcolor(WHITE); @@ -573,11 +598,11 @@ virtual int startup() throw (GeneralException) { font->printf("my: %i\n", mogltk::engine::mouseY()); font->printf("t: %.2fs\n", SDL_GetTicks() / 1000.0); - p->draw(mogltk::engine::mouseX() - 8, mogltk::engine::mouseY() - 8); +/* p->draw(mogltk::engine::mouseX() - 8, mogltk::engine::mouseY() - 8); */ s->draw(mogltk::engine::mouseX() - 8, mogltk::engine::mouseY() - 6); // sh->line(320, 240, mogltk::engine::mouseX(), mogltk::engine::mouseY()); - mogltk::ColorP::Min.A = 200; +/* mogltk::ColorP::Min.A = 200; */ // p->draw(sx1, sy1, AlphaBlue); // p->draw(sx2, sy2, AlphaBlue); -- cgit v1.2.3