mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
feat: Added Minimap to Hex Editor
This commit is contained in:
@@ -985,11 +985,19 @@ namespace hex {
|
||||
u16 m_maxCharsPerCell;
|
||||
};
|
||||
|
||||
struct MiniMapVisualizer {
|
||||
using Callback = std::function<ImColor(const std::vector<u8>&)>;
|
||||
|
||||
UnlocalizedString unlocalizedName;
|
||||
Callback callback;
|
||||
};
|
||||
|
||||
namespace impl {
|
||||
|
||||
void addDataVisualizer(std::shared_ptr<DataVisualizer> &&visualizer);
|
||||
|
||||
std::vector<std::shared_ptr<DataVisualizer>> &getVisualizers();
|
||||
std::vector<std::shared_ptr<MiniMapVisualizer>> &getMiniMapVisualizers();
|
||||
|
||||
}
|
||||
|
||||
@@ -1010,6 +1018,13 @@ namespace hex {
|
||||
*/
|
||||
std::shared_ptr<DataVisualizer> getVisualizerByName(const UnlocalizedString &unlocalizedName);
|
||||
|
||||
/**
|
||||
* @brief Adds a new minimap visualizer
|
||||
* @param unlocalizedName Unlocalized name of the minimap visualizer
|
||||
* @param callback The callback that will be called to get the color of a line
|
||||
*/
|
||||
void addMiniMapVisualizer(UnlocalizedString unlocalizedName, MiniMapVisualizer::Callback callback);
|
||||
|
||||
}
|
||||
|
||||
/* Diffing Registry. Allows adding new diffing algorithms */
|
||||
|
||||
@@ -1001,6 +1001,12 @@ namespace hex {
|
||||
return visualizers;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<MiniMapVisualizer>> &getMiniMapVisualizers() {
|
||||
static std::vector<std::shared_ptr<MiniMapVisualizer>> visualizers;
|
||||
|
||||
return visualizers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<DataVisualizer> getVisualizerByName(const UnlocalizedString &unlocalizedName) {
|
||||
@@ -1012,6 +1018,10 @@ namespace hex {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void addMiniMapVisualizer(UnlocalizedString unlocalizedName, MiniMapVisualizer::Callback callback) {
|
||||
impl::getMiniMapVisualizers().emplace_back(std::make_shared<MiniMapVisualizer>(std::move(unlocalizedName), std::move(callback)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace ContentRegistry::Diffing {
|
||||
|
||||
Reference in New Issue
Block a user