赞 | 0 |
VIP | 0 |
好人卡 | 3 |
积分 | 1 |
经验 | 8526 |
最后登录 | 2017-4-28 |
在线时间 | 81 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 81 小时
- 注册时间
- 2016-1-6
- 帖子
- 150
|
根据你的需要,重新修改了之前帮人做的显示头像位置的脚本,添加了调整语速的功能。你用用看,我测试过有效。
该脚本原始模板是Yami Engine Delta - Word Wrap,我在此基础上增加了左右方向显示对话头像和调整语速两个小功能。
使用方法:下载代码后命名为YED_WordWrap.js,加载该脚本后,在需要改语速的对话框里,文首加入<speed:x>
x设为你需要的语速,1的话就是1/4秒,最高可设为99,代码如下:- /*:
- * Yami Engine Delta - Word Wrap
- *
- * @plugindesc This plugin provides word wrap feature, so that a long text
- * will be properly broken down into lines.
- * @author Yami Engine Delta [Dr.Yami]
- *
- * @param Break Word
- * @desc Allows unbreakable words to be broken.
- * @default true
- *
- * @param Right Face
- * @desc 允许对话框头像可以左右切换。(默认值改不改其实都起效。)
- * @default false
- *
- * @param Dialog Speed
- * @desc 可以设置对话速度。(请于对话框中设置语速。)
- * @default 0
- *
- * @help
- * The word wrap isn't enabled by default. To activate word wrap in any text,
- * for example in Message, you have to put following code into the text:
- *
- * ------------
- * <wrap>
- * ------------
- *
- * The word wrapper will nullify the break lines in editor, so that you have
- * to manually break line by using following code in text:
- *
- * ------------
- * <br>
- * ------------
- *
- * 新添加的左右头像对话效果,需要在文本开头输入以下字符:
- * 如果不输入则默认头像在左侧。
- *
- * ------------
- * <right>
- * ------------
- *
- * 新添加的语速调整效果,需要在文本开头输入以下字符:
- * x处替换为小于100的正整数形,1为1/4秒,以此类推
- *
- * ------------
- * <speed:x>
- * ------------
- *
- * ============================================================================
- */
- /**
- * @namespace WordWrap
- * @memberof YED
- */
- var YED = YED || {};
- // init WordWrap module
- YED.WordWrap = {};
- YED.WordWrap.BreakWord
- = PluginManager.parameters('YED_WordWrap')['Break Word'];
- YED.WordWrap.RightFace
- = PluginManager.parameters('YED_WordWrap')['Right Face'];
- YED.WordWrap.Speed
- = PluginManager.parameters('YED_WordWrap')['Dialog Speed'];
-
- (function($WordWrap) {
- var _Window_Base_processNormalCharacter
- = Window_Base.prototype.processNormalCharacter;
- var _Window_Base_convertEscapeCharacters
- = Window_Base.prototype.convertEscapeCharacters;
-
- var breakWord = eval($WordWrap.BreakWord);
- Window_Message.prototype.drawMessageFace = function() {
- if (this._rightFace){
- this.drawFace($gameMessage.faceName(), $gameMessage.faceIndex(), Graphics.boxWidth-216, 0);//rightface
- }else{
- this.drawFace($gameMessage.faceName(), $gameMessage.faceIndex(), 0, -100);//leftface
- }
- };
- Window_Message.prototype.newLineX = function() {
- if (this._rightFace){
- return $gameMessage.faceName() === '' ? 0 : 0;//rightface
- }else{
- return $gameMessage.faceName() === '' ? 0 : 168;//leftface
- }
- };
-
- Window_Base.prototype.textAreaWidth = function() {
- return this.contentsWidth();
- };
- Window_Base.prototype.needWrap = function(textState) {
- var c = textState.text[textState.index],
- w = this.textWidth(c),
- nextSpaceIndex = 0,
- nextWord = "",
- nextWidth = 0,
- text = textState.text;
- if (!this._wordWrap) {
- return false;
- }
-
- if (this._rightFace){
- if (breakWord && (textState.x + w * 2) >= this.textAreaWidth()-144) {//rightface
- textState.index--; // hack for missing character
- return true;
- }
- }else{
- if (breakWord && (textState.x + w * 2) >= this.textAreaWidth()) {//leftface
- textState.index--; // hack for missing character
- return true;
- }
- }
- if (!breakWord && c === " ") {
- nextSpaceIndex = text.indexOf(" ", textState.index + 1);
- if (nextSpaceIndex < 0) {
- nextSpaceIndex = text.length + 1;
- }
- nextWord = text.substring(textState.index, nextSpaceIndex);
- nextWidth = this.textWidth(nextWord);
-
- if (this._rightFace){
- if (textState.x + nextWidth >= this.textAreaWidth()-144) {//rightface
- return true;
- }
- }else{
- if (textState.x + nextWidth >= this.textAreaWidth()) {//leftface
- return true;
- }
- }
- }
- return false;
- };
- Window_Base.prototype.convertEscapeCharacters = function(text) {
- text = _Window_Base_convertEscapeCharacters.call(this, text);
- text = this.convertWordWrapEscapeCharacters(text);
- return text;
- };
- Window_Base.prototype.convertWordWrapEscapeCharacters = function(text) {
- text = this.enableWordWrap(text);
-
- if (!!this._wordWrap) {
- text = text.replace(/[\n\r]+/g, '');
- text = text.replace(/\<br\>/gi, '\n');
- }
- return text;
- };
- Window.prototype.enableWordWrap = function(text) {
- this._wordWrap = false;
- this._rightFace = false;
- this._speed = false;
- if (!!text.match(/\<wrap\>/i)) {
- this._wordWrap = true;
- }
- if (!!text.match(/\<right\>/i)) {
- this._rightFace = true;
- }
- //if (!!text.match(/\<speed:1\>/i)) {//此处为只检测速度1的情况
- if (!!text.match(/\<speed/i)) {
- this._speed = true;
- }
- text = text.replace(/\<wrap\>/gi, '');
- text = text.replace(/\<right\>/gi, '');
- //text = text.replace(/\<speed:1\>/gi,'');
- text = text.replace(/\<speed/gi,'');
- /*//此处为只检测速度1的情况
- if(this._speed){
- text1 = text.split("") ;
- var text2="";
- for(i = 0;i <text1.length;i ++){
- text2+=(text1[i]+'\x1b.');
- }
- text=text2;
- }
- */
- if(this._speed){
- text1 = text.split("") ;
- var text2="";
- var textStart=(text1[2]=='>'?3:4);
- var speedNum=parseInt(text1[1]+text1[2]);
- for( textStart ;textStart <text1.length;textStart ++){
- text2+=text1[textStart];
- for(var j = 0 ; j < speedNum ; j ++){
- text2 +='\x1b.';
- }
- }
- text=text2;
- }
- return text;
- };
- Window_Base.prototype.processNormalCharacter = function(textState) {
- if (this.needWrap(textState)) {
- return this.processNewLine(textState);
- }
- _Window_Base_processNormalCharacter.call(this, textState);
- };
- }(YED.WordWrap));
复制代码 |
|