wip
This commit is contained in:
parent
abf55c9af1
commit
34b1a009f2
6 changed files with 26 additions and 18 deletions
|
@ -3,8 +3,4 @@ class Batch < ApplicationRecord
|
|||
has_many :menu_options
|
||||
has_many :wheel_options
|
||||
has_many :key_binds
|
||||
|
||||
def render
|
||||
actions.collect(&:render).join("; ")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class Execution < ApplicationRecord
|
||||
belongs_to :command
|
||||
has_many :actions
|
||||
has_one :execution, ->(o){Execution.find(o.value)}
|
||||
|
||||
def execution
|
||||
Execution.find(value)
|
||||
|
|
|
@ -3,10 +3,4 @@ class Setup < ApplicationRecord
|
|||
has_many :wheels
|
||||
has_many :menus
|
||||
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
|
||||
|
|
|
@ -52,6 +52,7 @@ class CreateKeys < ActiveRecord::Migration[7.0]
|
|||
t.string :name
|
||||
t.string :regex
|
||||
t.integer :specifity
|
||||
t.boolean :is_nestable, null: false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
|
|
1
rails/db/schema.rb
generated
1
rails/db/schema.rb
generated
|
@ -43,6 +43,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_11_27_130223) do
|
|||
t.string "name"
|
||||
t.string "regex"
|
||||
t.integer "specifity"
|
||||
t.boolean "is_nestable", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
|
|
@ -317,16 +317,32 @@ keys.each do |key|
|
|||
end
|
||||
|
||||
{
|
||||
'none' => /^$/,
|
||||
'command' => /^.*$/,
|
||||
'string' => /^.*$/,
|
||||
'integer' => /^\d+$/,
|
||||
'float' => /^\d+(?:\.\d+)|\.\d+$/,
|
||||
}.each_with_index do |(name, regex), i|
|
||||
'none' => {
|
||||
regex: /^$/,
|
||||
is_nestable: true,
|
||||
},
|
||||
'command' => {
|
||||
regex: /^.*$/,
|
||||
is_nestable: false,
|
||||
},
|
||||
'string' => {
|
||||
regex: /^.*$/,
|
||||
is_nestable: false,
|
||||
},
|
||||
'integer' => {
|
||||
regex: /^\d+$/,
|
||||
is_nestable: true,
|
||||
},
|
||||
'float' => {
|
||||
regex: /^\d+(?:\.\d+)|\.\d+$/,
|
||||
is_nestable: true,
|
||||
},
|
||||
}.each_with_index do |(name, conf), i|
|
||||
Datatype
|
||||
.find_or_initialize_by(name: name)
|
||||
.update!({
|
||||
regex: regex.to_s,
|
||||
regex: conf[:regex].to_s,
|
||||
is_nestable: conf[:is_nestable],
|
||||
specifity: i,
|
||||
})
|
||||
end
|
||||
|
@ -379,6 +395,7 @@ Setup
|
|||
command: Command.find_by!(
|
||||
datatype: Datatype.find_by!(name: 'float'),
|
||||
),
|
||||
value: 2.0,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue