赞 | 0 |
VIP | 13 |
好人卡 | 0 |
积分 | 129 |
经验 | 77844 |
最后登录 | 2024-11-16 |
在线时间 | 1047 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 12946
- 在线时间
- 1047 小时
- 注册时间
- 2007-12-15
- 帖子
- 188
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
几个月前写的一个脚本,与原版相比增强了部分功能,整合了动态光标(可以同时使用多种),使用了 猫哥哥 的 Bitmap 模糊化脚本。
主脚本:
- #==============================================================================
- # ■ Class_WindowSZ
- #------------------------------------------------------------------------------
- # 新的游戏内窗口的类。 By 洛克人SZ
- #==============================================================================
- class WindowSZ < Object
- #--------------------------------------------------------------------------
- # ● 定义常量
- #--------------------------------------------------------------------------
- BK_SIZE = 16 # 边框宽度(单位:像素)
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :cursor_rect # 光标的矩形
- attr_accessor :cursor_a # 动态光标 类型 A
- attr_accessor :cursor_a_s # 动态光标 类型 A 静态
- attr_accessor :cursor_b # 动态光标 类型 B
- attr_accessor :arrow_cr_id_max # 箭头 ID 最大数
- attr_accessor :arrow_cr_id # 箭头 ID
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize(viewport = Viewport.new(0,0,64,64))
- @viewportsz = viewport
- @viewportcr = Viewport.new(0,0,64,64)
- @self_wz = self.get_viewport_rect
- @rect = Array.new(7)
- @rect[0] = Rect.new(128, 0, BK_SIZE, BK_SIZE)
- @rect[1] = Rect.new(128, 64 - BK_SIZE, BK_SIZE, BK_SIZE)
- @rect[2] = Rect.new(192 - BK_SIZE, 0, BK_SIZE, BK_SIZE)
- @rect[3] = Rect.new(192 - BK_SIZE, 64 - BK_SIZE, BK_SIZE, BK_SIZE)
- @psize = [64, 64]
- @stretchsz = true
- @activesz = true
- @visiblesz = true
- @pausesz = false
- @opacitysz = 255
- @windowbg = Sprite.new
- @windowbk = Sprite.new
- @windownr = nil
- @windowskin = Bitmap.new(192, 128)
- @cursor_rect = Sprite_Cursor_Rect.new(@viewportsz)
- @cursor_rect.empty
- @pausecr = Sprite_Pause_Cursor.new(@viewportcr)
- @arrowcr = []
- @arrowcrp = []
- for i in 0..3
- @arrowcr.push(Sprite_Arrow_Cursor.new(@viewportcr, i))
- @arrowcrp.push(false)
- end
- @arrow_cr_id_max = 1
- @arrow_cr_id = 0
- self.set_name
- self.set_self_wz
- self.set_window(@self_wz.width, @self_wz.height)
- @disposedsz = false
- #GC.start
- end
- def set_window(widthcc, heightcc)
- unless widthcc == @psize[0] and heightcc == @psize[1]
- tdata1 = [BK_SIZE, BK_SIZE * 2,
- widthcc - 4, heightcc - 4, heightcc - @rect[1].height,
- widthcc - @rect[2].width, widthcc - @rect[3].width,
- heightcc - @rect[3].height]
- #bitmapcc = Bitmap.new(widthcc, heightcc)
- @windowbg.bitmap.dispose if @windowbg.bitmap != nil
- #@windowbg.bitmap.clear
- @windowbg.bitmap = nil
- @windowbg.bitmap = Bitmap.new(widthcc, heightcc)
- if @stretchsz
- rectcc = nil
- rectcc = Rect.new(2, 2, tdata1[2], tdata1[3])
- @rect[4] = Rect.new(2, 2, 124, 124)
- @windowbg.bitmap.stretch_blt(rectcc,@windowskin,@rect[4])
- rectcc = nil
- else
- if widthcc <= 124 and heightcc <= 124
- @rect[4] = Rect.new(2, 2, tdata1[2], tdata1[3])
- @windowbg.bitmap.blt(2,2,@windowskin,@rect[4])
- elsif widthcc > 124 and heightcc > 124
- @rect[4] = Rect.new(2, 2, 124, 124)
- cntt = [widthcc / 124, widthcc % 124, heightcc / 124, heightcc % 124]
- for i in 0...cntt[2]
- @rect[4].width = 124
- for l in 0...cntt[0]
- @windowbg.bitmap.blt(2+l*124,2+i*124,@windowskin,@rect[4])
- end
- @rect[4].width = cntt[1]
- @windowbg.bitmap.blt(2+l*124+124,2+i*124,@windowskin,@rect[4])
- end
- @rect[4].width, @rect[4].height = 124, cntt[3]
- for l in 0...cntt[0]
- @windowbg.bitmap.blt(2+l*124,2+i*124+124,@windowskin,@rect[4])
- end
- @rect[4].width = cntt[1]
- @windowbg.bitmap.blt(2+l*124+124,2+i*124+124,@windowskin,@rect[4])
- elsif widthcc > 124 and heightcc <= 124
- @rect[4] = Rect.new(2, 2, 124, tdata1[3])
- cntt = [widthcc / 124, widthcc % 124, tdata1[3]]
- for i in 0...cntt[0]
- @windowbg.bitmap.blt(2+i*124,2,@windowskin,@rect[4])
- end
- @rect[4].width = cntt[1]
- @windowbg.bitmap.blt(2+i*124+124,2,@windowskin,@rect[4])
- elsif widthcc <= 124 and heightcc > 124
- @rect[4] = Rect.new(2, 2, tdata1[2], 124)
- cntt = [heightcc / 124, heightcc % 124, tdata1[2]]
- for i in 0...cntt[0]
- @windowbg.bitmap.blt(2,2+i*124,@windowskin,@rect[4])
- end
- @rect[4].height = cntt[1]
- @windowbg.bitmap.blt(2,2+i*124+124,@windowskin,@rect[4])
- end
- end
- @windowbg.bitmap.blur
- #bitmapcc.dispose
- #bitmapcc = nil
- @windowbk.bitmap.dispose if @windowbk.bitmap != nil
- #@windowbk.bitmap.clear
- @windowbk.bitmap = nil
- @windowbk.bitmap = Bitmap.new(widthcc, heightcc)
- #bitmapcc = Bitmap.new(widthcc, heightcc)
- # @windowbk.bitmap.stretch_blt(Rect.new(0,0,widthcc,heightcc),@windowskin,Rect.new(128,0,64,64))
- @windowbk.bitmap.blt(0, 0, @windowskin, @rect[0])
- @windowbk.bitmap.blt(0, tdata1[4], @windowskin, @rect[1])
- @windowbk.bitmap.blt(tdata1[5], 0, @windowskin, @rect[2])
- @windowbk.bitmap.blt(tdata1[6], tdata1[7],@windowskin, @rect[3])
- tdata2 = [widthcc - tdata1[1], 64 - tdata1[1],
- heightcc - tdata1[1]]
- if tdata2[0] <= tdata2[1]
- @rect[5] = [0, @rect[0].dup]
- @rect[5][1].width = tdata2[0]
- @rect[5][1].x, @rect[5][1].y = 128 + tdata1[0], 0
- else
- @rect[5] = [1, tdata2[0] / tdata2[1], tdata2[0] % tdata2[1], 128 + tdata1[0], 0, 64 - tdata1[0]]
- end
- if @rect[5][0] == 1
- for i in 0...@rect[5][1]
- @windowbk.bitmap.blt(tdata1[0] + i * tdata2[1], 0, @windowskin, Rect.new(@rect[5][3], @rect[5][4], 64 - tdata1[1], tdata1[0]))
- @windowbk.bitmap.blt(tdata1[0] + i * tdata2[1], tdata1[4], @windowskin, Rect.new(@rect[5][3], @rect[5][5], 64 - tdata1[1], tdata1[0]))
- end
- wht = (tdata1[0] + i * tdata2[1]) + tdata2[1]
- @windowbk.bitmap.blt(wht, 0, @windowskin, Rect.new(@rect[5][3], @rect[5][4], @rect[5][2], tdata1[0]))
- @windowbk.bitmap.blt(wht, tdata1[4], @windowskin, Rect.new(@rect[5][3], @rect[5][5], @rect[5][2], tdata1[0]))
- wht = nil
- else
- @windowbk.bitmap.blt(tdata1[0], 0, @windowskin, @rect[5][1])
- @rect[5][1].y = 64 - tdata1[0]
- @windowbk.bitmap.blt(tdata1[0], tdata1[4], @windowskin, @rect[5][1])
- end
- if tdata2[2] <= tdata2[1]
- @rect[6] = [0, @rect[0].dup]
- @rect[6][1].height = tdata2[2]
- @rect[6][1].x, @rect[6][1].y = 128, tdata1[0]
- else
- @rect[6] = [1, tdata2[2] / tdata2[1], tdata2[2] % tdata2[1], 128, 64 - tdata1[0], 192 - tdata1[0]]
- end
- if @rect[6][0] == 1
- for i in 0...@rect[6][1]
- @windowbk.bitmap.blt(0, tdata1[0] + i * tdata2[1], @windowskin, Rect.new(@rect[6][3], tdata1[0], tdata1[0], 64 - tdata1[1]))
- @windowbk.bitmap.blt(tdata1[5], tdata1[0] + i * tdata2[1], @windowskin, Rect.new(@rect[6][5], tdata1[0], tdata1[0], 64 - tdata1[1]))
- end
- wht = (tdata1[0] + i * tdata2[1]) + tdata2[1]
- @windowbk.bitmap.blt(0, wht, @windowskin, Rect.new(@rect[6][3], tdata1[0], tdata1[0], @rect[6][2]))
- @windowbk.bitmap.blt(tdata1[5], wht, @windowskin, Rect.new(@rect[6][5], tdata1[0], tdata1[0], @rect[6][2]))
- wht = nil
- else
- @windowbk.bitmap.blt(0, tdata1[0], @windowskin, @rect[6][1])
- @rect[6][1].x = 192 - tdata1[0]
- @windowbk.bitmap.blt(tdata1[5], tdata1[0], @windowskin, @rect[6][1])
- end
- self.set_name(@selfname[0], @selfname[1], @selfname[2], @selfname[3], @selfname[4])
- @windowbk.z = @windowbg.z + 1
- #bitmapcc.dispose# = nil
- #bitmapcc = nil
- tdata1, tdata2, @rect[5], @rect[6] = nil, nil, nil, nil
- self.set_self_wz
- @psize = [widthcc, heightcc]
- end
- end
- def get_viewport_rect
- rectfw1 = [@viewportsz.rect.x, @viewportsz.rect.y]
- rectfw2 = [@viewportsz.rect.width, @viewportsz.rect.height]
- rect = Rect.new(rectfw1[0], rectfw1[1], rectfw2[0], rectfw2[1])
- return rect
- end
- def windowskin
- return @windowskin
- end
- def windowskin=(windowskin)
- @windowskin = windowskin
- self.set_window(@self_wz.width, @self_wz.height)
- @cursor_rect.windowskin = @windowskin if @cursor_rect != nil
- @pausecr.windowskin = @windowskin
- for i in 0..3
- @arrowcr[i].windowskin = @windowskin
- end
- end
- def set_self_wz
- @windowbk.x = @self_wz.x
- @windowbk.y = @self_wz.y
- @windowbg.x = @self_wz.x
- @windowbg.y = @self_wz.y
- @viewportsz.rect.x = @self_wz.x + BK_SIZE
- @viewportsz.rect.y = @self_wz.y + BK_SIZE
- @viewportsz.rect.width = @self_wz.width - (BK_SIZE * 2)
- @viewportsz.rect.height = @self_wz.height - (BK_SIZE * 2)
- @viewportcr.rect.x = @self_wz.x
- @viewportcr.rect.y = @self_wz.y
- @viewportcr.rect.width = @self_wz.width
- @viewportcr.rect.height = @self_wz.height
- @pausecr.x = (@self_wz.width - 16) / 2
- @pausecr.y = @self_wz.height - 16
- self.set_arrow_wz
- end
- def set_arrow_wz
- @arrowcr[0].x, @arrowcr[0].y = @self_wz.width - BK_SIZE, BK_SIZE + ((@self_wz.height - BK_SIZE * 2) / @arrow_cr_id_max * @arrow_cr_id)
- @arrowcr[1].x, @arrowcr[1].y = @self_wz.width - BK_SIZE, BK_SIZE + ((@self_wz.height - BK_SIZE * 2) / @arrow_cr_id_max * @arrow_cr_id) + 10
- @arrowcr[2].x, @arrowcr[2].y = BK_SIZE + ((@self_wz.height - BK_SIZE * 2) / @arrow_cr_id_max * @arrow_cr_id), @self_wz.height - BK_SIZE
- @arrowcr[3].x, @arrowcr[3].y = BK_SIZE + ((@self_wz.height - BK_SIZE * 2) / @arrow_cr_id_max * @arrow_cr_id) + 10, @self_wz.height - BK_SIZE
- end
- def x
- return @self_wz.x
- end
- def y
- return @self_wz.y
- end
- def width
- return @self_wz.width
- end
- def height
- return @self_wz.height
- end
- def x=(x)
- @self_wz.x = x
- self.set_self_wz
- end
- def y=(y)
- @self_wz.y = y
- self.set_self_wz
- end
- def width=(width)
- @self_wz.width = width
- self.set_self_wz
- self.set_window(@self_wz.width, @self_wz.height)
- end
- def height=(height)
- @self_wz.height = height
- self.set_self_wz
- self.set_window(@self_wz.width, @self_wz.height)
- end
- def contents
- return @windownr.bitmap if @windownr != nil
- end
- def contents=(contents)
- @windownr = Sprite.new(@viewportsz) if @windownr == nil
- @windownr.bitmap = contents
- end
- def stretch
- return @stretchsz
- end
- def stretch=(stretch_type)
- @stretchsz = stretch_type if stretch_type.is_a?(TrueClass)
- @stretchsz = stretch_type if stretch_type.is_a?(FalseClass)
- self.set_window(@self_wz.width, @self_wz.height)
- end
- def active
- return @activesz
- end
- def active=(active)
- @activesz = active if active.is_a?(TrueClass)
- @activesz = active if active.is_a?(FalseClass)
- end
- def visible
- return @visiblesz
- end
- def visible=(visible)
- @visiblesz = visible if visible.is_a?(TrueClass)
- @visiblesz = visible if visible.is_a?(FalseClass)
- @windowbk.visible = @visiblesz
- @windowbg.visible = @visiblesz
- @viewportsz.visible = @visiblesz
- @viewportcr.visible = @visiblesz
- #@cursor_rect.visible = @visiblesz if @cursor_rect != nil
- #@cursor_a.visible = @visiblesz if @cursor_a != nil
- #@cursor_a_s.visible = @visiblesz if @cursor_a_s != nil
- #@cursor_b.visible = @visiblesz if @cursor_b != nil
- end
- def pause
- return @pausesz
- end
- def pause=(pause)
- @pausesz = pause if pause.is_a?(TrueClass)
- @pausesz = pause if pause.is_a?(FalseClass)
- end
- def z
- return @windowbk.z
- end
- def z=(z)
- @windowbk.z = z# - 1
- @windowbg.z = z# - 1
- @viewportsz.z = z + 100
- @viewportcr.z = z + 100
- #@cursor_rect.z = z - 100 if @cursor_rect != nil
- #@cursor_a.z = z - 100 if @cursor_a != nil
- #@cursor_a_s.z = z - 100 if @cursor_a_s != nil
- #@cursor_b.z = z - 100 if @cursor_b != nil
- end
- def ox
- return @viewportsz.ox
- end
- def ox=(ox)
- @viewportsz.ox = ox
- end
- def oy
- return @viewportsz.oy
- end
- def oy=(oy)
- @viewportsz.oy = oy
- end
- def opacity
- return @opacitysz
- end
- def opacity=(opacity)
- opacity = 0 if opacity < 0
- opacity = 255 if opacity > 255
- @opacitysz = opacity
- @windowbk.opacity = @opacitysz
- @windowbg.opacity = @opacitysz
- end
- def back_opacity
- return @windowbg.opacity
- end
- def back_opacity=(opacity)
- opacity = 0 if opacity < 0
- opacity = 255 if opacity > 255
- @windowbg.opacity = opacity
- end
- def contents_opacity
- return @windownr.opacity if @windownr != nil
- end
- def contents_opacity=(opacity)
- opacity = 0 if opacity < 0
- opacity = 255 if opacity > 255
- @windownr.opacity = opacity if @windownr != nil
- @cursor_rect.opacity = opacity if @cursor_rect != nil
- @cursor_a.opacity = opacity if @cursor_a != nil
- @cursor_a_s.opacity = opacity if @cursor_a_s != nil
- @cursor_b.opacity = opacity if @cursor_b != nil
- end
- def viewport
- return @viewportsz
- end
- def dispose
- @viewportsz.dispose
- @viewportcr.dispose
- @windowbk.bitmap.dispose if @windowbk.bitmap != nil
- @windowbk.dispose
- @windowbg.bitmap.dispose if @windowbg.bitmap != nil
- @windowbg.dispose
- @windownr.bitmap.dispose if @windownr != nil and @windownr.bitmap != nil
- @windownr.dispose if @windownr != nil
- @cursor_rect.dispose if @cursor_rect != nil
- @cursor_a.dispose if @cursor_a != nil
- @cursor_a_s.dispose if @cursor_a_s != nil
- @cursor_b.dispose if @cursor_b != nil
- @pausecr.dispose
- for i in 0..3
- @arrowcr[i].dispose
- @arrowcr[i] = nil
- end
- @viewportsz = nil
- @viewportcr = nil
- @windowbk = nil
- @windowbg = nil
- @windownr = nil
- @cursor_rect = nil
- @cursor_a = nil
- @cursor_a_s = nil
- @cursor_b = nil
- @pausecr = nil
- @disposedsz = true
- GC.start
- end
- def disposed?
- return @disposedsz
- end
- def set_cursor_rect(on_off)
- @cursor_rect = Sprite_Cursor_Rect.new(@viewportsz) if on_off.is_a?(TrueClass) and @cursor_rect == nil
- @cursor_rect.dispose if on_off.is_a?(FalseClass)
- @cursor_rect = nil if on_off.is_a?(FalseClass)
- end
- def set_cursor_a(on_off)
- @cursor_a = Sprite_CursorA.new(@viewportcr) if on_off.is_a?(TrueClass) and @cursor_a == nil
- @cursor_a.dispose if on_off.is_a?(FalseClass)
- @cursor_a = nil if on_off.is_a?(FalseClass)
- end
- def set_cursor_a_s(on_off)
- @cursor_a_s = Sprite_CursorA_S.new(@viewportcr) if on_off.is_a?(TrueClass) and @cursor_a_s == nil
- @cursor_a_s.dispose if on_off.is_a?(FalseClass)
- @cursor_a_s = nil if on_off.is_a?(FalseClass)
- end
- def set_cursor_b(on_off)
- @cursor_b = Sprite_CursorB.new(@viewportcr) if on_off.is_a?(TrueClass) and @cursor_b == nil
- @cursor_b.dispose if on_off.is_a?(FalseClass)
- @cursor_b = nil if on_off.is_a?(FalseClass)
- end
- def set_name(namesz = "", wz1 = 0, wz2 = BK_SIZE, font = Font.new, align = 0)
- @selfname = [namesz, wz1, wz2, font, align]
- if namesz != ""
- @selfname = [namesz, wz1, wz2, font, align]
- @selfname[1] = 0 if wz1 == 0
- @selfname[1] = self.height - font.size - 2 if wz1 == 1
- @windowbk.bitmap.font = @selfname[3]
- tsize = @windowbk.bitmap.text_size(@selfname[0]).width
- @windowbk.bitmap.draw_text(@selfname[2],@selfname[1],tsize,@selfname[3].size,@selfname[0],@selfname[4])
- end
- end
- def update
- @cursor_rect.visible = true if @cursor_rect != nil and self.visible and self.active
- @cursor_rect.update if @cursor_rect != nil and @cursor_rect.visible and self.active
- #@cursor_a.visible = true if @cursor_a != nil and self.visible and self.active
- @cursor_a.update if @cursor_a != nil and @cursor_a.visible and self.active
- #@cursor_b.visible = true if @cursor_b != nil and self.visible and self.active
- @cursor_b.update if @cursor_b != nil and @cursor_b.visible and self.active
- @pausecr.visible = @pausesz
- @pausecr.update if @pausecr.visible
- if @windownr != nil and @windownr.bitmap != nil and self.active and @windownr.bitmap.height > self.height - BK_SIZE * 2 and self.oy > 0
- @arrowcr[0].opacity, @arrowcr[0].count, @arrowcr[0].wait_count = @arrowcr[1].opacity, @arrowcr[1].count, @arrowcr[1].wait_count if @arrowcrp[0] == false
- @arrowcrp[0] = true if @arrowcr[0].visible == false
- @arrowcr[0].visible = true if @arrowcr[0].visible == false
- else
- @arrowcrp[0] = false if @arrowcr[0].visible == true
- @arrowcr[0].visible = false if @arrowcr[0].visible == true
- end
- if @windownr != nil and @windownr.bitmap != nil and self.active and @windownr.bitmap.height > self.height - BK_SIZE * 2 and self.oy < @windownr.bitmap.height - (self.height - BK_SIZE * 2)
- @arrowcr[1].opacity, @arrowcr[1].count, @arrowcr[1].wait_count = @arrowcr[0].opacity, @arrowcr[0].count, @arrowcr[0].wait_count if @arrowcrp[1] == false
- @arrowcrp[1] = true if @arrowcr[1].visible == false
- @arrowcr[1].visible = true if @arrowcr[1].visible == false
- else
- @arrowcrp[1] = false if @arrowcr[1].visible == true
- @arrowcr[1].visible = false if @arrowcr[1].visible == true
- end
- if @windownr != nil and @windownr.bitmap != nil and self.active and @windownr.bitmap.width > self.width - BK_SIZE * 2 and self.ox > 0
- @arrowcr[2].opacity, @arrowcr[2].count, @arrowcr[2].wait_count = @arrowcr[3].opacity, @arrowcr[3].count, @arrowcr[3].wait_count if @arrowcrp[2] == false
- @arrowcrp[2] = true if @arrowcr[2].visible == false
- @arrowcr[2].visible = true if @arrowcr[2].visible == false
- else
- @arrowcrp[2] = false if @arrowcr[2].visible == true
- @arrowcr[2].visible = false if @arrowcr[2].visible == true
- end
- if @windownr != nil and @windownr.bitmap != nil and self.active and @windownr.bitmap.width > self.width - BK_SIZE * 2 and self.ox < @windownr.bitmap.width - (self.width - BK_SIZE * 2)
- @arrowcr[3].opacity, @arrowcr[3].count, @arrowcr[3].wait_count = @arrowcr[2].opacity, @arrowcr[2].count, @arrowcr[2].wait_count if @arrowcrp[3] == false
- @arrowcrp[3] = true if @arrowcr[3].visible == false
- @arrowcr[3].visible = true if @arrowcr[3].visible == false
- else
- @arrowcrp[3] = false if @arrowcr[3].visible == true
- @arrowcr[3].visible = false if @arrowcr[3].visible == true
- end
- @arrowcr[0].update if @arrowcr[0].visible
- @arrowcr[1].update if @arrowcr[1].visible
- @arrowcr[2].update if @arrowcr[2].visible
- @arrowcr[3].update if @arrowcr[3].visible
- end
- end
复制代码
辅助脚本:
- #==============================================================================
- # □ Sprite_Cursor
- #==============================================================================
- class Sprite_CursorA < Sprite
- def initialize(viewport)
- super(viewport)
- self.bitmap = RPG::Cache.windowskin("cursor.png")
- self.visible = false
- @count = 0
- @wait_count = 0
- update
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- if @wait_count == 0
- @count = 0
- elsif @wait_count == 8
- @count = 1
- end
- if @count == 0
- self.ox += 1
- @wait_count += 1
- elsif @count == 1
- self.ox -= 1
- @wait_count -= 1
- end
- end
- #--------------------------------------------------------------------------
- # ● 半透明化
- #--------------------------------------------------------------------------
- def opacitysz(type)
- if type == 0
- self.opacity -= 8 if self.opacity > 180
- else
- self.opacity += 8 if self.opacity < 255
- end
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- end
复制代码- #==============================================================================
- # □ Sprite_CursorA
- #==============================================================================
- class Sprite_CursorA_S < Sprite
- def initialize(viewport)
- super(viewport)
- self.bitmap = RPG::Cache.windowskin("cursor.png")
- self.visible = false
- @count = 0
- @wait_count = 0
- end
- #--------------------------------------------------------------------------
- # ● 半透明化
- #--------------------------------------------------------------------------
- def opacitysz(type)
- if type == 0
- self.opacity -= 8 if self.opacity > 180
- else
- self.opacity += 8 if self.opacity < 255
- end
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- end
复制代码- #==============================================================================
- # □ Sprite_Cursor
- #==============================================================================
- class Sprite_CursorB < Sprite
- def initialize(viewport)
- super(viewport)
- @bitmap = RPG::Cache.windowskin("cursora.png")
- self.visible = false
- @count = @count1 = @wait_count = @wait_count1 = 0
- @tp = false
- @ct = false
- @rect = Array.new(5)
- @rect[0] = Rect.new(0, 0, 12, 12)
- @rect[1] = Rect.new(0, 20, 12, 12)
- @rect[2] = Rect.new(20, 0, 12, 12)
- @rect[3] = Rect.new(20, 20, 12, 12)
- @utype = 0
- self.set(32, 32)
- update
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- update_type(@utype)
- end
- #--------------------------------------------------------------------------
- # ● 设置尺寸
- #--------------------------------------------------------------------------
- def set(width, height)
- width = 24 if width < 24
- height = 24 if height < 24
- @bitmapa.dispose if @bitmapa != nil
- @bitmapa = self.set_size(@bitmapa, width, height)
- @bitmapb.dispose if @bitmapb != nil
- @bitmapb = self.set_size(@bitmapb, width + 2, height + 2)
- @bitmapc.dispose if @bitmapc != nil
- @bitmapc = self.set_size(@bitmapc, width + 4, height + 4)
- self.bitmap.dispose if self.bitmap != nil
- self.bitmap = @bitmapa
- self.ox, self.oy = self.bitmap.width / 2, self.bitmap.height / 2
- end
- #--------------------------------------------------------------------------
- # ● 半透明化
- #--------------------------------------------------------------------------
- def opacitysz(type)
- if type == 0
- self.opacity -= 8 if self.opacity > 180
- else
- self.opacity += 8 if self.opacity < 255
- end
- end
- def set_size(bitmapcc, width, height)
- bitmapcc = Bitmap.new(width, height)
- bitmapcc.blt(0, 0, @bitmap, @rect[0])
- bitmapcc.blt(0, height - 12, @bitmap, @rect[1])
- bitmapcc.blt(width - 12, 0, @bitmap, @rect[2])
- bitmapcc.blt(width - 12, height - 12, @bitmap, @rect[3])
- @rect[4] = Rect.new(13, 0, 1, height)
- if width > 24
- for i in 1..width - 24
- bitmapcc.blt(width - 12 - i, 0, @bitmap, @rect[4])
- end
- end
- return bitmapcc
- end
- def set_update_type(type)
- @utype = type
- @ct = true
- end
- def update_type(type)
- case type
- when 0
- self.opacity = 255 if self.opacity < 255 and @ct
- self.bitmap = @bitmapa if @ct
- self.ox, self.oy = self.bitmap.width / 2 - 2, self.bitmap.height / 2 - 2 if @ct
- @count = @count1 = @wait_count = @wait_count1 = 0 if @ct
- @tp = false if @ct
- @ct = false if @ct
- if @wait_count == 0
- @count = 0
- elsif @wait_count == 15
- @count = 1
- end
- if @count == 0
- self.opacity -= 8
- @wait_count += 1
- elsif @count == 1
- self.opacity += 8
- @wait_count -= 1
- end
- when 1
- self.opacity = 255 if self.opacity < 255 and @ct
- @count = @count1 = @wait_count = @wait_count1 = 0 if @ct
- @tp = false if @ct
- @ct = false if @ct
- if @wait_count == 0
- @count = 0
- elsif @wait_count == 4
- @count = 1
- elsif @wait_count == 8
- @count = 2
- end
- if @count == 0
- self.bitmap = @bitmapa
- self.ox, self.oy = self.bitmap.width / 2 - 2, self.bitmap.height / 2 - 2
- @wait_count += 1
- @tp = false if @tp
- elsif @count == 1
- self.bitmap = @bitmapb
- self.ox, self.oy = self.bitmap.width / 2 - 1, self.bitmap.height / 2 - 1
- @wait_count += 1 if !@tp
- @wait_count -= 1 if @tp
- elsif @count == 2
- self.bitmap = @bitmapc
- self.ox, self.oy = self.bitmap.width / 2, self.bitmap.height / 2
- @wait_count -= 1
- @tp = true if !@tp
- end
- when 2
- self.opacity = 255 if self.opacity < 255 and @ct
- self.bitmap = @bitmapa if @ct
- self.ox, self.oy = self.bitmap.width / 2 - 2, self.bitmap.height / 2 - 2 if @ct
- @count = @count1 = @wait_count = @wait_count1 = 0 if @ct
- @tp = false if @ct
- @ct = false if @ct
- if @wait_count == 0
- @count = 0
- elsif @wait_count == 4
- @count = 1
- elsif @wait_count == 8
- @count = 2
- end
- if @wait_count1 == 0
- @count1 = 0
- elsif @wait_count1 == 15
- @count1 = 1
- end
- if @count == 0
- self.bitmap = @bitmapa
- self.ox, self.oy = self.bitmap.width / 2 - 2, self.bitmap.height / 2 - 2
- @wait_count += 1
- @tp = false if @tp
- elsif @count == 1
- self.bitmap = @bitmapb
- self.ox, self.oy = self.bitmap.width / 2 - 1, self.bitmap.height / 2 - 1
- @wait_count += 1 if !@tp
- @wait_count -= 1 if @tp
- elsif @count == 2
- self.bitmap = @bitmapc
- self.ox, self.oy = self.bitmap.width / 2, self.bitmap.height / 2
- @wait_count -= 1
- @tp = true if !@tp
- end
- if @count1 == 0
- self.opacity -= 8
- @wait_count1 += 1
- elsif @count1 == 1
- self.opacity += 8
- @wait_count1 -= 1
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- end
复制代码- #==============================================================================
- # □ Sprite_Cursor
- #==============================================================================
- class Sprite_Cursor_Rect < RPG::Sprite
- def initialize(viewport)
- super(viewport)
- @bitmap_rect = Rect.new(1, 1, 30, 30)
- @bitmap_rect1 = Rect.new(0, 0, 32, 32)
- @bitmap = Bitmap.new(32, 32)
- self.bitmap = Bitmap.new(1, 1)
- @rect = Array.new(5)
- @rect[0] = Rect.new(0, 0, 32, 1)
- @rect[1] = Rect.new(0, 31, 32, 1)
- @rect[2] = Rect.new(0, 1, 1, 30)
- @rect[3] = Rect.new(31, 1, 1, 30)
- @rect[4] = Rect.new(128, 64, 32, 32)
- @count = 0
- @wait_count = 0
- @psize = [0, 0, 0, 0]
- update
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- if self.visible
- if @wait_count == 0
- @count = 0
- elsif @wait_count == 16
- @count = 1
- end
- if @count == 0
- self.opacity += 8
- @wait_count += 1
- elsif @count == 1
- self.opacity -= 8
- @wait_count -= 1
- end
- end
- end
- def set(x, y, width, height)
- self.x, self.y = x, y
- unless width == @psize[0] and height == @psize[1]
- tdata = [width - 2, height - 2]
- self.bitmap.dispose if self.bitmap != nil
- self.bitmap = Bitmap.new(width, height)
- @bitmap_rect1.width, @bitmap_rect1.height = width, height
- self.bitmap.stretch_blt(@bitmap_rect1, @bitmap, @bitmap_rect)
- rectx = Rect.new(0, 0, width, 1)
- self.bitmap.stretch_blt(rectx, @bitmap, @rect[0])
- rectx.y = height - 1
- self.bitmap.stretch_blt(rectx, @bitmap, @rect[1])
- rectx.y, rectx.width, rectx.height = 1, 1, tdata[1]
- self.bitmap.stretch_blt(rectx, @bitmap, @rect[2])
- rectx.x = width - 1
- self.bitmap.stretch_blt(rectx, @bitmap, @rect[3])
- self.bitmap.blur
- @psize = [width, height]
- end
- end
- def empty
- self.x, self.y = 0, 0
- self.bitmap.dispose if self.bitmap != nil
- self.bitmap = Bitmap.new(1, 1)
- @psize = [1, 1]
- end
- def windowskin=(windowskin)
- @bitmap.blt(0, 0, windowskin, @rect[4])
- self.set(self.x, self.y, self.bitmap.width, self.bitmap.height)
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- end
复制代码- #==============================================================================
- # ■ Arrow_Base
- #------------------------------------------------------------------------------
- # 在战斗画面使用的箭头光标的活动块。本类作为
- # Arrow_Enemy 类与 Arrow_Actor 类的超级类使用。
- #==============================================================================
- class Sprite_Pause_Cursor < RPG::Sprite
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # viewport : 显示端口
- #--------------------------------------------------------------------------
- def initialize(viewport)
- super(viewport)
- self.bitmap = Bitmap.new(32, 32)
- self.visible = false
- @rect = Rect.new(160, 64, 32, 32)
- @count = 0
- @wait_count = 0
- update
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- @wait_count += 1
- if @wait_count == 7
- case @count
- when 0
- self.src_rect.set(0, 0, 16, 16)
- @count = 1
- when 1
- self.src_rect.set(16, 0, 16, 16)
- @count = 2
- when 2
- self.src_rect.set(0, 16, 16, 16)
- @count = 3
- when 3
- self.src_rect.set(16, 16, 16, 16)
- @count = 0
- end
- @wait_count = 0
- end
- end
- def windowskin=(windowskin)
- self.bitmap.blt(0, 0, windowskin, @rect)
- self.src_rect.set(0, 0, 16, 16)
- @count = @wait_count = 0
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- end
复制代码
字数不够了…… |
|