Skip to content

Commit

Permalink
feat: Keybinds
Browse files Browse the repository at this point in the history
- Added potential shortcut keybinds for exporting param data (none set to anything by default)
  • Loading branch information
vawser committed Oct 24, 2024
1 parent 248d045 commit b37eb3d
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/StudioCore/Configuration/KeyBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,31 @@ public class Bindings
"Trigger the CSV Export prompt.",
Key.Unknown);

public KeyBind PARAM_ExportCSV_Names = new(
"Export CSV - Export Row Names",
"Export selected row names to window.",
Key.Unknown);

public KeyBind PARAM_ExportCSV_Param = new(
"Export CSV - Export Param",
"Export selected param to window.",
Key.Unknown);

public KeyBind PARAM_ExportCSV_AllRows = new(
"Export CSV - Export All Rows",
"Export selected all rows to window.",
Key.Unknown);

public KeyBind PARAM_ExportCSV_ModifiedRows = new(
"Export CSV - Export Modified Rows",
"Export selected modified rows to window.",
Key.Unknown);

public KeyBind PARAM_ExportCSV_SelectedRows = new(
"Export CSV - Export Selected Rows",
"Export selected selected rows to window.",
Key.Unknown);

// Row Namer
public KeyBind PARAM_ApplyRowNamer = new(
"Apply Row Namer (Flat)",
Expand Down
21 changes: 21 additions & 0 deletions src/StudioCore/Configuration/Keybinds/KeybindWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,27 @@ public void Display()
KeyBindings.Current.PARAM_ExportCSV = InputTracker.KeybindLine(10,
KeyBindings.Current.PARAM_ExportCSV,
KeyBindings.Default.PARAM_ExportCSV);

KeyBindings.Current.PARAM_ExportCSV_Names = InputTracker.KeybindLine(11,
KeyBindings.Current.PARAM_ExportCSV_Names,
KeyBindings.Default.PARAM_ExportCSV_Names);

KeyBindings.Current.PARAM_ExportCSV_Param = InputTracker.KeybindLine(12,
KeyBindings.Current.PARAM_ExportCSV_Param,
KeyBindings.Default.PARAM_ExportCSV_Param);

KeyBindings.Current.PARAM_ExportCSV_AllRows = InputTracker.KeybindLine(13,
KeyBindings.Current.PARAM_ExportCSV_AllRows,
KeyBindings.Default.PARAM_ExportCSV_AllRows);


KeyBindings.Current.PARAM_ExportCSV_ModifiedRows = InputTracker.KeybindLine(14,
KeyBindings.Current.PARAM_ExportCSV_ModifiedRows,
KeyBindings.Default.PARAM_ExportCSV_ModifiedRows);

KeyBindings.Current.PARAM_ExportCSV_SelectedRows = InputTracker.KeybindLine(15,
KeyBindings.Current.PARAM_ExportCSV_SelectedRows,
KeyBindings.Default.PARAM_ExportCSV_SelectedRows);
}

if (ImGui.CollapsingHeader("Row Namer", ImGuiTreeNodeFlags.DefaultOpen))
Expand Down
10 changes: 8 additions & 2 deletions src/StudioCore/Editors/ParamEditor/ParamEditorScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ public class ParamEditorScreen : EditorScreen

private bool HasSetupFmgDecorators = false;

private ParamEditorShortcuts EditorShortcuts;

public ParamEditorScreen(Sdl2Window window, GraphicsDevice device)
{
EditorShortcuts = new ParamEditorShortcuts(this);

ToolWindow = new ToolWindow(this);
ToolSubMenu = new ToolSubMenu(this);
Handler = new ActionHandler(this);
Expand Down Expand Up @@ -249,13 +253,13 @@ public void EditorUniqueDropdowns()
{
EditorCommandQueue.AddCommand($@"param/menu/massEditSingleCSVExport/Name/2");
}
UIHelper.ShowHoverTooltip($"{KeyBindings.Current.PARAM_ExportCSV.HintText}");
UIHelper.ShowHoverTooltip($"{KeyBindings.Current.PARAM_ExportCSV_Names.HintText}");

if (ImGui.MenuItem("Export entire param to window"))
{
EditorCommandQueue.AddCommand(@"param/menu/massEditCSVExport/0");
}
UIHelper.ShowHoverTooltip($"{KeyBindings.Current.PARAM_ExportCSV.HintText}");
UIHelper.ShowHoverTooltip($"{KeyBindings.Current.PARAM_ExportCSV_Param.HintText}");

if (ImGui.MenuItem("Export entire param to file"))
{
Expand Down Expand Up @@ -644,6 +648,8 @@ public void OnGUI(string[] initcmd)
}
}

EditorShortcuts.Shortcuts();

ToolSubMenu.Shortcuts();
ToolWindow.Shortcuts();

Expand Down
63 changes: 63 additions & 0 deletions src/StudioCore/Editors/ParamEditor/ParamEditorShortcuts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using ImGuiNET;
using StudioCore.Configuration;
using StudioCore.Editor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StudioCore.Editors.ParamEditor;

public class ParamEditorShortcuts
{
private ParamEditorScreen Screen;

public ParamEditorShortcuts(ParamEditorScreen screen)
{
Screen = screen;
}

public void Shortcuts()
{
// Export CSV: Names
if (!ImGui.IsAnyItemActive() &&
Screen._activeView._selection.RowSelectionExists() &&
InputTracker.GetKeyDown(KeyBindings.Current.PARAM_ExportCSV_Names))
{
EditorCommandQueue.AddCommand($@"param/menu/massEditSingleCSVExport/Name/2");
}

// Export CSV: Param
if (!ImGui.IsAnyItemActive() &&
Screen._activeView._selection.RowSelectionExists() &&
InputTracker.GetKeyDown(KeyBindings.Current.PARAM_ExportCSV_Param))
{
EditorCommandQueue.AddCommand(@"param/menu/massEditCSVExport/0");
}

// Export CSV: All Rows
if (!ImGui.IsAnyItemActive() &&
Screen._activeView._selection.RowSelectionExists() &&
InputTracker.GetKeyDown(KeyBindings.Current.PARAM_ExportCSV_AllRows))
{
EditorCommandQueue.AddCommand($@"param/menu/massEditCSVExport/AllRows");
}

// Export CSV: Modified Rows
if (!ImGui.IsAnyItemActive() &&
Screen._activeView._selection.RowSelectionExists() &&
InputTracker.GetKeyDown(KeyBindings.Current.PARAM_ExportCSV_ModifiedRows))
{
EditorCommandQueue.AddCommand($@"param/menu/massEditCSVExport/ModifiedRows");
}

// Export CSV: Selected Rows
if (!ImGui.IsAnyItemActive() &&
Screen._activeView._selection.RowSelectionExists() &&
InputTracker.GetKeyDown(KeyBindings.Current.PARAM_ExportCSV_SelectedRows))
{
EditorCommandQueue.AddCommand($@"param/menu/massEditCSVExport/SelectedRows");
}
}
}

0 comments on commit b37eb3d

Please sign in to comment.