mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 08:02:36 +00:00
Extracted Console into CyberarmEngine
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
class IMICFPS
|
||||
class Commands
|
||||
class ConnectCommand < Command
|
||||
class ConnectCommand < CyberarmEngine::Console::Command
|
||||
def group
|
||||
:global
|
||||
end
|
||||
@@ -15,7 +15,7 @@ class IMICFPS
|
||||
end
|
||||
|
||||
def usage
|
||||
"Connect to a server.\n#{Style.highlight('connect')} #{Style.notice('[example.com:56789]')}"
|
||||
"Connect to a server.\n#{Console::Style.highlight('connect')} #{Style.notice('example.com[:56789]')}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class IMICFPS
|
||||
class Commands
|
||||
class DebugCommand < Command
|
||||
class DebugCommand < CyberarmEngine::Console::Command
|
||||
def group
|
||||
:global
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class IMICFPS
|
||||
class Commands
|
||||
class DisconnectCommand < Command
|
||||
class DisconnectCommand < CyberarmEngine::Console::Command
|
||||
def group
|
||||
:global
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class IMICFPS
|
||||
class Commands
|
||||
class FPSCommand < Command
|
||||
class FPSCommand < CyberarmEngine::Console::Command
|
||||
def group
|
||||
:global
|
||||
end
|
||||
@@ -13,26 +13,26 @@ class IMICFPS
|
||||
|
||||
def handle(arguments, console)
|
||||
if arguments.size > 1
|
||||
console.stdin("to many arguments for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
|
||||
console.stdin("to many arguments for #{Console::Style.highlight(command.to_s)}, got #{Console::Style.error(arguments.size)} expected #{Console::Style.notice(1)}.")
|
||||
return
|
||||
end
|
||||
|
||||
case arguments.last
|
||||
when "", nil
|
||||
console.stdin("#{Style.highlight('fps')}: #{$window.config.get(:options, :fps)}")
|
||||
console.stdin("#{Console::Style.highlight('fps')}: #{$window.config.get(:options, :fps)}")
|
||||
when "on"
|
||||
var = $window.config[:options, :fps] = true
|
||||
console.stdin("fps => #{Style.highlight(var)}")
|
||||
console.stdin("fps => #{Console::Style.highlight(var)}")
|
||||
when "off"
|
||||
var = $window.config[:options, :fps] = false
|
||||
console.stdin("fps => #{Style.highlight(var)}")
|
||||
console.stdin("fps => #{Console::Style.highlight(var)}")
|
||||
else
|
||||
console.stdin("Invalid argument for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.last)} expected #{Style.notice('on')}, or #{Style.notice('off')}.")
|
||||
console.stdin("Invalid argument for #{Console::Style.highlight(command.to_s)}, got #{Console::Style.error(arguments.last)} expected #{Console::Style.notice('on')}, or #{Console::Style.notice('off')}.")
|
||||
end
|
||||
end
|
||||
|
||||
def usage
|
||||
"#{Style.highlight('fps')} #{Style.notice('[on|off]')}"
|
||||
"#{Console::Style.highlight('fps')} #{Style.notice('[on|off]')}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IMICFPS
|
||||
class Commands
|
||||
class HelpCommand < Command
|
||||
def group
|
||||
:global
|
||||
end
|
||||
|
||||
def command
|
||||
:help
|
||||
end
|
||||
|
||||
def handle(arguments, console)
|
||||
console.stdin(usage(arguments.first))
|
||||
end
|
||||
|
||||
def autocomplete(console)
|
||||
split = console.text_input.text.split(" ")
|
||||
if !console.text_input.text.start_with?(" ") && split.size == 2
|
||||
list = console.abbrev_search(Commands::Command.list_commands.map { |cmd| cmd.command.to_s }, split.last)
|
||||
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(", "))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def usage(command = nil)
|
||||
if command
|
||||
if cmd = Command.find(command)
|
||||
cmd.usage
|
||||
else
|
||||
"#{Style.error(command)} is not a command"
|
||||
end
|
||||
else
|
||||
"Available commands:\n#{Command.list_commands.map { |cmd| Style.highlight(cmd.command).to_s }.join(', ')}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class IMICFPS
|
||||
class Commands
|
||||
class HUDCommand < Command
|
||||
class HUDCommand < CyberarmEngine::Console::Command
|
||||
def group
|
||||
:global
|
||||
end
|
||||
@@ -17,26 +17,26 @@ class IMICFPS
|
||||
|
||||
def handle(arguments, console)
|
||||
if arguments.size > 1
|
||||
console.stdin("to many arguments for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
|
||||
console.stdin("to many arguments for #{Console::Style.highlight(command.to_s)}, got #{Console::Style.error(arguments.size)} expected #{Console::Style.notice(1)}.")
|
||||
return
|
||||
end
|
||||
|
||||
case arguments.last
|
||||
when "", nil
|
||||
console.stdin("#{Style.highlight(command.to_s)}: #{$window.config.get(:options, command)}")
|
||||
console.stdin("#{Console::Style.highlight(command.to_s)}: #{$window.config.get(:options, command)}")
|
||||
when "on"
|
||||
var = $window.config[:options, command] = true
|
||||
console.stdin("fps => #{Style.highlight(var)}")
|
||||
console.stdin("#{command} => #{Console::Style.highlight(var)}")
|
||||
when "off"
|
||||
var = $window.config[:options, command] = false
|
||||
console.stdin("fps => #{Style.highlight(var)}")
|
||||
console.stdin("#{command} => #{Console::Style.highlight(var)}")
|
||||
else
|
||||
console.stdin("Invalid argument for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.last)} expected #{Style.notice('on')}, or #{Style.notice('off')}.")
|
||||
console.stdin("Invalid argument for #{Console::Style.highlight(command.to_s)}, got #{Console::Style.error(arguments.last)} expected #{Console::Style.notice('on')}, or #{Console::Style.notice('off')}.")
|
||||
end
|
||||
end
|
||||
|
||||
def usage
|
||||
"#{Style.highlight('hud')} #{Style.notice('[on|off]')}"
|
||||
"#{Console::Style.highlight('hud')} #{Console::Style.notice('[on|off]')}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class IMICFPS
|
||||
class Commands
|
||||
class ReloadShaderCommand < Command
|
||||
class ReloadShaderCommand < CyberarmEngine::Console::Command
|
||||
def group
|
||||
:reload_shader
|
||||
end
|
||||
@@ -13,7 +13,7 @@ class IMICFPS
|
||||
|
||||
def handle(arguments, console)
|
||||
if arguments.size > 2
|
||||
console.stdin("to many arguments for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
|
||||
console.stdin("to many arguments for #{Console::Style.highlight(command.to_s)}, got #{Console::Style.error(arguments.size)} expected #{Console::Style.notice(1)}.")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -51,9 +51,9 @@ class IMICFPS
|
||||
string = $stdout.string
|
||||
|
||||
if shader.compiled?
|
||||
console.stdin("#{Style.notice('Successfully reloaded shader')}: #{shader.name}")
|
||||
console.stdin("#{Console::Style.notice('Successfully reloaded shader')}: #{shader.name}")
|
||||
else
|
||||
console.stdin(Style.error("Failed to reload #{shader.name}").to_s)
|
||||
console.stdin(Console::Style.error("Failed to reload #{shader.name}").to_s)
|
||||
console.stdin(string)
|
||||
end
|
||||
ensure
|
||||
@@ -62,7 +62,7 @@ class IMICFPS
|
||||
end
|
||||
|
||||
def usage
|
||||
"#{Style.highlight(command)} #{Style.notice('vertex_name [fragment_name]')}"
|
||||
"#{Console::Style.highlight(command)} #{Console::Style.notice('vertex_name [fragment_name]')}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class IMICFPS
|
||||
class Commands
|
||||
class RendererInfoCommand < Command
|
||||
class RendererInfoCommand < CyberarmEngine::Console::Command
|
||||
def group
|
||||
:global
|
||||
end
|
||||
@@ -12,14 +12,14 @@ class IMICFPS
|
||||
end
|
||||
|
||||
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))}")
|
||||
console.stdin("OpenGL Shader Language Version: #{Style.notice(glGetString(GL_SHADING_LANGUAGE_VERSION))}")
|
||||
console.stdin("OpenGL Vendor: #{Console::Style.notice(glGetString(GL_VENDOR))}")
|
||||
console.stdin("OpenGL Renderer: #{Console::Style.notice(glGetString(GL_RENDERER))}")
|
||||
console.stdin("OpenGL Version: #{Console::Style.notice(glGetString(GL_VERSION))}")
|
||||
console.stdin("OpenGL Shader Language Version: #{Console::Style.notice(glGetString(GL_SHADING_LANGUAGE_VERSION))}")
|
||||
end
|
||||
|
||||
def usage
|
||||
"#{Style.highlight('renderer_info')} #{Style.notice('Returns OpenGL renderer information')}"
|
||||
"#{Console::Style.highlight('renderer_info')} #{Console::Style.notice('Returns OpenGL renderer information')}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user