All pastes #909829 Raw Edit

Something

public text v1 · immutable
·published 2008-02-19 15:28 UTC
rendered paste body
menu * {
  Patience:p.start
}

alias p.start {
  drawpic -c
  if (!$window(@Patience)) window -aCdpk0 +d @Patience 0 0 589 391

  if ($hget(p)) hdel -w p *

  var %cards 1 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 11.1 12.1 13. $+ $&
    2 1.2 2.2 3.2 4.2 5.2 6.2 7.2 8.2 9.2 10.2 11.2 12.2 13. $+ $&
    3 1.3 2.3 3.3 4.3 5.3 6.3 7.3 8.3 9.3 10.3 11.3 12.3 13. $+ $&
    4 1.4 2.4 3.4 4.4 5.4 6.4 7.4 8.4 9.4 10.4 11.4 12.4 13,%7 7,%6 6,%5 5,%4 4,%3 3,%2 2,%1 1,%c 7

  while (%c) {
    while ($(,% $+ %c)) {
      var %card $gettok(%cards,$r(1,$numtok(%cards,46)),46),%cards $remtok(%cards,%card,1,46)
      hadd -m p %c $addtok($hget(p,%c),$iif($(,% $+ %c) == 1,a:) $+ %card,46)
      dec % $+ %c
    }
    dec %c
  }

  p.restore

  ;dll $qt($scriptdirmouseevents.dll) hidemouse NA
}

alias p.restore {
  drawpic -cn @Patience 0 0 $qt($scriptdirbg.png)
  drawpic -ctn @Patience 4227327 12 6 144 151 71 96 $qt($scriptdirspray.png)
  drawpic -ctn @Patience 4227327 258 6 144 248 71 96 $qt($scriptdirspray.png)
  drawpic -ctn @Patience 4227327 340 6 144 248 71 96 $qt($scriptdirspray.png)
  drawpic -ctn @Patience 4227327 422 6 144 248 71 96 $qt($scriptdirspray.png)
  drawpic -ctn @Patience 4227327 504 6 144 248 71 96 $qt($scriptdirspray.png)
  drawtext -n @Patience 1 arial 11 5 371 New game (F2)   $chr(124)   Close (F9)

  var %c 7
  while (%c) {
    var %d 1
    while ($gettok($hget(p,%c),%d,46)) {
      if (a:* iswm $v1) p.draw $calc(-70+82* %c) $calc(102+7* %d) $mid($v2,3)
      elseif ($mid($gettok($hget(p,%c),%d,46),1,1) isnum) drawpic -ctn @Patience 4227327 $calc(-70+82* %c) $calc(102+7* %d) 144 54 71 96 $qt($scriptdirspray.png)
      inc %d
    }
    dec %c
  }
  var %d 1
  while ($gettok($hget(p,$hget(p,s)),%d,46)) {
    if (s:* iswm $gettok($hget(p,$hget(p,s)),%d,46)) p.draw $calc((-70+82* $hget(p,s)) - $hget(p,mx) + $mouse.x) $calc((102+7* %d) - $hget(p,my) + $mouse.y) $mid($v2,3)
    inc %d
  }
  drawdot @Patience
}

alias p.stop {
  close -@ @Patience
  ;dll $qt($scriptdirmouseevents.dll) showmouse NA
}

menu @Patience {
  sclick:{
    if ($mouse.x isnum 2-89) && ($mouse.y isnum 370-388) p.start
    if ($mouse.x isnum 91-163) && ($mouse.y isnum 370-388) p.stop
    if ($mouse.y isnum 107-369) {
      if ($mouse.x isnum 13-83) var %q 1
      elseif ($mouse.x isnum 95-165) var %q 2
      elseif ($mouse.x isnum 177-247) var %q 3
      elseif ($mouse.x isnum 259-329) var %q 4
      elseif ($mouse.x isnum 341-411) var %q 5
      elseif ($mouse.x isnum 423-493) var %q 6
      elseif ($mouse.x isnum 505-575) var %q 7
      if (%q) && ($calc($mouse.y -105) < $calc(89+7* $numtok($hget(p,%q),46))) {
        var %c $iif($floor($calc(($mouse.y -105)/7)) > $numtok($hget(p,%q),46),$v2,$v1)
        if (a:* iswm $gettok($hget(p,%q),%c,46)) {
          while (%c <= $numtok($hget(p,%q),46)) {
            hadd -m p %q $puttok($hget(p,%q),s: $+ $mid($gettok($hget(p,%q),%c,46),3),%c,46)
            inc %c
          }
          hadd -m p mx $mouse.x
          hadd -m p my $mouse.y
          hadd -m p s %q
          .timerp.drag -m 0 10 p.restore
        }
        elseif (a:* !iswm $gettok($hget(p,%q),$numtok($hget(p,%q),46),46)) {
          ; kaart omdraaien
        }
      }
    }
    p.restore

    echo #Helpopers Mouse clicked at x $+ $mouse.x and y $+ $mouse.y
  }
  uclick:{
    if ($hget(p,s)) {
      if ($mouse.y isnum 107-369) {
        if ($mouse.x isnum 13-83) var %q 1
        elseif ($mouse.x isnum 95-165) var %q 2
        elseif ($mouse.x isnum 177-247) var %q 3
        elseif ($mouse.x isnum 259-329) var %q 4
        elseif ($mouse.x isnum 341-411) var %q 5
        elseif ($mouse.x isnum 423-493) var %q 6
        elseif ($mouse.x isnum 505-575) var %q 7
        $wildtok(4 13.2 3.3 7.2 8.1 9.s:4 3.s:2 6,s:*,1,46)

      }
      var %c 1
      while ($gettok($hget(p,$hget(p,s)),%c,46)) {
        hadd -m p $hget(p,s) $puttok($hget(p,$hget(p,s)),$replace($v1,s:,a:),%c,46)
        inc %c
      }
      hdel p s
      .timerp.drag off
    }
    p.restore
  }
}

on *:KEYDOWN:@Patience:*:{
  if ($keyval == 113) p.start
  if ($keyval == 120) p.stop
}

alias p.draw {
  drawpic -ctn @Patience 4227327 $1 $2 144 345 71 96 $qt($scriptdirspray.png)

  drawpic -ctn @Patience 4227327 $calc($1 -1) $calc($2 +2) $calc(($4 -1)*18) $iif($3 isin 13,0,18) 16 16 $qt($scriptdirspray.png)
  drawpic -ctn @Patience 4227327 $calc($1 -1) $calc($2 +15) $calc(54+ $3 *18) 36 16 16 $qt($scriptdirspray.png)
  drawpic -ctn @Patience 4227327 $calc($1 +55) $calc($2 +64) $calc(54+ $3 *18) 442 16 16 $qt($scriptdirspray.png)
  drawpic -ctn @Patience 4227327 $calc($1 +55) $calc($2 +77) $calc(($4 -1)*18) $iif($3 isin 13,478,460) 16 16 $qt($scriptdirspray.png)

  if ($istok(1 3 5 9,$4,32)) {
    drawpic -ctn @Patience 4227327 $calc($1 +27) $calc($2 +40) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)
  }

  if ($istok(2 3,$4,32)) {
    drawpic -ctn @Patience 4227327 $calc($1 +27) $calc($2 +9) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)
    drawpic -ctn @Patience 4227327 $calc($1 +27) $calc($2 +71) $calc(-18+18* $3) 442 16 16 $qt($scriptdirspray.png)
  }

  if ($istok(4 5 6 7 8 9 10,$4,32)) {
    drawpic -ctn @Patience 4227327 $calc($1 +16) $calc($2 +9) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)
    drawpic -ctn @Patience 4227327 $calc($1 +38) $calc($2 +9) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)
    drawpic -ctn @Patience 4227327 $calc($1 +16) $calc($2 +71) $calc(-18+18* $3) 442 16 16 $qt($scriptdirspray.png)
    drawpic -ctn @Patience 4227327 $calc($1 +38) $calc($2 +71) $calc(-18+18* $3) 442 16 16 $qt($scriptdirspray.png)
  }

  if ($istok(6 7,$4,32)) {
    drawpic -ctn @Patience 4227327 $calc($1 +16) $calc($2 +40) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)
    drawpic -ctn @Patience 4227327 $calc($1 +38) $calc($2 +40) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)

    if ($4 == 7) {
      drawpic -ctn @Patience 4227327 $calc($1 +27) $calc($2 +24) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)
    }
  }

  if ($istok(8 9 10,$4,32)) {
    drawpic -ctn @Patience 4227327 $calc($1 +16) $calc($2 +28) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)
    drawpic -ctn @Patience 4227327 $calc($1 +38) $calc($2 +28) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)
    drawpic -ctn @Patience 4227327 $calc($1 +16) $calc($2 +52) $calc(-18+18* $3) 442 16 16 $qt($scriptdirspray.png)
    drawpic -ctn @Patience 4227327 $calc($1 +38) $calc($2 +52) $calc(-18+18* $3) 442 16 16 $qt($scriptdirspray.png)

    if ($4 == 10) {
      drawpic -ctn @Patience 4227327 $calc($1 +27) $calc($2 +19) $calc(-18+18* $3) 36 16 16 $qt($scriptdirspray.png)
      drawpic -ctn @Patience 4227327 $calc($1 +27) $calc($2 +61) $calc(-18+18* $3) 442 16 16 $qt($scriptdirspray.png)
    }
  }

  if ($4 > 10) {
    drawpic -ctn @Patience 4227327 $calc(12+ $1) $calc(11+ $2) $calc(-528+48* $4) $calc(-21+75* $3) 47 74 $qt($scriptdirspray.png)
  }
}