查看: 3760|回复: 1

[已经解决] 图片选项脚本的一些问题

[复制链接]
梦石
0
星屑
70
在线时间
1083 小时
注册时间
2013-3-29
回帖
2158
发表于 2015-7-12 22:23:34 | 显示全部楼层 |阅读模式

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

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

×
附件:
图片选项.rar (1.44 MB, 下载次数: 115)
打开菜单:
menu1.jpg
无异状
指向选项:
menu2.jpg
红圈的地方有原来的痕迹……
移开选项:
menu3.jpg
又有选中时的图片残留着……怎么解决?
相关脚本:
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ 图片选项(修改Window_Selectable 和 Window_Command)by 只有金刚心
  4. #  (不支持鼠标)
  5. #------------------------------------------------------------------------------
  6. # 使用方法:按照VA默认的在窗口添加指令的原方法add_command,多填写上参数就可以了。
  7. # 新增参数:
  8. # usepic - 是否使用图片,如果使用图片,则填写true,反正false
  9. # usepic的参数默认false,即不存在图片时使用VA默认的文字指令
  10. # pic- 默认显示图片,默认nil
  11. # over_pic - 当正在选择时的图片,即光标移动上去的图片,默认nil
  12. # overd - 是否已经选择,无需填写
  13. # 例如:add_command("新游戏", :new_game, true, nil, true, "图片1.png", "图片2.png")
  14. #==============================================================================

  15. class Window_Selectable < Window_Base
  16.   #--------------------------------------------------------------------------
  17.   # ● 处理光标的移动
  18.   #--------------------------------------------------------------------------
  19.   def process_cursor_move
  20.     return unless cursor_movable?
  21.     last_index = @index
  22.     cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
  23.     cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
  24.     cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
  25.     cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
  26.     cursor_pagedown   if !handle?(:pagedown) && Input.trigger?(:R)
  27.     cursor_pageup     if !handle?(:pageup)   && Input.trigger?(:L)
  28.    
  29.     #★★当光标移动时重新绘制指令★★
  30.     if @index != last_index
  31.     Sound.play_cursor
  32.     #重置指令的参数overd为false
  33.     move_overd_pic?(last_index)
  34.     draw_all_items
  35.     end
  36.   
  37.   end
  38.   
  39.   #--------------------------------------------------------------------------
  40.   # ● 更新光标
  41.   #--------------------------------------------------------------------------
  42.   def update_cursor
  43.     if @cursor_all
  44.       cursor_rect.set(0, 0, contents.width, row_max * item_height)
  45.       self.top_row = 0
  46.     elsif @index < 0
  47.       cursor_rect.empty
  48.     else

  49.       #★★更新图片指令★★
  50.       if pic_or_text(@index) == true
  51.         cursor_rect.empty
  52.         overd_pic?(@index)
  53.         redraw_item(@index)
  54.       #保留原来的光标
  55.       else
  56.       ensure_cursor_visible
  57.       cursor_rect.set(item_rect(@index))
  58.       end
  59.    
  60.     end
  61.   end
  62.   
  63.   #★★图片指令函数★★  
  64.   def pic_or_text(index)
  65.   end
  66.   def overd_pic(index)
  67.   end
  68.   
  69. end  

  70. class Window_Command < Window_Selectable
  71.   
  72.   #★★添加指令★★
  73.   #(保留原指令:name-指令名称,symbol-对应的符号,enabled-有效状态的标志,ext-任意的扩展数据)
  74.   #(新增参数usepic-是否使用图片,pic-默认显示图片,over_pic-当正在选择时的图片,overd-是否已经选择)
  75.   def add_command(name, symbol, enabled = true, ext = nil, usepic = false, pic = nil, over_pic = nil,overd = false)
  76.     @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext,:usepic=>usepic, :pic=>pic, :over_pic=>over_pic, :overd=>overd})
  77.   end
  78.   
  79.   #★★绘制图片指令★★
  80.   def draw_item(index)
  81.     #绘制图片指令
  82.     if @list[index][:usepic] == true && @list[index][:pic] != nil
  83.       if @list[index][:over_pic] != nil  && @list[index][:overd] == true
  84.         @bitmap = Cache.picture(@list[index][:over_pic])
  85.       else
  86.         @bitmap = Cache.picture(@list[index][:pic])
  87.       end
  88.     rect = Rect.new(0, 0, @bitmap.width, @bitmap.height)
  89.     #图片指令的坐标参照文字指令
  90.     contents.blt(index % col_max * (item_width + spacing), index / col_max * item_height, @bitmap, rect)
  91.     @bitmap.dispose
  92.     #保留原来的文字指令
  93.     else
  94.     change_color(normal_color, command_enabled?(index))
  95.     draw_text(item_rect_for_text(index), command_name(index), alignment)
  96.     end  
  97.   end
  98.   
  99.   #★★判断使用图片还是文字★★
  100.   def current_usepic?
  101.     current_data ? current_data[:usepic] : false
  102.   end
  103.   
  104.   def pic_or_text(index)
  105.     return current_usepic?
  106.   end
  107.   
  108.   #★★判断光标是否移动到图片上★★
  109.   def move_overd_pic?(index)
  110.     @list[index][:overd] = false
  111.   end
  112.   
  113.   def overd_pic?(index)
  114.     @list[index][:overd] = true
  115.   end
  116.   
  117. end
复制代码
  1. class Window_MenuCommand < Window_Command
  2.   def add_main_commands
  3.     add_command(Vocab::status, :status, true, nil, true, "MENUNOTE", "MENUNOTE_1")
  4.   end
复制代码

坑的进度如上                                                                                                        点击↑
梦石
0
星屑
76
在线时间
1379 小时
注册时间
2012-7-5
回帖
1643

开拓者

发表于 2015-7-13 17:15:27 | 显示全部楼层
在你给的工程 35行 上插一句
  1. contents.clear
复制代码
完

评分

参与人数 2星屑 +1 梦石 +1 收起 理由
VIPArcher + 1 完
冷峻逸 + 1 认可答案

查看全部评分


  -fk: -azogi:
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部