wip
This commit is contained in:
parent
b42d35d901
commit
abf55c9af1
5 changed files with 51 additions and 6 deletions
|
@ -1,4 +1,13 @@
|
||||||
class Action < ApplicationRecord
|
class Action < ApplicationRecord
|
||||||
belongs_to :batch
|
belongs_to :batch
|
||||||
belongs_to :actionable, polymorphic: true
|
belongs_to :actionable, polymorphic: true
|
||||||
|
|
||||||
|
def render
|
||||||
|
case actionable
|
||||||
|
when Execution
|
||||||
|
%(#{actionable.command.name} #{actionable.value})
|
||||||
|
else
|
||||||
|
to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,8 @@ class Batch < ApplicationRecord
|
||||||
has_many :menu_options
|
has_many :menu_options
|
||||||
has_many :wheel_options
|
has_many :wheel_options
|
||||||
has_many :key_binds
|
has_many :key_binds
|
||||||
|
|
||||||
|
def render
|
||||||
|
actions.collect(&:render).join("; ")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
class Execution < ApplicationRecord
|
class Execution < ApplicationRecord
|
||||||
belongs_to :command
|
belongs_to :command
|
||||||
has_many :actions
|
has_many :actions
|
||||||
|
has_one :execution, ->(o){Execution.find(o.value)}
|
||||||
|
|
||||||
|
def execution
|
||||||
|
Execution.find(value)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,10 @@ class Setup < ApplicationRecord
|
||||||
has_many :wheels
|
has_many :wheels
|
||||||
has_many :menus
|
has_many :menus
|
||||||
has_many :input_devices
|
has_many :input_devices
|
||||||
|
|
||||||
|
def render
|
||||||
|
key_binds.collect { |key_bind|
|
||||||
|
%(alias batch#{id} \"#{key_bind.batch.render}\"\nbind #{key_bind.key.ingame} batch#{id})
|
||||||
|
}.join("\n")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -318,6 +318,7 @@ end
|
||||||
|
|
||||||
{
|
{
|
||||||
'none' => /^$/,
|
'none' => /^$/,
|
||||||
|
'command' => /^.*$/,
|
||||||
'string' => /^.*$/,
|
'string' => /^.*$/,
|
||||||
'integer' => /^\d+$/,
|
'integer' => /^\d+$/,
|
||||||
'float' => /^\d+(?:\.\d+)|\.\d+$/,
|
'float' => /^\d+(?:\.\d+)|\.\d+$/,
|
||||||
|
@ -345,19 +346,39 @@ Nokogiri::HTML
|
||||||
flags = flags.strip.split(', ')[1..] # TODO
|
flags = flags.strip.split(', ')[1..] # TODO
|
||||||
Command
|
Command
|
||||||
.find_or_initialize_by(name: name.strip)
|
.find_or_initialize_by(name: name.strip)
|
||||||
.update!({
|
.update!(
|
||||||
name: name,
|
name: name,
|
||||||
description: description,
|
description: description,
|
||||||
default: default == 'cmd' ? nil : default,
|
default: default == 'cmd' ? nil : default,
|
||||||
datatype:
|
datatype:
|
||||||
if default == 'cmd'
|
if default.blank?
|
||||||
Datatype.find_by!(name: 'none')
|
Datatype.find_by!(name: 'none')
|
||||||
|
elsif default == 'cmd'
|
||||||
|
Datatype.find_by!(name: 'command')
|
||||||
else
|
else
|
||||||
Datatype
|
Datatype
|
||||||
.order(specifity: :desc)
|
.order(specifity: :desc)
|
||||||
.find{ |datatype|
|
.find{ |datatype| datatype.match? default } || raise(default)
|
||||||
datatype.match? default
|
|
||||||
} or raise(default)
|
|
||||||
end,
|
end,
|
||||||
})
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
(
|
||||||
|
Setup
|
||||||
|
.create!(name: 'test1')
|
||||||
|
.key_binds
|
||||||
|
.create!(
|
||||||
|
key: Key.find_by!(ingame: 'E'),
|
||||||
|
batch: Batch.create!(),
|
||||||
|
)
|
||||||
|
.batch
|
||||||
|
.actions
|
||||||
|
.create!(
|
||||||
|
actionable: Execution.create!(
|
||||||
|
command: Command.find_by!(
|
||||||
|
datatype: Datatype.find_by!(name: 'float'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue