fml sound feature
This commit is contained in:
parent
417e460588
commit
b10575d4f2
@ -307,6 +307,6 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Tools);
|
||||
$itemQuad->setAction(self::ACTION_TOGGLEMENU);
|
||||
$this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad,20,'Settings');
|
||||
$this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 20, 'Settings');
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,7 @@ class ManiaLink implements Container {
|
||||
/**
|
||||
* Construct a new Manialink
|
||||
*
|
||||
* @param string $id
|
||||
* Manialink Id
|
||||
* @param string $id Manialink Id
|
||||
*/
|
||||
public function __construct($id = null) {
|
||||
if ($id !== null) {
|
||||
@ -40,8 +39,7 @@ class ManiaLink implements Container {
|
||||
/**
|
||||
* Set XML Encoding
|
||||
*
|
||||
* @param string $encoding
|
||||
* XML Encoding
|
||||
* @param string $encoding XML Encoding
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
public function setXmlEncoding($encoding) {
|
||||
@ -52,8 +50,7 @@ class ManiaLink implements Container {
|
||||
/**
|
||||
* Set Manialink Id
|
||||
*
|
||||
* @param string $id
|
||||
* Manialink Id
|
||||
* @param string $id Manialink Id
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
public function setId($id) {
|
||||
@ -64,8 +61,7 @@ class ManiaLink implements Container {
|
||||
/**
|
||||
* Set Background
|
||||
*
|
||||
* @param string $background
|
||||
* Background Value
|
||||
* @param string $background Background Value
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
public function setBackground($background) {
|
||||
@ -76,8 +72,7 @@ class ManiaLink implements Container {
|
||||
/**
|
||||
* Set Navigable3d
|
||||
*
|
||||
* @param bool $navigable3d
|
||||
* If the manialink is 3d navigable
|
||||
* @param bool $navigable3d If the manialink is 3d navigable
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
public function setNavigable3d($navigable3d) {
|
||||
@ -88,8 +83,7 @@ class ManiaLink implements Container {
|
||||
/**
|
||||
* Set Timeout
|
||||
*
|
||||
* @param int $timeout
|
||||
* Timeout Duration
|
||||
* @param int $timeout Timeout Duration
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
public function setTimeout($timeout) {
|
||||
@ -118,7 +112,7 @@ class ManiaLink implements Container {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the script object of the Manialink
|
||||
* Set the Script of the ManiaLink
|
||||
*
|
||||
* @param Script $script
|
||||
* @return \FML\ManiaLink
|
||||
@ -128,11 +122,23 @@ class ManiaLink implements Container {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current Script of the ManiaLink
|
||||
*
|
||||
* @param string $createIfEmpty
|
||||
* @return \FML\Script\Script
|
||||
*/
|
||||
public function getScript($createIfEmpty = true) {
|
||||
if (!$this->script && $createIfEmpty) {
|
||||
$this->script = new Script();
|
||||
}
|
||||
return $this->script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the XML Document
|
||||
*
|
||||
* @param bool $echo
|
||||
* If the xml should be echoed and the content-type header should be set
|
||||
* @param bool $echo If the xml should be echoed and the content-type header should be set
|
||||
* @param \DOMDocument $domDocument
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
|
@ -20,4 +20,17 @@ abstract class Builder {
|
||||
$labelText = PHP_EOL . "***{$labelName}***" . PHP_EOL . "***{$implementationCode}***" . PHP_EOL;
|
||||
return $labelText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Real String-Representation of the given Value
|
||||
*
|
||||
* @param float $value
|
||||
* @return string
|
||||
*/
|
||||
public static function getReal($value) {
|
||||
$value = (float) $value;
|
||||
$stringVal = (string) $value;
|
||||
if (!fmod($value, 1)) $stringVal .= '.';
|
||||
return $stringVal;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ class Script {
|
||||
const CLASS_PAGELABEL = 'FML_PageLabel';
|
||||
const CLASS_PROFILE = 'FML_Profile';
|
||||
const CLASS_MAPINFO = 'FML_MapInfo';
|
||||
const CLASS_SOUND = 'FML_Sound';
|
||||
const OPTION_TOOLTIP_ONCLICK = 'FML_Tooltip_OnClick';
|
||||
const OPTION_TOOLTIP_STAYONCLICK = 'FML_Tooltip_StayOnClick';
|
||||
const OPTION_TOOLTIP_INVERT = 'FML_Tooltip_Invert';
|
||||
@ -50,6 +51,7 @@ class Script {
|
||||
protected $pages = false;
|
||||
protected $profile = false;
|
||||
protected $mapInfo = false;
|
||||
protected $sounds = array();
|
||||
|
||||
/**
|
||||
* Set an Include of the Script
|
||||
@ -249,6 +251,30 @@ class Script {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Sound Playing for the Control
|
||||
*
|
||||
* @param Control $control
|
||||
* @param UISound $sound
|
||||
* @param string $eventLabel
|
||||
* @return \FML\Script\Script
|
||||
*/
|
||||
public function addSound(Control $control, UISound $sound, $eventLabel = self::LABEL_MOUSECLICK) {
|
||||
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();
|
||||
$soundData['sound'] = $sound;
|
||||
$soundData['id'] = $control->getId();
|
||||
$soundData['label'] = $eventLabel;
|
||||
array_push($this->sounds, $soundData);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Script XML Tag
|
||||
*
|
||||
@ -279,6 +305,7 @@ class Script {
|
||||
$scriptText .= $this->getPagesLabels();
|
||||
$scriptText .= $this->getProfileLabels();
|
||||
$scriptText .= $this->getMapInfoLabels();
|
||||
$scriptText .= $this->getSoundLabels();
|
||||
$scriptText .= $this->getMainFunction();
|
||||
return $scriptText;
|
||||
}
|
||||
@ -330,13 +357,13 @@ class Script {
|
||||
$count = count($this->tooltipTexts);
|
||||
if ($count > 0) {
|
||||
foreach ($this->tooltipTexts as $tooltipId => $tooltipTexts) {
|
||||
$constantText .= '"' . $tooltipId . '"=>[';
|
||||
$constantText .= '"' . $tooltipId . '" => [';
|
||||
$subIndex = 0;
|
||||
$subCount = count($tooltipTexts);
|
||||
if ($subCount > 0) {
|
||||
foreach ($tooltipTexts as $hoverId => $text) {
|
||||
$constantText .= '"' . $hoverId . '"=>"' . $text . '"';
|
||||
if ($subIndex < $subCount - 1) $constantText .= ',';
|
||||
$constantText .= '"' . $hoverId . '" => "' . $text . '"';
|
||||
if ($subIndex < $subCount - 1) $constantText .= ', ';
|
||||
$subIndex++;
|
||||
}
|
||||
}
|
||||
@ -344,12 +371,12 @@ class Script {
|
||||
$constantText .= '""';
|
||||
}
|
||||
$constantText .= ']';
|
||||
if ($index < $count - 1) $constantText .= ',';
|
||||
if ($index < $count - 1) $constantText .= ', ';
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$constantText .= '""=>[""=>""]';
|
||||
$constantText .= '"" => ["" => ""]';
|
||||
}
|
||||
$constantText .= ']';
|
||||
$this->setConstant(self::CONSTANT_TOOLTIPTEXTS, $constantText);
|
||||
@ -602,6 +629,42 @@ if (Event.Control.HasClass(\"" . self::CLASS_MAPINFO . "\")) {
|
||||
return $mapInfoLabels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Sound Labels
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getSoundLabels() {
|
||||
if (!$this->sounds) return '';
|
||||
$labelScripts = array();
|
||||
foreach ($this->sounds as $soundData) {
|
||||
$controlId = $soundData['id'];
|
||||
$label = $soundData['label'];
|
||||
$sound = $soundData['sound'];
|
||||
$volume = Builder::getReal($sound->volume);
|
||||
$labelScript = "
|
||||
case \"{$controlId}\": {
|
||||
PlayUiSound(CMlScriptIngame::EUISound::{$sound->name}, {$sound->variant}, {$volume});
|
||||
}";
|
||||
if (!isset($labelScripts[$label])) {
|
||||
$labelScripts[$label] = '';
|
||||
}
|
||||
$labelScripts[$label] .= $labelScript;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Main Function
|
||||
*
|
||||
|
63
application/core/FML/Script/UISound.php
Normal file
63
application/core/FML/Script/UISound.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Script;
|
||||
|
||||
/**
|
||||
* Class for EUISound Variants
|
||||
*
|
||||
* @author steeffeen
|
||||
*/
|
||||
class UISound {
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
const SOUND_Bonus = 'Bonus';
|
||||
const SOUND_Capture = 'Capture';
|
||||
const SOUND_Checkpoint = 'Checkpoint';
|
||||
const SOUND_Combo = 'Combo';
|
||||
const SOUND_Custom1 = 'Custom1';
|
||||
const SOUND_Custom2 = 'Custom2';
|
||||
const SOUND_Custom3 = 'Custom3';
|
||||
const SOUND_Custom4 = 'Custom4';
|
||||
const SOUND_Default = 'Default';
|
||||
const SOUND_EndMatch = 'EndMatch';
|
||||
const SOUND_EndRound = 'EndRound';
|
||||
const SOUND_Finish = 'Finish';
|
||||
const SOUND_FirstHit = 'FirstHit';
|
||||
const SOUND_Notice = 'Notice';
|
||||
const SOUND_PhaseChange = 'PhaseChange';
|
||||
const SOUND_PlayerEliminated = 'PlayerEliminated';
|
||||
const SOUND_PlayerHit = 'PlayerHit';
|
||||
const SOUND_PlayersRemaining = 'PlayersRemaining';
|
||||
const SOUND_RankChange = 'RankChange';
|
||||
const SOUND_Record = 'Record';
|
||||
const SOUND_ScoreProgress = 'ScoreProgress';
|
||||
const SOUND_Silence = 'Silence';
|
||||
const SOUND_StartMatch = 'StartMatch';
|
||||
const SOUND_StartRound = 'StartRound';
|
||||
const SOUND_TieBreakPoint = 'TieBreakPoint';
|
||||
const SOUND_TiePoint = 'TiePoint';
|
||||
const SOUND_TimeOut = 'TimeOut';
|
||||
const SOUND_VictoryPoint = 'VictoryPoint';
|
||||
const SOUND_Warning = 'Warning';
|
||||
|
||||
/**
|
||||
* Public Properties
|
||||
*/
|
||||
public $name = self::SOUND_Default;
|
||||
public $variant = 0;
|
||||
public $volume = 1.;
|
||||
|
||||
/**
|
||||
* Create a new EUISound Instance
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $variant
|
||||
* @param real $volume
|
||||
*/
|
||||
public function __construct($name = self::SOUND_Default, $variant = 0, $volume = 1.) {
|
||||
$this->name = $name;
|
||||
$this->variant = $variant;
|
||||
$this->volume = $volume;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user