mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-16 00:02:33 +00:00
Added pause menu, refreshed solo lobby menu, added settings for storing player's color and team, misc.
This commit is contained in:
@@ -3,11 +3,11 @@ class IMICRTS
|
||||
def setup
|
||||
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
|
||||
|
||||
stack(height: 1.0) do
|
||||
stack(width: 600, height: 1.0) do
|
||||
background [0xff555555, Gosu::Color::GRAY]
|
||||
|
||||
label "About I-MIC-RTS", text_size: 78, margin: 20
|
||||
label "Words go here.\nMore words also go here. Thank you and have a nice day."
|
||||
label "Words go here. More words also go here. Thank you and have a nice day.", text_wrap: :word_wrap
|
||||
|
||||
button("Back", width: 1.0, margin_top: 20) do
|
||||
push_state(MainMenu)
|
||||
|
||||
@@ -5,10 +5,13 @@ class IMICRTS
|
||||
|
||||
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
|
||||
|
||||
stack(height: 1.0) do
|
||||
stack(width: 350, height: 1.0) do
|
||||
background [0xff555555, Gosu::Color::GRAY]
|
||||
label "I-MIC-RTS", text_size: 78, margin: 20
|
||||
button("Solo Play", width: 1.0) do
|
||||
button("Campaign", width: 1.0) do
|
||||
end
|
||||
|
||||
button("Skirmish", width: 1.0) do
|
||||
# push_state(SoloPlayMenu)
|
||||
push_state(SoloLobbyMenu)
|
||||
end
|
||||
|
||||
@@ -14,8 +14,12 @@ class IMICRTS
|
||||
button("Refresh") do
|
||||
refresh_games
|
||||
end
|
||||
button("Host Game")
|
||||
button("Join Game")
|
||||
button("Host Game") do
|
||||
push_state(HostMultiplayerGameMenu)
|
||||
end
|
||||
button("Join Game") do
|
||||
push_state(MultiplayerLobbyMenu)
|
||||
end
|
||||
end
|
||||
|
||||
button("Back", width: 1.0, margin_top: 20) do
|
||||
|
||||
39
lib/states/menus/pause_menu.rb
Normal file
39
lib/states/menus/pause_menu.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
class IMICRTS
|
||||
class PauseMenu < CyberarmEngine::GuiState
|
||||
def setup
|
||||
stack(width: 350) do
|
||||
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
|
||||
# TODO: Confirm
|
||||
|
||||
previous_state.director.finalize
|
||||
|
||||
if previous_state&.director.local_game?
|
||||
push_state(SoloLobbyMenu)
|
||||
else
|
||||
push_state(MultiplayerLobbyMenu)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def draw
|
||||
previous_state&.draw
|
||||
|
||||
# Gosu.flush
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
|
||||
previous_state&.director.update unless previous_state&.director.local_game?
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,7 +3,7 @@ class IMICRTS
|
||||
def setup
|
||||
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
|
||||
|
||||
stack(height: 1.0) do
|
||||
stack(width: 350, height: 1.0) do
|
||||
background [0xff555555, Gosu::Color::GRAY]
|
||||
|
||||
label "Settings", text_size: 78, margin: 20
|
||||
@@ -24,12 +24,12 @@ class IMICRTS
|
||||
if valid_options?
|
||||
save_settings
|
||||
|
||||
push_state(MainMenu)
|
||||
pop_state
|
||||
end
|
||||
end
|
||||
|
||||
button("Back", width: 1.0, margin_top: 20) do
|
||||
push_state(MainMenu)
|
||||
pop_state
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,40 +3,67 @@ class IMICRTS
|
||||
def setup
|
||||
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
|
||||
|
||||
stack(height: 1.0) do
|
||||
stack(width: 0.5, min_width: 720, height: 1.0) do
|
||||
background [0xff555555, Gosu::Color::GRAY]
|
||||
|
||||
label "Lobby", text_size: 78, margin: 20
|
||||
stack do
|
||||
flow do
|
||||
flow(width: 1.0, height: 0.8) do
|
||||
flow(width: 0.70, height: 1.0) do
|
||||
stack(width: 0.40) do
|
||||
label "Name"
|
||||
@player_name = edit_line Setting.get(:player_name), width: 1.0
|
||||
|
||||
elements = [:edit_line, :button, :button, :toggle_button]
|
||||
["Players", "Color", "Team", "Map Preview"].each_with_index do |item, index|
|
||||
stack do
|
||||
label item, background: 0xff7a0d71
|
||||
7.times do |i|
|
||||
list_box items: [:open, :closed, :easy, :hard, :brutal], width: 1.0
|
||||
end
|
||||
end
|
||||
|
||||
stack do
|
||||
case elements[index]
|
||||
when :edit_line
|
||||
@player_name = edit_line Setting.get(:player_name)
|
||||
when :button
|
||||
button item
|
||||
when :toggle_button
|
||||
toggle_button
|
||||
end
|
||||
stack(width: 0.29) do
|
||||
label "Color"
|
||||
@player_color = list_box items: TeamColors.keys, choose: Setting.get(:player_color).to_sym, width: 1.0
|
||||
@player_color.style.background = (TeamColors[@player_color.value.to_sym])
|
||||
@player_color.subscribe(:changed) do |sender, value|
|
||||
@player_color.style.background = TeamColors[value.to_sym]
|
||||
:handled
|
||||
end
|
||||
|
||||
7.times do |i|
|
||||
box = list_box items: TeamColors.keys, choose: TeamColors.keys[i + 1], width: 1.0
|
||||
box.style.background = (TeamColors[box.value.to_sym])
|
||||
box.subscribe(:changed) do |sender, value|
|
||||
box.style.background = TeamColors[value.to_sym]
|
||||
:handled
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
stack(width: 0.29) do
|
||||
label "Team"
|
||||
@player_team = list_box items: Array(1..8), choose: Setting.get(:player_team), width: 1.0
|
||||
|
||||
7.times do |i|
|
||||
list_box items: Array(1..8), choose: i + 2, width: 1.0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
stack(height: 100) do
|
||||
stack(width: 0.30, height: 1.0) do
|
||||
# TODO: Show preview image
|
||||
label "Map"
|
||||
@map_name = list_box items: [:test_map], choose: :test_map, width: 1.0
|
||||
image "#{GAME_ROOT_PATH}/assets/logo.png", width: 1.0
|
||||
end
|
||||
end
|
||||
|
||||
flow(width: 1.0) do
|
||||
button("Accept", width: 0.5) do
|
||||
flow(width: 1.0, height: 0.2) do
|
||||
button("Accept") do
|
||||
save_playerdata
|
||||
push_state(Game, networking_mode: :virtual)
|
||||
map = Map.new(map_file: "maps/#{@map_name.value}.tmx")
|
||||
players = [
|
||||
{ id: 0, team: @player_team.value.to_i, spawnpoint: map.spawnpoints.last, color: @player_color.value.to_sym },
|
||||
{ id: 1, team: 2, spawnpoint: map.spawnpoints.first, color: :lightblue }
|
||||
]
|
||||
push_state(Game, networking_mode: :virtual, map: map, players: players)
|
||||
end
|
||||
|
||||
button("Back", align: :right) do
|
||||
@@ -49,6 +76,8 @@ class IMICRTS
|
||||
|
||||
def save_playerdata
|
||||
Setting.set(:player_name, @player_name.value)
|
||||
Setting.set(:player_color, @player_color.value.to_sym)
|
||||
Setting.set(:player_team, @player_team.value.to_i)
|
||||
|
||||
Setting.save!
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user