apply script setting values

This commit is contained in:
kremsy 2013-12-30 18:56:42 +01:00
parent d5f68bb8dc
commit d346cf79be

View File

@ -161,15 +161,25 @@ class ScriptSettings implements ConfiguratorMenu {
public function saveConfigData(array $configData, Player $player) { public function saveConfigData(array $configData, Player $player) {
$this->maniaControl->client->query('GetModeScriptSettings'); $this->maniaControl->client->query('GetModeScriptSettings');
$scriptSettings = $this->maniaControl->client->getResponse(); $scriptSettings = $this->maniaControl->client->getResponse();
// var_dump($configData);
// var_dump($scriptSettings); $newSettings = array();
$prefixLength = strlen(self::ACTION_PREFIX_SETTING); $prefixLength = strlen(self::ACTION_PREFIX_SETTING);
foreach ($configData[3] as $dataName => $dataValue) { foreach ($configData[3] as $settings) {
if (substr($dataName, 0, $prefixLength) != self::ACTION_PREFIX_SETTING) continue; if (substr($settings['Name'], 0, $prefixLength) != self::ACTION_PREFIX_SETTING) continue;
$settingName = substr($dataName, $prefixLength); $settingName = substr($settings['Name'], $prefixLength);
// TODO: apply new script settings foreach($scriptSettings as $key => $value){
if($key == $settingName){
//Setting found, cast type, break the inner loop
settype($settings["Value"], gettype($value));
break;
}
}
$newSettings[$settingName] = $settings["Value"];
} }
$this->maniaControl->client->query('SetModeScriptSettings', $newSettings);
} }
} }