mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
WIP changes sync
This commit is contained in:
30
Gemfile.lock
30
Gemfile.lock
@@ -1,11 +1,11 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: https://github.com/cyberarm/cyberarm_engine
|
remote: https://github.com/cyberarm/cyberarm_engine
|
||||||
revision: d02c001989ce967e2b3184d1a0f01cd5b20ac241
|
revision: 20970e5aa9fbcad6d4bf7d9b56cbd06ba5c53275
|
||||||
specs:
|
specs:
|
||||||
cyberarm_engine (0.14.0)
|
cyberarm_engine (0.17.1)
|
||||||
clipboard (~> 1.3.4)
|
clipboard (~> 1.3.5)
|
||||||
excon (~> 0.76.0)
|
excon (~> 0.78.0)
|
||||||
gosu (~> 0.15.0)
|
gosu (~> 1.1)
|
||||||
gosu_more_drawables (~> 0.3)
|
gosu_more_drawables (~> 0.3)
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
@@ -22,21 +22,23 @@ GEM
|
|||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
clipboard (1.3.5)
|
clipboard (1.3.5)
|
||||||
concurrent-ruby (1.1.7)
|
concurrent-ruby (1.1.8)
|
||||||
cri (2.1.0)
|
cri (2.1.0)
|
||||||
excon (0.76.0)
|
excon (0.78.1)
|
||||||
gosu (0.15.2)
|
gosu (1.1.0)
|
||||||
gosu (0.15.2-x64-mingw32)
|
|
||||||
gosu_more_drawables (0.3.1)
|
gosu_more_drawables (0.3.1)
|
||||||
i18n (1.8.5)
|
i18n (1.8.8)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
mini_portile2 (2.5.0)
|
mini_portile2 (2.5.0)
|
||||||
nokogiri (1.11.0.rc3)
|
nokogiri (1.11.1)
|
||||||
mini_portile2 (~> 2.5.0)
|
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)
|
ocra (1.3.11)
|
||||||
opengl-bindings (1.6.10)
|
opengl-bindings (1.6.10)
|
||||||
rake (13.0.1)
|
racc (1.5.2)
|
||||||
|
rake (13.0.3)
|
||||||
rubyzip (2.3.0)
|
rubyzip (2.3.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
@@ -55,4 +57,4 @@ DEPENDENCIES
|
|||||||
rubyzip
|
rubyzip
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.1.4
|
2.2.3
|
||||||
|
|||||||
@@ -65,22 +65,22 @@ class IMICFPS
|
|||||||
def update
|
def update
|
||||||
position_camera
|
position_camera
|
||||||
|
|
||||||
if @mouse_captured
|
return unless @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
|
|
||||||
|
|
||||||
@camera.orientation.x -= Float(@true_mouse.y - window.mouse_y) / (@mouse_sensitivity * @camera.field_of_view) * 70
|
delta = Float(@true_mouse.x - mouse_x) / (@mouse_sensitivity * @camera.field_of_view) * 70
|
||||||
@camera.orientation.x = @camera.orientation.x.clamp(-90.0, 90.0)
|
@camera.orientation.y -= delta
|
||||||
|
@camera.orientation.y %= 360.0
|
||||||
|
|
||||||
@entity.orientation.y += delta
|
@camera.orientation.x -= Float(@true_mouse.y - window.mouse_y) / (@mouse_sensitivity * @camera.field_of_view) * 70
|
||||||
@entity.orientation.y %= 360.0
|
@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
|
@entity.orientation.y += delta
|
||||||
window.mouse_y = window.height / 2 if window.mouse_y <= 1 || window.mouse_y >= window.height - 1
|
@entity.orientation.y %= 360.0
|
||||||
@true_mouse.x = window.mouse_x
|
|
||||||
@true_mouse.y = window.mouse_y
|
window.mouse_x = window.width / 2 if window.mouse_x <= 1 || window.mouse_x >= window.width - 1
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def button_down(id)
|
def button_down(id)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class IMICFPS
|
|||||||
@score_board = ScoreBoardWidget.new({ player: player })
|
@score_board = ScoreBoardWidget.new({ player: player })
|
||||||
@squad = SquadWidget.new({ player: player })
|
@squad = SquadWidget.new({ player: player })
|
||||||
@crosshair = CrosshairWidget.new({ player: player })
|
@crosshair = CrosshairWidget.new({ player: player })
|
||||||
|
@chat = ChatWidget.new({ player: player })
|
||||||
|
|
||||||
@hud_elements = [
|
@hud_elements = [
|
||||||
@ammo,
|
@ammo,
|
||||||
@@ -18,6 +19,7 @@ class IMICFPS
|
|||||||
@chat_history,
|
@chat_history,
|
||||||
@score_board,
|
@score_board,
|
||||||
@squad,
|
@squad,
|
||||||
|
@chat,
|
||||||
|
|
||||||
@crosshair
|
@crosshair
|
||||||
]
|
]
|
||||||
|
|||||||
45
lib/hud/widgets/chat.rb
Normal file
45
lib/hud/widgets/chat.rb
Normal 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
|
||||||
@@ -12,7 +12,7 @@ class IMICFPS
|
|||||||
@last_changed_time = Gosu.milliseconds
|
@last_changed_time = Gosu.milliseconds
|
||||||
@change_interval = 1_500
|
@change_interval = 1_500
|
||||||
|
|
||||||
@colors = [0xffffffff, 0xaaffffff, 0x88ffffff, 0x22ffffff]
|
@color = 0xaaffffff
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
@@ -25,14 +25,6 @@ class IMICFPS
|
|||||||
@color
|
@color
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
|
||||||
if Gosu.milliseconds - @last_changed_time >= @change_interval
|
|
||||||
@last_changed_time = Gosu.milliseconds
|
|
||||||
|
|
||||||
@color = @colors.sample
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
100
lib/ui/menu.rb
100
lib/ui/menu.rb
@@ -30,10 +30,42 @@ class IMICFPS
|
|||||||
|
|
||||||
theme(
|
theme(
|
||||||
{
|
{
|
||||||
Label:
|
TextBlock:
|
||||||
{
|
{
|
||||||
font: SANS_FONT
|
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:
|
Button:
|
||||||
{
|
{
|
||||||
font: BOLD_SANS_FONT,
|
font: BOLD_SANS_FONT,
|
||||||
@@ -58,21 +90,6 @@ class IMICFPS
|
|||||||
)
|
)
|
||||||
end
|
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
|
def draw
|
||||||
menu_background(@primary_color, @accent_color, @bar_color_step, @bar_alpha, @bar_size, @bar_slope)
|
menu_background(@primary_color, @accent_color, @bar_color_step, @bar_alpha, @bar_size, @bar_slope)
|
||||||
draw_menu_box
|
draw_menu_box
|
||||||
@@ -133,56 +150,5 @@ class IMICFPS
|
|||||||
mouse_x.between?(object.x, object.x + object.width) &&
|
mouse_x.between?(object.x, object.x + object.width) &&
|
||||||
mouse_y.between?(object.y, object.y + object.height)
|
mouse_y.between?(object.y, object.y + object.height)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user