summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpixel <pixel>2003-11-14 17:21:14 +0000
committerpixel <pixel>2003-11-14 17:21:14 +0000
commitfae0c2bfe95a122de0f165791690dc18928a931c (patch)
tree1f8056a480702d72c4f871ad7375a575510bb7ff /src
parentd7575bef1e530eac004c973b0384a12561f0bb8b (diff)
Started working on widgets.
Diffstat (limited to 'src')
-rw-r--r--src/test.cc47
1 files changed, 36 insertions, 11 deletions
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 <math.h>
#include <SDL.h>
#include <vector>
-extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
-}
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
@@ -18,6 +16,8 @@ extern "C" {
#include <Main.h>
#include <Input.h>
#include <Output.h>
+#include <BLua.h>
+#include <LuaHandle.h>
#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);