WIP changes sync

This commit is contained in:
2021-03-22 22:11:11 -05:00
parent 5759055838
commit c848a11c12
6 changed files with 110 additions and 103 deletions

View File

@@ -1,11 +1,11 @@
GIT
remote: https://github.com/cyberarm/cyberarm_engine
revision: d02c001989ce967e2b3184d1a0f01cd5b20ac241
revision: 20970e5aa9fbcad6d4bf7d9b56cbd06ba5c53275
specs:
cyberarm_engine (0.14.0)
clipboard (~> 1.3.4)
excon (~> 0.76.0)
gosu (~> 0.15.0)
cyberarm_engine (0.17.1)
clipboard (~> 1.3.5)
excon (~> 0.78.0)
gosu (~> 1.1)
gosu_more_drawables (~> 0.3)
GIT
@@ -22,21 +22,23 @@ GEM
remote: https://rubygems.org/
specs:
clipboard (1.3.5)
concurrent-ruby (1.1.7)
concurrent-ruby (1.1.8)
cri (2.1.0)
excon (0.76.0)
gosu (0.15.2)
gosu (0.15.2-x64-mingw32)
excon (0.78.1)
gosu (1.1.0)
gosu_more_drawables (0.3.1)
i18n (1.8.5)
i18n (1.8.8)
concurrent-ruby (~> 1.0)
mini_portile2 (2.5.0)
nokogiri (1.11.0.rc3)
nokogiri (1.11.1)
mini_portile2 (~> 2.5.0)
nokogiri (1.11.0.rc3-x64-mingw32)
racc (~> 1.4)
nokogiri (1.11.1-x64-mingw32)
racc (~> 1.4)
ocra (1.3.11)
opengl-bindings (1.6.10)
rake (13.0.1)
racc (1.5.2)
rake (13.0.3)
rubyzip (2.3.0)
PLATFORMS
@@ -55,4 +57,4 @@ DEPENDENCIES
rubyzip
BUNDLED WITH
2.1.4
2.2.3

View File

@@ -65,22 +65,22 @@ class IMICFPS
def update
position_camera
if @mouse_captured
delta = Float(@true_mouse.x - mouse_x) / (@mouse_sensitivity * @camera.field_of_view) * 70
@camera.orientation.y -= delta
@camera.orientation.y %= 360.0
return unless @mouse_captured
@camera.orientation.x -= Float(@true_mouse.y - window.mouse_y) / (@mouse_sensitivity * @camera.field_of_view) * 70
@camera.orientation.x = @camera.orientation.x.clamp(-90.0, 90.0)
delta = Float(@true_mouse.x - mouse_x) / (@mouse_sensitivity * @camera.field_of_view) * 70
@camera.orientation.y -= delta
@camera.orientation.y %= 360.0
@entity.orientation.y += delta
@entity.orientation.y %= 360.0
@camera.orientation.x -= Float(@true_mouse.y - window.mouse_y) / (@mouse_sensitivity * @camera.field_of_view) * 70
@camera.orientation.x = @camera.orientation.x.clamp(-90.0, 90.0)
window.mouse_x = window.width / 2 if window.mouse_x <= 1 || window.mouse_x >= window.width - 1
window.mouse_y = window.height / 2 if window.mouse_y <= 1 || window.mouse_y >= window.height - 1
@true_mouse.x = window.mouse_x
@true_mouse.y = window.mouse_y
end
@entity.orientation.y += delta
@entity.orientation.y %= 360.0
window.mouse_x = window.width / 2 if window.mouse_x <= 1 || window.mouse_x >= window.width - 1
window.mouse_y = window.height / 2 if window.mouse_y <= 1 || window.mouse_y >= window.height - 1
@true_mouse.x = window.mouse_x
@true_mouse.y = window.mouse_y
end
def button_down(id)

View File

@@ -10,6 +10,7 @@ class IMICFPS
@score_board = ScoreBoardWidget.new({ player: player })
@squad = SquadWidget.new({ player: player })
@crosshair = CrosshairWidget.new({ player: player })
@chat = ChatWidget.new({ player: player })
@hud_elements = [
@ammo,
@@ -18,6 +19,7 @@ class IMICFPS
@chat_history,
@score_board,
@squad,
@chat,
@crosshair
]

45
lib/hud/widgets/chat.rb Normal file
View File

@@ -0,0 +1,45 @@
# frozen_string_literal: true
class IMICFPS
class HUD
class ChatWidget < HUD::Widget
def setup
@text = Text.new("", size: 28, mode: :add, font: SANS_FONT)
@background = Gosu::Color.new(0x88c64600)
end
def draw
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,
@background
)
@text.draw
end
def update
# NOTE: Account for Y in QWERTZ layout
text = window.text_input&.text
if window.text_input.nil? && (Gosu.button_down?(Gosu::KbT) || Gosu.button_down?(Gosu::KbY) || Gosu.button_down?(Gosu::KbU))
window.text_input = Gosu::TextInput.new
@deliver_to = :all if Gosu.button_down?(Gosu::KbT)
@deliver_to = :team if Gosu.button_down?(Gosu::KbY)
@deliver_to = :squad if Gosu.button_down?(Gosu::KbU)
end
if window.text_input && (Gosu.button_down?(Gosu::KbEnter) || Gosu.button_down?(Gosu::KbReturn))
window.text_input = nil
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)
end
end
end
end

View File

@@ -12,7 +12,7 @@ class IMICFPS
@last_changed_time = Gosu.milliseconds
@change_interval = 1_500
@colors = [0xffffffff, 0xaaffffff, 0x88ffffff, 0x22ffffff]
@color = 0xaaffffff
end
def draw
@@ -25,14 +25,6 @@ class IMICFPS
@color
)
end
def update
if Gosu.milliseconds - @last_changed_time >= @change_interval
@last_changed_time = Gosu.milliseconds
@color = @colors.sample
end
end
end
end
end

View File

@@ -30,10 +30,42 @@ class IMICFPS
theme(
{
Label:
TextBlock:
{
font: SANS_FONT
},
Title: {
font: BOLD_SANS_FONT,
text_size: 100,
color: Gosu::Color::BLACK,
text_align: :center,
width: 1.0
},
Subtitle: {
text_size: 50,
color: Gosu::Color::WHITE,
text_align: :center,
width: 1.0
},
Link: {
font: BOLD_SANS_FONT,
text_size: 50,
text_align: :center,
text_shadow: true,
text_shadow_size: 2,
text_shadow_color: Gosu::Color::BLACK,
text_shadow_alpha: 100,
color: Gosu::Color.rgb(0, 127, 127),
width: 1.0,
hover: {
color: Gosu::Color.rgb(64, 128, 255),
border_thickness: 2,
border_color: Gosu::Color::BLACK,
},
active: {
color: Gosu::Color.rgb(64, 128, 255),
}
},
Button:
{
font: BOLD_SANS_FONT,
@@ -58,21 +90,6 @@ class IMICFPS
)
end
def title(text, color = Gosu::Color::BLACK)
@elements << Text.new(text, color: color, size: 100, x: 0, y: 15, font: BOLD_SANS_FONT)
@_title = @elements.last
end
def subtitle(text, color = Gosu::Color::WHITE)
@elements << Text.new(text, color: color, size: 50, x: 0, y: 100, font: SANS_FONT)
@_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), font: BOLD_SANS_FONT)
@elements << Link.new(text, self, block)
end
def draw
menu_background(@primary_color, @accent_color, @bar_color_step, @bar_alpha, @bar_size, @bar_slope)
draw_menu_box
@@ -133,56 +150,5 @@ class IMICFPS
mouse_x.between?(object.x, object.x + object.width) &&
mouse_y.between?(object.y, object.y + object.height)
end
class Link
attr_reader :text, :block
def initialize(text, host, block)
@text = text
@host = host
@block = block
@color = @text.color
@hover_color = Gosu::Color.rgb(64, 128, 255)
@text.shadow_color = Gosu::Color::BLACK
@text.shadow_size = 2
@text.shadow_alpha = 100
end
def update
@text.color = if @host.mouse_over?(self)
@hover_color
else
@color
end
end
def x
text.x
end
def x=(n)
text.x = n
end
def y
text.y
end
def width
text.width
end
def height
text.height
end
def draw
text.draw
end
def clicked
@block&.call
end
end
end
end