From 47763eb91fd4e1a44fca718a08aa7e37425796f3 Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 1 Dec 2024 18:58:15 +0100 Subject: [PATCH] Fix various small issues --- lua/keymap/keyactions.lua | 28 ++++++++++++++----------- lua/keymap/keydescriptions.lua | 15 +++++++------- lua/ui/game/cinematics/Config.lua | 9 +++++--- lua/ui/game/cinematics/MoveTo.lua | 34 +++++++++++++++++++++++-------- 4 files changed, 56 insertions(+), 30 deletions(-) diff --git a/lua/keymap/keyactions.lua b/lua/keymap/keyactions.lua index 0a37c815dc..9341a3e461 100755 --- a/lua/keymap/keyactions.lua +++ b/lua/keymap/keyactions.lua @@ -1960,16 +1960,20 @@ local keyActionsCinematics = { action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").Append(true)', category = 'cinematics', }, - ['cinematics_move_to_insert'] = { - action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").Insert(true)', + ['cinematics_move_to_remove'] = { + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").RemoveLast(true)', category = 'cinematics', }, - ['cinematics_move_to_overwrite'] = { - action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").Overwrite(true)', + ['cinematics_move_to_insert_at_index'] = { + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").InsertAfterIndex(true)', category = 'cinematics', }, - ['cinematics_move_to_remove'] = { - action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").Remove(true)', + ['cinematics_move_to_overwrite_at_index'] = { + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").OverwriteAtIndex(true)', + category = 'cinematics', + }, + ['cinematics_move_to_remove_at_index'] = { + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").RemoveAtIndex(true)', category = 'cinematics', }, @@ -2008,27 +2012,27 @@ local keyActionsCinematics = { -- Preference file interactions ['cinematics_move_to_store_01'] = { - action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").StoreToDisk("01")', + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").StoreToDisk("01", true)', category = 'cinematics', }, ['cinematics_move_to_store_02'] = { - action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").StoreToDisk("02")', + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").StoreToDisk("02", true)', category = 'cinematics', }, ['cinematics_move_to_store_03'] = { - action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").StoreToDisk("03")', + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").StoreToDisk("03", true)', category = 'cinematics', }, ['cinematics_move_to_retrieve_01'] = { - action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").RetrieveFromDisk("01")', + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").RetrieveFromDisk("01", true)', category = 'cinematics', }, ['cinematics_move_to_retrieve_02'] = { - action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").RetrieveFromDisk("02")', + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").RetrieveFromDisk("02", true)', category = 'cinematics', }, ['cinematics_move_to_retrieve_03'] = { - action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").RetrieveFromDisk("03")', + action = 'UI_Lua import("/lua/ui/game/cinematics/moveto.lua").RetrieveFromDisk("03", true)', category = 'cinematics', } } diff --git a/lua/keymap/keydescriptions.lua b/lua/keymap/keydescriptions.lua index d5c56216d8..f1f489097e 100755 --- a/lua/keymap/keydescriptions.lua +++ b/lua/keymap/keydescriptions.lua @@ -561,29 +561,30 @@ keyDescriptions = { ['select_surface_bombers'] = 'Select all Bombers (Normal)', ['select_torpedo_bombers'] = 'Select all Bombers (Torpedo)', - -- CRUD-like operations + ['cinematics_bind_keys'] = 'Apply default key layout for cinematics. Applies until the game is restarted', + + --#region MoveTo ['cinematics_move_to_clear'] = 'MoveTo - Clear sequence', ['cinematics_move_to_add'] = 'MoveTo - Append current camera position to the sequence', - ['cinematics_move_to_insert'] = 'MoveTo - Insert current camera position after the current index of the sequence', - ['cinematics_move_to_overwrite'] = 'MoveTo - Overwrite with current camera position at the current index of the sequence', - ['cinematics_move_to_remove'] = 'MoveTo - Remove camera position at the current index of the sequence', + ['cinematics_move_to_remove'] = 'MoveTo - Remove the last camera position from sequence', + ['cinematics_move_to_insert_at_index'] = 'MoveTo - Insert current camera position at the current index of the sequence. Shifts the existing camera positions to the right.', + ['cinematics_move_to_overwrite_at_index'] = 'MoveTo - Overwrite with current camera position at the current index of the sequence', + ['cinematics_move_to_remove_at_index'] = 'MoveTo - Remove camera position at the current index of the sequence', - -- Navigation ['cinematics_move_to_jump_current'] = 'MoveTo - Jump to the camera position at the current index of the sequence', ['cinematics_move_to_jump_forward'] = 'MoveTo - Jump to the next camera position in the sequence', ['cinematics_move_to_jump_backward'] = 'MoveTo - Jump to the previous camera position in the sequence', - -- Animation ['cinematics_move_to_animate_forward'] = 'MoveTo - Animate to the next camera position in the sequence', ['cinematics_move_to_animate_backward'] = 'MoveTo - Animate to the previous camera position in the sequence', ['cinematics_move_to_jump_and_animate_forward'] = 'MoveTo - Jump to the next camera position, then animate to the one after', ['cinematics_move_to_jump_and_animate_backward'] = 'MoveTo - Jump to the previous camera position, then animate to the one before', - -- Preference file interactions ['cinematics_move_to_store_01'] = 'MoveTo - Save the 1st MoveTo sequence to the preference file', ['cinematics_move_to_store_02'] = 'MoveTo - Save the 2nd MoveTo sequence to the preference file', ['cinematics_move_to_store_03'] = 'MoveTo - Save the 3rd MoveTo sequence to the preference file', ['cinematics_move_to_retrieve_01'] = 'MoveTo - Load the 1st MoveTo sequence from the preference file', ['cinematics_move_to_retrieve_02'] = 'MoveTo - Load the 2nd MoveTo sequence from the preference file', ['cinematics_move_to_retrieve_03'] = 'MoveTo - Load the 3rd MoveTo sequence from the preference file', + --#endregion } diff --git a/lua/ui/game/cinematics/Config.lua b/lua/ui/game/cinematics/Config.lua index fd0b6b7f1f..7b8a3e7f63 100644 --- a/lua/ui/game/cinematics/Config.lua +++ b/lua/ui/game/cinematics/Config.lua @@ -37,9 +37,10 @@ local function DefaultMoveToLayout() -- 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, + ['S'] = keyActions.cinematics_move_to_insert_at_index, + ['D'] = keyActions.cinematics_move_to_overwrite_at_index, + ['BACKSPACE'] = keyActions.cinematics_move_to_remove, + ['DELETE'] = keyActions.cinematics_move_to_remove_at_index, -- animation ['Shift-Q'] = keyActions.cinematics_move_to_animate_forward, @@ -71,4 +72,6 @@ function ApplyDefaultKeyLayout() -- apply the keys IN_ClearKeyMap() IN_AddKeyMapTable(combinedKeyMap) + + print("Applied hotkeys for cinematics") end diff --git a/lua/ui/game/cinematics/MoveTo.lua b/lua/ui/game/cinematics/MoveTo.lua index c401e7fdb4..4ee0995b5a 100644 --- a/lua/ui/game/cinematics/MoveTo.lua +++ b/lua/ui/game/cinematics/MoveTo.lua @@ -103,7 +103,7 @@ RetrieveFromDisk = function(key, doPrint) -- inform user if doPrint then print("MoveTo - Loaded sequence for MoveTo to key '" .. - stringifiedKey .. "' (" .. table.getn(Sequence) .. " steps)") + stringifiedKey .. "' (" .. table.getn(Sequence) .. " steps)") end end @@ -118,9 +118,9 @@ Append = function(doPrint) end end ---- Inserts a camera position at the specified index. +--- Inserts a camera position at the specified index, pushing back the other camera positions. ---@param doPrint? boolean -Insert = function(doPrint) +InsertAfterIndex = function(doPrint) local sequenceCount = table.getn(Sequence) if sequenceCount == 0 then SequenceIndex = 1 @@ -129,16 +129,16 @@ Insert = function(doPrint) end local camera = GetCamera(DefaultCamera) - table.insert(camera, SequenceIndex + 1, camera:SaveSettings()) + table.insert(Sequence, SequenceIndex, camera:SaveSettings()) if doPrint then - print("MoveTo - Insert into sequence at index " .. SequenceIndex .. " (" .. sequenceCount .. " steps)") + print("MoveTo - Insert into sequence at index " .. SequenceIndex .. " (" .. (sequenceCount + 1) .. " steps)") end end --- Overwrites the camera position at the specified index. ---@param doPrint? boolean -Overwrite = function(doPrint) +OverwriteAtIndex = function(doPrint) local sequenceCount = table.getn(Sequence) if sequenceCount == 0 then SequenceIndex = 1 @@ -158,7 +158,8 @@ end --- Removes the current camera position. ---@param doPrint? boolean -Remove = function(doPrint) +---@return nil +RemoveAtIndex = function(doPrint) local sequenceCount = table.getn(Sequence) if sequenceCount == 0 then print("No camera sequence defined") @@ -168,7 +169,24 @@ Remove = function(doPrint) table.remove(Sequence, SequenceIndex) if doPrint then - print("MoveTo - Removed sequence " .. SequenceIndex .. " (" .. sequenceCount .. " steps)") + print("MoveTo - Removed at " .. SequenceIndex .. " (" .. (sequenceCount - 1).. " steps)") + end +end + +--- Removes the last camera position. +---@param doPrint doPrint? boolean +---@return nil +RemoveLast = function(doPrint) + local sequenceCount = table.getn(Sequence) + if sequenceCount == 0 then + print("No camera sequence defined") + return nil + end + + table.remove(Sequence) + + if doPrint then + print("MoveTo - Removed last (" .. (sequenceCount - 1) .. " steps)") end end