From bac03112635b2db019e70aa5b12cd9917957b144 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Sat, 16 May 2020 08:11:29 -0500 Subject: [PATCH] Added prototype multiplayer lobby --- lib/ui/menus/main_menu.rb | 3 +- lib/ui/menus/multiplayer_lobby_menu.rb | 82 ++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 lib/ui/menus/multiplayer_lobby_menu.rb diff --git a/lib/ui/menus/main_menu.rb b/lib/ui/menus/main_menu.rb index 0e1c92e..406ea26 100644 --- a/lib/ui/menus/main_menu.rb +++ b/lib/ui/menus/main_menu.rb @@ -5,11 +5,10 @@ class IMICFPS link "Single Player" do push_state(LevelSelectMenu) - # push_state(LoadingState.new(forward: Game, map_file: GAME_ROOT_PATH + "/maps/test_map.json")) end link "Multiplayer" do - push_state(MultiplayerMenu) + push_state(MultiplayerLobbyMenu) end link "Settings" do diff --git a/lib/ui/menus/multiplayer_lobby_menu.rb b/lib/ui/menus/multiplayer_lobby_menu.rb new file mode 100644 index 0000000..61647c0 --- /dev/null +++ b/lib/ui/menus/multiplayer_lobby_menu.rb @@ -0,0 +1,82 @@ +class IMICFPS + class MultiplayerLobbyMenu < Menu + def setup + @sample_games = [ + { + host: "Host", + game_type: "Type", + map: "Map", + players: "Players", + ping: "Ping", + source: "Source" + }, + { + host: "localhost:54637", + game_type: "C&C", + map: "Test Map", + players: "0/16", + ping: 48, + source: "LAN" + }, + { + host: "gameserver1.example.com:5637", + game_type: "C&C", + map: "Islands Test Map", + players: "14/64", + ping: 123, + source: "Internet" + } + ] + + label "Multiplayer Lobby", text_size: 100 + flow width: 1.0, height: 1.0 do + stack width: 0.25 do + button "Host Game", width: 1.0 + button "Direct Connect", width: 1.0 + + button "Back", width: 1.0 do + pop_state + end + end + + stack width: 0.5, height: 1.0 do + stack width: 1.0, height: 0.75, border_color: 0xffffffff, border_thickness: 1 do + @sample_games.each_with_index do |game, i| + text_size = 18 + flow width: 1.0 do + background i.even? ? 0x55000000 : 0x55ff5500 + + flow width: 0.1 do + label game[:game_type], text_size: text_size + end + flow width: 0.3 do + label game[:host], text_size: text_size + end + flow width: 0.3 do + label game[:map], text_size: text_size + end + flow width: 0.1 do + label game[:players], text_size: text_size + end + flow width: 0.1 do + label game[:ping], text_size: text_size + end + flow width: 0.1 do + label game[:source], text_size: text_size + end + end + end + end + + flow width: 1.0, height: 0.25 do + label "Name" + name = edit_line "", margin_right: 20 + button "Join", width: 0.25 do + pp name.value + end + end + end + end + end + end +end \ No newline at end of file