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

Project1

 找回密码
 注册会员
搜索
Project1 查看内容

鼠标脚本选项页的滚动

2008-3-15 21:29| 发布者: 风雪优游| 查看: 3192| 评论: 0|原作者: 水迭澜|来自: 点此进入发布帖

摘要: #==============================================================================# 本脚本来自www.66RPG.com,使用和转载请保留此信息#============================================================================== class Window_Selectable 

#==============================================================================
# 本脚本来自
www.66RPG.com,使用和转载请保留此信息
#==============================================================================

class Window_Selectable
  if @self_alias == nil
    alias self_update update
    @self_alias = true
  end
  def update
    #self.cursor_rect.empty
    self_update
    if self.active and @item_max > 0
      index_var = @index
      tp_index = @index
      mouse_x, mouse_y = Mouse.get_mouse_pos
      mouse_not_in_rect = true
      for i in 0...@item_max
        @index = i
        update_cursor_rect
        top_x = self.cursor_rect.x + self.x + 16
        top_y = self.cursor_rect.y + self.y + 16
        bottom_x = top_x + self.cursor_rect.width
        bottom_y = top_y + self.cursor_rect.height
        if (mouse_x > top_x) and (mouse_y > top_y) and
           (mouse_x < bottom_x) and (mouse_y < bottom_y)
          mouse_not_in_rect = false
          if tp_index != @index
            tp_index = @index
            $game_system.se_play($data_system.cursor_se)
          end
          break
        end
      end
      if mouse_not_in_rect
        #  row = @index / @column_max
          # 当前行被显示开头行前面的情况下
          if self.top_row < row_max-page_row_max and Mouse.press?(Mouse::LEFT) and mouse_y>self.y+self.height/2
            self.top_row +=1
          end
          # 当前行被显示末尾行之后的情况下
          if self.top_row > 0 and Mouse.press?(Mouse::LEFT) and mouse_y<=self.y+self.height/2#self.top_row + (self.page_row_max - 1)
            # 从当前行向末尾滚动
            self.top_row -=1
          end
        @index = index_var
        if self.is_a?(Window_Target)
          @index=-3
        end
        update_cursor_rect
        Mouse.click_lock
      else
        Mouse.click_unlock              
      end
    end
  end
  def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.cursor_rect.empty
      return
    end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.cursor_rect.empty
      return
    end
    # 计算光标的宽
    cursor_width = self.width / @column_max - 32
    # 计算光标坐标
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    # 更新光标矩形
    self.cursor_rect.set(x, y, cursor_width, 32)
  end
end

#==============================================================================
# 本脚本来自
www.66RPG.com,使用和转载请保留此信息
#==============================================================================

2

鲜花

刚表态过的朋友 (2 人)

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

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

GMT+8, 2024-5-4 09:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部