设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3465|回复: 0
打印 上一主题 下一主题

[搬运汉化] 一个和namepop相似的插件,支持事件页切换时变更显示文字

[复制链接]

Lv2.观梦者

梦石
0
星屑
637
在线时间
164 小时
注册时间
2012-4-18
帖子
264
跳转到指定楼层
1
发表于 2016-1-20 11:46:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 salvareless 于 2016-1-20 12:09 编辑

这是一个从MOG系列系统中抽出来的一个插件,原来的名字叫做MOG_EventText.js.
它的作用和namepop一致,不同之处在于不像namepop那样可以单独定义字体的大小和位置。
但优点在于它的注释是以说明(注释)的形式写在事件页当中的,而不是事件注释位置,这样就可以做到namepop无法做到的一件事:同一事件在执行不同事件页的时候显示不同的名字。
之前也是有朋友在namepop中问到这个功能,虽然原始的namepop不是我发的,但还是应该帮助有需要的朋友。
当时他给了我一个日文插件,但是我没弄懂,所以我就拿MOG_EventText.js,稍微改了下让它可以注释颜色,以满足那位朋友的需要。
这个插件的用法是:在事件页里面的第一行(注意不是事件名称和注释栏,是些事件内容的页面里),选择事件命令里面左下角的那个说明(以前叫注释)的选项,然后写入eventtext|测试|#ff0000。注意分割符,中间不留空格。颜色不能为空,为空会显示奇异的黑色= =白色的代码是#ffffff。
你可以在同一个事件的不同页中设置不同的标签,通过独立开关或者其他让事件激活不同页的方式来切换事件头上显示的文字。
以下为代码。
  1. //=============================================================================
  2. // MOG_EventText.js
  3. //=============================================================================

  4. /*:
  5. * @plugindesc (v1.0) Adiciona um texto em cima do evento.
  6. * @author Moghunter
  7. *
  8. * @param X axis
  9. * @desc Definição da posição X-axis.
  10. * @default 0
  11. *
  12. * @param Y axis
  13. * @desc Definição da posição Y-axis.
  14. * @default 0
  15. *
  16. * @param Font Size
  17. * @desc Definição do tamanho da fonte.
  18. * @default 18
  19. *
  20. * @help  
  21. * =============================================================================
  22. * +++ MOG - Event Text (v1.0) +++
  23. * By Moghunter
  24. * https://atelierrgss.wordpress.com/
  25. * =============================================================================
  26. * Adiciona um texto acima do evento, útil para fazer tutoriais.
  27. * =============================================================================
  28. * Para ativar o texto no evento use o seguinte comentário no evento.
  29. *
  30. *  event text: TEXT
  31. *
  32. * Exemplo.
  33. *
  34. *  event text: I'm The Boss
  35. *
  36. */

  37. //=============================================================================
  38. // ** PLUGIN PARAMETERS
  39. //=============================================================================
  40.   var Imported = Imported || {};
  41.   Imported.MOG_EventText = true;
  42.   var Moghunter = Moghunter || {};

  43.    Moghunter.parameters = PluginManager.parameters('MOG_EventText');
  44.     Moghunter.charText_x = Number(Moghunter.parameters['X axis'] || 0);
  45.         Moghunter.charText_y = Number(Moghunter.parameters['Y axis'] || 0);
  46.     Moghunter.charText_Size = Number(Moghunter.parameters['Font Size'] || 18);
  47.         
  48. //=============================================================================
  49. // ** Character Base
  50. //=============================================================================

  51. //==============================
  52. // * Init Members
  53. //==============================
  54. var _alias_mog_eventext_cbase_initMembers = Game_CharacterBase.prototype.initMembers;
  55. Game_CharacterBase.prototype.initMembers = function() {
  56.     _alias_mog_eventext_cbase_initMembers.call(this);
  57.         this._char_text = [false,""];
  58. };

  59. //=============================================================================
  60. // ** Game Event
  61. //=============================================================================

  62. //==============================
  63. // * Setup Page
  64. //==============================
  65. var _alias_mog_eventext_gevent_setupPage = Game_Event.prototype.setupPage;
  66. Game_Event.prototype.setupPage = function() {
  67.         _alias_mog_eventext_gevent_setupPage.call(this);
  68.     this.check_event_text();
  69. };

  70. //==============================
  71. // * Check Event Text
  72. //==============================
  73. Game_Event.prototype.check_event_text = function() {
  74.         this._need_clear_text = true
  75.         if (!this._erased && this.page()) {this.list().forEach(function(l) {
  76.                if (l.code === 108) {var comment = l.parameters[0].split('|')
  77.                            if (comment[0].toLowerCase() == "eventtext"){
  78.                   this._char_text = [true,String(comment[1]),String(comment[2])];
  79.                                   this._need_clear_text = false;                          
  80.                            };};
  81.         }, this);};
  82.         if (this._need_clear_text) {this._char_text = [true,""]};
  83. };

  84. //=============================================================================
  85. // ** Sprite Character
  86. //=============================================================================

  87. //==============================
  88. // * Initialize
  89. //==============================
  90. var _alias_mog_eventext_schar_initialize = Sprite_Character.prototype.initialize;
  91. Sprite_Character.prototype.initialize = function(character) {
  92.     _alias_mog_eventext_schar_initialize.call(this,character);
  93.         if (this._character && this._character._eventId) {this._character.check_event_text()};
  94. };

  95. //=============================================================================
  96. // ** Spriteset Map
  97. //=============================================================================

  98. //==============================
  99. // * create Lower Layer
  100. //==============================
  101. var _alias_mog_eventext_srmap_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;
  102. Spriteset_Map.prototype.createLowerLayer = function() {
  103.         _alias_mog_eventext_srmap_createLowerLayer.call(this);
  104.         this.create_event_text_field();
  105. };

  106. //==============================
  107. // * create Event Text Field
  108. //==============================
  109. Spriteset_Map.prototype.create_event_text_field = function() {
  110.         this._etextField = new Sprite();
  111.         this._baseSprite.addChild(this._etextField);
  112.         this._sprite_char_text = [];
  113.         for (var i = 0; i < this._characterSprites.length; i++) {
  114.              this._sprite_char_text[i] = new Sprite_CharText(this._characterSprites[i]);
  115.                  this._etextField.addChild(this._sprite_char_text[i]);
  116.     };
  117. };

  118. //=============================================================================
  119. // ** Sprite CharText
  120. //=============================================================================
  121. function Sprite_CharText() {
  122.     this.initialize.apply(this, arguments);
  123. };

  124. Sprite_CharText.prototype = Object.create(Sprite.prototype);
  125. Sprite_CharText.prototype.constructor = Sprite_CharText;

  126. //==============================
  127. // * Initialize
  128. //==============================
  129. Sprite_CharText.prototype.initialize = function(target) {
  130.     Sprite.prototype.initialize.call(this);
  131.         this.sprite_char = target;
  132. };

  133. //==============================
  134. // * Character
  135. //==============================
  136. Sprite_CharText.prototype.character = function() {
  137.          return this.sprite_char._character;
  138. };

  139. //==============================
  140. // * Update Char Text
  141. //==============================
  142. Sprite_CharText.prototype.update = function() {
  143.         Sprite.prototype.update.call(this);
  144.         if (this.character()._char_text[0]) {this.refresh_char_text()};
  145.         if (!this._char_text) {return};
  146.         this._char_text.x = this.textX_axis();
  147.         this._char_text.y = this.textY_axis();
  148. };

  149. //==============================
  150. // * Create Char Text
  151. //==============================
  152. Sprite_CharText.prototype.create_char_text = function() {
  153.          if (this._char_text) {this.removeChild(this._char_text)};
  154.          if (this.character()._char_text[1] === "") {return};
  155.      this._char_text = new Sprite(new Bitmap(90,32));
  156.          this._char_text.anchor.x = 0.5;
  157.          this._char_text.y = -(this.sprite_char.patternHeight());
  158.          this._char_text.bitmap.fontSize = Moghunter.charText_Size;
  159.          this.addChild(this._char_text);
  160. };

  161. //==============================
  162. // * Refresh Char Text
  163. //==============================
  164. Sprite_CharText.prototype.refresh_char_text = function() {
  165.     this.create_char_text();
  166.         this.character()._char_text[0] = false;
  167.         if (this.character()._char_text[1] === "") {return};
  168.         var text = this.character()._char_text[1];
  169.         this._char_text.bitmap.clear();
  170.         var color = this.character()._char_text[2];
  171.         this._char_text.bitmap.textColor = color;
  172.         this._char_text.bitmap.drawText(text,0,0,90,32,"center");
  173. };

  174. //==============================
  175. // * Text X Axis
  176. //==============================
  177. Sprite_CharText.prototype.textX_axis = function() {
  178.         return Moghunter.charText_x + this.sprite_char.x;
  179. };

  180. //==============================
  181. // * Text Y Axis
  182. //==============================
  183. Sprite_CharText.prototype.textY_axis = function() {
  184.         return -(this.sprite_char.patternHeight() + 24) + Moghunter.charText_y + this.sprite_char.y;
  185. };
复制代码

评分

参与人数 2梦石 +1 +1 收起 理由
mcxiguajun + 1 我很赞同
余烬之中 + 1 塞糖

查看全部评分

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-14 20:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表