From df18afb6d4b2dfb691b618d44549a9ce097f3126 Mon Sep 17 00:00:00 2001 From: Arcturus Date: Wed, 20 Nov 2024 17:31:37 +0900 Subject: [PATCH] add setting type --- .../classes/setting/setting.class.php | 81 ++++++++++++++++++- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/AvocadoAmber/classes/setting/setting.class.php b/AvocadoAmber/classes/setting/setting.class.php index 0743dd3..6638254 100644 --- a/AvocadoAmber/classes/setting/setting.class.php +++ b/AvocadoAmber/classes/setting/setting.class.php @@ -97,6 +97,15 @@ class Setting case "radius": $this->addRadiusSetting($set["desc"], array_key_exists("default", $set) ? (is_array($set["default"]) ? $set["default"] : []) : []); break; + case "margin": + $this->addMarginSetting($set["desc"], array_key_exists("default", $set) ? (is_array($set["default"]) ? $set["default"] : []) : []); + break; + case "font": + $this->addFontSetting($set["desc"], array_key_exists("default", $set) ? (is_array($set["default"]) ? $set["default"] : "") : []); + break; + case "fontsize": + $this->addFontSizeSetting($set["desc"], array_key_exists("default", $set) ? (is_array($set["default"]) ? $set["default"] : "16") : []); + break; } } @@ -253,6 +262,34 @@ class Setting $this->is_value_added = true; } + public function addFontSetting($desc, $default, $placeholder = "") + { + $idx = $this->getCurrentCount() + 1; + if ($idx <= 20) { + $key1 = "cs_etc_{$idx}"; + $val = $this->$key1 ? $this->$key1 : (isset($default) ? $default : ""); + + $this->settings[] = [ + "type" => "font", + "html" => "{$desc}
idx}]\" value=\"{$val}\" size=\"100\" placeholder=\"{$placeholder}\" />
" + ]; + } + } + + public function addFontSizeSetting($desc, $default) + { + $idx = $this->getCurrentCount() + 1; + if ($idx <= 20) { + $key1 = "cs_etc_{$idx}"; + $val = $this->$key1 ? $this->$key1 : (isset($default) ? $default : 16); + + $this->settings[] = [ + "type" => "font", + "html" => "{$desc}
idx}]\" value=\"{$val}\" style=\"width: 60px\" min=\"9\" max=\"72\" />
" + ]; + } + } + public function addRectSetting($desc, $default) { $idx = $this->getCurrentCount() + 1; @@ -313,10 +350,46 @@ class Setting "html" => "{$desc}
-
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[1]}\"/>px
-
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[2]}\"/>px
-
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[3]}\"/>px
-
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[4]}\"/>px
+
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[1]}\"/>px
+
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[2]}\"/>px
+
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[3]}\"/>px
+
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[4]}\"/>px
+
+ + " + ]; + } + // error + } + + public function addMarginSetting($desc, $default) + { + $idx = $this->getCurrentCount() + 1; + if ($idx <= 20) { + $key1 = "cs_etc_{$idx}"; + $values = explode("||", $this->$key1); + + if (empty($default)) { + $default = [0, 0, 0, 0]; + } + + if (count($values) < 6) { + $values = array_merge([""], $default, [""]); + } + + foreach ($values as &$val) { + $val = intval($val); + } + + $this->settings[] = [ + "type" => "margin", + "html" => "{$desc} + +
+
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[1]}\"/>px
+
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[2]}\"/>px
+
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[3]}\"/>px
+
cs_name}\" min=\"-9999\" max=\"9999\" size=\"20\" name=\"cs_etc_{$idx}[{$this->idx}][]\" value=\"{$values[4]}\"/>px
"