赞 | 54 |
VIP | 0 |
好人卡 | 3 |
积分 | 46 |
经验 | 31992 |
最后登录 | 2024-11-7 |
在线时间 | 1206 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 4598
- 在线时间
- 1206 小时
- 注册时间
- 2016-4-7
- 帖子
- 982
|
本帖最后由 shitake 于 2019-3-4 02:10 编辑
为什么不来试试 rgui 呢 【逃
github.com/molingyu/rgui
https://molingyu.github.io/rgui/
rgui
上边界面的等价物 没测试 感觉是跑不起来 orz
# require 'rgui' class View_Title include RGUI def initialize @childs = [] @bg = Component::ImageBox.new({ image: Bitmap.new('bg.png'), x: 0, y: 0, width: Graphics.width, height: Graphics.height, type: Component::ImageBoxType::Filling }) @childs.push @bg @button_bg = Component::ImageBox.new({ image: Bitmap.new(Graphics.width, 48).fill(0, 0, Graphics.width, 48, Color.new(255, 255, 255, 180)), type: Component::ImageBoxType::Responsive, visible: false }) @button_bg.add_action(:breath, {speed: 0.6}) @childs.push @button_bg @command_index = 0 end def create_command(name, method, enabled = false) button = Component::SpriteButton.new({ x: 0, y: 300 + @command_index * 48, status: enabled, images: create_button_bitmap(conf.name) }) button.on(:click){ |_| method.call } button.on(:mouse_out){ |em| em.object.lost_focus } button.on(:lost_focus) { |em| em.object.sprite.zoom_y = 1 index = @childs.index(em.object) while(@childs[index + 1].class == Component::SpriteButton) @childs[index + 1].y = @childs[index].y + @childs[index].height index += 1 end @button_bg.hide } button.on(:mouse_in){ |em| Event::EventManager.focus_object.lost_focus if Event::EventManager.focus_object != em.object Event::EventManager.focus_object == em.object em.object.get_focus } button.on(:get_focus){ |em| em.object.sprite.zoom_y = 1.5 index = @childs.index(em.object) while(@childs[index + 1].class == Component::SpriteButton) @childs[index + 1].y = @childs[index].y + @childs[index].height * 1.5 index += 1 end @button_bg.y = em.object.y @button_bg.show } @childs.push(button) @command_index += 1 end def create_button_bitmap(name) font = Font.new("LilyUPC", 32) font.bold = true font.out_color = Color::BLACK [Color::GL18, Color::GL32, Color::GL4].map{|c| bitmap = Bitmap.new(Graphics.width, 32) bitmap.font = font bitmap.font.color = c bitmap.draw_text(0, 0, Graphics.width, 32, name, 1) bitmap } end def update @childs.each{|c| c.update } end def dispose @childs.each{|c| c.dispose } end end class Scene_Title < Scene_Base def start @view = View_Title.new @view.create_command 'New Game', method :new_game @view.create_command 'Load Game', method(:continue), DataManager.save_file_exists? @view.create_command 'Shutdown', method :shutdown end def update @view.update end def new_game end def continue end def shutdown end end
# require 'rgui'
class View_Title
include RGUI
def initialize
@childs = []
@bg = Component::ImageBox.new({
image: Bitmap.new('bg.png'),
x: 0,
y: 0,
width: Graphics.width,
height: Graphics.height,
type: Component::ImageBoxType::Filling
})
@childs.push @bg
@button_bg = Component::ImageBox.new({
image: Bitmap.new(Graphics.width, 48).fill(0, 0, Graphics.width, 48, Color.new(255, 255, 255, 180)),
type: Component::ImageBoxType::Responsive,
visible: false
})
@button_bg.add_action(:breath, {speed: 0.6})
@childs.push @button_bg
@command_index = 0
end
def create_command(name, method, enabled = false)
button = Component::SpriteButton.new({
x: 0,
y: 300 + @command_index * 48,
status: enabled,
images: create_button_bitmap(conf.name)
})
button.on(:click){ |_| method.call }
button.on(:mouse_out){ |em| em.object.lost_focus }
button.on(:lost_focus) { |em|
em.object.sprite.zoom_y = 1
index = @childs.index(em.object)
while(@childs[index + 1].class == Component::SpriteButton)
@childs[index + 1].y = @childs[index].y + @childs[index].height
index += 1
end
@button_bg.hide
}
button.on(:mouse_in){ |em|
Event::EventManager.focus_object.lost_focus if Event::EventManager.focus_object != em.object
Event::EventManager.focus_object == em.object
em.object.get_focus
}
button.on(:get_focus){ |em|
em.object.sprite.zoom_y = 1.5
index = @childs.index(em.object)
while(@childs[index + 1].class == Component::SpriteButton)
@childs[index + 1].y = @childs[index].y + @childs[index].height * 1.5
index += 1
end
@button_bg.y = em.object.y
@button_bg.show
}
@childs.push(button)
@command_index += 1
end
def create_button_bitmap(name)
font = Font.new("LilyUPC", 32)
font.bold = true
font.out_color = Color::BLACK
[Color::GL18, Color::GL32, Color::GL4].map{|c|
bitmap = Bitmap.new(Graphics.width, 32)
bitmap.font = font
bitmap.font.color = c
bitmap.draw_text(0, 0, Graphics.width, 32, name, 1)
bitmap
}
end
def update
@childs.each{|c| c.update }
end
def dispose
@childs.each{|c| c.dispose }
end
end
class Scene_Title < Scene_Base
def start
@view = View_Title.new
@view.create_command 'New Game', method :new_game
@view.create_command 'Load Game', method(:continue), DataManager.save_file_exists?
@view.create_command 'Shutdown', method :shutdown
end
def update
@view.update
end
def new_game
end
def continue
end
def shutdown
end
end
|
|