impr: Various small fixes and improvements
This commit is contained in:
parent
e603c75bd3
commit
e6ab2c3b7e
@ -73,6 +73,7 @@ macro(detectOS)
|
||||
set(CMAKE_INSTALL_LIBDIR ".")
|
||||
set(PLUGINS_INSTALL_LOCATION "plugins")
|
||||
add_compile_definitions(WIN32_LEAN_AND_MEAN)
|
||||
add_compile_definitions(NOMINMAX)
|
||||
add_compile_definitions(UNICODE)
|
||||
elseif (APPLE)
|
||||
add_compile_definitions(OS_MACOS)
|
||||
@ -439,6 +440,8 @@ function(verifyCompiler)
|
||||
message(FATAL_ERROR "ImHex requires GCC 12.0.0 or newer. Please use the latest GCC version.")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "17.0.0")
|
||||
message(FATAL_ERROR "ImHex requires Clang 17.0.0 or newer. Please use the latest Clang version.")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
|
||||
elseif (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
|
||||
message(FATAL_ERROR "ImHex can only be compiled with GCC or Clang. ${CMAKE_CXX_COMPILER_ID} is not supported.")
|
||||
endif()
|
||||
@ -727,7 +730,7 @@ macro(addBundledLibraries)
|
||||
set(LIBPL_BUILD_CLI_AS_EXECUTABLE OFF CACHE BOOL "" FORCE)
|
||||
set(LIBPL_ENABLE_PRECOMPILED_HEADERS ${IMHEX_ENABLE_PRECOMPILED_HEADERS} CACHE BOOL "" FORCE)
|
||||
|
||||
if (WIN32)
|
||||
if (WIN32 AND NOT MSVC)
|
||||
set(LIBPL_SHARED_LIBRARY ON CACHE BOOL "" FORCE)
|
||||
else()
|
||||
set(LIBPL_SHARED_LIBRARY OFF CACHE BOOL "" FORCE)
|
||||
|
@ -40,7 +40,12 @@ IF(MBEDTLS_FOUND)
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
|
||||
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
|
||||
|
||||
if (MSVC)
|
||||
SET(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY_FILE}.lib ${MBEDX509_LIBRARY_FILE}.lib ${MBEDCRYPTO_LIBRARY_FILE}.lib)
|
||||
else()
|
||||
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
|
||||
endif()
|
||||
|
||||
IF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found mbedTLS:")
|
||||
|
@ -36,8 +36,8 @@ macro(add_imhex_plugin)
|
||||
|
||||
# Add include directories and link libraries
|
||||
target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
|
||||
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_LIBRARIES})
|
||||
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} imgui_all_includes libwolv)
|
||||
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC libimhex)
|
||||
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE ${FMT_LIBRARIES} imgui_all_includes libwolv ${IMHEX_PLUGIN_LIBRARIES})
|
||||
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl)
|
||||
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl-gen)
|
||||
|
||||
@ -62,7 +62,11 @@ macro(add_imhex_plugin)
|
||||
)
|
||||
|
||||
# Set rpath of plugin libraries to the plugins folder
|
||||
if (APPLE)
|
||||
if (WIN32)
|
||||
if (IMHEX_PLUGIN_LIBRARY_PLUGIN)
|
||||
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||
endif()
|
||||
elseif (APPLE)
|
||||
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES BUILD_RPATH "@executable_path/../Frameworks;@executable_path/plugins")
|
||||
endif()
|
||||
|
||||
|
@ -134,16 +134,22 @@ endif()
|
||||
if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD)
|
||||
if (WIN32)
|
||||
set_target_properties(libimhex PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||
target_link_options(libimhex PRIVATE -Wl,--export-all-symbols)
|
||||
if (NOT MSVC)
|
||||
target_link_options(libimhex PRIVATE -Wl,--export-all-symbols)
|
||||
endif()
|
||||
target_link_libraries(libimhex PRIVATE Netapi32.lib)
|
||||
elseif (APPLE)
|
||||
find_library(FOUNDATION NAMES Foundation)
|
||||
target_link_libraries(libimhex PUBLIC ${FOUNDATION})
|
||||
endif ()
|
||||
|
||||
target_link_libraries(libimhex PRIVATE microtar libwolv ${NFD_LIBRARIES} magic dl)
|
||||
target_link_libraries(libimhex PRIVATE microtar libwolv ${NFD_LIBRARIES} magic)
|
||||
target_link_libraries(libimhex PUBLIC libpl ${IMGUI_LIBRARIES} ${JTHREAD_LIBRARIES})
|
||||
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(libimhex PRIVATE dl)
|
||||
endif()
|
||||
|
||||
precompileHeaders(libimhex "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
endif()
|
||||
|
||||
|
@ -362,7 +362,7 @@ namespace hex {
|
||||
* @brief Returns all registered achievements
|
||||
* @return All achievements
|
||||
*/
|
||||
static const std::unordered_map<std::string, std::unordered_map<std::string, std::unique_ptr<Achievement>>>& getAchievements();
|
||||
static const std::unordered_map<UnlocalizedString, std::unordered_map<UnlocalizedString, std::unique_ptr<Achievement>>>& getAchievements();
|
||||
|
||||
/**
|
||||
* @brief Returns all achievement start nodes
|
||||
@ -370,14 +370,14 @@ namespace hex {
|
||||
* @param rebuild Whether to rebuild the list of start nodes
|
||||
* @return All achievement start nodes
|
||||
*/
|
||||
static const std::unordered_map<std::string, std::vector<AchievementNode*>>& getAchievementStartNodes(bool rebuild = true);
|
||||
static const std::unordered_map<UnlocalizedString, std::vector<AchievementNode*>>& getAchievementStartNodes(bool rebuild = true);
|
||||
|
||||
/**
|
||||
* @brief Returns all achievement nodes
|
||||
* @param rebuild Whether to rebuild the list of nodes
|
||||
* @return All achievement nodes
|
||||
*/
|
||||
static const std::unordered_map<std::string, std::list<AchievementNode>>& getAchievementNodes(bool rebuild = true);
|
||||
static const std::unordered_map<UnlocalizedString, std::list<AchievementNode>>& getAchievementNodes(bool rebuild = true);
|
||||
|
||||
/**
|
||||
* @brief Loads the progress of all achievements from the achievements save file
|
||||
|
@ -101,10 +101,9 @@ namespace hex {
|
||||
public:
|
||||
UnlocalizedString() = default;
|
||||
|
||||
template<typename T>
|
||||
UnlocalizedString(T &&arg) : m_unlocalizedString(std::forward<T>(arg)) {
|
||||
static_assert(!std::same_as<std::remove_cvref_t<T>, Lang>, "Expected a unlocalized name, got a localized one!");
|
||||
}
|
||||
UnlocalizedString(const std::string &string) : m_unlocalizedString(string) { }
|
||||
UnlocalizedString(const char *string) : m_unlocalizedString(string) { }
|
||||
UnlocalizedString(const Lang& arg) = delete;
|
||||
|
||||
[[nodiscard]] operator std::string() const {
|
||||
return m_unlocalizedString;
|
||||
@ -149,3 +148,10 @@ namespace hex {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct std::hash<hex::UnlocalizedString> {
|
||||
std::size_t operator()(const hex::UnlocalizedString &string) const noexcept {
|
||||
return std::hash<std::string>{}(string.get());
|
||||
}
|
||||
};
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <hex/helpers/fs.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
namespace hex::paths {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <map>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <numbers>
|
||||
|
||||
#include <opengl_support.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
@ -219,11 +220,11 @@ namespace hex::gl {
|
||||
this->mat[row*Columns + col] = value;
|
||||
}
|
||||
|
||||
T &operator()( const int &row,const int &col) {
|
||||
T &operator()( const unsigned&row, const unsigned&col) {
|
||||
return this->mat[row*Columns + col];
|
||||
}
|
||||
|
||||
const T &operator()(const unsigned& row,const unsigned& col ) const {
|
||||
const T &operator()(const unsigned& row, const unsigned& col) const {
|
||||
return this->mat[row*Columns + col];
|
||||
}
|
||||
|
||||
@ -401,7 +402,7 @@ namespace hex::gl {
|
||||
T Sx, Cx, Sy, Cy, Sz, Cz;
|
||||
Vector<T,3> angles = ypr;
|
||||
if(!radians)
|
||||
angles *= M_PI/180;
|
||||
angles *= std::numbers::pi / 180;
|
||||
|
||||
Sx = -sin(angles[0]); Cx = cos(angles[0]);
|
||||
Sy = -sin(angles[1]); Cy = cos(angles[1]);
|
||||
@ -524,7 +525,7 @@ namespace hex::gl {
|
||||
Vector<T,3> rotationVector3 = {{rotationVector[0], rotationVector[1], rotationVector[2]}};
|
||||
T theta = rotationVector3.magnitude();
|
||||
if (!radians)
|
||||
theta *= M_PI / 180;
|
||||
theta *= std::numbers::pi / 180;
|
||||
Vector<T,3> axis = rotationVector3;
|
||||
if (theta != 0)
|
||||
axis = axis.normalize();
|
||||
|
@ -37,7 +37,7 @@ namespace hex {
|
||||
template<typename T>
|
||||
[[nodiscard]] std::vector<std::vector<T>> sampleChannels(const std::vector<T> &data, size_t count, size_t channels) {
|
||||
if (channels == 0) return {};
|
||||
size_t signalLength = std::max(1.0, double(data.size()) / channels);
|
||||
size_t signalLength = std::max<double>(1.0, double(data.size()) / channels);
|
||||
|
||||
size_t stride = std::max(1.0, double(signalLength) / count);
|
||||
|
||||
|
@ -12,13 +12,13 @@
|
||||
|
||||
namespace hex {
|
||||
|
||||
static AutoReset<std::unordered_map<std::string, std::unordered_map<std::string, std::unique_ptr<Achievement>>>> s_achievements;
|
||||
const std::unordered_map<std::string, std::unordered_map<std::string, std::unique_ptr<Achievement>>> &AchievementManager::getAchievements() {
|
||||
static AutoReset<std::unordered_map<UnlocalizedString, std::unordered_map<UnlocalizedString, std::unique_ptr<Achievement>>>> s_achievements;
|
||||
const std::unordered_map<UnlocalizedString, std::unordered_map<UnlocalizedString, std::unique_ptr<Achievement>>> &AchievementManager::getAchievements() {
|
||||
return *s_achievements;
|
||||
}
|
||||
|
||||
static AutoReset<std::unordered_map<std::string, std::list<AchievementManager::AchievementNode>>> s_nodeCategoryStorage;
|
||||
std::unordered_map<std::string, std::list<AchievementManager::AchievementNode>>& getAchievementNodesMutable(bool rebuild) {
|
||||
static AutoReset<std::unordered_map<UnlocalizedString, std::list<AchievementManager::AchievementNode>>> s_nodeCategoryStorage;
|
||||
std::unordered_map<UnlocalizedString, std::list<AchievementManager::AchievementNode>>& getAchievementNodesMutable(bool rebuild) {
|
||||
if (!s_nodeCategoryStorage->empty() || !rebuild)
|
||||
return s_nodeCategoryStorage;
|
||||
|
||||
@ -36,12 +36,12 @@ namespace hex {
|
||||
return s_nodeCategoryStorage;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, std::list<AchievementManager::AchievementNode>>& AchievementManager::getAchievementNodes(bool rebuild) {
|
||||
const std::unordered_map<UnlocalizedString, std::list<AchievementManager::AchievementNode>>& AchievementManager::getAchievementNodes(bool rebuild) {
|
||||
return getAchievementNodesMutable(rebuild);
|
||||
}
|
||||
|
||||
static AutoReset<std::unordered_map<std::string, std::vector<AchievementManager::AchievementNode*>>> s_startNodes;
|
||||
const std::unordered_map<std::string, std::vector<AchievementManager::AchievementNode*>>& AchievementManager::getAchievementStartNodes(bool rebuild) {
|
||||
static AutoReset<std::unordered_map<UnlocalizedString, std::vector<AchievementManager::AchievementNode*>>> s_startNodes;
|
||||
const std::unordered_map<UnlocalizedString, std::vector<AchievementManager::AchievementNode*>>& AchievementManager::getAchievementStartNodes(bool rebuild) {
|
||||
|
||||
if (!s_startNodes->empty() || !rebuild)
|
||||
return s_startNodes;
|
||||
@ -187,10 +187,10 @@ namespace hex {
|
||||
const auto &category = newAchievement->getUnlocalizedCategory();
|
||||
const auto &name = newAchievement->getUnlocalizedName();
|
||||
|
||||
auto [categoryIter, categoryInserted] = s_achievements->insert({ category, std::unordered_map<std::string, std::unique_ptr<Achievement>>{} });
|
||||
auto [categoryIter, categoryInserted] = s_achievements->insert({ category, std::unordered_map<UnlocalizedString, std::unique_ptr<Achievement>>{} });
|
||||
auto &[categoryKey, achievements] = *categoryIter;
|
||||
|
||||
auto [achievementIter, achievementInserted] = achievements.insert({ name, std::move(newAchievement) });
|
||||
auto [achievementIter, achievementInserted] = achievements.emplace(name, std::move(newAchievement));
|
||||
auto &[achievementKey, achievement] = *achievementIter;
|
||||
|
||||
achievementAdded();
|
||||
@ -239,7 +239,7 @@ namespace hex {
|
||||
|
||||
achievement->setProgress(progress);
|
||||
} catch (const std::exception &e) {
|
||||
log::warn("Failed to load achievement progress for '{}::{}': {}", categoryName, achievementName, e.what());
|
||||
log::warn("Failed to load achievement progress for '{}::{}': {}", categoryName.get(), achievementName.get(), e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace hex {
|
||||
namespace impl {
|
||||
|
||||
struct OnChange {
|
||||
u32 id;
|
||||
u64 id;
|
||||
OnChangeCallback callback;
|
||||
};
|
||||
|
||||
@ -714,15 +714,15 @@ namespace hex {
|
||||
|
||||
namespace impl {
|
||||
|
||||
static AutoReset<std::map<std::string, std::unique_ptr<View>>> s_views;
|
||||
const std::map<std::string, std::unique_ptr<View>>& getEntries() {
|
||||
static AutoReset<std::map<UnlocalizedString, std::unique_ptr<View>>> s_views;
|
||||
const std::map<UnlocalizedString, std::unique_ptr<View>>& getEntries() {
|
||||
return *s_views;
|
||||
}
|
||||
|
||||
void add(std::unique_ptr<View> &&view) {
|
||||
log::debug("Registered new view: {}", view->getUnlocalizedName().get());
|
||||
|
||||
s_views->insert({ view->getUnlocalizedName(), std::move(view) });
|
||||
s_views->emplace(view->getUnlocalizedName(), std::move(view));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1126,7 +1126,9 @@ namespace hex {
|
||||
|
||||
namespace ContentRegistry::HexEditor {
|
||||
|
||||
const int DataVisualizer::TextInputFlags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoHorizontalScroll | ImGuiInputTextFlags_AlwaysOverwrite;
|
||||
int DataVisualizer::DefaultTextInputFlags() {
|
||||
return ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoHorizontalScroll | ImGuiInputTextFlags_AlwaysOverwrite;
|
||||
}
|
||||
|
||||
bool DataVisualizer::drawDefaultScalarEditingTextBox(u64 address, const char *format, ImGuiDataType dataType, u8 *data, ImGuiInputTextFlags flags) const {
|
||||
struct UserData {
|
||||
@ -1144,7 +1146,7 @@ namespace hex {
|
||||
};
|
||||
|
||||
ImGui::PushID(reinterpret_cast<void*>(address));
|
||||
ImGuiExt::InputScalarCallback("##editing_input", dataType, data, format, flags | TextInputFlags | ImGuiInputTextFlags_CallbackEdit, [](ImGuiInputTextCallbackData *data) -> int {
|
||||
ImGuiExt::InputScalarCallback("##editing_input", dataType, data, format, flags | DefaultTextInputFlags() | ImGuiInputTextFlags_CallbackEdit, [](ImGuiInputTextCallbackData *data) -> int {
|
||||
auto &userData = *static_cast<UserData*>(data->UserData);
|
||||
|
||||
if (data->CursorPos >= userData.maxChars)
|
||||
@ -1175,7 +1177,7 @@ namespace hex {
|
||||
};
|
||||
|
||||
ImGui::PushID(reinterpret_cast<void*>(address));
|
||||
ImGui::InputText("##editing_input", data.data(), data.size() + 1, flags | TextInputFlags | ImGuiInputTextFlags_CallbackEdit, [](ImGuiInputTextCallbackData *data) -> int {
|
||||
ImGui::InputText("##editing_input", data.data(), data.size() + 1, flags | DefaultTextInputFlags() | ImGuiInputTextFlags_CallbackEdit, [](ImGuiInputTextCallbackData *data) -> int {
|
||||
auto &userData = *static_cast<UserData*>(data->UserData);
|
||||
|
||||
userData.data->resize(data->BufSize);
|
||||
|
@ -15,7 +15,12 @@
|
||||
#include <string>
|
||||
|
||||
#include <magic.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
#define MAGIC_PATH_SEPARATOR ";"
|
||||
|
@ -332,7 +332,7 @@ namespace hex::prv {
|
||||
else if (category == "description")
|
||||
return magic::getDescription(this);
|
||||
else if (category == "provider_type")
|
||||
return this->getTypeName();
|
||||
return this->getTypeName().get();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ public:
|
||||
void SetLanguageDefinition(const LanguageDefinition& aLanguageDef);
|
||||
const LanguageDefinition& GetLanguageDefinition() const { return mLanguageDefinition; }
|
||||
|
||||
static const Palette& GetPalette() { return sPaletteBase; }
|
||||
static const Palette& GetPalette();
|
||||
static void SetPalette(const Palette& aValue);
|
||||
|
||||
void SetErrorMarkers(const ErrorMarkers& aMarkers) { mErrorMarkers = aMarkers; }
|
||||
@ -613,7 +613,6 @@ private:
|
||||
bool mIgnoreImGuiChild = false;
|
||||
bool mShowWhitespaces = true;
|
||||
|
||||
static Palette sPaletteBase;
|
||||
Palette mPalette = {};
|
||||
LanguageDefinition mLanguageDefinition = {};
|
||||
RegexList mRegexList;
|
||||
|
@ -25,7 +25,7 @@ bool equals(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Bi
|
||||
const int TextEditor::sCursorBlinkInterval = 1200;
|
||||
const int TextEditor::sCursorBlinkOnTime = 800;
|
||||
|
||||
TextEditor::Palette TextEditor::sPaletteBase = TextEditor::GetDarkPalette();
|
||||
TextEditor::Palette sPaletteBase = TextEditor::GetDarkPalette();
|
||||
|
||||
TextEditor::FindReplaceHandler::FindReplaceHandler() : mWholeWord(false),mFindRegEx(false),mMatchCase(false) {}
|
||||
|
||||
@ -79,6 +79,8 @@ void TextEditor::SetLanguageDefinition(const LanguageDefinition &aLanguageDef) {
|
||||
Colorize();
|
||||
}
|
||||
|
||||
const TextEditor::Palette& TextEditor::GetPalette() { return sPaletteBase; }
|
||||
|
||||
void TextEditor::SetPalette(const Palette &aValue) {
|
||||
sPaletteBase = aValue;
|
||||
}
|
||||
|
12
lib/third_party/imgui/backend/CMakeLists.txt
vendored
12
lib/third_party/imgui/backend/CMakeLists.txt
vendored
@ -25,16 +25,18 @@ if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD)
|
||||
set(GLFW_INCLUDE_DIRS ${glfw3_INCLUDE_DIRS})
|
||||
set(GLFW_LIBRARIES ${glfw3_LIBRARIES})
|
||||
|
||||
if (NOT glfw3_FOUND OR "${GLFW_LIBRARIES}" STREQUAL "")
|
||||
if (NOT glfw3_FOUND AND "${GLFW_LIBRARIES}" STREQUAL "")
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(GLFW REQUIRED glfw3)
|
||||
|
||||
if ("${GLFW_LIBRARIES}" MATCHES ".+dll")
|
||||
set(GLFW_LIBRARIES "glfw3")
|
||||
endif ()
|
||||
else()
|
||||
set(GLFW_LIBRARIES GLFW::GLFW)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
if ("${GLFW_LIBRARIES}" MATCHES ".+dll")
|
||||
set(GLFW_LIBRARIES "glfw3")
|
||||
endif ()
|
||||
|
||||
target_include_directories(imgui_backend PUBLIC ${FREETYPE_INCLUDE_DIRS} ${OpenGL_INCLUDE_DIRS})
|
||||
target_link_directories(imgui_backend PUBLIC ${FREETYPE_LIBRARY_DIRS} ${OpenGL_LIBRARY_DIRS})
|
||||
target_link_libraries(imgui_backend PUBLIC ${GLFW_LIBRARIES} ${OPENGL_LIBRARIES})
|
||||
|
@ -1,5 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#if !defined(WINGDIAPI)
|
||||
#define WINGDIAPI extern "C"
|
||||
#define APIENTRY
|
||||
#endif
|
||||
|
||||
#if defined(OS_WEB)
|
||||
#define GLFW_INCLUDE_ES3
|
||||
#include <GLES3/gl3.h>
|
||||
|
@ -113,6 +113,11 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#if !defined(WINGDIAPI)
|
||||
#define WINGDIAPI extern "C"
|
||||
#define APIENTRY
|
||||
#endif
|
||||
|
||||
#include "imgui.h"
|
||||
#ifndef IMGUI_DISABLE
|
||||
#include "imgui_impl_opengl3.h"
|
||||
|
@ -56,7 +56,7 @@ namespace hex {
|
||||
|
||||
std::map<u64, std::vector<u8>> orderedData;
|
||||
for (u32 i = 0; i < sequenceCount; i++) {
|
||||
ssize_t offset = random() % size;
|
||||
i64 offset = random() % size;
|
||||
|
||||
std::vector<u8> sequence;
|
||||
sequence.resize(std::min<size_t>(sequenceCount, size - offset));
|
||||
@ -93,7 +93,7 @@ namespace hex {
|
||||
|
||||
std::map<u64, std::vector<u8>> orderedData;
|
||||
for (u32 i = 0; i < sequenceCount; i++) {
|
||||
ssize_t offset = random() % inputBuffer.size();
|
||||
i64 offset = random() % inputBuffer.size();
|
||||
|
||||
std::vector<u8> sequence;
|
||||
sequence.reserve(sampleSize);
|
||||
|
@ -78,7 +78,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void importIPSPatch() {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &task) {
|
||||
TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &task) {
|
||||
auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readVector();
|
||||
auto patch = Patches::fromIPSPatch(patchData);
|
||||
if (!patch.has_value()) {
|
||||
@ -102,7 +102,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void importIPS32Patch() {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &task) {
|
||||
TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &task) {
|
||||
auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readVector();
|
||||
auto patch = Patches::fromIPS32Patch(patchData);
|
||||
if (!patch.has_value()) {
|
||||
@ -126,7 +126,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void importModifiedFile() {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &task) {
|
||||
TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &task) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readVector();
|
||||
|
||||
@ -165,7 +165,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void exportBase64() {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &) {
|
||||
TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &) {
|
||||
wolv::io::File outputFile(path, wolv::io::File::Mode::Create);
|
||||
if (!outputFile.isValid()) {
|
||||
TaskManager::doLater([] {
|
||||
@ -188,7 +188,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void exportSelectionToFile() {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &task) {
|
||||
TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &task) {
|
||||
wolv::io::File outputFile(path, wolv::io::File::Mode::Create);
|
||||
if (!outputFile.isValid()) {
|
||||
TaskManager::doLater([] {
|
||||
@ -216,7 +216,7 @@ namespace hex::plugin::builtin {
|
||||
for (const auto &formatter : ContentRegistry::DataFormatter::impl::getExportMenuEntries()) {
|
||||
if (menu::menuItem(Lang(formatter.unlocalizedName), Shortcut::None, false, ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->getActualSize() > 0)) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [&formatter](const auto &path) {
|
||||
TaskManager::createTask("hex.builtin.task.exporting_data"_lang, TaskManager::NoProgress, [&formatter, path](auto&){
|
||||
TaskManager::createTask("hex.builtin.task.exporting_data", TaskManager::NoProgress, [&formatter, path](auto&){
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
auto selection = ImHexApi::HexEditor::getSelection()
|
||||
.value_or(
|
||||
@ -243,7 +243,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void exportReport() {
|
||||
TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [](auto &) {
|
||||
TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [](auto &) {
|
||||
std::string data;
|
||||
|
||||
for (const auto &provider : ImHexApi::Provider::getProviders()) {
|
||||
@ -287,7 +287,7 @@ namespace hex::plugin::builtin {
|
||||
patches->get().at(0x00454F45) = value;
|
||||
}
|
||||
|
||||
TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [patches](auto &) {
|
||||
TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [patches](auto &) {
|
||||
auto data = patches->toIPSPatch();
|
||||
|
||||
TaskManager::doLater([data] {
|
||||
@ -326,7 +326,7 @@ namespace hex::plugin::builtin {
|
||||
patches->get().at(0x45454F45) = value;
|
||||
}
|
||||
|
||||
TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [patches](auto &) {
|
||||
TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [patches](auto &) {
|
||||
auto data = patches->toIPS32Patch();
|
||||
|
||||
TaskManager::doLater([data] {
|
||||
|
@ -63,7 +63,7 @@ namespace hex::plugin::builtin {
|
||||
if (!view->shouldStoreWindowState())
|
||||
continue;
|
||||
|
||||
buffer->appendf("%s=%d\n", name.c_str(), view->getWindowOpenState());
|
||||
buffer->appendf("%s=%d\n", name.get().c_str(), view->getWindowOpenState());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -90,8 +90,9 @@ namespace hex::plugin::builtin {
|
||||
m_dragStartIterator = tools.end();
|
||||
|
||||
// Attach the newly created window to the cursor, so it gets dragged around
|
||||
GImGui->MovingWindow = ImGui::GetCurrentWindowRead();
|
||||
GImGui->ActiveId = GImGui->MovingWindow->MoveId;
|
||||
auto& g = *ImGui::GetCurrentContext();
|
||||
g.MovingWindow = ImGui::GetCurrentWindowRead();
|
||||
g.ActiveId = g.MovingWindow->MoveId;
|
||||
}
|
||||
|
||||
const auto window = ImGui::GetCurrentWindowRead();
|
||||
|
@ -8,7 +8,9 @@ if (NOT USE_SYSTEM_CAPSTONE)
|
||||
set(CAPSTONE_BUILD_TESTS OFF CACHE BOOL "Disable tests")
|
||||
set(CAPSTONE_BUILD_MACOS_THIN ON CACHE BOOL "Enable thin builds of capstone for macOS" FORCE)
|
||||
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/capstone ${CMAKE_CURRENT_BINARY_DIR}/capstone EXCLUDE_FROM_ALL)
|
||||
target_compile_options(capstone PRIVATE -Wno-unused-function)
|
||||
if (NOT MSVC)
|
||||
target_compile_options(capstone PRIVATE -Wno-unused-function)
|
||||
endif()
|
||||
set(CAPSTONE_LIBRARY "capstone")
|
||||
set(CAPSTONE_INCLUDE_DIR ${THIRD_PARTY_LIBS_FOLDER}/capstone/include)
|
||||
else()
|
||||
|
@ -47,7 +47,7 @@ namespace hex::plugin::disasm {
|
||||
if (m_regionToDisassemble.get(provider).getStartAddress() < m_imageBaseAddress)
|
||||
return;
|
||||
|
||||
m_disassemblerTask = TaskManager::createTask("hex.disassembler.view.disassembler.disassembling"_lang, m_regionToDisassemble.get(provider).getSize(), [this, provider](auto &task) {
|
||||
m_disassemblerTask = TaskManager::createTask("hex.disassembler.view.disassembler.disassembling", m_regionToDisassemble.get(provider).getSize(), [this, provider](auto &task) {
|
||||
const auto &currArchitecture = m_currArchitecture.get(provider);
|
||||
const auto region = m_regionToDisassemble.get(provider);
|
||||
auto &disassembly = m_disassembly.get(provider);
|
||||
|
@ -62,7 +62,7 @@ namespace hex::ui {
|
||||
ImGui::PushID(reinterpret_cast<void*>(address));
|
||||
ON_SCOPE_EXIT { ImGui::PopID(); };
|
||||
std::array<char, 2> buffer = { std::isprint(data[0]) != 0 ? char(data[0]) : '.', 0x00 };
|
||||
ImGui::InputText("##editing_input", buffer.data(), buffer.size(), TextInputFlags | ImGuiInputTextFlags_CallbackEdit, [](ImGuiInputTextCallbackData *data) -> int {
|
||||
ImGui::InputText("##editing_input", buffer.data(), buffer.size(), DefaultTextInputFlags() | ImGuiInputTextFlags_CallbackEdit, [](ImGuiInputTextCallbackData *data) -> int {
|
||||
auto &userData = *static_cast<UserData*>(data->UserData);
|
||||
|
||||
if (data->BufTextLen >= userData.maxChars) {
|
||||
|
@ -1397,7 +1397,7 @@ namespace hex::ui {
|
||||
m_filtersUpdated = true;
|
||||
|
||||
if (!m_favoritesUpdateTask.isRunning()) {
|
||||
m_favoritesUpdateTask = TaskManager::createTask("hex.ui.pattern_drawer.updating"_lang, TaskManager::NoProgress, [this, patterns, runtime](auto &task) {
|
||||
m_favoritesUpdateTask = TaskManager::createTask("hex.ui.pattern_drawer.updating", TaskManager::NoProgress, [this, patterns, runtime](auto &task) {
|
||||
size_t updatedFavorites = 0;
|
||||
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ namespace hex::plugin::visualizers {
|
||||
rotation[2] = std::fmod(rotation[2], 2 * std::numbers::pi_v<float>);
|
||||
}
|
||||
|
||||
bool validateVector(const std::vector<float> &vector, u32 vertexCount, u32 divisor, const std::string &name,std::string &errorMessage) {
|
||||
bool validateVector(const std::vector<float> &vector, u32 vertexCount, u32 divisor, const std::string &name, std::string &errorMessage) {
|
||||
if (!vector.empty()) {
|
||||
if (vector.size() % divisor != 0) {
|
||||
errorMessage = hex::format("hex.visualizers.pl_visualizer.3d.error_message_count"_lang, name , std::to_string(divisor));
|
||||
@ -377,24 +377,24 @@ namespace hex::plugin::visualizers {
|
||||
|
||||
|
||||
if ((indexType == IndexType::Undefined || vectors.indices.empty()) && vertexCount % 3 != 0) {
|
||||
throw std::runtime_error(std::string("hex.visualizers.pl_visualizer.3d.error_message_vertex_count"_lang));
|
||||
throw std::runtime_error("hex.visualizers.pl_visualizer.3d.error_message_vertex_count"_lang.get());
|
||||
} else
|
||||
buffers.vertices = gl::Buffer<float>(gl::BufferType::Vertex, vectors.vertices);
|
||||
|
||||
|
||||
if (validateVector(vectors.colors, vertexCount, 4, std::string("hex.visualizers.pl_visualizer.3d.error_message_colors"_lang), errorMessage))
|
||||
if (validateVector(vectors.colors, vertexCount, 4, "hex.visualizers.pl_visualizer.3d.error_message_colors"_lang.get(), errorMessage))
|
||||
buffers.colors = gl::Buffer<float>(gl::BufferType::Vertex, vectors.colors);
|
||||
else {
|
||||
throw std::runtime_error(errorMessage);
|
||||
}
|
||||
|
||||
if (validateVector(vectors.normals, vertexCount, 3, std::string("hex.visualizers.pl_visualizer.3d.error_message_normals"_lang), errorMessage))
|
||||
if (validateVector(vectors.normals, vertexCount, 3, "hex.visualizers.pl_visualizer.3d.error_message_normals"_lang.get(), errorMessage))
|
||||
buffers.normals = gl::Buffer<float>(gl::BufferType::Vertex, vectors.normals);
|
||||
else {
|
||||
throw std::runtime_error(errorMessage);
|
||||
}
|
||||
|
||||
if (validateVector(vectors.uv, vertexCount, 2, std::string("hex.visualizers.pl_visualizer.3d.error_message_uv_coords"_lang), errorMessage))
|
||||
if (validateVector(vectors.uv, vertexCount, 2, "hex.visualizers.pl_visualizer.3d.error_message_uv_coords"_lang.get(), errorMessage))
|
||||
buffers.uv = gl::Buffer<float>(gl::BufferType::Vertex, vectors.uv);
|
||||
else {
|
||||
throw std::runtime_error(errorMessage);
|
||||
@ -430,11 +430,11 @@ namespace hex::plugin::visualizers {
|
||||
lineBuffers.indices = gl::Buffer<T>(gl::BufferType::Index, lineVectors.indices);
|
||||
|
||||
if ((indexType == IndexType::Undefined || lineVectors.indices.empty()) && vertexCount % 3 != 0) {
|
||||
throw std::runtime_error(std::string("hex.visualizers.pl_visualizer.3d.error_message_vertex_count"_lang));
|
||||
throw std::runtime_error("hex.visualizers.pl_visualizer.3d.error_message_vertex_count"_lang.get());
|
||||
} else
|
||||
lineBuffers.vertices = gl::Buffer<float>(gl::BufferType::Vertex, lineVectors.vertices);
|
||||
|
||||
if (validateVector(lineVectors.colors, vertexCount, 4, std::string("hex.visualizers.pl_visualizer.3d.error_message_colors"_lang), errorMessage))
|
||||
if (validateVector(lineVectors.colors, vertexCount, 4, "hex.visualizers.pl_visualizer.3d.error_message_colors"_lang.get(), errorMessage))
|
||||
lineBuffers.colors = gl::Buffer<float>(gl::BufferType::Vertex, lineVectors.colors);
|
||||
else {
|
||||
throw std::runtime_error(errorMessage);
|
||||
@ -644,7 +644,7 @@ namespace hex::plugin::visualizers {
|
||||
vectors.vertices = patternToArray<float>(verticesPattern.get());
|
||||
std::string errorMessage;
|
||||
s_vertexCount = vectors.vertices.size() / 3;
|
||||
if (!validateVector(vectors.vertices, s_vertexCount, 3, std::string("hex.visualizers.pl_visualizer.3d.error_message_positions"_lang), errorMessage))
|
||||
if (!validateVector(vectors.vertices, s_vertexCount, 3, "hex.visualizers.pl_visualizer.3d.error_message_positions"_lang, errorMessage))
|
||||
throw std::runtime_error(errorMessage);
|
||||
|
||||
if (s_indexType != IndexType::Undefined) {
|
||||
@ -652,16 +652,16 @@ namespace hex::plugin::visualizers {
|
||||
s_badIndices.clear();
|
||||
auto indexCount = vectors.indices.size();
|
||||
if (indexCount < 3 || indexCount % 3 != 0) {
|
||||
throw std::runtime_error(std::string("hex.visualizers.pl_visualizer.3d.error_message_index_count"_lang));
|
||||
throw std::runtime_error("hex.visualizers.pl_visualizer.3d.error_message_index_count"_lang.get());
|
||||
}
|
||||
auto booleans = std::views::transform(vectors.indices,isIndexInRange);
|
||||
if (!std::accumulate(std::begin(booleans), std::end(booleans), true, std::logical_and<>())) {
|
||||
errorMessage = std::string("hex.visualizers.pl_visualizer.3d.error_message_invalid_indices"_lang);
|
||||
errorMessage = "hex.visualizers.pl_visualizer.3d.error_message_invalid_indices"_lang.get();
|
||||
for (auto badIndex : s_badIndices)
|
||||
errorMessage += std::to_string(badIndex) + ", ";
|
||||
errorMessage.pop_back();
|
||||
errorMessage.pop_back();
|
||||
errorMessage += hex::format(std::string("hex.visualizers.pl_visualizer.3d.error_message_for_vertex_count"_lang),s_vertexCount);
|
||||
errorMessage += hex::format("hex.visualizers.pl_visualizer.3d.error_message_for_vertex_count"_lang.get(), s_vertexCount);
|
||||
throw std::runtime_error(errorMessage);
|
||||
}
|
||||
}
|
||||
@ -682,23 +682,23 @@ namespace hex::plugin::visualizers {
|
||||
|
||||
lineVectors.vertices = patternToArray<float>(verticesPattern.get());
|
||||
s_vertexCount = lineVectors.vertices.size() / 3;
|
||||
if (!validateVector(lineVectors.vertices, s_vertexCount, 3, std::string("hex.visualizers.pl_visualizer.3d.error_message_positions"_lang), errorMessage))
|
||||
if (!validateVector(lineVectors.vertices, s_vertexCount, 3, "hex.visualizers.pl_visualizer.3d.error_message_positions"_lang.get(), errorMessage))
|
||||
throw std::runtime_error(errorMessage);
|
||||
|
||||
if (s_indexType != IndexType::Undefined) {
|
||||
lineVectors.indices = patternToArray<T>(indicesPattern.get());
|
||||
auto indexCount = lineVectors.indices.size();
|
||||
if (indexCount < 3 || indexCount % 3 != 0) {
|
||||
throw std::runtime_error(std::string("hex.visualizers.pl_visualizer.3d.error_message_index_count"_lang));
|
||||
throw std::runtime_error("hex.visualizers.pl_visualizer.3d.error_message_index_count"_lang.get());
|
||||
}
|
||||
s_badIndices.clear();
|
||||
if (!std::ranges::all_of(lineVectors.indices,isIndexInRange)) {
|
||||
errorMessage = std::string("hex.visualizers.pl_visualizer.3d.error_message_invalid_indices"_lang);
|
||||
errorMessage = "hex.visualizers.pl_visualizer.3d.error_message_invalid_indices"_lang.get();
|
||||
for (auto badIndex : s_badIndices)
|
||||
errorMessage += std::to_string(badIndex) + ", ";
|
||||
errorMessage.pop_back();
|
||||
errorMessage.pop_back();
|
||||
errorMessage += hex::format(std::string("hex.visualizers.pl_visualizer.3d.error_message_for_vertex_count"_lang),s_vertexCount);
|
||||
errorMessage += hex::format("hex.visualizers.pl_visualizer.3d.error_message_for_vertex_count"_lang.get(), s_vertexCount);
|
||||
throw std::runtime_error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace hex::plugin::visualizers {
|
||||
ImGuiExt::TextSpinner("hex.visualizers.pl_visualizer.coordinates.querying"_lang);
|
||||
} else if (address.empty()) {
|
||||
if (ImGuiExt::DimmedButton("hex.visualizers.pl_visualizer.coordinates.query"_lang)) {
|
||||
addressTask = TaskManager::createBackgroundTask("hex.visualizers.pl_visualizer.coordinates.querying"_lang, [lat = latitude, lon = longitude](auto &) {
|
||||
addressTask = TaskManager::createBackgroundTask("hex.visualizers.pl_visualizer.coordinates.querying", [lat = latitude, lon = longitude](auto &) {
|
||||
constexpr static auto ApiURL = "https://geocode.maps.co/reverse?lat={}&lon={}&format=jsonv2";
|
||||
|
||||
HttpRequest request("GET", hex::format(ApiURL, lat, lon));
|
||||
@ -90,7 +90,7 @@ namespace hex::plugin::visualizers {
|
||||
jsonAddr["country"].get<std::string>());
|
||||
}
|
||||
} catch (std::exception &) {
|
||||
address = std::string("hex.visualizers.pl_visualizer.coordinates.querying_no_address"_lang);
|
||||
address = "hex.visualizers.pl_visualizer.coordinates.querying_no_address"_lang.get();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace hex::plugin::visualizers {
|
||||
if (shouldReset) {
|
||||
waveData.clear();
|
||||
|
||||
resetTask = TaskManager::createTask("hex.visualizers.pl_visualizer.task.visualizing"_lang, TaskManager::NoProgress, [=](Task &) {
|
||||
resetTask = TaskManager::createTask("hex.visualizers.pl_visualizer.task.visualizing", TaskManager::NoProgress, [=](Task &) {
|
||||
ma_device_stop(&audioDevice);
|
||||
waveData = patternToArray<i16>(wavePattern.get());
|
||||
if (waveData.empty())
|
||||
|
@ -250,7 +250,7 @@ namespace hex::plugin::yara {
|
||||
if (provider == nullptr)
|
||||
return;
|
||||
|
||||
m_matcherTask = TaskManager::createTask("hex.yara_rules.view.yara.matching"_lang, 0, [this, provider](auto &task) {
|
||||
m_matcherTask = TaskManager::createTask("hex.yara_rules.view.yara.matching", 0, [this, provider](auto &task) {
|
||||
std::vector<YaraRule::Result> results;
|
||||
for (const auto &[fileName, filePath] : *m_rulePaths) {
|
||||
YaraRule rule(filePath);
|
||||
|
Loading…
x
Reference in New Issue
Block a user