mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
impr: Display sub menus for shortcut settings
This commit is contained in:
@@ -246,9 +246,12 @@ namespace hex::plugin::builtin {
|
||||
|
||||
class KeybindingWidget : public ContentRegistry::Settings::Widgets::Widget {
|
||||
public:
|
||||
KeybindingWidget(View *view, const Shortcut &shortcut) : m_view(view), m_shortcut(shortcut), m_drawShortcut(shortcut), m_defaultShortcut(shortcut) {}
|
||||
KeybindingWidget(View *view, const Shortcut &shortcut, const std::vector<UnlocalizedString> &fullName)
|
||||
: m_view(view), m_shortcut(shortcut), m_drawShortcut(shortcut), m_defaultShortcut(shortcut), m_fullName(fullName) {}
|
||||
|
||||
bool draw(const std::string &name) override {
|
||||
std::ignore = name;
|
||||
|
||||
std::string label;
|
||||
|
||||
if (!m_editing)
|
||||
@@ -300,7 +303,15 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGuiExt::TextFormatted("{}", name);
|
||||
std::string fullName;
|
||||
for (const auto &part : m_fullName) {
|
||||
fullName += Lang(part).get();
|
||||
fullName += " -> ";
|
||||
}
|
||||
if (fullName.size() >= 4)
|
||||
fullName = fullName.substr(0, fullName.size() - 4);
|
||||
|
||||
ImGuiExt::TextFormatted("{}", fullName);
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
@@ -376,6 +387,7 @@ namespace hex::plugin::builtin {
|
||||
private:
|
||||
View *m_view = nullptr;
|
||||
Shortcut m_shortcut, m_drawShortcut, m_defaultShortcut;
|
||||
std::vector<UnlocalizedString> m_fullName;
|
||||
bool m_editing = false;
|
||||
bool m_hasDuplicate = false;
|
||||
};
|
||||
@@ -934,12 +946,12 @@ namespace hex::plugin::builtin {
|
||||
{
|
||||
EventImHexStartupFinished::subscribe([]{
|
||||
for (const auto &shortcutEntry : ShortcutManager::getGlobalShortcuts()) {
|
||||
ContentRegistry::Settings::add<KeybindingWidget>("hex.builtin.setting.shortcuts", "hex.builtin.setting.shortcuts.global", shortcutEntry.unlocalizedName, nullptr, shortcutEntry.shortcut);
|
||||
ContentRegistry::Settings::add<KeybindingWidget>("hex.builtin.setting.shortcuts", "hex.builtin.setting.shortcuts.global", shortcutEntry.unlocalizedName.back(), nullptr, shortcutEntry.shortcut, shortcutEntry.unlocalizedName);
|
||||
}
|
||||
|
||||
for (auto &[viewName, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||
for (const auto &shortcutEntry : ShortcutManager::getViewShortcuts(view.get())) {
|
||||
ContentRegistry::Settings::add<KeybindingWidget>("hex.builtin.setting.shortcuts", viewName, shortcutEntry.unlocalizedName, view.get(), shortcutEntry.shortcut);
|
||||
ContentRegistry::Settings::add<KeybindingWidget>("hex.builtin.setting.shortcuts", viewName, shortcutEntry.unlocalizedName.back(), view.get(), shortcutEntry.shortcut, shortcutEntry.unlocalizedName);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user