设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 56|回复: 0

[转载发布] One Line Battle Message Plugin (Updated With New Parameters)

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    4 天前
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    4594

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    23195
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    28683

    灌水之王

    发表于 前天 19:32 | 显示全部楼层 |阅读模式
    Remember the SimpleMsgSideView plugin that programmed the Battle Log Window for RPG Maker MV to display the battle log/message as a single line message but only for the side-view battle?  The OneLineBattleMessage plugin is similar to that plugin, but unlike the other plugin, the OneLineBattleMessage will work with the front-view battle and the side-view battle.  Here are the screenshots of the plugin in action during the front-view battle:







    Now, here are the screenshots of the plugin in action during the side-view battle:







    The plugin will also let you change the message speed (from 0 to 30) as well as change the window skin image (which should be in the same graphic format as the Window image file unless you choose to have no window displayed behind the text).  For the load window skin function, I created that type of function that's exclusive to the plugin.  I personally don't think that there's any risk of having a complete override to the loadWindowskin function for this plugin, but just to be on the safe as you never know if someone will create a plugin that may rely on the window properties from the Battle Log Window, I decided to create a function that's not a complete override to the loadWindowskin function as a precaution against any potential conflict with other plugins.  Here's the screenshot of the plugin:





    The plugin is copyleft and open-source, so there's no need for you to give me credit for the plugin and you are free to modify the plugin if you wish to do so.  Here's the code for the plugin:

    Spoiler: ONE LINE BATTLE MESSAGE PLUGIN CODE
                    JavaScript:       
    1. //=============================================================================
    2. // OneLineBattleMessage.js
    3. //=============================================================================
    4. /*:
    5. * @target MZ
    6. * @plugindesc Displays the Battle Log as a one-line battle message.
    7. * @author N/A (open-source, copyleft)
    8. *
    9. * @help OneLineBattleMessage.js
    10. *
    11. * This plugin displays the Battle Log as a one-line battle message at the
    12. * top window.  The window and the font that are used for the Battle Log
    13. * Window can be customized through the BL Window Properties and the BL Font
    14. * Properties.
    15. *
    16. * This plugin does not provide plugin commands.
    17. *
    18. * The following is about the parameters that are found in the Font Properties
    19. * structure:
    20. *
    21. * About Font Filename - The Font Filename is for the main font file that will
    22. * be used for the text.  The main font file must be located at the fonts
    23. * folder of the game project.  The filename of the font file must include the
    24. * format type (for example, Times.ttf).  If Font Filename is left blank, then
    25. * the Fallback Font (which is identified through Fallback Font Name) will be
    26. * used for the text.
    27. *
    28. * About Fallback Font Name - If Fallback Font Name is left blank, then Verdana
    29. * will be used as the Fallback Font.
    30. *
    31. * About Text Color Index - The Text Color Index uses the Message Window color
    32. * index for the text color.  The color index can be obtained by going through
    33. * the following steps:
    34. * 1. Go to Show Text on Event Commands
    35. * 2. Right-click on the Text space to open Show Text menu
    36. * 3. Choose Insert Color Index
    37. * 4. Pick the color choice for the text and press OK
    38. * 5. Write down the number, which is the color index for that color choice
    39. * 6. Use that number for the Text Color Index on Font Properties
    40. *
    41. * About Outline Color - The Outline Color can be typed as either a color name
    42. * or a hex code and the names as well as the hex codes for the colors can be
    43. * found on documentations about javascript.  For the hex code, the number
    44. * sign (#) must be included in front of the hex code (for example, #ffffffff).
    45. * In order to not have an outline around the text, the word "transparent" can
    46. * be used instead of either the color name or the hex code.
    47. *
    48. * @param battleLogWindow
    49. * @type struct<windowProperties>
    50. * @default {"windowName":"Window","windowBackground":"0","windowPlacement":"0","windowBackOpacity":"192"}
    51. * @text BL Window Properties
    52. * @desc Window properties for the Battle Log Window
    53. *
    54. * @param battleLogFont
    55. * @type struct<fontProperties>
    56. * @default {"fontFile":"mplus-1m-regular.woff","fontName":"Verdana","fontSize":"26","fontBold":"false","fontItalic":"false","textColorIndex":"0","outlineColor":"transparent"}
    57. * @text BL Font Properties
    58. * @desc Font properties for the Battle Log text
    59. *
    60. * @param textAlignment
    61. * @type select
    62. * @option Center
    63. * @value center
    64. * @option Left
    65. * @value left
    66. * @default center
    67. * @text Text Alignment
    68. * @desc Alignment of the text within the window
    69. *
    70. * @param messageSpeed
    71. * @type number
    72. * @min 0
    73. * @max 30
    74. * @default 16
    75. * @text Message Speed
    76. * @desc Message Speed value (0 - 30)
    77. *
    78. * @param constantOpenness
    79. * @type boolean
    80. * @on On
    81. * @off Off
    82. * @default false
    83. * @text Constant Window Openness
    84. * @desc Turn on/off constant openness for battle message window.  This works only during the battle turn.
    85. */
    86. /*~struct~windowProperties:
    87. * @param windowName
    88. * @type string
    89. * @default Window
    90. * @text Window
    91. * @desc Filename of the window
    92. *
    93. * @param windowBackground
    94. * @type select
    95. * @option Window
    96. * @value 0
    97. * @option Dim
    98. * @value 1
    99. * @option Transparent
    100. * @value 2
    101. * @default 0
    102. * @text Window Background
    103. * @desc Background option for the window
    104. *
    105. * @param windowPlacement
    106. * @type select
    107. * @option Top
    108. * @value 0
    109. * @option Bottom
    110. * @value 1
    111. * @default 0
    112. * @text Window Placement
    113. * @desc Placement option for the window within the screen. The window always remain above the status window.
    114. *
    115. * @param windowBackOpacity
    116. * @type number
    117. * @min 0
    118. * @max 255
    119. * @default 192
    120. * @text Window Back Opacity
    121. * @desc Opacity of the window background (0 - 255)
    122. */
    123. /*~struct~fontProperties:
    124. * @param fontFile
    125. * @type string
    126. * @default mplus-1m-regular.woff
    127. * @text Font Filename
    128. * @desc Filename of the main font for the text.  Include format type with the font filename.
    129. *
    130. * @param fontName
    131. * @type string
    132. * @default Verdana
    133. * @text Fallback Font Name
    134. * @desc Name of the Fallback Font for the text
    135. *
    136. * @param fontSize
    137. * @type number
    138. * @min 8
    139. * @max 32
    140. * @default 26
    141. * @text Font Size
    142. * @desc Size of the font used for the text (8 - 32)
    143. *
    144. * @param fontBold
    145. * @type boolean
    146. * @on On
    147. * @off Off
    148. * @default false
    149. * @text Font Bold
    150. * @desc Turn on/off bold for the text
    151. *
    152. * @param fontItalic
    153. * @type boolean
    154. * @on On
    155. * @off Off
    156. * @default false
    157. * @text Font Italic
    158. * @desc Turn on/off italic for the text
    159. *
    160. * @param textColorIndex
    161. * @type number
    162. * @min 0
    163. * @max 31
    164. * @default 0
    165. * @text Text Color Index
    166. * @desc Color index for the text color (0 - 31).  Use the color index from the Show Text Event Command.
    167. *
    168. * @param outlineColor
    169. * @type string
    170. * @default transparent
    171. * @text Outline Color
    172. * @desc Color of the text outline.  Type the name/hex code of the javascript color or type "transparent" for no outline.
    173. */
    174. (() => {
    175.       //-----------------------------------------------------------------------------
    176.     // PluginManager
    177.     //
    178.       const pluginName = "OneLineBattleMessage";
    179.     const parameters = PluginManager.parameters(pluginName);
    180.     const battleLogWindow = JsonEx.parse(parameters['battleLogWindow'] || {"windowName":"Window"});
    181.     const windowName = String(battleLogWindow.windowName || '');
    182.     const windowBackground = Number(battleLogWindow.windowBackground || 0);
    183.     const windowPlacement = Number(battleLogWindow.windowPlacement || 0);
    184.     const windowBackOpacity = Number(battleLogWindow.windowBackOpacity || 192);
    185.     const battleLogFont = JsonEx.parse(parameters['battleLogFont'] || {"fontFile":"mplus-1m-regular.woff"});
    186.     const fontFile = String(battleLogFont.fontFile || '');
    187.     const fontName = String(battleLogFont.fontName || 'Verdana');
    188.     const fontSize = Number(battleLogFont.fontSize || 26);
    189.     const fontBold = eval(battleLogFont.fontBold || false);
    190.     const fontItalic = eval(battleLogFont.fontItalic || false);
    191.     const textColorIndex = Number(battleLogFont.textColorIndex || 0);
    192.     const outlineColor = String(battleLogFont.outlineColor || 'transparent');
    193.     const textAlignment = String(parameters['textAlignment'] || 'center');
    194.     const messageSpeed = Number(parameters['messageSpeed'] || 16);
    195.     const constantOpenness = eval(parameters['constantOpenness'] || false);
    196.       //-----------------------------------------------------------------------------
    197.     // Window_BattleLog
    198.     //
    199.     // The window for displaying battle progress. No frame is displayed, but it is
    200.     // handled as a window for convenience.
    201.     Window_BattleLog.prototype.initialize = function(rect) {
    202.         Window_Base.prototype.initialize.call(this, rect);
    203.         this.openness = 0;
    204.         this.opacity = 255;
    205.         this._lines = [];
    206.         this._methods = [];
    207.         this._waitCount = 0;
    208.         this._waitMode = "";
    209.         this._baseLineStack = [];
    210.         this._spriteset = null;
    211.         this._messageStarted = false;
    212.         this.refresh();
    213.     };
    214.     Window_BattleLog.prototype.setStatusWindowHeight = function(statusWindowHeight) {
    215.         this._statusWindowHeight = statusWindowHeight;
    216.     }
    217.     Window_BattleLog.prototype.updatePlacement = function() {
    218.         const height = this._statusWindowHeight + this.height;
    219.         this.y = (windowPlacement * (Graphics.boxHeight - height));
    220.     };
    221.     Window_BattleLog.prototype.loadBattleLogWindowskin = function() {
    222.         this.windowskin = ImageManager.loadSystem(windowName);
    223.     };
    224.     Window_BattleLog.prototype.updateBattleLogWindowBackground = function() {
    225.         this.setBackgroundType(windowBackground);
    226.     };
    227.     Window_BattleLog.prototype.updateBattleLogBackOpacity = function() {
    228.         this.backOpacity = windowBackOpacity;
    229.     };
    230.     Window_BattleLog.prototype.setBattleLogFont = function() {
    231.         if (fontFile !== '') {
    232.             FontManager.load("rmmz-battlelogfont", fontFile);
    233.             this.contents.fontFace = "rmmz-battlelogfont";
    234.         } else {
    235.             this.contents.fontFace = fontName;
    236.         }
    237.         this.contents.fontSize = fontSize;
    238.         this.contents.fontBold = fontBold;
    239.         this.contents.fontItalic = fontItalic;
    240.         this.changeTextColor(ColorManager.textColor(textColorIndex));
    241.         this.changeOutlineColor(outlineColor);
    242.     };
    243.     Window_BattleLog.prototype.messageSpeed = function() {
    244.         return messageSpeed;
    245.     };
    246.     Window_BattleLog.prototype.update = function() {
    247.         if (constantOpenness) {
    248.             if ((BattleManager.isInTurn()) && (this._messageStarted)) {
    249.                 this.openness = 255;
    250.             } else if ((BattleManager.isTurnEnd()) || (BattleManager.isBattleEnd())) {
    251.                 this.openness = 0;
    252.                 this._messageStarted = false;
    253.             }
    254.         }
    255.         if (!this.updateWait()) {
    256.             this.callNextMethod();
    257.         }
    258.     };
    259.     Window_BattleLog.prototype.clear = function() {
    260.         if (!(constantOpenness)) {
    261.             this.openness = 0;
    262.         }
    263.         this._lines = [];
    264.         this._baseLineStack = [];
    265.         this.refresh();
    266.     };
    267.     Window_BattleLog.prototype.addText = function(text) {
    268.         if (text) {
    269.             if (!(constantOpenness)) {
    270.                 this.openness = 255;
    271.             } else if ((constantOpenness)) {
    272.                 if (!(this._messageStarted)) {
    273.                     this.openness = 255;
    274.                     this._messageStarted = true;
    275.                 }
    276.             }
    277.             this._lines.push(text);
    278.             this.refresh();
    279.             this.wait();
    280.         }
    281.     };
    282.     Window_BattleLog.prototype.refresh = function() {
    283.         this.contents.clear();
    284.         this.updatePlacement();
    285.         this.loadBattleLogWindowskin();
    286.         this.updateBattleLogWindowBackground();
    287.         this.updateBattleLogBackOpacity();
    288.         this.setBattleLogFont();
    289.         for (let i = 0; i < this._lines.length; i++) {
    290.             this.drawLineText(i);
    291.         }
    292.     };
    293.     Window_BattleLog.prototype.drawLineText = function(index) {
    294.         const rect = new Rectangle(0, 0, this.innerWidth, this.innerHeight);
    295.         this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
    296.         this.drawText(this._lines[index], rect.x, rect.y, rect.width, textAlignment);
    297.     };
    298.     //-----------------------------------------------------------------------------
    299.     // Scene_Battle
    300.     //
    301.     // The scene class of the battle screen.
    302.     Scene_Battle.prototype.createLogWindow = function() {
    303.         const rect = this.logWindowRect();
    304.         const statusWindowHeight = this.statusWindowRect().height;
    305.         this._logWindow = new Window_BattleLog(rect);
    306.         this._logWindow.setStatusWindowHeight(statusWindowHeight);
    307.         this.addWindow(this._logWindow);
    308.     };
    309.     Scene_Battle.prototype.logWindowRect = function() {
    310.         const wx = 0;
    311.         const wy = 0;
    312.         const ww = Graphics.boxWidth;
    313.         const wh = this.calcWindowHeight(1, false);
    314.         return new Rectangle(wx, wy, ww, wh);
    315.     };
    316. })();
    复制代码


    In addition to the code, I'll be attaching the OneLineBattleMessage plugin to this post.  If I notice that there's any mistake or error in the plugin that I may have overlooked, then I'll update the code and upload the plugin attachment with the fix(es).

    UPDATE: I have added more parameters/features to the plugin, and as a result, I uploaded the updated plugin as well as copy/pasted the updated code for the plugin under the spoiler tag above and replaced an earlier screenshot of the plugin with a new screenshot of the plugin.  The Message Speed parameter is still a standalone parameter, but Window is now part of the BL (Battle Log) Window Properties structure with three other parameters on that structure.




    In addition to the BL Window Properties structure, there is also the BL Font Properties structure, which handles the font properties.




    Finally, there are two new standalone parameters: Text Alignment and Constant Window Openness.  The Text Alignment allows you to choose between Center alignment and Left alignment for the text, while Constant Window Openness is for the ones that prefer for the Battle Message Window to stay constantly open during the battle turn instead of it opening when there's text and closing when there's no text.






    Let me know if you have any question about one of the parameters, please!  For now, here's a screenshot that shows the plugin making use of couple of its new parameters/features.





    本贴来自国际rpgmaker官方论坛作者:Lion Blade Soler处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/one-line-battle-message-plugin-updated-with-new-parameters.128178/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-16 14:21 , Processed in 0.120652 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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