mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-29 00:10:02 -05:00
Compare commits
8 Commits
feature/co
...
v1.35.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dffb7e95e3 | ||
|
|
916c1b7d4b | ||
|
|
2743b04f50 | ||
|
|
dbe8bfd75f | ||
|
|
c6c599c75b | ||
|
|
c2b7b4a11e | ||
|
|
495255484e | ||
|
|
b92b0922d5 |
@@ -117,6 +117,10 @@ macro(add_imhex_plugin)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(add_romfs_resource input output)
|
macro(add_romfs_resource input output)
|
||||||
|
if (NOT EXISTS ${input})
|
||||||
|
message(WARNING "Resource file ${input} does not exist")
|
||||||
|
endif()
|
||||||
|
|
||||||
configure_file(${input} ${CMAKE_CURRENT_BINARY_DIR}/romfs/${output} COPYONLY)
|
configure_file(${input} ${CMAKE_CURRENT_BINARY_DIR}/romfs/${output} COPYONLY)
|
||||||
|
|
||||||
list(APPEND LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/romfs)
|
list(APPEND LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/romfs)
|
||||||
|
|||||||
@@ -31,14 +31,30 @@ namespace hex::init {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isSubPathWritable(std::fs::path path) {
|
||||||
|
for (u32 i = 0; i < 128; i++) {
|
||||||
|
if (hex::fs::isPathWritable(path))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
auto parentPath = path.parent_path();
|
||||||
|
if (parentPath == path)
|
||||||
|
break;
|
||||||
|
|
||||||
|
path = std::move(parentPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool createDirectories() {
|
bool createDirectories() {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
// Try to create all default directories
|
// Try to create all default directories
|
||||||
for (auto path : paths::All) {
|
for (auto path : paths::All) {
|
||||||
for (auto &folder : path->write()) {
|
for (auto &folder : path->all()) {
|
||||||
try {
|
try {
|
||||||
wolv::io::fs::createDirectories(folder);
|
if (isSubPathWritable(folder.parent_path()))
|
||||||
|
wolv::io::fs::createDirectories(folder);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
log::error("Failed to create folder {}!", wolv::util::toUTF8String(folder));
|
log::error("Failed to create folder {}!", wolv::util::toUTF8String(folder));
|
||||||
result = false;
|
result = false;
|
||||||
|
|||||||
@@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.16)
|
|||||||
|
|
||||||
include(ImHexPlugin)
|
include(ImHexPlugin)
|
||||||
|
|
||||||
|
find_file(DEFAULT_MAGIC_FILE_PATH magic.mgc HINTS ${LIBMAGIC_INCLUDE_DIR}/../share/misc)
|
||||||
|
if (EXISTS ${DEFAULT_MAGIC_FILE_PATH})
|
||||||
|
add_romfs_resource(${DEFAULT_MAGIC_FILE_PATH} always_auto_extract/magic/magic.mgc)
|
||||||
|
endif ()
|
||||||
|
|
||||||
add_imhex_plugin(
|
add_imhex_plugin(
|
||||||
NAME
|
NAME
|
||||||
builtin
|
builtin
|
||||||
@@ -122,11 +127,6 @@ add_imhex_plugin(
|
|||||||
LLVMDemangle
|
LLVMDemangle
|
||||||
)
|
)
|
||||||
|
|
||||||
find_file(DEFAULT_MAGIC_FILE_PATH magic.mgc HINTS ${LIBMAGIC_INCLUDE_DIR}/../share/misc)
|
|
||||||
if (DEFAULT_MAGIC_FILE_PATH)
|
|
||||||
add_romfs_resource(${DEFAULT_MAGIC_FILE_PATH} always_auto_extract/magic/magic.mgc)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(builtin PRIVATE setupapi)
|
target_link_libraries(builtin PRIVATE setupapi)
|
||||||
endif ()
|
endif ()
|
||||||
@@ -152,8 +152,11 @@ namespace hex::fonts {
|
|||||||
return m_fontAtlas->Build();
|
return m_fontAtlas->Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] ImFontAtlas* getAtlas() const {
|
[[nodiscard]] ImFontAtlas* takeAtlas() {
|
||||||
return m_fontAtlas;
|
auto result = m_fontAtlas;
|
||||||
|
m_fontAtlas = nullptr;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float calculateFontDescend(const ImHexApi::Fonts::Font &font, float fontSize) const {
|
float calculateFontDescend(const ImHexApi::Fonts::Font &font, float fontSize) const {
|
||||||
@@ -331,7 +334,7 @@ namespace hex::fonts {
|
|||||||
const bool result = fontAtlas.build();
|
const bool result = fontAtlas.build();
|
||||||
if (result) {
|
if (result) {
|
||||||
// Set the font atlas if the build was successful
|
// Set the font atlas if the build was successful
|
||||||
ImHexApi::Fonts::impl::setFontAtlas(fontAtlas.getAtlas());
|
ImHexApi::Fonts::impl::setFontAtlas(fontAtlas.takeAtlas());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user