diff --git a/dist/web/source/style.css b/dist/web/source/style.css index c3437f86f..bd0a53222 100644 --- a/dist/web/source/style.css +++ b/dist/web/source/style.css @@ -1,6 +1,6 @@ html, body { height: 100%; - margin: 0px; + margin: 0; user-select: none; } @@ -16,16 +16,7 @@ body { margin-left: auto; margin-right: auto; display: none; - border: 0px none; -} - -.canvas_full_screen { - width: 100%; - height: 100%; - position: absolute; - top: 0; - left: 0; - image-rendering: pixelated; + border: 0 none; } h1, h2, h5 { @@ -44,7 +35,7 @@ h2 { } h5 { - margin-top: 0px; + margin-top: 0; font-size: 17px; } @@ -63,7 +54,7 @@ a { } a:hover { - text-shadow: #3a4677 0px 0px 10px; + text-shadow: #3a4677 0 0 10px; } .footer { @@ -135,8 +126,8 @@ a:hover { opacity: 1; } 100% { - top: 0px; - left: 0px; + top: 0; + left: 0; width: 72px; height: 72px; opacity: 0; diff --git a/lib/libimhex/include/hex/api/plugin_manager.hpp b/lib/libimhex/include/hex/api/plugin_manager.hpp index df819b489..acce25015 100644 --- a/lib/libimhex/include/hex/api/plugin_manager.hpp +++ b/lib/libimhex/include/hex/api/plugin_manager.hpp @@ -42,7 +42,7 @@ namespace hex { class Plugin { public: explicit Plugin(const std::fs::path &path); - explicit Plugin(PluginFunctions functions); + explicit Plugin(const PluginFunctions &functions); Plugin(const Plugin &) = delete; Plugin(Plugin &&other) noexcept; diff --git a/lib/libimhex/include/hex/api/shortcut_manager.hpp b/lib/libimhex/include/hex/api/shortcut_manager.hpp index ad50389ff..ed0feafa1 100644 --- a/lib/libimhex/include/hex/api/shortcut_manager.hpp +++ b/lib/libimhex/include/hex/api/shortcut_manager.hpp @@ -448,7 +448,7 @@ namespace hex { [[nodiscard]] static std::optional getPreviousShortcut(); [[nodiscard]] static std::vector getGlobalShortcuts(); - [[nodiscard]] static std::vector getViewShortcuts(View *view); + [[nodiscard]] static std::vector getViewShortcuts(const View *view); [[nodiscard]] static bool updateShortcut(const Shortcut &oldShortcut, const Shortcut &newShortcut, View *view = nullptr); }; diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 6539bd797..45f404e66 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -606,9 +606,9 @@ namespace hex { std::string getImHexVersion(bool withBuildType) { #if defined IMHEX_VERSION - if (withBuildType) + if (withBuildType) { return IMHEX_VERSION; - else { + } else { auto version = std::string(IMHEX_VERSION); return version.substr(0, version.find('-')); } diff --git a/lib/libimhex/source/api/plugin_manager.cpp b/lib/libimhex/source/api/plugin_manager.cpp index 86dae1b5e..80c263f0f 100644 --- a/lib/libimhex/source/api/plugin_manager.cpp +++ b/lib/libimhex/source/api/plugin_manager.cpp @@ -46,7 +46,7 @@ namespace hex { m_functions.getSubCommandsFunction = getPluginFunction("getSubCommands"); } - Plugin::Plugin(hex::PluginFunctions functions) { + Plugin::Plugin(const hex::PluginFunctions &functions) { m_handle = 0; m_functions = functions; } @@ -125,9 +125,9 @@ namespace hex { } std::string Plugin::getPluginName() const { - if (m_functions.getPluginNameFunction != nullptr) + if (m_functions.getPluginNameFunction != nullptr) { return m_functions.getPluginNameFunction(); - else { + } else { if (this->isLibraryPlugin()) return "Library Plugin"; else @@ -185,8 +185,9 @@ namespace hex { if (m_functions.getSubCommandsFunction != nullptr) { auto result = m_functions.getSubCommandsFunction(); return *static_cast*>(result); - } else + } else { return { }; + } } bool Plugin::isLibraryPlugin() const { diff --git a/lib/libimhex/source/api/shortcut_manager.cpp b/lib/libimhex/source/api/shortcut_manager.cpp index fc82f47cf..04ac2908e 100644 --- a/lib/libimhex/source/api/shortcut_manager.cpp +++ b/lib/libimhex/source/api/shortcut_manager.cpp @@ -98,7 +98,7 @@ namespace hex { return result; } - std::vector ShortcutManager::getViewShortcuts(View *view) { + std::vector ShortcutManager::getViewShortcuts(const View *view) { std::vector result; for (auto &[shortcut, entry] : view->m_shortcuts) diff --git a/lib/libimhex/source/api/theme_manager.cpp b/lib/libimhex/source/api/theme_manager.cpp index a0aa636b6..c1a4d82fb 100644 --- a/lib/libimhex/source/api/theme_manager.cpp +++ b/lib/libimhex/source/api/theme_manager.cpp @@ -90,9 +90,9 @@ namespace hex { theme["styles"][type] = {}; for (const auto &[key, style] : handler.styleMap) { - if (std::holds_alternative(style.value)) + if (std::holds_alternative(style.value)) { theme["styles"][type][key] = *std::get(style.value); - else if (std::holds_alternative(style.value)) { + } else if (std::holds_alternative(style.value)) { theme["styles"][type][key] = { std::get(style.value)->x, std::get(style.value)->y diff --git a/lib/libimhex/source/helpers/http_requests_native.cpp b/lib/libimhex/source/helpers/http_requests_native.cpp index ad15d6cc3..331371082 100644 --- a/lib/libimhex/source/helpers/http_requests_native.cpp +++ b/lib/libimhex/source/helpers/http_requests_native.cpp @@ -85,8 +85,8 @@ namespace hex { s_proxyUrl = std::move(proxy); } - void HttpRequest::setProxyState(bool state) { - s_proxyState = state; + void HttpRequest::setProxyState(bool enabled) { + s_proxyState = enabled; } void HttpRequest::checkProxyErrors() { diff --git a/lib/libimhex/source/helpers/opengl.cpp b/lib/libimhex/source/helpers/opengl.cpp index 9fd304f1b..0942e4d4e 100644 --- a/lib/libimhex/source/helpers/opengl.cpp +++ b/lib/libimhex/source/helpers/opengl.cpp @@ -635,13 +635,13 @@ namespace hex::gl { } } - void LightSourceVectors::moveTo(const Vector &positionVector) { + void LightSourceVectors::moveTo(const Vector &position) { auto vertexCount = m_vertices.size(); for (unsigned k = 0; k < vertexCount; k += 3) { - m_vertices[k ] = m_radius * m_normals[k ] + positionVector[0]; - m_vertices[k + 1] = m_radius * m_normals[k + 1] + positionVector[1]; - m_vertices[k + 2] = m_radius * m_normals[k + 2] + positionVector[2]; + m_vertices[k ] = m_radius * m_normals[k ] + position[0]; + m_vertices[k + 1] = m_radius * m_normals[k + 1] + position[1]; + m_vertices[k + 2] = m_radius * m_normals[k + 2] + position[2]; } } diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index 9cc22613e..d7adf9a00 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -67,8 +67,9 @@ namespace hex { if (value < 0) { data[index] = '-'; return { data + index }; - } else + } else { return { data + index + 1 }; + } } std::string toLower(std::string string) { @@ -376,9 +377,9 @@ namespace hex { std::string result; for (u8 byte : bytes) { - if (std::isprint(byte) && byte != '\\') + if (std::isprint(byte) && byte != '\\') { result += char(byte); - else { + } else { switch (byte) { case '\\': result += "\\"; @@ -538,9 +539,9 @@ namespace hex { std::wstring utf16; for (auto unicode : unicodes) { - if (unicode <= 0xFFFF) + if (unicode <= 0xFFFF) { utf16 += static_cast(unicode); - else { + } else { unicode -= 0x10000; utf16 += static_cast(((unicode >> 10) + 0xD800)); utf16 += static_cast(((unicode & 0x3FF) + 0xDC00)); diff --git a/lib/libimhex/source/ui/view.cpp b/lib/libimhex/source/ui/view.cpp index 59fbb0144..f5c7e4b00 100644 --- a/lib/libimhex/source/ui/view.cpp +++ b/lib/libimhex/source/ui/view.cpp @@ -2,7 +2,6 @@ #include -#include #include namespace hex { diff --git a/main/gui/source/crash_handlers.cpp b/main/gui/source/crash_handlers.cpp index bae3f1ac6..fdda088ab 100644 --- a/main/gui/source/crash_handlers.cpp +++ b/main/gui/source/crash_handlers.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp index 80d3458c0..69950bf47 100644 --- a/main/gui/source/init/splash_window.cpp +++ b/main/gui/source/init/splash_window.cpp @@ -95,9 +95,9 @@ namespace hex::init { }(); for (const auto &colorConfig : highlightConfig) { - if (!colorConfig.contains("time")) + if (!colorConfig.contains("time")) { selectedConfigs.push_back(colorConfig); - else { + } else { const auto &time = colorConfig["time"]; const auto &start = time["start"]; const auto &end = time["end"]; diff --git a/main/gui/source/window/win_window.cpp b/main/gui/source/window/win_window.cpp index 36f239086..c7d67318b 100644 --- a/main/gui/source/window/win_window.cpp +++ b/main/gui/source/window/win_window.cpp @@ -29,9 +29,9 @@ namespace hex { template using WinUniquePtr = std::unique_ptr, BOOL(*)(T)>; - static LONG_PTR g_oldWndProc; - static float g_titleBarHeight; - static Microsoft::WRL::ComPtr g_taskbarList; + static LONG_PTR s_oldWndProc; + static float s_titleBarHeight; + static Microsoft::WRL::ComPtr s_taskbarList; void nativeErrorMessage(const std::string &message) { log::fatal(message); @@ -83,7 +83,7 @@ namespace hex { } case WM_SETCURSOR: { if (LOWORD(lParam) != HTCLIENT) { - return CallWindowProc((WNDPROC)g_oldWndProc, hwnd, uMsg, wParam, lParam); + return CallWindowProc((WNDPROC)s_oldWndProc, hwnd, uMsg, wParam, lParam); } else { switch (ImGui::GetMouseCursor()) { case ImGuiMouseCursor_Arrow: @@ -122,7 +122,7 @@ namespace hex { break; } - return CallWindowProc((WNDPROC)g_oldWndProc, hwnd, uMsg, wParam, lParam); + return CallWindowProc((WNDPROC)s_oldWndProc, hwnd, uMsg, wParam, lParam); } // Custom window procedure for borderless window @@ -140,7 +140,7 @@ namespace hex { RECT &rect = *reinterpret_cast(lParam); RECT client = rect; - CallWindowProc((WNDPROC)g_oldWndProc, hwnd, uMsg, wParam, lParam); + CallWindowProc((WNDPROC)s_oldWndProc, hwnd, uMsg, wParam, lParam); if (IsMaximized(hwnd)) { WINDOWINFO windowInfo = { }; @@ -211,7 +211,7 @@ namespace hex { return HTBOTTOMRIGHT; case RegionClient: default: - if (cursor.y < (window.top + g_titleBarHeight * 2)) { + if (cursor.y < (window.top + s_titleBarHeight * 2)) { if (hoveredWindowName == "##MainMenuBar" || hoveredWindowName == "ImHexDockSpace") { if (!ImGui::IsAnyItemHovered()) { return HTCAPTION; @@ -302,7 +302,7 @@ namespace hex { // Set up the correct window procedure based on the borderless window mode state if (borderlessWindowMode) { - g_oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)borderlessWindowProc); + s_oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)borderlessWindowProc); MARGINS borderless = { 1, 1, 1, 1 }; ::DwmExtendFrameIntoClientArea(hwnd, &borderless); @@ -313,41 +313,41 @@ namespace hex { ::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE); ::SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW); } else { - g_oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)commonWindowProc); + s_oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)commonWindowProc); } // Set up a taskbar progress handler { if (SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) { - CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER, IID_ITaskbarList4, &g_taskbarList); + CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER, IID_ITaskbarList4, &s_taskbarList); } EventSetTaskBarIconState::subscribe([hwnd](u32 state, u32 type, u32 progress){ using enum ImHexApi::System::TaskProgressState; switch (ImHexApi::System::TaskProgressState(state)) { case Reset: - g_taskbarList->SetProgressState(hwnd, TBPF_NOPROGRESS); - g_taskbarList->SetProgressValue(hwnd, 0, 0); + s_taskbarList->SetProgressState(hwnd, TBPF_NOPROGRESS); + s_taskbarList->SetProgressValue(hwnd, 0, 0); break; case Flash: FlashWindow(hwnd, true); break; case Progress: - g_taskbarList->SetProgressState(hwnd, TBPF_INDETERMINATE); - g_taskbarList->SetProgressValue(hwnd, progress, 100); + s_taskbarList->SetProgressState(hwnd, TBPF_INDETERMINATE); + s_taskbarList->SetProgressValue(hwnd, progress, 100); break; } using enum ImHexApi::System::TaskProgressType; switch (ImHexApi::System::TaskProgressType(type)) { case Normal: - g_taskbarList->SetProgressState(hwnd, TBPF_NORMAL); + s_taskbarList->SetProgressState(hwnd, TBPF_NORMAL); break; case Warning: - g_taskbarList->SetProgressState(hwnd, TBPF_PAUSED); + s_taskbarList->SetProgressState(hwnd, TBPF_PAUSED); break; case Error: - g_taskbarList->SetProgressState(hwnd, TBPF_ERROR); + s_taskbarList->SetProgressState(hwnd, TBPF_ERROR); break; } }); @@ -388,7 +388,7 @@ namespace hex { } void Window::beginNativeWindowFrame() { - g_titleBarHeight = ImGui::GetCurrentWindowRead()->MenuBarHeight(); + s_titleBarHeight = ImGui::GetCurrentWindowRead()->MenuBarHeight(); } void Window::endNativeWindowFrame() { diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 02a58ce7f..092e04da8 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -372,9 +372,9 @@ namespace hex { ImGui::PopStyleVar(); bool shouldDrawSidebar = [] { - if (const auto &items = ContentRegistry::Interface::impl::getSidebarItems(); items.empty()) + if (const auto &items = ContentRegistry::Interface::impl::getSidebarItems(); items.empty()) { return false; - else { + } else { return std::any_of(items.begin(), items.end(), [](const auto &item) { return item.enabledCallback(); }); @@ -894,12 +894,12 @@ namespace hex { for (const auto viewPort : ImGui::GetPlatformIO().Viewports) { auto drawData = viewPort->DrawData; for (int n = 0; n < drawData->CmdListsCount; n++) { - const ImDrawList *cmd_list = drawData->CmdLists[n]; - drawDataHash = ImHashData(cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), drawDataHash); + const ImDrawList *cmdList = drawData->CmdLists[n]; + drawDataHash = ImHashData(cmdList->VtxBuffer.Data, cmdList->VtxBuffer.Size * sizeof(ImDrawVert), drawDataHash); } for (int n = 0; n < drawData->CmdListsCount; n++) { - const ImDrawList *cmd_list = drawData->CmdLists[n]; - drawDataHash = ImHashData(cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), drawDataHash); + const ImDrawList *cmdList = drawData->CmdLists[n]; + drawDataHash = ImHashData(cmdList->IdxBuffer.Data, cmdList->IdxBuffer.Size * sizeof(ImDrawIdx), drawDataHash); } } @@ -1202,7 +1202,7 @@ namespace hex { handler.ReadOpenFn = [](ImGuiContext *ctx, ImGuiSettingsHandler *, const char *) -> void* { return ctx; }; handler.ReadLineFn = [](ImGuiContext *, ImGuiSettingsHandler *handler, void *, const char *line) { - Window* window = static_cast(handler->UserData); + auto window = static_cast(handler->UserData); for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) { std::string format = view->getUnlocalizedName().get() + "=%d"; diff --git a/plugins/builtin/include/content/views/view_store.hpp b/plugins/builtin/include/content/views/view_store.hpp index 275e9b47b..bec995afa 100644 --- a/plugins/builtin/include/content/views/view_store.hpp +++ b/plugins/builtin/include/content/views/view_store.hpp @@ -59,16 +59,6 @@ namespace hex::plugin::builtin { [[nodiscard]] ImVec2 getMaxSize() const override { return scaled({ 900, 700 }); } private: - HttpRequest m_httpRequest = HttpRequest("GET", ""); - std::future> m_apiRequest; - std::future> m_download; - std::fs::path m_downloadPath; - RequestStatus m_requestStatus = RequestStatus::NotAttempted; - - std::vector m_categories; - TaskHolder m_updateAllTask; - std::atomic m_updateCount = 0; - void drawStore(); void drawTab(StoreCategory &category); void handleDownloadFinished(const StoreCategory &category, StoreEntry &entry); @@ -80,6 +70,17 @@ namespace hex::plugin::builtin { bool download(fs::ImHexPath pathType, const std::string &fileName, const std::string &url, bool update); bool remove(fs::ImHexPath pathType, const std::string &fileName); + + private: + HttpRequest m_httpRequest = HttpRequest("GET", ""); + std::future> m_apiRequest; + std::future> m_download; + std::fs::path m_downloadPath; + RequestStatus m_requestStatus = RequestStatus::NotAttempted; + + std::vector m_categories; + TaskHolder m_updateAllTask; + std::atomic m_updateCount = 0; }; } \ No newline at end of file diff --git a/plugins/builtin/source/content/achievements.cpp b/plugins/builtin/source/content/achievements.cpp index ee06a4dac..b06fdfeb2 100644 --- a/plugins/builtin/source/content/achievements.cpp +++ b/plugins/builtin/source/content/achievements.cpp @@ -220,7 +220,7 @@ namespace hex::plugin::builtin { ProjectFile::registerHandler({ .basePath = "challenge", .required = false, - .load = [](const std::fs::path &basePath, Tar &tar) { + .load = [](const std::fs::path &basePath, const Tar &tar) { if (!tar.contains(basePath / "achievements.json") || !tar.contains(basePath / "description.txt")) return true; @@ -302,7 +302,7 @@ namespace hex::plugin::builtin { return true; }, - .store = [](const std::fs::path &basePath, Tar &tar) { + .store = [](const std::fs::path &basePath, const Tar &tar) { if (!challengeAchievement.empty()) tar.writeString(basePath / "achievements.json", challengeAchievement); if (!challengeDescription.empty()) diff --git a/plugins/builtin/source/content/command_line_interface.cpp b/plugins/builtin/source/content/command_line_interface.cpp index 384c5b2a8..1d3d30b4a 100644 --- a/plugins/builtin/source/content/command_line_interface.cpp +++ b/plugins/builtin/source/content/command_line_interface.cpp @@ -266,9 +266,9 @@ namespace hex::plugin::builtin { void handlePatternLanguageCommand(const std::vector &args) { std::vector processedArgs = args; - if (processedArgs.empty()) + if (processedArgs.empty()) { processedArgs.emplace_back("--help"); - else { + } else { for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::PatternsInclude)) processedArgs.emplace_back(hex::format("--includes={}", wolv::util::toUTF8String(path))); } diff --git a/plugins/builtin/source/content/command_palette_commands.cpp b/plugins/builtin/source/content/command_palette_commands.cpp index a44fc4e79..8b63dd864 100644 --- a/plugins/builtin/source/content/command_palette_commands.cpp +++ b/plugins/builtin/source/content/command_palette_commands.cpp @@ -46,7 +46,7 @@ namespace hex::plugin::builtin { } else { m_value = std::stod(value) * m_multiplier; } - } catch (const std::exception &e) { + } catch (const std::exception &) { m_value = 0; m_unit = Unit::Invalid; m_unitString.clear(); @@ -176,34 +176,34 @@ namespace hex::plugin::builtin { else if (unitString.starts_with("a")) { multiplier = 1E-18; unitString = unitString.substr(1); } else if (unitString.starts_with("z")) { multiplier = 1E-21; unitString = unitString.substr(1); } else if (unitString.starts_with("y")) { multiplier = 1E-24; unitString = unitString.substr(1); } - else return parseUnit(unitString, false); + else { return parseUnit(unitString, false); } } unitString = wolv::util::trim(unitString); m_unitString = unitString; if (unitString.empty()) { - if (multiplier == 1) + if (multiplier == 1) { return { Unit::Unitless, 1 }; - else { + } else { m_unitString = unitStringCopy; return { Unit::Unitless, 1 }; } - } - else if (unitString == "bit" || unitString == "bits" || unitString == "b") + } else if (unitString == "bit" || unitString == "bits" || unitString == "b") { return { Unit::Bits, multiplier }; - else if (unitString == "byte" || unitString == "bytes" || unitString == "B") + } else if (unitString == "byte" || unitString == "bytes" || unitString == "B") { return { Unit::Bytes, multiplier }; - else if (unitString == "hex" || unitString == "hex.builtin.command.convert.hexadecimal"_lang.get()) + } else if (unitString == "hex" || unitString == "hex.builtin.command.convert.hexadecimal"_lang.get()) { return { Unit::Hexadecimal, multiplier }; - else if (unitString == "bin" || unitString == "hex.builtin.command.convert.binary"_lang.get()) + } else if (unitString == "bin" || unitString == "hex.builtin.command.convert.binary"_lang.get()) { return { Unit::Binary, multiplier }; - else if (unitString == "oct" || unitString == "hex.builtin.command.convert.octal"_lang.get()) + } else if (unitString == "oct" || unitString == "hex.builtin.command.convert.octal"_lang.get()) { return { Unit::Octal, multiplier }; - else if (unitString == "dec" || unitString == "hex.builtin.command.convert.decimal"_lang.get()) + } else if (unitString == "dec" || unitString == "hex.builtin.command.convert.decimal"_lang.get()) { return { Unit::Decimal, multiplier }; - else + } else { return { Unit::Invalid, multiplier }; + } } private: diff --git a/plugins/builtin/source/content/data_visualizers.cpp b/plugins/builtin/source/content/data_visualizers.cpp index 43a8a2f0f..3bff60c31 100644 --- a/plugins/builtin/source/content/data_visualizers.cpp +++ b/plugins/builtin/source/content/data_visualizers.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -30,9 +29,9 @@ namespace hex::plugin::builtin { if (size == ByteCount) { return drawDefaultScalarEditingTextBox(address, getFormatString(upperCase), ImGuiExt::getImGuiDataType(), data, ImGuiInputTextFlags_CharsHexadecimal); - } - else + } else { return false; + } } private: @@ -73,9 +72,9 @@ namespace hex::plugin::builtin { ImGui::Text(getFormatString(upperCase), c); break; } - } - else + } else { ImGuiExt::TextFormatted("{: {}s}", CharCount); + } } bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override { @@ -83,9 +82,9 @@ namespace hex::plugin::builtin { if (size == ByteCount) { return drawDefaultScalarEditingTextBox(address, getFormatString(upperCase), ImGuiExt::getImGuiDataType(), data, ImGuiInputTextFlags_None); - } - else + } else { return false; + } } private: @@ -116,9 +115,9 @@ namespace hex::plugin::builtin { ImGui::Text(getFormatString(), static_cast(*reinterpret_cast(data))); else ImGui::Text(getFormatString(), static_cast(*reinterpret_cast(data))); - } - else + } else { ImGuiExt::TextFormatted("{: {}s}", CharCount); + } } bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override { @@ -126,9 +125,9 @@ namespace hex::plugin::builtin { if (size == ByteCount) { return drawDefaultScalarEditingTextBox(address, FormatString.c_str(), ImGuiExt::getImGuiDataType(), data, ImGuiInputTextFlags_None); - } - else + } else { return false; + } } private: @@ -163,9 +162,9 @@ namespace hex::plugin::builtin { if (size == ByteCount) { return drawDefaultScalarEditingTextBox(address, getFormatString(upperCase), ImGuiExt::getImGuiDataType(), data, ImGuiInputTextFlags_CharsScientific); - } - else + } else { return false; + } } private: diff --git a/plugins/builtin/source/content/events.cpp b/plugins/builtin/source/content/events.cpp index 7a6672d17..3b109473e 100644 --- a/plugins/builtin/source/content/events.cpp +++ b/plugins/builtin/source/content/events.cpp @@ -108,7 +108,7 @@ namespace hex::plugin::builtin { ui::ToastError::open(hex::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); } } else { - FileProvider* newProvider = static_cast( + auto newProvider = static_cast( ImHexApi::Provider::createProvider("hex.builtin.provider.file", true) ); @@ -116,9 +116,9 @@ namespace hex::plugin::builtin { return; newProvider->setPath(path); - if (!newProvider->open()) + if (!newProvider->open()) { hex::ImHexApi::Provider::remove(newProvider); - else { + } else { EventProviderOpened::post(newProvider); AchievementManager::unlockAchievement("hex.builtin.achievement.starting_out", "hex.builtin.achievement.starting_out.open_file.name"); } diff --git a/plugins/builtin/source/content/fonts.cpp b/plugins/builtin/source/content/fonts.cpp index 666777c0e..97e3961da 100644 --- a/plugins/builtin/source/content/fonts.cpp +++ b/plugins/builtin/source/content/fonts.cpp @@ -1,4 +1,3 @@ -#include #include #include @@ -8,8 +7,6 @@ #include #include -#include - namespace hex::plugin::builtin { void loadFonts() { diff --git a/plugins/builtin/source/content/init_tasks.cpp b/plugins/builtin/source/content/init_tasks.cpp index c0a9e511c..2bf520865 100644 --- a/plugins/builtin/source/content/init_tasks.cpp +++ b/plugins/builtin/source/content/init_tasks.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -59,7 +58,7 @@ namespace hex::plugin::builtin { ImHexApi::System::impl::addInitArgument("update-available", latestVersion.data()); // Check if there is a telemetry uuid - std::string uuid = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", "").get(); + auto uuid = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", "").get(); if (uuid.empty()) { // Generate a new uuid uuid = wolv::hash::generateUUID(); diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index 9a02616d0..af2ba5032 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -26,7 +26,7 @@ using namespace std::literals::string_literals; namespace hex::plugin::builtin { - static bool g_demoWindowOpen = false; + static bool s_demoWindowOpen = false; namespace { @@ -275,9 +275,9 @@ namespace hex::plugin::builtin { return; } - if (data.has_value()) + if (data.has_value()) { file.writeVector(data.value()); - else { + } else { handleIPSError(data.error()); } @@ -314,9 +314,9 @@ namespace hex::plugin::builtin { return; } - if (data.has_value()) + if (data.has_value()) { file.writeVector(data.value()); - else { + } else { handleIPSError(data.error()); } @@ -490,7 +490,7 @@ namespace hex::plugin::builtin { #if defined(DEBUG) ImGui::Separator(); - ImGui::MenuItem("hex.builtin.menu.view.demo"_lang, "", &g_demoWindowOpen); + ImGui::MenuItem("hex.builtin.menu.view.demo"_lang, "", &s_demoWindowOpen); ImGui::MenuItem("hex.builtin.menu.view.debug"_lang, "", &hex::dbg::impl::getDebugWindowState()); #endif }); @@ -531,9 +531,9 @@ namespace hex::plugin::builtin { if (shift) { wolv::io::fs::remove(path); LayoutManager::reload(); - } - else + } else { LayoutManager::load(path); + } } } }); @@ -580,9 +580,9 @@ namespace hex::plugin::builtin { createHelpMenu(); (void)EventFrameEnd::subscribe([] { - if (g_demoWindowOpen) { - ImGui::ShowDemoWindow(&g_demoWindowOpen); - ImPlot::ShowDemoWindow(&g_demoWindowOpen); + if (s_demoWindowOpen) { + ImGui::ShowDemoWindow(&s_demoWindowOpen); + ImPlot::ShowDemoWindow(&s_demoWindowOpen); } }); } diff --git a/plugins/builtin/source/content/pl_builtin_functions.cpp b/plugins/builtin/source/content/pl_builtin_functions.cpp index 5c6cab9be..95f47e94f 100644 --- a/plugins/builtin/source/content/pl_builtin_functions.cpp +++ b/plugins/builtin/source/content/pl_builtin_functions.cpp @@ -6,7 +6,6 @@ #include #include -#include #include diff --git a/plugins/builtin/source/content/providers.cpp b/plugins/builtin/source/content/providers.cpp index ae19972ac..4eb2266ba 100644 --- a/plugins/builtin/source/content/providers.cpp +++ b/plugins/builtin/source/content/providers.cpp @@ -44,7 +44,7 @@ namespace hex::plugin::builtin { ProjectFile::registerHandler({ .basePath = "providers", .required = true, - .load = [](const std::fs::path &basePath, Tar &tar) { + .load = [](const std::fs::path &basePath, const Tar &tar) { auto json = nlohmann::json::parse(tar.readString(basePath / "providers.json")); auto providerIds = json.at("providers").get>(); @@ -88,8 +88,9 @@ namespace hex::plugin::builtin { if (loaded) { if (!newProvider->open() || !newProvider->isAvailable() || !newProvider->isReadable()) { providerWarnings[newProvider] = newProvider->getErrorMessage(); - } else + } else { EventProviderOpened::post(newProvider); + } } } @@ -110,15 +111,16 @@ namespace hex::plugin::builtin { } else { // Else, if are warnings, still display them - if (warningMsg.empty()) return true; - else { + if (warningMsg.empty()) { + return true; + } else { showWarning( hex::format("hex.builtin.popup.error.project.load.some_providers_failed"_lang, warningMsg)); } return success; } }, - .store = [](const std::fs::path &basePath, Tar &tar) { + .store = [](const std::fs::path &basePath, const Tar &tar) { std::vector providerIds; for (const auto &provider : ImHexApi::Provider::getProviders()) { auto id = provider->getID(); diff --git a/plugins/builtin/source/content/providers/disk_provider.cpp b/plugins/builtin/source/content/providers/disk_provider.cpp index be12b2657..79cf9794b 100644 --- a/plugins/builtin/source/content/providers/disk_provider.cpp +++ b/plugins/builtin/source/content/providers/disk_provider.cpp @@ -302,7 +302,7 @@ namespace hex::plugin::builtin { size_t currSize = std::min(size, m_sectorSize); this->readRaw(sectorBase, modifiedSectorBuffer.data(), modifiedSectorBuffer.size()); - std::memcpy(modifiedSectorBuffer.data() + ((offset - sectorBase) % m_sectorSize), reinterpret_cast(buffer) + (startOffset - offset), currSize); + std::memcpy(modifiedSectorBuffer.data() + ((offset - sectorBase) % m_sectorSize), static_cast(buffer) + (startOffset - offset), currSize); LARGE_INTEGER seekPosition; seekPosition.LowPart = (offset & 0xFFFF'FFFF) - (offset % m_sectorSize); diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index 0bf1c5ffe..b49816bc1 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -260,9 +260,9 @@ namespace hex::plugin::builtin { this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), e.what())); } } - } - else + } else { this->setPath(path); + } } nlohmann::json FileProvider::storeSettings(nlohmann::json settings) const { @@ -290,9 +290,9 @@ namespace hex::plugin::builtin { auto newProvider = hex::ImHexApi::Provider::createProvider("hex.builtin.provider.mem_file", true); if (auto memoryProvider = dynamic_cast(newProvider); memoryProvider != nullptr) { - if (!memoryProvider->open()) + if (!memoryProvider->open()) { ImHexApi::Provider::remove(newProvider); - else { + } else { const auto size = this->getActualSize(); TaskManager::createTask("Loading into memory", size, [this, size, memoryProvider](Task &task) { task.setInterruptCallback([memoryProvider]{ diff --git a/plugins/builtin/source/content/providers/intel_hex_provider.cpp b/plugins/builtin/source/content/providers/intel_hex_provider.cpp index 311cef892..634a3c360 100644 --- a/plugins/builtin/source/content/providers/intel_hex_provider.cpp +++ b/plugins/builtin/source/content/providers/intel_hex_provider.cpp @@ -57,9 +57,9 @@ namespace hex::plugin::builtin { return string[offset++]; }; - auto parseValue = [&](u8 byteCount) { + auto parseValue = [&](u8 count) { u64 value = 0x00; - for (u8 i = 0; i < byteCount; i++) { + for (u8 i = 0; i < count; i++) { u8 byte = (parseHexDigit(c()) << 4) | parseHexDigit(c()); value <<= 8; value |= byte; diff --git a/plugins/builtin/source/content/providers/memory_file_provider.cpp b/plugins/builtin/source/content/providers/memory_file_provider.cpp index b074cddde..0dce52a0b 100644 --- a/plugins/builtin/source/content/providers/memory_file_provider.cpp +++ b/plugins/builtin/source/content/providers/memory_file_provider.cpp @@ -53,9 +53,9 @@ namespace hex::plugin::builtin { if (auto fileProvider = dynamic_cast(newProvider); fileProvider != nullptr) { fileProvider->setPath(path); - if (!fileProvider->open()) + if (!fileProvider->open()) { ImHexApi::Provider::remove(newProvider); - else { + } else { MovePerProviderData::post(this, fileProvider); fileProvider->markDirty(false); diff --git a/plugins/builtin/source/content/providers/motorola_srec_provider.cpp b/plugins/builtin/source/content/providers/motorola_srec_provider.cpp index 2f3fd8ae1..746c63e9b 100644 --- a/plugins/builtin/source/content/providers/motorola_srec_provider.cpp +++ b/plugins/builtin/source/content/providers/motorola_srec_provider.cpp @@ -43,9 +43,9 @@ namespace hex::plugin::builtin { return string[offset++]; }; - auto parseValue = [&](u8 byteCount) { + auto parseValue = [&](u8 count) { u64 value = 0x00; - for (u8 i = 0; i < byteCount; i++) { + for (u8 i = 0; i < count; i++) { u8 byte = (parseHexDigit(c()) << 4) | parseHexDigit(c()); value <<= 8; value |= byte; diff --git a/plugins/builtin/source/content/providers/process_memory_provider.cpp b/plugins/builtin/source/content/providers/process_memory_provider.cpp index 2b39c8f79..bb338dc41 100644 --- a/plugins/builtin/source/content/providers/process_memory_provider.cpp +++ b/plugins/builtin/source/content/providers/process_memory_provider.cpp @@ -400,8 +400,9 @@ namespace hex::plugin::builtin { return m_selectedProcess->id; } else if (category == "process_name") { return m_selectedProcess->name; - } else + } else { return Provider::queryInformation(category, argument); + } } } diff --git a/plugins/builtin/source/content/recent.cpp b/plugins/builtin/source/content/recent.cpp index 04409a04e..fa430e7ec 100644 --- a/plugins/builtin/source/content/recent.cpp +++ b/plugins/builtin/source/content/recent.cpp @@ -344,9 +344,10 @@ namespace hex::plugin::builtin::recent { s_recentEntries.clear(); // Remove all recent files - for (const auto &recentPath : fs::getDefaultPaths(fs::ImHexPath::Recent)) + for (const auto &recentPath : fs::getDefaultPaths(fs::ImHexPath::Recent)) { for (const auto &entry : std::fs::directory_iterator(recentPath)) std::fs::remove(entry.path()); + } } ImGui::EndMenu(); diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index 9f5685145..6cb0fff94 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -543,9 +543,9 @@ namespace hex::plugin::builtin { static void loadThemeSettings() { auto theme = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.color", ThemeManager::NativeTheme).get(); - if (theme == ThemeManager::NativeTheme) + if (theme == ThemeManager::NativeTheme) { ImHexApi::System::enableSystemThemeDetection(true); - else { + } else { ImHexApi::System::enableSystemThemeDetection(false); ThemeManager::changeTheme(theme); } diff --git a/plugins/builtin/source/content/tools/color_picker.cpp b/plugins/builtin/source/content/tools/color_picker.cpp index 7e23cd08f..05b24bd0f 100644 --- a/plugins/builtin/source/content/tools/color_picker.cpp +++ b/plugins/builtin/source/content/tools/color_picker.cpp @@ -3,8 +3,6 @@ #include -#include - #include #include diff --git a/plugins/builtin/source/content/tools/file_tool_combiner.cpp b/plugins/builtin/source/content/tools/file_tool_combiner.cpp index 34b0b4ed9..2a308c310 100644 --- a/plugins/builtin/source/content/tools/file_tool_combiner.cpp +++ b/plugins/builtin/source/content/tools/file_tool_combiner.cpp @@ -106,9 +106,9 @@ namespace hex::plugin::builtin { ImGui::BeginDisabled(files.empty() || outputPath.empty()); { - if (combinerTask.isRunning()) + if (combinerTask.isRunning()) { ImGuiExt::TextSpinner("hex.builtin.tools.file_tools.combiner.combining"_lang); - else { + } else { if (ImGui::Button("hex.builtin.tools.file_tools.combiner.combine"_lang)) { combinerTask = TaskManager::createTask("hex.builtin.tools.file_tools.combiner.combining", 0, [](auto &task) { wolv::io::File output(outputPath, wolv::io::File::Mode::Create); diff --git a/plugins/builtin/source/content/tools/file_tool_shredder.cpp b/plugins/builtin/source/content/tools/file_tool_shredder.cpp index 619dc8340..c9a49d17b 100644 --- a/plugins/builtin/source/content/tools/file_tool_shredder.cpp +++ b/plugins/builtin/source/content/tools/file_tool_shredder.cpp @@ -42,9 +42,9 @@ namespace hex::plugin::builtin { } ImGui::EndChild(); - if (shredderTask.isRunning()) + if (shredderTask.isRunning()) { ImGuiExt::TextSpinner("hex.builtin.tools.file_tools.shredder.shredding"_lang); - else { + } else { ImGui::BeginDisabled(selectedFile.empty()); { if (ImGui::Button("hex.builtin.tools.file_tools.shredder.shred"_lang)) { diff --git a/plugins/builtin/source/content/tools/file_tool_splitter.cpp b/plugins/builtin/source/content/tools/file_tool_splitter.cpp index b0f628a55..a52961cee 100644 --- a/plugins/builtin/source/content/tools/file_tool_splitter.cpp +++ b/plugins/builtin/source/content/tools/file_tool_splitter.cpp @@ -89,9 +89,9 @@ namespace hex::plugin::builtin { ImGui::BeginDisabled(selectedFile.empty() || baseOutputPath.empty() || splitSize == 0); { - if (splitterTask.isRunning()) + if (splitterTask.isRunning()) { ImGuiExt::TextSpinner("hex.builtin.tools.file_tools.splitter.picker.splitting"_lang); - else { + } else { if (ImGui::Button("hex.builtin.tools.file_tools.splitter.picker.split"_lang)) { splitterTask = TaskManager::createTask("hex.builtin.tools.file_tools.splitter.picker.splitting", 0, [](auto &task) { ON_SCOPE_EXIT { diff --git a/plugins/builtin/source/content/tools/ieee_decoder.cpp b/plugins/builtin/source/content/tools/ieee_decoder.cpp index eb4a77c87..d85f6749f 100644 --- a/plugins/builtin/source/content/tools/ieee_decoder.cpp +++ b/plugins/builtin/source/content/tools/ieee_decoder.cpp @@ -262,9 +262,9 @@ namespace hex::plugin::builtin { // Zero or denormal. if (ieee754.exponentBits == 0) { // Result doesn't fit in 128 bits. - if ((ieee754.exponentBias - 1) > 128) + if ((ieee754.exponentBias - 1) > 128) { ieee754.exponentValue = std::pow(2.0L, static_cast(-ieee754.exponentBias + 1)); - else { + } else { if (ieee754.exponentBias == 0) { // Exponent is zero. if (ieee754.mantissaBits == 0) @@ -272,17 +272,18 @@ namespace hex::plugin::builtin { else // Exponent is one. ieee754.exponentValue = 2.0; - } - else + } else { ieee754.exponentValue = 1.0 / static_cast(u128(1) << (ieee754.exponentBias - 1)); + } } } // Normal. else { // Result doesn't fit in 128 bits. - if (std::abs(ieee754.exponentBits - ieee754.exponentBias) > 128) + if (std::abs(ieee754.exponentBits - ieee754.exponentBias) > 128) { ieee754.exponentValue = std::pow(2.0L, static_cast(ieee754.exponentBits - ieee754.exponentBias)); - //Result fits in 128 bits. + } + //Result fits in 128 bits. else { // Exponent is positive. if (ieee754.exponentBits > ieee754.exponentBias) @@ -356,9 +357,10 @@ namespace hex::plugin::builtin { // And remove it from the string. ieee754.signBits = 1; decimalFloatingPointNumberString.erase(0, 1); - } else + } else { // Important to switch from - to +. ieee754.signBits = 0; + } InputType inputType = InputType::Regular; bool matchFound = false; @@ -385,14 +387,13 @@ namespace hex::plugin::builtin { ieee754statics.resultFloat = std::numeric_limits::infinity(); ieee754statics.resultFloat *= (ieee754.signBits == 1 ? -1 : 1); - } else if (inputType == InputType::NotANumber) + } else if (inputType == InputType::NotANumber) { ieee754statics.resultFloat = std::numeric_limits::quiet_NaN(); - - else if (inputType == InputType::QuietNotANumber) + } else if (inputType == InputType::QuietNotANumber) { ieee754statics.resultFloat = std::numeric_limits::quiet_NaN(); - - else if (inputType == InputType::SignalingNotANumber) + } else if (inputType == InputType::SignalingNotANumber) { ieee754statics.resultFloat = std::numeric_limits::signaling_NaN(); + } if (inputType != InputType::Invalid) { @@ -514,15 +515,15 @@ namespace hex::plugin::builtin { ImGui::Text("qNaN"); else ImGui::Text("sNaN"); - - } else if (ieee754.numberType == NumberType::Infinity) + } else if (ieee754.numberType == NumberType::Infinity) { ImGui::Text("Inf"); - else if (ieee754.numberType == NumberType::Zero) + } else if (ieee754.numberType == NumberType::Zero) { ImGui::Text("0"); - else if (ieee754.numberType == NumberType::Denormal) + } else if (ieee754.numberType == NumberType::Denormal) { ImGuiExt::TextFormatted("2^{0}", 1 - ieee754.exponentBias); - else + } else { ImGuiExt::TextFormatted("2^{0}", ieee754.exponentBits - ieee754.exponentBias); + } ImGui::Unindent(20_scaled); @@ -681,8 +682,9 @@ namespace hex::plugin::builtin { decimalFloatingPointNumberString = "qnan"; else decimalFloatingPointNumberString = "snan"; - } else + } else { decimalFloatingPointNumberString = fmt::format("{:.{}}", ieee754statics.resultFloat, ieee754.precision); + } auto style1 = ImGui::GetStyle(); inputFieldWidth = std::fmax(inputFieldWidth, ImGui::CalcTextSize(decimalFloatingPointNumberString.c_str()).x + 2 * style1.FramePadding.x); diff --git a/plugins/builtin/source/content/tools/wiki_explainer.cpp b/plugins/builtin/source/content/tools/wiki_explainer.cpp index 5c19e35b8..def1ad9f3 100644 --- a/plugins/builtin/source/content/tools/wiki_explainer.cpp +++ b/plugins/builtin/source/content/tools/wiki_explainer.cpp @@ -16,7 +16,7 @@ namespace hex::plugin::builtin { using namespace std::literals::chrono_literals; std::string getWikipediaApiUrl() { - std::string setting = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.wiki_explain_language", "en").get(); + auto setting = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.wiki_explain_language", "en").get(); return "https://" + setting + ".wikipedia.org/w/api.php?format=json&action=query&prop=extracts&explaintext&redirects=10&formatversion=2"; } diff --git a/plugins/builtin/source/content/tutorials/introduction.cpp b/plugins/builtin/source/content/tutorials/introduction.cpp index 9e3a02cd3..1a4f8c935 100644 --- a/plugins/builtin/source/content/tutorials/introduction.cpp +++ b/plugins/builtin/source/content/tutorials/introduction.cpp @@ -92,7 +92,7 @@ namespace hex::plugin::builtin { Lang("hex.builtin.view.tutorials.name") }) .onAppear([&step] { - EventViewOpened::subscribe([&step](View *view){ + EventViewOpened::subscribe([&step](const View *view){ if (view->getUnlocalizedName() == UnlocalizedString("hex.builtin.view.tutorials.name")) step.complete(); }); diff --git a/plugins/builtin/source/content/views/view_achievements.cpp b/plugins/builtin/source/content/views/view_achievements.cpp index 4b32cdd9c..b41c16d51 100644 --- a/plugins/builtin/source/content/views/view_achievements.cpp +++ b/plugins/builtin/source/content/views/view_achievements.cpp @@ -53,14 +53,14 @@ namespace hex::plugin::builtin { // Determine achievement fill color based on unlock state const auto fillColor = [&] { - if (achievement.isUnlocked()) + if (achievement.isUnlocked()) { return ImGui::GetColorU32(ImGuiCol_FrameBg, 1.0F) | 0xFF000000; - else if (node->isUnlockable()) { + } else if (node->isUnlockable()) { auto cycleProgress = sinf(float(ImGui::GetTime()) * 6.0F) * 0.5F + 0.5F; return (u32(ImColor(ImLerp(ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled), ImGui::GetStyleColorVec4(ImGuiCol_Text), cycleProgress))) & 0x00FFFFFF) | 0x80000000; - } - else + } else { return ImGui::GetColorU32(ImGuiCol_TextDisabled, 0.5F); + } }(); // Draw achievement background diff --git a/plugins/builtin/source/content/views/view_bookmarks.cpp b/plugins/builtin/source/content/views/view_bookmarks.cpp index d286a00d4..53633199a 100644 --- a/plugins/builtin/source/content/views/view_bookmarks.cpp +++ b/plugins/builtin/source/content/views/view_bookmarks.cpp @@ -141,7 +141,7 @@ namespace hex::plugin::builtin { ProjectFile::registerPerProviderHandler({ .basePath = "bookmarks.json", .required = false, - .load = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) -> bool { + .load = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool { auto fileContent = tar.readString(basePath); if (fileContent.empty()) return true; @@ -150,7 +150,7 @@ namespace hex::plugin::builtin { m_bookmarks.get(provider).clear(); return this->importBookmarks(provider, data); }, - .store = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) -> bool { + .store = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool { nlohmann::json data; bool result = this->exportBookmarks(provider, data); @@ -194,7 +194,7 @@ namespace hex::plugin::builtin { static void drawColorPopup(ImColor &color) { // Generate color picker palette - static auto Palette = [] { + const static auto Palette = [] { constexpr static auto ColorCount = 36; std::array result = { 0 }; @@ -212,7 +212,7 @@ namespace hex::plugin::builtin { bool colorChanged = false; // Draw default color picker - if (ImGui::ColorPicker4("##picker", (float*)&color, ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview)) + if (ImGui::ColorPicker4("##picker", &color.Value.x, ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview)) colorChanged = true; ImGui::Separator(); @@ -343,9 +343,9 @@ namespace hex::plugin::builtin { ImGui::SameLine(); // Draw bookmark name if the bookmark is locked or an input text box if it's unlocked - if (locked) + if (locked) { ImGui::TextUnformatted(name.data()); - else { + } else { ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x); ImGui::InputText("##nameInput", name); ImGui::PopItemWidth(); diff --git a/plugins/builtin/source/content/views/view_command_palette.cpp b/plugins/builtin/source/content/views/view_command_palette.cpp index 7d17f7282..2e6c57cce 100644 --- a/plugins/builtin/source/content/views/view_command_palette.cpp +++ b/plugins/builtin/source/content/views/view_command_palette.cpp @@ -164,9 +164,9 @@ namespace hex::plugin::builtin { // These commands are used by entering a single symbol and then any input if (auto [match, value] = MatchCommand(input, command); match != MatchType::NoMatch) { - if (match != MatchType::PerfectMatch) + if (match != MatchType::PerfectMatch) { results.push_back({ command + " (" + Lang(unlocalizedDescription) + ")", "", AutoComplete }); - else { + } else { auto matchedCommand = wolv::util::trim(input.substr(command.length())); results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback }); } @@ -176,9 +176,9 @@ namespace hex::plugin::builtin { // These commands are used by entering a keyword followed by a space and then any input if (auto [match, value] = MatchCommand(input, command + " "); match != MatchType::NoMatch) { - if (match != MatchType::PerfectMatch) + if (match != MatchType::PerfectMatch) { results.push_back({ command + " (" + Lang(unlocalizedDescription) + ")", "", AutoComplete }); - else { + } else { auto matchedCommand = wolv::util::trim(input.substr(command.length() + 1)); results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback }); } diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index a7df18cc2..90e7c1b29 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -213,9 +213,10 @@ namespace hex::plugin::builtin { // Find the index of an attribute by its id auto indexFromId = [this](u32 id) -> std::optional { const auto &attributes = this->getAttributes(); - for (u32 i = 0; i < attributes.size(); i++) + for (u32 i = 0; i < attributes.size(); i++) { if (u32(attributes[i].getId()) == id) return i; + } return std::nullopt; }; @@ -355,7 +356,7 @@ namespace hex::plugin::builtin { ProjectFile::registerPerProviderHandler({ .basePath = "data_processor.json", .required = false, - .load = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) { + .load = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) { std::string save = tar.readString(basePath); ViewDataProcessor::loadNodes(m_mainWorkspace.get(provider), nlohmann::json::parse(save)); @@ -363,7 +364,7 @@ namespace hex::plugin::builtin { return true; }, - .store = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) { + .store = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) { tar.writeString(basePath, ViewDataProcessor::saveNodes(m_mainWorkspace.get(provider)).dump(4)); return true; @@ -599,11 +600,11 @@ namespace hex::plugin::builtin { // Show a different context menu depending on if a node, a link // or the background was right-clicked - if (ImNodes::IsNodeHovered(&m_rightClickedId)) + if (ImNodes::IsNodeHovered(&m_rightClickedId)) { ImGui::OpenPopup("Node Menu"); - else if (ImNodes::IsLinkHovered(&m_rightClickedId)) + } else if (ImNodes::IsLinkHovered(&m_rightClickedId)) { ImGui::OpenPopup("Link Menu"); - else { + } else { ImGui::OpenPopup("Context Menu"); this->reloadCustomNodes(); } diff --git a/plugins/builtin/source/content/views/view_find.cpp b/plugins/builtin/source/content/views/view_find.cpp index 8fb07fc48..f5fad153d 100644 --- a/plugins/builtin/source/content/views/view_find.cpp +++ b/plugins/builtin/source/content/views/view_find.cpp @@ -264,7 +264,7 @@ namespace hex::plugin::builtin { return { }; std::vector bytes; - Occurrence::DecodeType decodeType = Occurrence::DecodeType::Binary; + auto decodeType = Occurrence::DecodeType::Binary; std::endian endian; switch (settings.type) { default: @@ -494,11 +494,11 @@ namespace hex::plugin::builtin { void ViewFind::runSearch() { Region searchRegion = m_searchSettings.region; - if (m_searchSettings.mode == SearchSettings::Mode::Strings) + if (m_searchSettings.mode == SearchSettings::Mode::Strings) { AchievementManager::unlockAchievement("hex.builtin.achievement.find", "hex.builtin.achievement.find.find_strings.name"); - else if (m_searchSettings.mode == SearchSettings::Mode::Sequence) + } else if (m_searchSettings.mode == SearchSettings::Mode::Sequence) { AchievementManager::unlockAchievement("hex.builtin.achievement.find", "hex.builtin.achievement.find.find_specific_string.name"); - else if (m_searchSettings.mode == SearchSettings::Mode::Value) { + } else if (m_searchSettings.mode == SearchSettings::Mode::Value) { if (m_searchSettings.value.inputMin == "250" && m_searchSettings.value.inputMax == "1000") AchievementManager::unlockAchievement("hex.builtin.achievement.find", "hex.builtin.achievement.find.find_numeric.name"); } diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index d6e75d5be..e45832bc7 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -1013,7 +1013,7 @@ namespace hex::plugin::builtin { ProjectFile::registerPerProviderHandler({ .basePath = "custom_encoding.tbl", .required = false, - .load = [this](prv::Provider *, const std::fs::path &basePath, Tar &tar) { + .load = [this](prv::Provider *, const std::fs::path &basePath, const Tar &tar) { if (!tar.contains(basePath)) return true; @@ -1023,7 +1023,7 @@ namespace hex::plugin::builtin { return true; }, - .store = [this](prv::Provider *, const std::fs::path &basePath, Tar &tar) { + .store = [this](prv::Provider *, const std::fs::path &basePath, const Tar &tar) { if (const auto &encoding = m_hexEditor.getCustomEncoding(); encoding.has_value()) { auto content = encoding->getTableContent(); diff --git a/plugins/builtin/source/content/views/view_highlight_rules.cpp b/plugins/builtin/source/content/views/view_highlight_rules.cpp index 743908a5f..ab9c01df3 100644 --- a/plugins/builtin/source/content/views/view_highlight_rules.cpp +++ b/plugins/builtin/source/content/views/view_highlight_rules.cpp @@ -115,7 +115,7 @@ namespace hex::plugin::builtin { ProjectFile::registerPerProviderHandler({ .basePath = "highlight_rules.json", .required = false, - .load = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) -> bool { + .load = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool { const auto json = nlohmann::json::parse(tar.readString(basePath)); auto &rules = m_rules.get(provider); @@ -138,7 +138,7 @@ namespace hex::plugin::builtin { return true; }, - .store = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) -> bool { + .store = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool { nlohmann::json result = nlohmann::json::array(); for (const auto &rule : m_rules.get(provider)) { nlohmann::json content; diff --git a/plugins/builtin/source/content/views/view_information.cpp b/plugins/builtin/source/content/views/view_information.cpp index cf8f32626..0b0fbf84c 100644 --- a/plugins/builtin/source/content/views/view_information.cpp +++ b/plugins/builtin/source/content/views/view_information.cpp @@ -292,9 +292,9 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); ImGuiExt::TextFormatted("{}", "hex.builtin.view.information.file_entropy"_lang); ImGui::TableNextColumn(); - if (m_averageEntropy < 0) + if (m_averageEntropy < 0) { ImGui::TextUnformatted("???"); - else { + } else { auto entropy = std::abs(m_averageEntropy); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.1F); ImGui::PushStyleColor(ImGuiCol_FrameBg, ImGui::GetColorU32(ImGuiCol_TableRowBgAlt)); @@ -333,9 +333,9 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); ImGuiExt::TextFormatted("{}", "hex.builtin.view.information.plain_text_percentage"_lang); ImGui::TableNextColumn(); - if (m_plainTextCharacterPercentage < 0) + if (m_plainTextCharacterPercentage < 0) { ImGui::TextUnformatted("???"); - else { + } else { ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.1F); ImGui::PushStyleColor(ImGuiCol_FrameBg, ImGui::GetColorU32(ImGuiCol_TableRowBgAlt)); ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImColor::HSV(0.3F * (m_plainTextCharacterPercentage / 100.0F), 0.8F, 0.6F, 1.0F).Value); diff --git a/plugins/builtin/source/content/views/view_patches.cpp b/plugins/builtin/source/content/views/view_patches.cpp index 38a1b4d80..d68602bb2 100644 --- a/plugins/builtin/source/content/views/view_patches.cpp +++ b/plugins/builtin/source/content/views/view_patches.cpp @@ -21,7 +21,7 @@ namespace hex::plugin::builtin { ProjectFile::registerPerProviderHandler({ .basePath = "patches.json", .required = false, - .load = [](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) { + .load = [](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) { auto json = nlohmann::json::parse(tar.readString(basePath)); auto patches = json.at("patches").get>(); diff --git a/plugins/builtin/source/content/views/view_pattern_data.cpp b/plugins/builtin/source/content/views/view_pattern_data.cpp index 3a679a73f..78a15f852 100644 --- a/plugins/builtin/source/content/views/view_pattern_data.cpp +++ b/plugins/builtin/source/content/views/view_pattern_data.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 3c8492cdf..cd8b221d1 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -68,12 +68,13 @@ namespace hex::plugin::builtin { paletteIndex = TextEditor::PaletteIndex::Default; } else if (TokenizeCStyleIdentifier(inBegin, inEnd, outBegin, outEnd)) { paletteIndex = TextEditor::PaletteIndex::Identifier; - } else if (TokenizeCStyleNumber(inBegin, inEnd, outBegin, outEnd)) + } else if (TokenizeCStyleNumber(inBegin, inEnd, outBegin, outEnd)) { paletteIndex = TextEditor::PaletteIndex::Number; - else if (TokenizeCStyleCharacterLiteral(inBegin, inEnd, outBegin, outEnd)) + } else if (TokenizeCStyleCharacterLiteral(inBegin, inEnd, outBegin, outEnd)) { paletteIndex = TextEditor::PaletteIndex::CharLiteral; - else if (TokenizeCStyleString(inBegin, inEnd, outBegin, outEnd)) + } else if (TokenizeCStyleString(inBegin, inEnd, outBegin, outEnd)) { paletteIndex = TextEditor::PaletteIndex::String; + } return paletteIndex != TextEditor::PaletteIndex::Max; }; @@ -625,9 +626,9 @@ namespace hex::plugin::builtin { }); const auto &patterns = [&, this] -> const auto& { - if (patternProvider->isReadable() && *m_executionDone) + if (patternProvider->isReadable() && *m_executionDone) { return runtime.getPatterns(id); - else { + } else { static const std::vector> empty; return empty; } @@ -1150,9 +1151,9 @@ namespace hex::plugin::builtin { if (newProvider != nullptr) { m_consoleEditor.SetTextLines(m_console.get(newProvider)); m_textEditor.SetText(wolv::util::trim(m_sourceCode.get(newProvider))); - } - else + } else { m_textEditor.SetText(""); + } } else { m_hasUnevaluatedChanges = true; } @@ -1252,16 +1253,18 @@ namespace hex::plugin::builtin { [&, this] { if (ImGui::BeginMenu("hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin"_lang)) { if (ImGui::BeginMenu("hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin.single"_lang)) { - for (const auto &[type, size] : Types) + for (const auto &[type, size] : Types) { if (ImGui::MenuItem(type)) appendVariable(type); + } ImGui::EndMenu(); } if (ImGui::BeginMenu("hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin.array"_lang)) { - for (const auto &[type, size] : Types) + for (const auto &[type, size] : Types) { if (ImGui::MenuItem(type)) appendArray(type, size); + } ImGui::EndMenu(); } @@ -1366,7 +1369,7 @@ namespace hex::plugin::builtin { ProjectFile::registerPerProviderHandler({ .basePath = "pattern_source_code.hexpat", .required = false, - .load = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) { + .load = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) { std::string sourceCode = tar.readString(basePath); if (!m_syncPatternSourceCode) @@ -1377,7 +1380,7 @@ namespace hex::plugin::builtin { return true; }, - .store = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) { + .store = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) { std::string sourceCode; if (provider == ImHexApi::Provider::get()) diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index 8e6d07dca..d9cec6f94 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -359,8 +359,9 @@ namespace hex::plugin::builtin { } category.downloadCallback(); - } else + } else { log::error("Download failed! HTTP Code {}", response.getStatusCode()); + } m_download = {}; diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index baee1239a..afd6f014d 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -564,7 +564,7 @@ namespace hex::plugin::builtin { crashFileData.value("logFile", ""), // Restore callback - [=] { + [crashFileData, backupFilePath, hasProject, hasBackupFile] { if (hasBackupFile) { ProjectFile::load(backupFilePath); if (hasProject) { @@ -595,8 +595,8 @@ namespace hex::plugin::builtin { auto tipsCategories = nlohmann::json::parse(tipsData.string()); auto now = std::chrono::system_clock::now(); - auto days_since_epoch = std::chrono::duration_cast(now.time_since_epoch()); - std::mt19937 random(days_since_epoch.count()); + auto daysSinceEpoch = std::chrono::duration_cast(now.time_since_epoch()); + std::mt19937 random(daysSinceEpoch.count()); auto chosenCategory = tipsCategories[random()%tipsCategories.size()].at("tips"); auto chosenTip = chosenCategory[random()%chosenCategory.size()]; diff --git a/plugins/hashes/source/content/views/view_hashes.cpp b/plugins/hashes/source/content/views/view_hashes.cpp index aa04e6880..37c045ef1 100644 --- a/plugins/hashes/source/content/views/view_hashes.cpp +++ b/plugins/hashes/source/content/views/view_hashes.cpp @@ -108,7 +108,7 @@ namespace hex::plugin::hashes { ProjectFile::registerPerProviderHandler({ .basePath = "hashes.json", .required = false, - .load = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) -> bool { + .load = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool { auto fileContent = tar.readString(basePath); if (fileContent.empty()) return true; @@ -118,7 +118,7 @@ namespace hex::plugin::hashes { return this->importHashes(provider, data); }, - .store = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) -> bool { + .store = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool { nlohmann::json data; bool result = this->exportHashes(provider, data); diff --git a/plugins/ui/include/ui/pattern_drawer.hpp b/plugins/ui/include/ui/pattern_drawer.hpp index 2f7465e2c..5447b85e8 100644 --- a/plugins/ui/include/ui/pattern_drawer.hpp +++ b/plugins/ui/include/ui/pattern_drawer.hpp @@ -22,7 +22,7 @@ namespace hex::ui { virtual ~PatternDrawer() = default; - void draw(const std::vector> &patterns, pl::PatternLanguage *runtime = nullptr, float height = 0.0F); + void draw(const std::vector> &patterns, const pl::PatternLanguage *runtime = nullptr, float height = 0.0F); enum class TreeStyle { Default = 0, diff --git a/plugins/ui/source/ui/hex_editor.cpp b/plugins/ui/source/ui/hex_editor.cpp index 38041d01a..c76ad7687 100644 --- a/plugins/ui/source/ui/hex_editor.cpp +++ b/plugins/ui/source/ui/hex_editor.cpp @@ -24,9 +24,9 @@ namespace hex::ui { ImGui::Text("%c", c); else ImGui::TextDisabled("."); - } - else + } else { ImGui::TextDisabled("."); + } } bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override { @@ -62,9 +62,9 @@ namespace hex::ui { ImGui::PopID(); return userData.editingDone || ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_Escape); - } - else + } else { return false; + } } }; @@ -317,8 +317,8 @@ namespace hex::ui { const auto innerRect = window->InnerRect; const auto borderSize = window->WindowBorderSize; const auto scrollbarWidth = ImGui::GetStyle().ScrollbarSize; - const ImRect bb = ImRect(ImMax(outerRect.Min.x, outerRect.Max.x - borderSize - scrollbarWidth), innerRect.Min.y, outerRect.Max.x, innerRect.Max.y); - const ImDrawFlags roundingCorners = ImDrawFlags_RoundCornersTopRight | ImDrawFlags_RoundCornersBottomRight; + const auto bb = ImRect(ImMax(outerRect.Min.x, outerRect.Max.x - borderSize - scrollbarWidth), innerRect.Min.y, outerRect.Max.x, innerRect.Max.y); + const auto roundingCorners = ImDrawFlags_RoundCornersTopRight | ImDrawFlags_RoundCornersBottomRight; if (numRows > 0) { ImGui::ScrollbarEx( @@ -363,9 +363,9 @@ namespace hex::ui { if (m_showAscii) { ImGui::TableSetupColumn("hex.ui.common.encoding.ascii"_lang, ImGuiTableColumnFlags_WidthFixed, (CharacterSize.x + m_characterCellPadding * 1_scaled) * m_bytesPerRow); - } - else + } else { ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 0); + } ImGui::TableSetupColumn(""); // Custom encoding column @@ -773,9 +773,9 @@ namespace hex::ui { ? hex::toByteString(selection.getSize()) : hex::format("{}", selection.getSize()) ); - } - else + } else { value = std::string("hex.ui.hex_editor.selection.none"_lang); + } ImGuiExt::TextFormatted("{}:", "hex.ui.hex_editor.selection"_lang); ImGui::SameLine(); diff --git a/plugins/ui/source/ui/pattern_drawer.cpp b/plugins/ui/source/ui/pattern_drawer.cpp index bb0034a29..b5bf975d3 100644 --- a/plugins/ui/source/ui/pattern_drawer.cpp +++ b/plugins/ui/source/ui/pattern_drawer.cpp @@ -54,7 +54,7 @@ namespace hex::ui { template auto highlightWhenSelected(u64 address, u64 size, const T &callback) { - constexpr bool HasReturn = !requires(T t) { { t() } -> std::same_as; }; + constexpr static bool HasReturn = !requires(T t) { { t() } -> std::same_as; }; auto selected = isPatternSelected(address, size); @@ -103,7 +103,7 @@ namespace hex::ui { } void drawOffsetColumn(const pl::ptrn::Pattern& pattern) { - auto *bitfieldMember = dynamic_cast(&pattern); + auto *bitfieldMember = dynamic_cast(&pattern); if (bitfieldMember != nullptr && bitfieldMember->getParentBitfield() != nullptr) { drawOffsetColumnForBitfieldMember(*bitfieldMember); return; @@ -134,7 +134,7 @@ namespace hex::ui { } void drawSizeColumn(const pl::ptrn::Pattern& pattern) { - if (auto *bitfieldMember = dynamic_cast(&pattern); bitfieldMember != nullptr && bitfieldMember->getParentBitfield() != nullptr) + if (auto *bitfieldMember = dynamic_cast(&pattern); bitfieldMember != nullptr && bitfieldMember->getParentBitfield() != nullptr) drawSizeColumnForBitfieldMember(*bitfieldMember); else ImGuiExt::TextFormatted("0x{0:04X}", pattern.getSize()); @@ -179,9 +179,9 @@ namespace hex::ui { return std::nullopt; } break; - } else if (c == '.') + } else if (c == '.') { result.path.emplace_back(); - else if (c == '[') { + } else if (c == '[') { result.path.emplace_back(); result.path.back() += c; } else if (c == ' ') { @@ -849,11 +849,11 @@ namespace hex::ui { if (matchesFilter(m_filter.path, m_currPatternPath, false)) { if (m_filter.value.has_value()) { auto patternValue = pattern.getValue(); - if (patternValue == m_filter.value) + if (patternValue == m_filter.value) { pattern.accept(*this); - else if (!matchesFilter(m_filter.path, m_currPatternPath, true)) + } else if (!matchesFilter(m_filter.path, m_currPatternPath, true)) { pattern.accept(*this); - else if (patternValue.isPattern() && m_filter.value->isString()) { + } else if (patternValue.isPattern() && m_filter.value->isString()) { if (patternValue.toString(true) == m_filter.value->toString(false)) pattern.accept(*this); } @@ -1060,10 +1060,11 @@ namespace hex::ui { return this->sortPatterns(sortSpecs, left, right); }); - for (auto &pattern : sortedPatterns) + for (auto &pattern : sortedPatterns) { pattern->sort([this, &sortSpecs](const pl::ptrn::Pattern *left, const pl::ptrn::Pattern *right){ return this->sortPatterns(sortSpecs, left, right); }); + } sortSpecs->SpecsDirty = false; @@ -1082,7 +1083,7 @@ namespace hex::ui { } } - void PatternDrawer::draw(const std::vector> &patterns, pl::PatternLanguage *runtime, float height) { + void PatternDrawer::draw(const std::vector> &patterns, const pl::PatternLanguage *runtime, float height) { std::scoped_lock lock(s_resetDrawMutex); const auto treeStyleButton = [this](auto icon, TreeStyle style, const char *tooltip) { @@ -1141,10 +1142,10 @@ namespace hex::ui { if (ImGui::BeginPopup("ExportPatterns")) { for (const auto &formatter : m_formatters) { const auto name = [&]{ - auto name = formatter->getName(); - std::transform(name.begin(), name.end(), name.begin(), [](char c){ return char(std::toupper(c)); }); + auto formatterName = formatter->getName(); + std::transform(formatterName.begin(), formatterName.end(), formatterName.begin(), [](char c){ return char(std::toupper(c)); }); - return name; + return formatterName; }(); const auto &extension = formatter->getFileExtension(); @@ -1170,17 +1171,17 @@ namespace hex::ui { for (auto &pattern : patterns) { std::vector patternPath; - traversePatternTree(*pattern, patternPath, [&, this](const pl::ptrn::Pattern &pattern) { - if (pattern.hasAttribute("hex::favorite")) - m_favorites.insert({ patternPath, pattern.clone() }); + traversePatternTree(*pattern, patternPath, [&, this](const pl::ptrn::Pattern &currPattern) { + if (currPattern.hasAttribute("hex::favorite")) + m_favorites.insert({ patternPath, currPattern.clone() }); - if (const auto &args = pattern.getAttributeArguments("hex::group"); !args.empty()) { + if (const auto &args = currPattern.getAttributeArguments("hex::group"); !args.empty()) { auto groupName = args.front().toString(); if (!m_groups.contains(groupName)) m_groups.insert({groupName, std::vector>()}); - m_groups[groupName].push_back(pattern.clone()); + m_groups[groupName].push_back(currPattern.clone()); } }); @@ -1189,14 +1190,14 @@ namespace hex::ui { task.update(); patternPath.clear(); - traversePatternTree(*pattern, patternPath, [&, this](const pl::ptrn::Pattern &pattern) { + traversePatternTree(*pattern, patternPath, [&, this](const pl::ptrn::Pattern &currPattern) { for (auto &[path, favoritePattern] : m_favorites) { if (updatedFavorites == m_favorites.size()) task.interrupt(); task.update(); if (this->matchesFilter(patternPath, path, true)) { - favoritePattern = pattern.clone(); + favoritePattern = currPattern.clone(); updatedFavorites += 1; break; @@ -1309,9 +1310,10 @@ namespace hex::ui { for (auto &[path, pattern] : m_favorites) pattern = nullptr; - for (auto &[groupName, patterns]: m_groups) + for (auto &[groupName, patterns]: m_groups) { for (auto &pattern: patterns) pattern = nullptr; + } m_groups.clear(); diff --git a/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp b/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp index e6ebdabfe..b85ff371c 100644 --- a/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp @@ -579,18 +579,18 @@ namespace hex::plugin::visualizers { void draw3DVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span arguments) { static gl::LightSourceVectors sourceVectors(20); - static gl::VertexArray sourceVertexArray = gl::VertexArray(); + static gl::VertexArray sourceVertexArray = {}; static gl::LightSourceBuffers sourceBuffers(sourceVertexArray, sourceVectors); - static gl::VertexArray gridVertexArray = gl::VertexArray(); + static gl::VertexArray gridVertexArray = {}; static gl::GridVectors gridVectors(9); static gl::GridBuffers gridBuffers(gridVertexArray, gridVectors); - static gl::VertexArray axesVertexArray = gl::VertexArray(); + static gl::VertexArray axesVertexArray = {}; static gl::AxesVectors axesVectors; static gl::AxesBuffers axesBuffers(axesVertexArray, axesVectors); - static gl::VertexArray vertexArray = gl::VertexArray(); + static gl::VertexArray vertexArray = {}; static Buffers buffers; static LineBuffers lineBuffers; diff --git a/plugins/visualizers/source/content/pl_visualizers/image.cpp b/plugins/visualizers/source/content/pl_visualizers/image.cpp index 2376406a4..57e91bf24 100644 --- a/plugins/visualizers/source/content/pl_visualizers/image.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/image.cpp @@ -2,13 +2,10 @@ #include -#include #include #include -#include - namespace hex::plugin::visualizers { void drawImageVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span arguments) { diff --git a/plugins/yara_rules/source/content/views/view_yara.cpp b/plugins/yara_rules/source/content/views/view_yara.cpp index 36f139bfe..3307e895c 100644 --- a/plugins/yara_rules/source/content/views/view_yara.cpp +++ b/plugins/yara_rules/source/content/views/view_yara.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -16,7 +15,6 @@ #pragma GCC diagnostic pop #include -#include #include #include @@ -44,7 +42,7 @@ namespace hex::plugin::yara { ProjectFile::registerPerProviderHandler({ .basePath = "yara.json", .required = false, - .load = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) -> bool { + .load = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool { auto fileContent = tar.readString(basePath); if (fileContent.empty()) return true; @@ -75,7 +73,7 @@ namespace hex::plugin::yara { return true; }, - .store = [this](prv::Provider *provider, const std::fs::path &basePath, Tar &tar) -> bool { + .store = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool { nlohmann::json data; data["rules"] = nlohmann::json::array(); @@ -233,13 +231,14 @@ namespace hex::plugin::yara { ImGuiListClipper clipper; clipper.Begin(m_consoleMessages.size()); - while (clipper.Step()) + while (clipper.Step()) { for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { const auto &message = m_consoleMessages[i]; if (ImGui::Selectable(message.c_str())) ImGui::SetClipboardText(message.c_str()); } + } } ImGui::EndChild(); } diff --git a/tests/algorithms/source/crypto.cpp b/tests/algorithms/source/crypto.cpp index 4c3e7b096..55da31412 100644 --- a/tests/algorithms/source/crypto.cpp +++ b/tests/algorithms/source/crypto.cpp @@ -35,12 +35,12 @@ TEST_SEQUENCE("EncodeDecode16") { std::random_device rd; std::mt19937 gen(rd()); - std::uniform_int_distribution<> dataLen(0, 1024); + std::uniform_int_distribution dataLen(0, 1024); std::uniform_int_distribution data; for (int i = 0; i < 1000; i++) { std::vector original(dataLen(gen)); - std::generate(std::begin(original), std::end(original), [&]() { return data(gen); }); + std::generate(std::begin(original), std::end(original), [&] { return data(gen); }); auto encoded = hex::crypt::encode16(original); auto decoded = hex::crypt::decode16(encoded); @@ -85,12 +85,12 @@ TEST_SEQUENCE("EncodeDecode64") { std::random_device rd; std::mt19937 gen(rd()); - std::uniform_int_distribution<> dataLen(0, 1024); + std::uniform_int_distribution dataLen(0, 1024); std::uniform_int_distribution data; for (int i = 0; i < 1000; i++) { std::vector original(dataLen(gen)); - std::generate(std::begin(original), std::end(original), [&]() { return data(gen); }); + std::generate(std::begin(original), std::end(original), [&] { return data(gen); }); auto encoded = vectorToString(hex::crypt::encode64(original)); auto decoded = hex::crypt::decode64(stringToVector(encoded)); @@ -147,7 +147,7 @@ TEST_SEQUENCE("EncodeDecodeLEB128") { for (int i = 0; i < 1000; i++) { std::vector original(sizeof(u128)); - std::generate(std::begin(original), std::end(original), [&]() { return data(gen); }); + std::generate(std::begin(original), std::end(original), [&] { return data(gen); }); u128 u = *reinterpret_cast(original.data()); i128 s = *reinterpret_cast(original.data()); auto encodedS = hex::crypt::encodeSleb128(s); @@ -192,14 +192,14 @@ int checkCrcAgainstRandomData(Func func, int width) { std::random_device rd; std::mt19937 gen(rd()); - std::uniform_int_distribution<> distribLen(0, 1024); + std::uniform_int_distribution distribLen(0, 1024); std::uniform_int_distribution distribPoly(0, (0b10ull << (width - 1)) - 1); std::uniform_int_distribution distribData; for (int i = 0; i < 500; i++) { CrcCheck c { "", width, distribPoly(gen), distribPoly(gen), 0, false, false, 0, {} }; c.data.resize(distribLen(gen)); - std::generate(std::begin(c.data), std::end(c.data), [&]() { return distribData(gen); }); + std::generate(std::begin(c.data), std::end(c.data), [&] { return distribData(gen); }); hex::test::TestProvider testprovider(&c.data); hex::prv::Provider *provider = &testprovider; diff --git a/tests/helpers/source/file.cpp b/tests/helpers/source/file.cpp index 9f63eeb30..cee3189c2 100644 --- a/tests/helpers/source/file.cpp +++ b/tests/helpers/source/file.cpp @@ -1,7 +1,6 @@ #include #include -#include using namespace std::literals::string_literals; diff --git a/tests/helpers/source/net.cpp b/tests/helpers/source/net.cpp index 77acdea09..e439e0b36 100644 --- a/tests/helpers/source/net.cpp +++ b/tests/helpers/source/net.cpp @@ -3,7 +3,6 @@ #include #include #include -#include using namespace std::literals::string_literals;