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

Project1

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

[已经解决] 菜单选项前加图标

[复制链接]

Lv4.逐梦者

运否天赋

梦石
10
星屑
5243
在线时间
3567 小时
注册时间
2014-5-15
帖子
1599

开拓者

跳转到指定楼层
1
发表于 2014-8-18 20:05:20 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  于是这回想问下怎样在物品、技能、装备、状态等菜单选项前显示图标,图标由IconSet的编号控制。
土猫三国开发完成

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2014-8-18 20:17:49 | 只看该作者
本帖最后由 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
复制代码

点评

期待你的坑哦~  发表于 2014-8-18 20:34
测试可用,感谢xd君。  发表于 2014-8-18 20:33

评分

参与人数 1梦石 +1 收起 理由
VIPArcher + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv4.逐梦者 (版主)

无限の剣制

梦石
0
星屑
10073
在线时间
5020 小时
注册时间
2013-2-28
帖子
5030

开拓者贵宾

3
发表于 2014-8-18 21:06:23 | 只看该作者
本帖最后由 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
复制代码

点评

破VA本体 我真是机智  发表于 2014-8-18 22:06
对齐方式不重要,加空格来搞(啥?(ΦωΦ)  发表于 2014-8-18 22:02
不写在数据库常量,直接在内部按钮上面改,啊!我真是机智。  发表于 2014-8-18 21:58
改光了 Window_Command ,那么 alignment 怎么办?那些居中显示的指令怎么办?  发表于 2014-8-18 21:58
实际上以前有某人写过一样的东西 算法一样 而他的目的就是……任何时候都可以这样用  发表于 2014-8-18 21:57
回复 支持 反对

使用道具 举报

Lv1.梦旅人

进击的屌丝
中二同好会长

梦石
0
星屑
50
在线时间
628 小时
注册时间
2013-10-8
帖子
1246

贵宾

4
发表于 2014-8-21 15:40:01 | 只看该作者
楼上的干嘛非要自己写
  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. #==============================================================================
复制代码

点评

非常好的腳本 !  发表于 2016-8-26 18:21
支持国产!(`・ω・)  发表于 2014-8-21 15:47
吾乃不明事理之人,疯狂之人。


才怪咧,当时是怎么想到这么中二的句子233
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
22713
在线时间
8623 小时
注册时间
2011-12-31
帖子
3367
5
发表于 2014-8-21 16:01:56 | 只看该作者
文字拡張功能
https://rpg.blue/thread-224143-1-1.html
RM在文本模式可用不同指令加上不同效果(如顔色、icon)
這個脚本就是把這指令拡張到其他地方
这个脚本允许你使用特殊的信息代码,在任何一个窗口,而不仅仅是信息窗口和帮助窗口。要添加一个图标旁边的菜单命令?这个脚本,你可以做的多。

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

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-25 23:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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