From 81bae656f43fa882e34d434cc0f9cb49a2450d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=B6=A3=E4=BF=9D=E7=BD=97?= Date: Fri, 6 Apr 2018 21:33:16 +0800 Subject: [PATCH] Add Model Select MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加选择插件目录内所有模型的选项 --- Plugin.php | 30 ++++++++++++++---- model.json => models/pio/model.json | 0 model.moc => models/pio/model.moc | Bin .../pio/motions}/Breath Dere1.mtn | 0 .../pio/motions}/Breath Dere2.mtn | 0 .../pio/motions}/Breath Dere3.mtn | 0 {motions => models/pio/motions}/Breath1.mtn | 0 {motions => models/pio/motions}/Breath2.mtn | 0 {motions => models/pio/motions}/Breath3.mtn | 0 {motions => models/pio/motions}/Breath4.mtn | 0 {motions => models/pio/motions}/Breath5.mtn | 0 {motions => models/pio/motions}/Breath6.mtn | 0 {motions => models/pio/motions}/Breath7.mtn | 0 {motions => models/pio/motions}/Breath8.mtn | 0 {motions => models/pio/motions}/Fail.mtn | 0 {motions => models/pio/motions}/Sleeping.mtn | 0 {motions => models/pio/motions}/Success.mtn | 0 {motions => models/pio/motions}/Sukebei1.mtn | 0 {motions => models/pio/motions}/Sukebei2.mtn | 0 {motions => models/pio/motions}/Sukebei3.mtn | 0 .../pio/motions}/Touch Dere1.mtn | 0 .../pio/motions}/Touch Dere2.mtn | 0 .../pio/motions}/Touch Dere3.mtn | 0 .../pio/motions}/Touch Dere4.mtn | 0 .../pio/motions}/Touch Dere5.mtn | 0 .../pio/motions}/Touch Dere6.mtn | 0 {motions => models/pio/motions}/Touch1.mtn | 0 {motions => models/pio/motions}/Touch2.mtn | 0 {motions => models/pio/motions}/Touch3.mtn | 0 {motions => models/pio/motions}/Touch4.mtn | 0 {motions => models/pio/motions}/Touch5.mtn | 0 {motions => models/pio/motions}/Touch6.mtn | 0 {motions => models/pio/motions}/WakeUp.mtn | 0 .../pio/textures}/default-costume.png | Bin .../pio/textures}/pajamas-costume.png | Bin .../pio/textures}/school-costume.png | Bin 36 files changed, 23 insertions(+), 7 deletions(-) rename model.json => models/pio/model.json (100%) rename model.moc => models/pio/model.moc (100%) rename {motions => models/pio/motions}/Breath Dere1.mtn (100%) rename {motions => models/pio/motions}/Breath Dere2.mtn (100%) rename {motions => models/pio/motions}/Breath Dere3.mtn (100%) rename {motions => models/pio/motions}/Breath1.mtn (100%) rename {motions => models/pio/motions}/Breath2.mtn (100%) rename {motions => models/pio/motions}/Breath3.mtn (100%) rename {motions => models/pio/motions}/Breath4.mtn (100%) rename {motions => models/pio/motions}/Breath5.mtn (100%) rename {motions => models/pio/motions}/Breath6.mtn (100%) rename {motions => models/pio/motions}/Breath7.mtn (100%) rename {motions => models/pio/motions}/Breath8.mtn (100%) rename {motions => models/pio/motions}/Fail.mtn (100%) rename {motions => models/pio/motions}/Sleeping.mtn (100%) rename {motions => models/pio/motions}/Success.mtn (100%) rename {motions => models/pio/motions}/Sukebei1.mtn (100%) rename {motions => models/pio/motions}/Sukebei2.mtn (100%) rename {motions => models/pio/motions}/Sukebei3.mtn (100%) rename {motions => models/pio/motions}/Touch Dere1.mtn (100%) rename {motions => models/pio/motions}/Touch Dere2.mtn (100%) rename {motions => models/pio/motions}/Touch Dere3.mtn (100%) rename {motions => models/pio/motions}/Touch Dere4.mtn (100%) rename {motions => models/pio/motions}/Touch Dere5.mtn (100%) rename {motions => models/pio/motions}/Touch Dere6.mtn (100%) rename {motions => models/pio/motions}/Touch1.mtn (100%) rename {motions => models/pio/motions}/Touch2.mtn (100%) rename {motions => models/pio/motions}/Touch3.mtn (100%) rename {motions => models/pio/motions}/Touch4.mtn (100%) rename {motions => models/pio/motions}/Touch5.mtn (100%) rename {motions => models/pio/motions}/Touch6.mtn (100%) rename {motions => models/pio/motions}/WakeUp.mtn (100%) rename {textures => models/pio/textures}/default-costume.png (100%) rename {textures => models/pio/textures}/pajamas-costume.png (100%) rename {textures => models/pio/textures}/school-costume.png (100%) diff --git a/Plugin.php b/Plugin.php index d3d8b2b..2ad6fc0 100644 --- a/Plugin.php +++ b/Plugin.php @@ -4,7 +4,7 @@ * * @package Pio * @author Dreamer-Paul - * @version 1.1 + * @version 1.2 * @link https://paugram.com */ @@ -29,17 +29,30 @@ class Pio_Plugin implements Typecho_Plugin_Interface{ echo "

Pio 看版娘插件 (".$version.")

"; echo "

By: Dreamer-Paul

"; echo "

项目介绍 - 更新日志

"; + 更新日志

"; $update = file_get_contents("https://api.paugram.com/update/?name=".$name."¤t=".$version."&site=".$_SERVER['HTTP_HOST']); $update = json_decode($update, true); - if($update['text']){echo "

".$update['text']."

"; }; - if($update['message']){echo "

".$update['message']."

"; }; + if(isset($update['text'])){echo "

".$update['text']."

"; }; + if(isset($update['message'])){echo "

".$update['message']."

"; }; echo ""; } - paul_update("Pio", "1.1"); + paul_update("Pio", "1.2"); + + // 读取模型文件夹 + $models = array(); + $load = glob("../usr/plugins/Pio/models/*"); + + foreach($load as $key => &$value){ + $aaa = substr($value, 26); + $models[$aaa] = ucfirst($aaa); + }; + + // 自定义模型选择 + $choose_models = new Typecho_Widget_Helper_Form_Element_Select('choose_models', $models, 'pio', _t('选择模型'), _t('选择插件 Models 目录下的模型,每个模型为一个文件夹,并确定配置文件名为 model.json')); + $form->addInput($choose_models); // 自定义宽高 $custom_width = new Typecho_Widget_Helper_Form_Element_Text('custom_width', NULL, NULL, _t('自定义宽度'), _t('在这里填入自定义宽度,部分模型需要修改')); @@ -49,7 +62,7 @@ class Pio_Plugin implements Typecho_Plugin_Interface{ $form->addInput($custom_height); // 自定义模型 - $custom_model = new Typecho_Widget_Helper_Form_Element_Text('custom_model', NULL, NULL, _t('自定义配置文件地址'), _t('在这里填入一个模型 JSON 配置文件地址,可供更换模型,不填则使用默认配置文件')); + $custom_model = new Typecho_Widget_Helper_Form_Element_Text('custom_model', NULL, NULL, _t('自定义配置文件地址'), _t('在这里填入一个模型 JSON 配置文件地址,可供使用外链模型,不填则使用插件目录下的模型')); $form->addInput($custom_model); } @@ -82,8 +95,11 @@ class Pio_Plugin implements Typecho_Plugin_Interface{ if(Typecho_Widget::widget('Widget_Options')->Plugin('Pio')->custom_model){ echo "". "\n"; } + else if(Typecho_Widget::widget('Widget_Options')->Plugin('Pio')->choose_models){ + echo "". "\n"; + } else{ - echo "". "\n"; + echo "". "\n"; } } } \ No newline at end of file diff --git a/model.json b/models/pio/model.json similarity index 100% rename from model.json rename to models/pio/model.json diff --git a/model.moc b/models/pio/model.moc similarity index 100% rename from model.moc rename to models/pio/model.moc diff --git a/motions/Breath Dere1.mtn b/models/pio/motions/Breath Dere1.mtn similarity index 100% rename from motions/Breath Dere1.mtn rename to models/pio/motions/Breath Dere1.mtn diff --git a/motions/Breath Dere2.mtn b/models/pio/motions/Breath Dere2.mtn similarity index 100% rename from motions/Breath Dere2.mtn rename to models/pio/motions/Breath Dere2.mtn diff --git a/motions/Breath Dere3.mtn b/models/pio/motions/Breath Dere3.mtn similarity index 100% rename from motions/Breath Dere3.mtn rename to models/pio/motions/Breath Dere3.mtn diff --git a/motions/Breath1.mtn b/models/pio/motions/Breath1.mtn similarity index 100% rename from motions/Breath1.mtn rename to models/pio/motions/Breath1.mtn diff --git a/motions/Breath2.mtn b/models/pio/motions/Breath2.mtn similarity index 100% rename from motions/Breath2.mtn rename to models/pio/motions/Breath2.mtn diff --git a/motions/Breath3.mtn b/models/pio/motions/Breath3.mtn similarity index 100% rename from motions/Breath3.mtn rename to models/pio/motions/Breath3.mtn diff --git a/motions/Breath4.mtn b/models/pio/motions/Breath4.mtn similarity index 100% rename from motions/Breath4.mtn rename to models/pio/motions/Breath4.mtn diff --git a/motions/Breath5.mtn b/models/pio/motions/Breath5.mtn similarity index 100% rename from motions/Breath5.mtn rename to models/pio/motions/Breath5.mtn diff --git a/motions/Breath6.mtn b/models/pio/motions/Breath6.mtn similarity index 100% rename from motions/Breath6.mtn rename to models/pio/motions/Breath6.mtn diff --git a/motions/Breath7.mtn b/models/pio/motions/Breath7.mtn similarity index 100% rename from motions/Breath7.mtn rename to models/pio/motions/Breath7.mtn diff --git a/motions/Breath8.mtn b/models/pio/motions/Breath8.mtn similarity index 100% rename from motions/Breath8.mtn rename to models/pio/motions/Breath8.mtn diff --git a/motions/Fail.mtn b/models/pio/motions/Fail.mtn similarity index 100% rename from motions/Fail.mtn rename to models/pio/motions/Fail.mtn diff --git a/motions/Sleeping.mtn b/models/pio/motions/Sleeping.mtn similarity index 100% rename from motions/Sleeping.mtn rename to models/pio/motions/Sleeping.mtn diff --git a/motions/Success.mtn b/models/pio/motions/Success.mtn similarity index 100% rename from motions/Success.mtn rename to models/pio/motions/Success.mtn diff --git a/motions/Sukebei1.mtn b/models/pio/motions/Sukebei1.mtn similarity index 100% rename from motions/Sukebei1.mtn rename to models/pio/motions/Sukebei1.mtn diff --git a/motions/Sukebei2.mtn b/models/pio/motions/Sukebei2.mtn similarity index 100% rename from motions/Sukebei2.mtn rename to models/pio/motions/Sukebei2.mtn diff --git a/motions/Sukebei3.mtn b/models/pio/motions/Sukebei3.mtn similarity index 100% rename from motions/Sukebei3.mtn rename to models/pio/motions/Sukebei3.mtn diff --git a/motions/Touch Dere1.mtn b/models/pio/motions/Touch Dere1.mtn similarity index 100% rename from motions/Touch Dere1.mtn rename to models/pio/motions/Touch Dere1.mtn diff --git a/motions/Touch Dere2.mtn b/models/pio/motions/Touch Dere2.mtn similarity index 100% rename from motions/Touch Dere2.mtn rename to models/pio/motions/Touch Dere2.mtn diff --git a/motions/Touch Dere3.mtn b/models/pio/motions/Touch Dere3.mtn similarity index 100% rename from motions/Touch Dere3.mtn rename to models/pio/motions/Touch Dere3.mtn diff --git a/motions/Touch Dere4.mtn b/models/pio/motions/Touch Dere4.mtn similarity index 100% rename from motions/Touch Dere4.mtn rename to models/pio/motions/Touch Dere4.mtn diff --git a/motions/Touch Dere5.mtn b/models/pio/motions/Touch Dere5.mtn similarity index 100% rename from motions/Touch Dere5.mtn rename to models/pio/motions/Touch Dere5.mtn diff --git a/motions/Touch Dere6.mtn b/models/pio/motions/Touch Dere6.mtn similarity index 100% rename from motions/Touch Dere6.mtn rename to models/pio/motions/Touch Dere6.mtn diff --git a/motions/Touch1.mtn b/models/pio/motions/Touch1.mtn similarity index 100% rename from motions/Touch1.mtn rename to models/pio/motions/Touch1.mtn diff --git a/motions/Touch2.mtn b/models/pio/motions/Touch2.mtn similarity index 100% rename from motions/Touch2.mtn rename to models/pio/motions/Touch2.mtn diff --git a/motions/Touch3.mtn b/models/pio/motions/Touch3.mtn similarity index 100% rename from motions/Touch3.mtn rename to models/pio/motions/Touch3.mtn diff --git a/motions/Touch4.mtn b/models/pio/motions/Touch4.mtn similarity index 100% rename from motions/Touch4.mtn rename to models/pio/motions/Touch4.mtn diff --git a/motions/Touch5.mtn b/models/pio/motions/Touch5.mtn similarity index 100% rename from motions/Touch5.mtn rename to models/pio/motions/Touch5.mtn diff --git a/motions/Touch6.mtn b/models/pio/motions/Touch6.mtn similarity index 100% rename from motions/Touch6.mtn rename to models/pio/motions/Touch6.mtn diff --git a/motions/WakeUp.mtn b/models/pio/motions/WakeUp.mtn similarity index 100% rename from motions/WakeUp.mtn rename to models/pio/motions/WakeUp.mtn diff --git a/textures/default-costume.png b/models/pio/textures/default-costume.png similarity index 100% rename from textures/default-costume.png rename to models/pio/textures/default-costume.png diff --git a/textures/pajamas-costume.png b/models/pio/textures/pajamas-costume.png similarity index 100% rename from textures/pajamas-costume.png rename to models/pio/textures/pajamas-costume.png diff --git a/textures/school-costume.png b/models/pio/textures/school-costume.png similarity index 100% rename from textures/school-costume.png rename to models/pio/textures/school-costume.png