diff --git a/.github/workflows/glualint.yml b/.github/workflows/glualint.yml new file mode 100644 index 0000000..8b5da9d --- /dev/null +++ b/.github/workflows/glualint.yml @@ -0,0 +1,17 @@ +name: GLuaLint + +on: + push: + branches: [ master ] + + pull_request: + branches: [ master ] + + # Allows running this workflow from the Actions tab + workflow_dispatch: + +jobs: + Lint: + uses: FPtje/GLuaFixer/.github/workflows/glualint.yml@master + with: + config: "./glualint.json" diff --git a/README.md b/README.md index f9edcb7..de9b8aa 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,27 @@ A playable keyboard for Garry's Mod +[![GLuaLint](https://github.com/StyledStrike/musical-keyboard/actions/workflows/glualint.yml/badge.svg)](https://github.com/FPtje/GLuaFixer) +[![Workshop Page](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-steam-workshop.jross.me%2F2656563609%2Fsubscriptions-text)](https://steamcommunity.com/sharedfiles/filedetails/?id=2656563609) + ### Features - Sheets - Multiple keyboard layouts - Many instruments in one entity +- Preserves the key press timings when heard by other players - MIDI support ([Module installation guide](https://steamcommunity.com/workshop/filedetails/discussion/2656563609/3199240042192880687/)) - Multi-language *(Help needed! Feel free to open a issue/pull request to add/update language files)* +![Demo](https://i.imgur.com/hD7VBq1.gif) + ### Notice All samples used on this project are part of freely available soundfonts. - **GeneralUser GS:** [Custom License](http://www.schristiancollins.com/generaluser.php) - **Alex's gm soundfont version 1.3:** [Creative Commons Attribution 3.0](https://musical-artifacts.com/artifacts/1390) -- **LMMS Presets:** (https://docs.lmms.io/user-manual/8-legal/8.1-license) \ No newline at end of file +- **LMMS Presets:** (https://docs.lmms.io/user-manual/8-legal/8.1-license) + +## Contributing + +Please follow the [CFC style guidelines](https://github.com/CFC-Servers/cfc_glua_style_guidelines) before opening pull requests. \ No newline at end of file diff --git a/glualint.json b/glualint.json index 7406feb..935db7c 100644 --- a/glualint.json +++ b/glualint.json @@ -1,37 +1,45 @@ { - "lint_maxScopeDepth": 8, - "lint_syntaxErrors": true, - "lint_syntaxInconsistencies": true, - "lint_deprecated": true, - "lint_trailingWhitespace": true, - "lint_whitespaceStyle": true, - "lint_beginnerMistakes": true, - "lint_emptyBlocks": true, - "lint_shadowing": true, - "lint_gotos": true, - "lint_goto_identifier": true, - "lint_doubleNegations": true, - "lint_redundantIfStatements": true, - "lint_redundantParentheses": true, - "lint_duplicateTableKeys": true, - "lint_profanity": true, - "lint_unusedVars": true, - "lint_unusedParameters": true, - "lint_unusedLoopVars": false, - "lint_inconsistentVariableStyle": false, - "lint_ignoreFiles": [], + "lint_maxScopeDepth": 7, + "lint_syntaxErrors": true, + "lint_syntaxInconsistencies": true, + "lint_deprecated": true, + "lint_trailingWhitespace": true, + "lint_whitespaceStyle": true, + "lint_beginnerMistakes": true, + "lint_emptyBlocks": true, + "lint_shadowing": true, + "lint_gotos": true, + "lint_goto_identifier": true, + "lint_doubleNegations": true, + "lint_redundantIfStatements": true, + "lint_redundantParentheses": true, + "lint_duplicateTableKeys": true, + "lint_profanity": true, + "lint_unusedVars": true, + "lint_unusedParameters": true, + "lint_unusedLoopVars": true, + "lint_inconsistentVariableStyle": false, + "lint_spaceBeforeComma": true, + "lint_spaceAfterComma": true, + "lint_spaceBetweenParens": true, + "lint_spaceBetweenBrackets": true, + "lint_spaceBetweenBraces": true, + "lint_ignoreFiles": ["**.lua"], - "prettyprint_spaceAfterParens": true, - "prettyprint_spaceAfterBrackets": false, - "prettyprint_spaceAfterBraces": false, - "prettyprint_spaceEmptyParens": false, - "prettyprint_spaceEmptyBraces": false, - "prettyprint_spaceAfterLabel": false, - "prettyprint_spaceBeforeComma": false, - "prettyprint_spaceAfterComma": true, - "prettyprint_semicolons": false, - "prettyprint_cStyle": false, - "prettyprint_rejectInvalidCode": false, - "prettyprint_indentation": "\t", - "log_format": "auto" + "prettyprint_spaceBetweenParens": true, + "prettyprint_spaceBetweenBrackets": false, + "prettyprint_spaceBetweenBraces": true, + "prettyprint_spaceAfterLabel": true, + "prettyprint_spaceBeforeComma": false, + "prettyprint_spaceAfterComma": true, + "prettyprint_semicolons": false, + "prettyprint_cStyle": false, + "prettyprint_rejectInvalidCode": false, + "prettyprint_spaceEmptyParens": false, + "prettyprint_spaceEmptyBraces": false, + "prettyprint_removeRedundantParens":true, + "prettyprint_minimizeParens": true, + "prettyprint_assumeOperatorAssociativity": true, + "prettyprint_indentation": " ", + "log_format": "auto" } \ No newline at end of file diff --git a/lua/autorun/sh_mkeyboard.lua b/lua/autorun/sh_mkeyboard.lua index 7d41d47..07377fb 100644 --- a/lua/autorun/sh_mkeyboard.lua +++ b/lua/autorun/sh_mkeyboard.lua @@ -1,34 +1,37 @@ MKeyboard = { - -- max. allowed number of notes per net event - NET_MAX_NOTES = 32, + -- max. allowed number of notes per net event + NET_MAX_NOTES = 32, - -- players need to be within this distance to receive net events - NET_BROADCAST_DISTANCE = 1500, + -- players need to be within this distance to receive net events + NET_BROADCAST_DISTANCE = 1500, - -- name/location of the settings file - SETTINGS_FILE = 'musical_keyboard.json' + -- name/location of the settings file + SETTINGS_FILE = 'musical_keyboard.json', + + -- URL for the midi installation guide + URL_MIDI_GUIDE = 'https://steamcommunity.com/workshop/filedetails/discussion/2656563609/3199240042192880687/' } if SERVER then - include('mkeyboard/sv_init.lua') + include( 'mkeyboard/sv_init.lua' ) - AddCSLuaFile('mkeyboard/cl_init.lua') - AddCSLuaFile('mkeyboard/cl_interface.lua') - AddCSLuaFile('mkeyboard/cl_midi.lua') + AddCSLuaFile( 'mkeyboard/cl_init.lua' ) + AddCSLuaFile( 'mkeyboard/cl_interface.lua' ) + AddCSLuaFile( 'mkeyboard/cl_midi.lua' ) - AddCSLuaFile('mkeyboard/data/instruments.lua') - AddCSLuaFile('mkeyboard/data/layouts.lua') - AddCSLuaFile('mkeyboard/data/sheets.lua') + AddCSLuaFile( 'mkeyboard/data/instruments.lua' ) + AddCSLuaFile( 'mkeyboard/data/layouts.lua' ) + AddCSLuaFile( 'mkeyboard/data/sheets.lua' ) end if CLIENT then - include('mkeyboard/cl_init.lua') - include('mkeyboard/cl_interface.lua') - include('mkeyboard/cl_midi.lua') + include( 'mkeyboard/cl_init.lua' ) + include( 'mkeyboard/cl_interface.lua' ) + include( 'mkeyboard/cl_midi.lua' ) - include('mkeyboard/data/instruments.lua') - include('mkeyboard/data/layouts.lua') - include('mkeyboard/data/sheets.lua') + include( 'mkeyboard/data/instruments.lua' ) + include( 'mkeyboard/data/layouts.lua' ) + include( 'mkeyboard/data/sheets.lua' ) - MKeyboard:LoadSettings() + MKeyboard:LoadSettings() end \ No newline at end of file diff --git a/lua/entities/ent_musical_keyboard/cl_init.lua b/lua/entities/ent_musical_keyboard/cl_init.lua index 5465615..599d3d9 100644 --- a/lua/entities/ent_musical_keyboard/cl_init.lua +++ b/lua/entities/ent_musical_keyboard/cl_init.lua @@ -1,81 +1,85 @@ -include('shared.lua') +include( 'shared.lua' ) -local function Fit(val, valMin, valMax, outMin, outMax) - return (val - valMin) * (outMax - outMin) / (valMax - valMin) + outMin +local function Fit( val, valMin, valMax, outMin, outMax ) + return ( val - valMin ) * ( outMax - outMin ) / ( valMax - valMin ) + outMin end local blackKeys = { - [1] = true, [3] = true, [6] = true, [8] = true, [10] = true + [1] = true, [3] = true, [6] = true, [8] = true, [10] = true } local keyColors = { - Color(255, 148, 77), - Color(171, 0, 197) + Color( 255, 148, 77 ), + Color( 171, 0, 197 ) } local offsetKeys = { - [2] = 0.2, - [4] = 0.4, - [5] = -0.1, - [7] = 0.1, - [9] = 0.4, - [11] = 0.6 + [2] = 0.2, + [4] = 0.4, + [5] = -0.1, + [7] = 0.1, + [9] = 0.4, + [11] = 0.6 } function ENT:Initialize() - self.drawNotes = {} + self.drawNotes = {} end -function ENT:EmitNote(note, velocity, level, instrument, automated) - local instr = MKeyboard.Instruments[instrument] +function ENT:EmitNote( note, velocity, level, instrument, automated ) + local instr = MKeyboard.instruments[instrument] - if not instr then return end - if note < instr.firstNote or note > instr.lastNote then return end + if not instr then return end + if note < instr.firstNote or note > instr.lastNote then return end - -- self:EmitSound(string.format(instr.path, note), level, 100, velocity / 127, CHAN_STATIC, 0) - sound.Play(string.format(instr.path, note), self:GetPos(), level, 100, velocity / 127) + sound.Play( string.format( instr.path, note ), self:GetPos(), level, 100, velocity / 127 ) - local idx = note % 12 - local len = 8 - local height = -0.2 - local width = 1.6 - local x = -1.1 + local idx = note % 12 + local len = 8 + local height = -0.2 + local width = 1.6 + local x = -1.1 - if blackKeys[idx] then - len = 5 - height = 0.1 - width = 1 - x = -0.6 - end + if blackKeys[idx] then + len = 5 + height = 0.1 + width = 1 + x = -0.6 + end - if offsetKeys[idx] then - x = x + offsetKeys[idx] - end + if offsetKeys[idx] then + x = x + offsetKeys[idx] + end - self.drawNotes[note] = { - x = Fit(note, 21, 108, -37, 36.7), - t = RealTime() + 0.2, - min = Vector(x, -1.5, -1), - max = Vector(x + width, len, height), - colorIdx = automated and 2 or 1 - } + self.drawNotes[note] = { + x = Fit( note, 21, 108, -37, 36.7 ), + t = RealTime() + 0.2, + min = Vector( x, -1.5, -1 ), + max = Vector( x + width, len, height ), + colorIdx = automated and 2 or 1 + } end function ENT:Draw() - self:DrawModel() + self:DrawModel() - local t = RealTime() - local ang = self:GetAngles() + local t = RealTime() + local ang = self:GetAngles() - render.SetColorMaterial() + render.SetColorMaterial() - for note, p in pairs(self.drawNotes) do - if t > p.t then - self.drawNotes[note] = nil - else - local clr = keyColors[p.colorIdx] - render.DrawBox(self:LocalToWorld( Vector(-p.x,0,0) ), ang, p.min, p.max, - Color(clr.r, clr.g, clr.b, 255 * ((p.t - t) / 0.2))) - end - end + for note, p in pairs( self.drawNotes ) do + if t > p.t then + self.drawNotes[note] = nil + else + local clr = keyColors[p.colorIdx] + local alpha = 255 * ( ( p.t - t ) / 0.2 ) + + render.DrawBox( + self:LocalToWorld( Vector( -p.x, 0, 0 ) ), + ang, p.min, p.max, + Color( clr.r, clr.g, clr.b, alpha ) + ) + end + end end \ No newline at end of file diff --git a/lua/entities/ent_musical_keyboard/init.lua b/lua/entities/ent_musical_keyboard/init.lua index 3fbb7af..a0e4f09 100644 --- a/lua/entities/ent_musical_keyboard/init.lua +++ b/lua/entities/ent_musical_keyboard/init.lua @@ -1,51 +1,51 @@ -AddCSLuaFile('cl_init.lua') -AddCSLuaFile('shared.lua') -include('shared.lua') +AddCSLuaFile( 'cl_init.lua' ) +AddCSLuaFile( 'shared.lua' ) +include( 'shared.lua' ) -function ENT:SpawnFunction(ply, tr) - if not tr.Hit then return end +function ENT:SpawnFunction( ply, tr ) + if not tr.Hit then return end - local ent = ents.Create(self.ClassName) - ent:SetPos(tr.HitPos) - ent:SetAngles(Angle(0, ply:EyeAngles().y + 90, 0)) - ent:Spawn() - ent:Activate() + local ent = ents.Create( self.ClassName ) + ent:SetPos( tr.HitPos ) + ent:SetAngles( Angle( 0, ply:EyeAngles().y + 90, 0 ) ) + ent:Spawn() + ent:Activate() - return ent + return ent end function ENT:Initialize() - self:SetModel('models/styledstrike/musical_keyboard.mdl') - self:PhysicsInit(SOLID_VPHYSICS) - self:SetMoveType(MOVETYPE_VPHYSICS) - self:SetSolid(SOLID_VPHYSICS) - self:SetUseType(SIMPLE_USE) - self:DrawShadow(true) + self:SetModel( 'models/styledstrike/musical_keyboard.mdl' ) + self:PhysicsInit( SOLID_VPHYSICS ) + self:SetMoveType( MOVETYPE_VPHYSICS ) + self:SetSolid( SOLID_VPHYSICS ) + self:SetUseType( SIMPLE_USE ) + self:DrawShadow( true ) - local phys = self:GetPhysicsObject() - if IsValid(phys) then phys:Wake() end + local phys = self:GetPhysicsObject() + if IsValid( phys ) then phys:Wake() end end -function ENT:Use(ply) - self:SetPlayer(ply) +function ENT:Use( ply ) + self:SetPlayer( ply ) end -function ENT:SetPlayer(ply) - if not IsValid(self.Ply) then - net.Start('mkeyboard.set_entity', false) - net.WriteEntity(self) - net.Send(ply) +function ENT:SetPlayer( ply ) + if not IsValid( self.Ply ) then + net.Start( 'mkeyboard.set_entity', false ) + net.WriteEntity( self ) + net.Send( ply ) - self.Ply = ply - end + self.Ply = ply + end end function ENT:RemovePlayer() - if IsValid(self.Ply) then - net.Start('mkeyboard.set_entity', false) - net.WriteEntity(nil) - net.Send(self.Ply) + if IsValid( self.Ply ) then + net.Start( 'mkeyboard.set_entity', false ) + net.WriteEntity( nil ) + net.Send( self.Ply ) - self.Ply = nil - end + self.Ply = nil + end end \ No newline at end of file diff --git a/lua/mkeyboard/cl_init.lua b/lua/mkeyboard/cl_init.lua index 1d16bbf..b2f09bc 100644 --- a/lua/mkeyboard/cl_init.lua +++ b/lua/mkeyboard/cl_init.lua @@ -6,350 +6,366 @@ MKeyboard.queueTimer = nil MKeyboard.queueStart = 0 MKeyboard.shiftMode = false -MKeyboard.noteState = {} +MKeyboard.noteStates = {} MKeyboard.blockInput = 0 -- settings & persistence -MKeyboard.Settings = { - layout = 1, - instrument = 1, - sheet = 0, - velocity = 127, - octave = 0, - midiTranspose = 0, +MKeyboard.settings = { + layout = 1, + instrument = 1, + sheet = 0, + velocity = 127, + octave = 0, + midiTranspose = 0, - channelInstruments = {}, - drawKeyLabels = true + channelInstruments = {}, + drawKeyLabels = true } local shortcuts = { - [KEY_TAB] = function() - RunConsoleCommand('keyboard_leave', MKeyboard.entity:EntIndex()) - end, + [KEY_TAB] = function() + RunConsoleCommand( 'keyboard_leave', MKeyboard.entity:EntIndex() ) + end, - [KEY_SPACE] = function() - MKeyboard.HUD:ToggleExpandedBar() - end, + [KEY_SPACE] = function() + MKeyboard.uiHandler:ToggleExpandedBar() + end, - [KEY_LEFT] = function() - MKeyboard.HUD:ChangeInstrument(-1) - end, + [KEY_LEFT] = function() + MKeyboard.uiHandler:ChangeInstrument( -1 ) + end, - [KEY_RIGHT] = function() - MKeyboard.HUD:ChangeInstrument(1) - end, + [KEY_RIGHT] = function() + MKeyboard.uiHandler:ChangeInstrument( 1 ) + end, - [KEY_UP] = function() - MKeyboard.HUD:AddOctave(1) - end, + [KEY_UP] = function() + MKeyboard.uiHandler:AddOctave( 1 ) + end, - [KEY_DOWN] = function() - MKeyboard.HUD:AddOctave(-1) - end + [KEY_DOWN] = function() + MKeyboard.uiHandler:AddOctave( -1 ) + end } local dontBlockBinds = { - ['+attack'] = true, - ['+attack2'] = true, - ['+duck'] = true + ['+attack'] = true, + ['+attack2'] = true, + ['+duck'] = true } -local function ValidateInteger(n, min, max) - return math.Round(math.Clamp(tonumber(n), min, max)) +local function validateInteger( n, min, max ) + return math.Round( math.Clamp( tonumber( n ), min, max ) ) end function MKeyboard:LoadSettings() - local rawData = file.Read(self.SETTINGS_FILE, 'DATA') - if rawData == nil then return end + local rawData = file.Read( self.SETTINGS_FILE, 'DATA' ) + if rawData == nil then return end - local data = util.JSONToTable(rawData) or {} - local nInstruments = #self.Instruments + local data = util.JSONToTable( rawData ) or {} + local instrumentCount = #self.instruments - -- last layout that was used on the keyboard - if data.layout then - self.Settings.layout = ValidateInteger(data.layout, 1, #self.Layouts) - end + -- last layout that was used on the keyboard + if data.layout then + self.settings.layout = validateInteger( data.layout, 1, #self.layouts ) + end - -- last instrument that was used on the keyboard - if data.instrument then - self.Settings.instrument = ValidateInteger(data.instrument, 1, nInstruments) - end + -- last instrument that was used on the keyboard + if data.instrument then + self.settings.instrument = validateInteger( data.instrument, 1, instrumentCount ) + end - -- last selected sheet - if data.sheet then - self.Settings.sheet = ValidateInteger(data.sheet, 0, #self.Sheets) - end + -- last selected sheet + if data.sheet then + self.settings.sheet = validateInteger( data.sheet, 0, #self.sheets ) + end - -- last velocity set by the settings - if data.velocity then - self.Settings.velocity = ValidateInteger(data.velocity, 1, 127) - end + -- last velocity set by the settings + if data.velocity then + self.settings.velocity = validateInteger( data.velocity, 1, 127 ) + end - -- last octave that was used on the keyboard - if data.octave then - self.Settings.octave = ValidateInteger(data.octave, -3, 3) - end + -- last octave that was used on the keyboard + if data.octave then + self.settings.octave = validateInteger( data.octave, -3, 3 ) + end - -- last transpose that was used with midi - if data.midiTranspose then - self.Settings.midiTranspose = ValidateInteger(data.midiTranspose, -48, 48) - end + -- last transpose that was used with midi + if data.midiTranspose then + self.settings.midiTranspose = validateInteger( data.midiTranspose, -48, 48 ) + end - -- links between instruments and MIDI channels - if data.channelInstruments and type(data.channelInstruments) == 'table' then - for c, i in pairs(data.channelInstruments) do - local channel = ValidateInteger(c, 0, 15) - local instrument = ValidateInteger(i, 1, nInstruments) + -- links between instruments and MIDI channels + if data.channelInstruments and type( data.channelInstruments ) == 'table' then + for c, i in pairs( data.channelInstruments ) do + local channel = validateInteger( c, 0, 15 ) + local instrument = validateInteger( i, 1, instrumentCount ) - self.Settings.channelInstruments[channel] = instrument - end - end + self.settings.channelInstruments[channel] = instrument + end + end - -- draw labels for keys - self.Settings.drawKeyLabels = Either(isbool(data.drawKeyLabels), tobool(data.drawKeyLabels), true) + -- draw labels for keys + self.settings.drawKeyLabels = Either( isbool( data.drawKeyLabels ), tobool( data.drawKeyLabels ), true ) end function MKeyboard:SaveSettings() - local s = self.Settings + local s = self.settings - file.Write(self.SETTINGS_FILE, util.TableToJSON({ - layout = s.layout, - instrument = s.instrument, - sheet = s.sheet, - velocity = s.velocity, - octave = s.octave, - midiTranspose = s.midiTranspose, - channelInstruments = s.channelInstruments, - drawKeyLabels = s.drawKeyLabels - }, true)) + file.Write( + self.SETTINGS_FILE, + util.TableToJSON( { + layout = s.layout, + instrument = s.instrument, + sheet = s.sheet, + velocity = s.velocity, + octave = s.octave, + midiTranspose = s.midiTranspose, + channelInstruments = s.channelInstruments, + drawKeyLabels = s.drawKeyLabels + }, true ) + ) end -function MKeyboard:Init(ent) - self.entity = ent - self.blockInput = RealTime() + 0.3 +function MKeyboard:Init( ent ) + self.entity = ent + self.blockInput = RealTime() + 0.3 - self.HUD:Init() + self.uiHandler:Init() - hook.Add('Think', 'mkeyboard_Think', function() - self:Think() - end) + hook.Add( 'Think', 'mkeyboard_ProcessLocalKeyboard', function() + self:Think() + end ) - hook.Add('PlayerButtonDown', 'mkeyboard_PlayerButtonDown', function(ply, button) - if ply == LocalPlayer() and IsFirstTimePredicted() then - self:OnButton(button, true) - end - end) + hook.Add( 'PlayerButtonDown', 'mkeyboard_LocalButtonPress', function( ply, button ) + if ply == LocalPlayer() and IsFirstTimePredicted() then + self:OnButton( button, true ) + end + end ) - hook.Add('PlayerButtonUp', 'mkeyboard_PlayerButtonUp', function(ply, button) - if ply == LocalPlayer() and IsFirstTimePredicted() then - self:OnButton(button, false) - end - end) + hook.Add( 'PlayerButtonUp', 'mkeyboard_LocalButtonRelease', function( ply, button ) + if ply == LocalPlayer() and IsFirstTimePredicted() then + self:OnButton( button, false ) + end + end ) - hook.Add('PlayerBindPress', 'mkeyboard_PlayerBindPress', function(_, bind) - if not dontBlockBinds[bind] then return true end - end) + hook.Add( 'PlayerBindPress', 'mkeyboard_BlockBinds', function( _, bind ) + if not dontBlockBinds[bind] then return true end + end ) - -- Custom Chat compatibility - hook.Add('BlockChatInput', 'mkeyboard_BlockChatInput', function() - return true - end) + -- Custom Chat compatibility + hook.Add( 'BlockChatInput', 'mkeyboard_PreventOpeningChat', function() + return true + end ) end function MKeyboard:Shutdown() - self.entity = nil + self.entity = nil - self.transmitQueue = {} - self.queueTimer = nil + self.transmitQueue = {} + self.queueTimer = nil - self.shiftMode = false - self.noteState = {} + self.shiftMode = false + self.noteStates = {} - self.MIDI:Close() - self.HUD:Shutdown() + self.midiHandler:Close() + self.uiHandler:Shutdown() - hook.Remove('Think', 'mkeyboard_Think') - hook.Remove('PlayerButtonDown', 'mkeyboard_PlayerButtonDown') - hook.Remove('PlayerButtonUp', 'mkeyboard_PlayerButtonUp') - hook.Remove('PlayerBindPress', 'mkeyboard_PlayerBindPress') - hook.Remove('BlockChatInput', 'mkeyboard_BlockChatInput') + hook.Remove( 'Think', 'mkeyboard_ProcessLocalKeyboard' ) + hook.Remove( 'PlayerButtonDown', 'mkeyboard_LocalButtonPress' ) + hook.Remove( 'PlayerButtonUp', 'mkeyboard_LocalButtonRelease' ) + hook.Remove( 'PlayerBindPress', 'mkeyboard_BlockBinds' ) + hook.Remove( 'BlockChatInput', 'mkeyboard_PreventOpeningChat' ) end -function MKeyboard:NoteOn(note, velocity, isMidi, midiChannel) - local instrument = self.Settings.instrument +function MKeyboard:NoteOn( note, velocity, isMidi, midiChannel ) + local instrument = self.settings.instrument - if midiChannel then - self.HUD.channelState[midiChannel] = 1 - instrument = self.Settings.channelInstruments[midiChannel] or instrument + if midiChannel then + self.uiHandler.channelState[midiChannel] = 1 + instrument = self.settings.channelInstruments[midiChannel] or instrument - if instrument == 0 then return end - end + if instrument == 0 then return end + end - local instr = self.Instruments[instrument] - if note < instr.firstNote or note > instr.lastNote then return end + local instr = self.instruments[instrument] + if note < instr.firstNote or note > instr.lastNote then return end - self.entity:EmitNote(note, velocity, 80, instrument, isMidi) + self.entity:EmitNote( note, velocity, 80, instrument, isMidi ) - self.noteState[note] = isMidi and 4 or 3 -- see themeColors on cl_interface.lua - self.lastNoteWasAutomated = isMidi + self.noteStates[note] = isMidi and 'midi' or 'on' + self.lastNoteWasAutomated = isMidi - -- remember when we started putting notes - -- on the queue, and when we should send them - local t = SysTime() + -- remember when we started putting notes + -- on the queue, and when we should send them + local t = SysTime() - if not self.queueTimer then - self.queueTimer = t + 0.4 - self.queueStart = t - end + if not self.queueTimer then + self.queueTimer = t + 0.4 + self.queueStart = t + end - -- add notes to the queue unless the limit is was reached - local noteCount = #self.transmitQueue - if noteCount < self.NET_MAX_NOTES then - self.transmitQueue[noteCount + 1] = { note, velocity, instrument, t - self.queueStart } - end + -- add notes to the queue unless the limit is was reached + local noteCount = #self.transmitQueue + if noteCount < self.NET_MAX_NOTES then + self.transmitQueue[noteCount + 1] = { note, velocity, instrument, t - self.queueStart } + end end -function MKeyboard:NoteOff(note) - self.noteState[note] = nil +function MKeyboard:NoteOff( note ) + self.noteStates[note] = nil end function MKeyboard:NoteOffAll() - for k, _ in pairs(self.noteState) do - self.noteState[k] = nil - end + for k, _ in pairs( self.noteStates ) do + self.noteStates[k] = nil + end end function MKeyboard:ReproduceQueue() - local t = SysTime() + local t = SysTime() - -- play the networked notes, keeping the original timings - for time, data in pairs(self.reproduceQueue) do - if t > time then - if IsValid(data[1]) then - data[1]:EmitNote(data[2], data[3], 80, data[4], data[5]) - end + -- play the networked notes, keeping the original timings + for time, data in pairs( self.reproduceQueue ) do + if t > time then + if IsValid( data[1] ) then + data[1]:EmitNote( data[2], data[3], 80, data[4], data[5] ) + end - self.reproduceQueue[time] = nil - end - end + self.reproduceQueue[time] = nil + end + end end function MKeyboard:TransmitQueue() - net.Start('mkeyboard.notes', false) - net.WriteEntity(self.entity) - net.WriteBool(self.lastNoteWasAutomated) - net.WriteUInt(#self.transmitQueue, 5) + net.Start( 'mkeyboard.notes', false ) + net.WriteEntity( self.entity ) + net.WriteBool( self.lastNoteWasAutomated ) + net.WriteUInt( #self.transmitQueue, 5 ) - for _, params in ipairs(self.transmitQueue) do - net.WriteUInt(params[1], 7) -- note - net.WriteUInt(params[2], 7) -- velocity - net.WriteUInt(params[3], 6) -- instrument - net.WriteFloat(params[4]) -- time offset - end + for _, params in ipairs( self.transmitQueue ) do + net.WriteUInt( params[1], 7 ) -- note + net.WriteUInt( params[2], 7 ) -- velocity + net.WriteUInt( params[3], 6 ) -- instrument + net.WriteFloat( params[4] ) -- time offset + end - net.SendToServer() + net.SendToServer() - table.Empty(self.transmitQueue) - self.queueTimer = nil + table.Empty( self.transmitQueue ) + self.queueTimer = nil end function MKeyboard:Think() - if not IsValid(self.entity) then - self:Shutdown() - return - end + if not IsValid( self.entity ) then + self:Shutdown() - self.MIDI:Think() + return + end - local t = SysTime() + self.midiHandler:Think() - -- if the queued notes are ready to be sent... - if self.queueTimer and t > self.queueTimer then - self:TransmitQueue() - end + local t = SysTime() + + -- if the queued notes are ready to be sent... + if self.queueTimer and t > self.queueTimer then + self:TransmitQueue() + end end -function MKeyboard:OnButton(button, isPressed) - if button == KEY_LSHIFT then - self.shiftMode = isPressed - end +function MKeyboard:OnButton( button, isPressed ) + if button == KEY_LSHIFT then + self.shiftMode = isPressed + end - -- process shortcuts - if shortcuts[button] and not isPressed then - shortcuts[button]() - return - end + -- process shortcuts + if shortcuts[button] and not isPressed then + shortcuts[button]() + return + end - if self.blockInput > RealTime() then return end + if self.blockInput > RealTime() then return end - local layoutKeys = self.Layouts[self.Settings.layout].keys + local layoutKeys = self.layouts[self.settings.layout].keys - -- process layout keys - for idx, params in ipairs(layoutKeys) do - -- params: key [1], note [2], type [3], label [4], require SHIFT [5], alternative key [6] + -- process layout keys + for _, params in ipairs( layoutKeys ) do + --[[ params: + key [1], + note [2], + type [3], + label [4], + require SHIFT [5], + alternative key [6] + ]] - if params[1] == button or (params[6] and params[6] == button) then - local note = params[2] + self.Settings.octave * 12 + -- if either the "main" or "alternative" buttons are pressed for this key... + if params[1] == button or ( params[6] and params[6] == button ) then + local note = params[2] + self.settings.octave * 12 - if isPressed then - if params[5] and self.shiftMode then - self:NoteOn(note, self.Settings.velocity, false) - break - end + if isPressed then + -- if this key requires shift and shift is pressed... + if params[5] and self.shiftMode then + self:NoteOn( note, self.settings.velocity, false ) + break + end - if not params[5] and not self.shiftMode then - self:NoteOn(note, self.Settings.velocity, false) - break - end - else - self:NoteOff(note) - end - end - end + -- if this key does NOT require shift and shift is NOT pressed... + if not params[5] and not self.shiftMode then + self:NoteOn( note, self.settings.velocity, false ) + break + end + else + self:NoteOff( note ) + end + end + end end -hook.Add('Think', 'mkeyboard_OffscreenThink', function() - MKeyboard:ReproduceQueue() -end) +hook.Add( 'Think', 'mkeyboard_ProcessReproductionQueue', function() + MKeyboard:ReproduceQueue() +end ) -net.Receive('mkeyboard.set_entity', function() - local ent = net.ReadEntity() +net.Receive( 'mkeyboard.set_entity', function() + local ent = net.ReadEntity() - MKeyboard:Shutdown() + MKeyboard:Shutdown() - if IsValid(ent) then - MKeyboard:Init(ent) - end -end) + if IsValid( ent ) then + MKeyboard:Init( ent ) + end +end ) -net.Receive('mkeyboard.notes', function() - local ent = net.ReadEntity() - if not IsValid(ent) or not ent.EmitNote then return end +net.Receive( 'mkeyboard.notes', function() + local ent = net.ReadEntity() + if not IsValid( ent ) or not ent.EmitNote then return end - local automated = net.ReadBool() - local noteCount = net.ReadUInt(5) - local note, vel, instr, timeOffset + local automated = net.ReadBool() + local noteCount = net.ReadUInt( 5 ) + local note, vel, instr, timeOffset - local t = SysTime() + local t = SysTime() + local i = 1 - for i = 1, noteCount do - note = net.ReadUInt(7) - vel = net.ReadUInt(7) - instr = net.ReadUInt(6) - timeOffset = net.ReadFloat() + while i < noteCount do + note = net.ReadUInt( 7 ) + vel = net.ReadUInt( 7 ) + instr = net.ReadUInt( 6 ) + timeOffset = net.ReadFloat() - MKeyboard.reproduceQueue[t + timeOffset] = { ent, note, vel, instr, automated } - end -end) + MKeyboard.reproduceQueue[t + timeOffset] = { ent, note, vel, instr, automated } + i = i + 1 + end +end ) --- net event that only runs on single-player +-- key press/release net event that only runs on single-player if game.SinglePlayer() then - net.Receive('mkeyboard.key', function() - local button = net.ReadUInt(8) - local pressed = net.ReadBool() + net.Receive( 'mkeyboard.key', function() + local button = net.ReadUInt( 8 ) + local pressed = net.ReadBool() - if IsValid(MKeyboard.entity) then - MKeyboard:OnButton(button, pressed) - end - end) + if IsValid( MKeyboard.entity ) then + MKeyboard:OnButton( button, pressed ) + end + end ) end \ No newline at end of file diff --git a/lua/mkeyboard/cl_interface.lua b/lua/mkeyboard/cl_interface.lua index 99a0717..25b4393 100644 --- a/lua/mkeyboard/cl_interface.lua +++ b/lua/mkeyboard/cl_interface.lua @@ -1,705 +1,719 @@ -surface.CreateFont('MKeyboard_Title', { - size = ScrH() * 0.025, weight = 300, antialias = true, font = 'Coolvetica' -}) +surface.CreateFont( 'MKeyboard_Title', { + size = ScrH() * 0.025, weight = 300, antialias = true, font = 'Coolvetica' +} ) -surface.CreateFont('MKeyboard_Key', { - size = ScrH() * 0.02, weight = 300, antialias = true, font = 'Coolvetica' -}) +surface.CreateFont( 'MKeyboard_Key', { + size = ScrH() * 0.02, weight = 300, antialias = true, font = 'Coolvetica' +} ) -surface.CreateFont('MKeyboard_Sheet', { - size = ScrH() * 0.022, antialias = true, font = 'Roboto' -}) +surface.CreateFont( 'MKeyboard_Sheet', { + size = ScrH() * 0.022, antialias = true, font = 'Roboto' +} ) local setDrawColor = surface.SetDrawColor local drawRect = surface.DrawRect local simpleText = draw.SimpleText local roundedBoxEx = draw.RoundedBoxEx local langGet = language.GetPhrase +local ScrW = ScrW -local themeColors = { - [1] = Color(0, 0, 0, 255), - [2] = Color(255, 255, 255, 255), - [3] = Color(245, 163, 108), - [4] = Color(196, 0, 226), - [5] = Color(120, 120, 120, 255), - [6] = Color(0, 0, 0, 240) +local colors = { + black = Color( 0, 0, 0, 255 ), + white = Color( 255, 255, 255, 255 ), + gray = Color( 120, 120, 120, 255 ), + accent1 = Color( 245, 163, 108 ), + accent2 = Color( 196, 0, 226 ), + bg = Color( 0, 0, 0, 240 ) } -local HUD = { - expanded = false, - openPortName = nil, - channelState = {}, - whiteKeyCount = 0 +local uiHandler = { + expanded = false, + openPortName = nil, + channelState = {}, + whiteKeyCount = 0 } -MKeyboard.HUD = HUD +local MKeyboard = MKeyboard +local settings = MKeyboard.settings + +MKeyboard.uiHandler = uiHandler -- register a "Button" type for DProperties local DPropertyButton = {} function DPropertyButton:Init() end -function DPropertyButton:Setup(label) - self:Clear() +function DPropertyButton:Setup( label ) + self:Clear() - label = label or '' + label = label or '' - local btn = self:Add('DButton') - btn:Dock(FILL) - btn:SetText(label) + local btn = self:Add( 'DButton' ) + btn:Dock( FILL ) + btn:SetText( label ) - self.IsEditing = function() - return false - end + self.IsEditing = function() + return false + end - self.SetEnabled = function(_, b) - btn:SetEnabled(b) - end + self.SetEnabled = function( _, b ) + btn:SetEnabled( b ) + end - self.SetValue = function(_, val) - btn:SetText(val) - end + self.SetValue = function( _, val ) + btn:SetText( val ) + end - btn.DoClick = function() - self.m_pRow:OnClick() - end + btn.DoClick = function() + self.m_pRow:OnClick() + end end -derma.DefineControl('DProperty_Button', '', DPropertyButton, 'DProperty_Generic') +derma.DefineControl( 'DProperty_Button', '', DPropertyButton, 'DProperty_Generic' ) -local function drawKey(x, y, w, h, state, label, label2, rounded) - local color = themeColors[state] +local keyStateColors = { + -- state = background color + disabled = colors.gray, + off_white = colors.white, + off_black = colors.black, + on = colors.accent1, + midi = colors.accent2 +} - if rounded then - roundedBoxEx(4, x, y, w, h, color, false, false, true, true) - else - setDrawColor(color.r, color.g, color.b, 255) - drawRect(x, y, w, h) - end +local function drawKey( x, y, w, h, state, label, sublabel, rounded ) + if rounded then + roundedBoxEx( 4, x, y, w, h, keyStateColors[state], false, false, true, true ) + else + setDrawColor( keyStateColors[state]:Unpack() ) + drawRect( x, y, w, h ) + end - if not MKeyboard.Settings.drawKeyLabels then return end + if not settings.drawKeyLabels then return end - local labelColor = themeColors[ (state == 1) and 2 or 1 ] + local labelColor = rounded and colors.white or colors.black - if label then - simpleText(label, 'MKeyboard_Key', x + (w * 0.5), y + h - 2, - labelColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM) - end + if label then + simpleText( label, 'MKeyboard_Key', x + ( w * 0.5 ), y + h - 2, labelColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM ) + end - if label2 then - simpleText(label2, 'MKeyboard_Key', x + (w * 0.5), y + h - 22, - labelColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM) - end + if sublabel then + simpleText( sublabel, 'MKeyboard_Key', x + ( w * 0.5 ), y + h - 22, labelColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM ) + end end -local function drawKeyboard(x, y, h) - local keyWidth = math.ceil(ScrW() * 0.018) - local borderSize = math.ceil(ScrW() * 0.002) - local infoSize = math.ceil(ScrW() * 0.016) +local function drawKeyboard( x, y, h ) + local keyWidth = math.ceil( ScrW() * 0.018 ) + local borderSize = math.ceil( ScrW() * 0.002 ) + local infoSize = math.ceil( ScrW() * 0.016 ) - local w = keyWidth * HUD.whiteKeyCount - x = x - w * 0.5 + local w = keyWidth * uiHandler.whiteKeyCount + x = x - w * 0.5 - setDrawColor(0, 0, 0, 240) - drawRect(x - borderSize, y - infoSize - borderSize, w + borderSize * 2, h + infoSize + borderSize * 2) + setDrawColor( 0, 0, 0, 240 ) + drawRect( x - borderSize, y - infoSize - borderSize, w + borderSize * 2, h + infoSize + borderSize * 2 ) - local layoutData = MKeyboard.Layouts[MKeyboard.Settings.layout] - local instrumentData = MKeyboard.Instruments[MKeyboard.Settings.instrument] - local octave = MKeyboard.Settings.octave + local layoutData = MKeyboard.layouts[settings.layout] + local instrumentData = MKeyboard.instruments[settings.instrument] + local octave = settings.octave - if octave ~= 0 then - surface.SetFont('MKeyboard_Key') - local offsetX = surface.GetTextSize(layoutData.name) + if octave ~= 0 then + surface.SetFont( 'MKeyboard_Key' ) + local offsetX = surface.GetTextSize( layoutData.name ) - surface.SetTextPos(x + offsetX + borderSize * 2, y - infoSize + borderSize) - surface.SetTextColor(255, 208, 22) - surface.DrawText(octave > 0 and '+' .. octave or octave) - end + surface.SetTextPos( x + offsetX + borderSize * 2, y - infoSize + borderSize ) + surface.SetTextColor( 255, 208, 22 ) + surface.DrawText( octave > 0 and '+' .. octave or octave ) + end - simpleText(layoutData.name, 'MKeyboard_Key', x + borderSize, y - infoSize + borderSize, themeColors[2]) - simpleText(instrumentData.name, 'MKeyboard_Key', - x + w - borderSize, y - infoSize + borderSize, themeColors[2], TEXT_ALIGN_RIGHT) + simpleText( layoutData.name, 'MKeyboard_Key', x + borderSize, y - infoSize + borderSize, colors.white ) + simpleText( instrumentData.name, 'MKeyboard_Key', x + w - borderSize, y - infoSize + borderSize, colors.white, TEXT_ALIGN_RIGHT ) - local noteOffset = octave * 12 - local noteState = MKeyboard.noteState - local minNote = instrumentData.firstNote - local maxNote = instrumentData.lastNote + local noteOffset = octave * 12 + local noteStates = MKeyboard.noteStates + local minNote = instrumentData.firstNote + local maxNote = instrumentData.lastNote - -- draw the white keys - local whiteKeyBorder = math.ceil(ScrW() * 0.0004) - local keyX = x + -- draw the white keys + local whiteKeyBorder = math.ceil( ScrW() * 0.0004 ) + local keyX = x - for _, params in ipairs(layoutData.keys) do - if params[3] == 'b' then continue end + for _, params in ipairs( layoutData.keys ) do + if params[3] == 'b' then continue end - local note = params[2] + noteOffset - local state = noteState[note] + local note = params[2] + noteOffset + local state = noteStates[note] - if note < minNote or note > maxNote then - drawKey(keyX + whiteKeyBorder, y, keyWidth - whiteKeyBorder * 2, h, 5) - elseif state then - drawKey(keyX + whiteKeyBorder, y, keyWidth - whiteKeyBorder * 2, h, state, params[4], params[7]) - else - drawKey(keyX + whiteKeyBorder, y, keyWidth - whiteKeyBorder * 2, h, 2, params[4], params[7]) - end + if note < minNote or note > maxNote then + drawKey( keyX + whiteKeyBorder, y, keyWidth - whiteKeyBorder * 2, h, 'disabled' ) + elseif state then + drawKey( keyX + whiteKeyBorder, y, keyWidth - whiteKeyBorder * 2, h, state, params[4], params[7] ) + else + drawKey( keyX + whiteKeyBorder, y, keyWidth - whiteKeyBorder * 2, h, 'off_white', params[4], params[7] ) + end - keyX = keyX + keyWidth - end + keyX = keyX + keyWidth + end - -- draw the black keys - keyX = x - local bWidth, bHeight = keyWidth * 0.6, h * 0.64 + -- draw the black keys + keyX = x + local bWidth, bHeight = keyWidth * 0.6, h * 0.64 - for _, params in ipairs(layoutData.keys) do - if params[3] == 'w' then - keyX = keyX + keyWidth - continue - end + for _, params in ipairs( layoutData.keys ) do + if params[3] == 'w' then + keyX = keyX + keyWidth + continue + end - local note = params[2] + noteOffset - local state = noteState[note] + local note = params[2] + noteOffset + local state = noteStates[note] - if note < minNote or note > maxNote then - drawKey(keyX - (bWidth * 0.5), y, bWidth, bHeight, 5) - elseif state then - drawKey(keyX - (bWidth * 0.5), y, bWidth, bHeight, state, params[4], params[7], true) - else - drawKey(keyX - (bWidth * 0.5), y, bWidth, bHeight, 1, params[4], params[7], true) - end - end + if note < minNote or note > maxNote then + drawKey( keyX - ( bWidth * 0.5 ), y, bWidth, bHeight, 'disabled' ) + elseif state then + drawKey( keyX - ( bWidth * 0.5 ), y, bWidth, bHeight, state, params[4], params[7], true ) + else + drawKey( keyX - ( bWidth * 0.5 ), y, bWidth, bHeight, 'off_black', params[4], params[7], true ) + end + end end -local function drawSheet(sheet, x, y) - local oldClipping = DisableClipping(true) - local borderSize = math.ceil(ScrW() * 0.002) - local titleBarSize = ScrH() * 0.028 - local sheetData = MKeyboard.Sheets[sheet] +local function drawSheet( index, x, y ) + local borderSize = math.ceil( ScrW() * 0.002 ) + local titleBarSize = ScrH() * 0.028 + local data = MKeyboard.sheets[index] - surface.SetFont('MKeyboard_Sheet') + surface.SetFont( 'MKeyboard_Sheet' ) - local sheetW, sheetH = surface.GetTextSize(sheetData.sequence) - local w, h = math.max(ScrW() * 0.3, sheetW + borderSize * 2), sheetH + titleBarSize * 0.5 + local sheetW, sheetH = surface.GetTextSize( data.sequence ) + local w, h = math.max( ScrW() * 0.3, sheetW + borderSize * 2 ), sheetH + titleBarSize * 0.5 + local oldClipping = DisableClipping( true ) - x = x - w * 0.5 - y = y - h + x = x - w * 0.5 + y = y - h - setDrawColor(0, 0, 0, 254) - drawRect(x, y, w, h) + setDrawColor( 0, 0, 0, 254 ) + drawRect( x, y, w, h ) - draw.DrawText(sheetData.sequence,'MKeyboard_Sheet', x + w * 0.5, y + titleBarSize, nil, TEXT_ALIGN_CENTER) - simpleText(sheetData.title, 'MKeyboard_Title', x + w * 0.5, y + borderSize, themeColors[2], TEXT_ALIGN_CENTER) + draw.DrawText( data.sequence, 'MKeyboard_Sheet', x + w * 0.5, y + titleBarSize, nil, TEXT_ALIGN_CENTER ) + simpleText( data.title, 'MKeyboard_Title', x + w * 0.5, y + borderSize, colors.white, TEXT_ALIGN_CENTER ) - DisableClipping(oldClipping) + DisableClipping( oldClipping ) end -local function createCategoryPanel(title, parent, dock, wide, help) - local dockPadding = ScrH() * 0.01 - local dSkin = derma.GetDefaultSkin() +local function createCategoryPanel( title, parent, dock, wide, help ) + local dockPadding = ScrH() * 0.01 + local dSkin = derma.GetDefaultSkin() - local pnl = vgui.Create('DPanel', parent) - pnl:DockPadding(dockPadding, dockPadding, dockPadding, dockPadding) - pnl:Dock(dock) + local pnl = vgui.Create( 'DPanel', parent ) + pnl:DockPadding( dockPadding, dockPadding, dockPadding, dockPadding ) + pnl:Dock( dock ) - if wide then - pnl:SetWide(wide) - end + if wide then + pnl:SetWide( wide ) + end - pnl.oldPaint = pnl.Paint + pnl.oldPaint = pnl.Paint - pnl.Paint = function(s, sw, sh) - s.oldPaint(s, sw - 4, sh) - end + pnl.Paint = function( s, sw, sh ) + s.oldPaint( s, sw - 4, sh ) + end - local pnlHeader = vgui.Create('DPanel', pnl) - pnlHeader:Dock(TOP) - pnlHeader:SetPaintBackground(false) + local pnlHeader = vgui.Create( 'DPanel', pnl ) + pnlHeader:Dock( TOP ) + pnlHeader:SetPaintBackground( false ) - local lblTitle = vgui.Create('DLabel', pnlHeader) - lblTitle:SetFont('MKeyboard_Key') - lblTitle:SetText(title) - lblTitle:SizeToContents() - lblTitle:Dock(LEFT) - lblTitle:SetTextColor(dSkin.Colours.Label.Dark) + local lblTitle = vgui.Create( 'DLabel', pnlHeader ) + lblTitle:SetFont( 'MKeyboard_Key' ) + lblTitle:SetText( title ) + lblTitle:SizeToContents() + lblTitle:Dock( LEFT ) + lblTitle:SetTextColor( dSkin.Colours.Label.Dark ) - if help then - local lblHelp = vgui.Create('DLabel', pnlHeader) - lblHelp:SetFont('MKeyboard_Key') - lblHelp:SetText(help) - lblHelp:SizeToContents() - lblHelp:Dock(RIGHT) - lblHelp:SetTextColor(dSkin.Colours.Label.Dark) - end + if help then + local lblHelp = vgui.Create( 'DLabel', pnlHeader ) + lblHelp:SetFont( 'MKeyboard_Key' ) + lblHelp:SetText( help ) + lblHelp:SizeToContents() + lblHelp:Dock( RIGHT ) + lblHelp:SetTextColor( dSkin.Colours.Label.Dark ) + end - return pnl + return pnl end -function HUD:Init() - if not MKeyboard.MIDI.selectedPort and midi then - self:ShowDevicesDialog() - end +function uiHandler:Init() + if not MKeyboard.midiHandler.selectedPort and midi then + self:ShowDevicesDialog() + end - local wide = ScrW() * 0.7 - local tall = ScrH() * 0.5 + local wide = ScrW() * 0.7 + local tall = ScrH() * 0.5 - self.frameKeyboard = vgui.Create('DFrame') - self.frameKeyboard:SetPos((ScrW() - wide) * 0.5, ScrH() - tall * 0.5) - self.frameKeyboard:SetSize(wide, tall) - self.frameKeyboard:SetTitle('') - self.frameKeyboard:SetDeleteOnClose(true) - self.frameKeyboard:SetDraggable(false) - self.frameKeyboard:SetSizable(false) - self.frameKeyboard:ShowCloseButton(false) - self.frameKeyboard:LerpPositions(1, true) + self.frameKeyboard = vgui.Create( 'DFrame' ) + self.frameKeyboard:SetPos( ( ScrW() - wide ) * 0.5, ScrH() - tall * 0.5 ) + self.frameKeyboard:SetSize( wide, tall ) + self.frameKeyboard:SetTitle( '' ) + self.frameKeyboard:SetDeleteOnClose( true ) + self.frameKeyboard:SetDraggable( false ) + self.frameKeyboard:SetSizable( false ) + self.frameKeyboard:ShowCloseButton( false ) + self.frameKeyboard:LerpPositions( 1, true ) - self.frameKeyboard.OnKeyCodePressed = function(_, key) - MKeyboard:OnButton(key, true) - end + -- passthrough button events while this panel is focused + self.frameKeyboard.OnKeyCodePressed = function( _, key ) + MKeyboard:OnButton( key, true ) + end - self.frameKeyboard.OnKeyCodeReleased = function(_, key) - MKeyboard:OnButton(key, false) - end + self.frameKeyboard.OnKeyCodeReleased = function( _, key ) + MKeyboard:OnButton( key, false ) + end - local helpMessage = { - [false] = langGet('mk.help.open'), - [true] = langGet('mk.help.close'), - } + local helpMessage = { + [false] = langGet( 'mk.help.open' ), + [true] = langGet( 'mk.help.close' ), + } - self.frameKeyboard.Paint = function(_, sw, sh) - drawKeyboard(sw * 0.5, sh * 0.1, sh * 0.22) - roundedBoxEx(8, 0, sh * 0.4, sw, sh * 0.6, themeColors[6], true, true, false, false) + self.frameKeyboard.Paint = function( _, sw, sh ) + drawKeyboard( sw * 0.5, sh * 0.1, sh * 0.22 ) + roundedBoxEx( 8, 0, sh * 0.4, sw, sh * 0.6, colors.bg, true, true, false, false ) - if self.openPortName then - simpleText(self.openPortName, 'MKeyboard_Title', sw - (sw * 0.01), sh * 0.43, - themeColors[2], TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP) + if self.openPortName then + simpleText( self.openPortName, 'MKeyboard_Title', sw - ( sw * 0.01 ), sh * 0.43, + colors.white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP ) - simpleText(helpMessage[self.expanded], 'MKeyboard_Title', sw * 0.01, sh * 0.43, - themeColors[2], TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP) - else - simpleText(helpMessage[self.expanded], 'MKeyboard_Title', sw * 0.5, sh * 0.43, - themeColors[2], TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP) - end + simpleText( helpMessage[self.expanded], 'MKeyboard_Title', sw * 0.01, sh * 0.43, + colors.white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP ) + else + simpleText( helpMessage[self.expanded], 'MKeyboard_Title', sw * 0.5, sh * 0.43, + colors.white, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP ) + end - local sheet = MKeyboard.Settings.sheet - if sheet > 0 then - drawSheet(sheet, sw * 0.5, 0) - end - end + if settings.sheet > 0 then + drawSheet( settings.sheet, sw * 0.5, 0 ) + end + end - local pnlParent = vgui.Create('DPanel', self.frameKeyboard) - pnlParent:SetPos(wide * 0.01, tall * 0.52) - pnlParent:SetSize(wide * 0.98, tall * 0.45) - pnlParent:DockPadding(0, 0, 0, 0) - pnlParent:SetPaintBackground(false) + local pnlParent = vgui.Create( 'DPanel', self.frameKeyboard ) + pnlParent:SetPos( wide * 0.01, tall * 0.52 ) + pnlParent:SetSize( wide * 0.98, tall * 0.45 ) + pnlParent:DockPadding( 0, 0, 0, 0 ) + pnlParent:SetPaintBackground( false ) - local pnlSettings = createCategoryPanel(langGet('mk.settings'), pnlParent, LEFT, wide * 0.3) + local pnlSettings = createCategoryPanel( langGet( 'mk.settings' ), pnlParent, LEFT, wide * 0.3 ) - local propertyPanel = vgui.Create('DProperties', pnlSettings) - propertyPanel:Dock(FILL) - propertyPanel:DockMargin(0, 8, 0, 0) + local propertyPanel = vgui.Create( 'DProperties', pnlSettings ) + propertyPanel:Dock( FILL ) + propertyPanel:DockMargin( 0, 8, 0, 0 ) - local layoutValues = {} + local layoutValues = {} - for k, v in ipairs(MKeyboard.Layouts) do - layoutValues[v.name] = k - end + for k, v in ipairs( MKeyboard.layouts ) do + layoutValues[v.name] = k + end - local rLayouts = propertyPanel:CreateRow(langGet('mk.vkeys'), langGet('mk.layout')) - rLayouts:Setup('Combo', { - text = 'Select a layout...', - values = layoutValues - }) + local rLayouts = propertyPanel:CreateRow( langGet( 'mk.vkeys' ), langGet( 'mk.layout' ) ) + rLayouts:Setup( 'Combo', { + text = 'Select a layout...', + values = layoutValues + } ) - rLayouts:SetValue(MKeyboard.Settings.layout) + rLayouts:SetValue( settings.layout ) - rLayouts.DataChanged = function(_, val) - MKeyboard.Settings.layout = val - MKeyboard.Settings.sheet = 0 + rLayouts.DataChanged = function( _, val ) + settings.layout = val + settings.sheet = 0 - local limits = MKeyboard.Layouts[val].octaveLimits - MKeyboard.Settings.octave = math.Clamp(MKeyboard.Settings.octave, limits.min, limits.max) - MKeyboard:SaveSettings() + local limits = MKeyboard.layouts[val].octaveLimits + settings.octave = math.Clamp( settings.octave, limits.min, limits.max ) + MKeyboard:SaveSettings() - self.rowOctave:Setup('Int', {min = limits.min, max = limits.max}) - self.rowOctave:SetValue(MKeyboard.Settings.octave) - self:UpdateLayout() - end + self.rowOctave:Setup( 'Int', { min = limits.min, max = limits.max } ) + self.rowOctave:SetValue( settings.octave ) + self:UpdateLayout() + end - local rDrawLabels = propertyPanel:CreateRow(langGet('mk.vkeys'), langGet('mk.vkeys.labels')) - rDrawLabels:Setup('Boolean') - rDrawLabels:SetValue(MKeyboard.Settings.drawKeyLabels) + local rDrawLabels = propertyPanel:CreateRow( langGet( 'mk.vkeys' ), langGet( 'mk.vkeys.labels' ) ) + rDrawLabels:Setup( 'Boolean' ) + rDrawLabels:SetValue( settings.drawKeyLabels ) - rDrawLabels.DataChanged = function(_, val) - MKeyboard.Settings.drawKeyLabels = tobool(val) - MKeyboard:SaveSettings() - end + rDrawLabels.DataChanged = function( _, val ) + settings.drawKeyLabels = tobool( val ) + MKeyboard:SaveSettings() + end - local rVelocity = propertyPanel:CreateRow(langGet('mk.vkeys'), langGet('mk.vkeys.velocity')) - rVelocity:Setup('Int', {min = 1, max = 127}) - rVelocity:SetValue(MKeyboard.Settings.velocity) + local rVelocity = propertyPanel:CreateRow( langGet( 'mk.vkeys' ), langGet( 'mk.vkeys.velocity' ) ) + rVelocity:Setup( 'Int', { min = 1, max = 127 } ) + rVelocity:SetValue( settings.velocity ) - rVelocity.DataChanged = function(_, val) - MKeyboard.Settings.velocity = math.ceil(val) - end + rVelocity.DataChanged = function( _, val ) + settings.velocity = math.ceil( val ) + end - local octaveLimits = MKeyboard.Layouts[MKeyboard.Settings.layout].octaveLimits + local octaveLimits = MKeyboard.layouts[settings.layout].octaveLimits - self.rowOctave = propertyPanel:CreateRow(langGet('mk.vkeys'), langGet('mk.vkeys.octave')) - self.rowOctave:Setup('Int', {min = octaveLimits.min, max = octaveLimits.max}) - self.rowOctave:SetValue(MKeyboard.Settings.octave) + self.rowOctave = propertyPanel:CreateRow( langGet( 'mk.vkeys' ), langGet( 'mk.vkeys.octave' ) ) + self.rowOctave:Setup( 'Int', { min = octaveLimits.min, max = octaveLimits.max } ) + self.rowOctave:SetValue( settings.octave ) - self.rowOctave.DataChanged = function(_, val) - if val < 0 then - MKeyboard.Settings.octave = math.ceil(val) - else - MKeyboard.Settings.octave = math.floor(val) - end + self.rowOctave.DataChanged = function( _, val ) + if val < 0 then + settings.octave = math.ceil( val ) + else + settings.octave = math.floor( val ) + end - MKeyboard:SaveSettings() - MKeyboard:NoteOffAll() - end + MKeyboard:SaveSettings() + MKeyboard:NoteOffAll() + end - local rDevices = propertyPanel:CreateRow('MIDI', langGet('mk.midi.device')) - rDevices:Setup('Button', langGet('mk.midi.device.choose')) + local rDevices = propertyPanel:CreateRow( 'MIDI', langGet( 'mk.midi.device' ) ) + rDevices:Setup( 'Button', langGet( 'mk.midi.device.choose' ) ) - if midi then - local rChannels = propertyPanel:CreateRow('MIDI', langGet('mk.midi.channels')) - rChannels:Setup('Button', langGet('mk.midi.channels.setup')) + if midi then + local rChannels = propertyPanel:CreateRow( 'MIDI', langGet( 'mk.midi.channels' ) ) + rChannels:Setup( 'Button', langGet( 'mk.midi.channels.setup' ) ) - rChannels.OnClick = function() - self:ShowChannelsDialog() - end + rChannels.OnClick = function() + self:ShowChannelsDialog() + end - rDevices.OnClick = function() - self:ShowDevicesDialog() - end + rDevices.OnClick = function() + self:ShowDevicesDialog() + end - if table.Count(midi.GetPorts()) == 0 then - rDevices:SetValue(langGet('mk.midi.nodevices')) - rDevices:SetEnabled(false) - end + if table.Count( midi.GetPorts() ) == 0 then + rDevices:SetValue( langGet( 'mk.midi.nodevices' ) ) + rDevices:SetEnabled( false ) + end - local midiTranspose = propertyPanel:CreateRow('MIDI', langGet('mk.vkeys.transpose')) - midiTranspose:Setup('Int', {min = -48, max = 48}) - midiTranspose:SetValue(MKeyboard.Settings.midiTranspose) + local midiTranspose = propertyPanel:CreateRow( 'MIDI', langGet( 'mk.vkeys.transpose' ) ) + midiTranspose:Setup( 'Int', { min = -48, max = 48 } ) + midiTranspose:SetValue( settings.midiTranspose ) - midiTranspose.DataChanged = function(_, val) - MKeyboard.Settings.midiTranspose = math.Round(val) - MKeyboard:SaveSettings() - MKeyboard:NoteOffAll() - end - else - rDevices:SetValue(langGet('mk.midi.nomodule')) - rDevices:SetEnabled(false) + midiTranspose.DataChanged = function( _, val ) + settings.midiTranspose = math.Round( val ) + MKeyboard:SaveSettings() + MKeyboard:NoteOffAll() + end + else + rDevices:SetValue( langGet( 'mk.midi.nomodule' ) ) + rDevices:SetEnabled( false ) - local rInstallHelp = propertyPanel:CreateRow('MIDI', 'Module installation') - rInstallHelp:Setup('Button', langGet('mk.midi.guide')) + local rInstallHelp = propertyPanel:CreateRow( 'MIDI', 'Module installation' ) + rInstallHelp:Setup( 'Button', langGet( 'mk.midi.guide' ) ) - rInstallHelp.OnClick = function() - gui.OpenURL('https://steamcommunity.com/workshop/filedetails/discussion/2656563609/3199240042192880687/') - self:ToggleExpandedBar() - end - end + rInstallHelp.OnClick = function() + gui.OpenURL( MKeyboard.URL_MIDI_GUIDE ) + self:ToggleExpandedBar() + end + end - local pnlInstruments = createCategoryPanel(langGet('mk.instruments'), - pnlParent, FILL, nil, langGet('mk.instruments.help')) + local pnlInstruments = createCategoryPanel( langGet( 'mk.instruments' ), pnlParent, FILL, nil, langGet( 'mk.instruments.help' ) ) - self.instrList = vgui.Create('DListView', pnlInstruments) - self.instrList:Dock(FILL) - self.instrList:DockMargin(0, 8, 0, 0) - self.instrList:AddColumn(langGet('mk.instruments')) - self.instrList:SetMultiSelect(false) - self.instrList:SetHideHeaders(true) - self.instrList:SetSortable(false) + self.instrList = vgui.Create( 'DListView', pnlInstruments ) + self.instrList:Dock( FILL ) + self.instrList:DockMargin( 0, 8, 0, 0 ) + self.instrList:AddColumn( langGet( 'mk.instruments' ) ) + self.instrList:SetMultiSelect( false ) + self.instrList:SetHideHeaders( true ) + self.instrList:SetSortable( false ) - for i, v in ipairs(MKeyboard.Instruments) do - self.instrList:AddLine(i .. ' - ' .. v.name) - end + for i, v in ipairs( MKeyboard.instruments ) do + self.instrList:AddLine( i .. ' - ' .. v.name ) + end - self.instrList:SelectItem( self.instrList:GetLine(MKeyboard.Settings.instrument) ) + self.instrList:SelectItem( self.instrList:GetLine( settings.instrument ) ) - self.instrList.OnRowSelected = function(_, index, _) - MKeyboard.Settings.instrument = index - MKeyboard:SaveSettings() - end + self.instrList.OnRowSelected = function( _, index ) + settings.instrument = index + MKeyboard:SaveSettings() + end - local pnlSheets = createCategoryPanel(langGet('mk.sheets'), pnlParent, RIGHT, wide * 0.3) + local pnlSheets = createCategoryPanel( langGet( 'mk.sheets' ), pnlParent, RIGHT, wide * 0.3 ) - self.sheetList = vgui.Create('DListView', pnlSheets) - self.sheetList:Dock(FILL) - self.sheetList:DockMargin(0, 8, 0, 0) - self.sheetList:AddColumn(langGet('mk.sheets')) - self.sheetList:SetMultiSelect(false) - self.sheetList:SetHideHeaders(true) - self.sheetList:SetSortable(false) + self.sheetList = vgui.Create( 'DListView', pnlSheets ) + self.sheetList:Dock( FILL ) + self.sheetList:DockMargin( 0, 8, 0, 0 ) + self.sheetList:AddColumn( langGet( 'mk.sheets' ) ) + self.sheetList:SetMultiSelect( false ) + self.sheetList:SetHideHeaders( true ) + self.sheetList:SetSortable( false ) - self:UpdateLayout() + self:UpdateLayout() end -function HUD:Shutdown() - self.expanded = false +function uiHandler:Shutdown() + self.expanded = false - if IsValid(self.frameKeyboard) then - self.frameKeyboard:Close() - end + if IsValid( self.frameKeyboard ) then + self.frameKeyboard:Close() + end - if IsValid(self.frameDevices) then - self.frameDevices:Close() - end + if IsValid( self.frameDevices ) then + self.frameDevices:Close() + end - if IsValid(self.frameChannels) then - self.frameChannels:Close() - end + if IsValid( self.frameChannels ) then + self.frameChannels:Close() + end end -function HUD:UpdateLayout() - self.whiteKeyCount = 0 +function uiHandler:UpdateLayout() + self.whiteKeyCount = 0 - local layout = MKeyboard.Settings.layout - local layoutKeys = MKeyboard.Layouts[layout].keys + local layout = settings.layout + local layoutKeys = MKeyboard.layouts[layout].keys - for idx, params in ipairs(layoutKeys) do - if params[3] == 'w' then - self.whiteKeyCount = self.whiteKeyCount + 1 - end - end + for _, params in ipairs( layoutKeys ) do + if params[3] == 'w' then + self.whiteKeyCount = self.whiteKeyCount + 1 + end + end - self.sheetList:Clear() + self.sheetList:Clear() - local shouldSelect = self.sheetList:AddLine(langGet('mk.sheets.hidden')) - shouldSelect._sheetIndex = 0 + local shouldSelect = self.sheetList:AddLine( langGet( 'mk.sheets.hidden' ) ) + shouldSelect._sheetIndex = 0 - for k, v in ipairs(MKeyboard.Sheets) do - if v.layout == layout then - local line = self.sheetList:AddLine(v.title) - line._sheetIndex = k + for k, v in ipairs( MKeyboard.sheets ) do + if v.layout == layout then + local line = self.sheetList:AddLine( v.title ) + line._sheetIndex = k - if k == MKeyboard.Settings.sheet then - shouldSelect = line - end - end - end + if k == settings.sheet then + shouldSelect = line + end + end + end - self.sheetList:SelectItem(shouldSelect) + self.sheetList:SelectItem( shouldSelect ) - self.sheetList.OnRowSelected = function(_, _, line) - MKeyboard.Settings.sheet = line._sheetIndex - MKeyboard:SaveSettings() - end + self.sheetList.OnRowSelected = function( _, _, line ) + settings.sheet = line._sheetIndex + MKeyboard:SaveSettings() + end end -function HUD:ChangeInstrument(to) - local newInstrument = MKeyboard.Settings.instrument + to +function uiHandler:ChangeInstrument( to ) + local newInstrument = settings.instrument + to - if newInstrument < 1 then - newInstrument = #MKeyboard.Instruments - end + if newInstrument < 1 then + newInstrument = #MKeyboard.instruments + end - if newInstrument > #MKeyboard.Instruments then - newInstrument = 1 - end + if newInstrument > #MKeyboard.instruments then + newInstrument = 1 + end - MKeyboard.Settings.instrument = newInstrument + settings.instrument = newInstrument - local line = self.instrList:GetLine(newInstrument) + local line = self.instrList:GetLine( newInstrument ) - self.instrList:ClearSelection() - self.instrList:SelectItem(line) - self.instrList.VBar:AnimateTo(line:GetY() - self.instrList:GetTall() * 0.5, 0.25, 0, -1) + self.instrList:ClearSelection() + self.instrList:SelectItem( line ) + self.instrList.VBar:AnimateTo( line:GetY() - self.instrList:GetTall() * 0.5, 0.25, 0, -1 ) - MKeyboard:SaveSettings() + MKeyboard:SaveSettings() end -function HUD:AddOctave(value) - local newOctave = MKeyboard.Settings.octave + value - local limits = MKeyboard.Layouts[MKeyboard.Settings.layout].octaveLimits +function uiHandler:AddOctave( value ) + local newOctave = settings.octave + value + local limits = MKeyboard.layouts[settings.layout].octaveLimits - if newOctave < limits.min then - newOctave = limits.max - end + if newOctave < limits.min then + newOctave = limits.max + end - if newOctave > limits.max then - newOctave = limits.min - end + if newOctave > limits.max then + newOctave = limits.min + end - MKeyboard.Settings.octave = newOctave - MKeyboard.noteState = {} + settings.octave = newOctave + MKeyboard.noteStates = {} - self:UpdateLayout() - self.rowOctave:SetValue(newOctave) + self:UpdateLayout() + self.rowOctave:SetValue( newOctave ) - MKeyboard:SaveSettings() + MKeyboard:SaveSettings() end -function HUD:ToggleExpandedBar() - self.expanded = not self.expanded +function uiHandler:ToggleExpandedBar() + self.expanded = not self.expanded - -- I might have found a bug here. Basically, cant get the panel position - -- after calling LerpPositions without playing the animation first - -- local x = self.frameKeyboard:GetX() + -- I might have found a bug here. Basically, cant get the panel position + -- after calling LerpPositions without playing the animation first + -- local x = self.frameKeyboard:GetX() - local x = (ScrW() - ScrW() * 0.7) * 0.5 - local tall = self.frameKeyboard:GetTall() + local x = ( ScrW() - ScrW() * 0.7 ) * 0.5 + local tall = self.frameKeyboard:GetTall() - if self.expanded then - self.frameKeyboard:SetPos(x, ScrH() - tall) - self.frameKeyboard:MakePopup() - else - self.frameKeyboard:SetPos(x, ScrH() - tall * 0.49) - self.frameKeyboard:SetMouseInputEnabled(false) - self.frameKeyboard:SetKeyboardInputEnabled(false) - end + if self.expanded then + self.frameKeyboard:SetPos( x, ScrH() - tall ) + self.frameKeyboard:MakePopup() + else + self.frameKeyboard:SetPos( x, ScrH() - tall * 0.49 ) + self.frameKeyboard:SetMouseInputEnabled( false ) + self.frameKeyboard:SetKeyboardInputEnabled( false ) + end end -function HUD:SetMidiPortName(name) - if name then - if string.len(name) > 28 then - name = string.sub(name, 1, 25) .. '...' - end +function uiHandler:SetMidiPortName( name ) + if name then + if string.len( name ) > 28 then + name = string.sub( name, 1, 25 ) .. '...' + end - self.openPortName = string.format(langGet('mk.midi.connected'), name) - else - self.openPortName = nil - end + self.openPortName = string.format( langGet( 'mk.midi.connected' ), name ) + else + self.openPortName = nil + end end -function HUD:ShowDevicesDialog() - if IsValid(self.frameDevices) then - self.frameDevices:Close() - end +function uiHandler:ShowDevicesDialog() + if IsValid( self.frameDevices ) then + self.frameDevices:Close() + end - if not midi then return end + if not midi then return end - local midiPorts = midi.GetPorts() - if table.Count(midiPorts) == 0 then return end + local midiPorts = midi.GetPorts() + if table.Count( midiPorts ) == 0 then return end - if midi.IsOpened() then - MKeyboard.MIDI:Close() - MKeyboard.MIDI.selectedPort = nil - end + if midi.IsOpened() then + MKeyboard.midiHandler:Close() + MKeyboard.midiHandler.selectedPort = nil + end - self.frameDevices = vgui.Create('DFrame') - self.frameDevices:SetSize(300, 130) - self.frameDevices:SetTitle(langGet('mk.midi.device.choose')) - self.frameDevices:SetVisible(true) - self.frameDevices:SetDraggable(true) - self.frameDevices:ShowCloseButton(true) - self.frameDevices:SetDeleteOnClose(true) - self.frameDevices:Center() - self.frameDevices:MakePopup() + self.frameDevices = vgui.Create( 'DFrame' ) + self.frameDevices:SetSize( 300, 130 ) + self.frameDevices:SetTitle( langGet( 'mk.midi.device.choose' ) ) + self.frameDevices:SetVisible( true ) + self.frameDevices:SetDraggable( true ) + self.frameDevices:ShowCloseButton( true ) + self.frameDevices:SetDeleteOnClose( true ) + self.frameDevices:Center() + self.frameDevices:MakePopup() - local startTime = SysTime() - local oldPaint = self.frameDevices.Paint + local startTime = SysTime() + local oldPaint = self.frameDevices.Paint - self.frameDevices.Paint = function(s, sw, sh) - Derma_DrawBackgroundBlur(s, startTime) - oldPaint(s, sw, sh) - end + self.frameDevices.Paint = function( s, sw, sh ) + Derma_DrawBackgroundBlur( s, startTime ) + oldPaint( s, sw, sh ) + end - local labelHelp = vgui.Create('DLabel', self.frameDevices) - labelHelp:SetPos(10, 40) - labelHelp:SetSize(280, 40) - labelHelp:SetText(string.format(langGet('mk.midi.found'), tostring(table.Count(midiPorts)))) + local labelHelp = vgui.Create( 'DLabel', self.frameDevices ) + labelHelp:SetPos( 10, 40 ) + labelHelp:SetSize( 280, 40 ) - local comboDevices = vgui.Create('DComboBox', self.frameDevices) - comboDevices:SetPos(10, 90) - comboDevices:SetSize(280, 20) - comboDevices:SetValue(langGet('mk.midi.select')) + labelHelp:SetText( string.format( + langGet( 'mk.midi.found' ), + tostring( table.Count( midiPorts ) ) + ) ) - for k, v in pairs(midiPorts) do - comboDevices:AddChoice('[' .. k .. '] ' .. v) - end + local comboDevices = vgui.Create( 'DComboBox', self.frameDevices ) + comboDevices:SetPos( 10, 90 ) + comboDevices:SetSize( 280, 20 ) + comboDevices:SetValue( langGet( 'mk.midi.select' ) ) - comboDevices.OnSelect = function(_, index, _) - MKeyboard.MIDI.selectedPort = index - 1 - self.frameDevices:Close() - end + for k, v in pairs( midiPorts ) do + comboDevices:AddChoice( '[' .. k .. '] ' .. v ) + end + + comboDevices.OnSelect = function( _, index ) + MKeyboard.midiHandler.selectedPort = index - 1 + self.frameDevices:Close() + end end -function HUD:ShowChannelsDialog() - if IsValid(self.frameChannels) then - self.frameChannels:Close() - return - end +function uiHandler:ShowChannelsDialog() + if IsValid( self.frameChannels ) then + self.frameChannels:Close() + return + end - local tall = math.min(610, ScrH() * 0.6) + local tall = math.min( 610, ScrH() * 0.6 ) - self.frameChannels = vgui.Create('DFrame') - self.frameChannels:SetSize(400, tall) - self.frameChannels:SetTitle(langGet('mk.channels')) - self.frameChannels:SetVisible(true) - self.frameChannels:SetSizable(true) - self.frameChannels:SetDraggable(true) - self.frameChannels:ShowCloseButton(true) - self.frameChannels:SetDeleteOnClose(true) - self.frameChannels:SetPos(ScrW() - self.frameChannels:GetWide(), 0) - self.frameChannels:MakePopup() + self.frameChannels = vgui.Create( 'DFrame' ) + self.frameChannels:SetSize( 400, tall ) + self.frameChannels:SetTitle( langGet( 'mk.channels' ) ) + self.frameChannels:SetVisible( true ) + self.frameChannels:SetSizable( true ) + self.frameChannels:SetDraggable( true ) + self.frameChannels:ShowCloseButton( true ) + self.frameChannels:SetDeleteOnClose( true ) + self.frameChannels:SetPos( ScrW() - self.frameChannels:GetWide(), 0 ) + self.frameChannels:MakePopup() - self.frameChannels.OnKeyCodePressed = function(_, key) - MKeyboard:OnButton(key, true) - end + -- passthrough button events while this panel is focused + self.frameChannels.OnKeyCodePressed = function( _, key ) + MKeyboard:OnButton( key, true ) + end - self.frameChannels.OnKeyCodeReleased = function(_, key) - MKeyboard:OnButton(key, false) - end + self.frameChannels.OnKeyCodeReleased = function( _, key ) + MKeyboard:OnButton( key, false ) + end - local scrollChannels = vgui.Create('DScrollPanel', self.frameChannels) - scrollChannels:Dock(FILL) + local scrollChannels = vgui.Create( 'DScrollPanel', self.frameChannels ) + scrollChannels:Dock( FILL ) - local function paintChannelPanel(s, sw, sh) - setDrawColor(0, 0, 0, 255) - drawRect(0, 0, sw, sh) + local function paintChannelPanel( s, sw, sh ) + setDrawColor( 0, 0, 0, 255 ) + drawRect( 0, 0, sw, sh ) - setDrawColor(50, 50, 50, 255) - drawRect(4, 4, 8, sh - 8) + setDrawColor( 50, 50, 50, 255 ) + drawRect( 4, 4, 8, sh - 8 ) - self.channelState[s.channel] = Lerp(FrameTime() * 8, self.channelState[s.channel], 0) - setDrawColor(themeColors[4].r, themeColors[4].g, themeColors[4].b, 255 * self.channelState[s.channel]) - drawRect(4, 4, 8, sh - 8) - end + local accentColor = colors.accent2 - local function selectChannelInst(s, _, _, idx) - if idx == -1 then - MKeyboard.Settings.channelInstruments[s.channel] = nil - else - MKeyboard.Settings.channelInstruments[s.channel] = idx - end + self.channelState[s.channel] = Lerp( FrameTime() * 8, self.channelState[s.channel], 0 ) + setDrawColor( accentColor.r, accentColor.g, accentColor.b, 255 * self.channelState[s.channel] ) + drawRect( 4, 4, 8, sh - 8 ) + end - MKeyboard:SaveSettings() - end + local function selectChannelInst( s, _, _, idx ) + if idx == -1 then + settings.channelInstruments[s.channel] = nil + else + settings.channelInstruments[s.channel] = idx + end - for c = 0, 15 do - self.channelState[c] = 0 + MKeyboard:SaveSettings() + end - local panelChannel = vgui.Create('DPanel', scrollChannels) - panelChannel:SetSize(wide, 32) - panelChannel:Dock(TOP) - panelChannel:DockMargin(0, 0, 0, 4) + for c = 0, 15 do + self.channelState[c] = 0 - panelChannel.channel = c - panelChannel.Paint = paintChannelPanel + local panelChannel = vgui.Create( 'DPanel', scrollChannels ) + panelChannel:SetSize( wide, 32 ) + panelChannel:Dock( TOP ) + panelChannel:DockMargin( 0, 0, 0, 4 ) - local lblIndex = vgui.Create('DLabel', panelChannel) - lblIndex:SetFont('Trebuchet24') - lblIndex:SetTextColor(themeColors[2]) - lblIndex:SetText('#' .. (c + 1)) - lblIndex:SetWide(50) - lblIndex:Dock(LEFT) - lblIndex:DockMargin(20, 0, 0, 0) + panelChannel.channel = c + panelChannel.Paint = paintChannelPanel - local comboInstr = vgui.Create('DComboBox', panelChannel) - comboInstr:SetSortItems(false) - comboInstr:AddChoice(langGet('mk.channels.usecurrent'), -1, true) - comboInstr:AddChoice(langGet('mk.channels.mute'), 0) - comboInstr:AddSpacer() - comboInstr:Dock(FILL) + local lblIndex = vgui.Create( 'DLabel', panelChannel ) + lblIndex:SetFont( 'Trebuchet24' ) + lblIndex:SetTextColor( colors.white ) + lblIndex:SetText( '#' .. ( c + 1 ) ) + lblIndex:SetWide( 50 ) + lblIndex:Dock( LEFT ) + lblIndex:DockMargin( 20, 0, 0, 0 ) - local myInstrument = MKeyboard.Settings.channelInstruments[c] or -1 + local comboInstr = vgui.Create( 'DComboBox', panelChannel ) + comboInstr:SetSortItems( false ) + comboInstr:AddChoice( langGet( 'mk.channels.usecurrent' ), -1, true ) + comboInstr:AddChoice( langGet( 'mk.channels.mute' ), 0 ) + comboInstr:AddSpacer() + comboInstr:Dock( FILL ) - for idx, v in ipairs(MKeyboard.Instruments) do - comboInstr:AddChoice(v.name, idx, idx == myInstrument) - end + local myInstrument = settings.channelInstruments[c] or -1 - comboInstr.channel = c - comboInstr.OnSelect = selectChannelInst - end + for idx, v in ipairs( MKeyboard.instruments ) do + comboInstr:AddChoice( v.name, idx, idx == myInstrument ) + end + + comboInstr.channel = c + comboInstr.OnSelect = selectChannelInst + end end \ No newline at end of file diff --git a/lua/mkeyboard/cl_midi.lua b/lua/mkeyboard/cl_midi.lua index 6ad9119..e5bb912 100644 --- a/lua/mkeyboard/cl_midi.lua +++ b/lua/mkeyboard/cl_midi.lua @@ -1,89 +1,91 @@ -- based on Starfall's SF.Require, for clientside use -local function SafeRequireModule(moduleName) - local osSuffix +local function SafeRequireModule( moduleName ) + local osSuffix - if system.IsWindows() then - osSuffix = (jit.arch ~= 'x64' and 'win32' or 'win64') - elseif system.IsLinux() then - osSuffix = (jit.arch ~= 'x64' and 'linux' or 'linux64') - elseif system.IsOSX() then - osSuffix = (jit.arch ~= 'x64' and 'osx' or 'osx64') - else - return - end + if system.IsWindows() then + osSuffix = jit.arch ~= 'x64' and 'win32' or 'win64' + elseif system.IsLinux() then + osSuffix = jit.arch ~= 'x64' and 'linux' or 'linux64' + elseif system.IsOSX() then + osSuffix = jit.arch ~= 'x64' and 'osx' or 'osx64' + else + return + end - if file.Exists('lua/bin/gmcl_' .. moduleName .. '_' .. osSuffix .. '.dll', 'GAME') then - local ok, err = pcall(require, moduleName) - if ok then - return true - else - ErrorNoHalt(err) - return false - end - end + if file.Exists( 'lua/bin/gmcl_' .. moduleName .. '_' .. osSuffix .. '.dll', 'GAME' ) then + local ok, err = pcall( require, moduleName ) + if ok then + return true + else + ErrorNoHalt( err ) - return false + return false + end + end + + return false end -- safely require the midi module -SafeRequireModule('midi') +SafeRequireModule( 'midi' ) -local MIDI = { - selectedPort = nil, - portTimer = 0 +local midiHandler = { + selectedPort = nil, + portTimer = 0 } -MKeyboard.MIDI = MIDI +MKeyboard.midiHandler = midiHandler -function MIDI:Open(port) - self:Close() +function midiHandler:Open( port ) + self:Close() - local portName = midi.GetPorts()[port] - if not portName then - print('Could not find MIDI port: ' .. port) - return - end + local portName = midi.GetPorts()[port] + if not portName then + print( 'Could not find MIDI port: ' .. port ) - print('Opening MIDI port: ' .. portName) + return + end - local success, err = pcall(midi.Open, port) - if success then - MKeyboard.HUD:SetMidiPortName(portName) - else - print('Failed to open MIDI port: ' .. err) - end + print( 'Opening MIDI port: ' .. portName ) + + local success, err = pcall( midi.Open, port ) + if success then + MKeyboard.uiHandler:SetMidiPortName( portName ) + else + print( 'Failed to open MIDI port: ' .. err ) + end end -function MIDI:Close() - MKeyboard.HUD:SetMidiPortName(nil) +function midiHandler:Close() + MKeyboard.uiHandler:SetMidiPortName( nil ) - if midi and midi.IsOpened() then - print('Closing MIDI port.') - midi.Close() - end + if midi and midi.IsOpened() then + print( 'Closing MIDI port.' ) + midi.Close() + end end -function MIDI:Think() - -- Try to open the selected midi port - if self.selectedPort and not midi.IsOpened() and RealTime() > self.portTimer then - self.portTimer = RealTime() + 5 - self:Open(self.selectedPort) - end +function midiHandler:Think() + -- Try to open the selected midi port + if self.selectedPort and not midi.IsOpened() and RealTime() > self.portTimer then + self.portTimer = RealTime() + 5 + self:Open( self.selectedPort ) + end end -- listen to events from the MIDI module -hook.Add('MIDI', 'mkeyboard_MIDI', function(_, code, p1, p2) - if not IsValid(MKeyboard.entity) then return end - if not code then return end +hook.Add( 'MIDI', 'mkeyboard_CaptureMIDIEvents', function( _, code, p1, p2 ) + if not IsValid( MKeyboard.entity ) then return end + if not code then return end - local midiCmd = midi.GetCommandName(code) - local transpose = MKeyboard.Settings.midiTranspose + local midiCmd = midi.GetCommandName( code ) + local transpose = MKeyboard.settings.midiTranspose - if midiCmd == 'NOTE_ON' and p2 > 0 then - local midiChannel = midi.GetCommandChannel(code) - MKeyboard:NoteOn(p1 + transpose, p2, true, midiChannel) + if midiCmd == 'NOTE_ON' and p2 > 0 then + local midiChannel = midi.GetCommandChannel( code ) + MKeyboard:NoteOn( p1 + transpose, p2, true, midiChannel ) - elseif midiCmd == 'NOTE_OFF' then - MKeyboard:NoteOff(p1 + transpose) - end -end) \ No newline at end of file + elseif midiCmd == 'NOTE_OFF' then + MKeyboard:NoteOff( p1 + transpose ) + end +end ) \ No newline at end of file diff --git a/lua/mkeyboard/data/instruments.lua b/lua/mkeyboard/data/instruments.lua index 4f06d11..d58d74c 100644 --- a/lua/mkeyboard/data/instruments.lua +++ b/lua/mkeyboard/data/instruments.lua @@ -1,47 +1,47 @@ -MKeyboard.Instruments = {} +MKeyboard.instruments = {} -function MKeyboard:RegisterInstrument(name, path, firstNote, lastNote) - self.Instruments[#self.Instruments + 1] = { - name = name, - path = path, - firstNote = firstNote, - lastNote = lastNote - } +function MKeyboard:RegisterInstrument( name, path, firstNote, lastNote ) + self.instruments[#self.instruments + 1] = { + name = name, + path = path, + firstNote = firstNote, + lastNote = lastNote + } end --- ##### Default instruments ##### -- +-- default instruments -MKeyboard:RegisterInstrument('Grand Piano', 'styledstrike/instruments/grand_piano/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Grand Piano (Soft)', 'styledstrike/instruments/grand_piano_2/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Electric Piano', 'styledstrike/instruments/electric_piano/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Analog Piano', 'styledstrike/instruments/analog_piano/%i.mp3', 24, 108) -MKeyboard:RegisterInstrument('Binary Piano', 'styledstrike/instruments/binary_piano/%i.mp3', 24, 96) +MKeyboard:RegisterInstrument( 'Grand Piano', 'styledstrike/instruments/grand_piano/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Grand Piano (Soft)', 'styledstrike/instruments/grand_piano_2/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Electric Piano', 'styledstrike/instruments/electric_piano/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Analog Piano', 'styledstrike/instruments/analog_piano/%i.mp3', 24, 108 ) +MKeyboard:RegisterInstrument( 'Binary Piano', 'styledstrike/instruments/binary_piano/%i.mp3', 24, 96 ) -MKeyboard:RegisterInstrument('Music Box', 'styledstrike/instruments/music_box/%i.mp3', 36, 96) -MKeyboard:RegisterInstrument('Harp', 'styledstrike/instruments/harp/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Harpsichord', 'styledstrike/instruments/harpsichord/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Nylon Guitar', 'styledstrike/instruments/nylon_guitar/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Jazz Guitar', 'styledstrike/instruments/jazz_guitar/%i.mp3', 24, 84) -MKeyboard:RegisterInstrument('Picked Bass', 'styledstrike/instruments/picked_bass/%i.mp3', 24, 72) -MKeyboard:RegisterInstrument('Slap Bass', 'styledstrike/instruments/slap_bass/%i.mp3', 24, 72) -MKeyboard:RegisterInstrument('Acoustic Bass', 'styledstrike/instruments/acoustic_bass/%i.mp3', 24, 72) +MKeyboard:RegisterInstrument( 'Music Box', 'styledstrike/instruments/music_box/%i.mp3', 36, 96 ) +MKeyboard:RegisterInstrument( 'Harp', 'styledstrike/instruments/harp/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Harpsichord', 'styledstrike/instruments/harpsichord/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Nylon Guitar', 'styledstrike/instruments/nylon_guitar/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Jazz Guitar', 'styledstrike/instruments/jazz_guitar/%i.mp3', 24, 84 ) +MKeyboard:RegisterInstrument( 'Picked Bass', 'styledstrike/instruments/picked_bass/%i.mp3', 24, 72 ) +MKeyboard:RegisterInstrument( 'Slap Bass', 'styledstrike/instruments/slap_bass/%i.mp3', 24, 72 ) +MKeyboard:RegisterInstrument( 'Acoustic Bass', 'styledstrike/instruments/acoustic_bass/%i.mp3', 24, 72 ) -MKeyboard:RegisterInstrument('Marimba', 'styledstrike/instruments/marimba/%i.mp3', 36, 96) -MKeyboard:RegisterInstrument('Vibraphone', 'styledstrike/instruments/vibraphone/%i.mp3', 36, 96) -MKeyboard:RegisterInstrument('Piccolo', 'styledstrike/instruments/piccolo/%i.mp3', 48, 96) -MKeyboard:RegisterInstrument('Pizzicato Strings', 'styledstrike/instruments/pizzicato_strings/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Choir Oohs', 'styledstrike/instruments/choir_oohs/%i.mp3', 36, 96) +MKeyboard:RegisterInstrument( 'Marimba', 'styledstrike/instruments/marimba/%i.mp3', 36, 96 ) +MKeyboard:RegisterInstrument( 'Vibraphone', 'styledstrike/instruments/vibraphone/%i.mp3', 36, 96 ) +MKeyboard:RegisterInstrument( 'Piccolo', 'styledstrike/instruments/piccolo/%i.mp3', 48, 96 ) +MKeyboard:RegisterInstrument( 'Pizzicato Strings', 'styledstrike/instruments/pizzicato_strings/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Choir Oohs', 'styledstrike/instruments/choir_oohs/%i.mp3', 36, 96 ) -MKeyboard:RegisterInstrument('New Age', 'styledstrike/instruments/new_age/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Polysynth', 'styledstrike/instruments/polysynth/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Soft Synth', 'styledstrike/instruments/soft_synth/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Space Voice', 'styledstrike/instruments/space_voice/%i.mp3', 36, 96) -MKeyboard:RegisterInstrument('Saw Lead', 'styledstrike/instruments/saw_lead/%i.mp3', 24, 96) -MKeyboard:RegisterInstrument('Square Lead', 'styledstrike/instruments/square_lead/%i.mp3', 24, 96) +MKeyboard:RegisterInstrument( 'New Age', 'styledstrike/instruments/new_age/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Polysynth', 'styledstrike/instruments/polysynth/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Soft Synth', 'styledstrike/instruments/soft_synth/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Space Voice', 'styledstrike/instruments/space_voice/%i.mp3', 36, 96 ) +MKeyboard:RegisterInstrument( 'Saw Lead', 'styledstrike/instruments/saw_lead/%i.mp3', 24, 96 ) +MKeyboard:RegisterInstrument( 'Square Lead', 'styledstrike/instruments/square_lead/%i.mp3', 24, 96 ) -MKeyboard:RegisterInstrument('Drums (Standard)', 'styledstrike/instruments/drums_standard/%i.mp3', 26, 87) -MKeyboard:RegisterInstrument('Drums (Analog)', 'styledstrike/instruments/drums_analog/%i.mp3', 26, 75) -MKeyboard:RegisterInstrument('Drums (Jazz)', 'styledstrike/instruments/drums_jazz/%i.mp3', 26, 75) -MKeyboard:RegisterInstrument('Drums (Brush)', 'styledstrike/instruments/drums_brush/%i.mp3', 26, 75) +MKeyboard:RegisterInstrument( 'Drums (Standard)', 'styledstrike/instruments/drums_standard/%i.mp3', 26, 87 ) +MKeyboard:RegisterInstrument( 'Drums (Analog)', 'styledstrike/instruments/drums_analog/%i.mp3', 26, 75 ) +MKeyboard:RegisterInstrument( 'Drums (Jazz)', 'styledstrike/instruments/drums_jazz/%i.mp3', 26, 75 ) +MKeyboard:RegisterInstrument( 'Drums (Brush)', 'styledstrike/instruments/drums_brush/%i.mp3', 26, 75 ) -MKeyboard:RegisterInstrument('Honky Tonk', 'styledstrike/instruments/honky_tonk/%i.mp3', 24, 96) \ No newline at end of file +MKeyboard:RegisterInstrument( 'Honky Tonk', 'styledstrike/instruments/honky_tonk/%i.mp3', 24, 96 ) \ No newline at end of file diff --git a/lua/mkeyboard/data/layouts.lua b/lua/mkeyboard/data/layouts.lua index 7f71135..0a8cf4f 100644 --- a/lua/mkeyboard/data/layouts.lua +++ b/lua/mkeyboard/data/layouts.lua @@ -1,144 +1,144 @@ -MKeyboard.Layouts = {} +MKeyboard.layouts = {} -function MKeyboard:RegisterLayout(name, keys, octaveLimits) - self.Layouts[#self.Layouts + 1] = { - name = name, - keys = keys, - octaveLimits = octaveLimits - } +function MKeyboard:RegisterLayout( name, keys, octaveLimits ) + self.layouts[#self.layouts + 1] = { + name = name, + keys = keys, + octaveLimits = octaveLimits + } end --- ##### Default keyboard layouts ##### -- +-- default keyboard layouts -MKeyboard:RegisterLayout('Compact', { - -- key, note, type, label - {KEY_A, 60, 'w', 'a'}, - {KEY_W, 61, 'b', 'w'}, - {KEY_S, 62, 'w', 's'}, - {KEY_E, 63, 'b', 'e'}, - {KEY_D, 64, 'w', 'd'}, - {KEY_F, 65, 'w', 'f'}, - {KEY_T, 66, 'b', 't'}, - {KEY_G, 67, 'w', 'g'}, - {KEY_Y, 68, 'b', 'y'}, - {KEY_H, 69, 'w', 'h'}, - {KEY_U, 70, 'b', 'u'}, - {KEY_J, 71, 'w', 'j'}, - {KEY_K, 72, 'w', 'k'}, - {KEY_O, 73, 'b', 'o'}, - {KEY_L, 74, 'w', 'l'}, - {KEY_P, 75, 'b', 'p'}, - {KEY_SEMICOLON, 76, 'w', ';'}, - {KEY_APOSTROPHE, 77, 'w', '\''} +MKeyboard:RegisterLayout( 'Compact', { + -- key, note, type, label + { KEY_A, 60, 'w', 'a' }, + { KEY_W, 61, 'b', 'w' }, + { KEY_S, 62, 'w', 's' }, + { KEY_E, 63, 'b', 'e' }, + { KEY_D, 64, 'w', 'd' }, + { KEY_F, 65, 'w', 'f' }, + { KEY_T, 66, 'b', 't' }, + { KEY_G, 67, 'w', 'g' }, + { KEY_Y, 68, 'b', 'y' }, + { KEY_H, 69, 'w', 'h' }, + { KEY_U, 70, 'b', 'u' }, + { KEY_J, 71, 'w', 'j' }, + { KEY_K, 72, 'w', 'k' }, + { KEY_O, 73, 'b', 'o' }, + { KEY_L, 74, 'w', 'l' }, + { KEY_P, 75, 'b', 'p' }, + { KEY_SEMICOLON, 76, 'w', ';' }, + { KEY_APOSTROPHE, 77, 'w', '\'' } }, { - min = -3, max = 2 -}) + min = -3, max = 2 +} ) -MKeyboard:RegisterLayout('Expanded', { - -- key, note, type, label, require SHIFT - {KEY_1, 36, 'w', '1'}, - {KEY_1, 37, 'b', '!', true}, - {KEY_2, 38, 'w', '2'}, - {KEY_2, 39, 'b', '@', true}, - {KEY_3, 40, 'w', '3'}, - {KEY_4, 41, 'w', '4'}, - {KEY_4, 42, 'b', '$', true}, - {KEY_5, 43, 'w', '5'}, - {KEY_5, 44, 'b', '%', true}, - {KEY_6, 45, 'w', '6'}, - {KEY_6, 46, 'b', '^', true}, - {KEY_7, 47, 'w', '7'}, - {KEY_8, 48, 'w', '8'}, - {KEY_8, 49, 'b', '*', true}, - {KEY_9, 50, 'w', '9'}, - {KEY_9, 51, 'b', '(', true}, - {KEY_0, 52, 'w', '0'}, +MKeyboard:RegisterLayout( 'Expanded', { + -- key, note, type, label, require SHIFT + { KEY_1, 36, 'w', '1' }, + { KEY_1, 37, 'b', '!', true }, + { KEY_2, 38, 'w', '2' }, + { KEY_2, 39, 'b', '@', true }, + { KEY_3, 40, 'w', '3' }, + { KEY_4, 41, 'w', '4' }, + { KEY_4, 42, 'b', '$', true }, + { KEY_5, 43, 'w', '5' }, + { KEY_5, 44, 'b', '%', true }, + { KEY_6, 45, 'w', '6' }, + { KEY_6, 46, 'b', '^', true }, + { KEY_7, 47, 'w', '7' }, + { KEY_8, 48, 'w', '8' }, + { KEY_8, 49, 'b', '*', true }, + { KEY_9, 50, 'w', '9' }, + { KEY_9, 51, 'b', '(', true }, + { KEY_0, 52, 'w', '0' }, - {KEY_Q, 53, 'w', 'q'}, - {KEY_Q, 54, 'b', 'Q', true}, - {KEY_W, 55, 'w', 'w'}, - {KEY_W, 56, 'b', 'W', true}, - {KEY_E, 57, 'w', 'e'}, - {KEY_E, 58, 'b', 'E', true}, - {KEY_R, 59, 'w', 'r'}, - {KEY_T, 60, 'w', 't'}, - {KEY_T, 61, 'b', 'T', true}, - {KEY_Y, 62, 'w', 'y'}, - {KEY_Y, 63, 'b', 'Y', true}, - {KEY_U, 64, 'w', 'u'}, - {KEY_I, 65, 'w', 'i'}, - {KEY_I, 66, 'b', 'I', true}, - {KEY_O, 67, 'w', 'o'}, - {KEY_O, 68, 'b', 'O', true}, - {KEY_P, 69, 'w', 'p'}, - {KEY_P, 70, 'b', 'P', true}, + { KEY_Q, 53, 'w', 'q' }, + { KEY_Q, 54, 'b', 'Q', true }, + { KEY_W, 55, 'w', 'w' }, + { KEY_W, 56, 'b', 'W', true }, + { KEY_E, 57, 'w', 'e' }, + { KEY_E, 58, 'b', 'E', true }, + { KEY_R, 59, 'w', 'r' }, + { KEY_T, 60, 'w', 't' }, + { KEY_T, 61, 'b', 'T', true }, + { KEY_Y, 62, 'w', 'y' }, + { KEY_Y, 63, 'b', 'Y', true }, + { KEY_U, 64, 'w', 'u' }, + { KEY_I, 65, 'w', 'i' }, + { KEY_I, 66, 'b', 'I', true }, + { KEY_O, 67, 'w', 'o' }, + { KEY_O, 68, 'b', 'O', true }, + { KEY_P, 69, 'w', 'p' }, + { KEY_P, 70, 'b', 'P', true }, - {KEY_A, 71, 'w', 'a'}, - {KEY_S, 72, 'w', 's'}, - {KEY_S, 73, 'b', 'S', true}, - {KEY_D, 74, 'w', 'd'}, - {KEY_D, 75, 'b', 'D', true}, - {KEY_F, 76, 'w', 'f'}, - {KEY_G, 77, 'w', 'g'}, - {KEY_G, 78, 'b', 'G', true}, - {KEY_H, 79, 'w', 'h'}, - {KEY_H, 80, 'b', 'H', true}, - {KEY_J, 81, 'w', 'j'}, - {KEY_J, 82, 'b', 'J', true}, - {KEY_K, 83, 'w', 'k'}, - {KEY_L, 84, 'w', 'l'}, - {KEY_L, 85, 'b', 'L', true}, + { KEY_A, 71, 'w', 'a' }, + { KEY_S, 72, 'w', 's' }, + { KEY_S, 73, 'b', 'S', true }, + { KEY_D, 74, 'w', 'd' }, + { KEY_D, 75, 'b', 'D', true }, + { KEY_F, 76, 'w', 'f' }, + { KEY_G, 77, 'w', 'g' }, + { KEY_G, 78, 'b', 'G', true }, + { KEY_H, 79, 'w', 'h' }, + { KEY_H, 80, 'b', 'H', true }, + { KEY_J, 81, 'w', 'j' }, + { KEY_J, 82, 'b', 'J', true }, + { KEY_K, 83, 'w', 'k' }, + { KEY_L, 84, 'w', 'l' }, + { KEY_L, 85, 'b', 'L', true }, - {KEY_Z, 86, 'w', 'z'}, - {KEY_Z, 87, 'b', 'Z', true}, - {KEY_X, 88, 'w', 'x'}, - {KEY_C, 89, 'w', 'c'}, - {KEY_C, 90, 'b', 'C', true}, - {KEY_V, 91, 'w', 'v'}, - {KEY_V, 92, 'b', 'V', true}, - {KEY_B, 93, 'w', 'b'}, - {KEY_B, 94, 'b', 'B', true}, - {KEY_N, 95, 'w', 'n'}, - {KEY_M, 96, 'w', 'm'} + { KEY_Z, 86, 'w', 'z' }, + { KEY_Z, 87, 'b', 'Z', true }, + { KEY_X, 88, 'w', 'x' }, + { KEY_C, 89, 'w', 'c' }, + { KEY_C, 90, 'b', 'C', true }, + { KEY_V, 91, 'w', 'v' }, + { KEY_V, 92, 'b', 'V', true }, + { KEY_B, 93, 'w', 'b' }, + { KEY_B, 94, 'b', 'B', true }, + { KEY_N, 95, 'w', 'n' }, + { KEY_M, 96, 'w', 'm' } }, { - min = -2, max = 1 -}) + min = -2, max = 1 +} ) -MKeyboard:RegisterLayout('FL Style', { - -- key, note, type, label, require SHIFT, alternative key - {KEY_Z, 24, 'w', 'z'}, - {KEY_S, 25, 'b', 's'}, - {KEY_X, 26, 'w', 'x'}, - {KEY_D, 27, 'b', 'd'}, - {KEY_C, 28, 'w', 'c'}, - {KEY_V, 29, 'w', 'v'}, - {KEY_G, 30, 'b', 'g'}, - {KEY_B, 31, 'w', 'b'}, - {KEY_H, 32, 'b', 'h'}, - {KEY_N, 33, 'w', 'n'}, - {KEY_J, 34, 'b', 'j'}, - {KEY_M, 35, 'w', 'm'}, +MKeyboard:RegisterLayout( 'FL Style', { + -- key, note, type, label, require SHIFT, alternative key + { KEY_Z, 24, 'w', 'z' }, + { KEY_S, 25, 'b', 's' }, + { KEY_X, 26, 'w', 'x' }, + { KEY_D, 27, 'b', 'd' }, + { KEY_C, 28, 'w', 'c' }, + { KEY_V, 29, 'w', 'v' }, + { KEY_G, 30, 'b', 'g' }, + { KEY_B, 31, 'w', 'b' }, + { KEY_H, 32, 'b', 'h' }, + { KEY_N, 33, 'w', 'n' }, + { KEY_J, 34, 'b', 'j' }, + { KEY_M, 35, 'w', 'm' }, - {KEY_Q, 36, 'w', 'q', false, KEY_COMMA, ','}, - {KEY_2, 37, 'b', '2', false, KEY_L, 'l'}, - {KEY_W, 38, 'w', 'w', false, KEY_PERIOD, '.'}, - {KEY_3, 39, 'b', '3', false, KEY_SEMICOLON, ';'}, - {KEY_E, 40, 'w', 'e', false, KEY_SLASH, '/'}, - {KEY_R, 41, 'w', 'r'}, - {KEY_5, 42, 'b', '5'}, - {KEY_T, 43, 'w', 't'}, - {KEY_6, 44, 'b', '6'}, - {KEY_Y, 45, 'w', 'y'}, - {KEY_7, 46, 'b', '7'}, - {KEY_U, 47, 'w', 'u'}, - {KEY_I, 48, 'w', 'i'}, - {KEY_9, 49, 'b', '9'}, - {KEY_O, 50, 'w', 'o'}, - {KEY_0, 51, 'b', '0'}, - {KEY_P, 52, 'w', 'p'}, - {KEY_LBRACKET, 53, 'w', '['}, - {KEY_EQUAL, 54, 'b', '='}, - {KEY_RBRACKET, 55, 'w', ']'} + { KEY_Q, 36, 'w', 'q', false, KEY_COMMA, ',' }, + { KEY_2, 37, 'b', '2', false, KEY_L, 'l' }, + { KEY_W, 38, 'w', 'w', false, KEY_PERIOD, '.' }, + { KEY_3, 39, 'b', '3', false, KEY_SEMICOLON, ';' }, + { KEY_E, 40, 'w', 'e', false, KEY_SLASH, '/' }, + { KEY_R, 41, 'w', 'r' }, + { KEY_5, 42, 'b', '5' }, + { KEY_T, 43, 'w', 't' }, + { KEY_6, 44, 'b', '6' }, + { KEY_Y, 45, 'w', 'y' }, + { KEY_7, 46, 'b', '7' }, + { KEY_U, 47, 'w', 'u' }, + { KEY_I, 48, 'w', 'i' }, + { KEY_9, 49, 'b', '9' }, + { KEY_O, 50, 'w', 'o' }, + { KEY_0, 51, 'b', '0' }, + { KEY_P, 52, 'w', 'p' }, + { KEY_LBRACKET, 53, 'w', '[' }, + { KEY_EQUAL, 54, 'b', '=' }, + { KEY_RBRACKET, 55, 'w', ']' } }, { - min = 0, max = 3 -}) \ No newline at end of file + min = 0, max = 3 +} ) \ No newline at end of file diff --git a/lua/mkeyboard/data/sheets.lua b/lua/mkeyboard/data/sheets.lua index e047a10..94ff39d 100644 --- a/lua/mkeyboard/data/sheets.lua +++ b/lua/mkeyboard/data/sheets.lua @@ -1,93 +1,92 @@ -MKeyboard.Sheets = {} +MKeyboard.sheets = {} -function MKeyboard:RegisterSheet(title, layout, sequence) - self.Sheets[#self.Sheets + 1] = { - title = title, - layout = layout, - sequence = sequence - } +function MKeyboard:RegisterSheet( title, layout, sequence ) + self.sheets[#self.sheets + 1] = { + title = title, + layout = layout, + sequence = sequence + } end -function MKeyboard:RegisterSheetForLayout(title, layoutName, sequence) - local layout +function MKeyboard:RegisterSheetForLayout( title, layoutName, sequence ) + local layout - for k, lay in ipairs(self.Layouts) do - if lay.name == layoutName or lay.originalName == layoutName then - layout = k - break - end - end + for k, lay in ipairs( self.layouts ) do + if lay.name == layoutName or lay.originalName == layoutName then + layout = k + break + end + end - if not layout then - ErrorNoHalt('Could not find any layout named "' .. layoutName .. '".') - return - end + if not layout then + ErrorNoHalt( 'Could not find any layout named "' .. layoutName .. '".' ) + return + end - self:RegisterSheet(title, layout, sequence) + self:RegisterSheet( title, layout, sequence ) end --- ##### Default sheets ##### +-- default sheets +-- all of these came from Playable Piano Reborn (thanks Phatso!) --- All of these came from Playable Piano Rebord (thanks Phatso!) - -MKeyboard:RegisterSheet('Clocks | Coldplay', 1, [[ +MKeyboard:RegisterSheet( 'Clocks | Coldplay', 1, [[ PUG PUG PU OUF OUF OU OUF OUF OU KYF KYF KY -]]) +]] ) -MKeyboard:RegisterSheet('Zelda Dungeon | Nintendo', 1, [[ +MKeyboard:RegisterSheet( 'Zelda Dungeon | Nintendo', 1, [[ GULP GULP GULP GULP THLP THLP THLP THLP FYLP FYLP FYLP FYLP DGLP DGLP DGLP DGLP EGKL EGKL EGKL EGKL SGKL SGKL SGKL SGKL -]]) +]] ) -MKeyboard:RegisterSheet('Bennie and the Jets | Elton John', 1, [[ +MKeyboard:RegisterSheet( 'Bennie and the Jets | Elton John', 1, [[ [SFHK] [SFHK] [SFHK] [SFHK][DGJL] [ADGJ] [ADGJ] A : L JK -]]) +]] ) -MKeyboard:RegisterSheet('Forest Maze | Super Mario RPG', 1, [[ +MKeyboard:RegisterSheet( 'Forest Maze | Super Mario RPG', 1, [[ WEDTY O J Y U J YUJ UTE D E WEDTD EDT DEW T DEW EDT DTY WEDTY O : POJ Y O JHY D T Y E -]]) +]] ) -MKeyboard:RegisterSheet('Clocks | Coldplay', 2, [[ +MKeyboard:RegisterSheet( 'Clocks | Coldplay', 2, [[ DPo DPo DP SPi SPi SP SPi SPi SP sOi sOi sO -]]) +]] ) -MKeyboard:RegisterSheet('Game of Thrones', 2, [[ +MKeyboard:RegisterSheet( 'Game of Thrones', 2, [[ o t Y i o t Y i y i E y Y i E Y y t o t Y i o t Y i y i E y Y i E y Y y t -]]) +]] ) -MKeyboard:RegisterSheet('Entertainer', 2, [[ +MKeyboard:RegisterSheet( 'Entertainer', 2, [[ yYu s us us isisisis sdDfsdfad sususus yYu s us us isisisis poIp sfdsdp adadadadad yYu s us us isisisis sdDfsdfad sususus fsdfsdsfsdfsdsfsdfads -]]) +]] ) -MKeyboard:RegisterSheet('To Zanarkand', 2, [[ +MKeyboard:RegisterSheet( 'To Zanarkand', 2, [[ [uax] f h k [xy] C [vt] [pyz] d G j [zt] x [Cr] [tk] o [dk] s [fk] G [sfhk] j z G I a S d G k [ex] u [ax] p [sx] d [psx] z v [ql] t i o p s g s g h j l [f0] r u a [fo] G [h8] w G [fu] [d9] e y f d [a5] 9 w e r y [f0] r u a [fo] G [h8] w G [hu] [j9] e y h [jy] [k5] 9 w e r y [f0] r u a [fo] G [h8] w G [fu] [d9] e y f d [a5] 9 w e [or] p [au8] w [aut] w [aur] w [a9] p d [ot6] o I y [u8] w t u o s f u o s f h [ej] u p a [sx] f [hjx] t [iz] o [pl] s [whk] y o p [av] d [vx0] r u I o a f G k -]]) +]] ) -MKeyboard:RegisterSheet('Under The Sea | Little Mermaid', 2, [[ +MKeyboard:RegisterSheet( 'Under The Sea | Little Mermaid', 2, [[ u o s f f f d g f s u u o s s s a d s s s s s a d s o u o o o i p o s s s s a d o u o o o i p o @@ -100,9 +99,9 @@ f d s p o f d s p o f d s f f d s p p s d d f d s d d f f s f d s p o f d s p o f d s f -]]) +]] ) -MKeyboard:RegisterSheet('Part of Your World | Little Mermaid', 2, [[ +MKeyboard:RegisterSheet( 'Part of Your World | Little Mermaid', 2, [[ l g h j l j d f g g s d g s d g | s d f h s d f h | y u i i u i o o | y u i i u i u i o o | u i o o i o i | t i o p p o o | y u i i u i o o | y u i i u i u i o o | u i o o i o i | t o p p o o | i o p p p p o i u t | i o p p p p o p y | i o p i u i i o p i u i y i o | i i i i o p t t t | t t t t y i t y i o | i i i i o p i o p i o | i o p @@ -110,9 +109,9 @@ p i o p p | i o p s # # p s # | # p i t # p i t t i u i | p o i i y u i o u i o | p o i i y u i o u i o # p p o o i | y i p o y i p o y u i o | p i i i i o p u u u u i | t t t t y i t y i o | i i i o p t t t t y i o | i o p p i o p p i o p s p # # p s # | # p i t i p # p o y u t i u i | t y u o t y u o i o p s t i o p s g -]]) +]] ) -MKeyboard:RegisterSheet('A Whole New World | Aladdin', 2, [[ +MKeyboard:RegisterSheet( 'A Whole New World | Aladdin', 2, [[ u y i u t w u y i u t u y y T u y r y t r t e t y t w @@ -126,9 +125,9 @@ u i p o y i u u u i o a p o t a s o t u y t y i u t r t -]]) +]] ) -MKeyboard:RegisterSheet('Can You Feel the Love Tonight', 2, [[ +MKeyboard:RegisterSheet( 'Can You Feel the Love Tonight', 2, [[ [t f] [rd] h [g e] | [g w] f s o [q p] | [0o] s o u [7y][8u][9i][0o] | [q p] a s d [0s] o | [q p] a s d [0ws] 8 | [q p] a s sd [0s] o f [9g] f d f [wd] r | [q p] a s d [0s] o | [q p] a s d [0ws] 8 | [q p] a s p p [0h] f s d | [9qg] f d f [wrd] q o [0th] f [wrd] h [etf] [us] [ i p] | q [0t] o s @@ -137,9 +136,9 @@ a s d [0ws] 8 | [q p] a s sd [0s] o f [9g] f d f [wd] r | [q p] a s d [0s] o | [ [0eh] d f s [qes] s p o | [g9] [0f] [qd] [qws] [8es] [8w] t f [dr] h [ge] | [gw] f s p [qp] | [0o] s o u [7y][8u][9i][0o] [q e] p a [ws] o o [0eh] d f s [qes] s p o | [g9] [0f] [qd] [qws] [0esi] y [8ues] -]]) +]] ) -MKeyboard:RegisterSheet('You Got A Friend In Me', 2, [[ +MKeyboard:RegisterSheet( 'You Got A Friend In Me', 2, [[ p s p d s p d g d g d s d d s s f f g d s g d s d p i p o i d f h g p i p o i d g d s p i p d g d s g g g p s p d s p d g d g d s d d s s s @@ -151,9 +150,9 @@ p P p o s p s p d s p s d g d g d s s d d s s s g g g g d s p i p d g d s g g g -]]) +]] ) -MKeyboard:RegisterSheet('Pirates of the Caribean', 2, [[ +MKeyboard:RegisterSheet( 'Pirates of the Caribean', 2, [[ e t y y - y u i i - i o u u - y t t y - e t y y - y u i i - i o u u - y t y - e t y y - y i o o - o p P P - p o p y - y u i i - o p y - y i u u - i y u y y u i o - p i y e - P i y E - e E e - p p p P p - o o o o p - p p p p P p - i i u y @@ -162,9 +161,9 @@ y u i - o p o - i u i - o p o - i o p - p o u - i u y - u t y - y u i - u i o - - y o i - o u y u t p P p p p p o - o i u i u T p P p p s p o - o i u i u T -]]) +]] ) -MKeyboard:RegisterSheet('Bad Romance', 2, [[ +MKeyboard:RegisterSheet( 'Bad Romance', 2, [[ Tyutiuiuyrtyuuyuyt tyutiuiuyrtyuuyuyt eeuuiu @@ -175,15 +174,15 @@ eeuuiu eeuuiu eeuuiu ttet -]]) +]] ) -MKeyboard:RegisterSheet('Super Mario Brothers', 2, [[ +MKeyboard:RegisterSheet( 'Super Mario Brothers', 2, [[ fff s f h o soupa Ppo fhj ghf sda soupa Ppo fhj ghf sda hGgDf Opspsd hGgDf lll hGgDf Opspsd [DO][id][us] ssssdfspo ssssdf ssssdfspo fffsfho fsoopggpajjjhgfspo fsoopggp [ao][dg dg | dg][sf][ad][os] u t -]]) +]] ) -MKeyboard:RegisterSheet('Für Elise', 2, [[ +MKeyboard:RegisterSheet( 'Für Elise', 2, [[ fDfDfadsp tupa uOas ufDfDfadsp @@ -192,16 +191,16 @@ ufuffxDfDfDfDfDfDfadsp tupa uOas ufDfDfadsp tupa usap -]]) +]] ) -MKeyboard:RegisterSheet('Terminator Theme', 2, [[ +MKeyboard:RegisterSheet( 'Terminator Theme', 2, [[ yui u t q yui u t p o yui u t w q 9 qq 0 9 -]]) +]] ) -MKeyboard:RegisterSheet('Metal Gear Solid Theme', 2, [[ +MKeyboard:RegisterSheet( 'Metal Gear Solid Theme', 2, [[ u y t y u e u y t y u @@ -209,15 +208,15 @@ p o u t y u p s a s d s o p a s a p o p -]]) +]] ) -MKeyboard:RegisterSheet('Happy Birthday', 2, [[ +MKeyboard:RegisterSheet( 'Happy Birthday', 2, [[ ssdsgf ssdshg ssjhgfdhhfsds -]]) +]] ) -MKeyboard:RegisterSheet('Morrowind Theme', 2, [[ +MKeyboard:RegisterSheet( 'Morrowind Theme', 2, [[ t y Y Y i o o P i @@ -231,15 +230,15 @@ d s P O o i Y o i Y y t -]]) +]] ) -MKeyboard:RegisterSheet('Dueling Banjos', 2, [[ +MKeyboard:RegisterSheet( 'Dueling Banjos', 2, [[ dfgdfsdas erterweqw affghfhg qrrtyryt -]]) +]] ) -MKeyboard:RegisterSheet('Ocarina of Time Theme', 2, [[ +MKeyboard:RegisterSheet( 'Ocarina of Time Theme', 2, [[ 4 {qeyu} 1 {0ryu} 4 qeyu 1 0ry[uy] u [4d] qey{Hs[au]} 1 0ry[uy] u [4d] qey{Hs[au]} [1a] 0ry[uy] u [4d] qey{Hs[au]} fa [4p] [qu]eyu u [1y] [0y]ryu @@ -249,23 +248,23 @@ MKeyboard:RegisterSheet('Ocarina of Time Theme', 2, [[ [1y] [0y]ryu [Rs] o o [ti] o -]]) +]] ) -MKeyboard:RegisterSheet('Godfather Theme', 2, [[ +MKeyboard:RegisterSheet( 'Godfather Theme', 2, [[ cbmnbmbnbcvx cbmnbmbnbcvz -]]) +]] ) -MKeyboard:RegisterSheet('X-Files Theme', 2, [[ +MKeyboard:RegisterSheet( 'X-Files Theme', 2, [[ p f d f h f p f d f j f l k j h j f l k j h k p f d f h f pu -]]) +]] ) -MKeyboard:RegisterSheet('NiGHTS Dreams Dreams', 2, [[ +MKeyboard:RegisterSheet( 'NiGHTS Dreams Dreams', 2, [[ sdf dfg fdsas o sdf dfg fdsas h sdf dfg fdsas o o s hgfds dfd fds @@ -277,9 +276,9 @@ dfh dfp as jhgfgh dfh dfp asdfgo fd fds -]]) +]] ) -MKeyboard:RegisterSheet('Saria’s Song', 2, [[ +MKeyboard:RegisterSheet( 'Saria’s Song', 2, [[ ipa ipa ipafd asaou yuou ipa ipa ipafd @@ -288,17 +287,17 @@ yui opa sau yui opa sdf yui opa sau uy iu oi po ap sa ds fgdf -]]) +]] ) -MKeyboard:RegisterSheet('Still Alive', 2, [[ +MKeyboard:RegisterSheet( 'Still Alive', 2, [[ o I u u I o I u u I y u e e u I o u T y u e e I o I u u I o I u u I y u e u I o u T y u e y u i u yu te e E t i u y y t y t t t e E t i o i u y y u i i o p P P p o i o p p o i y t y i i u u I I 9 7 7 9 9 7 79 9 7 7 9 e9 o I u u I o I u u I y u e u I o u T y u e e I ao Ip ou ou Ip y ao Ip ou ou Ip Iy ou ye u I o u T y u e y u i u y t e E t i u y y t yt t t t e E t i o i u y y u i i o p P P p o i o p p o i i y t y i i u u I I 9 9 7 7 9 9 7 7 9 9 7 7 9 9 o7 u u7 -]]) +]] ) -MKeyboard:RegisterSheet('Imagine', 2, [[ +MKeyboard:RegisterSheet( 'Imagine', 2, [[ 10w 8 w0 8 w0 8 3wr 8 4qe 8 qe 8 qe 8 4qe E r 10w 8 w0 8 w0 8 3wr 8 4qe 8 qe 8 qe 8 4qe E r @@ -310,9 +309,9 @@ w yiw te4 q te q rw5 9 rw 95 tw1 0 rw 0 EW3 0 yw 0 te4 q te q rw5 9 rw 95 tw1 0 rw 0 EW3 0 yw 0 tw4 q tw q rw5 9 rw 95 tw1 0 rw 0 EW3 0 yw 0 te4 q et q rw5 9 rw 9 4 tw01 8 2 8 1 8 2 8 -]]) +]] ) -MKeyboard:RegisterSheet('Harry Potter Theme', 2, [[ +MKeyboard:RegisterSheet( 'Harry Potter Theme', 2, [[ r u0 o I u0 a p0 I0 u0 o I Y0 i r70 r u0 o I u0 a dy9wE S st8qW O Y80e a P pQ0 o uo w u0 o aw07 o aw07 o sw07 a Pw08 I ow07 a P Ew08 r aw07 o aw07 o aw07 o dw9^ S s8q0 O sw07 a P EQ0 o uw0 u3 @@ -320,39 +319,39 @@ s8q0 O sw07 a P EQ0 o uw0 u3 a fu h G fu k ju Gu fu h G Du g aru a fu h G fu k zdyoP L lstiO H ltup k J jITO h fh o fu h kour h kour h lour k Jout G hour k J Pout a kour h kour h kour h zoyE L ltiu H lour k J PITO h fou u0 -]]) +]] ) -MKeyboard:RegisterSheet('Work It Out', 2, [[ +MKeyboard:RegisterSheet( 'Work It Out', 2, [[ IIoppoIuyyuIIuu IIoppoIuyyuIuyy uuI y uIoI y uIoI uyu e IIoppoIuyyuIuyy -]]) +]] ) -MKeyboard:RegisterSheet('BBC Sherlock Theme', 2, [[ +MKeyboard:RegisterSheet( 'BBC Sherlock Theme', 2, [[ 8 w w Q w W w q t q t t r t y t Y o t t y Y yYyt i t t y Y Y i y y Y t t y r W w 8 -]]) +]] ) -MKeyboard:RegisterSheet('Forget You', 2, [[ +MKeyboard:RegisterSheet( 'Forget You', 2, [[ s s s [duo] f s s s [dyi] p | s s [sip] s s s [dip] p p (tou) | s s s [duo] f s s | s [dyi] p | s s [sip] s s s [dip] p p [tou] | f h j [zou] l d [fip] h f d [sip] s p s | [ht] [fu] [dy] [st] | s f h [jt] h j [DY] d s [sip] d D [dip] s p s | [ht] [fu] [dy] (sip) | s f h (jt) h j [DY] d s [sip] d D [dip] s p s | [ht] [fu] [dy] [sip] | [hut] [fot] [dyi] [stu] | [hut] [fot] [dyi] [sip] [stu] -]]) +]] ) -MKeyboard:RegisterSheet('Somewhere Over the Rainbow', 2, [[ +MKeyboard:RegisterSheet( 'Somewhere Over the Rainbow', 2, [[ t s aopas t p o e i utyuiy rtyut ououououoioioioipp ououououoIpIpIpIpa a d a t s aopas t p o e i utyui yrtyu [osf] -]]) +]] ) -MKeyboard:RegisterSheet('My Heart Will Go On', 2, [[ +MKeyboard:RegisterSheet( 'My Heart Will Go On', 2, [[ i s gg s i i s ggfh i s gg is is ggf IOP OI OS POI YT OIOS SP DSPIO [t8] ttt [r5] t r [r4] t y [u5] yy [t8] ttt [r5] t t [w4] 5 [t8] ttt [r5] t r [r4] t y [u5] u [t8] ttt [r5] t y [w4] @@ -360,41 +359,41 @@ i s gg s i i s ggfh i s gg is is ggf IOP OI OS POI YT OIOS SP DSPIO [r5] t r [r4] t y [u5] y [t8] [t8] ttt [r5] t r [r4] t y [u5] y [t8] ttt [r5] t t [w4] 5 [t8] ttt [r5] t r [r4] t y [u5] y [t8] ttt [r5] t y [w4] -]]) +]] ) -MKeyboard:RegisterSheet('Chariots of Fire', 2, [[ +MKeyboard:RegisterSheet( 'Chariots of Fire', 2, [[ s 8qeg h j 80wh f - s 8qeg h j 80wh s 8qeg h j 80wh f - f 8qeg f s 80ws l k j h 0wrk h qetj g tuoh l k j h 0wrk l k j h 0wrk h qetj g 80wh f f 8qeg f s 80ws -]]) +]] ) -MKeyboard:RegisterSheet('Tetris Theme', 2, [[ +MKeyboard:RegisterSheet( 'Tetris Theme', 2, [[ fasd sap psf dsa sd fs pp dgj hgf sf dsa asd fs pp -]]) +]] ) -MKeyboard:RegisterSheet('Phantom of the Opera', 2, [[ +MKeyboard:RegisterSheet( 'Phantom of the Opera', 2, [[ u p u [2o] i i 5 y o y [6u] u p u [2o] i i 5 y o y [6u] 0 e t [2u] y y 5 y o y [6u] u [6p] o i u y t r e W q q 0 [60] -]]) +]] ) -MKeyboard:RegisterSheet('Beethoven’s Fifth', 2, [[ +MKeyboard:RegisterSheet( 'Beethoven’s Fifth', 2, [[ [ho] [ho] [ho] [DY] - [gi] [gi] [gi] [dy] o o o Y - O O O o - D D D s o o o y - O O O o - g g g d o o i Y - s s d D - o o i Y - D D g h [ho] [ho] [gi] [DY] [yh] [tl] -]]) +]] ) -MKeyboard:RegisterSheet('Lilium | Elfen Lied', 2, [[ +MKeyboard:RegisterSheet( 'Lilium | Elfen Lied', 2, [[ ISOpp ISOpapI Ouyu IyTyuI OpapO ISOpp ISOpapI Ouyu IyTyapOIiYiI PaSdpO dSfpSa pOIi PaSdpO dSfpSapOIiI -]]) +]] ) -MKeyboard:RegisterSheet('Hall of the Mountain King', 2, [[ +MKeyboard:RegisterSheet( 'Hall of the Mountain King', 2, [[ y u i o p i p O u O o u o y u i o p i p @@ -404,28 +403,28 @@ o p a s d a d D a D d a d o p a s d a d D a D d -]]) +]] ) -MKeyboard:RegisterSheet('Zelda\'s Lullaby', 2, [[ +MKeyboard:RegisterSheet( 'Zelda\'s Lullaby', 2, [[ a dp opa dp a d j h dsap a dp opa dp a d j h z z lklkh l kjkjf z lklkh zb -]]) +]] ) -MKeyboard:RegisterSheet('Lavender Town', 2, [[ +MKeyboard:RegisterSheet( 'Lavender Town', 2, [[ l v n C (4x) g g d d g f d j P P g g f f j h g j k k g g d d g f d j P P g g f f g f d j P P U Y T u y t u g g d d g f d j P P -]]) +]] ) -MKeyboard:RegisterSheet('Imperials March', 2, [[ +MKeyboard:RegisterSheet( 'Imperials March', 2, [[ www(Ew (Ew yyyYEQ(Ew owo IiuYu -]]) +]] ) -MKeyboard:RegisterSheet('Aozora | Air', 2, [[ +MKeyboard:RegisterSheet( 'Aozora | Air', 2, [[ LZZl lXllZ ZlZZL @@ -438,9 +437,9 @@ LlC-lLg-L-Z-lL LZ-lL L-Z-lL (h)LlC-lLg-L-[hZ]-lL -]]) +]] ) -MKeyboard:RegisterSheet('Sailor Moon Theme', 2, [[ +MKeyboard:RegisterSheet( 'Sailor Moon Theme', 2, [[ osDh hg gD dg adgH HJ HhgDh osDl lk kJ H Hhgh g Dd s wtYo oi iYYy i wryi iY Yy t Y wtYoooi iYYy i wryi oiYy Y wtYo oi iY y i wryi iiYy t Y wtYo oi iooP O Ooio iiYy t s H Jl l JH h gDg h s H Jl llJHh wtYo oi iYYy i wryi oiYy t Y wtYo oi iooPOO Ooio i Y y t ssss H g h @@ -449,9 +448,9 @@ iooP O Ooio iiYy t s H Jl l JH h gDg h s H Jl llJHh wtYo oi iYYy i wryi oiYy t Y iooPOO Ooio i Yy t osDh hg gD dg adgH HJ HhgDh osDl lk kJ H Hhgh g Dd s tttt s H Jl l JH h gDg h s H Jl llJHh wtYo oi iYYy i wryi oiYy t Y wtYo oi iooPOO Ooio i Yy t ssss hgh g Dd s Hhgh g Dd s (Ydo) -]]) +]] ) -MKeyboard:RegisterSheet('Keyboard Cat', 2, [[ +MKeyboard:RegisterSheet( 'Keyboard Cat', 2, [[ t u o u t-u o-u r y i y r-y i-y e t u t e-t u-t @@ -460,24 +459,24 @@ t u o u t-u o-u r y i y r-y i-y e t u t e-t u-t w -]]) +]] ) -MKeyboard:RegisterSheet('F.U.N | Spongebob', 2, [[ +MKeyboard:RegisterSheet( 'F.U.N | Spongebob', 2, [[ t t y u t - e e r t e - t t t y u o y - w t t t y u y p p p a s a p o o u o u y t -]]) +]] ) -MKeyboard:RegisterSheet('Pokemon Theme', 2, [[ +MKeyboard:RegisterSheet( 'Pokemon Theme', 2, [[ dddd d s p i i d d s P s DDDD D d s P P d d s P d | dddd d s p ii d d s P s DDDD D d s P P d d s P d | d g h d g h h g d s P g g hJ j h g d g hhh h g d s P P d d s P d | d g h d g h h h g h g h h j J jh g d D JJ ddd JJ J J J j | dd g h h dd g h J h d g [dh] -]]) +]] ) -MKeyboard:RegisterSheet('Lost Theme', 2, [[ +MKeyboard:RegisterSheet( 'Lost Theme', 2, [[ [hwtu] [hwru] [wtu] [wru] [whtu] f h f h f [whru] k h| [hwtu][hwru] [wtu] [wru] [hwtu] f h f h f [hwru] k h | [hqet] g h g h g [whtu] g f g h | [hqet] g h g h g [fwtu] [dwry] [s1wt] -]]) +]] ) -MKeyboard:RegisterSheet('Clubbed to Death', 2, [[ +MKeyboard:RegisterSheet( 'Clubbed to Death', 2, [[ 5yoyPyoy 6yoysyoy ^yoydyPy @@ -491,9 +490,9 @@ PtYPpty IowE yoyPodP hdJhzJv -]]) +]] ) -MKeyboard:RegisterSheet('Lord of the Rings Theme', 2, [[ +MKeyboard:RegisterSheet( 'Lord of the Rings Theme', 2, [[ t y [80tu] o [70ru] y [68tu] [58] t u o [qeip] s [wroa] o[80tu] i u [79ry] @@ -504,9 +503,9 @@ y [68tu] [58] t u o [680etu] e t u 8 6 [579wry] w r y7 5 [80tu] -]]) +]] ) -MKeyboard:RegisterSheet('Smooth Criminal | Michael Jackson', 2, [[ +MKeyboard:RegisterSheet( 'Smooth Criminal | Michael Jackson', 2, [[ pp opaa d aa ss ssaoo p pp opaa d aa ss ssaoo i pppfdp pppfdpppaoop @@ -518,21 +517,21 @@ lll kh kkjg jjhhkl pppfdp pppfdp ppaoop pppfdp pppfdp ppaoop fsdd oo fsdd o sf dsppopaa aa ss ssaoop -]]) +]] ) -MKeyboard:RegisterSheet('Stairway to Heaven | Led Zeppelin', 2, [[ +MKeyboard:RegisterSheet( 'Stairway to Heaven | Led Zeppelin', 2, [[ e t u p Wa u t a ws u t s IQ y e I qu t e u t e w5 e6 e6 6 6q e t u p Wa u t a ws u t s IQ y e I qu t e u t e w5 e6 e6 6 6q -]]) +]] ) -MKeyboard:RegisterSheet('Nightmare on Elm Street', 2, [[ +MKeyboard:RegisterSheet( 'Nightmare on Elm Street', 2, [[ p d j H j f g p p d j H j f g j J S p d l z l J k g p d j H j f g j J S -]]) +]] ) -MKeyboard:RegisterSheet('Time | Inception', 2, [[ +MKeyboard:RegisterSheet( 'Time | Inception', 2, [[ [6et] 6 6 6 [3ro] 3 3 3 [5wr] 5 5 5 {2eI} 2 2 2 [6et] 6 6 6 [10wr] 1 1 1 [59wr] 5 5 5 {29Q} 2 2 2 [680t] 6 6 6 [30wro] 3 3 3 [57wr] 5 5 5 {29QI} 2 2 2 @@ -548,24 +547,24 @@ MKeyboard:RegisterSheet('Time | Inception', 2, [[ [60sfl] [sl] [uf] [15ahk] [oh] [ts] [59rya] [pj] [yd] {69GC} [uf] [ep] [6ps] [jl] [30h] [af] -]]) +]] ) -MKeyboard:RegisterSheet('Inspector Gadget', 2, [[ +MKeyboard:RegisterSheet( 'Inspector Gadget', 2, [[ pasd fs Da ds pasd f j H pasd fs Da ds pasd f H j -]]) +]] ) -MKeyboard:RegisterSheet('Max Payne Theme', 2, [[ +MKeyboard:RegisterSheet( 'Max Payne Theme', 2, [[ tYiosoPoYr WwywyYr tYiosoPoYr WwywyY rt -]]) +]] ) -MKeyboard:RegisterSheet('Max Payne 3 Theme', 2, [[ +MKeyboard:RegisterSheet( 'Max Payne 3 Theme', 2, [[ [18] t Y o s o P o Y [29] r W w [5wy] w y Y r [18t] Y i o s o P o Y [29r] W w [5wy] w y Y [18] [ts] [YD] [ig] [oh] [sl] [oh] [PJ] [oh] [YD] @@ -574,16 +573,16 @@ Y i o s o P o Y [29r] W w [5wy] w y Y [18] [18ra] [WO] [wo] [5wyd] [wo] [yd] [YD] [4qi] [qi] [wo] [WO] [yd] [5wrya] [wo] [YD] [yd] [4giq] [ig] [oh] [OH] [yd] [5wts] [ra] [ep] [ra] [18osh] -]]) +]] ) -MKeyboard:RegisterSheet('Right Here Waiting For You', 2, [[ +MKeyboard:RegisterSheet( 'Right Here Waiting For You', 2, [[ toshhgfd wyoddfgf eussdfdsapo 8wtooiuy 59wyyuiu 60ttyuiuytrt shlvvcxz odhzzxcx pfllzxzlkjh toshhgfd wyoddfgf eussdfg q gfd w sas -]]) +]] ) -MKeyboard:RegisterSheet('Amelie', 2, [[ +MKeyboard:RegisterSheet( 'Amelie', 2, [[ [d9] [qey] s [a6] [80e] p [d9] [qey] f d s a s [a6] [80e] p [sq] [et] a [u8] [0r] [sq] [et] d s a s a [u8] [0r] @@ -591,26 +590,26 @@ p [sq] [et] a [u8] [0r] [sq] [et] d s a s a [u8] [0r] [pj] [dz9] [qey] f d s a s [ak6] [80e] [pj] [sql] [et] [ak] [uf8] [0r] [sql] [et] d s a s a [uf8] [0r] fuiuiu dui sui ayuyuy ptyuytfuiuiu dui sui ayuyuy ptyuyt -]]) +]] ) -MKeyboard:RegisterSheet('Let It Be | The Beatles', 2, [[ +MKeyboard:RegisterSheet( 'Let It Be | The Beatles', 2, [[ tuo tuo ruo ruo tup tup tuo tui yi tuo tuo ruo ruo yip tuo yi tu tu -]]) +]] ) -MKeyboard:RegisterSheet('Rugrats', 2, [[ +MKeyboard:RegisterSheet( 'Rugrats', 2, [[ [sf][dg][fh] [gj] [hk] [jl] [hk] [fh][gj] [fh] [dg] [sf][dg][fh] [gj] [hk] [jl] [kz] [hk][jl] [hk] [gj] (3x) [sf][dg][fh] [gj] [hk] [jl] [sf][dg][fh] [gj] [hk] [jl] [kz] [jl] [hk] [gj] [fh] [dg] [ad] k l 1 5 8 4 6 8 5 9 7 4 8 6 1 5 8 4 6 8 5 9 7 4 8 6 1 -]]) +]] ) -MKeyboard:RegisterSheet('Once Upon a Dream', 2, [[ +MKeyboard:RegisterSheet( 'Once Upon a Dream', 2, [[ i u i y etu i y u o p I o - ps a P P p o d s P p p o I o y u i u i y u i I o y tp y P - a d ps i d s d P o f d g f d s - s D d s P d yi wu eti -]]) +]] ) -MKeyboard:RegisterSheet('Just The Way You Are | Bruno Mars', 2, [[ +MKeyboard:RegisterSheet( 'Just The Way You Are | Bruno Mars', 2, [[ ss ghj g[ps] [ps] Pp sghjhgghg gghjhjhJjghg g[ps] [ps] Pp [psgj] [pg] gg ff dd ss PpPsi gg ff dd ss PpPsi s[ip] s[ip] s[ip] Pi sd ghh Jl @@ -618,9 +617,9 @@ s[ip] s[ip] s[ip] Pi [is] [id] [ig] [oh] [oh] J[ls] [psgj] [oh] [ig] [oh] [pj] s h g l g[ps] [ps] Pp s h g l j gghjhjhJjghg g[ps] [ps] Pp ss g l j g[ps] [ps] Pp s ghjhJjhg gghjhjhJjghg g[ps] [ps] Pp [psgj] -]]) +]] ) -MKeyboard:RegisterSheet('Brahams Lullaby', 2, [[ +MKeyboard:RegisterSheet( 'Brahams Lullaby', 2, [[ f f hu o f f hu o f h lu ko j ji hu @@ -634,22 +633,22 @@ s s pl t j g uh t f s pg h g of id us o f f uh o x x flv -]]) +]] ) -MKeyboard:RegisterSheet('Mariage d\'amour', 2, [[ +MKeyboard:RegisterSheet( 'Mariage d\'amour', 2, [[ h h - j j - J J - j j - h h - d d - P P - o o - g g - D D - d D g D D D - g g - h h - j j - g g - s s - D D - d d - s s D d z - d - o P d s d - o P d s d - o P D d D - o P D d D - D d D f g - g h g h d z - h J z l z - h J z l z - h J Z z Z - h J Z z Z - Z z Z x c - c v c v z J - d d D D - s s j j - s s d d - P P h g h - P P s s - p d s d J - J J J l l - J j h g - g h g d J - J J J l l - J j h g - g h g h JB - JB JB JB lm lm - JB jb hv gc - gc hv gc dz JB - JB JB JB lm lm - JB jb hv gc - gc hv gc hv -]]) +]] ) -MKeyboard:RegisterSheet('Moonlight Sonata', 2, [[ +MKeyboard:RegisterSheet( 'Moonlight Sonata', 2, [[ [e9] yi eyi eyi eyi [e8]yi eyi eyi eyi [E^]yi eyi [5E] Yo EYo [e6]To eyi [e6]yu wTu [9q]eyeyieyip [e y p] [p*]uo euo euop uop [9p]yi eyi [wP]yo Eyo [8p]ti eti [8o]tusuo [4i] -]]) +]] ) -MKeyboard:RegisterSheet('Aeris Theme | Final Fantasy', 2, [[ +MKeyboard:RegisterSheet( 'Aeris Theme | Final Fantasy', 2, [[ z L k j f f f G h G f d h k ypsf j z upfl j f ypsf j z L x z k L sfj psf @@ -662,9 +661,9 @@ z LQ ke j69 e GG 5 wry l z L kw r CC w 5 r y z L k j5 fe fu f G yoah G f dp h j z yoah G d f 2d 6 9 0 Q e u p z d G L d G k d G uoadj pf f G oadh GL fx dz 0ryo 6wyua S 2d 6 Q e y -]]) +]] ) -MKeyboard:RegisterSheet('Final Fantasy X-2 Theme', 2, [[ +MKeyboard:RegisterSheet( 'Final Fantasy X-2 Theme', 2, [[ 4-8-w-e -5-9-e-r -6-0-r-t -3-7-I-w h-l4-8-k-hw-e-d-l5-9-k-hr-t-g-f6-0-z-zr-t-w-5-9-e- r-e hw-l4-8-k-hw-e-d-l5-9-k-hr-t-g-f6-0-z-zr-t-l-z5-9-x-le-r-k-h-h4-s-8-w-e-h-h5-d-9- e-r-h-h6-f-0-r-t-h-h5-d-9-e-r h-h4-si-8-w-e-h-ha5-dy-9-e-r-h-hs6-fu-0-r-t-h-ha5-d-9- @@ -672,9 +671,9 @@ e-r h-l4-8-k-hw-e-d-l5-9-k-hr-t-g-f6-0-z-zr-t-wl-z5-9-e-r-e hw-lg4-8-k-hw-e-d-l5 hr-t-g-fa6-0s-z-zr-t-l-z5-9-x-le-r-k h-h4-si-8-w-e-h-ha5-dy-9-e-r-h-hs6-fu-0-r-t-h- ha5-d-9-e-r h-h4-si-8-w-e-h-ha5-dy-9-e-r-h-hs6-fu-0-r-t-h-ha5-d-9-e-r-y 4-8-w-e-5- 9-e-r-6-0-r-t-3-7-I-w 4-8-w-e-5-9-e-r-6-0-r-t-u-p-a-s-eu6 -]]) +]] ) -MKeyboard:RegisterSheet('Fade to Black', 2, [[ +MKeyboard:RegisterSheet( 'Fade to Black', 2, [[ r r7 Q w Q 7 Q 9 Q 6e Q w Q 6 Q 9 Q r7 Q w Q 7 Q y9 Q | | *T 0 e 0 e 0a 6d 0G ar7 Q w QG | h j7 Q 9 Q j ke6 Qj w h Q j6 Q 9 Q r7 Qk j wh GQ h7 GQ y9f | GQ | *TG h G0 e 0f *G 0 f 6 d 0 pr7 Q wa Q 7 Q 9 Qd 6eS Q | w Q 6 Qd 9S Qh 7rG Q w Q 7 Q 9y Qh | *Tj 0 @@ -683,9 +682,9 @@ Lw zQ 7L z L kQ Ly9 Qz *TL 0n eb 0v * 0 6v 0b | 7rC Q zw Qk 7 Q 9C vQ Ce6 Q wz Q 9C vQ | Cr7 Q | wz Qb 7 Q 9yv Q CT* 0 e 0 * 0 6 0 4p 8a 9s 4d %f 7g h0 7j 7k | 0l zW x 7 c 0 vW rc v c zy | 60er t e 0 u 0 w e t w08 t 0 u 0 w | e t 5w y 9 0 9 eo ow | w3 0 7 wr ry 60er t e 0 u 0 w e t w08 t | 0 u 0 w e t 5w y 9 o 9 w e w w urw0 3 0 7 3rw te -]]) +]] ) -MKeyboard:RegisterSheet('Ballade pour AdEline', 2, [[ +MKeyboard:RegisterSheet( 'Ballade pour AdEline', 2, [[ [18t] osd tosd tosd tosd [8t] ofo tofo tofo tofo[8f] w [uf] w u | w [uof] w [pg] [9pg] | e [ipg] e i [pg] [epg] [pg] [ipg] [pg] [epg] [ah] [wah] | y [ah] y a y | [ah] [sj] [8of]w u w u w u 5 [1of] w [uof] w u | [of] [wof] [of] | [8of] [of] [wof] [pg] [2pg] | e [ipg] e 9 [pg] @@ -698,9 +697,9 @@ wyio wyio | [5y]iod [wy]iod | [5o]dgh [wo]dgh | | [5d]ghz [wd]ghz | [5h]zcv [wh] [18hx] w [uhx] w 8 [w8hx] [w8hx] [w8hx] | [w8hx] [w8hx] [w8hx] [w8hx] [kv] [wkv] y [akv] y a d h [kv] | [lb] [tkx] | o f h s j l c v [av] k z b [thx] | o f h s j l c v [av] k z b | [18hx] -]]) +]] ) -MKeyboard:RegisterSheet('Requiem for a Dream', 2, [[ +MKeyboard:RegisterSheet( 'Requiem for a Dream', 2, [[ 6e 6e 6e 6e 4q 4q 30 30 6e 6e 6e 6e 4q 4q 30 30 | 6t r 6e 0 6t r 6e 0 4t r 4e 0 3y t 3r t | 6t r 6e 0 6t r 6e 0 4t r 4e 0 3y t 3r t | 6t e 6 t e 6t e 6 t e 4t e 4 t e 3t e t e 3t e | t e 6t r t 6 t r 6t r t 6 t r | 4t r t 4 t r 3t r r r 3t r r r | 6t e 6 t e 6t e 6 t e 4t e 4 t e 3t e t e 3t e | t @@ -710,53 +709,53 @@ e e e 3e r r r 3r t t t | 6t r 6e 0 6t r 6e 0 4t r 4e 0 3y t 3r t | 6t r 6e 0 6t r r r 3t r r r | 6t e 6 t e 6t e 6 t e 4t e 4 t e 3t e t e 3 t e | t e 6t r t 6 t r 6t r t 6 t r 4t r t 4 t r 3t r r r 3t r r r | 6t e 6 t e 6t e 6 t e 4t e 4 t e 3t e t e 3t e | t e 6t r t 6 t r 6t r t 6 t r | 4t r t 4 t r 3t r r r 3t r r r | 6t r 6e 0 6t r 6e 0 6t r 6e 0 6t r 6e 0 | 3 6 0 e t u -]]) +]] ) -MKeyboard:RegisterSheet('Love Story | Beethoven', 2, [[ +MKeyboard:RegisterSheet( 'Love Story | Beethoven', 2, [[ lffllffllfgfdddkkddkkdfdsssjjssjjsdsaaaHH jkgf | lffllffllfgfdddkkddkkdfdsssjjssjjsdsaaaHH jkHL dfpg pg ppaa dgfd | psfsd adas dfpsfg opsa sdgf oiuY IpIo LggLLggLLgGgD | DDllDDllDgDSSSJJSSJJSDSsssjj paiu -]]) +]] ) -MKeyboard:RegisterSheet('The Bear Necessities | Jungle Book', 2, [[ +MKeyboard:RegisterSheet( 'The Bear Necessities | Jungle Book', 2, [[ t y i - p O p o i | i o i o i o i y | t i t i p d s P p o \ s d s - d s d s p | i o i o i p (ii) | o p s p s p i y t i | i (u u) y t t | o (o i) u i | i (u u) y t o | o i o [up] | p P s d d d P p |o p P s d s p | o i s (ddd) | P p o i u i -]]) +]] ) -MKeyboard:RegisterSheet('Never Gonna Give You Up', 2, [[ +MKeyboard:RegisterSheet( 'Never Gonna Give You Up', 2, [[ passdapo ppaspohhd ppaspsdapo | ppaspodddfd | sdfsdddfdo paspdfd | opspffd opspdds opspsdapoods | opspffd opsphasap opspsdapoods -]]) +]] ) -MKeyboard:RegisterSheet('I\'m Blue', 2, [[ +MKeyboard:RegisterSheet( 'I\'m Blue', 2, [[ PyoPsipPoPdDods | PyoPsipPoPdDods | PyoPsipPoPdDods | PyoPptioEioiop -]]) +]] ) -MKeyboard:RegisterSheet('Symphony 40 | Wolfgang Amadeus Mozart', 2, [[ +MKeyboard:RegisterSheet( 'Symphony 40 | Wolfgang Amadeus Mozart', 2, [[ D d d D d d D d d J | J j h h g D D d s s | d s s d s s d s s j | j h G G D d d s P P | J j j | l G j h d J j j l kjhgf fgHjkjHgf| Z x Z x ZxZxZx| D d d D d d D d d j | J j h h g D D d s s | f d d f d d f d d l | l k j j h g g f d d -]]) +]] ) -MKeyboard:RegisterSheet('Pearl Harbor Theme', 2, [[ +MKeyboard:RegisterSheet( 'Pearl Harbor Theme', 2, [[ 8 w tu y t 3 7 0o I u 4 8 qu y t 80 w wt t y 6 0 es a u 3 7 0o I r 8 w tu y t 5t 9 wr e w 9q e yi u e q u y q 9 e yi u y 5wg f d f 8 w tu y t 3 7 0o I u 8t u y w 30 o I r 9 eo u e o r ak 8sl w tak sl uf 3oh 7 0 w 3 7 0oh w 4pj 8 qoh pj ts 8uf w t 5wyd 9 wak 6sl 0 eak sl uf 3oh 7 0 w 3 7 0oh w 9ig e yuf yd ts 5uf 9 w r 5 9 w r 5yd 9 w r 5ak 8sl w tak sl uf 3oh 7 0 w 3 7 0oh w 4pj 8 qoh pj ts 8uf w t 5wyd ak 6sl 0 eak sl uf 3oh 7 0 w 3 7 0oh w 9-e-i- g uf yd ts 4-8-i-g uf yd ts 5-9-i-g uf yd ts 8ts w ts -]]) +]] ) -MKeyboard:RegisterSheet('Crazy Monsters and Nice Sprites | Skrillex', 2, [[ +MKeyboard:RegisterSheet( 'Crazy Monsters and Nice Sprites | Skrillex', 2, [[ hghJhzlJiPpgDdsPgPoPdvzJhcJhg hghJhzlJiPpgDdsPgPoPdvzJhcJhg oioPhzlJiPpgDdsPgPoPdvzJhcJhg oioPhzlJiPpgDdsPgPoPdvzJhcJhg PPg ddddsPPsdDd iPPPiPPPgPPPsPpoiPPg -]]) +]] ) -MKeyboard:RegisterSheet('Take On Me | A-ha', 2, [[ +MKeyboard:RegisterSheet( 'Take On Me | A-ha', 2, [[ GGdaafffHHjkjjjfdGGGffGf GGdaafffHHjkjjjfdGGGffGf GGdaafffHHjkjjfdGGGfff @@ -764,18 +763,18 @@ ddSa SSSpGGGfdddSa aSdSapaSap dddd pppppOOII eOp fGf pfG fGf SHj kLkjx aSddSa aSdSpGGGfSddSa aSdSaapaSap dddd pppppppOOII eOp fGf pfG fGf SHj kLkjx -]]) +]] ) -MKeyboard:RegisterSheet('Kokiri Forest | Zelda OOT', 2, [[ +MKeyboard:RegisterSheet( 'Kokiri Forest | Zelda OOT', 2, [[ hlhfdfg hjh ghg fdfs PiPdso hlhfdfg hjh ghg fdfs PiPds pspad psf dfd a pspsd sdD ghg d pspad psf dfd a pspsd sdD ghg df vbv ghg fgf dsPsdso [zc][lx] lzl PsP pPpoiuiouoP -]]) +]] ) -MKeyboard:RegisterSheet('Song of Storms | Zelda OOT', 2, [[ +MKeyboard:RegisterSheet( 'Song of Storms | Zelda OOT', 2, [[ [yip][yip]uoa[ips][ips]uoa [yip][yip]uoa[ips][ips]uoa yid yid fgfgfsp @@ -788,9 +787,9 @@ dgz dgz xcxcxlj jdghj jdghf dgz dgz xcxcxlj jdghjjd -]]) +]] ) -MKeyboard:RegisterSheet('Dire Dire Docks | Super Mario 64', 2, [[ +MKeyboard:RegisterSheet( 'Dire Dire Docks | Super Mario 64', 2, [[ 59wery[5o]9w[dh] 48qery[4o]8q[dh] 859wery[5o]9w[dh] 48qery[4o]8q[dh] @^(eEyo^([dh] @@ -802,20 +801,20 @@ yopasapoytoy ttryoer [ro][ei][ei][ei][ei][ei][ei][ei][ei][ei][ei] [Eo][Eo][Eo][Eo]E[Eo][Eo][Eo][Eo][Eo] [to][to][to][tp][tp][tp] -]]) +]] ) -MKeyboard:RegisterSheet('File Select | Super Mario 64', 2, [[ +MKeyboard:RegisterSheet( 'File Select | Super Mario 64', 2, [[ oddpdadasd oddpda oddpdadasd oddpda dsdadh dsdads dsdadh jhjhkh -]]) +]] ) -MKeyboard:RegisterSheet('Start | Super Mario 64', 2, [[ +MKeyboard:RegisterSheet( 'Start | Super Mario 64', 2, [[ uu uuuuii iiiioo ooooii iiiiuuopot iipapY oosdshgsoifspiuYT -]]) +]] ) -MKeyboard:RegisterSheet('Bomb-omb Battlefield | Super Mario 64', 2, [[ +MKeyboard:RegisterSheet( 'Bomb-omb Battlefield | Super Mario 64', 2, [[ tetyt0qQwwww yYuYuopot wWeWetyte 0qwo wqooiopoy yYuYuopoP OpOpsdsp poIowoIow[yi]u[t0]wet @@ -827,9 +826,9 @@ suPsuP ptYptY suPsuP [sfh][sgj][sfh][DG][sfh][fhl][hlx] hjhGhlx os[pdg][pfh][pdg][PSf][pdg][dhk][hkz] osghgfgkz oa[psf][pdg][psf][OpD][psf][sfj][fjl] oafgfDfjl [sfj][dGk][fjl][Gkz][Gjl][Gkz][Gjl][dGj][sdG][osd][9os][07o]q9 jklzlzljGdsoq9 -]]) +]] ) -MKeyboard:RegisterSheet('Bowser\'s Theme | Super Mario 64', 2, [[ +MKeyboard:RegisterSheet( 'Bowser\'s Theme | Super Mario 64', 2, [[ 9[96][2q][6e][%W] 96qeW [ey] {dsoytw [269]} [ey][ru][ti][yo][ey][ru][ti][yo] @@ -841,9 +840,9 @@ shg[ad] shgdk s[oh][og][od][OD]sd[OD]HD[od]h p[dz][gj]H[kn] [9y] pdjH pdhg pdgf oSfd pdS oPp pdg pdg Po PSf PSf gj zjg zjg fh Lhf Lhf dg jgd jgd ShJjh zLzZzLHjgfghgfSd -]]) +]] ) -MKeyboard:RegisterSheet('Ending Song | Super Mario 64', 2, [[ +MKeyboard:RegisterSheet( 'Ending Song | Super Mario 64', 2, [[ [wru] uio[tip] poi[wru] uio[tip] asd[wru] uio[tip] [yoa][yoa] [yoa] uuiuiout uopppadso ppadsos tyioiuyto uuiuiout uopppadso ppadsos sdgfass @@ -855,9 +854,9 @@ sdfaoupaso iopoaspsd ffgfghfs fhjjjkzlh jjkzlhl sdghgfdsh ti[iIO][TIP]POI[ti]iIO[TIP]POI[ti]iIO[TIP][TpS]OS -]]) +]] ) -MKeyboard:RegisterSheet('Corridors of Time | Chrono Trigger', 2, [[ +MKeyboard:RegisterSheet( 'Corridors of Time | Chrono Trigger', 2, [[ y I a S G I a S f I a S G I a S y I a S G I a S f I a S G I a S jHGSpOoIuyYT I a S f I a S G I a S a I a S G I a S H I a S G I a S [OH] [OH] [IG] [IG] G H [pj] [ak] [pj] H [IG] [IG] [uf] [uf] @@ -867,9 +866,9 @@ S [OH] [OH] [IG] [IG] [pj] [IG] [SL] [ak] [SL] [OH] [IG] [uf] Y [uf] [IG] [ep] [yd] [uf] [IG] [OH] [pj] [OH] [ra] [uf] [IG] [OH] [pj] [OH] [OaH] [IG] [IpG] -]]) +]] ) -MKeyboard:RegisterSheet('On To The Grass Town | Cavestory', 2, [[ +MKeyboard:RegisterSheet( 'On To The Grass Town | Cavestory', 2, [[ ot opo toiuuyuii iuyy iuyy iuyy ot opo toiuuyuii yidd yidd yidd ertrtytyu uiouopuyuytt @@ -878,9 +877,9 @@ hs hjh shgffdfgg gfdd gfdd gfdd hs hjh shgffdfgg dgzz dgzz dgzz passdfdfg fghfhjfdfds pssasdsdf of hg hg hg -]]) +]] ) -MKeyboard:RegisterSheet('Canon In C | Johann Pachelbel', 2, [[ +MKeyboard:RegisterSheet( 'Canon In C | Johann Pachelbel', 2, [[ f o s f - d o a d - s u p s - a u o a p t i p - o t u o - p y i p - a o y r [sf] o s f - [ad] o a d - [ps] u p s - [oa] u o a @@ -891,22 +890,22 @@ h fgh fghopasdfgf sdf uiopoiouioi poi uyuytyuuioi pop asapopasdf [fh] f h h j h g [sf] s f f g f d s p s s o s P p s a [osf] [oad] [ups] [uoa] [tip] [tuo] [yip] [oyr] [uos] -]]) +]] ) -MKeyboard:RegisterSheet('Black Mesa Source Theme | Joel Nielsen', 2, [[ +MKeyboard:RegisterSheet( 'Black Mesa Source Theme | Joel Nielsen', 2, [[ [oth] l g l D l d l s l s l s [oth] l g l D l d l s l s l s s d [^ED] d D d [soiq] [tw8h] l g l D l d l s l s l d D g [tw8h] l g l D l d l s l s l h H [qh] g D d [soiq] -]]) +]] ) -MKeyboard:RegisterSheet('Merry Go Round | Howl\'s Moving Castle', 2, [[ +MKeyboard:RegisterSheet( 'Merry Go Round | Howl\'s Moving Castle', 2, [[ wtYo oiY YyYt tips ssdapa uOaDSa psap oiuioyu -]]) +]] ) -MKeyboard:RegisterSheet('Open Sesame Tofu! | Mother 3', 2, [[ +MKeyboard:RegisterSheet( 'Open Sesame Tofu! | Mother 3', 2, [[ o ps d sf s p o ps d sf f f g g g h h h s s ss s @@ -914,17 +913,17 @@ g g g h h h s s ss s O PS D Sf S P O PS D Sg g g G G G H H H L -]]) +]] ) -MKeyboard:RegisterSheet('Overworld | Super Mario World', 2, [[ +MKeyboard:RegisterSheet( 'Overworld | Super Mario World', 2, [[ pityii ytiispo tpityii ytiPpoi pitpi OitOo pitpi Oits pityii opityi ysdsds tPpoi -]]) +]] ) -MKeyboard:RegisterSheet('Ending | Super Mario World', 2, [[ +MKeyboard:RegisterSheet( 'Ending | Super Mario World', 2, [[ [ipsf] [29][29] [ipsf][ipsf][29][29] [oah][oah] [5w][5w] [oah][oah] [5w] f hj h jklkJj Df hj h HjJjHh @@ -937,33 +936,33 @@ fDfs sps s sa aP P pf ffDfgfS p pfdfdfdsp od ddSdfda o dsssdDf o -]]) +]] ) -MKeyboard:RegisterSheet('Koopa Troopa Beach | Super Mario Kart', 2, [[ +MKeyboard:RegisterSheet( 'Koopa Troopa Beach | Super Mario Kart', 2, [[ fgh z lhg fghl khj hgf fgh J jfh gfg Ghjk lxzk jhh fgh z lhg fghl khj hgf hgffdSd hhgfdgfDfk -]]) +]] ) -MKeyboard:RegisterSheet('Title | Super Mario Kart', 2, [[ +MKeyboard:RegisterSheet( 'Title | Super Mario Kart', 2, [[ hhjhG z jlkjkl hhjhG z jlkjkl jjkzl h sgfgjh f llzcZ J hhGjh -]]) +]] ) -MKeyboard:RegisterSheet('World 1 | Super Mario Land', 2, [[ +MKeyboard:RegisterSheet( 'World 1 | Super Mario Land', 2, [[ [fh][DG][dg][sf] w fdsf sdffdsfghj ssposs iopa [cv][cv] fdsf sdffdsjhlfd ssdfss gfsd vh jklk h ghgfgGh jklk h Zzl ooiuy -]]) +]] ) -MKeyboard:RegisterSheet('OverWorld | Super Mario Bros 3', 2, [[ +MKeyboard:RegisterSheet( 'OverWorld | Super Mario Bros 3', 2, [[ oshgpPa hv fDf Df ps fDf f s d @@ -976,25 +975,25 @@ fDfops [ip][ip][ps][ps] ij pp[ps][ps] Ij [oa][oa][ps][ps][PS][PS][ad][ad] [dh][dh] -]]) +]] ) -MKeyboard:RegisterSheet('Green Hill Zone | Sonic The Hedgehog', 2, [[ +MKeyboard:RegisterSheet( 'Green Hill Zone | Sonic The Hedgehog', 2, [[ [oa][ip][oa][ip][oa][ip][ps][oa][ip] [ip][oa][ps][ip][oa][ps][ps][oa] ljlklk{hjlj} jxzlklk{hjlx} ljlklk{hjlj} jjgjhjhs {sfJ}jhg{fsdf}[ps]asd{fsjfH}hgDsD hjh jx xcxvxl -]]) +]] ) -MKeyboard:RegisterSheet('Marble Zone | Sonic The Hedgehog', 2, [[ +MKeyboard:RegisterSheet( 'Marble Zone | Sonic The Hedgehog', 2, [[ ertua apa apa apaputopi {czjg zjgd jgdp gdpip} pop pop popaiu cczkH a apa apa apaputopi {czjg zjgd jgdp gdpip} aOaap xxzlk j{ljl}jkhdk g{jgj}ghjkh j{ljl}jkhdk g{jgj}ghjkh -]]) +]] ) -MKeyboard:RegisterSheet('Emerald Hill Zone | Sonic The Hedgehog 2', 2, [[ +MKeyboard:RegisterSheet( 'Emerald Hill Zone | Sonic The Hedgehog 2', 2, [[ [dg][fh][sf][dg] opossdf dpssd {PsPd}sPsp opossdf dpsd {PsPd}sPsp @@ -1003,9 +1002,9 @@ opssdsfdp PPsdsPsp pspds ljhjlklk asa klzlkzlljxl ljhjlklk asa [yod][yos][upf] {czjg zjgd jgdp gdpi} -]]) +]] ) -MKeyboard:RegisterSheet('Mad World', 2, [[ +MKeyboard:RegisterSheet( 'Mad World', 2, [[ O s o O i o Y y O s o O i o O P i i O O i i s s s O @@ -1023,36 +1022,36 @@ i O O s s d P P d d P P i i O O s d P P P d d P P O i O i -]]) +]] ) -MKeyboard:RegisterSheet('Resistance | Muse', 2, [[ +MKeyboard:RegisterSheet( 'Resistance | Muse', 2, [[ i asdsasp i pasapad o dfgfdfs fdsa dsap {apO} -]]) +]] ) -MKeyboard:RegisterSheet('Course Clear | Super Mario World', 2, [[ +MKeyboard:RegisterSheet( 'Course Clear | Super Mario World', 2, [[ (sg) (sg) d (sg) dgds (sg) d jkjkh {jJjh} g (cb) -]]) +]] ) -MKeyboard:RegisterSheet('Dead Island Theme', 2, [[ +MKeyboard:RegisterSheet( 'Dead Island Theme', 2, [[ (QT) (QE) r E T E r E T E r E Y -]]) +]] ) -MKeyboard:RegisterSheet('Triage At Dawn | Half-Life 2', 2, [[ +MKeyboard:RegisterSheet( 'Triage At Dawn | Half-Life 2', 2, [[ s p s a o p u y t u y u (x2) fpufpufp (x2) dpudpudp (x2) l j l k h k (j - hold) (z - hold) -]]) +]] ) -MKeyboard:RegisterSheet('Reconstructing Science | Portal 2', 2, [[ +MKeyboard:RegisterSheet( 'Reconstructing Science | Portal 2', 2, [[ isoO isoO isoOPOoO isoO isoO isoOPSSPOoO isoO isoO isoOPOoO isoO isoO PSSPOoO i s O P o O i u i s O P S o P u (x2) [(ig) (sl) (OH) (PJ) (oh) (OH) (ig) (uf) (ig) (sl) (OH) (PJ) (SL) (oh) (PJ) (uf)] x2 -]]) +]] ) -MKeyboard:RegisterSheet('Back to the Future', 2, [[ +MKeyboard:RegisterSheet( 'Back to the Future', 2, [[ T O S a P O P O I O T O S a P O P O I O O T o OPOiT o OP O Y O DD d sd (PD) @@ -1060,34 +1059,34 @@ O T o OPOiT o OP O Y O DD d sd (PD) (PS) (TI) s SD (PS) P I s (SD) S O S HH h gh H -]]) +]] ) -MKeyboard:RegisterSheet('Gonna Fly Now | Rockey', 2, [[ +MKeyboard:RegisterSheet( 'Gonna Fly Now | Rockey', 2, [[ t t tt t tt u ttt (tu) (tu) (tu)(tu) (tu) (tu) (tu) (uo) (tu) (tu) (tu) (ru)(ru)(ru)(ru)(ru)(ru)(ru) (4q) (30) (ru)(ru)(ru)(ru)(ru)(ru)(ru) u o p p a u u o p p a u yty tyu ttr re ew i(ru) uuu u u uuuu u uu uu -]]) +]] ) -MKeyboard:RegisterSheet('Where\'s Hiccup | How to Train Your Dragon', 2, [[ +MKeyboard:RegisterSheet( 'Where\'s Hiccup | How to Train Your Dragon', 2, [[ [hsx] [cz] [hz] c [lx] t [hsx] [cz] [hz] c [lx] s [gj] [gj] k [gk] j h [fs] s [gijt] [gj] [hk] [hk] j h [fs] [flp] [gil] [koz] x [hsx] a p h [hix] v [koz] x [hsx] a p f [bl] v [hux] [hx] z [hkoz] x [Gjy] k [dglpy] [fostv] [dg] [ad] g [fs] [ep] [fs] [dgl] [dk] f g [fl] [dkow] [iqs] [gj] [gj] [hk] [0dhu] s [fs] a [9py] [gj] [gj] [hk] [dhkowy] o [8stw] o [8stw] d [59aw] o [59akw] [ls] [48cgijlpqs] -]]) +]] ) -MKeyboard:RegisterSheet('Sweden | C418', 2, [[ +MKeyboard:RegisterSheet( 'Sweden | C418', 2, [[ [0ou] Q [dpw] r [epI] w [9pS] [0aou] Q [dpw] r [epIS] w [9pSf] [0aou] Q [dpw] r [epIS] w [9pSf] [0aou] [jQ] k [dpw] r d f [epIS] w G j [9pSf] [0aou] z [kQ] j [dpw] r d f [epIS] w j G [9pSf] [0aou] [jQ] k [dpwz] r [Cd] [fx] [depILS] w [zG] L [9pSfj] [0aou] [kQ] j [dpw] r d f [epIS] w G j [9pSf] [0aou] [jQ] k [dpw] r d f [epIS] w G j [9pSf] [0aou] [jQ] k [dpwz] r d f [epIS] [wC] G j [9pSf] [7adrG] k j [0afO] f d [6epS] d f [5aowy] [8adrzG] k j [0afO] f [dx] [6uepLS] z [dC] f [5aky] o a -]]) +]] ) -MKeyboard:RegisterSheet('Spice and Wolf', 2, [[ +MKeyboard:RegisterSheet( 'Spice and Wolf', 2, [[ [S*T] [QIG] [WOH] [rak] [YDZ] S D [*OSg] [SW] [OT] [0u] [ra] [uf] [epSH] [uG] [pS] [raSH] [IG] [YD] @@ -1098,9 +1097,9 @@ S D [*OSg] [SW] [OT] [0u] [ra] [uf] [IPS] [V Z L H] T Y [*i] I i [W*] T Y [6u] I u [60] e [eu] u u [7rQY] r [370W] [@*Q] T Y [*i] I i [W*] T Y [6u] I u [0e] [Qru] u u [7rQY] r [37ru] [^WTI] [ETO] -]]) +]] ) -MKeyboard:RegisterSheet('Song of Healing', 2, [[ +MKeyboard:RegisterSheet( 'Song of Healing', 2, [[ (aq)tptit(aq)tptit(aq)tptu(ty)(u0)rrr (aq)tptit(aq)tptit(aq)tptu(ty)(u0)rrr (i9)etere(i9)etere(i8)wuwr(we)(8r)www @@ -1109,9 +1108,9 @@ MKeyboard:RegisterSheet('Song of Healing', 2, [[ (iy)(iy)(iy)(ai)(ai)(ai)(ut)(yt)(pt)(ut) (pi)(pi)(pi)(pd)(pd)(pd)(ou)(ou)(ou)(su)(ou) (iy)(oy)(py)(ia)(is)(id)(ip)(ia)(id)(wuf)to -]]) +]] ) -MKeyboard:RegisterSheet('Ed Sheeran - Perfect', 2, [[ +MKeyboard:RegisterSheet( 'Ed Sheeran - Perfect', 2, [[ u y t [8wu]||u||u|| u y t [etu]||u||u|| u y t [eti]||u||t|| @@ -1127,9 +1126,9 @@ t y u [wry]| |u||y||[0et]| | [qes]| a p| a [8wu]| | [7wo]| i u| i [etu]||y||[qei]||u|| [8wu]||y||[7wy]||t| r [80wt] -]]) +]] ) -MKeyboard:RegisterSheet('Frank Ocean - Self Control', 2, [[ +MKeyboard:RegisterSheet( 'Frank Ocean - Self Control', 2, [[ [8j] w [th] f [0h] [wj] t| [8f] [wf] [tg] f [0h] w [rg] f 6 0 e| 8 0 e| [6j] [0j] [eh] f [8h] 0 e| [9j] [ej] [th] g [qh] e [tg] f 9 e t| q e t| 5 [9h] [wh] j [7h] 9 [wf] h [5j] [9j] [wh] f [7h] 9 [wj] h @@ -1143,9 +1142,9 @@ MKeyboard:RegisterSheet('Frank Ocean - Self Control', 2, [[ [tl] o [sl]| [ul] o [sh]jlz[tx] o [sx]| [ux] o [ah] h[ex]zuzp nt [ub] p lz[el] u [pl]| [tl] u p| [yl] p [sl]| [ix] p [sh]jl [yv] [pb] [sz]l i p [sl]l [el] uj[px]zzlt u p| e u p| [etup] -]]) +]] ) -MKeyboard:RegisterSheet('Lil Nas X - Old Town Road', 2, [[ +MKeyboard:RegisterSheet( 'Lil Nas X - Old Town Road', 2, [[ [ues]|[us]|[tod]|[od]|[wda]|[da]|[qpd]|[pd]|[ues]|[us]|[tod]|[od]|[wda]|[da]|[qpi] [pif] fff[spf6] d [utse] pp[f8][od] [sod][wt]ppo5 [oda] [wr] df[spi4] a [qiea]ppo[spf6] d [utse] pp[f8][od] [sod] [wt]ppo5 [oda] [wr] df[spi4] a [qpie]ppp [upd6][f0][fe][d0][tspfe] 6 [us8][wd][td]s[utsod] w [yso5] [d9][wd][so9][wsrod] [d5]s[pid4][s8][qd]f[qied]s[tpi8] @@ -1163,9 +1162,9 @@ dpp[pf][wt8][pd] [pd] ppp[w95] [oa]|ap[sqi84] a p[xjf][xjf][xjf][xjf6]0[zed]0[ts [wpj][oh]59[zwhd]9[wr] [zhd5][xf][sl4]8[qka] [qkea][pj][pj8][oh][xjf6]0[zed]0[tsle] [pj6][pj] [xjf8][zwd]t[zd][ut][pj][wpj][oh]59[zwhd]9[wr] [zhd5][xf][sl4]8[qka] [qpje]|[ues]|[us]|[tod]| [od]|[wda]|[da]|[qpd]|[pd]|[ues]|[us]|[tod]|[od]|[wda]|[da]|[qpd] -]]) +]] ) -MKeyboard:RegisterSheet('Heart Attack - Demi Lovato', 2, [[ +MKeyboard:RegisterSheet( 'Heart Attack - Demi Lovato', 2, [[ SSSSSso | osssssii | ioOOOOOoooooi [it] | SSSSSssPP | PPPPPOsO SSSSssssPP | OPPPOPOPOPsS @@ -1177,9 +1176,9 @@ sPOioODsP | POPOPsPOioOSso | ioSSSSSso | osssssii | ioOOOOOoooooiioODsP OPOPOs OioODsP | OPPPOPOOi -]]) +]] ) -MKeyboard:RegisterSheet('When I Was Your Man | Bruno Mars', 2, [[ +MKeyboard:RegisterSheet( 'When I Was Your Man | Bruno Mars', 2, [[ [Ips] [ips] [uos] df [Ips] [ips] [tu]w[tu]w[tu]w[ry]w[etu] [etu] [wtu] [wtu] [eyi] [eyi] [eyi] [eyi] [etu] [etu] [wtu] [wtu] [eyi] [eyi] [eyi] [eyi] @@ -1199,4 +1198,4 @@ MKeyboard:RegisterSheet('When I Was Your Man | Bruno Mars', 2, [[ [qet] [qet] [wry] [wry] [etu] [etu] [9qe] [9qe] [qet] [qet] [qwt] [qwt] [80w] [80w] [80w] [80w] [qet] [qet] [qwt] [qwt] [80w] -]]) \ No newline at end of file +]] ) \ No newline at end of file diff --git a/lua/mkeyboard/sv_init.lua b/lua/mkeyboard/sv_init.lua index 2440dab..b753c5b 100644 --- a/lua/mkeyboard/sv_init.lua +++ b/lua/mkeyboard/sv_init.lua @@ -1,105 +1,105 @@ -resource.AddWorkshop('2656563609') +resource.AddWorkshop( '2656563609' ) -util.AddNetworkString('mkeyboard.set_entity') -util.AddNetworkString('mkeyboard.notes') +util.AddNetworkString( 'mkeyboard.set_entity' ) +util.AddNetworkString( 'mkeyboard.notes' ) -local function FindBroadcastTargets(pos, radius, filter) - -- make the radius squared since we're using DistToSqr (faster) - radius = radius * radius +local function FindBroadcastTargets( pos, radius, filter ) + -- make the radius squared since we're using DistToSqr (faster) + radius = radius * radius - local found = {} + local found = {} - for _, v in ipairs(player.GetHumans()) do - if v ~= filter and pos:DistToSqr(v:GetPos()) < radius then - table.insert(found, v) - end - end + for _, v in ipairs( player.GetHumans() ) do + if v ~= filter and pos:DistToSqr( v:GetPos() ) < radius then + table.insert( found, v ) + end + end - return found + return found end -function MKeyboard:IsAMusicalKeyboard(ent) - return IsValid(ent) and ent:GetClass() == 'ent_musical_keyboard' +function MKeyboard:IsAMusicalKeyboard( ent ) + return IsValid( ent ) and ent:GetClass() == 'ent_musical_keyboard' end -function MKeyboard:BroadcastNotes(notes, ent, automated, ignoreTarget) - if #notes == 0 then return end +function MKeyboard:BroadcastNotes( notes, ent, automated, ignoreTarget ) + if #notes == 0 then return end - -- only broadcast to nearby players, if any - local targets = FindBroadcastTargets(ent:GetPos(), self.NET_BROADCAST_DISTANCE, ignoreTarget) - if #targets == 0 then return end + -- only broadcast to nearby players, if any + local targets = FindBroadcastTargets( ent:GetPos(), self.NET_BROADCAST_DISTANCE, ignoreTarget ) + if #targets == 0 then return end - net.Start('mkeyboard.notes', false) - net.WriteEntity(ent) - net.WriteBool(automated) - net.WriteUInt(#notes, 5) + net.Start( 'mkeyboard.notes', false ) + net.WriteEntity( ent ) + net.WriteBool( automated ) + net.WriteUInt( #notes, 5 ) - for _, params in ipairs(notes) do - net.WriteUInt(params[1], 7) -- note - net.WriteUInt(params[2], 7) -- velocity - net.WriteUInt(params[3], 6) -- insrument - net.WriteFloat(params[4]) -- time offset - end + for _, params in ipairs( notes ) do + net.WriteUInt( params[1], 7 ) -- note + net.WriteUInt( params[2], 7 ) -- velocity + net.WriteUInt( params[3], 6 ) -- insrument + net.WriteFloat( params[4] ) -- time offset + end - net.Send(targets) + net.Send( targets ) end -concommand.Add('keyboard_leave', function(ply, _, args) - if #args < 1 then return end - local ent = ents.GetByIndex(args[1]) +concommand.Add( 'keyboard_leave', function( ply, _, args ) + if #args < 1 then return end + local ent = ents.GetByIndex( args[1] ) - if MKeyboard:IsAMusicalKeyboard(ent) and ent.Ply == ply then - ent:RemovePlayer() - end -end) + if MKeyboard:IsAMusicalKeyboard( ent ) and ent.Ply == ply then + ent:RemovePlayer() + end +end ) -net.Receive('mkeyboard.notes', function(_, ply) - local ent = net.ReadEntity() +net.Receive( 'mkeyboard.notes', function( _, ply ) + local ent = net.ReadEntity() - -- make sure the client didnt send the wrong entity - if not MKeyboard:IsAMusicalKeyboard(ent) then return end + -- make sure the client didnt send the wrong entity + if not MKeyboard:IsAMusicalKeyboard( ent ) then return end - local automated = net.ReadBool() - local noteCount = net.ReadUInt(5) - local notes = {} + local automated = net.ReadBool() + local noteCount = net.ReadUInt( 5 ) + local notes = {} - -- make sure the client isnt tricking us - noteCount = math.Clamp(noteCount, 1, MKeyboard.NET_MAX_NOTES) + -- make sure the client isnt tricking us + noteCount = math.Clamp( noteCount, 1, MKeyboard.NET_MAX_NOTES ) - -- read all notes, to make sure we have as - -- many as the client told us on noteCount - for i = 1, noteCount do - notes[i] = { - net.ReadUInt(7), -- note - net.ReadUInt(7), -- velocity - net.ReadUInt(6), -- instrument - math.Clamp(net.ReadFloat(), 0, 1) -- time offset - } - end + -- read all notes, to make sure we have as + -- many as the client told us on noteCount + for i = 1, noteCount do + notes[i] = { + net.ReadUInt( 7 ), -- note + net.ReadUInt( 7 ), -- velocity + net.ReadUInt( 6 ), -- instrument + math.Clamp( net.ReadFloat(), 0, 1 ) -- time offset + } + end - -- make sure the client is actually using this keyboard - if IsValid(ent.Ply) and ply == ent.Ply then - -- then broadcast the notes - MKeyboard:BroadcastNotes(notes, ent, automated, ply) - end -end) + -- make sure the client is actually using this keyboard + if IsValid( ent.Ply ) and ply == ent.Ply then + -- then broadcast the notes + MKeyboard:BroadcastNotes( notes, ent, automated, ply ) + end +end ) -- hooks that only run serverside on single-player -- TODO: is there a better way to detect these hooks client-side? if game.SinglePlayer() then - util.AddNetworkString('mkeyboard.key') + util.AddNetworkString( 'mkeyboard.key' ) - hook.Add('PlayerButtonDown', 'mkeyboard_SPButtonDown', function(ply, button) - net.Start('mkeyboard.key', true) - net.WriteUInt(button, 8) - net.WriteBool(true) - net.Send(ply) - end) + hook.Add( 'PlayerButtonDown', 'mkeyboard_ButtonDownWorkaround', function( ply, button ) + net.Start( 'mkeyboard.key', true ) + net.WriteUInt( button, 8 ) + net.WriteBool( true ) + net.Send( ply ) + end ) - hook.Add('PlayerButtonUp', 'mkeyboard_SPButtonUp', function(ply, button) - net.Start('mkeyboard.key', true) - net.WriteUInt(button, 8) - net.WriteBool(false) - net.Send(ply) - end) + hook.Add( 'PlayerButtonUp', 'mkeyboard_ButtonUpWorkaround', function( ply, button ) + net.Start( 'mkeyboard.key', true ) + net.WriteUInt( button, 8 ) + net.WriteBool( false ) + net.Send( ply ) + end ) end \ No newline at end of file