Skip to content

Commit

Permalink
Add default configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed Dec 1, 2024
1 parent b1bf526 commit 8b3b7d9
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/keymap/keyactions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1945,8 +1945,12 @@ local keyActionsMisc = {

}

---@type table<string, UIKeyAction>
local keyActionsCinematics = {
['cinematics_bind_keys'] = {
action = 'UI_Lua import("/lua/ui/game/cinematics/config.lua").ApplyDefaultKeyLayout()',
category = 'cinematics',
},

-- CRUD-like operations
['cinematics_move_to_clear'] = {
action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").Clear(true)',
Expand Down
74 changes: 74 additions & 0 deletions lua/ui/game/cinematics/Config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
--*******************************************************************************
-- MIT License
--
-- Copyright (c) 2024 (Jip) Willem Wijnia
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--
--*******************************************************************************

local function DefaultMoveToLayout()
local keyActions = import("/lua/keymap/keyactions.lua").keyActions

return {
-- clear it out
['CTRL-SHIFT-BACKSPACE'] = keyActions.cinematics_move_to_clear,

-- navigate between sequences
['Q'] = keyActions.cinematics_move_to_jump_backward,
['W'] = keyActions.cinematics_move_to_jump_current,
['E'] = keyActions.cinematics_move_to_jump_forward,

-- add, insert, overwrite and remove camera orientations
['A'] = keyActions.cinematics_move_to_add,
['S'] = keyActions.cinematics_move_to_insert,
['D'] = keyActions.cinematics_move_to_overwrite,
['DELETE'] = keyActions.cinematics_move_to_remove,

-- animation
['Shift-Q'] = keyActions.cinematics_move_to_animate_forward,
['Shift-W'] = keyActions.cinematics_move_to_animate_backward,
['Shift-E'] = keyActions.cinematics_move_to_jump_and_animate_forward,
['Shift-R'] = keyActions.cinematics_move_to_jump_and_animate_backward,

-- store/retrieve from preference file
['1'] = keyActions.cinematics_move_to_store_01,
['2'] = keyActions.cinematics_move_to_store_02,
['3'] = keyActions.cinematics_move_to_store_03,

['ALT-1'] = keyActions.cinematics_move_to_retrieve_01,
['ALT-2'] = keyActions.cinematics_move_to_retrieve_02,
['ALT-3'] = keyActions.cinematics_move_to_retrieve_03,
}
end

function ApplyDefaultKeyLayout()
local userKeys = import("/lua/keymap/keymapper.lua").GetKeyMappings()

-- cinematics-related keys
local moveToKeyMap = DefaultMoveToLayout()

-- we overwrite existing user keys with our own key maps. This lasts for the entire session,
-- only restarting the game can undo this. It does not affect your preference file.
local combinedKeyMap = table.combine(userKeys, moveToKeyMap)

-- apply the keys
IN_ClearKeyMap()
IN_AddKeyMapTable(combinedKeyMap)
end

0 comments on commit 8b3b7d9

Please sign in to comment.