Project1

标题: 怎么让选择项的光标不闪呢? [打印本页]

作者: a5858520    时间: 2022-9-5 00:20
标题: 怎么让选择项的光标不闪呢?
怎么让选择项的光标不闪来闪去呢?
作者: 我为鱼肉    时间: 2022-9-5 11:52
本帖最后由 我为鱼肉 于 2022-9-5 13:33 编辑

原创脚本,插入main前会有立竿见影的效果。如果新建了窗口,需要照猫画虎在脚本尾处继续添加
思路就是,隐藏默认光标,用新生成的sprite代替。

RUBY 代码复制
  1. #==============================
  2. #系统cursor。不再闪烁
  3. #==============================
  4.  
  5. #多了一个Window_SaveFile另类,只好Window_Base,不然可以把内容全放在Window_Selectable
  6. #==============================
  7. #通用窗口
  8. #未重定义update_cursor_rect
  9. #==============================
  10. class Window_Base < Window
  11.   alias rgss1_init_for_cursor initialize unless method_defined? :rgss1_init_for_cursor
  12.   def initialize(*args)
  13.     rgss1_init_for_cursor(*args)
  14.     @cursor_sprite = Sprite.new(self.viewport)
  15.     @cursor_sprite.visible = false
  16.     @cursor_sprite.x = 16 + self.x
  17.     @cursor_sprite.y = 16 + self.y
  18.     @cursor_sprite.z = self.z + 1
  19.   end
  20.   alias rgss1_x_for_cursor x= unless method_defined? :rgss1_x_for_cursor
  21.   def x=(x)
  22.     rgss1_x_for_cursor(x)
  23.     return if @cursor_sprite.nil?
  24.     @cursor_sprite.x = 16 + x
  25.   end
  26.   alias rgss1_y_for_cursor y= unless method_defined? :rgss1_y_for_cursor
  27.   def y=(y)
  28.     rgss1_y_for_cursor(y)
  29.     return if @cursor_sprite.nil?
  30.     @cursor_sprite.y = 16 + y
  31.   end
  32.   alias rgss1_z_for_cursor z= unless method_defined? :rgss1_z_for_cursor
  33.   def z=(z)
  34.     rgss1_z_for_cursor(z)
  35.     return if @cursor_sprite.nil?
  36.     @cursor_sprite.z = 1 + z
  37.   end
  38.   alias rgss1_vis_for_cursor visible= unless method_defined? :rgss1_vis_for_cursor
  39.   def visible=(visible)
  40.     rgss1_vis_for_cursor(visible)
  41.     return if @cursor_sprite.nil?
  42.     @cursor_sprite.visible = false unless visible
  43.   end
  44.   alias rgss1_dis_for_cursor dispose unless method_defined? :rgss1_dis_for_cursor
  45.   def dispose
  46.     @cursor_sprite.dispose
  47.     rgss1_dis_for_cursor
  48.   end
  49.   def update_cursor_sprite
  50.     return if self.cursor_rect.width == 0 or self.cursor_rect.height == 0
  51.     if @index.is_a?(Integer)
  52.       if @index < 0 ; @cursor_sprite.visible = false ; return ; end
  53.     else
  54.       unless @selected ; @cursor_sprite.visible = false ; return ; end
  55.     end
  56.     cursor_x = self.cursor_rect.x
  57.     cursor_y = self.cursor_rect.y
  58.     cursor_width = self.cursor_rect.width
  59.     cursor_height = self.cursor_rect.height
  60.     self.cursor_rect.empty
  61.     if @cursor_sprite.bitmap.nil? or @cursor_sprite.bitmap.width != cursor_width or @cursor_sprite.bitmap.height != cursor_height
  62.       if @cursor_sprite.bitmap
  63.         @cursor_sprite.bitmap.dispose
  64.         @cursor_sprite.bitmap = nil
  65.       end
  66.       @cursor_sprite.bitmap = Bitmap.new(cursor_width, cursor_height)
  67.       dest_rect = Rect.new(0, 0, cursor_width, 1)
  68.       src_rect = Rect.new(128, 64, 32, 1)
  69.       @cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
  70.       dest_rect.set(0, cursor_height - 1, cursor_width, 1)
  71.       src_rect.set(128, 64, 32, 1)
  72.       @cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
  73.       dest_rect.set(0, 0, 1, cursor_height)
  74.       src_rect.set(128, 64, 1, 32)
  75.       @cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
  76.       dest_rect.set(cursor_width - 1, 0, 1, cursor_height)
  77.       src_rect.set(128, 64, 1, 32)
  78.       @cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
  79.       dest_rect.set(0, 0, cursor_width, cursor_height)
  80.       src_rect.set(130, 66, 28, 28)
  81.       @cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
  82.     end
  83.     @cursor_sprite.x = 16 + self.x + cursor_x
  84.     @cursor_sprite.y = 16 + self.y + cursor_y
  85.     @cursor_sprite.visible = true
  86.   end
  87. end
  88. class Window_Selectable < Window_Base
  89.   alias rgss1_index_for_cursor index= unless method_defined? :rgss1_index_for_cursor
  90.   def index=(index)
  91.     rgss1_index_for_cursor(index)
  92.     return if @cursor_sprite.nil?
  93.     @cursor_sprite.visible = false if index < 0
  94.   end
  95.   alias rgss1_active_for_cursor active= unless method_defined? :rgss1_active_for_cursor
  96.   def active=(active)
  97.     rgss1_active_for_cursor(active)
  98.     return if @cursor_sprite.nil?
  99.     @cursor_sprite.visible = false unless active
  100.   end
  101.   alias rgss1_upcur_for_cursor update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor
  102.   def update_cursor_rect
  103.     rgss1_upcur_for_cursor
  104.     update_cursor_sprite if self.active
  105.   end
  106. end
  107.  
  108.  
  109. #==============================
  110. #一般窗口
  111. #重定义了update_cursor_rect
  112. #其他的窗口,照猫画虎就行了
  113. #==============================
  114. class Window_MenuStatus < Window_Selectable
  115.   alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
  116.   def update_cursor_rect
  117.     rgss1_upcur_for_cursor_subclass
  118.     update_cursor_sprite if self.active
  119.   end
  120. end
  121. class Window_Target < Window_Selectable
  122.   alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
  123.   def update_cursor_rect
  124.     rgss1_upcur_for_cursor_subclass
  125.     update_cursor_sprite if self.active
  126.   end
  127. end
  128. class Window_Message < Window_Selectable
  129.   alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
  130.   def update_cursor_rect
  131.     rgss1_upcur_for_cursor_subclass
  132.     update_cursor_sprite if self.active
  133.   end
  134. end
  135. class Window_PartyCommand < Window_Selectable
  136.   alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
  137.   def update_cursor_rect
  138.     rgss1_upcur_for_cursor_subclass
  139.     update_cursor_sprite if self.active
  140.   end
  141. end
  142. class Window_SaveFile < Window_Base
  143.   alias rgss1_sele_for_cursor selected= unless method_defined? :rgss1_sele_for_cursor
  144.   def selected=(selected)
  145.     rgss1_sele_for_cursor(selected)
  146.     @cursor_sprite.visible = false unless @selected
  147.   end
  148.   alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
  149.   def update_cursor_rect
  150.     rgss1_upcur_for_cursor_subclass
  151.     update_cursor_sprite
  152.   end
  153. end


作者: 纯属小虫    时间: 2022-9-5 12:01
在main之前加上
class Window
  alias update_forbid update
  def update
    return
  end
end




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