Example #1
0
 public function __construct($sprite)
 {
     $lines = explode("\n", $sprite);
     foreach ($lines as $line) {
         $len = mb_strlen(Color::strip($line), "utf8");
         if ($len > $this->width) {
             $this->width = $len;
         }
     }
     foreach ($lines as $line) {
         $this->sprite[] = String::str_pad_unicode($line, $this->width);
         $this->height++;
     }
     return $this;
 }
Example #2
0
 public function windows($title, $msg)
 {
     if (strpos($title, "\n")) {
         throw new Exception("GLI-020 : The title must be on one line", 20);
     }
     $this->title_length = mb_strlen($title, "utf-8");
     //$this->msg = wordwrap($msg, $this->max_default, "\n", true);
     $this->msg = $msg;
     $lines = explode("\n", $this->msg);
     $this->msg_height = count($lines);
     foreach ($lines as $line) {
         $len = mb_strlen($line, "utf-8");
         if ($len > $this->msg_width) {
             $this->msg_width = $len;
         }
     }
     $this->msg_width += 6;
     $this->borderTop($title);
     $i = 0;
     foreach ($lines as $line) {
         $this->borderLeft();
         if ($line === "[[INPUT]]") {
             $cursor = array();
             $cursor['x'] = ($this->max_width - $this->msg_width) / 2 + 4;
             $cursor['y'] = ceil(($this->max_height - $this->msg_height) / 2) + $i;
             $this->cursor_position_input[] = $cursor;
             $this->windows .= Color::getColoredString(str_pad(" ", $this->msg_width - 6), $this->color_foreground_msg, $this->color_cursor);
             //$this->position_input = $i;
         } else {
             $this->windows .= Color::getColoredString(String::str_pad_unicode($line, Color::strip($this->msg_width) - 6), $this->color_foreground_msg, $this->color_window);
             //$this->windows .= Color::getColoredString(str_pad($line, mb_strlen(Color::strip($this->msg_width) - 6)-strlen($this->msg_width) ), $this->color_foreground_msg, $this->color_window);
         }
         $this->borderRight();
         $i++;
     }
     $this->position_input2 = $i - $this->position_input;
     $this->borderBottom();
     debug($this);
     return $this->encapsulate();
 }