Changeset 400

Show
Ignore:
Timestamp:
07/21/08 17:19:03 (4 months ago)
Author:
FeepingCreature
Message:
  • Whee
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/qd/SDL_ttf.d

    r369 r400  
    1616 
    1717TTF_FontClass[int] standard; 
    18 void initFont(int size = 14, string name="Vera.ttf") { 
    19   standard[size] = new TTF_FontClass(read(name), size); 
     18void initFont(int size = 14, string name="") { 
     19  void[] data; 
     20  if (name.length) data = name.read(); 
     21  else data = import("Vera.ttf"); 
     22  standard[size] = new TTF_FontClass(data, size); 
    2023} 
    2124 
  • trunk/qd/dsss.conf

    r373 r400  
    22[qd.d] 
    33type=library 
    4 # [dt/main.d] 
    5 # buildflags=-L-lSDL -L-lSDL_ttf -g -O 
    64[test.d] 
    75buildflags=-L-lSDL -g 
    8 [test2.d] 
    9 buildflags=-L-lSDL -L-lSDL_ttf -g 
     6# [test2.d] 
     7# buildflags=-L-lSDL -L-lSDL_ttf -g 
    108[cellular.d] 
    11 buildflags=-L-lSDL -g -J. -O -release -inline -q,-march=nocona 
    12 # buildflags=-L-lSDL -g -J. 
     9buildflags=-L-lSDL -g -J. -O -release -inline 
    1310[SDL_ttf.d] 
    1411type=library 
     12buildflags=-J. 
    1513[primes.d] 
    1614buildflags=-L-lSDL 
    17 # [ff.d] 
    18 # buildflags=-L-lSDL 
    1915[pingtest.d] 
    2016buildflags=-g -L-lSDL -L-lSDL_ttf 
    2117[dgram.d] 
    2218buildflags=-L-lSDL 
    23 # [tetris.d] 
    24 # buildflags=-L-lSDL 
    2519[test11.d] 
    2620buildflags=-L-lSDL -L-lSDL_ttf -g 
    27 # [test12.d] 
    28 # buildflags=-L-lSDL -L-lSDL_ttf -g 
    2921[ff.d] 
    3022buildflags=-L-lSDL -L-lSDL_ttf -O 
    31 # [test13.d] 
    32 # buildflags=-L-lSDL -L-lSDL_ttf -O -release -inline 
    3323[snake.d] 
    3424buildflags=-L-lSDL 
  • trunk/qd/gone.d

    r97 r400  
    5757    auto res=new SuperGoBoard(turn); 
    5858    foreach (id, value; this.tupleof) 
    59       static if (isArray!(typeof(value))) res.tupleof[id]=value.dup; 
     59      static if (is(typeof(value.dup))) res.tupleof[id]=value.dup; 
    6060      else res.tupleof[id]=value; 
    6161    res.conns=conns.dup; 
     
    143143    if (e) line(px-2, py, px-2, py+5); 
    144144    if (f) line(px+2, py, px+2, py+5); 
    145     if (g) line(px-2, py+5, px+2, py+5); 
     145    if (g) line(px+2, py+5, px-2, py+5); 
    146146  } 
    147147  const y=true; 
     
    196196        if (i) { 
    197197          if (cond(j)) board.connect(newPos, columns[dir*i][j]); 
     198          if (cond(j) && (j + 2) in columns[dir*i]) 
     199            board.connect(newPos, columns[dir*i][j+2]); 
    198200          // connect outsides 
    199201          /*if (j==i-size-1) board.connect(newPos, columns[dir*i][j-1]); 
     
    235237      fill=fill~(fill~overlay); 
    236238      circle(x, y, 10, Red, Fill=fill); 
    237       //drawNumber(x, y, id); 
     239      if (board[id]) drawNumber(x, y, board.freedoms(board.group(id))); 
     240      // drawNumber(x, y, id); 
    238241    } 
    239242     
  • trunk/qd/qd.d

    r373 r400  
    11module qd; 
    22import std.c.string, std.math, std.traits: ParameterTypeTuple; 
    3  
    4 uint delegate() qd_rand; 
    5 import std.random; 
    6 static this() { qd_rand = { return rand(); }; } 
    73 
    84import tools.base; 
     
    119115  int SDL_Init(uint flags); 
    120116} 
    121 static this() { SDL_Init(SDL_INIT_VIDEO); } 
     117uint delegate() qd_rand; 
     118import std.random; 
     119static this() { qd_rand = { return rand(); }; SDL_Init(SDL_INIT_VIDEO); } 
    122120 
    123121import std.string: toStringz; 
     
    389387    static if (steep) { 
    390388      if (countUp) { 
    391         putpixel(var2, var1, color.values, 255-alpha); 
    392         if (var2 < display.width) putpixel(var2+1, var1, color.values, alpha); 
     389        putpixel(var2-1, var1, color.values, 255-alpha); 
     390        if (var2 < display.width) putpixel(var2, var1, color.values, alpha); 
    393391      } else { 
    394         putpixel(var2, var1, color.values, alpha); 
    395         if (var2 > 0) putpixel(var2-1, var1, color.values, 255-alpha); 
     392        putpixel(var2+1, var1, color.values, alpha); 
     393        if (var2 > 0) putpixel(var2, var1, color.values, 255-alpha); 
    396394      } 
    397395    } else { 
     
    400398        if (var2 < display.height) putpixel(var1, var2+1, color.values, alpha); 
    401399      } else { 
    402         putpixel(var1, var2, color.values, alpha); 
    403         if (var2 > 0) putpixel(var1, var2-1, color.values, 255-alpha); 
     400        putpixel(var1, var2+1, color.values, alpha); 
     401        if (var2 > 0) putpixel(var1, var2, color.values, 255-alpha); 
    404402      } 
    405403    } 
     
    504502    auto stopy="~(first?"0":"x2square*radius")~"; 
    505503    while (stopx"~(first?">=":"<=")~"stopy) { 
    506       putpixel(cx+x, cy+y, col); 
    507       putpixel(cx+x, cy-y, col); 
    508       putpixel(cx-x, cy+y, col); 
    509       putpixel(cx-x, cy-y, col); 
     504      putpixel(cast(int) (cx+x), cast(int) (cy+y), col); 
     505      putpixel(cast(int) (cx+x), cast(int) (cy-y), col); 
     506      putpixel(cast(int) (cx-x), cast(int) (cy+y), col); 
     507      putpixel(cast(int) (cx-x), cast(int) (cy-y), col); 
    510508      "~yx~"++; 
    511509      stop"~yx~"+="~xy~"2square; 
     
    540538import std.stdio; 
    541539void circle(T...)(T t) { 
    542   static assert(T.length!<3, "Circle: Needs x, y and radius"); 
    543   int cx=cast(int)t[0], cy=cast(int)t[1]; float radius=cast(float)t[2]; 
    544   SDL_LockSurface(display.surface); 
    545   scope(exit) { SDL_UnlockSurface(display.surface); if (doFlip) flip; } 
    546   execParams(t[3..$]); 
    547   if (radius!>0) return; 
    548   static if (T.length>3 && is(T[3]: int)) yradius=t[3]; 
    549   static if (Select!(back_rgb, T) != -1) { 
    550     auto back_sdl=SDL_MapRGBA(display.surface.format, back.values[0], back.values[1], back.values[2], 0); 
    551     for (int i=0; i<=radius; ++i) { 
    552       ushort j=cast(ushort)(sqrt(cast(real)(radius*radius-i*i))); 
    553       hline(cx-j, cy+i, 2*j, back_sdl); 
    554       if (i) hline(cx-j, cy-i, 2*j, back_sdl); 
    555     } 
    556   } 
    557   static if (Select!(back_rgb, T) == -1 || Select!(rgb, T) != -1) { 
    558     auto x2square=2*radius*radius, y2square=x2square; 
    559     uint col=SDL_MapRGBA(display.surface.format, color.values[0], color.values[1], color.values[2], 0); 
    560     { mixin(circle_bresenham_pass!(true).str); } 
    561     { mixin(circle_bresenham_pass!(false).str); } 
    562   } 
    563 } 
    564  
    565 void circle_aa(T...)(T t) { 
    566540  static assert(T.length!<3, "Circle: Needs x, y and radius"); 
    567541  int cx=cast(int)t[0], cy=cast(int)t[1]; float radius=cast(float)t[2]; 
     
    637611} 
    638612 
     613bool opengl_mode; 
    639614 
    640615struct screen { 
     
    647622    } 
    648623    void resize(int w, int h, bool osc = false) { 
     624      if (opengl_mode && !offscreen) { display.width = w; display.height = h; return; } 
    649625      if (display && display.surface && offscreen) SDL_FreeSurface(display.surface); 
    650626      offscreen = osc; 
  • trunk/qd/test2.d

    r369 r400  
    444444   
    445445  list!(Window) windows; 
    446 <<<<<<< .mine 
    447   this() { mouse_sched~=stackthread=&mousethr; } 
    448 ======= 
    449446  // this() { mouse.sched~=stackthread=&mousethr; } 
    450 >>>>>>> .r368 
    451447  void draw() { windows.each((Window w) { w.draw(); }); } 
    452 <<<<<<< .mine 
    453   void mousethr(proc yield) { 
    454     assert(mouse_sched.runsMe); 
    455 ======= 
    456448  /*void mousethr(proc yield) { 
    457449    // assert(mouse.sched.runsMe); 
    458 >>>>>>> .r368 
    459450    enum State { start, title_inside, title_dragging, resize_inside, resize_dragging } 
    460451    pt lastpos;