mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
impr: Clean up entire API and added doc comments
This commit is contained in:
@@ -225,7 +225,7 @@ namespace hex::init {
|
||||
|
||||
while (ImHexApi::Provider::isValid())
|
||||
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
||||
ContentRegistry::Provider::getEntries().clear();
|
||||
ContentRegistry::Provider::impl::getEntries().clear();
|
||||
|
||||
ImHexApi::System::getInitArguments().clear();
|
||||
ImHexApi::HexEditor::impl::getBackgroundHighlights().clear();
|
||||
@@ -235,48 +235,48 @@ namespace hex::init {
|
||||
ImHexApi::HexEditor::impl::getTooltips().clear();
|
||||
ImHexApi::HexEditor::impl::getTooltipFunctions().clear();
|
||||
|
||||
ContentRegistry::Settings::getEntries().clear();
|
||||
ContentRegistry::Settings::getSettingsData().clear();
|
||||
ContentRegistry::Settings::impl::getEntries().clear();
|
||||
ContentRegistry::Settings::impl::getSettingsData().clear();
|
||||
|
||||
ContentRegistry::CommandPaletteCommands::getEntries().clear();
|
||||
ContentRegistry::CommandPaletteCommands::getHandlers().clear();
|
||||
ContentRegistry::CommandPaletteCommands::impl::getEntries().clear();
|
||||
ContentRegistry::CommandPaletteCommands::impl::getHandlers().clear();
|
||||
|
||||
ContentRegistry::PatternLanguage::getFunctions().clear();
|
||||
ContentRegistry::PatternLanguage::getPragmas().clear();
|
||||
ContentRegistry::PatternLanguage::impl::getFunctions().clear();
|
||||
ContentRegistry::PatternLanguage::impl::getPragmas().clear();
|
||||
ContentRegistry::PatternLanguage::impl::getVisualizers().clear();
|
||||
|
||||
{
|
||||
auto &views = ContentRegistry::Views::getEntries();
|
||||
auto &views = ContentRegistry::Views::impl::getEntries();
|
||||
for (auto &[name, view] : views)
|
||||
delete view;
|
||||
views.clear();
|
||||
}
|
||||
|
||||
|
||||
ContentRegistry::Tools::getEntries().clear();
|
||||
ContentRegistry::DataInspector::getEntries().clear();
|
||||
ContentRegistry::Tools::impl::getEntries().clear();
|
||||
ContentRegistry::DataInspector::impl::getEntries().clear();
|
||||
|
||||
ContentRegistry::Language::getLanguages().clear();
|
||||
ContentRegistry::Language::getLanguageDefinitions().clear();
|
||||
ContentRegistry::Language::impl::getLanguages().clear();
|
||||
ContentRegistry::Language::impl::getLanguageDefinitions().clear();
|
||||
LangEntry::resetLanguageStrings();
|
||||
|
||||
ContentRegistry::Interface::getWelcomeScreenEntries().clear();
|
||||
ContentRegistry::Interface::getFooterItems().clear();
|
||||
ContentRegistry::Interface::getToolbarItems().clear();
|
||||
ContentRegistry::Interface::getMainMenuItems().clear();
|
||||
ContentRegistry::Interface::getMenuItems().clear();
|
||||
ContentRegistry::Interface::getSidebarItems().clear();
|
||||
ContentRegistry::Interface::getTitleBarButtons().clear();
|
||||
ContentRegistry::Interface::getLayouts().clear();
|
||||
ContentRegistry::Interface::impl::getWelcomeScreenEntries().clear();
|
||||
ContentRegistry::Interface::impl::getFooterItems().clear();
|
||||
ContentRegistry::Interface::impl::getToolbarItems().clear();
|
||||
ContentRegistry::Interface::impl::getMainMenuItems().clear();
|
||||
ContentRegistry::Interface::impl::getMenuItems().clear();
|
||||
ContentRegistry::Interface::impl::getSidebarItems().clear();
|
||||
ContentRegistry::Interface::impl::getTitleBarButtons().clear();
|
||||
ContentRegistry::Interface::impl::getLayouts().clear();
|
||||
|
||||
ShortcutManager::clearShortcuts();
|
||||
|
||||
TaskManager::getRunningTasks().clear();
|
||||
|
||||
ContentRegistry::DataProcessorNode::getEntries().clear();
|
||||
ContentRegistry::DataProcessorNode::impl::getEntries().clear();
|
||||
|
||||
ContentRegistry::DataFormatter::getEntries().clear();
|
||||
ContentRegistry::FileHandler::getEntries().clear();
|
||||
ContentRegistry::DataFormatter::impl::getEntries().clear();
|
||||
ContentRegistry::FileHandler::impl::getEntries().clear();
|
||||
ContentRegistry::Hashes::impl::getHashes().clear();
|
||||
|
||||
api::ThemeManager::reset();
|
||||
@@ -396,14 +396,14 @@ namespace hex::init {
|
||||
bool loadSettings() {
|
||||
try {
|
||||
// Try to load settings from file
|
||||
ContentRegistry::Settings::load();
|
||||
ContentRegistry::Settings::impl::load();
|
||||
} catch (std::exception &e) {
|
||||
// If that fails, create a new settings file
|
||||
|
||||
log::error("Failed to load configuration! {}", e.what());
|
||||
|
||||
ContentRegistry::Settings::clear();
|
||||
ContentRegistry::Settings::store();
|
||||
ContentRegistry::Settings::impl::clear();
|
||||
ContentRegistry::Settings::impl::store();
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -413,7 +413,7 @@ namespace hex::init {
|
||||
|
||||
bool storeSettings() {
|
||||
try {
|
||||
ContentRegistry::Settings::store();
|
||||
ContentRegistry::Settings::impl::store();
|
||||
} catch (std::exception &e) {
|
||||
log::error("Failed to store configuration! {}", e.what());
|
||||
return false;
|
||||
|
||||
@@ -418,7 +418,7 @@ namespace hex {
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetColorU32(ImGuiCol_ScrollbarGrabActive));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetColorU32(ImGuiCol_ScrollbarGrabHovered));
|
||||
|
||||
auto &titleBarButtons = ContentRegistry::Interface::getTitleBarButtons();
|
||||
auto &titleBarButtons = ContentRegistry::Interface::impl::getTitleBarButtons();
|
||||
|
||||
// Draw custom title bar buttons
|
||||
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * (4 + titleBarButtons.size()));
|
||||
@@ -446,7 +446,7 @@ namespace hex {
|
||||
|
||||
// Draw close button
|
||||
if (ImGui::TitleBarButton(ICON_VS_CHROME_CLOSE, buttonSize)) {
|
||||
ImHexApi::Common::closeImHex();
|
||||
ImHexApi::System::closeImHex();
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(5);
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace hex {
|
||||
auto logoData = romfs::get("logo.png");
|
||||
this->m_logoTexture = ImGui::Texture(reinterpret_cast<const ImU8 *>(logoData.data()), logoData.size());
|
||||
|
||||
ContentRegistry::Settings::store();
|
||||
ContentRegistry::Settings::impl::store();
|
||||
EventManager::post<EventSettingsChanged>();
|
||||
EventManager::post<EventWindowInitialized>();
|
||||
}
|
||||
@@ -317,7 +317,7 @@ namespace hex {
|
||||
auto drawList = ImGui::GetWindowDrawList();
|
||||
ImGui::PopStyleVar();
|
||||
auto sidebarPos = ImGui::GetCursorPos();
|
||||
auto sidebarWidth = ContentRegistry::Interface::getSidebarItems().empty() ? 0 : 30_scaled;
|
||||
auto sidebarWidth = ContentRegistry::Interface::impl::getSidebarItems().empty() ? 0 : 30_scaled;
|
||||
|
||||
ImGui::SetCursorPosX(sidebarWidth);
|
||||
|
||||
@@ -334,7 +334,7 @@ namespace hex {
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::SetCursorPosX(8);
|
||||
for (const auto &callback : ContentRegistry::Interface::getFooterItems()) {
|
||||
for (const auto &callback : ContentRegistry::Interface::impl::getFooterItems()) {
|
||||
auto prevIdx = drawList->_VtxCurrentIdx;
|
||||
callback();
|
||||
auto currIdx = drawList->_VtxCurrentIdx;
|
||||
@@ -355,7 +355,7 @@ namespace hex {
|
||||
static i32 openWindow = -1;
|
||||
u32 index = 0;
|
||||
ImGui::PushID("SideBarWindows");
|
||||
for (const auto &[icon, callback] : ContentRegistry::Interface::getSidebarItems()) {
|
||||
for (const auto &[icon, callback] : ContentRegistry::Interface::impl::getSidebarItems()) {
|
||||
ImGui::SetCursorPosY(sidebarPos.y + sidebarWidth * index);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
|
||||
@@ -404,13 +404,13 @@ namespace hex {
|
||||
ImGui::Image(this->m_logoTexture, ImVec2(menuBarHeight, menuBarHeight));
|
||||
}
|
||||
|
||||
for (const auto &[priority, menuItem] : ContentRegistry::Interface::getMainMenuItems()) {
|
||||
for (const auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMainMenuItems()) {
|
||||
if (ImGui::BeginMenu(LangEntry(menuItem.unlocalizedName))) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::getMenuItems()) {
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) {
|
||||
const auto &[unlocalizedNames, shortcut, callback, enabledCallback] = menuItem;
|
||||
createNestedMenu(unlocalizedNames, shortcut, callback, enabledCallback);
|
||||
}
|
||||
@@ -424,7 +424,7 @@ namespace hex {
|
||||
// Render toolbar
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
|
||||
for (const auto &callback : ContentRegistry::Interface::getToolbarItems()) {
|
||||
for (const auto &callback : ContentRegistry::Interface::impl::getToolbarItems()) {
|
||||
callback();
|
||||
ImGui::SameLine();
|
||||
}
|
||||
@@ -524,7 +524,7 @@ namespace hex {
|
||||
TaskManager::runDeferredCalls();
|
||||
|
||||
// Draw main menu popups
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::getMenuItems()) {
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) {
|
||||
const auto &[unlocalizedNames, shortcut, callback, enabledCallback] = menuItem;
|
||||
|
||||
if (ImGui::BeginPopup(unlocalizedNames.front().c_str())) {
|
||||
@@ -540,7 +540,7 @@ namespace hex {
|
||||
auto &io = ImGui::GetIO();
|
||||
|
||||
// Loop through all views and draw them
|
||||
for (auto &[name, view] : ContentRegistry::Views::getEntries()) {
|
||||
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||
ImGui::GetCurrentContext()->NextWindowData.ClearFlags();
|
||||
|
||||
// Draw always visible views
|
||||
@@ -766,7 +766,7 @@ namespace hex {
|
||||
|
||||
// Check if a custom file handler can handle the file
|
||||
bool handled = false;
|
||||
for (const auto &[extensions, handler] : ContentRegistry::FileHandler::getEntries()) {
|
||||
for (const auto &[extensions, handler] : ContentRegistry::FileHandler::impl::getEntries()) {
|
||||
for (const auto &extension : extensions) {
|
||||
if (path.extension() == extension) {
|
||||
// Pass the file to the handler and check if it was successful
|
||||
@@ -857,11 +857,11 @@ namespace hex {
|
||||
handler.ReadOpenFn = [](ImGuiContext *ctx, ImGuiSettingsHandler *, const char *) -> void* { return ctx; };
|
||||
|
||||
handler.ReadLineFn = [](ImGuiContext *, ImGuiSettingsHandler *, void *, const char *line) {
|
||||
for (auto &[name, view] : ContentRegistry::Views::getEntries()) {
|
||||
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||
std::string format = view->getUnlocalizedName() + "=%d";
|
||||
sscanf(line, format.c_str(), &view->getWindowOpenState());
|
||||
}
|
||||
for (auto &[name, function, detached] : ContentRegistry::Tools::getEntries()) {
|
||||
for (auto &[name, function, detached] : ContentRegistry::Tools::impl::getEntries()) {
|
||||
std::string format = name + "=%d";
|
||||
sscanf(line, format.c_str(), &detached);
|
||||
}
|
||||
@@ -870,10 +870,10 @@ namespace hex {
|
||||
handler.WriteAllFn = [](ImGuiContext *, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf) {
|
||||
buf->appendf("[%s][General]\n", handler->TypeName);
|
||||
|
||||
for (auto &[name, view] : ContentRegistry::Views::getEntries()) {
|
||||
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||
buf->appendf("%s=%d\n", name.c_str(), view->getWindowOpenState());
|
||||
}
|
||||
for (auto &[name, function, detached] : ContentRegistry::Tools::getEntries()) {
|
||||
for (auto &[name, function, detached] : ContentRegistry::Tools::impl::getEntries()) {
|
||||
buf->appendf("%s=%d\n", name.c_str(), detached);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user