Tweaked ui a bit, updated Credits, stubbed load menu, fixed crash when stopping helicopter, Stop order is now only emitted if player has entities selected.

This commit is contained in:
2021-01-04 09:33:07 -06:00
parent f3fccc8b24
commit 7087316347
18 changed files with 93 additions and 56 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
data/settings.json
data/replays/*.replay
data/saves/*.save
doc/
.yardoc/

0
data/replays/.gitkeep Normal file
View File

0
data/saves/.gitkeep Normal file
View File

View File

@@ -19,6 +19,7 @@ require_relative "lib/window"
require_relative "lib/camera"
require_relative "lib/setting"
require_relative "lib/team_colors"
require_relative "lib/constants"
require_relative "lib/states/boot"
require_relative "lib/states/game"
@@ -27,7 +28,7 @@ require_relative "lib/states/menus/main_menu"
require_relative "lib/states/menus/credits_menu"
require_relative "lib/states/menus/settings_menu"
require_relative "lib/states/menus/pause_menu"
require_relative "lib/states/menus/solo_play_menu"
require_relative "lib/states/menus/load_menu"
require_relative "lib/states/menus/multiplayer_menu"
require_relative "lib/states/menus/solo_lobby_menu"
require_relative "lib/states/menus/multiplayer_lobby_menu"

View File

@@ -10,6 +10,8 @@ class IMICRTS
follow_path
else
return unless @parent.target
rotate_towards(@parent.target)
@parent.position -= (@parent.position.xy - @parent.target.xy).normalized * @parent.speed
end

4
lib/constants.rb Normal file
View File

@@ -0,0 +1,4 @@
class IMICRTS
MENU_WIDTH = 350
MENU_PADDING = 8
end

View File

@@ -99,7 +99,7 @@ class IMICRTS
def target=(entity)
@target = entity
component(:movement).pathfinder = @director.find_path(player: @player, entity: self, goal: @target) if component(:movement) && @movement == :ground
component(:movement).pathfinder = @director.find_path(player: @player, entity: self, goal: @target) if @target && component(:movement) && @movement == :ground
end
def hit?(x_or_vector, y = nil)

View File

@@ -34,7 +34,7 @@ class IMICRTS
@debug_info = CyberarmEngine::Text.new("", y: 10, z: Float::INFINITY, shadow_color: Gosu::Color.rgba(0, 0, 0, 200))
@sidebar = stack(width: 350, height: 1.0) do
@sidebar = stack(width: IMICRTS::MENU_WIDTH, height: 1.0, padding: IMICRTS::MENU_PADDING) do
background [0x55555555, 0x55666666]
label "SIDEBAR", text_size: 78, margin_bottom: 20

View File

@@ -3,14 +3,29 @@ class IMICRTS
def setup
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
stack(width: 600, height: 1.0) do
background [0xff555555, Gosu::Color::GRAY]
flow(width: 1.0, height: 1.0) do
stack(width: IMICRTS::MENU_WIDTH, height: 1.0, padding: IMICRTS::MENU_PADDING) do
background [0xff555555, Gosu::Color::GRAY]
label "About I-MIC-RTS", text_size: 78, margin: 20
label "Words go here. More words also go here. Thank you and have a nice day.", text_wrap: :word_wrap
label "Credits", text_size: 78, margin: 20
button("Back", width: 1.0, margin_top: 20) do
push_state(MainMenu)
licenses = Gosu::LICENSES.lines
preamble = licenses.shift
licenses.shift # remove blank line
label preamble, text_wrap: :word_wrap
licenses.each do |l|
name, website, license, license_website = l.strip.split(",")
flow(width: 1.0) do
label name.strip, width: 0.49
label license.strip, width: 0.49
end
end
button("Back", width: 1.0, margin_top: 20) do
push_state(MainMenu)
end
end
end
end

View File

@@ -0,0 +1,32 @@
class IMICRTS
class LoadMenu < CyberarmEngine::GuiState
def setup
self.show_cursor = true
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
stack(width: IMICRTS::MENU_WIDTH, height: 1.0, padding: IMICRTS::MENU_PADDING) do
background [0xff555555, Gosu::Color::GRAY]
label "Load", text_size: 78, margin: 20
label "Replays"
stack(width: 1.0, height: 0.30) do
["2020-01-31_16-31-45.replay"].each do |item|
button item, width: 1.0
end
end
label "Saves"
stack(width: 1.0, height: 0.30) do
["2020-01-31_16-31-45.save"].each do |item|
button item, width: 1.0
end
end
button("Back", width: 1.0, margin_top: 20) do
pop_state
end
end
end
end
end

View File

@@ -5,10 +5,11 @@ class IMICRTS
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
stack(width: 350, height: 1.0) do
stack(width: IMICRTS::MENU_WIDTH, height: 1.0, padding: IMICRTS::MENU_PADDING) do
background [0xff555555, Gosu::Color::GRAY]
label "I-MIC-RTS", text_size: 78, margin: 20
button("Campaign", width: 1.0) do
label IMICRTS::NAME, text_size: 78, margin: 20
button("Campaign", width: 1.0, enabled: false) do
push_state(CampaignMenu)
end
button("Skirmish", width: 1.0) do
@@ -20,7 +21,11 @@ class IMICRTS
push_state(MultiplayerMenu)
end
button("Settings", width: 1.0, margin_top: 20) do
button("Load", width: 1.0, margin_top: 20) do
push_state(LoadMenu)
end
button("Settings", width: 1.0) do
push_state(SettingsMenu)
end

View File

@@ -3,7 +3,7 @@ class IMICRTS
def setup
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
stack(height: 1.0) do
stack(width: IMICRTS::MENU_WIDTH, height: 1.0, padding: IMICRTS::MENU_PADDING) do
background [0xff555555, Gosu::Color::GRAY]
label "Multiplayer", text_size: 78, margin: 20

View File

@@ -1,14 +1,19 @@
class IMICRTS
class PauseMenu < CyberarmEngine::GuiState
def setup
stack(width: 350) do
stack(width: IMICRTS::MENU_WIDTH, height: 1.0, padding: IMICRTS::MENU_PADDING) do
background [0xff555555, Gosu::Color::GRAY]
label "Paused", text_size: 78, margin: 20
button "Resume", width: 1.0 do
pop_state
end
button "Settings", width: 1.0 do
push_state(SettingsMenu)
end
button "Quit", width: 1.0 do
button "Quit", width: 1.0, margin_top: 20 do
# TODO: Confirm
previous_state.director.finalize
@@ -25,7 +30,7 @@ class IMICRTS
def draw
previous_state&.draw
# Gosu.flush
Gosu.flush
super
end

View File

@@ -3,22 +3,18 @@ class IMICRTS
def setup
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
stack(width: 350, height: 1.0) do
stack(width: IMICRTS::MENU_WIDTH, height: 1.0, padding: IMICRTS::MENU_PADDING) do
background [0xff555555, Gosu::Color::GRAY]
label "Settings", text_size: 78, margin: 20
@skip_intro = check_box "Skip Intro", checked: Setting.enabled?(:skip_intro)
stack(width: 1.0) do
background 0xff030303
label "Debug Settings"
@debug_mode = check_box "Debug Mode", checked: Setting.enabled?(:debug_mode)
@debug_info_bar = check_box "Show Debug Info Bar", checked: Setting.enabled?(:debug_info_bar)
@debug_pathfinding = check_box "Debug Pathfinding", checked: Setting.enabled?(:debug_pathfinding)
@debug_pathfinding_allow_diagonal = check_box "Allow Diagonal Paths", checked: Setting.enabled?(:debug_pathfinding_allow_diagonal)
end
label "Debug Settings", background: 0xff030303, width: 1.0, margin_top: 20
@debug_mode = check_box "Debug Mode", checked: Setting.enabled?(:debug_mode)
@debug_info_bar = check_box "Show Debug Info Bar", checked: Setting.enabled?(:debug_info_bar)
@debug_pathfinding = check_box "Debug Pathfinding", checked: Setting.enabled?(:debug_pathfinding)
@debug_pathfinding_allow_diagonal = check_box "Allow Diagonal Paths", checked: Setting.enabled?(:debug_pathfinding_allow_diagonal)
button("Save and Close", width: 1.0, margin_top: 20) do
if valid_options?

View File

@@ -3,7 +3,7 @@ class IMICRTS
def setup
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
stack(width: 0.5, min_width: 720, height: 1.0) do
stack(width: 0.5, min_width: 720, height: 1.0, padding: IMICRTS::MENU_PADDING) do
background [0xff555555, Gosu::Color::GRAY]
label "Lobby", text_size: 78, margin: 20

View File

@@ -1,25 +0,0 @@
class IMICRTS
class SoloPlayMenu < CyberarmEngine::GuiState
def setup
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
stack(height: 1.0) do
background [0xff555555, Gosu::Color::GRAY]
label "Solo Play", text_size: 78, margin: 20
label "Words go here.\nMore words also go here. Thank you and have a nice day."
button("Campaign", width: 1.0) do
end
button("Skirmish", width: 1.0) do
push_state(SoloLobbyMenu)
end
button("Back", width: 1.0, margin_top: 20) do
push_state(MainMenu)
end
end
end
end
end

View File

@@ -36,7 +36,7 @@ class IMICRTS
)
when Gosu::KB_S
@director.schedule_order(Order::STOP, @player.id)
@director.schedule_order(Order::STOP, @player.id) if @player.selected_entities.size.positive?
when Gosu::MS_LEFT
unless @game.sidebar.hit?(@game.window.mouse_x, @game.window.mouse_y)

View File

@@ -22,9 +22,9 @@ class IMICRTS
end
def draw
@cursor.draw(mouse_x, mouse_y, Float::INFINITY) if @show_cursor
super
@cursor.draw(mouse_x, mouse_y, Float::INFINITY) if @show_cursor
end
def update