赞 | 2 |
VIP | 109 |
好人卡 | 208 |
积分 | 4 |
经验 | 22037 |
最后登录 | 2024-11-11 |
在线时间 | 1198 小时 |
Lv2.观梦者 虚構歪曲
- 梦石
- 0
- 星屑
- 364
- 在线时间
- 1198 小时
- 注册时间
- 2010-12-18
- 帖子
- 3928
|
- #==============================================================================
- # ■ Window_Picture_Command
- #------------------------------------------------------------------------------
- # 创建一个图片按钮的窗口类。
- #==============================================================================
- class Window_Picture_Command < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # width : 窗口的宽
- # commands : 命令字符串序列
- #--------------------------------------------------------------------------
- def initialize(commands,type=1)
- # 由命令的个数计算出窗口的高
- super(0, 0, 640, 480)
- # self.z = 9999
- @item_max = commands.size
- @commands = commands
- @dash = []
- @sprite = []
- @type = type
- @move_index = self.index
- self.opacity = 0
- self.contents = Bitmap.new(width - 32, @item_max * 32)
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_picture_item(i, @type)
- end
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- for index in @dash
- if @sprite[index] != nil
- @sprite[index].dispose
- @sprite[index].bitmap.dispose
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘图片项目
- # index : 项目编号
- # type : 描绘类型
- # type = 1 只支持键盘
- # type = 2 双面支持
- #--------------------------------------------------------------------------
- def draw_picture_item(index, type)
- @sprite[index] = Sprite.new
- if @commands[index][0] == nil
- p "图片名设置有误"
- end
- if @commands[index][1] == nil
- p "图片X坐标设置有误"
- end
- if @commands[index][2] == nil
- p "图片Y坐标设置有误"
- end
- bitmap = RPG::Cache.picture("../Commands/" + @commands[index][0])
- @sprite[index].bitmap = bitmap
- @sprite[index].x = @commands[index][1]
- @sprite[index].y = @commands[index][2]
- # @sprite[index].z = 999999
- @sprite[index].index = index
- if @sprite[index].index != self.index
- @sprite[index].color = Color.new(0,0,0,100)
- else
- @sprite[index].color = Color.new(0,0,0,0)
- end
- @dash.push(index)
- end
- #--------------------------------------------------------------------------
- # ● 刷新图片项目
- #--------------------------------------------------------------------------
- def update_item
- if @type == 2
- for index in @dash
- if @sprite[index] != nil
- top_x = @sprite[index].x
- top_y = @sprite[index].y
- bottom_x = top_x + @sprite[index].bitmap.width
- bottom_y = top_y + @sprite[index].bitmap.height
- if ($mouse_x > top_x) and ($mouse_y > top_y) and
- ($mouse_x < bottom_x) and ($mouse_y < bottom_y)
- self.index = @sprite[index].index
- if @move_index != self.index
- Se.ok
- @move_index = self.index
- end
- end
- if @sprite[index].index != self.index
- @sprite[index].color = Color.new(0,0,0,100)
- else
- @sprite[index].color = Color.new(0,0,0,0)
- end
- end
- end
- elsif @type == 1
- for index in @dash
- if @sprite[index].index != self.index
- @sprite[index].color = Color.new(0,0,0,100)
- else
- @sprite[index].color = Color.new(0,0,0,0)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 图片项目无效化
- # index : 项目编号
- #--------------------------------------------------------------------------
- def disable_item(index)
- @sprite[index].color = Color.new(0,0,0,100)
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- alias window_picture_command_update update
- def update
- window_picture_command_update
- update_item
- end
- #--------------------------------------------------------------------------
- # ● 更新光标举行
- #--------------------------------------------------------------------------
- def update_cursor_rect
- if @index < 0
- self.cursor_rect.empty
- return
- end
- row = @index / @column_max
- if row < self.top_row
- self.top_row = row
- end
- if row > self.top_row + (self.page_row_max - 1)
- self.top_row = row - (self.page_row_max - 1)
- 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+5000, y, cursor_width, 32)
- end
- end
- #==============================================================================
- # ■ Se
- #------------------------------------------------------------------------------
- # ■ 音效模块
- #==============================================================================
- module Se
- def self.ok
- $game_system.se_play($data_system.cursor_se)
- end
- def self.no
- $game_system.se_play($data_system.cancel_se)
- end
- end
- #==============================================================================
- # ■ Sprite
- #------------------------------------------------------------------------------
- # ■ index 选择光标
- #==============================================================================
- class Sprite
- attr_accessor :index
- end
复制代码 事件……长篇大论呢,还是脚本吧。
|
|