This commit is contained in:
mwiegand 2022-11-27 19:23:31 +01:00
parent abf55c9af1
commit 34b1a009f2
No known key found for this signature in database
6 changed files with 26 additions and 18 deletions

View file

@ -3,8 +3,4 @@ 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

View file

@ -1,7 +1,6 @@
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 def execution
Execution.find(value) Execution.find(value)

View file

@ -3,10 +3,4 @@ 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

View file

@ -52,6 +52,7 @@ class CreateKeys < ActiveRecord::Migration[7.0]
t.string :name t.string :name
t.string :regex t.string :regex
t.integer :specifity t.integer :specifity
t.boolean :is_nestable, null: false
t.timestamps t.timestamps
end end

1
rails/db/schema.rb generated
View file

@ -43,6 +43,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_11_27_130223) do
t.string "name" t.string "name"
t.string "regex" t.string "regex"
t.integer "specifity" t.integer "specifity"
t.boolean "is_nestable", null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
end end

View file

@ -317,16 +317,32 @@ keys.each do |key|
end end
{ {
'none' => /^$/, 'none' => {
'command' => /^.*$/, regex: /^$/,
'string' => /^.*$/, is_nestable: true,
'integer' => /^\d+$/, },
'float' => /^\d+(?:\.\d+)|\.\d+$/, 'command' => {
}.each_with_index do |(name, regex), i| 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 Datatype
.find_or_initialize_by(name: name) .find_or_initialize_by(name: name)
.update!({ .update!({
regex: regex.to_s, regex: conf[:regex].to_s,
is_nestable: conf[:is_nestable],
specifity: i, specifity: i,
}) })
end end
@ -379,6 +395,7 @@ Setup
command: Command.find_by!( command: Command.find_by!(
datatype: Datatype.find_by!(name: 'float'), datatype: Datatype.find_by!(name: 'float'),
), ),
value: 2.0,
), ),
) )
) )