yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::CommandPalette Class Reference

#include <command_palette.h>

Public Member Functions

void AddCommand (const std::string &name, const std::string &category, const std::string &description, const std::string &shortcut, std::function< void()> callback)
 
void RecordUsage (const std::string &name)
 
std::vector< CommandEntrySearchCommands (const std::string &query)
 
std::vector< CommandEntryGetRecentCommands (int limit=10)
 
std::vector< CommandEntryGetFrequentCommands (int limit=10)
 
std::vector< CommandEntryGetAllCommands () const
 Get all registered commands.
 
size_t GetCommandCount () const
 Get command count.
 
void Clear ()
 Clear all commands.
 
void RegisterPanelCommands (PanelManager *panel_manager, size_t session_id)
 Register all panel toggle commands from PanelManager.
 
void RegisterEditorCommands (std::function< void(const std::string &)> switch_callback)
 Register all editor switch commands.
 
void RegisterLayoutCommands (std::function< void(const std::string &)> apply_callback)
 Register layout preset commands.
 
void RegisterRecentFilesCommands (std::function< void(const std::string &)> open_callback)
 Register commands to open recent files.
 
void RegisterDungeonRoomCommands (size_t session_id)
 Register dungeon room navigation commands.
 
void SaveHistory (const std::string &filepath)
 Save command usage history to disk.
 
void LoadHistory (const std::string &filepath)
 Load command usage history from disk.
 

Static Public Member Functions

static int FuzzyScore (const std::string &text, const std::string &query)
 

Private Attributes

std::unordered_map< std::string, CommandEntrycommands_
 

Detailed Description

Definition at line 40 of file command_palette.h.

Member Function Documentation

◆ AddCommand()

void yaze::editor::CommandPalette::AddCommand ( const std::string & name,
const std::string & category,
const std::string & description,
const std::string & shortcut,
std::function< void()> callback )

◆ RecordUsage()

void yaze::editor::CommandPalette::RecordUsage ( const std::string & name)

◆ SearchCommands()

std::vector< CommandEntry > yaze::editor::CommandPalette::SearchCommands ( const std::string & query)

Definition at line 91 of file command_palette.cc.

References commands_, and FuzzyScore().

Referenced by yaze::editor::CommandPaletteWidget::Draw().

Here is the call graph for this function:

◆ GetRecentCommands()

std::vector< CommandEntry > yaze::editor::CommandPalette::GetRecentCommands ( int limit = 10)

◆ GetFrequentCommands()

std::vector< CommandEntry > yaze::editor::CommandPalette::GetFrequentCommands ( int limit = 10)

◆ GetAllCommands()

std::vector< CommandEntry > yaze::editor::CommandPalette::GetAllCommands ( ) const

Get all registered commands.

Returns
Vector of all command entries

Definition at line 236 of file command_palette.cc.

References commands_.

Referenced by yaze::editor::CommandPaletteWidget::Draw(), and yaze::editor::UICoordinator::DrawCommandPalette().

◆ GetCommandCount()

size_t yaze::editor::CommandPalette::GetCommandCount ( ) const
inline

Get command count.

Definition at line 63 of file command_palette.h.

References commands_.

◆ Clear()

void yaze::editor::CommandPalette::Clear ( )
inline

Clear all commands.

Definition at line 68 of file command_palette.h.

References commands_.

Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().

◆ RegisterPanelCommands()

void yaze::editor::CommandPalette::RegisterPanelCommands ( PanelManager * panel_manager,
size_t session_id )

Register all panel toggle commands from PanelManager.

Parameters
panel_managerThe panel manager to query for panels
session_idCurrent session ID for panel prefixing

Definition at line 245 of file command_palette.cc.

References AddCommand(), yaze::editor::PanelManager::GetAllPanelDescriptors(), yaze::editor::PanelManager::HidePanel(), yaze::editor::CommandCategory::kPanel, and yaze::editor::PanelManager::TogglePanel().

Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().

Here is the call graph for this function:

◆ RegisterEditorCommands()

void yaze::editor::CommandPalette::RegisterEditorCommands ( std::function< void(const std::string &)> switch_callback)

Register all editor switch commands.

Parameters
switch_callbackCallback to switch to an editor category

Definition at line 292 of file command_palette.cc.

References AddCommand(), yaze::editor::EditorRegistry::GetAllEditorCategories(), and yaze::editor::CommandCategory::kEditor.

Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().

Here is the call graph for this function:

◆ RegisterLayoutCommands()

void yaze::editor::CommandPalette::RegisterLayoutCommands ( std::function< void(const std::string &)> apply_callback)

Register layout preset commands.

Parameters
apply_callbackCallback to apply a layout preset by name

Definition at line 307 of file command_palette.cc.

References AddCommand(), and yaze::editor::CommandCategory::kLayout.

Here is the call graph for this function:

◆ RegisterRecentFilesCommands()

void yaze::editor::CommandPalette::RegisterRecentFilesCommands ( std::function< void(const std::string &)> open_callback)

Register commands to open recent files.

Parameters
open_callbackCallback to open a file by path

Creates "Open Recent: <filename>" commands for each file in RecentFilesManager. Files are checked for existence before registration.

Definition at line 376 of file command_palette.cc.

References AddCommand(), yaze::project::RecentFilesManager::GetInstance(), yaze::project::RecentFilesManager::GetRecentFiles(), and yaze::editor::CommandCategory::kFile.

Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().

Here is the call graph for this function:

◆ RegisterDungeonRoomCommands()

void yaze::editor::CommandPalette::RegisterDungeonRoomCommands ( size_t session_id)

Register dungeon room navigation commands.

Adds one command per room ID (0x000-0x127) using the ResourceLabelProvider label (when available). Commands publish JumpToRoomRequestEvent.

Definition at line 399 of file command_palette.cc.

References AddCommand(), yaze::editor::JumpToRoomRequestEvent::Create(), yaze::editor::ContentRegistry::Context::event_bus(), yaze::zelda3::GetRoomLabel(), and yaze::editor::CommandCategory::kNavigation.

Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().

Here is the call graph for this function:

◆ SaveHistory()

void yaze::editor::CommandPalette::SaveHistory ( const std::string & filepath)

Save command usage history to disk.

Parameters
filepathPath to save JSON history file

Definition at line 174 of file command_palette.cc.

References commands_, yaze::Json::dump(), LOG_ERROR, LOG_INFO, and yaze::Json::object().

Referenced by yaze::editor::UICoordinator::DrawCommandPalette().

Here is the call graph for this function:

◆ LoadHistory()

void yaze::editor::CommandPalette::LoadHistory ( const std::string & filepath)

Load command usage history from disk.

Parameters
filepathPath to load JSON history file from

Definition at line 200 of file command_palette.cc.

References commands_, yaze::Json::contains(), yaze::Json::is_object(), yaze::Json::items(), LOG_ERROR, LOG_INFO, and yaze::Json::parse().

Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().

Here is the call graph for this function:

◆ FuzzyScore()

int yaze::editor::CommandPalette::FuzzyScore ( const std::string & text,
const std::string & query )
static

Member Data Documentation

◆ commands_

std::unordered_map<std::string, CommandEntry> yaze::editor::CommandPalette::commands_
private

The documentation for this class was generated from the following files: