mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
impr: Added more documentation to libimhex (#1052)
This PR adds some documentation. It's actually pretty random, I followed the function calls I was curious about and commented whenever I wasn't sure/I thought it needed clarification You might want to make sure to squash them, because the commits are kind of a mess, I didn't went through the effort of interactive rebase
This commit is contained in:
@@ -99,7 +99,8 @@ namespace hex::plugin::builtin {
|
||||
EventManager::post<EventHighlightingChanged>();
|
||||
});
|
||||
|
||||
EventManager::subscribe<EventProviderCreated>([](hex::prv::Provider *provider) {
|
||||
// Handles the provider initialization, and calls EventProviderOpened if successful
|
||||
EventManager::subscribe<EventProviderCreated>([](hex::prv::Provider *provider) {
|
||||
if (provider->shouldSkipLoadInterface())
|
||||
return;
|
||||
|
||||
|
||||
@@ -409,7 +409,9 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Draw some default background if there are no views avaialble in the current layout
|
||||
*/
|
||||
static void drawNoViewsBackground() {
|
||||
if (ImGui::Begin("ImHexDockSpace")) {
|
||||
static char title[256];
|
||||
@@ -444,10 +446,16 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Registers the event handlers related to the welcome screen
|
||||
* should only be called once, at startup
|
||||
*/
|
||||
void createWelcomeScreen() {
|
||||
updateRecentProviders();
|
||||
|
||||
(void)EventManager::subscribe<EventFrameBegin>(drawWelcomeScreen);
|
||||
|
||||
// Sets a background when they are no views
|
||||
(void)EventManager::subscribe<EventFrameBegin>([]{
|
||||
if (ImHexApi::Provider::isValid() && !isAnyViewOpen())
|
||||
drawNoViewsBackground();
|
||||
@@ -496,10 +504,13 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Save every opened provider as a "recent" shortcut
|
||||
(void)EventManager::subscribe<EventProviderOpened>([](prv::Provider *provider) {
|
||||
if (ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.save_recent_providers", 1) == 1) {
|
||||
auto fileName = hex::format("{:%y%m%d_%H%M%S}.json", fmt::gmtime(std::chrono::system_clock::now()));
|
||||
// The recent provider is saved to every "recent" directory
|
||||
for (const auto &recentPath : fs::getDefaultPaths(fs::ImHexPath::Recent)) {
|
||||
auto fileName = hex::format("{:%y%m%d_%H%M%S}.json", fmt::gmtime(std::chrono::system_clock::now()));
|
||||
wolv::io::File recentFile(recentPath / fileName, wolv::io::File::Mode::Create);
|
||||
if (!recentFile.isValid())
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user