User Tools

Site Tools


dev:plugin:gui

GUI

Provides basic windowing system classes for the plugin package.

Basic UI Elements

namespace ManiaLivePlugins\eXpansion\Gui\Elements

provides elements: Button, Checkbox, InputBox, Ratiobutton

Button

Public methods:

  • setText, getText, for setting the button label
  • setValue, getValue, for assigning a value for the button
  • setActive, getActive, for blue blink for the borders of the button
  • setAction, inherited from quad –> sets action handler for the button

Usage:

// first create action
$this->actionOK = ActionHandler::getInstance()->createAction(array($this, "Ok"));
 
$button = new myButton();
$button->setText("Ok");
$button->setAction($this->actionOk);
$this->_mainFrame->addComponent($button);

CheckBox

Checkbox has its own action handler build in, basicly you just say if the checkbox is checked or not, user changes its state and onsave you query the current state from the element.

Public methods:

  • setText, getText, set text for checkbox label, label is inserted after checkbox to same row
  • setStatus(bool), getStatus(bool), when status is true, checkbox is checked.
  • setAction, inherited from quad –> sets action handler for the button

Usage:

$xsize = 4;
$ysize = 4;
$textwidth = 40;
 
$checkbox = new checkbox($xsize,$ysize,$textwidth);
$checkbox -> setText("is Server online");
$checkbox -> setStatus(true);
$this->_mainFrame->addComponent($checkbox );

Ratiobutton

Ratiobutton has its own action handler build in, basicly you just say if the ratiobutton is checked or not, user changes its state and onsave you query the current state from the element.

Public methods:

  • setText, getText, set text for checkbox label, label is inserted after checkbox to same row
  • setStatus(bool), getStatus(bool), when status is true, checkbox is checked.
  • setAction, inherited from quad –> sets action handler for the button

Usage:

$xsize = 4;
$ysize = 4;
$textwidth = 40;
 
$ratiobutton = new ratibutton($xsize,$ysize,$textwidth);
$ratiobutton-> setText("is Server online");
$ratiobutton-> setStatus(true);
$this->_mainFrame->addComponent($ratiobutton);

Inputbox

Inputbox is currently implemented for future usage. Currently there is no way to return the value of an inputbox to servercontroller.

Public methods:

  • setText, (getText), set the default value of the element.
  • setLabel, getLabel, set text for inputbox label above the inputbox.

Usage:

$this->minLadder = new Inputbox("ladderMin");
$this->minLadder->setLabel("Ladderpoints minimum");
$this->minLadder->setText($server->ladderServerLimitMin);
$this->frameLadder->addComponent($this->minLadder);

Windows

Provides minimizable and movable window, written in maniascript and manialib.
please use $this→mainFrame→addComponent($component); for adding window content.

Window

namespace whaever;
 
class myWindow extends \ManiaLivePlugins\eXpansion\Gui\Windows\Window {
 
private $actionOK, $buttonOk;
 
  function onConstruct() {
        parent::onConstruct();
   $this->actionOK = ActionHandler::getInstance()->createAction(array($this, "Ok"));
   $this->setTitle('My Window');
 
    $this->buttonOK = new Button();
    $this->buttonOK->setText("Apply");
    $this->buttonOK->setAction($this->actionOK);
    $this->mainFrame->addComponent($this->buttonOK);
 
  }
 
    public function Ok($login) {
        $this->hide();
    }
 
    // remember every time to create the destroy method and call destroy() for custom elements + frames.
    // do also clearComponents() for frames and basic layout to minimize memory leaks.
    function destroy() {
       $this->buttonOk->destroy();
       ActionHandler::getInstance()->deleteAction($this->actionOK);
       $this->clearComponents();
       parent::destroy();
    }
 
    function onResize($oldX, $oldY) {
        parent::onResize($oldX, $oldY);
    }
 
}

Configuration

button = '' 
button active = ''

checkbox = '' 
checkboxActive = '' 

ratiobutton = '' 
ratiobuttonActive = '' 

windowTitleBar = '' 

windowClosebutton = '' 
windowClosebuttonActive = '' 

windowMinbutton = '' 
windowMinbuttonActive = '' 
dev/plugin/gui.txt · Last modified: 2013/07/17 10:08 (external edit)