From 791b3f354b378769bffe623b05f1305c91b77101 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Fri, 3 Jun 2022 23:30:01 -0700 Subject: Changeset: 64 [WIP] Rename directories --- source/Game/EditorCommandPalette.hpp | 94 ------------------------------------ 1 file changed, 94 deletions(-) delete mode 100644 source/Game/EditorCommandPalette.hpp (limited to 'source/Game/EditorCommandPalette.hpp') diff --git a/source/Game/EditorCommandPalette.hpp b/source/Game/EditorCommandPalette.hpp deleted file mode 100644 index 101344d..0000000 --- a/source/Game/EditorCommandPalette.hpp +++ /dev/null @@ -1,94 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -class EditorCommandExecuteContext; -class EditorCommand { -public: - std::string name; - std::function callback; - std::function subsequentCallback; - std::function terminate; -}; - -class EditorCommandExecuteContext { - friend class EditorCommandPalette; - -private: - const EditorCommand* mCommand = nullptr; - std::vector mCurrentOptions; - int mDepth = 0; - -public: - bool IsInitiated() const; - const EditorCommand* GetCurrentCommand() const; - void Initiate(const EditorCommand& command); - - void Prompt(std::vector options); - void Finish(); - - /// Return the number of prompts that the user is currently completing. For example, when the user opens command - /// palette fresh and selects a command, 0 is returned. If the command asks some prompt, and then the user selects - /// again, 1 is returned. - int GetExecutionDepth() const; -}; - -class EditorCommandPalette { -private: - struct SearchResult; - struct Item; - - std::vector mCommands; - std::vector mItems; - std::vector mSearchResults; - std::string mSearchText; - EditorCommandExecuteContext mExeCtx; - int mFocusedItemId = 0; - bool mFocusSearchBox = false; - bool mShouldCloseNextFrame = false; - -public: - EditorCommandPalette(); - ~EditorCommandPalette(); - - EditorCommandPalette(const EditorCommandPalette&) = delete; - EditorCommandPalette& operator=(const EditorCommandPalette&) = delete; - EditorCommandPalette(EditorCommandPalette&&) = default; - EditorCommandPalette& operator=(EditorCommandPalette&&) = default; - - void AddCommand(std::string_view category, std::string_view name, EditorCommand command); - void RemoveCommand(std::string_view category, std::string_view name); - void RemoveCommand(const std::string& commandName); - - void Show(bool* open = nullptr); - - enum ItemType { - CommandItem, - CommandOptionItem, - }; - - enum IndexType { - DirectIndex, - SearchResultIndex, - }; - - struct ItemInfo { - const char* text; - const EditorCommand* command; - int itemId; - ItemType itemType; - IndexType indexType; - }; - - size_t GetItemCount() const; - ItemInfo GetItem(size_t idx) const; - - void SelectFocusedItem(); - -private: - void InvalidateSearchResults(); -}; -- cgit v1.2.3-70-g09d2