mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 08:02:36 +00:00
Added more menus; stub for settings, basic pause menu, fixes for multiple Game inits
This commit is contained in:
@@ -12,14 +12,27 @@ class IMICFPS
|
||||
|
||||
def title(text, color = @base_color)
|
||||
@elements << Text.new(text, color: color, size: 100, x: 0, y: 15, alignment: :center)
|
||||
@_title = @elements.last
|
||||
end
|
||||
|
||||
def subtitle(text, color = Gosu::Color::WHITE)
|
||||
@elements << Text.new(text, color: color, size: 50, x: 0, y: 100, alignment: :center)
|
||||
@_subtitle = @elements.last
|
||||
end
|
||||
|
||||
def link(text, color = Gosu::Color.rgb(0,127,127), &block)
|
||||
text = Text.new(text, color: color, size: 50, x: 0, y: 100+(60*@elements.count), alignment: :center)
|
||||
text = Text.new(text, color: color, size: 50, x: 0, y: 100 + (60 * @elements.count), alignment: :center)
|
||||
@elements << Link.new(text, self, block)
|
||||
end
|
||||
|
||||
def draw
|
||||
draw_background
|
||||
draw_menu_box
|
||||
draw_menu
|
||||
window.draw_cursor
|
||||
end
|
||||
|
||||
def draw_background
|
||||
@background ||= Gosu.record(Gosu.screen_width, Gosu.screen_height) do
|
||||
((Gosu.screen_height+@slope)/@size).times do |i|
|
||||
fill_quad(
|
||||
@@ -41,30 +54,21 @@ class IMICFPS
|
||||
end
|
||||
|
||||
@background.draw(0, 0, 0)
|
||||
end
|
||||
|
||||
# Box
|
||||
def draw_menu_box
|
||||
draw_rect(
|
||||
window.width/4, 0,
|
||||
window.width/2, window.height,
|
||||
Gosu::Color.rgba(0, 0, 0, 150)
|
||||
# Gosu::Color.rgba(@base_color.red+@color_step, @base_color.green+@color_step, @base_color.blue+@color_step, 200)
|
||||
)
|
||||
end
|
||||
|
||||
# Texts
|
||||
def draw_menu
|
||||
@elements.each do |e|
|
||||
e.draw
|
||||
end
|
||||
|
||||
# Cursor
|
||||
if window.needs_cursor
|
||||
fill_quad(
|
||||
mouse_x, mouse_y,
|
||||
mouse_x+16, mouse_y,
|
||||
mouse_x, mouse_y+16,
|
||||
mouse_x, mouse_y+16,
|
||||
Gosu::Color::WHITE, Float::INFINITY
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -84,7 +88,6 @@ class IMICFPS
|
||||
end
|
||||
|
||||
def button_up(id)
|
||||
window.close if id == Gosu::KbEscape
|
||||
if id == Gosu::MsLeft
|
||||
@elements.each do |e|
|
||||
next unless e.is_a?(Link)
|
||||
@@ -126,7 +129,7 @@ class IMICFPS
|
||||
def width; text.width; end
|
||||
def height; text.height; end
|
||||
def draw; text.draw; end
|
||||
def clicked; @block.call; end
|
||||
def clicked; @block.call if @block; end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
23
lib/ui/menus/game_pause_menu.rb
Normal file
23
lib/ui/menus/game_pause_menu.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
class IMICFPS
|
||||
class GamePauseMenu < Menu
|
||||
def setup
|
||||
title "I-MIC FPS"
|
||||
subtitle "Paused"
|
||||
|
||||
link "Resume" do
|
||||
pop_state
|
||||
end
|
||||
|
||||
link "Disconnect" do
|
||||
push_state(MainMenu)
|
||||
end
|
||||
end
|
||||
|
||||
def draw
|
||||
previous_state.draw
|
||||
Gosu.flush
|
||||
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6,7 +6,7 @@ class IMICFPS
|
||||
push_state(LoadingState.new(forward: Game, map_file: GAME_ROOT_PATH + "/maps/test_map.json"))
|
||||
end
|
||||
link "Settings" do
|
||||
# push_game_state(SettingsMenu)
|
||||
push_state(SettingsMenu)
|
||||
end
|
||||
link "Exit" do
|
||||
window.close
|
||||
|
||||
14
lib/ui/menus/settings_menu.rb
Normal file
14
lib/ui/menus/settings_menu.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class IMICFPS
|
||||
class SettingsMenu < Menu
|
||||
def setup
|
||||
title "I-MIC FPS"
|
||||
subtitle "Settings"
|
||||
|
||||
link "\"There is no spoon.\""
|
||||
|
||||
link "Back" do
|
||||
pop_state
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user