Ran rubocop autocorrect

This commit is contained in:
2020-12-02 17:37:48 -06:00
parent aa30ff73d0
commit 95bea199ed
116 changed files with 758 additions and 575 deletions

View File

@@ -1,16 +1,20 @@
# frozen_string_literal: true
class IMICFPS
class Commands
module Style
def self.error(string)
"<c=ff5555>#{string}</c>"
end
def self.warn(string)
"<c=ff7700>#{string}</c>"
end
def self.notice(string)
"<c=55ff55>#{string}</c>"
end
def self.highlight(string, color = "5555ff")
"<c=#{color}>#{string}</c>"
end
@@ -28,7 +32,9 @@ class IMICFPS
@commands = []
@list.each do |subclass|
cmd = subclass.new
raise "Command '#{cmd.command}' from '#{cmd.class}' already exists!" if @commands.detect { |c| c.command == cmd.command }
if @commands.detect { |c| c.command == cmd.command }
raise "Command '#{cmd.command}' from '#{cmd.class}' already exists!"
end
@commands << cmd
end
@@ -59,15 +65,19 @@ class IMICFPS
setup
end
def setup; end
def setup
end
def subcommand(command, type)
raise "Subcommand '#{command}' for '#{self.command}' already exists!" if @subcommands.detect { |subcmd| subcmd.command == command.to_sym }
if @subcommands.detect { |subcmd| subcmd.command == command.to_sym }
raise "Subcommand '#{command}' for '#{self.command}' already exists!"
end
@subcommands << SubCommand.new(self, command, type)
end
def get(key)
@store.dig(key)
@store[key]
end
def set(key, value)
@@ -89,15 +99,16 @@ class IMICFPS
def autocomplete(console)
split = console.text_input.text.split(" ")
if @subcommands.size > 0
if @subcommands.size.positive?
if !console.text_input.text.end_with?(" ") && split.size == 2
list = console.abbrev_search(@subcommands.map { |cmd| cmd.command.to_s}, split.last)
list = console.abbrev_search(@subcommands.map { |cmd| cmd.command.to_s }, split.last)
if list.size == 1
console.text_input.text = "#{split.first} #{list.first} "
else
return unless list.size > 0
console.stdin("#{list.map { |cmd| Commands::Style.highlight(cmd)}.join(", ")}")
return unless list.size.positive?
console.stdin(list.map { |cmd| Commands::Style.highlight(cmd) }.join(", ").to_s)
end
# List available options on subcommand
@@ -106,26 +117,26 @@ class IMICFPS
if subcommand
if split.size == 2
console.stdin("Available options: #{subcommand.values.map { |value| Commands::Style.highlight(value) }.join(",")}")
console.stdin("Available options: #{subcommand.values.map { |value| Commands::Style.highlight(value) }.join(',')}")
else
list = console.abbrev_search(subcommand.values, split.last)
if list.size == 1
console.text_input.text = "#{split.first} #{split[1]} #{list.first} "
else
console.stdin("Available options: #{list.map { |value| Commands::Style.highlight(value) }.join(",")}") if list.size > 0
elsif list.size.positive?
console.stdin("Available options: #{list.map { |value| Commands::Style.highlight(value) }.join(',')}")
end
end
end
# List available subcommands if command was entered and has only a space after it
elsif console.text_input.text.end_with?(" ") && split.size == 1
console.stdin("Available subcommands: #{@subcommands.map { |cmd| Commands::Style.highlight(cmd.command)}.join(", ")}")
console.stdin("Available subcommands: #{@subcommands.map { |cmd| Commands::Style.highlight(cmd.command) }.join(', ')}")
end
end
end
def handle_subcommand(arguments, console)
if arguments.size == 0
if arguments.size.zero?
console.stdin(usage)
return
end
@@ -144,4 +155,4 @@ class IMICFPS
end
end
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Commands
class ConnectCommand < Command
@@ -14,8 +15,8 @@ class IMICFPS
end
def usage
"Connect to a server.\n#{Style.highlight("connect")} #{Style.notice("[example.com:56789]")}"
"Connect to a server.\n#{Style.highlight('connect')} #{Style.notice('[example.com:56789]')}"
end
end
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Commands
class DebugCommand < Command
@@ -39,7 +40,7 @@ class IMICFPS
end
def usage
"debug\n #{@subcommands.map { |sub| sub.usage }.join("\n ")}"
"debug\n #{@subcommands.map(&:usage).join("\n ")}"
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Commands
class DisconnectCommand < Command
@@ -18,4 +19,4 @@ class IMICFPS
end
end
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Commands
class FPSCommand < Command
@@ -12,13 +13,13 @@ class IMICFPS
def handle(arguments, console)
if arguments.size > 1
console.stdin("to many arguments for #{Style.highlight("#{command}")}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
console.stdin("to many arguments for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
return
end
case arguments.last
when "", nil
console.stdin("#{Style.highlight("fps")}: #{$window.config.get(:options, :fps)}")
console.stdin("#{Style.highlight('fps')}: #{$window.config.get(:options, :fps)}")
when "on"
var = $window.config[:options, :fps] = true
console.stdin("fps => #{Style.highlight(var)}")
@@ -26,12 +27,12 @@ class IMICFPS
var = $window.config[:options, :fps] = false
console.stdin("fps => #{Style.highlight(var)}")
else
console.stdin("Invalid argument for #{Style.highlight("#{command}")}, got #{Style.error(arguments.last)} expected #{Style.notice("on")}, or #{Style.notice("off")}.")
console.stdin("Invalid argument for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.last)} expected #{Style.notice('on')}, or #{Style.notice('off')}.")
end
end
def usage
"#{Style.highlight("fps")} #{Style.notice("[on|off]")}"
"#{Style.highlight('fps')} #{Style.notice('[on|off]')}"
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Commands
class HelpCommand < Command
@@ -21,7 +22,7 @@ class IMICFPS
if list.size == 1
console.text_input.text = "#{split.first} #{list.first} "
elsif list.size > 1
console.stdin(list.map { |cmd| Style.highlight(cmd) }.join(', '))
console.stdin(list.map { |cmd| Style.highlight(cmd) }.join(", "))
end
end
end
@@ -34,9 +35,9 @@ class IMICFPS
"#{Style.error(command)} is not a command"
end
else
"Available commands:\n#{Command.list_commands.map { |cmd| "#{Style.highlight(cmd.command)}" }.join(', ')}"
"Available commands:\n#{Command.list_commands.map { |cmd| Style.highlight(cmd.command).to_s }.join(', ')}"
end
end
end
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Commands
class ReloadShaderCommand < Command
@@ -12,7 +13,7 @@ class IMICFPS
def handle(arguments, console)
if arguments.size > 2
console.stdin("to many arguments for #{Style.highlight("#{command}")}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
console.stdin("to many arguments for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
return
end
@@ -22,7 +23,7 @@ class IMICFPS
case arguments.size
when 0
console.stdin( usage )
console.stdin(usage)
return
when 1
name = arguments.first
@@ -50,9 +51,9 @@ class IMICFPS
string = $stdout.string
if shader.compiled?
console.stdin("#{Style.notice("Successfully reloaded shader")}: #{shader.name}")
console.stdin("#{Style.notice('Successfully reloaded shader')}: #{shader.name}")
else
console.stdin("#{Style.error("Failed to reload #{shader.name}")}")
console.stdin(Style.error("Failed to reload #{shader.name}").to_s)
console.stdin(string)
end
ensure
@@ -61,7 +62,7 @@ class IMICFPS
end
def usage
"#{Style.highlight(command)} #{Style.notice("vertex_name [fragment_name]")}"
"#{Style.highlight(command)} #{Style.notice('vertex_name [fragment_name]')}"
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Commands
class RendererInfoCommand < Command
@@ -10,7 +11,7 @@ class IMICFPS
:renderer_info
end
def handle(arguments, console)
def handle(_arguments, console)
console.stdin("OpenGL Vendor: #{Style.notice(glGetString(GL_VENDOR))}")
console.stdin("OpenGL Renderer: #{Style.notice(glGetString(GL_RENDERER))}")
console.stdin("OpenGL Version: #{Style.notice(glGetString(GL_VERSION))}")
@@ -18,7 +19,7 @@ class IMICFPS
end
def usage
"#{Style.highlight("renderer_info")} #{Style.notice("Returns OpenGL renderer information")}"
"#{Style.highlight('renderer_info')} #{Style.notice('Returns OpenGL renderer information')}"
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Console
Z = 100_000
@@ -6,6 +7,7 @@ class IMICFPS
include CommonMethods
attr_reader :text_input
def initialize
@text_input = Gosu::TextInput.new
@width = window.width / 4 * 3
@@ -47,7 +49,9 @@ class IMICFPS
@history.draw
@input.draw
# Caret
draw_rect(@input.x + caret_from_left, @input.y, Console::PADDING, @input.height, @caret_color, Console::Z + 2) if @show_caret
if @show_caret
draw_rect(@input.x + caret_from_left, @input.y, Console::PADDING, @input.height, @caret_color, Console::Z + 2)
end
# Caret selection
if caret_start != caret_end
if caret_start < @text_input.selection_start
@@ -59,8 +63,9 @@ class IMICFPS
end
def caret_from_left
return 0 if @text_input.caret_pos == 0
@input.textobject.text_width(@text_input.text[0..@text_input.caret_pos-1])
return 0 if @text_input.caret_pos.zero?
@input.textobject.text_width(@text_input.text[0..@text_input.caret_pos - 1])
end
def caret_selection_width
@@ -99,7 +104,8 @@ class IMICFPS
def button_down(id)
case id
when Gosu::KbEnter, Gosu::KbReturn
return unless @text_input.text.length > 0
return unless @text_input.text.length.positive?
@history.text += "\n<c=999999>> #{@text_input.text}</c>"
@command_history << @text_input.text
@command_history_index = @command_history.size
@@ -109,7 +115,7 @@ class IMICFPS
when Gosu::KbUp
@command_history_index -= 1
@command_history_index = 0 if @command_history_index < 0
@command_history_index = 0 if @command_history_index.negative?
@text_input.text = @command_history[@command_history_index]
when Gosu::KbDown
@@ -125,26 +131,24 @@ class IMICFPS
split = @text_input.text.split(" ")
if !@text_input.text.end_with?(" ") && split.size == 1
list = abbrev_search(Commands::Command.list_commands.map { |cmd| cmd.command.to_s}, @text_input.text)
list = abbrev_search(Commands::Command.list_commands.map { |cmd| cmd.command.to_s }, @text_input.text)
if list.size == 1
@text_input.text = "#{list.first} "
else
stdin("\n#{list.map { |cmd| Commands::Style.highlight(cmd)}.join(", ")}") if list.size > 0
end
else
if split.size > 0 && cmd = Commands::Command.find(split.first)
cmd.autocomplete(self)
elsif list.size.positive?
stdin("\n#{list.map { |cmd| Commands::Style.highlight(cmd) }.join(', ')}")
end
elsif split.size.positive? && cmd = Commands::Command.find(split.first)
cmd.autocomplete(self)
end
when Gosu::KbBacktick
# Remove backtick character from input
if @text_input.text.size > 1
@text_input.text = @text_input.text[0..@text_input.text.size - 2]
else
@text_input.text = ""
end
@text_input.text = if @text_input.text.size > 1
@text_input.text[0..@text_input.text.size - 2]
else
""
end
# Copy
when Gosu::KbC
@@ -187,9 +191,7 @@ class IMICFPS
# Clear history
when Gosu::KbL
if control_down?
@history.text = ""
end
@history.text = "" if control_down?
end
end
@@ -197,29 +199,29 @@ class IMICFPS
end
def update_history_y
@history.y = @height - (PADDING * 2) - @input.height - (@history.text.lines.count * (@history.textobject.height))
@history.y = @height - (PADDING * 2) - @input.height - (@history.text.lines.count * @history.textobject.height)
end
def handle_command
string = @text_input.text
split = string.split(" ")
command = split.first
arguments = split.length > 0 ? split[1..split.length - 1] : []
arguments = split.length.positive? ? split[1..split.length - 1] : []
IMICFPS::Commands::Command.use(command, arguments, self)
end
def abbrev_search(array, text)
return [] unless text.length > 0
return [] unless text.length.positive?
list = []
Abbrev.abbrev(array).each do |abbrev, value|
next unless abbrev && abbrev.start_with?(text)
next unless abbrev&.start_with?(text)
list << value
end
return list.uniq
list.uniq
end
def stdin(string)
@@ -245,4 +247,4 @@ class IMICFPS
window.needs_cursor = @showing_cursor
end
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Menu < IMICFPS::GuiState
include CommonMethods
@@ -67,7 +68,7 @@ class IMICFPS
@_subtitle = @elements.last
end
def link(text, color = Gosu::Color.rgb(0,127,127), &block)
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
@@ -94,14 +95,12 @@ class IMICFPS
draw_rect(
window.width / 4, 0,
window.width / 2, window.height,
Gosu::Color.new(0x11ffffff),
Gosu::Color.new(0x11ffffff)
)
end
def draw_menu
@elements.each do |e|
e.draw
end
@elements.each(&:draw)
end
def update
@@ -110,9 +109,7 @@ class IMICFPS
e.update
end
if window.scene
window.scene.update(window.dt)
end
window.scene&.update(window.dt)
super
@@ -124,9 +121,8 @@ class IMICFPS
if id == Gosu::MsLeft
@elements.each do |e|
next unless e.is_a?(Link)
if mouse_over?(e)
e.clicked
end
e.clicked if mouse_over?(e)
end
end
@@ -134,36 +130,59 @@ class IMICFPS
end
def mouse_over?(object)
mouse_x.between?(object.x, object.x+object.width) &&
mouse_y.between?(object.y, object.y+object.height)
mouse_x.between?(object.x, object.x + object.width) &&
mouse_y.between?(object.y, object.y + object.height)
end
class Link
attr_reader :text, :block
def initialize(text, host, block)
@text, @host, @block = 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_color = Gosu::Color::BLACK
@text.shadow_size = 2
@text.shadow_alpha = 100
end
def update
if @host.mouse_over?(self)
@text.color = @hover_color
else
@text.color = @color
end
@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 if @block; 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

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class ExtrasMenu < Menu
def setup
@@ -18,4 +19,4 @@ class IMICFPS
end
end
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class GamePauseMenu < Menu
def setup

View File

@@ -1,11 +1,12 @@
# frozen_string_literal: true
class IMICFPS
class LevelSelectMenu < Menu
def setup
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|
Dir.glob("#{GAME_ROOT_PATH}/maps/*.json").map { |file| [file, MapParser.new(map_file: file)] }.each do |file, map|
link map.metadata.name do
push_state(
LoadingState.new(forward: Game, map_file: file)

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class MainMenu < Menu
def setup
@@ -25,16 +26,16 @@ class IMICFPS
end
gl_version = glGetString(GL_VERSION).to_s
major, minor = gl_version.split(" ").first.split(".").map { |v| v.to_i }
major, minor = gl_version.split(" ").first.split(".").map(&:to_i)
unless (major == 3 && minor >= 3) || (major > 3)
message =
"<b><c=a00>[Notice]</c></b> Your computer is reporting support for <b><c=f50>OpenGL #{major}.#{minor}</c></b>,
message =
"<b><c=a00>[Notice]</c></b> Your computer is reporting support for <b><c=f50>OpenGL #{major}.#{minor}</c></b>,
however <b><c=5f5>OpenGL 3.3 or higher is required.</c></b>
Fallback <b>immediate mode renderer</b> will be used."
linux_mesa_message =
"
linux_mesa_message =
"
(Linux Only) For MESA based drivers append <b>--mesa-override</b>
as a commandline argument to override reported version."
@@ -46,9 +47,7 @@ as a commandline argument to override reported version."
def draw
super
if @old_gl_warning
@old_gl_warning.draw(window.width / 2 - @old_gl_warning.width / 2, window.height - (@old_gl_warning.height + 10), Float::INFINITY)
end
@old_gl_warning&.draw(window.width / 2 - @old_gl_warning.width / 2, window.height - (@old_gl_warning.height + 10), Float::INFINITY)
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class MultiplayerMenu < Menu
def setup
@@ -17,4 +18,4 @@ class IMICFPS
end
end
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class MultiplayerProfileMenu < Menu
def setup
@@ -49,4 +50,4 @@ class IMICFPS
end
end
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class MultiplayerServerBrowserMenu < Menu
def setup
@@ -80,4 +81,4 @@ class IMICFPS
end
end
end
end
end

View File

@@ -1,21 +1,28 @@
# frozen_string_literal: true
class IMICFPS
class SettingsMenu < Menu
include CommonMethods
def self.set_defaults
$window.config[:options, :audio, :volume_sound] = 1.0 if $window.config.get(:options, :audio, :volume_sound).nil?
$window.config[:options, :audio, :volume_music] = 0.7 if $window.config.get(:options, :audio, :volume_music).nil?
$window.config[:options, :audio, :volume_dialogue] = 0.7 if $window.config.get(:options, :audio, :volume_dialogue).nil?
if $window.config.get(:options, :audio, :volume_sound).nil?
$window.config[:options, :audio, :volume_sound] = 1.0
end
if $window.config.get(:options, :audio, :volume_music).nil?
$window.config[:options, :audio, :volume_music] = 0.7
end
if $window.config.get(:options, :audio, :volume_dialogue).nil?
$window.config[:options, :audio, :volume_dialogue] = 0.7
end
end
def setup
@categories = [
"Display",
"Graphics",
"Audio",
"Controls",
"Multiplayer"
@categories = %w[
Display
Graphics
Audio
Controls
Multiplayer
]
@pages = {}
@current_page = nil
@@ -40,9 +47,7 @@ class IMICFPS
@pages[:"#{category}".downcase] = element
element.hide
if respond_to?(:"create_page_#{category}".downcase)
self.send(:"create_page_#{category}".downcase)
end
send(:"create_page_#{category}".downcase) if respond_to?(:"create_page_#{category}".downcase)
end
end
end
@@ -51,8 +56,8 @@ class IMICFPS
end
def show_page(page)
if element = @pages.dig(page)
@current_page.hide if @current_page
if element = @pages[page]
@current_page&.hide
@current_page = element
element.show
end
@@ -68,8 +73,8 @@ class IMICFPS
label "Height"
end
stack do
edit_line "#{window.width}"
edit_line "#{window.height}"
edit_line window.width.to_s
edit_line window.height.to_s
end
end
@@ -80,7 +85,7 @@ class IMICFPS
flow do
label "Gamma Correction".ljust(longest_string.length, " ")
@display_gamma_correction = slider range: 0.0..1.0, value: 0.5
@display_gamma_correction.subscribe(:changed) do |sender, value|
@display_gamma_correction.subscribe(:changed) do |_sender, value|
@display_gamma_correction_label.value = value.round(1).to_s
end
@display_gamma_correction_label = label "0.0"
@@ -88,14 +93,15 @@ class IMICFPS
flow do
label "Brightness".ljust(longest_string.length, " ")
@display_brightness = slider range: 0.0..1.0, value: 0.5
@display_brightness.subscribe(:changed) do |sender, value|
@display_brightness.subscribe(:changed) do |_sender, value|
@display_brightness_label.value = value.round(1).to_s
end
@display_brightness_label = label "0.0" end
@display_brightness_label = label "0.0"
end
flow do
label "Contrast".ljust(longest_string.length, " ")
@display_contrast = slider range: 0.0..1.0, value: 0.5
@display_contrast.subscribe(:changed) do |sender, value|
@display_contrast.subscribe(:changed) do |_sender, value|
@display_contrast_label.value = value.round(1).to_s
end
@display_contrast_label = label "0.0"
@@ -106,7 +112,7 @@ class IMICFPS
def create_page_audio
label "Audio", text_size: 50
longest_string = "Dialogue".length
volumes = [:sound, :music, :dialogue]
volumes = %i[sound music dialogue]
stack do
volumes.each do |volume|
@@ -115,11 +121,11 @@ class IMICFPS
flow do
label volume.to_s.split("_").join(" ").capitalize.ljust(longest_string, " ")
instance_variable_set(:"@volume_#{volume}", slider(range: 0.0..1.0, value: config_value))
instance_variable_get(:"@volume_#{volume}").subscribe(:changed) do |sender, value|
instance_variable_get(:"@volume_#{volume}_label").value = "%03.2f%%" % [value * 100.0]
instance_variable_get(:"@volume_#{volume}").subscribe(:changed) do |_sender, value|
instance_variable_get(:"@volume_#{volume}_label").value = format("%03.2f%%", value * 100.0)
window.config[:options, :audio, :"volume_#{volume}"] = value
end
instance_variable_set(:"@volume_#{volume}_label", label("%03.2f%%" % [config_value * 100.0]))
instance_variable_set(:"@volume_#{volume}_label", label(format("%03.2f%%", config_value * 100.0)))
end
end
end
@@ -130,7 +136,7 @@ class IMICFPS
InputMapper.keymap.each do |key, values|
flow do
label "#{key}"
label key.to_s
[values].flatten.each do |value|
if name = Gosu.button_name(value)
@@ -156,7 +162,7 @@ class IMICFPS
flow do
label "Field of View".ljust(longest_string.length, " ")
@fov = slider range: 70.0..110.0
@fov.subscribe(:changed) do |sender, value|
@fov.subscribe(:changed) do |_sender, value|
@fov_label.value = value.round.to_s
end
@fov_label = label "90.0"
@@ -164,7 +170,7 @@ class IMICFPS
flow do
label "Detail".ljust(longest_string.length, " ")
list_box items: [:high, :medium, :low], width: 250
list_box items: %i[high medium low], width: 250
end
label ""
@@ -177,27 +183,27 @@ class IMICFPS
stack do
flow do
label "Geometry Detail".ljust(longest_string.length, " ")
list_box items: [:high, :medium, :low], width: 250
list_box items: %i[high medium low], width: 250
end
flow do
label "Shadow Detail".ljust(longest_string.length, " ")
list_box items: [:high, :medium, :low, :off], width: 250
list_box items: %i[high medium low off], width: 250
end
flow do
label "Texture Detail".ljust(longest_string.length, " ")
list_box items: [:high, :medium, :low], width: 250
list_box items: %i[high medium low], width: 250
end
flow do
label "Particle Detail".ljust(longest_string.length, " ")
list_box items: [:high, :medium, :low, :off], width: 250
list_box items: %i[high medium low off], width: 250
end
flow do
label "Surface Effect Detail".ljust(longest_string.length, " ")
list_box items: [:high, :medium, :low], width: 250
list_box items: %i[high medium low], width: 250
end
flow do
label "Lighting Mode".ljust(longest_string.length, " ")
list_box items: [:per_pixel, :per_vertex], width: 250
list_box items: %i[per_pixel per_vertex], width: 250
end
flow do
label "Texture Filtering".ljust(longest_string.length, " ")
@@ -206,7 +212,7 @@ class IMICFPS
end
end
advanced_mode.subscribe(:changed) do |element, value|
advanced_mode.subscribe(:changed) do |_element, value|
advanced_settings.show if value
advanced_settings.hide unless value
end
@@ -222,4 +228,4 @@ class IMICFPS
check_box "Show player names"
end
end
end
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
class IMICFPS
class Commands
class Command
@@ -9,13 +10,11 @@ class IMICFPS
@type = type
end
def command
@command
end
attr_reader :command
def handle(arguments, console)
if arguments.size > 1
console.stdin("to many arguments for #{Style.highlight("#{command}")}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
console.stdin("to many arguments for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
return
end
@@ -23,7 +22,7 @@ class IMICFPS
when :boolean
case arguments.last
when "", nil
var = @parent.get(command.to_sym) ? @parent.get(command.to_sym) : false
var = @parent.get(command.to_sym) || false
console.stdin("#{command}: #{Style.highlight(var)}")
when "on"
var = @parent.set(command.to_sym, true)
@@ -32,12 +31,12 @@ class IMICFPS
var = @parent.set(command.to_sym, false)
console.stdin("#{command} => #{Style.highlight(var)}")
else
console.stdin("Invalid argument for #{Style.highlight("#{command}")}, got #{Style.error(arguments.last)} expected #{Style.notice("on")}, or #{Style.notice("off")}.")
console.stdin("Invalid argument for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.last)} expected #{Style.notice('on')}, or #{Style.notice('off')}.")
end
when :string
case arguments.last
when "", nil
var = @parent.get(command.to_sym) ? @parent.get(command.to_sym) : "\"\""
var = @parent.get(command.to_sym) || "\"\""
console.stdin("#{command}: #{Style.highlight(var)}")
else
var = @parent.set(command.to_sym, arguments.last)
@@ -46,7 +45,7 @@ class IMICFPS
when :integer
case arguments.last
when "", nil
var = @parent.get(command.to_sym) ? @parent.get(command.to_sym) : "nil"
var = @parent.get(command.to_sym) || "nil"
console.stdin("#{command}: #{Style.highlight(var)}")
else
begin
@@ -59,7 +58,7 @@ class IMICFPS
when :decimal
case arguments.last
when "", nil
var = @parent.get(command.to_sym) ? @parent.get(command.to_sym) : "nil"
var = @parent.get(command.to_sym) || "nil"
console.stdin("#{command}: #{Style.highlight(var)}")
else
begin
@@ -77,7 +76,7 @@ class IMICFPS
def values
case @type
when :boolean
["on", "off"]
%w[on off]
else
[]
end
@@ -86,16 +85,16 @@ class IMICFPS
def usage
case @type
when :boolean
"#{Style.highlight(command)} #{Style.notice("[on|off]")}"
"#{Style.highlight(command)} #{Style.notice('[on|off]')}"
when :string
"#{Style.highlight(command)} #{Style.notice("[string]")}"
"#{Style.highlight(command)} #{Style.notice('[string]')}"
when :integer
"#{Style.highlight(command)} #{Style.notice("[0]")}"
"#{Style.highlight(command)} #{Style.notice('[0]')}"
when :decimal
"#{Style.highlight(command)} #{Style.notice("[0.0]")}"
"#{Style.highlight(command)} #{Style.notice('[0.0]')}"
end
end
end
end
end
end
end