# 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