mirror of
https://github.com/Dreamer-Paul/Pio.git
synced 2025-04-22 19:22:36 +08:00
Add Position Sets
增加看板娘位置的设置功能
This commit is contained in:
parent
81bae656f4
commit
baf40e2aec
44
Plugin.php
44
Plugin.php
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @package Pio
|
||||
* @author Dreamer-Paul
|
||||
* @version 1.2
|
||||
* @version 1.3
|
||||
* @link https://paugram.com
|
||||
*/
|
||||
|
||||
@ -12,8 +12,8 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
|
||||
/* 激活插件方法 */
|
||||
public static function activate(){
|
||||
Typecho_Plugin::factory('Widget_Archive')->header = array('Pio_Plugin', 'header');
|
||||
Typecho_Plugin::factory('Widget_Archive')->footer = array('Pio_Plugin', 'footer');
|
||||
Typecho_Plugin::factory('Widget_Archive') -> header = array('Pio_Plugin', 'header');
|
||||
Typecho_Plugin::factory('Widget_Archive') -> footer = array('Pio_Plugin', 'footer');
|
||||
}
|
||||
|
||||
/* 禁用插件方法 */
|
||||
@ -39,7 +39,7 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
|
||||
echo "</div>";
|
||||
}
|
||||
paul_update("Pio", "1.2");
|
||||
paul_update("Pio", "1.3");
|
||||
|
||||
// 读取模型文件夹
|
||||
$models = array();
|
||||
@ -52,18 +52,27 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
|
||||
// 自定义模型选择
|
||||
$choose_models = new Typecho_Widget_Helper_Form_Element_Select('choose_models', $models, 'pio', _t('选择模型'), _t('选择插件 Models 目录下的模型,每个模型为一个文件夹,并确定配置文件名为 <a>model.json</a>'));
|
||||
$form->addInput($choose_models);
|
||||
$form -> addInput($choose_models);
|
||||
|
||||
// 自定义定位
|
||||
$position = new Typecho_Widget_Helper_Form_Element_Radio('position',
|
||||
array(
|
||||
'left' => _t('靠左'),
|
||||
'right' => _t('靠右'),
|
||||
),
|
||||
'left', _t('自定义位置'), _t('自定义看板娘所在的位置'));
|
||||
$form -> addInput($position);
|
||||
|
||||
// 自定义宽高
|
||||
$custom_width = new Typecho_Widget_Helper_Form_Element_Text('custom_width', NULL, NULL, _t('自定义宽度'), _t('在这里填入自定义宽度,部分模型需要修改'));
|
||||
$form->addInput($custom_width);
|
||||
$form -> addInput($custom_width);
|
||||
|
||||
$custom_height = new Typecho_Widget_Helper_Form_Element_Text('custom_height', NULL, NULL, _t('自定义高度'), _t('在这里填入自定义高度,部分模型需要修改'));
|
||||
$form->addInput($custom_height);
|
||||
$form -> addInput($custom_height);
|
||||
|
||||
// 自定义模型
|
||||
$custom_model = new Typecho_Widget_Helper_Form_Element_Text('custom_model', NULL, NULL, _t('自定义配置文件地址'), _t('在这里填入一个模型 JSON 配置文件地址,可供使用外链模型,不填则使用插件目录下的模型'));
|
||||
$form->addInput($custom_model);
|
||||
$form -> addInput($custom_model);
|
||||
}
|
||||
|
||||
/* 个人用户的配置方法 */
|
||||
@ -71,11 +80,12 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
|
||||
/* 插件实现方法 */
|
||||
public static function header(){
|
||||
echo "<style>#pio{ left: 0; bottom: 0; z-index: 520; position: fixed; pointer-events: none; } @media screen and (max-width: 768px){ #pio{ width: 8em; } }</style>";
|
||||
$pos = Typecho_Widget::widget('Widget_Options') -> Plugin('Pio') -> position;
|
||||
echo "<style>#pio{ $pos: 0; bottom: 0; z-index: 520; position: fixed; pointer-events: none; } @media screen and (max-width: 768px){ #pio{ width: 8em; } }</style>";
|
||||
}
|
||||
public static function footer(){
|
||||
$height = Typecho_Widget::widget('Widget_Options')->Plugin('Pio')->custom_height;
|
||||
$width = Typecho_Widget::widget('Widget_Options')->Plugin('Pio')->custom_width;
|
||||
$height = Typecho_Widget::widget('Widget_Options') -> Plugin('Pio') -> custom_height;
|
||||
$width = Typecho_Widget::widget('Widget_Options') -> Plugin('Pio') -> custom_width;
|
||||
|
||||
if($height && $width){
|
||||
echo "<canvas id='pio' width='".$width."' height='".$height."'></canvas>";
|
||||
@ -90,16 +100,16 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
echo "<canvas id='pio' width='280' height='250'></canvas>";
|
||||
}
|
||||
|
||||
echo "<script src='" . Helper::options()->pluginUrl . "/Pio/l2d.js'></script>" . "\n";
|
||||
echo "<script src='" . Helper::options() -> pluginUrl . "/Pio/l2d.js'></script>" . "\n";
|
||||
|
||||
if(Typecho_Widget::widget('Widget_Options')->Plugin('Pio')->custom_model){
|
||||
echo "<script>loadlive2d('pio', '" . Typecho_Widget::widget('Widget_Options')->Plugin('Pio')->custom_model . "');</script>". "\n";
|
||||
if(Typecho_Widget::widget('Widget_Options') -> Plugin('Pio') -> custom_model){
|
||||
echo "<script>loadlive2d('pio', '" . Typecho_Widget::widget('Widget_Options') -> Plugin('Pio') -> custom_model . "');</script>". "\n";
|
||||
}
|
||||
else if(Typecho_Widget::widget('Widget_Options')->Plugin('Pio')->choose_models){
|
||||
echo "<script>loadlive2d('pio', '" . Helper::options()->pluginUrl . "/Pio/models/" . Typecho_Widget::widget('Widget_Options')->Plugin('Pio')->choose_models . "/model.json');</script>". "\n";
|
||||
else if(Typecho_Widget::widget('Widget_Options') -> Plugin('Pio') -> choose_models){
|
||||
echo "<script>loadlive2d('pio', '" . Helper::options() -> pluginUrl . "/Pio/models/" . Typecho_Widget::widget('Widget_Options') -> Plugin('Pio') -> choose_models . "/model.json');</script>". "\n";
|
||||
}
|
||||
else{
|
||||
echo "<script>loadlive2d('pio', '" . Helper::options()->pluginUrl . "/Pio/models/pio/model.json');</script>". "\n";
|
||||
echo "<script>loadlive2d('pio', '" . Helper::options() -> pluginUrl . "/Pio/models/pio/model.json');</script>". "\n";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user