找回密码
 注册用户
查看: 162|回复: 0

[RMMV] 【有改动】选项显示图片

[复制链接]

88

主题

7

回帖

1277

积分

资深会员

积分
1277
发表于 2024-5-31 17:49:05 | 显示全部楼层 |阅读模式
本帖最后由 烁灵 于 2024-6-20 17:48 编辑

在选择某个选项时显示图片。
对原脚本有修改,可以使用变量的值指定图片名。

原地址:MV Choice Pictures | Galv's RPG Maker Scripts & Plugins (galvs-scripts.com)


效果:
QQ图片20240531173258.png


范例:https://www.123pan.com/s/uBKyVv-CzF3A.html 提取码:SXdx


脚本:命名为 Galv_ChoicePictures.js
  1. //-----------------------------------------------------------------------------
  2. //  Galv's Choice Pictures
  3. //-----------------------------------------------------------------------------
  4. //  For: RPGMAKER MV
  5. //  Galv_ChoicePictures.js
  6. //-----------------------------------------------------------------------------
  7. //  2017-09-17 - Version 1.2 - Added code to remove an overwrite
  8. //  2017-03-01 - Version 1.1 - made compatible with HIME hidden choices
  9. //  2016-12-10 - Version 1.0 - release
  10. //-----------------------------------------------------------------------------
  11. // Terms can be found at:
  12. // galvs-scripts.com
  13. //-----------------------------------------------------------------------------

  14. var Imported = Imported || {};
  15. Imported.Galv_ChoicePictures = true;

  16. var Galv = Galv || {};                  // Galv's main object
  17. Galv.CPICS = Galv.CPICS || {};          // Galv's stuff

  18. //-----------------------------------------------------------------------------
  19. /*:
  20. * @plugindesc (v.1.2) 根据当前选中的选项显示不同的图片 定制-支持读取变量中的文件名.
  21. * 汉化&修改 by 烁灵 更多脚本请访问 www.hknmtt.com
  22. * @author Galv - galvs-scripts.com
  23. *
  24. * @param Choice Picture Id
  25. * @text 显示图片编号
  26. * @desc 这个图片编号将用来显示选项图片
  27. * @default 1
  28. *
  29. * @help
  30. *   Galv's Choice Pictures
  31. * ----------------------------------------------------------------------------
  32. * 这个插件可以使当前选项选中时在屏幕中显示图片
  33. * 需要在选项文本中使用以下标签来使用本功能
  34. *
  35. *   <p:imageName,x,y>     // imageName指定 /img/pictures/ 文件夹中的图片文件名
  36. *                         // 本脚本改动:可以使用 v[n] 指定图片名为变量 n 的值
  37. *                         // x,y 是图片中心的坐标
  38. *
  39. * 将使用指定的编号显示图片,这表示已经使用该图片编号显示的图片会被替换
  40. * ----------------------------------------------------------------------------
  41. */



  42. //-----------------------------------------------------------------------------
  43. //  CODE STUFFS
  44. //-----------------------------------------------------------------------------

  45. (function() {

  46. Galv.CPICS.pidId = Number(PluginManager.parameters('Galv_ChoicePictures')["Choice Picture Id"]);
  47. Galv.CPICS.picList = [];

  48. Galv.CPICS.getPics = function() {
  49.         Galv.CPICS.picList = [];
  50.         if (!$gameMessage._choices) return;
  51.         for (var i = 0; i < $gameMessage._choices.length; i++) {
  52.                 var txt = $gameMessage._choices[i].match(/<p:(.*)>/i);
  53.                 if (txt) Galv.CPICS.setPic(i,txt);
  54.         }
  55. };

  56. Galv.CPICS.setPic = function(index,txt) {
  57.         $gameMessage._choices[index] = $gameMessage._choices[index].replace(txt[0],'');
  58.         var opts = txt[1].split(',');
  59.         var variableTxt = opts[0].match(/v\[(\d+)\]/);
  60.         if (variableTxt) {
  61.                 opts[0] = $gameVariables.value(Number(variableTxt[1]));
  62.         }
  63.         Galv.CPICS.picList[index] = {img:opts[0],x:Number(opts[1]),y:Number(opts[2])};
  64. };

  65. Galv.CPICS.showPic = function(obj) {
  66.         $gameScreen.showPicture(Galv.CPICS.pidId, obj.img, 1, obj.x, obj.y, 100, 100, 255, 0);
  67. };

  68. Galv.CPICS.erasePic = function(obj) {
  69.         $gameScreen.erasePicture(Galv.CPICS.pidId);
  70. };


  71. //-----------------------------------------------------------------------------
  72. //  WINDOW CHOICE
  73. //-----------------------------------------------------------------------------

  74. Galv.CPICS.Window_ChoiceList_callUpdateHelp = Window_ChoiceList.prototype.callUpdateHelp;
  75. Window_ChoiceList.prototype.callUpdateHelp = function() {
  76.         Galv.CPICS.Window_ChoiceList_callUpdateHelp.call(this);
  77.         var i = this.index();
  78.         if (this.active && Galv.CPICS.picList[i]) {
  79.         Galv.CPICS.showPic(Galv.CPICS.picList[i]);
  80.     } else {
  81.                 Galv.CPICS.erasePic();
  82.         }
  83. };

  84. Galv.CPICS.Window_ChoiceList_start = Window_ChoiceList.prototype.start;
  85. Window_ChoiceList.prototype.start = function() {
  86.         Galv.CPICS.getPics();
  87.         Galv.CPICS.Window_ChoiceList_start.call(this);
  88. };

  89. })();


  90. if (Imported.HiddenChoiceConditions) {
  91. // HIME hide choices
  92. Galv.CPICS.Window_ChoiceList_makeCommandList = Window_ChoiceList.prototype.makeCommandList;
  93. Window_ChoiceList.prototype.makeCommandList = function() {
  94.         Galv.CPICS.Window_ChoiceList_makeCommandList.call(this);
  95.         Galv.CPICS.getPics();
  96.         var needsUpdate = false;
  97.         for (var i = 0; i < this._list.length; i++) {
  98.                 var txt = this._list[i].name.match(/<p:(.*)>/i);
  99.                 if (txt) {
  100.                         this._list[i].name = this._list[i].name.replace(txt[0],'');
  101.                         needsUpdate = true;
  102.                 }
  103.         }
  104.         if (needsUpdate) this.updatePlacement();
  105. };
  106. }
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册用户

本版积分规则

Archiver|QQ群: 48625831|爱上RPG|哈库纳玛塔塔 |网站地图 Clicky

GMT+8, 2024-10-23 13:22 , Processed in 0.066415 second(s), 22 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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