2013-12-31 11:19:19 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Script;
|
|
|
|
|
|
|
|
use FML\Controls\Control;
|
|
|
|
use FML\Controls\Label;
|
2014-01-19 19:30:21 +01:00
|
|
|
use FML\Types\Scriptable;
|
2014-01-21 20:30:40 +01:00
|
|
|
use FML\Types\Actionable;
|
2013-12-31 11:19:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class representing the ManiaLink Script
|
|
|
|
*
|
|
|
|
* @author steeffeen
|
|
|
|
*/
|
|
|
|
class Script {
|
2014-01-21 20:30:40 +01:00
|
|
|
/*
|
2013-12-31 11:19:19 +01:00
|
|
|
* Constants
|
|
|
|
*/
|
2014-01-12 00:51:46 +01:00
|
|
|
const CLASS_TOOLTIP = 'FML_Tooltip';
|
2014-01-03 17:18:14 +01:00
|
|
|
const CLASS_MENU = 'FML_Menu';
|
|
|
|
const CLASS_MENUBUTTON = 'FML_MenuButton';
|
|
|
|
const CLASS_PAGE = 'FML_Page';
|
|
|
|
const CLASS_PAGER = 'FML_Pager';
|
|
|
|
const CLASS_PAGELABEL = 'FML_PageLabel';
|
|
|
|
const CLASS_PROFILE = 'FML_Profile';
|
|
|
|
const CLASS_MAPINFO = 'FML_MapInfo';
|
2014-01-05 16:04:55 +01:00
|
|
|
const CLASS_SOUND = 'FML_Sound';
|
2014-01-05 17:19:44 +01:00
|
|
|
const CLASS_TOGGLE = 'FML_Toggle';
|
2014-01-12 00:51:46 +01:00
|
|
|
const CLASS_SPECTATE = 'FML_Spectate';
|
2014-01-21 20:30:40 +01:00
|
|
|
const CLASS_PAGEACTION = 'FML_PageAction';
|
2014-02-16 13:59:28 +01:00
|
|
|
const CLASS_TIME = 'FML_Time';
|
2014-01-12 00:51:46 +01:00
|
|
|
const OPTION_TOOLTIP_STAYONCLICK = 'FML_StayOnClick_Tooltip';
|
|
|
|
const OPTION_TOOLTIP_INVERT = 'FML_Invert_Tooltip';
|
|
|
|
const OPTION_TOOLTIP_TEXT = 'FML_Text_Tooltip';
|
|
|
|
const OPTION_TOGGLE_SHOW = 'FML_Show_Toggle';
|
|
|
|
const OPTION_TOGGLE_HIDE = 'FML_Hide_Toggle';
|
2014-01-19 19:30:21 +01:00
|
|
|
const OPTION_PROFILE_OWN = 'FML_Own_Profile';
|
2014-02-16 13:59:28 +01:00
|
|
|
const OPTION_TIME_FULLDATE = 'FML_FullDate_Time';
|
2014-01-03 17:18:14 +01:00
|
|
|
const LABEL_ONINIT = 'OnInit';
|
|
|
|
const LABEL_LOOP = 'Loop';
|
2014-02-16 13:59:28 +01:00
|
|
|
const LABEL_TICK = 'Tick';
|
2014-01-03 17:18:14 +01:00
|
|
|
const LABEL_ENTRYSUBMIT = 'EntrySubmit';
|
|
|
|
const LABEL_KEYPRESS = 'KeyPress';
|
|
|
|
const LABEL_MOUSECLICK = 'MouseClick';
|
|
|
|
const LABEL_MOUSEOUT = 'MouseOut';
|
|
|
|
const LABEL_MOUSEOVER = 'MouseOver';
|
|
|
|
const CONSTANT_TOOLTIPTEXTS = 'C_FML_TooltipTexts';
|
2014-01-12 00:51:46 +01:00
|
|
|
const FUNCTION_GETTOOLTIPCONTROLID = 'FML_GetTooltipControlId';
|
2014-01-03 17:18:14 +01:00
|
|
|
const FUNCTION_SETTOOLTIPTEXT = 'FML_SetTooltipText';
|
2014-01-05 17:19:44 +01:00
|
|
|
const FUNCTION_TOGGLE = 'FML_Toggle';
|
2013-12-31 11:19:19 +01:00
|
|
|
|
2014-01-21 20:30:40 +01:00
|
|
|
/*
|
2013-12-31 11:19:19 +01:00
|
|
|
* Protected Properties
|
|
|
|
*/
|
|
|
|
protected $tagName = 'script';
|
|
|
|
protected $includes = array();
|
2014-01-03 17:18:14 +01:00
|
|
|
protected $constants = array();
|
|
|
|
protected $functions = array();
|
2013-12-31 11:19:19 +01:00
|
|
|
protected $tooltips = false;
|
2014-01-03 17:18:14 +01:00
|
|
|
protected $tooltipTexts = array();
|
2013-12-31 11:19:19 +01:00
|
|
|
protected $menus = false;
|
|
|
|
protected $pages = false;
|
|
|
|
protected $profile = false;
|
|
|
|
protected $mapInfo = false;
|
2014-01-05 16:04:55 +01:00
|
|
|
protected $sounds = array();
|
2014-01-05 17:19:44 +01:00
|
|
|
protected $toggles = false;
|
2014-01-12 00:51:46 +01:00
|
|
|
protected $spectate = false;
|
2014-01-21 20:30:40 +01:00
|
|
|
protected $pageActions = false;
|
2014-02-16 13:59:28 +01:00
|
|
|
protected $times = false;
|
2013-12-31 11:19:19 +01:00
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
|
|
|
* Create a new Script Object
|
|
|
|
*
|
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public static function create() {
|
|
|
|
$script = new Script();
|
|
|
|
return $script;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a new Script Object
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
}
|
|
|
|
|
2013-12-31 11:19:19 +01:00
|
|
|
/**
|
2014-01-03 17:18:14 +01:00
|
|
|
* Set an Include of the Script
|
2013-12-31 11:19:19 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $namespace Namespace used for the Include
|
|
|
|
* @param string $file Included File Url
|
2013-12-31 11:19:19 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
2014-01-03 17:18:14 +01:00
|
|
|
public function setInclude($namespace, $file) {
|
2013-12-31 11:19:19 +01:00
|
|
|
$this->includes[$namespace] = $file;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-03 17:18:14 +01:00
|
|
|
/**
|
|
|
|
* Set a Constant of the Script
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $name Variable Name of the Constant
|
|
|
|
* @param string $value Constant Value
|
2014-01-03 17:18:14 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function setConstant($name, $value) {
|
|
|
|
$this->constants[$name] = $value;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a Function of the Script
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $name Function Name
|
|
|
|
* @param string $coding Complete Function Implementation including Declaration
|
2014-01-03 17:18:14 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function setFunction($name, $coding) {
|
|
|
|
$this->functions[$name] = $coding;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-12-31 11:19:19 +01:00
|
|
|
/**
|
|
|
|
* Add a Tooltip Behavior
|
|
|
|
*
|
2014-01-03 17:18:14 +01:00
|
|
|
* @param Control $hoverControl The Control that shows the Tooltip
|
|
|
|
* @param Control $tooltipControl The Tooltip to display
|
|
|
|
* @param string $options,... (optional) Unlimited Number of Tooltip Options
|
2013-12-31 11:19:19 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function addTooltip(Control $hoverControl, Control $tooltipControl) {
|
|
|
|
if (!($hoverControl instanceof Scriptable)) {
|
|
|
|
trigger_error('Scriptable Control needed as HoverControl for Tooltips!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
$tooltipControl->checkId();
|
|
|
|
$tooltipControl->setVisible(false);
|
2014-01-03 17:18:14 +01:00
|
|
|
$hoverControl->checkId();
|
2013-12-31 11:19:19 +01:00
|
|
|
$hoverControl->setScriptEvents(true);
|
2014-01-12 00:51:46 +01:00
|
|
|
$hoverControl->addClass(self::CLASS_TOOLTIP);
|
|
|
|
$hoverControl->addClass(self::CLASS_TOOLTIP . '-' . $tooltipControl->getId());
|
2014-01-03 17:18:14 +01:00
|
|
|
$options = $this->spliceParameters(func_get_args(), 2);
|
|
|
|
foreach ($options as $option => $value) {
|
|
|
|
if ($option == self::OPTION_TOOLTIP_TEXT) {
|
|
|
|
if (!($tooltipControl instanceof Label)) {
|
|
|
|
trigger_error('Label needed for Tooltip Text Option!');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$hoverId = $hoverControl->getId();
|
|
|
|
$tooltipId = $tooltipControl->getId();
|
|
|
|
if (!isset($this->tooltipTexts[$tooltipId])) {
|
|
|
|
$this->tooltipTexts[$tooltipId] = array();
|
|
|
|
}
|
|
|
|
$this->tooltipTexts[$tooltipId][$hoverId] = $value;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($option == self::OPTION_TOOLTIP_INVERT) {
|
|
|
|
$tooltipControl->setVisible(true);
|
|
|
|
}
|
|
|
|
$hoverControl->addClass($option);
|
|
|
|
}
|
2013-12-31 11:19:19 +01:00
|
|
|
$this->tooltips = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a Menu Behavior
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param Control $clickControl The Control showing the Menu
|
|
|
|
* @param Control $menuControl The Menu to show
|
|
|
|
* @param string $menuId (optional) An identifier to specify the Menu Group
|
2013-12-31 11:19:19 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function addMenu(Control $clickControl, Control $menuControl, $menuId = null) {
|
|
|
|
if (!($clickControl instanceof Scriptable)) {
|
|
|
|
trigger_error('Scriptable Control needed as ClickControl for Menus!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
if (!$menuId) $menuId = '_';
|
|
|
|
$menuControl->checkId();
|
|
|
|
$menuControl->addClass(self::CLASS_MENU);
|
|
|
|
$menuControl->addClass($menuId);
|
|
|
|
$clickControl->setScriptEvents(true);
|
|
|
|
$clickControl->addClass(self::CLASS_MENUBUTTON);
|
|
|
|
$clickControl->addClass($menuId . '-' . $menuControl->getId());
|
|
|
|
$this->menus = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a Page for a Paging Behavior
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param Control $pageControl The Page to display
|
|
|
|
* @param int $pageNumber The Number of the Page
|
|
|
|
* @param string $pagesId (optional) An identifier to specify the Pages Group
|
2013-12-31 11:19:19 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function addPage(Control $pageControl, $pageNumber, $pagesId = null) {
|
|
|
|
$pageNumber = (int) $pageNumber;
|
|
|
|
if (!$pagesId) $pagesId = '_';
|
|
|
|
$pageControl->addClass(self::CLASS_PAGE);
|
|
|
|
$pageControl->addClass($pagesId);
|
|
|
|
$pageControl->addClass(self::CLASS_PAGE . '-P' . $pageNumber);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a Pager Button for a Paging Behavior
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param Control $pagerControl The Control to leaf through the Pages
|
|
|
|
* @param int $pagingAction The Number of Pages the Pager leafs
|
|
|
|
* @param string $pagesId (optional) An identifier to specify the Pages Group
|
2013-12-31 11:19:19 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function addPager(Control $pagerControl, $pagingAction, $pagesId = null) {
|
|
|
|
if (!($pagerControl instanceof Scriptable)) {
|
|
|
|
trigger_error('Scriptable Control needed as PagerControl for Pages!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
$pagingAction = (int) $pagingAction;
|
|
|
|
if (!$pagesId) $pagesId = '_';
|
|
|
|
$pagerControl->setScriptEvents(true);
|
|
|
|
$pagerControl->addClass(self::CLASS_PAGER);
|
|
|
|
$pagerControl->addClass(self::CLASS_PAGER . '-I' . $pagesId);
|
|
|
|
$pagerControl->addClass(self::CLASS_PAGER . '-A' . $pagingAction);
|
|
|
|
$this->pages = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a Label that shows the current Page Number
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param Label $pageLabel The Label showing the Number of the currently displayed Page
|
2014-01-03 17:18:14 +01:00
|
|
|
* @param string $pagesId
|
2013-12-31 11:19:19 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function addPageLabel(Label $pageLabel, $pagesId = null) {
|
|
|
|
if (!$pagesId) $pagesId = '_';
|
|
|
|
$pageLabel->addClass(self::CLASS_PAGELABEL);
|
|
|
|
$pageLabel->addClass($pagesId);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a Button Behavior that will open the Built-In Player Profile
|
2014-01-12 00:51:46 +01:00
|
|
|
* (Works only for Server ManiaLinks)
|
2013-12-31 11:19:19 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param Control $profileControl The Control opening a Profile
|
|
|
|
* @param string $playerLogin The Player Login
|
2014-01-19 19:30:21 +01:00
|
|
|
* @param string $options,... (optional) Unlimited Number of Profile Options
|
2013-12-31 11:19:19 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function addProfileButton(Control $profileControl, $playerLogin) {
|
|
|
|
if (!($profileControl instanceof Scriptable)) {
|
|
|
|
trigger_error('Scriptable Control needed as ClickControl for Profiles!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
$profileControl->setScriptEvents(true);
|
|
|
|
$profileControl->addClass(self::CLASS_PROFILE);
|
2014-01-12 00:51:46 +01:00
|
|
|
$playerLogin = (string) $playerLogin;
|
|
|
|
$profileControl->addClass(self::CLASS_PROFILE . '-' . $playerLogin);
|
2014-01-19 19:30:21 +01:00
|
|
|
$options = $this->spliceParameters(func_get_args(), 2);
|
|
|
|
foreach ($options as $option => $value) {
|
|
|
|
$profileControl->addClass($option);
|
|
|
|
}
|
2013-12-31 11:19:19 +01:00
|
|
|
$this->profile = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a Button Behavior that will open the Built-In Map Info
|
2014-01-12 00:51:46 +01:00
|
|
|
* (Works only on a Server)
|
2013-12-31 11:19:19 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param Control $mapInfoControl The Control opening the Map Info
|
2013-12-31 11:19:19 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function addMapInfoButton(Control $mapInfoControl) {
|
|
|
|
if (!($mapInfoControl instanceof Scriptable)) {
|
|
|
|
trigger_error('Scriptable Control needed as ClickControl for Map Info!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
$mapInfoControl->setScriptEvents(true);
|
|
|
|
$mapInfoControl->addClass(self::CLASS_MAPINFO);
|
|
|
|
$this->mapInfo = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-05 16:04:55 +01:00
|
|
|
/**
|
|
|
|
* Add a Sound Playing for the Control
|
2014-01-12 00:51:46 +01:00
|
|
|
* (Works only for Server ManiaLinks)
|
2014-01-05 16:04:55 +01:00
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param Control $control The Control playing a Sound
|
|
|
|
* @param string $soundName The Sound to play
|
|
|
|
* @param int $soundVariant (optional) Sound Variant
|
|
|
|
* @param float $soundVolume (optional) Sound Volume
|
|
|
|
* @param string $eventLabel (optional) The Event Label on which the Sound should be played
|
2014-01-05 16:04:55 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
2014-01-05 17:19:44 +01:00
|
|
|
public function addSound(Control $control, $soundName, $soundVariant = 0, $soundVolume = 1., $eventLabel = self::LABEL_MOUSECLICK) {
|
2014-01-05 16:04:55 +01:00
|
|
|
if (!($control instanceof Scriptable)) {
|
|
|
|
trigger_error('Scriptable Control needed as ClickControl for Sounds!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
$control->setScriptEvents(true);
|
|
|
|
$control->checkId();
|
|
|
|
$control->addClass(self::CLASS_SOUND);
|
|
|
|
$soundData = array();
|
2014-01-05 17:19:44 +01:00
|
|
|
$soundData['soundName'] = $soundName;
|
|
|
|
$soundData['soundVariant'] = $soundVariant;
|
|
|
|
$soundData['soundVolume'] = $soundVolume;
|
|
|
|
$soundData['controlId'] = $control->getId();
|
|
|
|
$soundData['eventLabel'] = $eventLabel;
|
2014-01-05 16:04:55 +01:00
|
|
|
array_push($this->sounds, $soundData);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-05 17:19:44 +01:00
|
|
|
/**
|
|
|
|
* Add a Toggling Behavior
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param Control $clickControl The Control that toggles another Control on Click
|
|
|
|
* @param Control $toggleControl The Control to toggle
|
|
|
|
* @param string $mode (optional) Whether the Visibility should be toggled or only en-/disabled
|
2014-01-05 17:19:44 +01:00
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
2014-01-12 00:51:46 +01:00
|
|
|
public function addToggle(Control $clickControl, Control $toggleControl, $option = null) {
|
2014-01-05 17:19:44 +01:00
|
|
|
if (!($clickControl instanceof Scriptable)) {
|
|
|
|
trigger_error('Scriptable Control needed as ClickControl for Toggles!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
$toggleControl->checkId();
|
2014-01-12 00:51:46 +01:00
|
|
|
if ($option == self::OPTION_TOGGLE_HIDE) {
|
2014-01-05 17:30:19 +01:00
|
|
|
$toggleControl->setVisible(true);
|
2014-01-12 00:51:46 +01:00
|
|
|
$clickControl->addClass($option);
|
2014-01-05 17:30:19 +01:00
|
|
|
}
|
2014-01-12 00:51:46 +01:00
|
|
|
else if ($option == self::OPTION_TOGGLE_SHOW) {
|
2014-01-05 17:30:19 +01:00
|
|
|
$toggleControl->setVisible(false);
|
2014-01-12 00:51:46 +01:00
|
|
|
$clickControl->addClass($option);
|
2014-01-05 17:30:19 +01:00
|
|
|
}
|
2014-01-05 17:19:44 +01:00
|
|
|
$clickControl->setScriptEvents(true);
|
|
|
|
$clickControl->addClass(self::CLASS_TOGGLE);
|
2014-01-12 00:51:46 +01:00
|
|
|
$clickControl->addClass(self::CLASS_TOGGLE . '-' . $toggleControl->getId());
|
2014-01-05 17:19:44 +01:00
|
|
|
$this->toggles = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-12 00:51:46 +01:00
|
|
|
/**
|
|
|
|
* Add a Spectate Button Behavior
|
|
|
|
*
|
|
|
|
* @param Control $clickControl The Control that works as Spectate Button
|
|
|
|
* @param string $spectateTargetLogin The Login of the Player to Spectate
|
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function addSpectateButton(Control $clickControl, $spectateTargetLogin) {
|
2014-01-19 19:30:21 +01:00
|
|
|
// FIXME: current implementation doesn't support logins with dots in them ('nick.name')
|
2014-01-12 00:51:46 +01:00
|
|
|
if (!($clickControl instanceof Scriptable)) {
|
|
|
|
trigger_error('Scriptable Control needed as ClickControl for Spectating!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
$clickControl->setScriptEvents(true);
|
|
|
|
$clickControl->addClass(self::CLASS_SPECTATE);
|
|
|
|
$spectateTargetLogin = (string) $spectateTargetLogin;
|
|
|
|
$clickControl->addClass(self::CLASS_SPECTATE . '-' . $spectateTargetLogin);
|
|
|
|
$this->spectate = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-21 20:30:40 +01:00
|
|
|
/**
|
|
|
|
* Trigger an Action on Control Click
|
|
|
|
*
|
|
|
|
* @param Control $actionControl The Control triggering the Action
|
|
|
|
* @param string $action (optional) The Action to trigger (if empty the Action of the Control will be triggered)
|
2014-02-16 13:59:28 +01:00
|
|
|
* @return \FML\Script\Script
|
2014-01-21 20:30:40 +01:00
|
|
|
*/
|
|
|
|
public function addPageActionTrigger(Control $actionControl, $action = null) {
|
|
|
|
if (!($actionControl instanceof Scriptable)) {
|
|
|
|
trigger_error('Scriptable Control needed as ActionControl for PageActions!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
$action = (string) $action;
|
|
|
|
if (strlen($action) <= 0) {
|
|
|
|
if (!($actionControl instanceof Actionable)) {
|
|
|
|
trigger_error('Either Action or Actionable Control needed for PageActions!');
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
$action = $actionControl->getAction();
|
|
|
|
}
|
|
|
|
$actionControl->setScriptEvents(true);
|
|
|
|
$actionControl->setAction('');
|
|
|
|
$actionControl->addClass(self::CLASS_PAGEACTION);
|
|
|
|
$actionControl->addClass(self::CLASS_PAGEACTION . '-' . $action);
|
|
|
|
$this->pageActions = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-02-16 13:59:28 +01:00
|
|
|
/**
|
|
|
|
* Add a Label showing the current Time
|
|
|
|
*
|
|
|
|
* @param Label $timeLabel The Label showing the current Time
|
|
|
|
* @param bool $showFullDate Whether to show the full Date Text
|
|
|
|
* @return \FML\Script\Script
|
|
|
|
*/
|
|
|
|
public function addTimeLabel(Label $timeLabel, $showFullDate = false) {
|
|
|
|
$timeLabel->addClass(self::CLASS_TIME);
|
|
|
|
if ($showFullDate) {
|
|
|
|
$timeLabel->addClass(self::OPTION_TIME_FULLDATE);
|
|
|
|
}
|
|
|
|
$this->times = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-12-31 11:19:19 +01:00
|
|
|
/**
|
|
|
|
* Create the Script XML Tag
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param \DOMDocument $domDocument DOMDocument for which the XML Element should be created
|
2013-12-31 11:19:19 +01:00
|
|
|
* @return \DOMElement
|
|
|
|
*/
|
|
|
|
public function render(\DOMDocument $domDocument) {
|
|
|
|
$scriptXml = $domDocument->createElement($this->tagName);
|
|
|
|
$scriptText = $this->buildScriptText();
|
|
|
|
$scriptComment = $domDocument->createComment($scriptText);
|
|
|
|
$scriptXml->appendChild($scriptComment);
|
|
|
|
return $scriptXml;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the complete Script Text
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function buildScriptText() {
|
2014-01-12 01:49:43 +01:00
|
|
|
$mainFunction = $this->getMainFunction();
|
|
|
|
$labels = $this->getLabels();
|
|
|
|
$functions = $this->getFunctions();
|
|
|
|
$constants = $this->getConstants();
|
|
|
|
$includes = $this->getIncludes();
|
|
|
|
$headerComment = $this->getHeaderComment();
|
|
|
|
|
|
|
|
$scriptText = PHP_EOL;
|
|
|
|
$scriptText .= $headerComment;
|
|
|
|
$scriptText .= $includes;
|
|
|
|
$scriptText .= $constants;
|
|
|
|
$scriptText .= $functions;
|
|
|
|
$scriptText .= $labels;
|
|
|
|
$scriptText .= $mainFunction;
|
|
|
|
|
2013-12-31 11:19:19 +01:00
|
|
|
return $scriptText;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Header Comment
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getHeaderComment() {
|
|
|
|
$headerComment = file_get_contents(__DIR__ . '/Parts/Header.txt');
|
|
|
|
return $headerComment;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Includes
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getIncludes() {
|
|
|
|
$includesText = PHP_EOL;
|
|
|
|
foreach ($this->includes as $namespace => $file) {
|
|
|
|
$includesText .= "#Include \"{$file}\" as {$namespace}" . PHP_EOL;
|
|
|
|
}
|
|
|
|
return $includesText;
|
|
|
|
}
|
|
|
|
|
2014-01-03 17:18:14 +01:00
|
|
|
/**
|
|
|
|
* Get the Constants
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getConstants() {
|
|
|
|
$this->buildTooltipConstants();
|
|
|
|
$constantsText = PHP_EOL;
|
|
|
|
foreach ($this->constants as $name => $value) {
|
|
|
|
$constantsText .= "#Const {$name} {$value}" . PHP_EOL;
|
|
|
|
}
|
|
|
|
return $constantsText;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the Constants needed for tooltips
|
|
|
|
*/
|
|
|
|
private function buildTooltipConstants() {
|
|
|
|
if (!$this->tooltips) return;
|
2014-01-03 17:26:55 +01:00
|
|
|
$constantText = '[';
|
2014-01-03 17:18:14 +01:00
|
|
|
$index = 0;
|
|
|
|
$count = count($this->tooltipTexts);
|
2014-01-03 17:26:55 +01:00
|
|
|
if ($count > 0) {
|
|
|
|
foreach ($this->tooltipTexts as $tooltipId => $tooltipTexts) {
|
2014-01-19 19:30:21 +01:00
|
|
|
$constantText .= '"' . Builder::escapeText($tooltipId) . '" => [';
|
2014-01-03 17:26:55 +01:00
|
|
|
$subIndex = 0;
|
|
|
|
$subCount = count($tooltipTexts);
|
|
|
|
if ($subCount > 0) {
|
|
|
|
foreach ($tooltipTexts as $hoverId => $text) {
|
2014-01-19 19:30:21 +01:00
|
|
|
$constantText .= '"' . Builder::escapeText($hoverId) . '" => "' . Builder::escapeText($text) . '"';
|
2014-01-05 16:04:55 +01:00
|
|
|
if ($subIndex < $subCount - 1) $constantText .= ', ';
|
2014-01-03 17:26:55 +01:00
|
|
|
$subIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$constantText .= '""';
|
|
|
|
}
|
|
|
|
$constantText .= ']';
|
2014-01-05 16:04:55 +01:00
|
|
|
if ($index < $count - 1) $constantText .= ', ';
|
2014-01-03 17:26:55 +01:00
|
|
|
$index++;
|
2014-01-03 17:18:14 +01:00
|
|
|
}
|
|
|
|
}
|
2014-01-03 17:26:55 +01:00
|
|
|
else {
|
2014-01-05 16:04:55 +01:00
|
|
|
$constantText .= '"" => ["" => ""]';
|
2014-01-03 17:26:55 +01:00
|
|
|
}
|
|
|
|
$constantText .= ']';
|
2014-01-03 17:18:14 +01:00
|
|
|
$this->setConstant(self::CONSTANT_TOOLTIPTEXTS, $constantText);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Functions
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getFunctions() {
|
|
|
|
$this->buildTooltipFunctions();
|
|
|
|
$functionsText = PHP_EOL;
|
|
|
|
foreach ($this->functions as $name => $coding) {
|
|
|
|
$functionsText .= $coding;
|
|
|
|
}
|
|
|
|
return $functionsText;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the Functions needed for Tooltips
|
|
|
|
*/
|
|
|
|
private function buildTooltipFunctions() {
|
|
|
|
if (!$this->tooltips) return;
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->setInclude('TextLib', 'TextLib');
|
2014-01-03 17:18:14 +01:00
|
|
|
$setFunctionText = "
|
|
|
|
Void " . self::FUNCTION_SETTOOLTIPTEXT . "(CMlControl _TooltipControl, CMlControl _HoverControl) {
|
|
|
|
if (!_TooltipControl.Visible) return;
|
|
|
|
declare TooltipId = _TooltipControl.ControlId;
|
|
|
|
declare HoverId = _HoverControl.ControlId;
|
|
|
|
if (!" . self::CONSTANT_TOOLTIPTEXTS . ".existskey(TooltipId)) return;
|
|
|
|
if (!" . self::CONSTANT_TOOLTIPTEXTS . "[TooltipId].existskey(HoverId)) return;
|
|
|
|
declare Label = (_TooltipControl as CMlLabel);
|
|
|
|
Label.Value = " . self::CONSTANT_TOOLTIPTEXTS . "[TooltipId][HoverId];
|
2014-01-12 01:38:55 +01:00
|
|
|
}";
|
2014-01-12 01:49:43 +01:00
|
|
|
$this->setFunction(self::FUNCTION_SETTOOLTIPTEXT, $setFunctionText);
|
2014-01-12 01:38:55 +01:00
|
|
|
$getFunctionText = "
|
2014-01-12 00:51:46 +01:00
|
|
|
Text " . self::FUNCTION_GETTOOLTIPCONTROLID . "(Text _ControlClass) {
|
|
|
|
declare ClassParts = TextLib::Split(\"-\", _ControlClass);
|
2014-01-12 01:26:35 +01:00
|
|
|
if (ClassParts.count < 2) return \"\";
|
2014-01-12 00:51:46 +01:00
|
|
|
if (ClassParts[0] != \"" . self::CLASS_TOOLTIP . "\") return \"\";
|
|
|
|
return ClassParts[1];
|
2014-01-03 17:18:14 +01:00
|
|
|
}";
|
2014-01-12 01:38:55 +01:00
|
|
|
$this->setFunction(self::FUNCTION_GETTOOLTIPCONTROLID, $getFunctionText);
|
2014-01-03 17:18:14 +01:00
|
|
|
}
|
|
|
|
|
2014-01-12 01:49:43 +01:00
|
|
|
/**
|
|
|
|
* Get Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getLabels() {
|
|
|
|
$labelsText = PHP_EOL;
|
|
|
|
$labelsText .= $this->getTooltipLabels();
|
|
|
|
$labelsText .= $this->getMenuLabels();
|
|
|
|
$labelsText .= $this->getPagesLabels();
|
|
|
|
$labelsText .= $this->getProfileLabels();
|
|
|
|
$labelsText .= $this->getMapInfoLabels();
|
|
|
|
$labelsText .= $this->getSoundLabels();
|
|
|
|
$labelsText .= $this->getToggleLabels();
|
|
|
|
$labelsText .= $this->getSpectateLabels();
|
2014-02-16 13:59:28 +01:00
|
|
|
$labelsText .= $this->getTimeLabels();
|
2014-01-12 01:49:43 +01:00
|
|
|
return $labelsText;
|
|
|
|
}
|
|
|
|
|
2013-12-31 11:19:19 +01:00
|
|
|
/**
|
|
|
|
* Get the Tooltip Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getTooltipLabels() {
|
2014-01-12 00:51:46 +01:00
|
|
|
if (!$this->tooltips) return '';
|
2014-01-03 17:18:14 +01:00
|
|
|
$mouseOverScript = "
|
2014-01-12 00:51:46 +01:00
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIP . "\")) {
|
2014-01-05 17:19:44 +01:00
|
|
|
declare Invert = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_INVERT . "\");
|
|
|
|
foreach (ControlClass in Event.Control.ControlClasses) {
|
2014-01-12 00:51:46 +01:00
|
|
|
declare ControlId = " . self::FUNCTION_GETTOOLTIPCONTROLID . "(ControlClass);
|
|
|
|
if (ControlId == \"\") continue;
|
|
|
|
declare TooltipControl <=> Page.GetFirstChild(ControlId);
|
2014-01-05 17:19:44 +01:00
|
|
|
if (TooltipControl == Null) continue;
|
|
|
|
TooltipControl.Visible = !Invert;
|
|
|
|
" . self::FUNCTION_SETTOOLTIPTEXT . "(TooltipControl, Event.Control);
|
|
|
|
}
|
|
|
|
}";
|
|
|
|
$mouseOutScript = "
|
2014-01-12 00:51:46 +01:00
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIP . "\")) {
|
2014-01-05 17:19:44 +01:00
|
|
|
declare FML_Clicked for Event.Control = False;
|
|
|
|
declare StayOnClick = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_STAYONCLICK . "\");
|
|
|
|
if (!StayOnClick || !FML_Clicked) {
|
2014-01-05 14:12:32 +01:00
|
|
|
declare Invert = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_INVERT . "\");
|
|
|
|
foreach (ControlClass in Event.Control.ControlClasses) {
|
2014-01-12 00:51:46 +01:00
|
|
|
declare ControlId = " . self::FUNCTION_GETTOOLTIPCONTROLID . "(ControlClass);
|
|
|
|
if (ControlId == \"\") continue;
|
|
|
|
declare TooltipControl <=> Page.GetFirstChild(ControlId);
|
2014-01-05 14:12:32 +01:00
|
|
|
if (TooltipControl == Null) continue;
|
2014-01-05 17:19:44 +01:00
|
|
|
TooltipControl.Visible = Invert;
|
2014-01-05 14:12:32 +01:00
|
|
|
" . self::FUNCTION_SETTOOLTIPTEXT . "(TooltipControl, Event.Control);
|
|
|
|
}
|
2014-01-05 12:11:40 +01:00
|
|
|
}
|
2014-01-03 17:18:14 +01:00
|
|
|
}";
|
|
|
|
$mouseClickScript = "
|
2014-01-12 00:51:46 +01:00
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIP . "\")) {
|
2014-01-05 14:12:32 +01:00
|
|
|
declare Handle = True;
|
2014-01-05 12:11:40 +01:00
|
|
|
declare Show = False;
|
2014-01-05 17:19:44 +01:00
|
|
|
declare StayOnClick = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_STAYONCLICK . "\");
|
|
|
|
if (StayOnClick) {
|
|
|
|
declare FML_Clicked for Event.Control = False;
|
|
|
|
FML_Clicked = !FML_Clicked;
|
|
|
|
if (FML_Clicked) {
|
2014-01-05 14:12:32 +01:00
|
|
|
Handle = False;
|
2014-01-05 17:19:44 +01:00
|
|
|
} else {
|
|
|
|
Show = False;
|
2014-01-05 12:11:40 +01:00
|
|
|
}
|
2014-01-05 17:19:44 +01:00
|
|
|
} else {
|
|
|
|
Handle = False;
|
2014-01-05 12:11:40 +01:00
|
|
|
}
|
2014-01-05 14:12:32 +01:00
|
|
|
if (Handle) {
|
|
|
|
declare Invert = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_INVERT . "\");
|
|
|
|
foreach (ControlClass in Event.Control.ControlClasses) {
|
2014-01-12 00:51:46 +01:00
|
|
|
declare ControlId = " . self::FUNCTION_GETTOOLTIPCONTROLID . "(ControlClass);
|
|
|
|
if (ControlId == \"\") continue;
|
|
|
|
declare TooltipControl <=> Page.GetFirstChild(ControlId);
|
2014-01-05 14:12:32 +01:00
|
|
|
if (TooltipControl == Null) continue;
|
|
|
|
TooltipControl.Visible = Show && !Invert;
|
|
|
|
" . self::FUNCTION_SETTOOLTIPTEXT . "(TooltipControl, Event.Control);
|
|
|
|
}
|
2014-01-03 17:18:14 +01:00
|
|
|
}
|
2013-12-31 11:19:19 +01:00
|
|
|
}";
|
|
|
|
$tooltipsLabels = Builder::getLabelImplementationBlock(self::LABEL_MOUSEOVER, $mouseOverScript);
|
|
|
|
$tooltipsLabels .= Builder::getLabelImplementationBlock(self::LABEL_MOUSEOUT, $mouseOutScript);
|
2014-01-03 17:18:14 +01:00
|
|
|
$tooltipsLabels .= Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $mouseClickScript);
|
2013-12-31 11:19:19 +01:00
|
|
|
return $tooltipsLabels;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Menu Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getMenuLabels() {
|
2014-01-12 00:51:46 +01:00
|
|
|
if (!$this->menus) return '';
|
|
|
|
$this->setInclude('TextLib', 'TextLib');
|
2014-01-03 17:18:14 +01:00
|
|
|
$mouseClickScript = "
|
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_MENUBUTTON . "\")) {
|
|
|
|
declare Text MenuIdClass;
|
|
|
|
declare Text MenuControlId;
|
|
|
|
foreach (ControlClass in Event.Control.ControlClasses) {
|
|
|
|
declare ClassParts = TextLib::Split(\"-\", ControlClass);
|
2014-01-12 00:51:46 +01:00
|
|
|
if (ClassParts.count < 2) continue;
|
2014-01-03 17:18:14 +01:00
|
|
|
MenuIdClass = ClassParts[0];
|
|
|
|
MenuControlId = ClassParts[1];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Page.GetClassChildren(MenuIdClass, Page.MainFrame, True);
|
|
|
|
foreach (MenuControl in Page.GetClassChildren_Result) {
|
|
|
|
if (!MenuControl.HasClass(\"" . self::CLASS_MENU . "\")) continue;
|
2014-01-05 12:11:40 +01:00
|
|
|
MenuControl.Visible = (MenuControlId == MenuControl.ControlId);
|
2014-01-03 17:18:14 +01:00
|
|
|
}
|
2013-12-31 11:19:19 +01:00
|
|
|
}";
|
|
|
|
$menuLabels = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $mouseClickScript);
|
|
|
|
return $menuLabels;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Pages Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getPagesLabels() {
|
2014-01-03 17:18:14 +01:00
|
|
|
if (!$this->pages) return "";
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->setInclude('TextLib', 'TextLib');
|
2013-12-31 11:19:19 +01:00
|
|
|
$pagesNumberPrefix = self::CLASS_PAGE . '-P';
|
|
|
|
$pagesNumberPrefixLength = strlen($pagesNumberPrefix);
|
2014-01-03 17:18:14 +01:00
|
|
|
$pagesScript = "
|
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_PAGER . "\")) {
|
|
|
|
declare Text PagesId;
|
|
|
|
declare Integer PagingAction;
|
|
|
|
foreach (ControlClass in Event.Control.ControlClasses) {
|
|
|
|
declare ClassParts = TextLib::Split(\"-\", ControlClass);
|
2014-01-12 00:51:46 +01:00
|
|
|
if (ClassParts.count < 2) continue;
|
2014-01-03 17:18:14 +01:00
|
|
|
if (ClassParts[0] != \"" . self::CLASS_PAGER . "\") continue;
|
|
|
|
switch (TextLib::SubText(ClassParts[1], 0, 1)) {
|
|
|
|
case \"I\": {
|
2014-01-21 20:30:40 +01:00
|
|
|
PagesId = TextLib::SubText(ClassParts[1], 1, TextLib::Length(ClassParts[1]));
|
2014-01-03 17:18:14 +01:00
|
|
|
}
|
|
|
|
case \"A\": {
|
2014-01-21 20:30:40 +01:00
|
|
|
PagingAction = TextLib::ToInteger(TextLib::SubText(ClassParts[1], 1, TextLib::Length(ClassParts[1])));
|
2014-01-03 17:18:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare FML_PagesLastScriptStart for This = FML_ScriptStart;
|
|
|
|
declare FML_MinPageNumber for This = Integer[Text];
|
|
|
|
declare FML_MaxPageNumber for This = Integer[Text];
|
|
|
|
declare FML_PageNumber for This = Integer[Text];
|
|
|
|
if (FML_PagesLastScriptStart != FML_ScriptStart || !FML_PageNumber.existskey(PagesId) || !FML_MinPageNumber.existskey(PagesId) || !FML_MaxPageNumber.existskey(PagesId)) {
|
|
|
|
Page.GetClassChildren(PagesId, Page.MainFrame, True);
|
|
|
|
foreach (PageControl in Page.GetClassChildren_Result) {
|
|
|
|
if (!PageControl.HasClass(\"" . self::CLASS_PAGE . "\")) continue;
|
|
|
|
foreach (ControlClass in PageControl.ControlClasses) {
|
|
|
|
if (TextLib::SubText(ControlClass, 0, {$pagesNumberPrefixLength}) != \"{$pagesNumberPrefix}\") continue;
|
2014-01-21 20:30:40 +01:00
|
|
|
declare PageNumber = TextLib::ToInteger(TextLib::SubText(ControlClass, {$pagesNumberPrefixLength}, TextLib::Length(ControlClass)));
|
2014-01-03 17:18:14 +01:00
|
|
|
if (!FML_MinPageNumber.existskey(PagesId) || PageNumber < FML_MinPageNumber[PagesId]) {
|
|
|
|
FML_MinPageNumber[PagesId] = PageNumber;
|
|
|
|
}
|
|
|
|
if (!FML_MaxPageNumber.existskey(PagesId) || PageNumber > FML_MaxPageNumber[PagesId]) {
|
|
|
|
FML_MaxPageNumber[PagesId] = PageNumber;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FML_PageNumber[PagesId] = FML_MinPageNumber[PagesId];
|
|
|
|
}
|
|
|
|
FML_PageNumber[PagesId] += PagingAction;
|
|
|
|
if (FML_PageNumber[PagesId] < FML_MinPageNumber[PagesId]) {
|
|
|
|
FML_PageNumber[PagesId] = FML_MinPageNumber[PagesId];
|
|
|
|
}
|
|
|
|
if (FML_PageNumber[PagesId] > FML_MaxPageNumber[PagesId]) {
|
|
|
|
FML_PageNumber[PagesId] = FML_MaxPageNumber[PagesId];
|
|
|
|
}
|
|
|
|
FML_PagesLastScriptStart = FML_ScriptStart;
|
|
|
|
Page.GetClassChildren(PagesId, Page.MainFrame, True);
|
|
|
|
foreach (PageControl in Page.GetClassChildren_Result) {
|
|
|
|
if (!PageControl.HasClass(\"" . self::CLASS_PAGE . "\")) continue;
|
|
|
|
declare PageNumber = -1;
|
|
|
|
foreach (ControlClass in PageControl.ControlClasses) {
|
|
|
|
if (TextLib::SubText(ControlClass, 0, {$pagesNumberPrefixLength}) != \"{$pagesNumberPrefix}\") continue;
|
2014-01-21 20:30:40 +01:00
|
|
|
PageNumber = TextLib::ToInteger(TextLib::SubText(ControlClass, {$pagesNumberPrefixLength}, TextLib::Length(ControlClass)));
|
2014-01-03 17:18:14 +01:00
|
|
|
break;
|
|
|
|
}
|
2014-01-05 12:11:40 +01:00
|
|
|
PageControl.Visible = (PageNumber == FML_PageNumber[PagesId]);
|
2014-01-03 17:18:14 +01:00
|
|
|
}
|
|
|
|
Page.GetClassChildren(\"" . self::CLASS_PAGELABEL . "\", Page.MainFrame, True);
|
|
|
|
foreach (PageControl in Page.GetClassChildren_Result) {
|
|
|
|
if (!PageControl.HasClass(PagesId)) continue;
|
|
|
|
declare PageLabel <=> (PageControl as CMlLabel);
|
|
|
|
PageLabel.Value = FML_PageNumber[PagesId]^\"/\"^FML_MaxPageNumber[PagesId];
|
|
|
|
}
|
2013-12-31 11:19:19 +01:00
|
|
|
}";
|
|
|
|
$pagesLabels = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $pagesScript);
|
|
|
|
return $pagesLabels;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Profile Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getProfileLabels() {
|
2014-01-03 17:18:14 +01:00
|
|
|
if (!$this->profile) return "";
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->setInclude('TextLib', 'TextLib');
|
2014-01-19 19:30:21 +01:00
|
|
|
$prefixLength = strlen(self::CLASS_PROFILE) + 1;
|
2014-01-03 17:18:14 +01:00
|
|
|
$profileScript = "
|
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_PROFILE . "\")) {
|
|
|
|
declare Login = LocalUser.Login;
|
2014-01-24 19:55:17 +01:00
|
|
|
if (!Event.Control.HasClass(\"" . self::OPTION_PROFILE_OWN . "\")) {
|
2014-01-19 19:30:21 +01:00
|
|
|
foreach (ControlClass in Event.Control.ControlClasses) {
|
|
|
|
declare ClassParts = TextLib::Split(\"-\", ControlClass);
|
|
|
|
if (ClassParts.count < 2) continue;
|
|
|
|
if (ClassParts[0] != \"" . self::CLASS_PROFILE . "\") continue;
|
|
|
|
Login = TextLib::SubText(ControlClass, {$prefixLength}, TextLib::Length(ControlClass));
|
|
|
|
break;
|
2014-01-12 00:51:46 +01:00
|
|
|
}
|
2014-01-03 17:18:14 +01:00
|
|
|
}
|
|
|
|
ShowProfile(Login);
|
2013-12-31 11:19:19 +01:00
|
|
|
}";
|
|
|
|
$profileLabels = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $profileScript);
|
|
|
|
return $profileLabels;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Map Info Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getMapInfoLabels() {
|
2014-01-03 17:18:14 +01:00
|
|
|
if (!$this->mapInfo) return "";
|
|
|
|
$mapInfoScript = "
|
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_MAPINFO . "\")) {
|
|
|
|
ShowCurChallengeCard();
|
2013-12-31 11:19:19 +01:00
|
|
|
}";
|
|
|
|
$mapInfoLabels = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $mapInfoScript);
|
|
|
|
return $mapInfoLabels;
|
|
|
|
}
|
|
|
|
|
2014-01-05 16:04:55 +01:00
|
|
|
/**
|
|
|
|
* Get the Sound Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getSoundLabels() {
|
|
|
|
if (!$this->sounds) return '';
|
|
|
|
$labelScripts = array();
|
|
|
|
foreach ($this->sounds as $soundData) {
|
2014-01-05 17:19:44 +01:00
|
|
|
$volume = Builder::getReal($soundData['soundVolume']);
|
2014-01-05 16:04:55 +01:00
|
|
|
$labelScript = "
|
2014-01-05 17:19:44 +01:00
|
|
|
case \"{$soundData['controlId']}\": {
|
|
|
|
PlayUiSound(CMlScriptIngame::EUISound::{$soundData['soundName']}, {$soundData['soundVariant']}, {$volume});
|
2014-01-05 16:04:55 +01:00
|
|
|
}";
|
2014-01-05 17:19:44 +01:00
|
|
|
if (!isset($labelScripts[$soundData['eventLabel']])) {
|
|
|
|
$labelScripts[$soundData['eventLabel']] = '';
|
2014-01-05 16:04:55 +01:00
|
|
|
}
|
2014-01-05 17:19:44 +01:00
|
|
|
$labelScripts[$soundData['eventLabel']] .= $labelScript;
|
2014-01-05 16:04:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$soundScript = '';
|
|
|
|
foreach ($labelScripts as $label => $scriptPart) {
|
|
|
|
$labelScript = "
|
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_SOUND . "\")) {
|
|
|
|
switch (Event.Control.ControlId) {
|
|
|
|
{$scriptPart}
|
|
|
|
}
|
|
|
|
}";
|
|
|
|
$soundScript .= Builder::getLabelImplementationBlock($label, $labelScript);
|
|
|
|
}
|
|
|
|
return $soundScript;
|
|
|
|
}
|
|
|
|
|
2014-01-05 17:19:44 +01:00
|
|
|
/**
|
|
|
|
* Get the Toggle Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getToggleLabels() {
|
|
|
|
if (!$this->toggles) return '';
|
2014-01-12 00:51:46 +01:00
|
|
|
$this->setInclude('TextLib', 'TextLib');
|
2014-01-05 17:19:44 +01:00
|
|
|
$toggleScript = "
|
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_TOGGLE . "\")) {
|
2014-01-12 00:51:46 +01:00
|
|
|
declare HasShow = Event.Control.HasClass(\"" . self::OPTION_TOGGLE_SHOW . "\");
|
|
|
|
declare HasHide = Event.Control.HasClass(\"" . self::OPTION_TOGGLE_HIDE . "\");
|
2014-01-05 17:19:44 +01:00
|
|
|
declare Toggle = True;
|
|
|
|
declare Show = True;
|
|
|
|
if (HasShow || HasHide) {
|
|
|
|
Toggle = False;
|
|
|
|
Show = HasShow;
|
|
|
|
}
|
2014-01-12 00:51:46 +01:00
|
|
|
declare PrefixLength = TextLib::Length(\"" . self::CLASS_TOGGLE . "\");
|
2014-01-05 17:19:44 +01:00
|
|
|
foreach (ControlClass in Event.Control.ControlClasses) {
|
2014-01-12 00:51:46 +01:00
|
|
|
declare ClassParts = TextLib::Split(\"-\", ControlClass);
|
|
|
|
if (ClassParts.count < 2) continue;
|
|
|
|
if (ClassParts[0] != \"" . self::CLASS_TOGGLE . "\") continue;
|
|
|
|
declare ToggleControl <=> Page.GetFirstChild(ClassParts[1]);
|
2014-01-05 17:19:44 +01:00
|
|
|
if (ToggleControl == Null) continue;
|
|
|
|
if (Toggle) {
|
|
|
|
ToggleControl.Visible = !ToggleControl.Visible;
|
|
|
|
} else {
|
|
|
|
ToggleControl.Visible = Show;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}";
|
|
|
|
$toggleScript = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $toggleScript);
|
|
|
|
return $toggleScript;
|
|
|
|
}
|
|
|
|
|
2014-01-12 00:51:46 +01:00
|
|
|
/**
|
|
|
|
* Get the Spectate labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getSpectateLabels() {
|
|
|
|
if (!$this->spectate) return '';
|
2014-01-12 01:38:55 +01:00
|
|
|
$this->setInclude('TextLib', 'TextLib');
|
2014-01-19 19:30:21 +01:00
|
|
|
$prefixLength = strlen(self::CLASS_SPECTATE) + 1;
|
2014-01-12 00:51:46 +01:00
|
|
|
$spectateScript = "
|
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_SPECTATE . "\")) {
|
|
|
|
declare Login = \"\";
|
2014-01-19 19:30:21 +01:00
|
|
|
foreach (ControlClass in Event.Control.ControlClasses) {
|
2014-01-12 00:51:46 +01:00
|
|
|
declare ClassParts = TextLib::Split(\"-\", ControlClass);
|
|
|
|
if (ClassParts.count < 2) continue;
|
|
|
|
if (ClassParts[0] != \"" . self::CLASS_SPECTATE . "\") continue;
|
2014-01-19 19:30:21 +01:00
|
|
|
Login = TextLib::SubText(ControlClass, {$prefixLength}, TextLib::Length(ControlClass));
|
|
|
|
break;
|
2014-01-12 00:51:46 +01:00
|
|
|
}
|
|
|
|
if (Login != \"\") {
|
|
|
|
SetSpectateTarget(Login);
|
|
|
|
}
|
|
|
|
}";
|
|
|
|
$spectateScript = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $spectateScript);
|
|
|
|
return $spectateScript;
|
|
|
|
}
|
|
|
|
|
2014-01-21 20:30:40 +01:00
|
|
|
/**
|
|
|
|
* Get the Page Actions Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getPageActionLabels() {
|
|
|
|
if (!$this->pageActions) return '';
|
|
|
|
$this->setInclude('TextLib', 'TextLib');
|
|
|
|
$prefixLength = strlen(self::CLASS_PAGEACTION) + 1;
|
|
|
|
$pageActionScript = "
|
|
|
|
if (Event.Control.HasClass(\"" . self::CLASS_PAGEACTION . "\")) {
|
|
|
|
declare Action = \"\";
|
|
|
|
foreach (ControlClass in Event.Control.ControlClasses) {
|
|
|
|
declare ClassParts = TextLib::Split(\"-\", ControlClass);
|
|
|
|
if (ClassParts.count < 2) continue;
|
|
|
|
if (ClassParts[0] != \"" . self::CLASS_PAGEACTION . "\") continue;
|
|
|
|
Action = TextLib::SubText(ControlClass, {$prefixLength}, TextLib::Length(ControlClass));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (Action != \"\") {
|
|
|
|
TriggerPageAction(Action);
|
|
|
|
}
|
|
|
|
}";
|
|
|
|
$pageActionScript = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $pageActionScript);
|
|
|
|
return $pageActionScript;
|
|
|
|
}
|
|
|
|
|
2014-02-16 13:59:28 +01:00
|
|
|
/**
|
|
|
|
* Get the Time Labels
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getTimeLabels() {
|
|
|
|
if (!$this->times) return '';
|
|
|
|
$this->setInclude('TextLib', 'TextLib');
|
|
|
|
$timesScript = "
|
|
|
|
Page.GetClassChildren(\"" . self::CLASS_TIME . "\", Page.MainFrame, True);
|
|
|
|
foreach (TimeLabelControl in Page.GetClassChildren_Result) {
|
|
|
|
declare TimeLabel = (TimeLabelControl as CMlLabel);
|
|
|
|
declare ShowFullDate = TimeLabel.HasClass(\"" . self::OPTION_TIME_FULLDATE . "\");
|
|
|
|
if (ShowFullDate) {
|
|
|
|
TimeLabel.Value = CurrentLocalDateText;
|
|
|
|
} else {
|
|
|
|
TimeLabel.Value = TextLib::SubText(CurrentLocalDateText, 11, 8);
|
|
|
|
}
|
|
|
|
}";
|
|
|
|
$timesScript = Builder::getLabelImplementationBlock(self::LABEL_TICK, $timesScript);
|
|
|
|
return $timesScript;
|
|
|
|
}
|
|
|
|
|
2013-12-31 11:19:19 +01:00
|
|
|
/**
|
|
|
|
* Get the Main Function
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getMainFunction() {
|
|
|
|
$mainFunction = file_get_contents(__DIR__ . '/Parts/Main.txt');
|
|
|
|
return $mainFunction;
|
|
|
|
}
|
2014-01-03 17:18:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the Array of additional optional Parameters
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param array $args The Array of Function Parameters
|
|
|
|
* @param int $offset The Number of obligatory Parameters
|
2014-01-03 17:18:14 +01:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function spliceParameters(array $params, $offset) {
|
|
|
|
$args = array_splice($params, $offset);
|
|
|
|
if (!$args) return $args;
|
|
|
|
$parameters = array();
|
|
|
|
foreach ($args as $arg) {
|
|
|
|
if (is_array($arg)) {
|
|
|
|
foreach ($arg as $key => $value) {
|
|
|
|
$parameters[$key] = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$parameters[$arg] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $parameters;
|
|
|
|
}
|
|
|
|
}
|