2025-11-24 19:27:35 +01:00
|
|
|
#include "bit_container.h"
|
2025-12-08 17:50:52 +01:00
|
|
|
#include "cli/cmd.h"
|
2025-11-24 19:27:35 +01:00
|
|
|
#include "common/widgets/menuitem_fileopen.h"
|
2025-12-08 17:50:52 +01:00
|
|
|
#include "core/cli/cli.h"
|
2024-05-18 18:05:04 +02:00
|
|
|
#include "core/plugin.h"
|
2025-06-22 17:18:53 +02:00
|
|
|
#include "explorer/explorer.h"
|
2024-05-18 18:05:04 +02:00
|
|
|
#include "logger.h"
|
|
|
|
|
|
|
|
|
|
#include "bitview.h"
|
2025-06-22 17:18:53 +02:00
|
|
|
#include "explorer/explorer.h"
|
2025-11-24 19:27:35 +01:00
|
|
|
#include <filesystem>
|
|
|
|
|
#include <memory>
|
2024-05-18 18:05:04 +02:00
|
|
|
|
|
|
|
|
class BitViewAppPlugin : public satdump::Plugin
|
|
|
|
|
{
|
|
|
|
|
public:
|
2025-05-18 20:05:55 +02:00
|
|
|
std::string getID() { return "bitview_app"; }
|
2024-05-18 18:05:04 +02:00
|
|
|
|
|
|
|
|
void init()
|
|
|
|
|
{
|
2025-05-18 20:05:55 +02:00
|
|
|
// TODOREWORK maybe a way to call up/init a handler?
|
2025-07-24 21:55:57 +02:00
|
|
|
satdump::eventBus->register_handler<satdump::explorer::RenderLoadMenuElementsEvent>(renderExplorerLoaderButton);
|
2025-12-08 17:50:52 +01:00
|
|
|
|
|
|
|
|
satdump::eventBus->register_handler<satdump::cli::RegisterSubcommandEvent>(registerCliCommands);
|
2024-05-18 18:05:04 +02:00
|
|
|
}
|
|
|
|
|
|
2025-12-09 20:46:12 +01:00
|
|
|
static void registerCliCommands(const satdump::cli::RegisterSubcommandEvent &evt)
|
|
|
|
|
{
|
|
|
|
|
if (evt.is_gui)
|
|
|
|
|
evt.cmd_handlers.push_back(std::make_shared<satdump::BitViewCmdHandler>());
|
|
|
|
|
}
|
2025-12-08 17:50:52 +01:00
|
|
|
|
2025-11-24 19:27:35 +01:00
|
|
|
static satdump::widget::MenuItemFileOpen fopen_menu;
|
|
|
|
|
|
2025-07-24 21:55:57 +02:00
|
|
|
static void renderExplorerLoaderButton(const satdump::explorer::RenderLoadMenuElementsEvent &evt)
|
2024-05-18 18:05:04 +02:00
|
|
|
{
|
2025-08-12 11:04:46 +02:00
|
|
|
if (ImGui::BeginMenu("Add"))
|
2025-05-18 20:05:55 +02:00
|
|
|
{
|
2025-06-22 12:21:12 +02:00
|
|
|
if (ImGui::BeginMenu("Tools"))
|
2025-05-18 20:05:55 +02:00
|
|
|
{
|
2025-11-24 19:27:35 +01:00
|
|
|
fopen_menu.render("BitView", "Open binary file", "", {{"All Files", "*"}});
|
2025-05-18 20:05:55 +02:00
|
|
|
ImGui::EndMenu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
|
}
|
2025-11-24 19:27:35 +01:00
|
|
|
|
|
|
|
|
if (fopen_menu.update())
|
|
|
|
|
evt.master_handler->addSubHandler(std::make_shared<satdump::BitViewHandler>(std::make_shared<satdump::BitContainer>( //
|
|
|
|
|
std::filesystem::path(fopen_menu.getPath()).stem().string() + std::filesystem::path(fopen_menu.getPath()).extension().string(), //
|
|
|
|
|
fopen_menu.getPath())));
|
2025-06-22 12:21:12 +02:00
|
|
|
}
|
2024-05-18 18:05:04 +02:00
|
|
|
};
|
|
|
|
|
|
2025-11-24 19:27:35 +01:00
|
|
|
satdump::widget::MenuItemFileOpen BitViewAppPlugin::fopen_menu;
|
|
|
|
|
|
2024-05-18 18:05:04 +02:00
|
|
|
PLUGIN_LOADER(BitViewAppPlugin)
|