Updated menus, added background to Tools

This commit is contained in:
2020-05-04 11:13:51 -05:00
parent 06fb2c0e43
commit fd3785cdcd
7 changed files with 59 additions and 40 deletions

View File

@@ -52,19 +52,21 @@ class IMICFPS
) )
end end
def menu_background(color, color_step, transparency, bar_size, slope) def menu_background(primary_color, accent_color, color_step, transparency, bar_size, slope)
((Gosu.screen_height + slope) / bar_size).times do |i| ((Gosu.screen_height + slope) / bar_size).times do |i|
color = Gosu::Color.rgba(
primary_color.red - i * color_step,
primary_color.green - i * color_step,
primary_color.blue - i * color_step,
transparency
)
fill_quad( fill_quad(
0, i * bar_size, 0, i * bar_size,
0, slope + (i * bar_size), 0, slope + (i * bar_size),
window.width / 2, (-slope) + (i * bar_size), window.width / 2, (-slope) + (i * bar_size),
window.width / 2, i * bar_size, window.width / 2, i * bar_size,
Gosu::Color.rgba( color,
color.red - i * color_step,
color.green - i * color_step,
color.blue - i * color_step,
transparency
),
-2 -2
) )
fill_quad( fill_quad(
@@ -72,15 +74,18 @@ class IMICFPS
window.width, slope + (i * bar_size), window.width, slope + (i * bar_size),
window.width / 2, (-slope) + (i * bar_size), window.width / 2, (-slope) + (i * bar_size),
window.width / 2, i * bar_size, window.width / 2, i * bar_size,
Gosu::Color.rgba( color,
color.red - i * color_step,
color.green - i * color_step,
color.blue - i * color_step,
transparency
),
-2 -2
) )
end end
Gosu.draw_quad(
0, 0, primary_color,
window.width, 0, primary_color,
window.width, window.height, accent_color,
0, window.height, accent_color,
-2
)
end end
def gl_error? def gl_error?

View File

@@ -19,17 +19,10 @@ class IMICFPS
end end
def draw def draw
menu_background(@primary_color, @color_step, @transparency, @bar_size, @slope) menu_background(@primary_color, @accent_color, @color_step, @transparency, @bar_size, @slope)
fraction_left = ((Gosu.milliseconds - @start_time) / (@time_to_live - 200).to_f) fraction_left = ((Gosu.milliseconds - @start_time) / (@time_to_live - 200).to_f)
Gosu.draw_quad(
0, 0, @primary_color,
window.width, 0, @primary_color,
window.width, window.height, @accent_color,
0, window.height, @accent_color
)
if fraction_left <= 1.0 if fraction_left <= 1.0
Gosu.draw_circle( Gosu.draw_circle(
window.width / 2, window.width / 2,

View File

@@ -34,7 +34,8 @@ class IMICFPS
@completed_for_ms = 0 @completed_for_ms = 0
@lock = false @lock = false
@base_color = Gosu::Color.rgb(0, 180, 180) @primary_color = Gosu::Color.rgba(0, 180, 180, 200)
@accent_color = Gosu::Color.rgba(0, 90, 90, 200)
end end
def draw def draw
@@ -115,9 +116,9 @@ class IMICFPS
progress = (@asset_index.to_f/@assets.count)*window.width/2 progress = (@asset_index.to_f/@assets.count)*window.width/2
height = 100 height = 100
dark_color= Gosu::Color.rgb(@base_color.red - 100, @base_color.green - 100, @base_color.blue - 100)#Gosu::Color.rgb(64, 127, 255) dark_color= Gosu::Color.rgb(@primary_color.red - 100, @primary_color.green - 100, @primary_color.blue - 100)#Gosu::Color.rgb(64, 127, 255)
color = Gosu::Color.rgb(@base_color.red - 50, @base_color.green - 50, @base_color.blue - 50)#Gosu::Color.rgb(0,127,127) color = Gosu::Color.rgb(@primary_color.red - 50, @primary_color.green - 50, @primary_color.blue - 50)#Gosu::Color.rgb(0,127,127)
color_two = Gosu::Color.rgb(@base_color.red + 50, @base_color.green + 50, @base_color.blue + 50)#Gosu::Color.rgb(64, 127, 255) color_two = Gosu::Color.rgb(@primary_color.red + 50, @primary_color.green + 50, @primary_color.blue + 50)#Gosu::Color.rgb(64, 127, 255)
draw_rect(x, y-2, x + window.width/4, height+4, dark_color) draw_rect(x, y-2, x + window.width/4, height+4, dark_color)

View File

@@ -1,6 +1,7 @@
class IMICFPS class IMICFPS
class AssetViewerTool class AssetViewerTool
class MainMenu < CyberarmEngine::GuiState class MainMenu < CyberarmEngine::GuiState
include CommonMethods
def setup def setup
window.needs_cursor = true window.needs_cursor = true
@@ -31,6 +32,11 @@ class IMICFPS
end end
end end
def draw
menu_background(Menu::PRIMARY_COLOR, Menu::ACCENT_COLOR, Menu::BAR_COLOR_STEP, Menu::BAR_ALPHA, Menu::BAR_SIZE, Menu::BAR_SLOPE)
super
end
def update def update
super super

View File

@@ -1,6 +1,8 @@
class IMICFPS class IMICFPS
class MapEditorTool class MapEditorTool
class MainMenu < CyberarmEngine::GuiState class MainMenu < CyberarmEngine::GuiState
include CommonMethods
def setup def setup
window.needs_cursor = true window.needs_cursor = true
@@ -35,6 +37,11 @@ class IMICFPS
end end
end end
def draw
menu_background(Menu::PRIMARY_COLOR, Menu::ACCENT_COLOR, Menu::BAR_COLOR_STEP, Menu::BAR_ALPHA, Menu::BAR_SIZE, Menu::BAR_SLOPE)
super
end
def update def update
super super

View File

@@ -1,12 +1,21 @@
class IMICFPS class IMICFPS
class Menu < IMICFPS::GameState class Menu < IMICFPS::GameState
PRIMARY_COLOR = Gosu::Color.rgba(255, 127, 0, 200)
ACCENT_COLOR = Gosu::Color.rgba(155, 27, 0, 200)
BAR_SIZE = 50
BAR_SLOPE = 250
BAR_COLOR_STEP = 10
BAR_ALPHA = 200
def initialize(*args) def initialize(*args)
@elements = [] @elements = []
@size = 50 @bar_size = BAR_SIZE
@slope = 250 @bar_slope = BAR_SLOPE
@color_step = 10 @bar_color_step = BAR_COLOR_STEP
@base_color = Gosu::Color.rgb(255, 127, 0) @bar_alpha = BAR_ALPHA
@background_alpha = 200 @primary_color = PRIMARY_COLOR
@accent_color = ACCENT_COLOR
window.needs_cursor = true window.needs_cursor = true
@__version_text = CyberarmEngine::Text.new("<b>#{IMICFPS::NAME}</b> v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME})") @__version_text = CyberarmEngine::Text.new("<b>#{IMICFPS::NAME}</b> v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME})")
@@ -15,7 +24,7 @@ class IMICFPS
super(*args) super(*args)
end end
def title(text, color = @base_color) def title(text, color = Gosu::Color::BLACK)
@elements << Text.new(text, color: color, size: 100, x: 0, y: 15) @elements << Text.new(text, color: color, size: 100, x: 0, y: 15)
@_title = @elements.last @_title = @elements.last
end end
@@ -31,7 +40,7 @@ class IMICFPS
end end
def draw def draw
menu_background(@base_color, @color_step, @background_alpha, @size, @slope) menu_background(@primary_color, @accent_color, @bar_color_step, @bar_alpha, @bar_size, @bar_slope)
draw_menu_box draw_menu_box
draw_menu draw_menu
@@ -50,7 +59,7 @@ class IMICFPS
draw_rect( draw_rect(
window.width/4, 0, window.width/4, 0,
window.width/2, window.height, window.width/2, window.height,
Gosu::Color.rgba(0, 0, 0, 150), Gosu::Color.new(0x22222222),
) )
end end
@@ -62,7 +71,7 @@ class IMICFPS
def update def update
@elements.each do |e| @elements.each do |e|
e.x = window.width / 2 - e.width / 2 e.x = (window.width / 2 - e.width / 2).round
e.update e.update
end end
@@ -95,19 +104,17 @@ class IMICFPS
def initialize(text, host, block) def initialize(text, host, block)
@text, @host, @block = text, host, block @text, @host, @block = text, host, block
@color = @text.color @color = @text.color
@hover_color = Gosu::Color.rgb(64, 127, 255) @hover_color = Gosu::Color.rgb(64, 128, 255)
@text.shadow_color= Gosu::Color::BLACK
@text.shadow_size = 2
@text.shadow_alpha = 100 @text.shadow_alpha = 100
end end
def update def update
if @host.mouse_over?(self) if @host.mouse_over?(self)
@text.color = @hover_color @text.color = @hover_color
@text.shadow_color= Gosu::Color::BLACK
@text.shadow_size = 3
else else
@text.color = @color @text.color = @color
@text.shadow_color = nil
@text.shadow_size = 1
end end
end end

View File

@@ -1,5 +1,5 @@
class IMICFPS class IMICFPS
class Window < CyberarmEngine::Engine class Window < CyberarmEngine::Window
attr_accessor :number_of_vertices, :needs_cursor attr_accessor :number_of_vertices, :needs_cursor
attr_reader :renderer, :scene, :config attr_reader :renderer, :scene, :config