mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 08:02:36 +00:00
Added vertical_/horizontal_margin/padding to Widgets, added HUD command to toggle HUD
This commit is contained in:
@@ -9,11 +9,11 @@ class IMICFPS
|
||||
end
|
||||
|
||||
def draw
|
||||
# Gosu.draw_rect(
|
||||
# @text.x - Widget.padding, @text.y - Widget.padding,
|
||||
# @text.width + Widget.padding * 2, @text.height + Widget.padding * 2,
|
||||
# @background
|
||||
# )
|
||||
Gosu.draw_rect(
|
||||
@text.x - Widget.horizontal_padding, @text.y - Widget.vertical_padding,
|
||||
@text.width + Widget.horizontal_padding * 2, @text.height + Widget.vertical_padding * 2,
|
||||
@background
|
||||
)
|
||||
@text.draw
|
||||
end
|
||||
|
||||
@@ -23,8 +23,8 @@ class IMICFPS
|
||||
@text.text = "#{random}/999"
|
||||
end
|
||||
|
||||
@text.x = window.width - (Widget.margin + @text.width + Widget.padding)
|
||||
@text.y = window.height - (Widget.margin + @text.height + Widget.padding)
|
||||
@text.x = window.width - (Widget.horizontal_margin + @text.width + Widget.horizontal_padding)
|
||||
@text.y = window.height - (Widget.vertical_margin + @text.height + Widget.vertical_padding)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,8 +12,8 @@ class IMICFPS
|
||||
return unless window.text_input
|
||||
|
||||
Gosu.draw_rect(
|
||||
@text.x - Widget.padding, @text.y - Widget.padding,
|
||||
@text.width + Widget.padding * 2, @text.height + Widget.padding * 2,
|
||||
@text.x - Widget.horizontal_padding, @text.y - Widget.horizontal_padding,
|
||||
@text.width + Widget.vertical_padding * 2, @text.height + Widget.vertical_padding * 2,
|
||||
@background
|
||||
)
|
||||
|
||||
@@ -37,8 +37,8 @@ class IMICFPS
|
||||
end
|
||||
|
||||
@text.text = text.to_s
|
||||
@text.x = window.width / 2 - (Widget.margin + @text.width / 2 + Widget.padding)
|
||||
@text.y = window.height - (Widget.margin + @text.height + Widget.padding)
|
||||
@text.x = window.width / 2 - (Widget.horizontal_margin + @text.width / 2 + Widget.horizontal_padding)
|
||||
@text.y = window.height - (Widget.vertical_margin + @text.height + Widget.vertical_padding)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class IMICFPS
|
||||
@text = CyberarmEngine::Text.new(
|
||||
"",
|
||||
size: 16,
|
||||
x: Widget.margin, y: Widget.margin, z: 45,
|
||||
x: Widget.horizontal_margin, y: Widget.vertical_margin, z: 45,
|
||||
border_color: Gosu::Color::BLACK,
|
||||
font: BOLD_SANS_FONT
|
||||
)
|
||||
|
||||
@@ -19,10 +19,10 @@ class IMICFPS
|
||||
def draw
|
||||
@text.draw
|
||||
fill_quad(
|
||||
window.width / 2 - @width / 2, @spacer + Widget.margin, # TOP LEFT
|
||||
window.width / 2 + @width / 2, @spacer + Widget.margin, # TOP RIGHT
|
||||
window.width / 2 + @width / 2 - @slant, @spacer + Widget.margin + @height, # BOTTOM RIGHT
|
||||
window.width / 2 - @width / 2 + @slant, @spacer + Widget.margin + @height, # BOTTOM LEFT
|
||||
window.width / 2 - @width / 2, @spacer + Widget.vertical_margin, # TOP LEFT
|
||||
window.width / 2 + @width / 2, @spacer + Widget.vertical_margin, # TOP RIGHT
|
||||
window.width / 2 + @width / 2 - @slant, @spacer + Widget.vertical_margin + @height, # BOTTOM RIGHT
|
||||
window.width / 2 - @width / 2 + @slant, @spacer + Widget.vertical_margin + @height, # BOTTOM LEFT
|
||||
@color
|
||||
)
|
||||
|
||||
@@ -31,10 +31,10 @@ class IMICFPS
|
||||
|
||||
# Current Health
|
||||
fill_quad(
|
||||
window.width / 2 - @width / 2, @spacer + Widget.margin, # TOP LEFT
|
||||
(window.width / 2 - @width / 2) + @width * @health, @spacer + Widget.margin, # TOP RIGHT
|
||||
bottom_right, @spacer + Widget.margin + @height, # BOTTOM RIGHT
|
||||
window.width / 2 - @width / 2 + @slant, @spacer + Widget.margin + @height, # BOTTOM LEFT
|
||||
window.width / 2 - @width / 2, @spacer + Widget.vertical_margin, # TOP LEFT
|
||||
(window.width / 2 - @width / 2) + @width * @health, @spacer + Widget.vertical_margin, # TOP RIGHT
|
||||
bottom_right, @spacer + Widget.vertical_margin + @height, # BOTTOM RIGHT
|
||||
window.width / 2 - @width / 2 + @slant, @spacer + Widget.vertical_margin + @height, # BOTTOM LEFT
|
||||
@shield
|
||||
)
|
||||
end
|
||||
@@ -43,7 +43,7 @@ class IMICFPS
|
||||
percentage = (@health * 100).round.to_s.rjust(3, "0")
|
||||
@text.text = "[Health #{percentage}%]"
|
||||
@text.x = window.width / 2 - @text.width / 2
|
||||
@text.y = @spacer + Widget.margin + @height / 2 - @text.height / 2
|
||||
@text.y = @spacer + Widget.vertical_margin + @height / 2 - @text.height / 2
|
||||
|
||||
@health += 0.1 * window.dt
|
||||
@health = 0 if @health > 1.0
|
||||
|
||||
@@ -14,34 +14,39 @@ class IMICFPS
|
||||
|
||||
@text = Text.new("RADAR", size: 18, font: MONOSPACE_FONT, border: true, border_color: Gosu::Color::BLACK)
|
||||
@image = Gosu::Image.new("#{CYBERARM_ENGINE_ROOT_PATH}/assets/textures/default.png", retro: true)
|
||||
@scale = (@size - Widget.padding * 2.0) / @image.width
|
||||
@scale = (@size - Widget.horizontal_padding * 2.0) / @image.width
|
||||
end
|
||||
|
||||
def draw
|
||||
Gosu.draw_rect(
|
||||
Widget.margin, window.height - (@size + Widget.margin),
|
||||
Widget.horizontal_margin, window.height - (@size + Widget.vertical_margin),
|
||||
@size, @size,
|
||||
@border_color
|
||||
)
|
||||
|
||||
Gosu.draw_rect(
|
||||
Widget.margin + Widget.padding, window.height - (@size + Widget.margin) + Widget.padding,
|
||||
@size - Widget.padding * 2, @size - Widget.padding * 2,
|
||||
Widget.horizontal_margin + Widget.horizontal_padding,
|
||||
window.height - (@size + Widget.vertical_margin) + Widget.vertical_padding,
|
||||
@size - Widget.horizontal_padding * 2, @size - Widget.horizontal_padding * 2,
|
||||
@radar_color
|
||||
)
|
||||
|
||||
@image.draw(Widget.margin + Widget.padding, window.height - (@size + Widget.margin) + Widget.padding, 46, @scale, @scale, 0x88ffffff)
|
||||
@image.draw(
|
||||
Widget.horizontal_margin + Widget.horizontal_padding,
|
||||
window.height - (@size + Widget.vertical_margin) + Widget.vertical_padding,
|
||||
46, @scale, @scale, 0x88ffffff
|
||||
)
|
||||
|
||||
@text.draw
|
||||
end
|
||||
|
||||
def update
|
||||
@size = (window.width / @target_screen_width.to_f * @max_size).clamp(@min_size, @max_size)
|
||||
@scale = (@size - Widget.padding * 2.0) / @image.width
|
||||
@scale = (@size - Widget.horizontal_padding * 2.0) / @image.width
|
||||
|
||||
@text.text = "X: #{@player.position.x.round(1)} Y: #{@player.position.y.round(1)} Z: #{@player.position.z.round(1)}"
|
||||
@text.x = Widget.margin + @size / 2 - @text.width / 2
|
||||
@text.y = window.height - (Widget.margin + @size + @text.height)
|
||||
@text.x = Widget.horizontal_margin + @size / 2 - @text.width / 2
|
||||
@text.y = window.height - (Widget.vertical_margin + @size + @text.height)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class IMICFPS
|
||||
@text = CyberarmEngine::Text.new(
|
||||
"",
|
||||
size: 16,
|
||||
x: Widget.margin, y: Widget.margin, z: 45,
|
||||
x: Widget.horizontal_margin, y: Widget.vertical_margin, z: 45,
|
||||
border: true,
|
||||
border_color: Gosu::Color::BLACK,
|
||||
font: BOLD_SANS_FONT
|
||||
@@ -23,7 +23,7 @@ class IMICFPS
|
||||
end
|
||||
|
||||
def update
|
||||
@text.x = window.width - (@text.markup_width + Widget.margin)
|
||||
@text.x = window.width - (@text.markup_width + Widget.horizontal_margin)
|
||||
end
|
||||
|
||||
def generate_random_data
|
||||
|
||||
@@ -28,8 +28,8 @@ class IMICFPS
|
||||
def update
|
||||
@size = (window.width / @target_screen_width.to_f * @max_size).clamp(@min_size, @max_size)
|
||||
|
||||
@text.x = Widget.margin + @size + Widget.padding
|
||||
@text.y = window.height - (Widget.margin + @text.height)
|
||||
@text.x = Widget.horizontal_margin + @size + Widget.horizontal_padding
|
||||
@text.y = window.height - (Widget.vertical_margin + @text.height)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user