Project1

标题: 菜单选项前加图标 [打印本页]

作者: 喵kano    时间: 2014-8-18 20:05
标题: 菜单选项前加图标
  于是这回想问下怎样在物品、技能、装备、状态等菜单选项前显示图标,图标由IconSet的编号控制。
作者: taroxd    时间: 2014-8-18 20:17
本帖最后由 taroxd 于 2014-8-18 20:19 编辑


  1. class Window_MenuCommand
  2.   
  3.   # 图标ID。不需要图标的填入0或nil。
  4.   ICON_INDICE = [1,2,3,4,5,6,0]
  5.   
  6.   def draw_item(index)
  7.     rect = item_rect_for_text(index)
  8.     enable = command_enabled?(index)
  9.     draw_icon(ICON_INDICE[index], rect.x, rect.y, enable) if ICON_INDICE[index]
  10.     rect.x += 24
  11.     change_color(normal_color, enable)
  12.     draw_text(rect, command_name(index), alignment)
  13.   end
  14.   
  15. end
复制代码

作者: VIPArcher    时间: 2014-8-18 21:06
本帖最后由 VIPArcher 于 2014-8-18 21:51 编辑

暴力点用这个 draw_text_ex  会怎样呢?
使用方法系统用语\那些写着按钮名字的一切地方
结果就是这样的笑果
  1. class Window_Command < Window_Selectable
  2.   def draw_item(index)
  3.     change_color(normal_color, command_enabled?(index))
  4.     rect = item_rect_for_text(index)
  5.     draw_text_ex(rect.x, rect.y, command_name(index))
  6.   end
  7. end
复制代码

作者: ナイフ君    时间: 2014-8-21 15:40
楼上的干嘛非要自己写
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Command Window Icons v1.00
  4. # -- Last Updated: 2011.12.11
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-CommandWindowIcons"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2011.12.11 - Started Script and Finished.
  15. #
  16. #==============================================================================
  17. # ▼ Introduction
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # Here's a script that allows you to allocate icons to each of your commands
  20. # provided that the text for the command matches the icon in the script. There
  21. # are, however, some scripts that this won't be compatible with and it's due
  22. # to them using unique way of drawing out their commands. This script does not
  23. # maintain compatibility for those specific scripts.
  24. #
  25. #==============================================================================
  26. # ▼ Instructions
  27. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  28. # To install this script, open up your script editor and copy/paste this script
  29. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  30. #
  31. # Go to the module and match the text under ICON_HASH with a proper Icon ID.
  32. # You can find an icon's ID by opening up the icon select window in the RPG
  33. # Maker VX Ace database and look in the lower left corner.
  34. #
  35. #==============================================================================
  36. # ▼ Compatibility
  37. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  38. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  39. # it will run with RPG Maker VX without adjusting.
  40. #
  41. #==============================================================================

  42. module YEA
  43.   module COMMAND_WINDOW_ICONS
  44.    
  45.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  46.     # - Icon Hash -
  47.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  48.     # This hash controls all of the icon data for what's used with each text
  49.     # item. Any text items without icons won't display icons. The text has to
  50.     # match with the hash (case sensitive) to display icons.
  51.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  52.     ICON_HASH ={
  53.     # Matching Text   => Icon ID,
  54.       "New Game"      => 224,    # Title scene.
  55.       "Continue"      => 230,    # Title scene.
  56.       "Shutdown"      => 368,    # Title scene. Game End scene.
  57.       
  58.       "Fight"         => 386,    # Battle scene.
  59.       "Escape"        => 328,    # Battle scene.
  60.       "Attack"        => 116,    # Battle scene.
  61.       "Defend"        => 506,    # Battle scene.
  62.       
  63.       "Special Skill" => 128,    # Skill scene. Battle scene.
  64.       "Magic"         => 136,    # Skill scene. Battle scene.
  65.       
  66.       "Items"         => 260,    # Menu scene. Item scene. Battle scene.
  67.       "Skills"        => 143,    # Menu scene.
  68.       "Equipment"     => 436,    # Menu scene.
  69.       "Status"        => 121,    # Menu scene.
  70.       "Formation"     =>  12,    # Menu scene.
  71.       "Save"          => 286,    # Menu scene.
  72.       "Game End"      => 368,    # Menu scene.
  73.       
  74.       "Weapons"       => 386,    # Item scene.
  75.       "Armors"        => 436,    # Item scene.
  76.       "Key Items"     => 243,    # Item scene.
  77.       
  78.       "To Title"      => 224,    # Game End scene.
  79.       "Cancel"        => 119,    # Game End scene.
  80.     } # Do not remove this.
  81.    
  82.   end # COMMAND_WINDOW_ICONS
  83. end # YEA

  84. #==============================================================================
  85. # ▼ Editting anything past this point may potentially result in causing
  86. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  87. # halitosis so edit at your own risk.
  88. #==============================================================================

  89. #==============================================================================
  90. # ■ Window_Command
  91. #==============================================================================

  92. class Window_Command < Window_Selectable
  93.   
  94.   #--------------------------------------------------------------------------
  95.   # new method: use_icon?
  96.   #--------------------------------------------------------------------------
  97.   def use_icon?(text)
  98.     return YEA::COMMAND_WINDOW_ICONS::ICON_HASH.include?(text)
  99.   end
  100.   
  101.   #--------------------------------------------------------------------------
  102.   # new method: command_icon
  103.   #--------------------------------------------------------------------------
  104.   def command_icon(text)
  105.     return YEA::COMMAND_WINDOW_ICONS::ICON_HASH[text]
  106.   end
  107.   
  108.   #--------------------------------------------------------------------------
  109.   # overwrite method: draw_item
  110.   #--------------------------------------------------------------------------
  111.   def draw_item(index)
  112.     enabled = command_enabled?(index)
  113.     change_color(normal_color, enabled)
  114.     rect = item_rect_for_text(index)
  115.     text = command_name(index)
  116.     if use_icon?(text)
  117.       draw_icon_text(rect.clone, text, alignment, enabled)
  118.     else
  119.       draw_text(rect, text, alignment)
  120.     end
  121.   end
  122.   
  123.   #--------------------------------------------------------------------------
  124.   # new method: draw_icon_text
  125.   #--------------------------------------------------------------------------
  126.   def draw_icon_text(rect, text, alignment, enabled)
  127.     cw = text_size(text).width
  128.     icon = command_icon(text)
  129.     draw_icon(icon, rect.x, rect.y, enabled)
  130.     rect.x += 24
  131.     rect.width -= 24
  132.     draw_text(rect, text, alignment)
  133.   end
  134.   
  135. end # Window_Command

  136. #==============================================================================
  137. #
  138. # ▼ End of File
  139. #
  140. #==============================================================================
复制代码

作者: tseyik    时间: 2014-8-21 16:01
文字拡張功能
https://rpg.blue/thread-224143-1-1.html
RM在文本模式可用不同指令加上不同效果(如顔色、icon)
這個脚本就是把這指令拡張到其他地方
这个脚本允许你使用特殊的信息代码,在任何一个窗口,而不仅仅是信息窗口和帮助窗口。要添加一个图标旁边的菜单命令?这个脚本,你可以做的多。

注:在文本中使用特殊的消息代码,将让这个文本将不会自動收缩,如果超出其指定的宽度。可能會不正常顕示。

使用方法
只要在指令前面加上\*
如\c[5]Hand Axe\c[0]; 改成 \*\c[5]Hand Axe\c[0]
効果





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1