赞 | 1 |
VIP | 246 |
好人卡 | 87 |
积分 | 1 |
经验 | 34142 |
最后登录 | 2015-1-15 |
在线时间 | 323 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 55
- 在线时间
- 323 小时
- 注册时间
- 2010-8-21
- 帖子
- 666
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
之前在ISA发的子选项的升级版,不兼容上个版本.
先上预览图...
这次做了视频说明.....
网盘下载:
sub
脚本分为2部分:主体,库。之后可能会对库进行更新(可能性趋近与0)。我估计也没什么人用这个"半成品",
所以之后以本脚本为基础,做一些漂亮有实用的东西出来
xp,vx,va全支持,详见附件的范例下载(3个版本的都在里面),不过,范例只是个半成品,仅仅是来说明这个脚本是怎么使用的.
本体脚本:
#============================================================================== # 中文名称: 子选项Final # 英文名称: ZiXuanXiangFinal #------------------------------------------------------------------------------ # 协议: Ideal Script Association(ISA) #------------------------------------------------------------------------------ # 作者: 沙漠点灰 # 版本: 0.9.5 # 更新日期: #============================================================================== module ISA # 字体选中显示修正 SubTitleUpdate = true # 子选项字体阴影 SubTitleShadow = true # 一页最大选项数,不建议修改,会出现bug SubTitleMAX = 5 # 间距,不建议修改 SubTitleSpan = 20 # 移动层数 当层数达到该值,左移一格 SubTitleDeep = 3 @@_reg ||= {} @@_reg["子选项Final"] = "0.9.5" end ISA::Edition = self ? (RUBY_VERSION == '1.9.2' ? :va : :vx) : :xp #============================================================================== # ■ 临时缓存 #============================================================================== module ISACache # 注: "0xFF" => 窗体 "0xFE" => 窗体(选中) "0xFD" => 右箭头 # "0xFC" => 数字选择 "0xFB" => 数字 def self.load(name) @@_cache[name] end def self.save(obj,name) @@_cache[name] = obj end def self.clear @@_cache = {} GC.start bg = Bitmap.new(22*6,32) bg.fill_rect(0,2,bg.width,bg.height-4, Color.new(220,150,0,255)) self.save(bg, "0xFE") bg = Bitmap.new(14,32) bg.height.times{|i|bg.fill_rect(i,i-2,1,28-i*2, Color.new(255,255,255,200)) if i > 1} self.save(bg, "0xFD") bg = Bitmap.new(11,22) bg.fill_rect(bg.rect, Color.new(220,150,0)) self.save(bg, "0xFC") rect = bg.text_size("0123456789") bg = Bitmap.new(rect.width, rect.height) bg.font.color = Color.new(0,0,0) bg.draw_text(rect, "0123456789") self.save(bg, "0xFB") #self.save(Bitmap.new("font.png"), "0xFB") end end # 绘制位图数据 ISACache.clear #============================================================================== # ■ Wnd_SubTitle_Main #------------------------------------------------------------------------------ # 子选项 主窗体 #============================================================================== class Wnd_SubTitle_Main include ISA attr_reader :_id attr_reader :_sub attr_reader :index #-------------------------------------------------------------------------- # 初始化对象 #-------------------------------------------------------------------------- def initialize(x, y, title,index=0) #!!!!!Sub的initialize也要修改!! @_backing = nil # 返回中 @_num_input = false # 数字输入标志 @_num_op = 255 # 数值不透明度 @_num_de = -1 # 滚动方向 @_num_ipt = 0 # 数值 @_num_max = 0 # 最大数值 @_num_index = 0 # 数值标志 @_num_frt = 0 # 数值输入x坐标 @_num_dig = 1 # 数值位数 @_window_x = 0 # 窗体x @_window_x_old = 0 # 窗体旧x @_window_count = 0 # 窗体移动帧数 @_window_move = [] # 窗体移动路径 @title = title!(title) @index = index @_id = [] @_view = Rect.new(x, y, 22*6+4, 32*SubTitleMAX) @_self = Sprite.new @_self.bitmap = Bitmap.new(@_view.width+SubTitleSpan, @_view.height) @_bitmap = @_self.bitmap.dup @_bitmap_data = [] # 临时位图储存 @_title_count = [] # 移动剩余帧数 @_title_move = [] # 移动速度 @_title_now_y = [] # 各index的y坐标 @_title_str_x = [] # 显示项目的x坐标 @_title_direc = [] # 项目滚动方向 @_head_op = 128;@_head_dr = 1;@_head_move = 25;@_head_move_d = -1 @size = 0 @title.keys.each{|i|make_new(i[@_id.size],@title[i]) if be2self?(i) @size+=1 if be2self?(i)} j = 0 @title.keys.each{|i| if be2self?(i) @_title_str_x << 0 @_title_count << 0 @_title_move << [] @_title_direc[j] = 1 unless @_title_direc[j] @_title_now_y << j*32 + SubTitleMAX*32 get_to(j, @_title_now_y[j]) move_to(j,j*32+64,30,1.5) add_pause(j, [j*10,50].min) j+=1 end } @_update_step = 0 @_sub = nil @_visible = true @_active = true self.x = x;self.y = y;@_z = 0 @_exit = false end #-------------------------------------------------------------------------- # 光标位置 #-------------------------------------------------------------------------- def _index index = [@index] obj = self while obj._sub index += [obj._sub.index] obj = obj._sub end index end #-------------------------------------------------------------------------- # 回到x层数 #-------------------------------------------------------------------------- def back2(x) @_backing = x end #-------------------------------------------------------------------------- # 缓存清除 #-------------------------------------------------------------------------- def cache_clear @_bitmap_data = [] @size = 0 @title.keys.each{|i|make_new(i[@_id.size],@title[i]) if be2self?(i) @size+=1 if be2self?(i)} move_nor @_sub.cache_clear if @_sub end #-------------------------------------------------------------------------- # 选择 #-------------------------------------------------------------------------- def set_index(index=@index) @index = index return if moving? @_title_move[index] = [0] @_title_count[index] = 1 end #-------------------------------------------------------------------------- # 存在子选项? #-------------------------------------------------------------------------- def exist_sub?(index=@index) @title[@_id+[index,0]] end #-------------------------------------------------------------------------- # 退出 #-------------------------------------------------------------------------- def exit! @_exit = true @size.times{|i| move_to(i,160,30,1.5) add_pause(i, [50, @size*10].min-[i*10,50].min) } end #-------------------------------------------------------------------------- # 返回 #-------------------------------------------------------------------------- def back! return if @_exit return exit! unless @_sub @_sub.back! if !@_sub.exit? end #-------------------------------------------------------------------------- # 显示数字 #-------------------------------------------------------------------------- def show_num(num) var = sprintf("%.#{@_num_dig}d", num) bmp = ISACache.load("0xFB");wd = bmp.width/10 rect = bmp.text_size(var) new_b = Bitmap.new(@_view.width,32) x = (new_b.width-rect.width)/2;y = (new_b.height-rect.height)/2 @_num_frt = x var.split("").each{|i|new_b.blt(x, y, bmp, Rect.new(i.to_i*wd,0,wd,bmp.height));x += wd} new_b end #-------------------------------------------------------------------------- # 退出 #-------------------------------------------------------------------------- def exit? @_exit and !moving? end #-------------------------------------------------------------------------- # 自己的?? #-------------------------------------------------------------------------- def be2self?(ary) ary.size == @_id.size+1 and @_id == ary[0,@_id.size] end #-------------------------------------------------------------------------- # 加入暂停 缓停 #-------------------------------------------------------------------------- def add_pause(index, count) @_title_move[index] += [0]*count @_title_count[index] += count end #-------------------------------------------------------------------------- # 释放 #-------------------------------------------------------------------------- def dispose @_sub.dispose if @_sub @_self.dispose @_bitmap.dispose @_self.bitmap.dispose end #-------------------------------------------------------------------------- # 刷新副选项箭头 #-------------------------------------------------------------------------- def update_sub_head return unless exist_sub? @_head_move += @_head_move_d @_head_move = [0,[@_head_move,25].min].max @_bitmap.fill_rect(@_view.width, 67, SubTitleSpan, 32, Color.new(0,0,0,0)) src_bmp = ISACache.load("0xFD") @_bitmap.blt(@_view.width+@_head_move, 67, src_bmp, src_bmp.rect, @_head_op) @_head_op += @_head_dr * 3 @_head_dr *= -1 if @_head_op >= 255 or @_head_op <= 125 @_head_op = 255 if @_head_op > 255 end #-------------------------------------------------------------------------- # 刷新 #-------------------------------------------------------------------------- def update if @_sub # 子选项刷新 @_sub.update if @_sub.exit? @_sub.dispose @_sub = nil self.active = true end end if self.class == Wnd_SubTitle_Main # 窗体移动 @_window_x = [(140+SubTitleSpan)*(SubTitleDeep-_index.size),0].min move_window if @_window_x != @_window_x_old if @_window_count > 0 @_window_count -= 1 self.x += @_window_move[@_window_count] end end update_move # 移动刷新 if @_num_input # 数值输入?? if Input.repeat?(Input::DOWN) and self.active and !@_exit play_se @_num_ipt -= 10**(@_num_dig-@_num_index-1) @_num_ipt = [[@_num_ipt, 0].max, @_num_max].min end if Input.repeat?(Input::UP) and self.active and !@_exit play_se @_num_ipt += 10**(@_num_dig-@_num_index-1) @_num_ipt = [[@_num_ipt, 0].max, @_num_max].min end if Input.repeat?(Input::LEFT) and self.active and !@_exit play_se @_num_index -= 1 if @_num_index > 0 update_input end if Input.repeat?(Input::RIGHT) and self.active and !@_exit play_se @_num_index += 1 if @_num_index < @_num_dig -1 update_input end else # 普通 if Input.repeat?(Input::DOWN) and self.active and !@_exit play_se @index += 1;@index%=@size move_nor end if Input.repeat?(Input::UP) and self.active and !@_exit play_se @index -= 1;@index%=@size move_nor end end if Input.trigger?(Input::C) and self.active and !@_exit if exist_sub? # 存在选择支 play_se(1) @_sub = Wnd_SubTitle_Sub.new(@title,self,@_id+[@index]) self.active = false end end if Input.trigger?(Input::B) and self.active and !@_sub and !@_exit play_se(2) exit! end if self.active update_input if @_num_input and @_num_ipt_old != @_num_ipt update_sub_head# 刷新副选项箭头 update_show # 字符显示修正 update_bitmap # 位图刷新 end return if self.class != Wnd_SubTitle_Main or !@_backing # 检查返回 return @_backing = nil if @_backing == _index.size back! # 返回! end #-------------------------------------------------------------------------- # SE播放 #-------------------------------------------------------------------------- def play_se(se=0) case ISA::Edition when :xp case se when 0 $game_system.se_play($data_system.cursor_se) when 1 $game_system.se_play($data_system.decision_se) when 2 $game_system.se_play($data_system.cancel_se) end when :vx case se when 0 Sound.play_cursor when 1 Sound.play_decision when 2 Sound.play_cancel end when :va case se when 0 Sound.play_cursor when 1 Sound.play_ok when 2 Sound.play_cancel end end end #-------------------------------------------------------------------------- # 刷新输入 #-------------------------------------------------------------------------- def update_input return unless @_bitmap_data[index] @_bitmap_data[index][1] = show_num(@_num_ipt) bmp = ISACache.load("0xFC") get_to(0) @_bitmap.blt(@_num_frt+@_num_index*bmp.width, 16-bmp.height/2+@_title_now_y[0],bmp,bmp.rect,@_num_op) @_num_op += @_num_de * 5 @_num_de *= -1 if @_num_op < 156 or @_num_op >= 255 @_num_op = [[@_num_op, 155].max,255].min end #-------------------------------------------------------------------------- # 移动窗体 #-------------------------------------------------------------------------- def move_window count = 30; triangle_v = (@_window_x-@_window_x_old).to_f*2/(count**2) @_window_move = [-triangle_v/2] count.times{|i|@_window_move[i]=triangle_v+@_window_move[i-1]} @_window_count = count @_window_x_old = @_window_x end #-------------------------------------------------------------------------- # C键允许 #-------------------------------------------------------------------------- def c? return true if !@_sub and !exist_sub? return true if @_sub and @_sub.c? false end #-------------------------------------------------------------------------- # 字符显示修正 #-------------------------------------------------------------------------- def update_show @size.times{|i| if @_title_direc[i] != 0 and (i == @index or !SubTitleUpdate ) @_title_direc[i] *= -1 if @_title_str_x[i] == 0 or @_title_str_x[i]-4 == @_bitmap_data[i][1].width-@_view.width @_title_str_x[i] -= @_title_direc[i]*0.25 get_to(i, nil, @_title_str_x[i],@index==i) end } end #-------------------------------------------------------------------------- # 位图刷新 #-------------------------------------------------------------------------- def update_bitmap @_self.bitmap.clear @_bitmap.height.times{|a| if a < 64 @_self.bitmap.blt(0,a,@_bitmap,Rect.new(0,a,@_bitmap.width,1),a*4) elsif a >= 96 @_self.bitmap.blt(0,a,@_bitmap,Rect.new(0,a,@_bitmap.width,1),(159-a)*4) elsif a == 64 @_self.bitmap.blt(0,a,@_bitmap,Rect.new(0,a,@_bitmap.width,32)) end } end #-------------------------------------------------------------------------- # 按键通常移动 #-------------------------------------------------------------------------- def move_nor @size.times{|i|move_to(i, (i-@index+2)*32, 20, 4)} @_head_move = 25;@_head_move_d =-1 end #-------------------------------------------------------------------------- # 生成选项 #-------------------------------------------------------------------------- def make_new(index,title) bg = ISACache.load("0xFF") # 我就不信有人用这个当名称 unless bg bg = Bitmap.new(22*6,32) bg.fill_rect(0,2,bg.width,bg.height-4, Color.new(255,255,255,125)) ISACache.save(bg, "0xFF") end tl = ISACache.load([@_id+[index],title]) unless tl tl = make_bmp(@title[@_id+[index]]) ISACache.save(tl, [@_id+[index],title]) if !@_num_input end @_title_direc[index] = 0 if tl.width-8 <= @_view.width @_bitmap_data[index] = [bg, tl] end #-------------------------------------------------------------------------- # 获取选项到... #-------------------------------------------------------------------------- def get_to(index, y=nil, indentation=0,choosing=false) y = @_title_now_y[index] unless y @_bitmap.fill_rect(0, y, @_bitmap.width-SubTitleSpan, 32, Color.new(0,0,0,0)) @_bitmap.blt(0, y, @_bitmap_data[index][0], @_bitmap_data[index][0].rect) if choosing and !@_num_input @_bitmap.blt(0, y, ISACache.load("0xFE"), @_bitmap_data[index][0].rect) end @_bitmap.blt(2, y+3, @_bitmap_data[index][1], Rect.new(indentation.to_i, 0, @_bitmap_data[index][0].width,32),60) if SubTitleShadow @_bitmap.blt(0, y, @_bitmap_data[index][1], Rect.new(indentation.to_i, 0, @_bitmap_data[index][0].width,32)) end #-------------------------------------------------------------------------- # 移动 仅Y轴 tag_y:目标y count移动时间(帧) a加速度 #-------------------------------------------------------------------------- def move_to(index, tag_y, count, acc) triangle_v = (tag_y-@_title_now_y[index]).to_f*2/(count**2) @_title_move[index] = [-triangle_v/2] count.times{|i|@_title_move[index][i]=triangle_v+@_title_move[index][i-1]} @_title_count[index] = count end #-------------------------------------------------------------------------- # 刷新移动 #-------------------------------------------------------------------------- def update_move @_title_count.size.times{|i| if @_title_count[i] > 0 @_title_count[i] -= 1 clear(i) @_title_now_y[i] += @_title_move[i][@_title_count[i]] get_to(i, nil, 0, @index==i) end } end #-------------------------------------------------------------------------- # 清除 #-------------------------------------------------------------------------- def clear(index) y = @_title_now_y[index] @_bitmap.fill_rect(0, y, @_bitmap.width, 32, Color.new(0,0,0,0)) end #-------------------------------------------------------------------------- # 运动中?? #-------------------------------------------------------------------------- def moving? @_title_count.any?{|i|i>0} end #-------------------------------------------------------------------------- # 各种属性 #-------------------------------------------------------------------------- def x=(x) @_x = x @_self.x = x @_view.x = x end def x @_x end def y=(y) @_y = y @_self.y = y @_view.y = y end def y @_y end def z=(z) @_z = z @_self.z = @_z end def z @_z end def visible=(visible) @_visible = visible @_self.visible = visible end def visible @_visible end def active=(active) @_active = active end def active @_active end def input input = [0] obj = @_sub loop do input << obj._num_ipt break if !obj.exist_sub? obj = obj._sub end input end end class Array def add_ele(pos, num) self[pos] += num end end #============================================================================== # ■ Wnd_SubTitle_Main #------------------------------------------------------------------------------ # 子选项 主窗体 #============================================================================== class Wnd_SubTitle_Sub < Wnd_SubTitle_Main def true_father obj = @father loop do break if obj.class == Wnd_SubTitle_Main obj = obj.father end obj end attr_reader :father attr_reader :_num_ipt #-------------------------------------------------------------------------- # 初始化对象 #-------------------------------------------------------------------------- def initialize(title,father,_id,index=0) @_num_input = false # 数字输入标志 @_num_ipt = 0 # 数值 @_num_max = 0 # 最大数值 @_num_index = 0 # 数值标志 @_num_frt = 0 # 数值输入x坐标 @_num_op = 255 @_num_dig = 1 # 数值位数 @title = title @index = index @_num_de = -1 ########## @father = father @_id = _id @_view = Rect.new(father.x, father.y, 22*6+4, 32*ISA::SubTitleMAX) @_self = Sprite.new @_self.bitmap = Bitmap.new(@_view.width+ISA::SubTitleSpan, @_view.height) @_bitmap = @_self.bitmap.dup @_bitmap_data = [] # 临时位图储存 @_title_count = [] # 移动剩余帧数 @_title_move = [] # 移动速度 @_title_now_y = [] # 各index的y坐标 @_title_str_x = [] # 显示项目的x坐标 @_title_direc = [] # 项目滚动方向 @_head_op = 128;@_head_dr = 1;@_head_move = 25;@_head_move_d = -1 @size = 0 @title.keys.each{|i|make_new(i[@_id.size],@title[i]) if be2self?(i) @size+=1 if be2self?(i)} j = 0 @title.keys.each{|i| if be2self?(i) @_title_str_x << 0 @_title_count << 0 @_title_move << [] @_title_direc[j] = 1 unless @_title_direc[j] @_title_now_y << j*32 + ISA::SubTitleMAX*32 get_to(j, @_title_now_y[j]) move_to(j,j*32+64,30,1.5) add_pause(j, [j*10,50].min) j+=1 end } @_update_step = 0 @_sub = nil @_visible = true @_active = true self.x = father.x+140+ISA::SubTitleSpan;self.y = father.y;@_z = father.z @_exit = false end def update super self.x = @father.x+140+ISA::SubTitleSpan;self.y = @father.y;@_z = @father.z end end
#==============================================================================
# 中文名称: 子选项Final
# 英文名称: ZiXuanXiangFinal
#------------------------------------------------------------------------------
# 协议: Ideal Script Association(ISA)
#------------------------------------------------------------------------------
# 作者: 沙漠点灰
# 版本: 0.9.5
# 更新日期:
#==============================================================================
module ISA
# 字体选中显示修正
SubTitleUpdate = true
# 子选项字体阴影
SubTitleShadow = true
# 一页最大选项数,不建议修改,会出现bug
SubTitleMAX = 5
# 间距,不建议修改
SubTitleSpan = 20
# 移动层数 当层数达到该值,左移一格
SubTitleDeep = 3
@@_reg ||= {}
@@_reg["子选项Final"] = "0.9.5"
end
ISA::Edition = self ? (RUBY_VERSION == '1.9.2' ? :va : :vx) : :xp
#==============================================================================
# ■ 临时缓存
#==============================================================================
module ISACache
# 注: "0xFF" => 窗体 "0xFE" => 窗体(选中) "0xFD" => 右箭头
# "0xFC" => 数字选择 "0xFB" => 数字
def self.load(name)
@@_cache[name]
end
def self.save(obj,name)
@@_cache[name] = obj
end
def self.clear
@@_cache = {}
GC.start
bg = Bitmap.new(22*6,32)
bg.fill_rect(0,2,bg.width,bg.height-4, Color.new(220,150,0,255))
self.save(bg, "0xFE")
bg = Bitmap.new(14,32)
bg.height.times{|i|bg.fill_rect(i,i-2,1,28-i*2, Color.new(255,255,255,200)) if i > 1}
self.save(bg, "0xFD")
bg = Bitmap.new(11,22)
bg.fill_rect(bg.rect, Color.new(220,150,0))
self.save(bg, "0xFC")
rect = bg.text_size("0123456789")
bg = Bitmap.new(rect.width, rect.height)
bg.font.color = Color.new(0,0,0)
bg.draw_text(rect, "0123456789")
self.save(bg, "0xFB")
#self.save(Bitmap.new("font.png"), "0xFB")
end
end
# 绘制位图数据
ISACache.clear
#==============================================================================
# ■ Wnd_SubTitle_Main
#------------------------------------------------------------------------------
# 子选项 主窗体
#==============================================================================
class Wnd_SubTitle_Main
include ISA
attr_reader :_id
attr_reader :_sub
attr_reader :index
#--------------------------------------------------------------------------
# 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y, title,index=0)
#!!!!!Sub的initialize也要修改!!
@_backing = nil # 返回中
@_num_input = false # 数字输入标志
@_num_op = 255 # 数值不透明度
@_num_de = -1 # 滚动方向
@_num_ipt = 0 # 数值
@_num_max = 0 # 最大数值
@_num_index = 0 # 数值标志
@_num_frt = 0 # 数值输入x坐标
@_num_dig = 1 # 数值位数
@_window_x = 0 # 窗体x
@_window_x_old = 0 # 窗体旧x
@_window_count = 0 # 窗体移动帧数
@_window_move = [] # 窗体移动路径
@title = title!(title)
@index = index
@_id = []
@_view = Rect.new(x, y, 22*6+4, 32*SubTitleMAX)
@_self = Sprite.new
@_self.bitmap = Bitmap.new(@_view.width+SubTitleSpan, @_view.height)
@_bitmap = @_self.bitmap.dup
@_bitmap_data = [] # 临时位图储存
@_title_count = [] # 移动剩余帧数
@_title_move = [] # 移动速度
@_title_now_y = [] # 各index的y坐标
@_title_str_x = [] # 显示项目的x坐标
@_title_direc = [] # 项目滚动方向
@_head_op = 128;@_head_dr = 1;@_head_move = 25;@_head_move_d = -1
@size = 0
@title.keys.each{|i|make_new(i[@_id.size],@title[i]) if be2self?(i)
@size+=1 if be2self?(i)}
j = 0
@title.keys.each{|i|
if be2self?(i)
@_title_str_x << 0
@_title_count << 0
@_title_move << []
@_title_direc[j] = 1 unless @_title_direc[j]
@_title_now_y << j*32 + SubTitleMAX*32
get_to(j, @_title_now_y[j])
move_to(j,j*32+64,30,1.5)
add_pause(j, [j*10,50].min)
j+=1
end
}
@_update_step = 0
@_sub = nil
@_visible = true
@_active = true
self.x = x;self.y = y;@_z = 0
@_exit = false
end
#--------------------------------------------------------------------------
# 光标位置
#--------------------------------------------------------------------------
def _index
index = [@index]
obj = self
while obj._sub
index += [obj._sub.index]
obj = obj._sub
end
index
end
#--------------------------------------------------------------------------
# 回到x层数
#--------------------------------------------------------------------------
def back2(x)
@_backing = x
end
#--------------------------------------------------------------------------
# 缓存清除
#--------------------------------------------------------------------------
def cache_clear
@_bitmap_data = []
@size = 0
@title.keys.each{|i|make_new(i[@_id.size],@title[i]) if be2self?(i)
@size+=1 if be2self?(i)}
move_nor
@_sub.cache_clear if @_sub
end
#--------------------------------------------------------------------------
# 选择
#--------------------------------------------------------------------------
def set_index(index=@index)
@index = index
return if moving?
@_title_move[index] = [0]
@_title_count[index] = 1
end
#--------------------------------------------------------------------------
# 存在子选项?
#--------------------------------------------------------------------------
def exist_sub?(index=@index)
@title[@_id+[index,0]]
end
#--------------------------------------------------------------------------
# 退出
#--------------------------------------------------------------------------
def exit!
@_exit = true
@size.times{|i|
move_to(i,160,30,1.5)
add_pause(i, [50, @size*10].min-[i*10,50].min)
}
end
#--------------------------------------------------------------------------
# 返回
#--------------------------------------------------------------------------
def back!
return if @_exit
return exit! unless @_sub
@_sub.back! if !@_sub.exit?
end
#--------------------------------------------------------------------------
# 显示数字
#--------------------------------------------------------------------------
def show_num(num)
var = sprintf("%.#{@_num_dig}d", num)
bmp = ISACache.load("0xFB");wd = bmp.width/10
rect = bmp.text_size(var)
new_b = Bitmap.new(@_view.width,32)
x = (new_b.width-rect.width)/2;y = (new_b.height-rect.height)/2
@_num_frt = x
var.split("").each{|i|new_b.blt(x, y, bmp, Rect.new(i.to_i*wd,0,wd,bmp.height));x += wd}
new_b
end
#--------------------------------------------------------------------------
# 退出
#--------------------------------------------------------------------------
def exit?
@_exit and !moving?
end
#--------------------------------------------------------------------------
# 自己的??
#--------------------------------------------------------------------------
def be2self?(ary)
ary.size == @_id.size+1 and @_id == ary[0,@_id.size]
end
#--------------------------------------------------------------------------
# 加入暂停 缓停
#--------------------------------------------------------------------------
def add_pause(index, count)
@_title_move[index] += [0]*count
@_title_count[index] += count
end
#--------------------------------------------------------------------------
# 释放
#--------------------------------------------------------------------------
def dispose
@_sub.dispose if @_sub
@_self.dispose
@_bitmap.dispose
@_self.bitmap.dispose
end
#--------------------------------------------------------------------------
# 刷新副选项箭头
#--------------------------------------------------------------------------
def update_sub_head
return unless exist_sub?
@_head_move += @_head_move_d
@_head_move = [0,[@_head_move,25].min].max
@_bitmap.fill_rect(@_view.width, 67, SubTitleSpan, 32, Color.new(0,0,0,0))
src_bmp = ISACache.load("0xFD")
@_bitmap.blt(@_view.width+@_head_move, 67, src_bmp, src_bmp.rect, @_head_op)
@_head_op += @_head_dr * 3
@_head_dr *= -1 if @_head_op >= 255 or @_head_op <= 125
@_head_op = 255 if @_head_op > 255
end
#--------------------------------------------------------------------------
# 刷新
#--------------------------------------------------------------------------
def update
if @_sub # 子选项刷新
@_sub.update
if @_sub.exit?
@_sub.dispose
@_sub = nil
self.active = true
end
end
if self.class == Wnd_SubTitle_Main # 窗体移动
@_window_x = [(140+SubTitleSpan)*(SubTitleDeep-_index.size),0].min
move_window if @_window_x != @_window_x_old
if @_window_count > 0
@_window_count -= 1
self.x += @_window_move[@_window_count]
end
end
update_move # 移动刷新
if @_num_input # 数值输入??
if Input.repeat?(Input::DOWN) and self.active and !@_exit
play_se
@_num_ipt -= 10**(@_num_dig-@_num_index-1)
@_num_ipt = [[@_num_ipt, 0].max, @_num_max].min
end
if Input.repeat?(Input::UP) and self.active and !@_exit
play_se
@_num_ipt += 10**(@_num_dig-@_num_index-1)
@_num_ipt = [[@_num_ipt, 0].max, @_num_max].min
end
if Input.repeat?(Input::LEFT) and self.active and !@_exit
play_se
@_num_index -= 1 if @_num_index > 0
update_input
end
if Input.repeat?(Input::RIGHT) and self.active and !@_exit
play_se
@_num_index += 1 if @_num_index < @_num_dig -1
update_input
end
else # 普通
if Input.repeat?(Input::DOWN) and self.active and !@_exit
play_se
@index += 1;@index%=@size
move_nor
end
if Input.repeat?(Input::UP) and self.active and !@_exit
play_se
@index -= 1;@index%=@size
move_nor
end
end
if Input.trigger?(Input::C) and self.active and !@_exit
if exist_sub? # 存在选择支
play_se(1)
@_sub = Wnd_SubTitle_Sub.new(@title,self,@_id+[@index])
self.active = false
end
end
if Input.trigger?(Input::B) and self.active and !@_sub and !@_exit
play_se(2)
exit!
end
if self.active
update_input if @_num_input and @_num_ipt_old != @_num_ipt
update_sub_head# 刷新副选项箭头
update_show # 字符显示修正
update_bitmap # 位图刷新
end
return if self.class != Wnd_SubTitle_Main or !@_backing # 检查返回
return @_backing = nil if @_backing == _index.size
back! # 返回!
end
#--------------------------------------------------------------------------
# SE播放
#--------------------------------------------------------------------------
def play_se(se=0)
case ISA::Edition
when :xp
case se
when 0
$game_system.se_play($data_system.cursor_se)
when 1
$game_system.se_play($data_system.decision_se)
when 2
$game_system.se_play($data_system.cancel_se)
end
when :vx
case se
when 0
Sound.play_cursor
when 1
Sound.play_decision
when 2
Sound.play_cancel
end
when :va
case se
when 0
Sound.play_cursor
when 1
Sound.play_ok
when 2
Sound.play_cancel
end
end
end
#--------------------------------------------------------------------------
# 刷新输入
#--------------------------------------------------------------------------
def update_input
return unless @_bitmap_data[index]
@_bitmap_data[index][1] = show_num(@_num_ipt)
bmp = ISACache.load("0xFC")
get_to(0)
@_bitmap.blt(@_num_frt+@_num_index*bmp.width,
16-bmp.height/2+@_title_now_y[0],bmp,bmp.rect,@_num_op)
@_num_op += @_num_de * 5
@_num_de *= -1 if @_num_op < 156 or @_num_op >= 255
@_num_op = [[@_num_op, 155].max,255].min
end
#--------------------------------------------------------------------------
# 移动窗体
#--------------------------------------------------------------------------
def move_window
count = 30;
triangle_v = (@_window_x-@_window_x_old).to_f*2/(count**2)
@_window_move = [-triangle_v/2]
count.times{|i|@_window_move[i]=triangle_v+@_window_move[i-1]}
@_window_count = count
@_window_x_old = @_window_x
end
#--------------------------------------------------------------------------
# C键允许
#--------------------------------------------------------------------------
def c?
return true if !@_sub and !exist_sub?
return true if @_sub and @_sub.c?
false
end
#--------------------------------------------------------------------------
# 字符显示修正
#--------------------------------------------------------------------------
def update_show
@size.times{|i|
if @_title_direc[i] != 0 and (i == @index or !SubTitleUpdate )
@_title_direc[i] *= -1 if @_title_str_x[i] == 0 or @_title_str_x[i]-4 == @_bitmap_data[i][1].width-@_view.width
@_title_str_x[i] -= @_title_direc[i]*0.25
get_to(i, nil, @_title_str_x[i],@index==i)
end
}
end
#--------------------------------------------------------------------------
# 位图刷新
#--------------------------------------------------------------------------
def update_bitmap
@_self.bitmap.clear
@_bitmap.height.times{|a|
if a < 64
@_self.bitmap.blt(0,a,@_bitmap,Rect.new(0,a,@_bitmap.width,1),a*4)
elsif a >= 96
@_self.bitmap.blt(0,a,@_bitmap,Rect.new(0,a,@_bitmap.width,1),(159-a)*4)
elsif a == 64
@_self.bitmap.blt(0,a,@_bitmap,Rect.new(0,a,@_bitmap.width,32))
end
}
end
#--------------------------------------------------------------------------
# 按键通常移动
#--------------------------------------------------------------------------
def move_nor
@size.times{|i|move_to(i, (i-@index+2)*32, 20, 4)}
@_head_move = 25;@_head_move_d =-1
end
#--------------------------------------------------------------------------
# 生成选项
#--------------------------------------------------------------------------
def make_new(index,title)
bg = ISACache.load("0xFF") # 我就不信有人用这个当名称
unless bg
bg = Bitmap.new(22*6,32)
bg.fill_rect(0,2,bg.width,bg.height-4, Color.new(255,255,255,125))
ISACache.save(bg, "0xFF")
end
tl = ISACache.load([@_id+[index],title])
unless tl
tl = make_bmp(@title[@_id+[index]])
ISACache.save(tl, [@_id+[index],title]) if !@_num_input
end
@_title_direc[index] = 0 if tl.width-8 <= @_view.width
@_bitmap_data[index] = [bg, tl]
end
#--------------------------------------------------------------------------
# 获取选项到...
#--------------------------------------------------------------------------
def get_to(index, y=nil, indentation=0,choosing=false)
y = @_title_now_y[index] unless y
@_bitmap.fill_rect(0, y, @_bitmap.width-SubTitleSpan, 32, Color.new(0,0,0,0))
@_bitmap.blt(0, y, @_bitmap_data[index][0], @_bitmap_data[index][0].rect)
if choosing and !@_num_input
@_bitmap.blt(0, y, ISACache.load("0xFE"), @_bitmap_data[index][0].rect)
end
@_bitmap.blt(2, y+3, @_bitmap_data[index][1],
Rect.new(indentation.to_i, 0, @_bitmap_data[index][0].width,32),60) if SubTitleShadow
@_bitmap.blt(0, y, @_bitmap_data[index][1],
Rect.new(indentation.to_i, 0, @_bitmap_data[index][0].width,32))
end
#--------------------------------------------------------------------------
# 移动 仅Y轴 tag_y:目标y count移动时间(帧) a加速度
#--------------------------------------------------------------------------
def move_to(index, tag_y, count, acc)
triangle_v = (tag_y-@_title_now_y[index]).to_f*2/(count**2)
@_title_move[index] = [-triangle_v/2]
count.times{|i|@_title_move[index][i]=triangle_v+@_title_move[index][i-1]}
@_title_count[index] = count
end
#--------------------------------------------------------------------------
# 刷新移动
#--------------------------------------------------------------------------
def update_move
@_title_count.size.times{|i|
if @_title_count[i] > 0
@_title_count[i] -= 1
clear(i)
@_title_now_y[i] += @_title_move[i][@_title_count[i]]
get_to(i, nil, 0, @index==i)
end
}
end
#--------------------------------------------------------------------------
# 清除
#--------------------------------------------------------------------------
def clear(index)
y = @_title_now_y[index]
@_bitmap.fill_rect(0, y, @_bitmap.width, 32, Color.new(0,0,0,0))
end
#--------------------------------------------------------------------------
# 运动中??
#--------------------------------------------------------------------------
def moving?
@_title_count.any?{|i|i>0}
end
#--------------------------------------------------------------------------
# 各种属性
#--------------------------------------------------------------------------
def x=(x)
@_x = x
@_self.x = x
@_view.x = x
end
def x
@_x
end
def y=(y)
@_y = y
@_self.y = y
@_view.y = y
end
def y
@_y
end
def z=(z)
@_z = z
@_self.z = @_z
end
def z
@_z
end
def visible=(visible)
@_visible = visible
@_self.visible = visible
end
def visible
@_visible
end
def active=(active)
@_active = active
end
def active
@_active
end
def input
input = [0]
obj = @_sub
loop do
input << obj._num_ipt
break if !obj.exist_sub?
obj = obj._sub
end
input
end
end
class Array
def add_ele(pos, num)
self[pos] += num
end
end
#==============================================================================
# ■ Wnd_SubTitle_Main
#------------------------------------------------------------------------------
# 子选项 主窗体
#==============================================================================
class Wnd_SubTitle_Sub < Wnd_SubTitle_Main
def true_father
obj = @father
loop do
break if obj.class == Wnd_SubTitle_Main
obj = obj.father
end
obj
end
attr_reader :father
attr_reader :_num_ipt
#--------------------------------------------------------------------------
# 初始化对象
#--------------------------------------------------------------------------
def initialize(title,father,_id,index=0)
@_num_input = false # 数字输入标志
@_num_ipt = 0 # 数值
@_num_max = 0 # 最大数值
@_num_index = 0 # 数值标志
@_num_frt = 0 # 数值输入x坐标
@_num_op = 255
@_num_dig = 1 # 数值位数
@title = title
@index = index
@_num_de = -1
##########
@father = father
@_id = _id
@_view = Rect.new(father.x, father.y, 22*6+4, 32*ISA::SubTitleMAX)
@_self = Sprite.new
@_self.bitmap = Bitmap.new(@_view.width+ISA::SubTitleSpan, @_view.height)
@_bitmap = @_self.bitmap.dup
@_bitmap_data = [] # 临时位图储存
@_title_count = [] # 移动剩余帧数
@_title_move = [] # 移动速度
@_title_now_y = [] # 各index的y坐标
@_title_str_x = [] # 显示项目的x坐标
@_title_direc = [] # 项目滚动方向
@_head_op = 128;@_head_dr = 1;@_head_move = 25;@_head_move_d = -1
@size = 0
@title.keys.each{|i|make_new(i[@_id.size],@title[i]) if be2self?(i)
@size+=1 if be2self?(i)}
j = 0
@title.keys.each{|i|
if be2self?(i)
@_title_str_x << 0
@_title_count << 0
@_title_move << []
@_title_direc[j] = 1 unless @_title_direc[j]
@_title_now_y << j*32 + ISA::SubTitleMAX*32
get_to(j, @_title_now_y[j])
move_to(j,j*32+64,30,1.5)
add_pause(j, [j*10,50].min)
j+=1
end
}
@_update_step = 0
@_sub = nil
@_visible = true
@_active = true
self.x = father.x+140+ISA::SubTitleSpan;self.y = father.y;@_z = father.z
@_exit = false
end
def update
super
self.x = @father.x+140+ISA::SubTitleSpan;self.y = @father.y;@_z = @father.z
end
end
库:
class Wnd_SubTitle_Main case ISA::Edition when :xp #-------------------------------------------------------------------------- # 文件初处理 #-------------------------------------------------------------------------- def title!(title) tmp = title.dup ary = tmp.keys.sort ary.each{|i| case tmp[i][0] when "输入" next unless tmp[i][4] size = 0;tmp2 = i.dup pos = tmp[i][4] loop do tmp2.add_ele(pos,1) tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i] break unless tmp[tmp2[0,pos+1]] end when "特技" if tmp[i][1].is_a?(String) actor = eval(tmp[i][1]) next unless actor data = actor.skills if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["特技",data[j]]} end end when "命令" size = 0;tmp2 = i.dup pos = tmp[i][3] ? tmp[i][3] : i.size-2 loop do tmp2.add_ele(pos,1) tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i] break unless tmp[tmp2[0,pos+1]] end when "队伍" data = $game_party.actors if data == [] tmp.delete(i) # 删除 else size = 0;tmp2 = i.dup pos = tmp[i][1] #? tmp[i][1] : i.size-2 unless pos data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["角色",data[j]]} else loop do var = tmp2[0,pos+1]+i[pos+1,i.size-pos-1] data.size.times{|j|tmp[var[0,var.size-1]+[j]] = ["角色",data[j]]} tmp2.add_ele(pos,1) break unless tmp[tmp2[0,pos+1]] end end end when "物品" if tmp[i][1] == 0 data = [] for j in 1...$data_items.size data << j if $game_party.item_number(j) > 0 end if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]} end end when "武器" if tmp[i][1] == 0 data = [] for j in 1...$data_weapons.size data << j if $game_party.weapon_number(j) > 0 end if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["武器",data[j]]} end end when "防具" if tmp[i][1] == 0 data = [] for j in 1...$data_armors.size data << j if $game_party.armor_number(j) > 0 end if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["防具",data[j]]} end end end } tmp end #-------------------------------------------------------------------------- # 生成位图 #-------------------------------------------------------------------------- def make_bmp(obj) case obj[0] when "输入" @_num_input = true @_num_dig = eval(obj[1]) @_num_ipt = eval(obj[2]) @_num_max = eval(obj[3]) bmp = show_num(@_num_ipt) update_input when "命令" str = eval(obj[1]) wid = @_self.bitmap.text_size(str) bmp = Bitmap.new([wid.width, @_view.width].max,32) bmp.font.color = eval(obj[2]) ? Color.new(0,0,0) : Color.new(120,120,120) bmp.draw_text(bmp.rect, str, 1) when "文字" wid = @_self.bitmap.text_size(obj[1]) bmp = Bitmap.new([wid.width, @_view.width].max,32) bmp.font.color = Color.new(0,0,0) bmp.draw_text(bmp.rect, obj[1], 1) when "特技" item = $data_skills[obj[1]] name = item.name wid = @_self.bitmap.text_size(name) wid.width += 24 bitmap = RPG::Cache.icon(item.icon_name) bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32) bmp.blt((bmp.width-wid.width)/2, 4, bitmap, Rect.new(0, 0, 24, 24)) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0, 0, bmp.width, 32, " "+name,1) when "物品" item = $data_items[obj[1]] name = item.name + " ×#{$game_party.item_number(item.id)} " wid = @_self.bitmap.text_size(name) bitmap = RPG::Cache.icon(item.icon_name) bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32) bmp.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24)) bmp.font.color = Color.new(0,0,0) bmp.draw_text(28, 0, 212, 32, name) when "武器" item = $data_weapons[obj[1]] name = item.name + " ×#{$game_party.weapon_number(item.id)} " wid = @_self.bitmap.text_size(name) bitmap = RPG::Cache.icon(item.icon_name) bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32) bmp.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24)) bmp.font.color = Color.new(0,0,0) bmp.draw_text(28, 0, 212, 32, name) when "防具" item = $data_armors[obj[1]] name = item.name + " ×#{$game_party.armor_number(item.id)} " wid = @_self.bitmap.text_size(name) bitmap = RPG::Cache.icon(item.icon_name) bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32) bmp.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24)) bmp.font.color = Color.new(0,0,0) bmp.draw_text(28, 0, 212, 32, name) when "脚本" str = eval(obj[1]) wid = @_self.bitmap.text_size(str) bmp = Bitmap.new([wid.width, @_view.width].max+8,32) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, str, 1) when "角色" wid = @_self.bitmap.text_size(obj[1].name) bmp = Bitmap.new([wid.width, @_view.width].max+8,32) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, obj[1].name, 1) else print "未定义#{obj[0]}";exit end bmp end when :vx #-------------------------------------------------------------------------- # 文件初处理 #-------------------------------------------------------------------------- def title!(title) tmp = title.dup ary = tmp.keys.sort ary.each{|i| case tmp[i][0] when "输入" next unless tmp[i][4] size = 0;tmp2 = i.dup pos = tmp[i][4] loop do tmp2.add_ele(pos,1) tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i] break unless tmp[tmp2[0,pos+1]] end when "特技" if tmp[i][1].is_a?(String) actor = eval(tmp[i][1]) next unless actor data = actor.skills if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["特技",data[j]]} end end when "命令" size = 0;tmp2 = i.dup pos = tmp[i][3] ? tmp[i][3] : i.size-2 loop do tmp2.add_ele(pos,1) tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i] break unless tmp[tmp2[0,pos+1]] end when "队伍" data = $game_party.members if data == [] tmp.delete(i) # 删除 else size = 0;tmp2 = i.dup pos = tmp[i][1] #? tmp[i][1] : i.size-2 unless pos data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["角色",data[j]]} else loop do tmp2.add_ele(pos,1) var = tmp2[0,pos+1]+i[pos+1,i.size-pos-1] data.size.times{|j|tmp[var[0,var.size-1]+[j]] = ["角色",data[j]]} break unless tmp[tmp2[0,pos+1]] end end end when "物品" if tmp[i][1] == 0 data = [] $game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Item)} if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]} end end when "武器" if tmp[i][1] == 0 data = [] $game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Weapon)} if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]} end end when "防具" if tmp[i][1] == 0 data = [] $game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Armor)} if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]} end end end } tmp end #-------------------------------------------------------------------------- # 生成位图 #-------------------------------------------------------------------------- def make_bmp(obj) case obj[0] when "输入" @_num_input = true @_num_dig = eval(obj[1]) @_num_ipt = eval(obj[2]) @_num_max = eval(obj[3]) bmp = show_num(@_num_ipt) update_input when "命令" str = eval(obj[1]) wid = @_self.bitmap.text_size(str) bmp = Bitmap.new([wid.width, @_view.width].max,32) bmp.font.color = eval(obj[2]) ? Color.new(0,0,0) : Color.new(120,120,120) bmp.draw_text(bmp.rect, str, 1) when "文字" wid = @_self.bitmap.text_size(obj[1]) bmp = Bitmap.new([wid.width, @_view.width].max,32) bmp.font.color = Color.new(0,0,0) bmp.draw_text(bmp.rect, obj[1], 1) when "特技" item = obj[1];name = item.name icon_index = item.icon_index wid = @_self.bitmap.text_size(name) wid.width += 24 bitmap = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32) bmp.blt((bmp.width-wid.width)/2, 4, bitmap, rect) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0, 0, bmp.width, 32, " "+name,1) when "物品" item = obj[1];name = item.name+" ×#{$game_party.item_number(item)} " icon_index = item.icon_index wid = @_self.bitmap.text_size(name) wid.width += 24 bitmap = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32) bmp.blt((bmp.width-wid.width)/2, 4, bitmap, rect) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0, 0, bmp.width, 32, " "+name,1) when "脚本" str = eval(obj[1]) wid = @_self.bitmap.text_size(str) bmp = Bitmap.new([wid.width, @_view.width].max+8,32) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, str, 1) when "角色" wid = @_self.bitmap.text_size(obj[1].name) bmp = Bitmap.new([wid.width, @_view.width].max+8,32) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, obj[1].name, 1) else print "未定义#{obj}";exit end bmp end when :va #-------------------------------------------------------------------------- # 文件初处理 #-------------------------------------------------------------------------- def title!(title) tmp = title.dup ary = tmp.keys.sort ary.each{|i| case tmp[i][0] when "输入" next unless tmp[i][4] size = 0;tmp2 = i.dup pos = tmp[i][4] loop do tmp2.add_ele(pos,1) tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i] break unless tmp[tmp2[0,pos+1]] end when "特技" if tmp[i][1].is_a?(String) actor = eval(tmp[i][1]) next unless actor data = actor.skills if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["特技",data[j]]} end end when "命令" size = 0;tmp2 = i.dup pos = tmp[i][3] ? tmp[i][3] : i.size-2 loop do tmp2.add_ele(pos,1) tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i] break unless tmp[tmp2[0,pos+1]] end when "队伍" data = $game_party.members if data == [] tmp.delete(i) # 删除 else size = 0;tmp2 = i.dup pos = tmp[i][1] #? tmp[i][1] : i.size-2 unless pos data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["角色",data[j]]} else loop do tmp2.add_ele(pos,1) var = tmp2[0,pos+1]+i[pos+1,i.size-pos-1] data.size.times{|j|tmp[var[0,var.size-1]+[j]] = ["角色",data[j]]} break unless tmp[tmp2[0,pos+1]] end end end when "贵重物品" if tmp[i][1] == 0 data = [] $game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Item) and item.key_item?} if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]} end end when "物品" if tmp[i][1] == 0 data = [] $game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Item) and !item.key_item?} if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]} end end when "武器" if tmp[i][1] == 0 data = [] $game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Weapon)} if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]} end end when "防具" if tmp[i][1] == 0 data = [] $game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Armor)} if data == [] tmp.delete(i) # 删除 else data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]} end end end } tmp end #-------------------------------------------------------------------------- # 生成位图 #-------------------------------------------------------------------------- def make_bmp(obj) case obj[0] when "输入" @_num_input = true @_num_dig = eval(obj[1]) @_num_ipt = eval(obj[2]) @_num_max = eval(obj[3]) bmp = show_num(@_num_ipt) update_input when "命令" str = eval(obj[1]) wid = @_self.bitmap.text_size(str) bmp = Bitmap.new([wid.width, @_view.width].max,32) bmp.font.color = eval(obj[2]) ? Color.new(0,0,0) : Color.new(120,120,120) bmp.draw_text(bmp.rect, str, 1) when "文字" wid = @_self.bitmap.text_size(obj[1]) bmp = Bitmap.new([wid.width, @_view.width].max,32) bmp.font.color = Color.new(0,0,0) bmp.draw_text(bmp.rect, obj[1], 1) when "特技" item = obj[1];name = item.name icon_index = item.icon_index wid = @_self.bitmap.text_size(name) wid.width += 24 bitmap = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32) bmp.blt((bmp.width-wid.width)/2, 4, bitmap, rect) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0, 0, bmp.width, 32, " "+name,1) when "物品" item = obj[1];name = item.name+" ×#{$game_party.item_number(item)} " icon_index = item.icon_index wid = @_self.bitmap.text_size(name) wid.width += 24 bitmap = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32) bmp.blt((bmp.width-wid.width)/2, 4, bitmap, rect) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0, 0, bmp.width, 32, " "+name,1) when "脚本" str = eval(obj[1]) wid = @_self.bitmap.text_size(str) bmp = Bitmap.new([wid.width, @_view.width].max+8,32) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, str, 1) when "角色" wid = @_self.bitmap.text_size(obj[1].name) bmp = Bitmap.new([wid.width, @_view.width].max+8,32) bmp.font.color = Color.new(0,0,0) bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, obj[1].name, 1) else print "未定义#{obj}";exit end bmp end else print "RGSS版本识别不能" end end
class Wnd_SubTitle_Main
case ISA::Edition
when :xp
#--------------------------------------------------------------------------
# 文件初处理
#--------------------------------------------------------------------------
def title!(title)
tmp = title.dup
ary = tmp.keys.sort
ary.each{|i|
case tmp[i][0]
when "输入"
next unless tmp[i][4]
size = 0;tmp2 = i.dup
pos = tmp[i][4]
loop do
tmp2.add_ele(pos,1)
tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i]
break unless tmp[tmp2[0,pos+1]]
end
when "特技"
if tmp[i][1].is_a?(String)
actor = eval(tmp[i][1])
next unless actor
data = actor.skills
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["特技",data[j]]}
end
end
when "命令"
size = 0;tmp2 = i.dup
pos = tmp[i][3] ? tmp[i][3] : i.size-2
loop do
tmp2.add_ele(pos,1)
tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i]
break unless tmp[tmp2[0,pos+1]]
end
when "队伍"
data = $game_party.actors
if data == []
tmp.delete(i) # 删除
else
size = 0;tmp2 = i.dup
pos = tmp[i][1] #? tmp[i][1] : i.size-2
unless pos
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["角色",data[j]]}
else
loop do
var = tmp2[0,pos+1]+i[pos+1,i.size-pos-1]
data.size.times{|j|tmp[var[0,var.size-1]+[j]] = ["角色",data[j]]}
tmp2.add_ele(pos,1)
break unless tmp[tmp2[0,pos+1]]
end
end
end
when "物品"
if tmp[i][1] == 0
data = []
for j in 1...$data_items.size
data << j if $game_party.item_number(j) > 0
end
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]}
end
end
when "武器"
if tmp[i][1] == 0
data = []
for j in 1...$data_weapons.size
data << j if $game_party.weapon_number(j) > 0
end
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["武器",data[j]]}
end
end
when "防具"
if tmp[i][1] == 0
data = []
for j in 1...$data_armors.size
data << j if $game_party.armor_number(j) > 0
end
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["防具",data[j]]}
end
end
end
}
tmp
end
#--------------------------------------------------------------------------
# 生成位图
#--------------------------------------------------------------------------
def make_bmp(obj)
case obj[0]
when "输入"
@_num_input = true
@_num_dig = eval(obj[1])
@_num_ipt = eval(obj[2])
@_num_max = eval(obj[3])
bmp = show_num(@_num_ipt)
update_input
when "命令"
str = eval(obj[1])
wid = @_self.bitmap.text_size(str)
bmp = Bitmap.new([wid.width, @_view.width].max,32)
bmp.font.color = eval(obj[2]) ? Color.new(0,0,0) : Color.new(120,120,120)
bmp.draw_text(bmp.rect, str, 1)
when "文字"
wid = @_self.bitmap.text_size(obj[1])
bmp = Bitmap.new([wid.width, @_view.width].max,32)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(bmp.rect, obj[1], 1)
when "特技"
item = $data_skills[obj[1]]
name = item.name
wid = @_self.bitmap.text_size(name)
wid.width += 24
bitmap = RPG::Cache.icon(item.icon_name)
bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32)
bmp.blt((bmp.width-wid.width)/2, 4, bitmap, Rect.new(0, 0, 24, 24))
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0, 0, bmp.width, 32, " "+name,1)
when "物品"
item = $data_items[obj[1]]
name = item.name + " ×#{$game_party.item_number(item.id)} "
wid = @_self.bitmap.text_size(name)
bitmap = RPG::Cache.icon(item.icon_name)
bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32)
bmp.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(28, 0, 212, 32, name)
when "武器"
item = $data_weapons[obj[1]]
name = item.name + " ×#{$game_party.weapon_number(item.id)} "
wid = @_self.bitmap.text_size(name)
bitmap = RPG::Cache.icon(item.icon_name)
bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32)
bmp.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(28, 0, 212, 32, name)
when "防具"
item = $data_armors[obj[1]]
name = item.name + " ×#{$game_party.armor_number(item.id)} "
wid = @_self.bitmap.text_size(name)
bitmap = RPG::Cache.icon(item.icon_name)
bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32)
bmp.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(28, 0, 212, 32, name)
when "脚本"
str = eval(obj[1])
wid = @_self.bitmap.text_size(str)
bmp = Bitmap.new([wid.width, @_view.width].max+8,32)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, str, 1)
when "角色"
wid = @_self.bitmap.text_size(obj[1].name)
bmp = Bitmap.new([wid.width, @_view.width].max+8,32)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, obj[1].name, 1)
else
print "未定义#{obj[0]}";exit
end
bmp
end
when :vx
#--------------------------------------------------------------------------
# 文件初处理
#--------------------------------------------------------------------------
def title!(title)
tmp = title.dup
ary = tmp.keys.sort
ary.each{|i|
case tmp[i][0]
when "输入"
next unless tmp[i][4]
size = 0;tmp2 = i.dup
pos = tmp[i][4]
loop do
tmp2.add_ele(pos,1)
tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i]
break unless tmp[tmp2[0,pos+1]]
end
when "特技"
if tmp[i][1].is_a?(String)
actor = eval(tmp[i][1])
next unless actor
data = actor.skills
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["特技",data[j]]}
end
end
when "命令"
size = 0;tmp2 = i.dup
pos = tmp[i][3] ? tmp[i][3] : i.size-2
loop do
tmp2.add_ele(pos,1)
tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i]
break unless tmp[tmp2[0,pos+1]]
end
when "队伍"
data = $game_party.members
if data == []
tmp.delete(i) # 删除
else
size = 0;tmp2 = i.dup
pos = tmp[i][1] #? tmp[i][1] : i.size-2
unless pos
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["角色",data[j]]}
else
loop do
tmp2.add_ele(pos,1)
var = tmp2[0,pos+1]+i[pos+1,i.size-pos-1]
data.size.times{|j|tmp[var[0,var.size-1]+[j]] = ["角色",data[j]]}
break unless tmp[tmp2[0,pos+1]]
end
end
end
when "物品"
if tmp[i][1] == 0
data = []
$game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Item)}
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]}
end
end
when "武器"
if tmp[i][1] == 0
data = []
$game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Weapon)}
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]}
end
end
when "防具"
if tmp[i][1] == 0
data = []
$game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Armor)}
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]}
end
end
end
}
tmp
end
#--------------------------------------------------------------------------
# 生成位图
#--------------------------------------------------------------------------
def make_bmp(obj)
case obj[0]
when "输入"
@_num_input = true
@_num_dig = eval(obj[1])
@_num_ipt = eval(obj[2])
@_num_max = eval(obj[3])
bmp = show_num(@_num_ipt)
update_input
when "命令"
str = eval(obj[1])
wid = @_self.bitmap.text_size(str)
bmp = Bitmap.new([wid.width, @_view.width].max,32)
bmp.font.color = eval(obj[2]) ? Color.new(0,0,0) : Color.new(120,120,120)
bmp.draw_text(bmp.rect, str, 1)
when "文字"
wid = @_self.bitmap.text_size(obj[1])
bmp = Bitmap.new([wid.width, @_view.width].max,32)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(bmp.rect, obj[1], 1)
when "特技"
item = obj[1];name = item.name
icon_index = item.icon_index
wid = @_self.bitmap.text_size(name)
wid.width += 24
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32)
bmp.blt((bmp.width-wid.width)/2, 4, bitmap, rect)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0, 0, bmp.width, 32, " "+name,1)
when "物品"
item = obj[1];name = item.name+" ×#{$game_party.item_number(item)} "
icon_index = item.icon_index
wid = @_self.bitmap.text_size(name)
wid.width += 24
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32)
bmp.blt((bmp.width-wid.width)/2, 4, bitmap, rect)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0, 0, bmp.width, 32, " "+name,1)
when "脚本"
str = eval(obj[1])
wid = @_self.bitmap.text_size(str)
bmp = Bitmap.new([wid.width, @_view.width].max+8,32)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, str, 1)
when "角色"
wid = @_self.bitmap.text_size(obj[1].name)
bmp = Bitmap.new([wid.width, @_view.width].max+8,32)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, obj[1].name, 1)
else
print "未定义#{obj}";exit
end
bmp
end
when :va
#--------------------------------------------------------------------------
# 文件初处理
#--------------------------------------------------------------------------
def title!(title)
tmp = title.dup
ary = tmp.keys.sort
ary.each{|i|
case tmp[i][0]
when "输入"
next unless tmp[i][4]
size = 0;tmp2 = i.dup
pos = tmp[i][4]
loop do
tmp2.add_ele(pos,1)
tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i]
break unless tmp[tmp2[0,pos+1]]
end
when "特技"
if tmp[i][1].is_a?(String)
actor = eval(tmp[i][1])
next unless actor
data = actor.skills
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["特技",data[j]]}
end
end
when "命令"
size = 0;tmp2 = i.dup
pos = tmp[i][3] ? tmp[i][3] : i.size-2
loop do
tmp2.add_ele(pos,1)
tmp[tmp2[0,pos+1]+i[pos+1,i.size-pos-1]] = tmp[i]
break unless tmp[tmp2[0,pos+1]]
end
when "队伍"
data = $game_party.members
if data == []
tmp.delete(i) # 删除
else
size = 0;tmp2 = i.dup
pos = tmp[i][1] #? tmp[i][1] : i.size-2
unless pos
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["角色",data[j]]}
else
loop do
tmp2.add_ele(pos,1)
var = tmp2[0,pos+1]+i[pos+1,i.size-pos-1]
data.size.times{|j|tmp[var[0,var.size-1]+[j]] = ["角色",data[j]]}
break unless tmp[tmp2[0,pos+1]]
end
end
end
when "贵重物品"
if tmp[i][1] == 0
data = []
$game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Item) and item.key_item?}
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]}
end
end
when "物品"
if tmp[i][1] == 0
data = []
$game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Item) and !item.key_item?}
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]}
end
end
when "武器"
if tmp[i][1] == 0
data = []
$game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Weapon)}
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]}
end
end
when "防具"
if tmp[i][1] == 0
data = []
$game_party.items.each{|item|data.push(item) if item.is_a?(RPG::Armor)}
if data == []
tmp.delete(i) # 删除
else
data.size.times{|j|tmp[i[0,i.size-1]+[j]] = ["物品",data[j]]}
end
end
end
}
tmp
end
#--------------------------------------------------------------------------
# 生成位图
#--------------------------------------------------------------------------
def make_bmp(obj)
case obj[0]
when "输入"
@_num_input = true
@_num_dig = eval(obj[1])
@_num_ipt = eval(obj[2])
@_num_max = eval(obj[3])
bmp = show_num(@_num_ipt)
update_input
when "命令"
str = eval(obj[1])
wid = @_self.bitmap.text_size(str)
bmp = Bitmap.new([wid.width, @_view.width].max,32)
bmp.font.color = eval(obj[2]) ? Color.new(0,0,0) : Color.new(120,120,120)
bmp.draw_text(bmp.rect, str, 1)
when "文字"
wid = @_self.bitmap.text_size(obj[1])
bmp = Bitmap.new([wid.width, @_view.width].max,32)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(bmp.rect, obj[1], 1)
when "特技"
item = obj[1];name = item.name
icon_index = item.icon_index
wid = @_self.bitmap.text_size(name)
wid.width += 24
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32)
bmp.blt((bmp.width-wid.width)/2, 4, bitmap, rect)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0, 0, bmp.width, 32, " "+name,1)
when "物品"
item = obj[1];name = item.name+" ×#{$game_party.item_number(item)} "
icon_index = item.icon_index
wid = @_self.bitmap.text_size(name)
wid.width += 24
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bmp = Bitmap.new([wid.width+28, @_view.width].max+8,32)
bmp.blt((bmp.width-wid.width)/2, 4, bitmap, rect)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0, 0, bmp.width, 32, " "+name,1)
when "脚本"
str = eval(obj[1])
wid = @_self.bitmap.text_size(str)
bmp = Bitmap.new([wid.width, @_view.width].max+8,32)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, str, 1)
when "角色"
wid = @_self.bitmap.text_size(obj[1].name)
bmp = Bitmap.new([wid.width, @_view.width].max+8,32)
bmp.font.color = Color.new(0,0,0)
bmp.draw_text(0,0,bmp.width-SubTitleSpan,bmp.height, obj[1].name, 1)
else
print "未定义#{obj}";exit
end
bmp
end
else
print "RGSS版本识别不能"
end
end
附件范例下载:
RM.part1.rar
(999 KB, 下载次数: 180)
RM.part2.rar
(914.33 KB, 下载次数: 193)
|
评分
-
查看全部评分
|