diff --git a/i-mic-fps.rb b/i-mic-fps.rb index 6149bd9..4bf1875 100644 --- a/i-mic-fps.rb +++ b/i-mic-fps.rb @@ -58,6 +58,7 @@ require_relative "lib/ui/console" require_relative "lib/ui/menus/main_menu" require_relative "lib/ui/menus/settings_menu" require_relative "lib/ui/menus/extras_menu" +require_relative "lib/ui/menus/multiplayer_menu" require_relative "lib/ui/menus/level_select_menu" require_relative "lib/ui/menus/game_pause_menu" diff --git a/lib/states/game_states/loading_state.rb b/lib/states/game_states/loading_state.rb index 1a0a334..4fe7036 100644 --- a/lib/states/game_states/loading_state.rb +++ b/lib/states/game_states/loading_state.rb @@ -10,7 +10,7 @@ class IMICFPS raise "Unable to load map, missing :map_file or :map_parser" end - title "I-MIC FPS" + title IMICFPS::NAME @subheading = Text.new("Loading Map: #{@map_parser.metadata.name}", y: 100, size: 50, alignment: :center) @description = Text.new("Map created by: #{@map_parser.metadata.authors.join(", ")}\n#{@map_parser.metadata.description}", y: 180, size: 24, alignment: :center) @state = Text.new("Preparing...", y: window.height/2-40, size: 40, alignment: :center) diff --git a/lib/tools/asset_viewer/lib/main_menu.rb b/lib/tools/asset_viewer/lib/main_menu.rb index 0e1f951..3b517f3 100644 --- a/lib/tools/asset_viewer/lib/main_menu.rb +++ b/lib/tools/asset_viewer/lib/main_menu.rb @@ -1,13 +1,9 @@ class IMICFPS class AssetViewerTool - class MainMenu < CyberarmEngine::GuiState - include CommonMethods + class MainMenu < Menu def setup window.needs_cursor = true - label "#{IMICFPS::NAME}", text_size: 50 - label "Asset Viewer", text_size: 28 - @manifests = [] Dir.glob(GAME_ROOT_PATH + "/assets/**/manifest.yaml").each do |manifest| begin @@ -19,24 +15,31 @@ class IMICFPS @manifests.sort_by! { |m| m.name.downcase } - button "Back", margin_bottom: 25 do - pop_state - end + label "#{IMICFPS::NAME}", text_size: 100, color: Gosu::Color::BLACK + label "Asset Viewer", text_size: 50 - flow(margin: 10) do - @manifests.each do |manifest| - button manifest.name do - push_state(TurnTable, manifest: manifest) + flow(width: 1.0, height: 1.0) do + stack(width: 0.25, height: 1.0) do + button "Refresh" do + request_recalculate + end + button "Back", margin_bottom: 25 do + pop_state + end + end + + stack(width: 0.5, height: 1.0) do + flow(width: 1.0, height: 1.0) do + @manifests.each do |manifest| + button manifest.name do + push_state(TurnTable, manifest: manifest) + end + end end end end end - def draw - menu_background(Menu::PRIMARY_COLOR, Menu::ACCENT_COLOR, Menu::BAR_COLOR_STEP, Menu::BAR_ALPHA, Menu::BAR_SIZE, Menu::BAR_SLOPE) - super - end - def update super diff --git a/lib/tools/map_editor/lib/main_menu.rb b/lib/tools/map_editor/lib/main_menu.rb index 7044ddc..0ecdc28 100644 --- a/lib/tools/map_editor/lib/main_menu.rb +++ b/lib/tools/map_editor/lib/main_menu.rb @@ -1,8 +1,6 @@ class IMICFPS class MapEditorTool - class MainMenu < CyberarmEngine::GuiState - include CommonMethods - + class MainMenu < Menu def setup window.needs_cursor = true @@ -37,11 +35,6 @@ class IMICFPS end end - def draw - menu_background(Menu::PRIMARY_COLOR, Menu::ACCENT_COLOR, Menu::BAR_COLOR_STEP, Menu::BAR_ALPHA, Menu::BAR_SIZE, Menu::BAR_SLOPE) - super - end - def update super diff --git a/lib/ui/menu.rb b/lib/ui/menu.rb index 910308c..81c8800 100644 --- a/lib/ui/menu.rb +++ b/lib/ui/menu.rb @@ -1,5 +1,7 @@ class IMICFPS - class Menu < IMICFPS::GameState + class Menu < IMICFPS::GuiState + include CommonMethods + PRIMARY_COLOR = Gosu::Color.rgba(255, 127, 0, 200) ACCENT_COLOR = Gosu::Color.rgba(155, 27, 0, 200) @@ -53,13 +55,15 @@ class IMICFPS window.scene.draw end + + super end def draw_menu_box draw_rect( - window.width/4, 0, - window.width/2, window.height, - Gosu::Color.new(0x22222222), + window.width / 4, 0, + window.width / 2, window.height, + Gosu::Color.new(0x11ffffff), ) end @@ -79,6 +83,8 @@ class IMICFPS window.scene.update(window.dt) end + super + @__version_text.x = window.width - (@__version_text.width + 10) @__version_text.y = window.height - (@__version_text.height + 10) end @@ -92,6 +98,8 @@ class IMICFPS end end end + + super end def mouse_over?(object) diff --git a/lib/ui/menus/extras_menu.rb b/lib/ui/menus/extras_menu.rb index 2f177a6..6b12856 100644 --- a/lib/ui/menus/extras_menu.rb +++ b/lib/ui/menus/extras_menu.rb @@ -1,7 +1,7 @@ class IMICFPS class ExtrasMenu < Menu def setup - title "I-MIC FPS" + title IMICFPS::NAME subtitle "Extras" link "Asset Viewer" do diff --git a/lib/ui/menus/game_pause_menu.rb b/lib/ui/menus/game_pause_menu.rb index 3950989..de3bc7a 100644 --- a/lib/ui/menus/game_pause_menu.rb +++ b/lib/ui/menus/game_pause_menu.rb @@ -1,8 +1,8 @@ class IMICFPS class GamePauseMenu < Menu def setup - @background_alpha = 50 - title "I-MIC FPS" + @bar_alpha = 50 + title IMICFPS::NAME subtitle "Paused" link "Resume" do diff --git a/lib/ui/menus/level_select_menu.rb b/lib/ui/menus/level_select_menu.rb index 7620f48..c614a16 100644 --- a/lib/ui/menus/level_select_menu.rb +++ b/lib/ui/menus/level_select_menu.rb @@ -1,7 +1,7 @@ class IMICFPS class LevelSelectMenu < Menu def setup - title "I-MIC FPS" + title IMICFPS::NAME subtitle "Choose a Map" Dir.glob(GAME_ROOT_PATH + "/maps/*.json").map { |file| [file, MapParser.new(map_file: file)]}.each do |file, map| diff --git a/lib/ui/menus/main_menu.rb b/lib/ui/menus/main_menu.rb index 6e684a6..86172d7 100644 --- a/lib/ui/menus/main_menu.rb +++ b/lib/ui/menus/main_menu.rb @@ -1,13 +1,17 @@ class IMICFPS class MainMenu < Menu def setup - title "I-MIC FPS" + title IMICFPS::NAME 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) + end + link "Settings" do push_state(SettingsMenu) end diff --git a/lib/ui/menus/multiplayer_menu.rb b/lib/ui/menus/multiplayer_menu.rb new file mode 100644 index 0000000..ce7fd4e --- /dev/null +++ b/lib/ui/menus/multiplayer_menu.rb @@ -0,0 +1,14 @@ +class IMICFPS + class MultiplayerMenu < Menu + def setup + title IMICFPS::NAME + subtitle "Multiplayer" + + link "Online" + link "LAN" + link "Back" do + pop_state + end + end + end +end \ No newline at end of file diff --git a/lib/ui/menus/settings_menu.rb b/lib/ui/menus/settings_menu.rb index ab0925b..3b90a67 100644 --- a/lib/ui/menus/settings_menu.rb +++ b/lib/ui/menus/settings_menu.rb @@ -1,14 +1,210 @@ class IMICFPS class SettingsMenu < Menu + include CommonMethods + def setup - title "I-MIC FPS" - subtitle "Settings" + @categories = [ + "Display", + "Graphics", + "Audio", + "Controls", + "Multiplayer" + ] + @pages = {} + @current_page = nil - link "\"There is no spoon.\"" + label "Settings", text_size: 100, color: Gosu::Color::BLACK - link "Back" do - pop_state + flow(width: 1.0, height: 1.0) do + stack(width: 0.25, height: 1.0) do + @categories.each do |category| + button category, width: 1.0 do + show_page(:"#{category}".downcase) + end + end + + button "Back", width: 1.0, margin_top: 64 do + pop_state + end + end + + @categories.each do |category| + stack(width: 0.5, height: 1.0) do |element| + @pages[:"#{category}".downcase] = element + element.hide + + if respond_to?(:"create_page_#{category}".downcase) + self.send(:"create_page_#{category}".downcase) + end + end + end end + + show_page(:display) + end + + def show_page(page) + if element = @pages.dig(page) + @current_page.hide if @current_page + @current_page = element + element.show + end + end + + def create_page_display + label "Display", text_size: 50 + + label "Resolution" + flow do + stack do + label "Width" + label "Height" + end + stack do + edit_line "#{window.width}" + edit_line "#{window.height}" + end + end + + label "" + check_box "Fullscreen" + label "" + + flow do + stack do + label "Gamma Correction" + label "Brightness" + label "Contrast" + end + stack do + slider + slider + slider + end + stack do + label "0.0" + label "0.0" + label "0.0" + end + end + end + + def create_page_audio + label "Audio", text_size: 50 + + flow do + stack do + label "Master Volume" + label "Sound Effects" + label "Dialog" + label "Cinematic" + end + stack do + slider range: 0.0..1.0, value: 1.0 + slider range: 0.0..1.0, value: 1.0 + slider range: 0.0..1.0, value: 1.0 + slider range: 0.0..1.0, value: 1.0 + end + stack do + label "0.0" + label "0.0" + label "0.0" + label "0.0" + end + end + end + + def create_page_controls + label "Controls", text_size: 50 + + InputMapper.keymap.each do |key, values| + flow do + label "#{key}" + + [values].flatten.each do |value| + button Gosu.button_id_to_char(value) + end + end + end + end + + def create_page_graphics + label "Graphics", text_size: 50 + + flow do + check_box "V-Sync" + label "(No Supported)" + end + + flow do + label "Field of View" + slider range: 70.0..110.0 + label "90.0" + end + + flow do + stack do + label "Detail" + end + stack do + slider range: 1..3 + end + stack do + label "High" + end + end + + advanced_mode = check_box "Advanced Mode" + + advanced_settings = stack do |element| + element.hide + + flow do + stack do + label "Geometry Detail" + label "Shadow Detail" + label "Texture Detail" + label "Particle Detail" + label "Surface Effect Detail" + end + stack do + slider + slider + slider + slider + slider + end + stack do + label "High" + label "High" + label "High" + label "High" + label "High" + end + end + + flow do + stack do + label "Lighting Mode" + edit_line "" + end + stack do + label "Texture Filtering" + edit_line "" + end + end + end + + advanced_mode.subscribe(:changed) do |element, value| + advanced_settings.show if value + advanced_settings.hide unless value + end + end + + def create_page_multiplayer + label "Multiplayer", text_size: 50 + + check_box "Show player names" end end end \ No newline at end of file