Add CommandManager::ShowWhichKey and include src in build
This commit is contained in:
27
src/app/editor/system/command_manager.cc
Normal file
27
src/app/editor/system/command_manager.cc
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "command_manager.h"
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
namespace editor {
|
||||
|
||||
// When the player presses Space, a popup will appear fixed to the bottom of the
|
||||
// ImGui window with a list of the available key commands which can be used.
|
||||
void CommandManager::ShowWhichKey() {
|
||||
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space))) {
|
||||
ImGui::OpenPopup("WhichKey");
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("WhichKey")) {
|
||||
for (const auto& [shortcut, command] : commands_) {
|
||||
ImGui::Text("%s: %s", shortcut.c_str(),
|
||||
command->GetDescription().c_str());
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef YAZE_APP_EDITOR_SYSTEM_COMMAND_MANAGER_H
|
||||
#define YAZE_APP_EDITOR_SYSTEM_COMMAND_MANAGER_H
|
||||
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -16,6 +17,8 @@ class Command {
|
||||
|
||||
class CommandManager {
|
||||
public:
|
||||
void ShowWhichKey();
|
||||
|
||||
void RegisterCommand(const std::string& shortcut, Command* command) {
|
||||
commands_[shortcut] = command;
|
||||
}
|
||||
@@ -50,4 +53,6 @@ class CommandManager {
|
||||
|
||||
} // namespace editor
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_SYSTEM_COMMAND_MANAGER_H
|
||||
Reference in New Issue
Block a user