The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Allegro GUI php

From Allegro Wiki
Jump to: navigation, search
This article is a stub. Please help Allegro by expanding it.


WTF?

What's the point? Well this could enable Allegro dialogs to run on a Web browser. It would at least allow them to be previewed, for an online database.

CODE

<highlightSyntax language="php"><?php

class Dialog {

  var $proc;  // Items in our shopping cart
  var $x, $y, $w, $h;
  var $fg,$bg;
  var $key, $d1, $d2, $dp, $dp2, $dp3;
  function Dialog($proc) {
     $this->proc = $proc;
  }
  
  function draw($image) {
  imagefilledrectangle($image, $this->x ,  $this->y,
                     $this->x + $this->w -1, $this->y +$this->h -1 ,
                 $this->bg);
  imagerectangle($image, $this->x ,  $this->y,
              $this->x + $this->w -1, $this->y +$this->h -1 ,
              $this->fg);
  
  }

}


function draw_dialog_array($d) {

     $draw_dialog_array= @ imagecreate($d[0]->w, $d[0]->h)
                          or die("Cannot Initialize new GD image stream");
     for $a in $d a$->draw($draw_dialog_array);

}


$im = draw_dialog_array(the_dialog); imagepng($im); imagedestroy($im);


?>

</highlightSyntax>

Parsing XML

PHP5 has excellent XML parsing built in based on expat

Dustin Dettmer has done this in C++ in XUI, but that's dead now.

Do not fear however, he revived the project in DUI. Feel free to rip the XML parser from the script, its only 2 files.