From 7338b38e4ac8ae7c01a3e7d736a342542ce129db Mon Sep 17 00:00:00 2001 From: rodri Date: Tue, 16 Jun 2020 17:17:57 +0000 Subject: added debugging stats. more hud changes. --- dat.h | 5 ++++- hud.c | 12 ++++++++++++ main.c | 25 +++++++++++++++++++++++++ mkfile | 1 + puppeteer.png | Bin 0 -> 7441 bytes readme.md | 4 ++++ 6 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 hud.c create mode 100644 puppeteer.png diff --git a/dat.h b/dat.h index 8e42349..352a394 100644 --- a/dat.h +++ b/dat.h @@ -35,12 +35,15 @@ struct HUD { Point2 p; HUDWidget *widgets; + + void (*addwidget)(HUD*, Point2, char*, ...); }; struct HUDWidget { Point2 p; char *fmt; - va_arg va; + void *args; + int nargs; HUDWidget *next; }; diff --git a/hud.c b/hud.c new file mode 100644 index 0000000..b1084c7 --- /dev/null +++ b/hud.c @@ -0,0 +1,12 @@ +#include +#include +#include +#include +#include "dat.h" +#include "fns.h" + +HUD* +newhud() +{ + return nil; +} diff --git a/main.c b/main.c index 3d5d8b5..902ac8f 100644 --- a/main.c +++ b/main.c @@ -8,6 +8,11 @@ #include "dat.h" #include "fns.h" +enum { + SMPOS, + NSTAT +}; + RFrame worldrf; Image *background; Canvas *curcanvas; @@ -15,6 +20,8 @@ Image *brushcolor; Image *pal[NCOLOR]; int zoom = 1; +char stats[NSTAT][256]; + void resized(void); Point @@ -56,6 +63,16 @@ mkcheckerboard(int w, int h) return i; } +void +drawstats(void) +{ + int i; + Point o; + + for(i = 0, o = Pt(10,10); i < nelem(stats); i++, o.y += font->height) + stringn(screen, addpt(screen->r.min, o), pal[PCWhite], ZP, font, stats[i], sizeof stats[i]); +} + void drawlayer(Layer *l, Canvas *c) { @@ -81,6 +98,7 @@ redraw(void) draw(screen, screen->r, pal[PCBlack], nil, ZP); draw(screen, curcanvas == nil? screen->r: rectaddpt(curcanvas->image->r, toscreen(curcanvas->p)), background, nil, ZP); drawcanvas(curcanvas); + drawstats(); flushimage(display, 1); unlockdisplay(display); } @@ -154,6 +172,7 @@ rmb(Mousectl *mc, Keyboardctl *kc) chan = strtochan(s); cpos = Pt2(Dx(screen->r)/2 - w/2,Dy(screen->r)/2 - h/2,1); curcanvas = newcanvas("default", cpos, Rect(0,0,w,h), chan); + addlayer(curcanvas, "layer #1"); break; case NEWLAYER: if(curcanvas == nil) @@ -254,6 +273,11 @@ lmb(Mousectl *mc, Keyboardctl *) void mouse(Mousectl *mc, Keyboardctl *kc) { + if(curcanvas == nil) + snprint(stats[SMPOS], sizeof stats[SMPOS], "%v", fromscreen(mc->xy)); + else + snprint(stats[SMPOS], sizeof stats[SMPOS], "%v", rframexform(fromscreen(mc->xy), *curcanvas)); + if((mc->buttons&1) != 0) lmb(mc, kc); if((mc->buttons&2) != 0) @@ -296,6 +320,7 @@ threadmain(int argc, char *argv[]) Keyboardctl *kc; Rune r; + GEOMfmtinstall(); ARGBEGIN{ default: usage(); }ARGEND; diff --git a/mkfile b/mkfile index 5fa680c..4072486 100644 --- a/mkfile +++ b/mkfile @@ -4,6 +4,7 @@ BIN=/$objtype/bin TARG=puppeteer OFILES=\ utils.$O\ + hud.$O\ alloc.$O\ layer.$O\ canvas.$O\ diff --git a/puppeteer.png b/puppeteer.png new file mode 100644 index 0000000..247c135 Binary files /dev/null and b/puppeteer.png differ diff --git a/readme.md b/readme.md index 7f51b4a..0383015 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,7 @@ # Puppeteer +![A demo screenshot](puppeteer.png) + A 2D drawing and animation suite. + +It's currently a work in progress and subject to radical changes. -- cgit v1.2.3