mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-24 11:11:02 -07:00
Add a menu option to allow resetting the workspace.
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
#include <hex/plugin.hpp>
|
||||
#include <hex/api/content_registry/views.hpp>
|
||||
#include <hex/api/content_registry/user_interface.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/api/content_registry/provider.hpp>
|
||||
#include <hex/api/workspace_manager.hpp>
|
||||
#include <hex/helpers/default_paths.hpp>
|
||||
#include <fonts/vscode_icons.hpp>
|
||||
#include <fonts/tabler_icons.hpp>
|
||||
#include <romfs/romfs.hpp>
|
||||
#include "globals.h"
|
||||
#include "imageview.h"
|
||||
@@ -24,6 +29,42 @@ IMHEX_PLUGIN_SETUP("FluxEngine", "David Given", "FluxEngine integration")
|
||||
return romfs::get(path).string();
|
||||
});
|
||||
|
||||
hex::ContentRegistry::UserInterface::addMenuItem(
|
||||
{"hex.builtin.menu.workspace", "fluxengine.menu.workspace.reset"},
|
||||
ICON_TA_CANCEL,
|
||||
10000,
|
||||
hex::Shortcut::None,
|
||||
[]
|
||||
{
|
||||
static const std::string extractFolder = "auto_extract/workspaces";
|
||||
for (const auto& romfsPath : romfs::list(extractFolder))
|
||||
{
|
||||
for (const auto& imhexPath : hex::paths::getDataPaths(false))
|
||||
{
|
||||
const auto path =
|
||||
imhexPath / std::fs::relative(romfsPath, extractFolder);
|
||||
hex::log::info("Extracting {} to {}",
|
||||
romfsPath.string(),
|
||||
path.string());
|
||||
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Create);
|
||||
if (!file.isValid())
|
||||
continue;
|
||||
|
||||
auto data = romfs::get(romfsPath).span<u8>();
|
||||
file.writeBuffer(data.data(), data.size());
|
||||
|
||||
if (file.getSize() == data.size())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto currentWorkspaceName =
|
||||
hex::WorkspaceManager::getCurrentWorkspace()->first;
|
||||
hex::WorkspaceManager::reload();
|
||||
hex::WorkspaceManager::switchWorkspace(currentWorkspaceName);
|
||||
});
|
||||
|
||||
hex::ContentRegistry::Provider::add<DiskProvider>();
|
||||
|
||||
hex::ContentRegistry::Views::add<ConfigView>();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -57,5 +57,6 @@
|
||||
"fluxengine.view.status.writeImage": "Writing image file to disk",
|
||||
"fluxengine.view.status.blankFilesystem": "Creating blank filesystem",
|
||||
|
||||
"fluxengine.messages.writingFluxToFile": "The current configuration is to write to a flux file rather than to hardware. Is this what you intended?"
|
||||
"fluxengine.messages.writingFluxToFile": "The current configuration is to write to a flux file rather than to hardware. Is this what you intended?",
|
||||
"fluxengine.menu.workspace.reset": "Reset workspace"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user