赞 | 3 |
VIP | 1 |
好人卡 | 40 |
积分 | 1 |
经验 | 93188 |
最后登录 | 2020-7-27 |
在线时间 | 1379 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 76
- 在线时间
- 1379 小时
- 注册时间
- 2012-7-5
- 帖子
- 1698
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
#encoding:utf-8 # 一个子窗口 # 其实功能好扩展我会乱说? class Sub_Window < Window_Base #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize(x, y) super(x, y, window_width, fitting_height(visible_line_number)) self.openness = 0 activate end #-------------------------------------------------------------------------- # ● 获取窗口的宽度 #-------------------------------------------------------------------------- def window_width return 128 end #-------------------------------------------------------------------------- # ● 获取显示行数 #-------------------------------------------------------------------------- def visible_line_number return 1 end #-------------------------------------------------------------------------- # ● 设置 #-------------------------------------------------------------------------- def setup(text, *mode) create_contents self.contents.draw_text(self.contents.rect, text) case mode when [:bar] @var = 0 @vartemp = @var @bar = Sprite.new @bar.x,@bar.y,@bar.z,@bar.opacity = self.x+14,self.y+14,100,205 @bar.bitmap = Bitmap.new(74, 20) @bar.bitmap.fill_rect(@bar.bitmap.rect, Color.new(255,255,255)) self.contents.draw_text(self.contents.rect, @var, 2) end open end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def update super if @bar @var += 1 if Input.press?(:UP) && @var != 100 @var -= 1 if Input.press?(:DOWN) && @var != 0 if @var != @vartemp @vartemp = @var update_bar end end end def dispose (@bar.bitmap.dispose;@bar.dispose) if @bar super end def update_bar self.contents.clear self.contents.draw_text(self.contents.rect, @var, 2) @bar.bitmap.clear @bar.bitmap.fill_rect(@bar.bitmap.rect, Color.new(255,255,255)) @bar.bitmap.fill_rect(0, 0, @bar.bitmap.width*@var/100, 20, Color.new(102,204,255)) end end # 子菜单管理器 # 其实是场景我会瞎说? class Window_WithSub attr_reader :x,:y # 坐标 attr_reader :index # 当前光标位置 attr_reader :windows # 窗口数组 attr_reader :value # 传参借位 attr_reader :methd # 方法数组 # hash 格式: #{ :command1 => method(:symbol1), # :command2 => { :command21 => method(:symbol2) } } def initialize(x, y, hash, &block) @x,@y,@index = x,y,0 @last = @index instance_eval(&block) if block_given? @windows,@methd = [],[] create_windows(hash) main end def main loop do Graphics.update Input.update break dispose if Input.trigger?(:LEFT) update end end def create_windows(hash) hash.each do |key, value| if (value.is_a? Method)||(value.is_a? Symbol) @windows.push(new_window(key, value)) elsif value.is_a? Hash @value = value @windows.push(new_window(key, method(:new_sub))) end end end def new_sub Window_WithSub.new(self.x+60, self.y+40, @value) end def new_window(sym, obj) w = Sub_Window.new(self.x, self.y + 48 * @windows.size) if obj.is_a? Method w.setup(sym.to_s) @methd[@windows.size] = obj elsif obj.is_a? Symbol w.setup("" , obj) @methd[@windows.size] = ->{} end return w end def update if Input.trigger?(:UP) Sound.play_cursor @index == 0 ? @index = @windows.size-1 : @index -= 1 elsif Input.trigger?(:DOWN) Sound.play_cursor @index == @windows.size-1 ? @index = 0 : @index += 1 elsif Input.trigger?(:RIGHT) if @methd[@index].inspect == "#<Method: Game_Interpreter#m1>" Sound.play_buzzer else Sound.play_ok @methd[@index].call end elsif Input.trigger?(:LEFT) Sound.play_cancel end @windows.each { |w| w.update } activate(@windows[@index]) if @last != @index @last = @index end end def dispose @windows.each { |w| w.dispose } end def activate(window) @windows.each_with_index do |w,i| w.cursor_rect.empty w.cursor_rect.set(Rect.new(0, 0, 104, 24)) if w == window end end end class Game_Interpreter def m1;end def callsubw subw = Window_WithSub.new(60, 60, { :物品 => method(:m1), :装备 => method(:m1), :技能 => method(:m1), :状态 => method(:m1), :笔记 => method(:m1), :系统 => { :音乐 => { :var => :bar }, :音效 => method(:m1), :读档 => method(:m1), :标题 => method(:m1)}, :读档 => method(:m1), }) end end
#encoding:utf-8
# 一个子窗口
# 其实功能好扩展我会乱说?
class Sub_Window < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, window_width, fitting_height(visible_line_number))
self.openness = 0
activate
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return 128
end
#--------------------------------------------------------------------------
# ● 获取显示行数
#--------------------------------------------------------------------------
def visible_line_number
return 1
end
#--------------------------------------------------------------------------
# ● 设置
#--------------------------------------------------------------------------
def setup(text, *mode)
create_contents
self.contents.draw_text(self.contents.rect, text)
case mode
when [:bar]
@var = 0
@vartemp = @var
@bar = Sprite.new
@bar.x,@bar.y,@bar.z,@bar.opacity = self.x+14,self.y+14,100,205
@bar.bitmap = Bitmap.new(74, 20)
@bar.bitmap.fill_rect(@bar.bitmap.rect, Color.new(255,255,255))
self.contents.draw_text(self.contents.rect, @var, 2)
end
open
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def update
super
if @bar
@var += 1 if Input.press?(:UP) && @var != 100
@var -= 1 if Input.press?(:DOWN) && @var != 0
if @var != @vartemp
@vartemp = @var
update_bar
end
end
end
def dispose
(@bar.bitmap.dispose;@bar.dispose) if @bar
super
end
def update_bar
self.contents.clear
self.contents.draw_text(self.contents.rect, @var, 2)
@bar.bitmap.clear
@bar.bitmap.fill_rect(@bar.bitmap.rect, Color.new(255,255,255))
@bar.bitmap.fill_rect(0, 0, @bar.bitmap.width*@var/100, 20, Color.new(102,204,255))
end
end
# 子菜单管理器
# 其实是场景我会瞎说?
class Window_WithSub
attr_reader :x,:y # 坐标
attr_reader :index # 当前光标位置
attr_reader :windows # 窗口数组
attr_reader :value # 传参借位
attr_reader :methd # 方法数组
# hash 格式:
#{ :command1 => method(:symbol1),
# :command2 => { :command21 => method(:symbol2) } }
def initialize(x, y, hash, &block)
@x,@y,@index = x,y,0
@last = @index
instance_eval(&block) if block_given?
@windows,@methd = [],[]
create_windows(hash)
main
end
def main
loop do
Graphics.update
Input.update
break dispose if Input.trigger?(:LEFT)
update
end
end
def create_windows(hash)
hash.each do |key, value|
if (value.is_a? Method)||(value.is_a? Symbol)
@windows.push(new_window(key, value))
elsif value.is_a? Hash
@value = value
@windows.push(new_window(key, method(:new_sub)))
end
end
end
def new_sub
Window_WithSub.new(self.x+60, self.y+40, @value)
end
def new_window(sym, obj)
w = Sub_Window.new(self.x, self.y + 48 * @windows.size)
if obj.is_a? Method
w.setup(sym.to_s)
@methd[@windows.size] = obj
elsif obj.is_a? Symbol
w.setup("" , obj)
@methd[@windows.size] = ->{}
end
return w
end
def update
if Input.trigger?(:UP)
Sound.play_cursor
@index == 0 ? @index = @windows.size-1 : @index -= 1
elsif Input.trigger?(:DOWN)
Sound.play_cursor
@index == @windows.size-1 ? @index = 0 : @index += 1
elsif Input.trigger?(:RIGHT)
if @methd[@index].inspect == "#<Method: Game_Interpreter#m1>"
Sound.play_buzzer
else
Sound.play_ok
@methd[@index].call
end
elsif Input.trigger?(:LEFT)
Sound.play_cancel
end
@windows.each { |w| w.update }
activate(@windows[@index])
if @last != @index
@last = @index
end
end
def dispose
@windows.each { |w| w.dispose }
end
def activate(window)
@windows.each_with_index do |w,i|
w.cursor_rect.empty
w.cursor_rect.set(Rect.new(0, 0, 104, 24)) if w == window
end
end
end
class Game_Interpreter
def m1;end
def callsubw
subw = Window_WithSub.new(60, 60, {
:物品 => method(:m1),
:装备 => method(:m1),
:技能 => method(:m1),
:状态 => method(:m1),
:笔记 => method(:m1),
:系统 => {
:音乐 => { :var => :bar },
:音效 => method(:m1),
:读档 => method(:m1),
:标题 => method(:m1)},
:读档 => method(:m1),
})
end
end
我还是太年轻了
以及颜文字功能好像有bug的说搞基编辑模式下按颜文字会清空已编辑的内容 |
评分
-
查看全部评分
|