sys: Implement more functionality into splash screen (#223)
* build: Add libcurl * build: Stop the whole static linking on Windows mess. There's no use anymore * sys: Added update detector and moved some startup tasks to splash screen * sys: Updated ImHex icon * fix: Settings button on welcome page once again works * build: Fix build on Linux * sys: Fixed splash window not searching all paths for resources
This commit is contained in:
parent
6fb6de6b64
commit
ebbbcafe5c
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -11,3 +11,6 @@
|
|||||||
[submodule "external/fmt"]
|
[submodule "external/fmt"]
|
||||||
path = external/fmt
|
path = external/fmt
|
||||||
url = https://github.com/fmtlib/fmt
|
url = https://github.com/fmtlib/fmt
|
||||||
|
[submodule "external/curl"]
|
||||||
|
path = external/curl
|
||||||
|
url = https://github.com/curl/curl
|
||||||
|
@ -73,7 +73,7 @@ set_target_properties(imhex PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
|||||||
target_link_directories(imhex PRIVATE ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS})
|
target_link_directories(imhex PRIVATE ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS})
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(imhex libdl.a libmagic.a libgnurx.a libtre.a libintl.a libiconv.a libshlwapi.a libcapstone.a LLVMDemangle libimhex ${Python_LIBRARIES} wsock32 ws2_32 libyara)
|
target_link_libraries(imhex magic ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} wsock32 ws2_32 libyara)
|
||||||
else ()
|
else ()
|
||||||
target_link_libraries(imhex magic ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} dl pthread libyara)
|
target_link_libraries(imhex magic ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} dl pthread libyara)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -120,7 +120,7 @@ macro(configurePackageCreation)
|
|||||||
set(application_type)
|
set(application_type)
|
||||||
endif ()
|
endif ()
|
||||||
set(imhex_icon "${CMAKE_SOURCE_DIR}/res/resource.rc")
|
set(imhex_icon "${CMAKE_SOURCE_DIR}/res/resource.rc")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -Wl,--allow-multiple-definition -static")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wl,-subsystem,windows")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wl,-subsystem,windows")
|
||||||
|
|
||||||
if (CREATE_PACKAGE)
|
if (CREATE_PACKAGE)
|
||||||
@ -233,8 +233,9 @@ macro(createPackage)
|
|||||||
# Install the magicdb files.
|
# Install the magicdb files.
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/magic_dbs.mgc DESTINATION ${MAGIC_INSTALL_LOCATION} RENAME imhex.mgc)
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/magic_dbs.mgc DESTINATION ${MAGIC_INSTALL_LOCATION} RENAME imhex.mgc)
|
||||||
|
|
||||||
# Install splash screen
|
# Install resources
|
||||||
install(FILES ${CMAKE_SOURCE_DIR}/res/splash.png DESTINATION ${RESOURCES_INSTALL_LOCATION})
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/resources/ DESTINATION ${RESOURCES_INSTALL_LOCATION})
|
||||||
|
|
||||||
|
|
||||||
if (CREATE_BUNDLE)
|
if (CREATE_BUNDLE)
|
||||||
include(PostprocessBundle)
|
include(PostprocessBundle)
|
||||||
|
4
external/ImGui/CMakeLists.txt
vendored
4
external/ImGui/CMakeLists.txt
vendored
@ -10,7 +10,7 @@ pkg_search_module(GLFW REQUIRED glfw3)
|
|||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||||
|
|
||||||
add_library(imgui
|
add_library(imgui STATIC
|
||||||
source/imgui.cpp
|
source/imgui.cpp
|
||||||
source/imgui_demo.cpp
|
source/imgui_demo.cpp
|
||||||
source/imgui_draw.cpp
|
source/imgui_draw.cpp
|
||||||
@ -42,7 +42,7 @@ target_include_directories(imgui PUBLIC include fonts ${FREETYPE_INCLUDE_DIRS} $
|
|||||||
target_link_directories(imgui PUBLIC ${GLM_INCLUDE_DIRS} ${GLFW_LIBRARY_DIRS})
|
target_link_directories(imgui PUBLIC ${GLM_INCLUDE_DIRS} ${GLFW_LIBRARY_DIRS})
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(imgui libstdc++.a libgcc.a libharfbuzz.a libfreetype.a libharfbuzz.a libgraphite2.a libpng.a libbrotlidec-static.a libbrotlicommon-static.a libz.a libbz2.a librpcrt4.a glad libglfw3.a)
|
target_link_libraries(imgui Freetype::Freetype glad glfw3)
|
||||||
elseif (UNIX)
|
elseif (UNIX)
|
||||||
target_link_libraries(imgui Freetype::Freetype glad glfw)
|
target_link_libraries(imgui Freetype::Freetype glad glfw)
|
||||||
endif()
|
endif()
|
||||||
|
1
external/curl
vendored
Submodule
1
external/curl
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 566b74a0e19b9aa610f4931e5bfd339bcf8e9147
|
12
external/glad/CMakeLists.txt
vendored
12
external/glad/CMakeLists.txt
vendored
@ -3,20 +3,12 @@ project(glad)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||||
|
|
||||||
add_library(glad
|
add_library(glad STATIC
|
||||||
source/glad.c
|
source/glad.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(glad PUBLIC include)
|
target_include_directories(glad PUBLIC include)
|
||||||
|
|
||||||
if (WIN32)
|
target_link_libraries(glad PRIVATE dl)
|
||||||
target_link_libraries(glad PRIVATE libdl.a)
|
|
||||||
else()
|
|
||||||
target_link_libraries(glad PRIVATE dl)
|
|
||||||
endif()
|
|
6
external/llvm/CMakeLists.txt
vendored
6
external/llvm/CMakeLists.txt
vendored
@ -3,13 +3,9 @@ project(LLVMDemangle)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||||
|
|
||||||
add_library(LLVMDemangle
|
add_library(LLVMDemangle STATIC
|
||||||
Demangle/Demangle.cpp
|
Demangle/Demangle.cpp
|
||||||
Demangle/ItaniumDemangle.cpp
|
Demangle/ItaniumDemangle.cpp
|
||||||
Demangle/MicrosoftDemangle.cpp
|
Demangle/MicrosoftDemangle.cpp
|
||||||
|
4
external/yara/CMakeLists.txt
vendored
4
external/yara/CMakeLists.txt
vendored
@ -117,7 +117,9 @@ target_include_directories(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
target_link_libraries(libyara pthread)
|
target_link_libraries(libyara magic pthread)
|
||||||
|
else ()
|
||||||
|
target_link_libraries(libyara magic)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
@ -36,7 +36,6 @@ namespace hex {
|
|||||||
void drawWelcomeScreen();
|
void drawWelcomeScreen();
|
||||||
void resetLayout();
|
void resetLayout();
|
||||||
|
|
||||||
void createDirectories() const;
|
|
||||||
void initGLFW();
|
void initGLFW();
|
||||||
void initImGui();
|
void initImGui();
|
||||||
void deinitGLFW();
|
void deinitGLFW();
|
||||||
@ -54,7 +53,7 @@ namespace hex {
|
|||||||
|
|
||||||
bool m_prevKeysDown[512];
|
bool m_prevKeysDown[512];
|
||||||
|
|
||||||
static inline std::tuple<int, int> s_currShortcut = { -1, -1 };
|
std::string m_availableUpdate;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -36,7 +36,7 @@ set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
|||||||
set(CMAKE_SHARED_LIBRARY_SUFFIX ".hexplug")
|
set(CMAKE_SHARED_LIBRARY_SUFFIX ".hexplug")
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -Wl,--allow-multiple-definition -fvisibility=hidden")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -fvisibility=hidden")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME})
|
add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME})
|
||||||
|
@ -31,9 +31,13 @@ namespace hex::plugin::builtin {
|
|||||||
{ "hex.welcome.header.customize", "Anpassen" },
|
{ "hex.welcome.header.customize", "Anpassen" },
|
||||||
{ "hex.welcome.customize.settings.title", "Einstellungen" },
|
{ "hex.welcome.customize.settings.title", "Einstellungen" },
|
||||||
{ "hex.welcome.customize.settings.desc", "Ändere ImHex' Einstellungen" },
|
{ "hex.welcome.customize.settings.desc", "Ändere ImHex' Einstellungen" },
|
||||||
|
{ "hex.welcome.header.update", "Updates" },
|
||||||
|
{ "hex.welcome.update.title", "Neues Update verfügbar!" },
|
||||||
|
{ "hex.welcome.update.desc", "ImHex {0} wurde gerade released! Downloade die neue version hier" },
|
||||||
|
{ "hex.welcome.update.link", "https://github.com/WerWolv/ImHex/releases/latest" },
|
||||||
{ "hex.welcome.header.learn", "Lernen" },
|
{ "hex.welcome.header.learn", "Lernen" },
|
||||||
{ "hex.welcome.learn.latest.title", "Neuster Release" },
|
{ "hex.welcome.learn.latest.title", "Neuster Release" },
|
||||||
{ "hex.welcome.learn.latest.desc", "Lade die neuste Version von ImHex herunter oder lies den Changelog" },
|
{ "hex.welcome.learn.latest.desc", "Lies den momentanen ImHex Changelog" },
|
||||||
{ "hex.welcome.learn.latest.link", "https://github.com/WerWolv/ImHex/releases/latest" },
|
{ "hex.welcome.learn.latest.link", "https://github.com/WerWolv/ImHex/releases/latest" },
|
||||||
{ "hex.welcome.learn.pattern.title", "Pattern Language Dokumentation" },
|
{ "hex.welcome.learn.pattern.title", "Pattern Language Dokumentation" },
|
||||||
{ "hex.welcome.learn.pattern.desc", "Lern ImHex Patterns zu schreiben mit unserer umfangreichen Dokumentation" },
|
{ "hex.welcome.learn.pattern.desc", "Lern ImHex Patterns zu schreiben mit unserer umfangreichen Dokumentation" },
|
||||||
@ -49,6 +53,7 @@ namespace hex::plugin::builtin {
|
|||||||
{ "hex.common.hexadecimal", "Hexadezimal" },
|
{ "hex.common.hexadecimal", "Hexadezimal" },
|
||||||
{ "hex.common.octal", "Oktal" },
|
{ "hex.common.octal", "Oktal" },
|
||||||
{ "hex.common.error", "Fehler" },
|
{ "hex.common.error", "Fehler" },
|
||||||
|
{ "hex.common.fatal", "Fataler Fehler" },
|
||||||
{ "hex.common.address", "Adresse" },
|
{ "hex.common.address", "Adresse" },
|
||||||
{ "hex.common.size", "Länge" },
|
{ "hex.common.size", "Länge" },
|
||||||
{ "hex.common.region", "Region" },
|
{ "hex.common.region", "Region" },
|
||||||
@ -56,7 +61,6 @@ namespace hex::plugin::builtin {
|
|||||||
{ "hex.common.yes", "Ja" },
|
{ "hex.common.yes", "Ja" },
|
||||||
{ "hex.common.no", "Nein" },
|
{ "hex.common.no", "Nein" },
|
||||||
{ "hex.common.okay", "Okay" },
|
{ "hex.common.okay", "Okay" },
|
||||||
{ "hex.common.error", "Fehler" },
|
|
||||||
{ "hex.common.load", "Laden" },
|
{ "hex.common.load", "Laden" },
|
||||||
{ "hex.common.cancel", "Abbrechen" },
|
{ "hex.common.cancel", "Abbrechen" },
|
||||||
{ "hex.common.set", "Setzen" },
|
{ "hex.common.set", "Setzen" },
|
||||||
|
@ -31,9 +31,13 @@ namespace hex::plugin::builtin {
|
|||||||
{ "hex.welcome.header.customize", "Customize" },
|
{ "hex.welcome.header.customize", "Customize" },
|
||||||
{ "hex.welcome.customize.settings.title", "Settings" },
|
{ "hex.welcome.customize.settings.title", "Settings" },
|
||||||
{ "hex.welcome.customize.settings.desc", "Change preferences of ImHex" },
|
{ "hex.welcome.customize.settings.desc", "Change preferences of ImHex" },
|
||||||
|
{ "hex.welcome.header.update", "Updates" },
|
||||||
|
{ "hex.welcome.update.title", "New Update available!" },
|
||||||
|
{ "hex.welcome.update.desc", "ImHex {0} just released! Download it here." },
|
||||||
|
{ "hex.welcome.update.link", "https://github.com/WerWolv/ImHex/releases/latest" },
|
||||||
{ "hex.welcome.header.learn", "Learn" },
|
{ "hex.welcome.header.learn", "Learn" },
|
||||||
{ "hex.welcome.learn.latest.title", "Latest Release" },
|
{ "hex.welcome.learn.latest.title", "Latest Release" },
|
||||||
{ "hex.welcome.learn.latest.desc", "Get the latest version of ImHex or read the current changelog" },
|
{ "hex.welcome.learn.latest.desc", "Read ImHex' current changelog" },
|
||||||
{ "hex.welcome.learn.latest.link", "https://github.com/WerWolv/ImHex/releases/latest" },
|
{ "hex.welcome.learn.latest.link", "https://github.com/WerWolv/ImHex/releases/latest" },
|
||||||
{ "hex.welcome.learn.pattern.title", "Pattern Language Documentation" },
|
{ "hex.welcome.learn.pattern.title", "Pattern Language Documentation" },
|
||||||
{ "hex.welcome.learn.pattern.desc", "Learn how to write ImHex patterns with our extensive documentation" },
|
{ "hex.welcome.learn.pattern.desc", "Learn how to write ImHex patterns with our extensive documentation" },
|
||||||
@ -49,6 +53,7 @@ namespace hex::plugin::builtin {
|
|||||||
{ "hex.common.hexadecimal", "Hexadecimal" },
|
{ "hex.common.hexadecimal", "Hexadecimal" },
|
||||||
{ "hex.common.octal", "Octal" },
|
{ "hex.common.octal", "Octal" },
|
||||||
{ "hex.common.error", "Error" },
|
{ "hex.common.error", "Error" },
|
||||||
|
{ "hex.common.fatal", "Fatal Error" },
|
||||||
{ "hex.common.address", "Address" },
|
{ "hex.common.address", "Address" },
|
||||||
{ "hex.common.size", "Size" },
|
{ "hex.common.size", "Size" },
|
||||||
{ "hex.common.region", "Region" },
|
{ "hex.common.region", "Region" },
|
||||||
@ -56,7 +61,6 @@ namespace hex::plugin::builtin {
|
|||||||
{ "hex.common.yes", "Yes" },
|
{ "hex.common.yes", "Yes" },
|
||||||
{ "hex.common.no", "No" },
|
{ "hex.common.no", "No" },
|
||||||
{ "hex.common.okay", "Okay" },
|
{ "hex.common.okay", "Okay" },
|
||||||
{ "hex.common.error", "Error" },
|
|
||||||
{ "hex.common.load", "Load" },
|
{ "hex.common.load", "Load" },
|
||||||
{ "hex.common.cancel", "Cancel" },
|
{ "hex.common.cancel", "Cancel" },
|
||||||
{ "hex.common.set", "Set" },
|
{ "hex.common.set", "Set" },
|
||||||
|
@ -31,9 +31,13 @@ namespace hex::plugin::builtin {
|
|||||||
{ "hex.welcome.header.customize", "Personalizza" },
|
{ "hex.welcome.header.customize", "Personalizza" },
|
||||||
{ "hex.welcome.customize.settings.title", "Impostazioni" },
|
{ "hex.welcome.customize.settings.title", "Impostazioni" },
|
||||||
{ "hex.welcome.customize.settings.desc", "Cambia le preferenze di ImHex" },
|
{ "hex.welcome.customize.settings.desc", "Cambia le preferenze di ImHex" },
|
||||||
|
//{ "hex.welcome.header.update", "Updates" },
|
||||||
|
// { "hex.welcome.update.title", "New Update available!" },
|
||||||
|
// { "hex.welcome.update.desc", "ImHex {0} just released! Download it here." },
|
||||||
|
// { "hex.welcome.update.link", "https://github.com/WerWolv/ImHex/releases/latest" },
|
||||||
{ "hex.welcome.header.learn", "Scopri" },
|
{ "hex.welcome.header.learn", "Scopri" },
|
||||||
{ "hex.welcome.learn.latest.title", "Ultima Versione" },
|
{ "hex.welcome.learn.latest.title", "Ultima Versione" },
|
||||||
{ "hex.welcome.learn.latest.desc", "Scarica l'ultima versione di ImHex o leggi le modifiche" },
|
// { "hex.welcome.learn.latest.desc", "Read ImHex' current changelog" },
|
||||||
{ "hex.welcome.learn.latest.link", "https://github.com/WerWolv/ImHex/releases/latest" },
|
{ "hex.welcome.learn.latest.link", "https://github.com/WerWolv/ImHex/releases/latest" },
|
||||||
{ "hex.welcome.learn.pattern.title", "Documentazione dei Pattern" },
|
{ "hex.welcome.learn.pattern.title", "Documentazione dei Pattern" },
|
||||||
{ "hex.welcome.learn.pattern.desc", "Scopri come scrivere pattern per ImHex con la nostra dettagliata documentazione" },
|
{ "hex.welcome.learn.pattern.desc", "Scopri come scrivere pattern per ImHex con la nostra dettagliata documentazione" },
|
||||||
@ -49,6 +53,7 @@ namespace hex::plugin::builtin {
|
|||||||
{ "hex.common.hexadecimal", "Esadecimale" },
|
{ "hex.common.hexadecimal", "Esadecimale" },
|
||||||
{ "hex.common.octal", "Ottale" },
|
{ "hex.common.octal", "Ottale" },
|
||||||
{ "hex.common.error", "Errore" },
|
{ "hex.common.error", "Errore" },
|
||||||
|
// { "hex.common.fatal", "Fatal Error" },
|
||||||
{ "hex.common.address", "Indirizzo" },
|
{ "hex.common.address", "Indirizzo" },
|
||||||
{ "hex.common.size", "Dimensione" },
|
{ "hex.common.size", "Dimensione" },
|
||||||
{ "hex.common.region", "Regione" },
|
{ "hex.common.region", "Regione" },
|
||||||
@ -56,7 +61,6 @@ namespace hex::plugin::builtin {
|
|||||||
{ "hex.common.yes", "Sì" },
|
{ "hex.common.yes", "Sì" },
|
||||||
{ "hex.common.no", "No" },
|
{ "hex.common.no", "No" },
|
||||||
{ "hex.common.okay", "Okay" },
|
{ "hex.common.okay", "Okay" },
|
||||||
{ "hex.common.error", "Errore" },
|
|
||||||
{ "hex.common.load", "Carica" },
|
{ "hex.common.load", "Carica" },
|
||||||
{ "hex.common.cancel", "Cancella" },
|
{ "hex.common.cancel", "Cancella" },
|
||||||
{ "hex.common.set", "Imposta" },
|
{ "hex.common.set", "Imposta" },
|
||||||
|
@ -22,7 +22,7 @@ set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
|||||||
set(CMAKE_SHARED_LIBRARY_SUFFIX ".hexplug")
|
set(CMAKE_SHARED_LIBRARY_SUFFIX ".hexplug")
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -Wl,--allow-multiple-definition -fvisibility=hidden")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -fvisibility=hidden")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME})
|
add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME})
|
||||||
|
@ -3,15 +3,17 @@ project(libimhex)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/ImGui ${CMAKE_CURRENT_BINARY_DIR}/external/ImGui)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/ImGui ${CMAKE_CURRENT_BINARY_DIR}/external/ImGui)
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/nlohmann_json ${CMAKE_CURRENT_BINARY_DIR}/external/nlohmann_json)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/nlohmann_json ${CMAKE_CURRENT_BINARY_DIR}/external/nlohmann_json)
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/nativefiledialog ${CMAKE_CURRENT_BINARY_DIR}/external/nativefiledialog)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/nativefiledialog ${CMAKE_CURRENT_BINARY_DIR}/external/nativefiledialog)
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/fmt ${CMAKE_CURRENT_BINARY_DIR}/external/fmt)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/fmt ${CMAKE_CURRENT_BINARY_DIR}/external/fmt)
|
||||||
set(XDGPP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../external/xdgpp")
|
set(XDGPP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../external/xdgpp")
|
||||||
|
set(CMAKE_USE_MBEDTLS ON)
|
||||||
if (WIN32)
|
set(BUILD_CURL_EXE OFF)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
|
set(FPHSA_NAME_MISMATCHED ON CACHE BOOL "")
|
||||||
endif()
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/curl ${CMAKE_CURRENT_BINARY_DIR}/external/curl)
|
||||||
|
set_target_properties(libcurl PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||||
|
|
||||||
@ -26,6 +28,7 @@ set(LIBIMHEX_SOURCES
|
|||||||
source/helpers/shared_data.cpp
|
source/helpers/shared_data.cpp
|
||||||
source/helpers/crypto.cpp
|
source/helpers/crypto.cpp
|
||||||
source/helpers/lang.cpp
|
source/helpers/lang.cpp
|
||||||
|
source/helpers/net.cpp
|
||||||
|
|
||||||
source/lang/pattern_language.cpp
|
source/lang/pattern_language.cpp
|
||||||
source/lang/preprocessor.cpp
|
source/lang/preprocessor.cpp
|
||||||
@ -57,11 +60,9 @@ add_library(libimhex SHARED ${LIBIMHEX_SOURCES})
|
|||||||
target_include_directories(libimhex PUBLIC include ${MBEDTLS_INCLUDE_DIR} ${XDGPP_INCLUDE_DIRS})
|
target_include_directories(libimhex PUBLIC include ${MBEDTLS_INCLUDE_DIR} ${XDGPP_INCLUDE_DIRS})
|
||||||
target_link_directories(libimhex PUBLIC ${MBEDTLS_LIBRARY_DIR})
|
target_link_directories(libimhex PUBLIC ${MBEDTLS_LIBRARY_DIR})
|
||||||
|
|
||||||
if (WIN32)
|
if (APPLE)
|
||||||
target_link_libraries(libimhex PUBLIC imgui nlohmann_json libmbedcrypto.a nfd fmt-header-only)
|
|
||||||
elseif (APPLE)
|
|
||||||
find_library(FOUNDATION NAMES Foundation)
|
find_library(FOUNDATION NAMES Foundation)
|
||||||
target_link_libraries(libimhex PUBLIC imgui nlohmann_json mbedcrypto ${FOUNDATION} nfd fmt-header-only)
|
target_link_libraries(libimhex PUBLIC imgui nlohmann_json mbedcrypto ${FOUNDATION} nfd fmt-header-only libcurl)
|
||||||
else()
|
else ()
|
||||||
target_link_libraries(libimhex PUBLIC imgui nlohmann_json mbedcrypto nfd fmt-header-only)
|
target_link_libraries(libimhex PUBLIC imgui nlohmann_json mbedcrypto nfd fmt-header-only libcurl)
|
||||||
endif ()
|
endif ()
|
30
plugins/libimhex/include/hex/helpers/net.hpp
Normal file
30
plugins/libimhex/include/hex/helpers/net.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <hex.hpp>
|
||||||
|
#include <future>
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace hex {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct Response {
|
||||||
|
u32 code;
|
||||||
|
T response;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Net {
|
||||||
|
public:
|
||||||
|
Net();
|
||||||
|
~Net();
|
||||||
|
|
||||||
|
Response<std::string> getString(std::string_view url);
|
||||||
|
Response<nlohmann::json> getJson(std::string_view url);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CURL *m_ctx;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -43,6 +43,7 @@ namespace hex {
|
|||||||
static void drawCommonInterfaces();
|
static void drawCommonInterfaces();
|
||||||
|
|
||||||
static void showErrorPopup(std::string_view errorMessage);
|
static void showErrorPopup(std::string_view errorMessage);
|
||||||
|
static void showFatalPopup(std::string_view errorMessage);
|
||||||
|
|
||||||
virtual bool hasViewMenuItemEntry();
|
virtual bool hasViewMenuItemEntry();
|
||||||
virtual ImVec2 getMinSize();
|
virtual ImVec2 getMinSize();
|
||||||
|
92
plugins/libimhex/source/helpers/net.cpp
Normal file
92
plugins/libimhex/source/helpers/net.cpp
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#include <hex/helpers/net.hpp>
|
||||||
|
|
||||||
|
#include <hex/helpers/utils.hpp>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
namespace hex {
|
||||||
|
|
||||||
|
Net::Net() {
|
||||||
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
|
this->m_ctx = curl_easy_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
Net::~Net() {
|
||||||
|
curl_easy_cleanup(this->m_ctx);
|
||||||
|
curl_global_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t writeToString(void *contents, size_t size, size_t nmemb, void *userp){
|
||||||
|
static_cast<std::string*>(userp)->append((char*)contents, size * nmemb);
|
||||||
|
return size * nmemb;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setCommonSettings(CURL *ctx, std::string &response, std::string_view path, const std::map<std::string, std::string> &extraHeaders, const std::string &body) {
|
||||||
|
struct curl_slist *headers = nullptr;
|
||||||
|
headers = curl_slist_append(headers, "Cache-Control: no-cache");
|
||||||
|
|
||||||
|
if (!extraHeaders.empty())
|
||||||
|
for (const auto &[key, value] : extraHeaders) {
|
||||||
|
std::string entry = key;
|
||||||
|
entry += ": ";
|
||||||
|
entry += value;
|
||||||
|
|
||||||
|
headers = curl_slist_append(headers, entry.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!body.empty())
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_POSTFIELDS, body.c_str());
|
||||||
|
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_HTTPHEADER, headers);
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_USERAGENT, "ImHex/1.0");
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_URL, path.data());
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_FOLLOWLOCATION, 1L);
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_DEFAULT_PROTOCOL, "https");
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_WRITEFUNCTION, writeToString);
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_SSL_VERIFYPEER, 1L);
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_SSL_VERIFYHOST, 1L);
|
||||||
|
for (const auto &resourceDir : hex::getPath(hex::ImHexPath::Resources)) {
|
||||||
|
if (std::filesystem::exists(resourceDir + "/cacert.pem"))
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_CAPATH, resourceDir.c_str());
|
||||||
|
}
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_WRITEDATA, &response);
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_TIMEOUT_MS, 2000L);
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_CONNECTTIMEOUT_MS, 2000L);
|
||||||
|
curl_easy_setopt(ctx, CURLOPT_NOPROGRESS, 1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
Response<std::string> Net::getString(std::string_view url) {
|
||||||
|
std::string response;
|
||||||
|
|
||||||
|
curl_easy_setopt(this->m_ctx, CURLOPT_CUSTOMREQUEST, "GET");
|
||||||
|
setCommonSettings(this->m_ctx, response, url, {}, "");
|
||||||
|
|
||||||
|
CURLcode result = curl_easy_perform(this->m_ctx);
|
||||||
|
|
||||||
|
u32 responseCode = 0;
|
||||||
|
curl_easy_getinfo(this->m_ctx, CURLINFO_RESPONSE_CODE, &responseCode);
|
||||||
|
|
||||||
|
if (result != CURLE_OK)
|
||||||
|
return Response<std::string>{ responseCode, "" };
|
||||||
|
else
|
||||||
|
return Response<std::string>{ responseCode, response };
|
||||||
|
}
|
||||||
|
|
||||||
|
Response<nlohmann::json> Net::getJson(std::string_view url) {
|
||||||
|
std::string response;
|
||||||
|
|
||||||
|
curl_easy_setopt(this->m_ctx, CURLOPT_CUSTOMREQUEST, "GET");
|
||||||
|
setCommonSettings(this->m_ctx, response, url, {}, "");
|
||||||
|
|
||||||
|
CURLcode result = curl_easy_perform(this->m_ctx);
|
||||||
|
|
||||||
|
u32 responseCode = 0;
|
||||||
|
curl_easy_getinfo(this->m_ctx, CURLINFO_RESPONSE_CODE, &responseCode);
|
||||||
|
|
||||||
|
if (result != CURLE_OK)
|
||||||
|
return Response<nlohmann::json>{ responseCode, { } };
|
||||||
|
else
|
||||||
|
return Response<nlohmann::json>{ responseCode, nlohmann::json::parse(response) };
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -60,6 +60,18 @@ namespace hex {
|
|||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginPopupModal("hex.common.fatal"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
ImGui::Text("%s", SharedData::errorPopupMessage.c_str());
|
||||||
|
ImGui::NewLine();
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::Button("hex.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape)) {
|
||||||
|
EventManager::post<RequestCloseImHex>();
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::showErrorPopup(std::string_view errorMessage) {
|
void View::showErrorPopup(std::string_view errorMessage) {
|
||||||
@ -68,6 +80,12 @@ namespace hex {
|
|||||||
View::doLater([] { ImGui::OpenPopup("hex.common.error"_lang); });
|
View::doLater([] { ImGui::OpenPopup("hex.common.error"_lang); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::showFatalPopup(std::string_view errorMessage) {
|
||||||
|
SharedData::errorPopupMessage = errorMessage;
|
||||||
|
|
||||||
|
View::doLater([] { ImGui::OpenPopup("hex.common.fatal"_lang); });
|
||||||
|
}
|
||||||
|
|
||||||
bool View::hasViewMenuItemEntry() {
|
bool View::hasViewMenuItemEntry() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
BIN
res/icon.ico
BIN
res/icon.ico
Binary file not shown.
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 9.3 KiB |
3214
res/resources/cacert.pem
Normal file
3214
res/resources/cacert.pem
Normal file
File diff suppressed because it is too large
Load Diff
BIN
res/resources/splash.png
Normal file
BIN
res/resources/splash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
BIN
res/splash.png
BIN
res/splash.png
Binary file not shown.
Before Width: | Height: | Size: 39 KiB |
@ -6,8 +6,8 @@ namespace hex {
|
|||||||
|
|
||||||
ViewSettings::ViewSettings() : View("hex.view.settings.name") {
|
ViewSettings::ViewSettings() : View("hex.view.settings.name") {
|
||||||
EventManager::subscribe<RequestOpenWindow>(this, [this](const std::string &name) {
|
EventManager::subscribe<RequestOpenWindow>(this, [this](const std::string &name) {
|
||||||
if (name == "hex.view.settings.name") {
|
if (name == "Settings") {
|
||||||
View::doLater([]{ ImGui::OpenPopup("hex.view.settings.name"_lang); });
|
View::doLater([]{ ImGui::OpenPopup(View::toWindowName("hex.view.settings.name").c_str()); });
|
||||||
this->getWindowOpenState() = true;
|
this->getWindowOpenState() = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -58,14 +58,62 @@ namespace hex {
|
|||||||
SharedData::mainArgv = argv;
|
SharedData::mainArgv = argv;
|
||||||
SharedData::currentProvider = nullptr;
|
SharedData::currentProvider = nullptr;
|
||||||
|
|
||||||
#if defined(RELEASE)
|
#if !defined(RELEASE)
|
||||||
if (argv[argc - 1] != std::string(GIT_COMMIT_HASH)) {
|
{
|
||||||
printf("Version mismatch! Make sure you updated all of ImHex\n");
|
if (argc < 2) {
|
||||||
exit(1);
|
View::showFatalPopup("No launch arguments supplied! Please launch imhex instead of imhexg!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string launchArguments = argv[argc - 1];
|
||||||
|
|
||||||
|
if (launchArguments.find("--args=") != 0) {
|
||||||
|
View::showFatalPopup("No launch arguments supplied! Please launch imhex instead of imhexg!");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool commitChecked = false;
|
||||||
|
bool branchChecked = false;
|
||||||
|
|
||||||
|
for (const auto& arg : hex::splitString(launchArguments.substr(7), "|")) {
|
||||||
|
auto splitArg = hex::splitString(arg, "=");
|
||||||
|
|
||||||
|
// Handle flags
|
||||||
|
if (splitArg.size() == 1) {
|
||||||
|
auto &flag = splitArg[0];
|
||||||
|
|
||||||
|
if (flag == "tasks-failed") {
|
||||||
|
|
||||||
|
} else if (flag == "splash-skipped") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle arguments
|
||||||
|
else if (splitArg.size() == 2) {
|
||||||
|
auto &name = splitArg[0];
|
||||||
|
auto &value = splitArg[1];
|
||||||
|
|
||||||
|
if (name == "git-hash") {
|
||||||
|
if (value != GIT_COMMIT_HASH)
|
||||||
|
View::showFatalPopup("Launcher and ImHex version commit mismatch. Please fully update ImHex before using it!");
|
||||||
|
commitChecked = true;
|
||||||
|
} else if (name == "git-branch") {
|
||||||
|
if (value != GIT_BRANCH)
|
||||||
|
View::showFatalPopup("Launcher and ImHex version branch mismatch. Please fully update ImHex before using it!");
|
||||||
|
branchChecked = true;
|
||||||
|
} else if (name == "update") {
|
||||||
|
this->m_availableUpdate = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle others
|
||||||
|
else {
|
||||||
|
View::showFatalPopup("Invalid launch arguments supplied! Please launch imhex instead of imhexg!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!commitChecked || !branchChecked)
|
||||||
|
View::showFatalPopup("No commit information available! Please launch imhex instead of imhexg!");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->createDirectories();
|
|
||||||
this->initGLFW();
|
this->initGLFW();
|
||||||
this->initImGui();
|
this->initImGui();
|
||||||
|
|
||||||
@ -416,11 +464,10 @@ namespace hex {
|
|||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
const auto availableSpace = ImGui::GetContentRegionAvail();
|
const auto availableSpace = ImGui::GetContentRegionAvail();
|
||||||
const auto rowHeight = ImGui::GetTextLineHeightWithSpacing() * 6;
|
|
||||||
|
|
||||||
ImGui::Indent();
|
ImGui::Indent();
|
||||||
if (ImGui::BeginTable("Welcome Left", 1, ImGuiTableFlags_NoBordersInBody, ImVec2(availableSpace.x / 2, availableSpace.y))) {
|
if (ImGui::BeginTable("Welcome Left", 1, ImGuiTableFlags_NoBordersInBody, ImVec2(availableSpace.x / 2, availableSpace.y))) {
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5);
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted("hex.welcome.header.start"_lang);
|
ImGui::TextUnformatted("hex.welcome.header.start"_lang);
|
||||||
{
|
{
|
||||||
@ -430,7 +477,7 @@ namespace hex {
|
|||||||
EventManager::post<RequestOpenWindow>("Open Project");
|
EventManager::post<RequestOpenWindow>("Open Project");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 9);
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted("hex.welcome.start.recent"_lang);
|
ImGui::TextUnformatted("hex.welcome.start.recent"_lang);
|
||||||
{
|
{
|
||||||
@ -444,7 +491,17 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
if (!this->m_availableUpdate.empty()) {
|
||||||
|
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5);
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextUnformatted("hex.welcome.header.update"_lang);
|
||||||
|
{
|
||||||
|
if (ImGui::DescriptionButton("hex.welcome.update.title"_lang, hex::format("hex.welcome.update.desc"_lang, this->m_availableUpdate).c_str(), ImVec2(ImGui::GetContentRegionAvail().x * 0.8F, 0)))
|
||||||
|
hex::openWebpage("hex.welcome.update.link"_lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5);
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted("hex.welcome.header.help"_lang);
|
ImGui::TextUnformatted("hex.welcome.header.help"_lang);
|
||||||
{
|
{
|
||||||
@ -452,7 +509,7 @@ namespace hex {
|
|||||||
if (ImGui::BulletHyperlink("hex.welcome.help.gethelp"_lang)) hex::openWebpage("hex.welcome.help.gethelp.link"_lang);
|
if (ImGui::BulletHyperlink("hex.welcome.help.gethelp"_lang)) hex::openWebpage("hex.welcome.help.gethelp.link"_lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5);
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted("hex.welcome.header.plugins"_lang);
|
ImGui::TextUnformatted("hex.welcome.header.plugins"_lang);
|
||||||
{
|
{
|
||||||
@ -464,7 +521,7 @@ namespace hex {
|
|||||||
"No plugins loaded! To use ImHex properly, "
|
"No plugins loaded! To use ImHex properly, "
|
||||||
"make sure at least the builtin plugin is in the /plugins folder next to the executable");
|
"make sure at least the builtin plugin is in the /plugins folder next to the executable");
|
||||||
} else {
|
} else {
|
||||||
if (ImGui::BeginTable("plugins", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY | ImGuiTableFlags_SizingFixedFit, ImVec2((ImGui::GetContentRegionAvail().x * 5) / 6, ImGui::GetTextLineHeightWithSpacing() * 4))) {
|
if (ImGui::BeginTable("plugins", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY | ImGuiTableFlags_SizingFixedFit, ImVec2((ImGui::GetContentRegionAvail().x * 5) / 6, ImGui::GetTextLineHeightWithSpacing() * 5))) {
|
||||||
ImGui::TableSetupScrollFreeze(0, 1);
|
ImGui::TableSetupScrollFreeze(0, 1);
|
||||||
ImGui::TableSetupColumn("hex.welcome.plugins.plugin"_lang);
|
ImGui::TableSetupColumn("hex.welcome.plugins.plugin"_lang);
|
||||||
ImGui::TableSetupColumn("hex.welcome.plugins.author"_lang);
|
ImGui::TableSetupColumn("hex.welcome.plugins.author"_lang);
|
||||||
@ -498,14 +555,14 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::BeginTable("Welcome Right", 1, ImGuiTableFlags_NoBordersInBody, ImVec2(availableSpace.x / 2, availableSpace.y))) {
|
if (ImGui::BeginTable("Welcome Right", 1, ImGuiTableFlags_NoBordersInBody, ImVec2(availableSpace.x / 2, availableSpace.y))) {
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5);
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted("hex.welcome.header.customize"_lang);
|
ImGui::TextUnformatted("hex.welcome.header.customize"_lang);
|
||||||
{
|
{
|
||||||
if (ImGui::DescriptionButton("hex.welcome.customize.settings.title"_lang, "hex.welcome.customize.settings.desc"_lang, ImVec2(ImGui::GetContentRegionAvail().x * 0.8F, 0)))
|
if (ImGui::DescriptionButton("hex.welcome.customize.settings.title"_lang, "hex.welcome.customize.settings.desc"_lang, ImVec2(ImGui::GetContentRegionAvail().x * 0.8F, 0)))
|
||||||
EventManager::post<RequestOpenWindow>("hex.view.settings.title");
|
EventManager::post<RequestOpenWindow>("Settings");
|
||||||
}
|
}
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5);
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted("hex.welcome.header.learn"_lang);
|
ImGui::TextUnformatted("hex.welcome.header.learn"_lang);
|
||||||
{
|
{
|
||||||
@ -519,7 +576,7 @@ namespace hex {
|
|||||||
|
|
||||||
auto extraWelcomeScreenEntries = ContentRegistry::Interface::getWelcomeScreenEntries();
|
auto extraWelcomeScreenEntries = ContentRegistry::Interface::getWelcomeScreenEntries();
|
||||||
if (!extraWelcomeScreenEntries.empty()) {
|
if (!extraWelcomeScreenEntries.empty()) {
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight);
|
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5);
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted("hex.welcome.header.various"_lang);
|
ImGui::TextUnformatted("hex.welcome.header.various"_lang);
|
||||||
{
|
{
|
||||||
@ -556,15 +613,6 @@ namespace hex {
|
|||||||
ImGui::DockBuilderFinish(dockId);
|
ImGui::DockBuilderFinish(dockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::createDirectories() const {
|
|
||||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Patterns)[0]);
|
|
||||||
std::filesystem::create_directories(hex::getPath(ImHexPath::PatternsInclude)[0]);
|
|
||||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Magic)[0]);
|
|
||||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Plugins)[0]);
|
|
||||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Resources)[0]);
|
|
||||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Config)[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::initGLFW() {
|
void Window::initGLFW() {
|
||||||
glfwSetErrorCallback([](int error, const char* desc) {
|
glfwSetErrorCallback([](int error, const char* desc) {
|
||||||
fprintf(stderr, "Glfw Error %d: %s\n", error, desc);
|
fprintf(stderr, "Glfw Error %d: %s\n", error, desc);
|
||||||
@ -626,7 +674,6 @@ namespace hex {
|
|||||||
key = std::toupper(keyName[0]);
|
key = std::toupper(keyName[0]);
|
||||||
|
|
||||||
if (action == GLFW_PRESS) {
|
if (action == GLFW_PRESS) {
|
||||||
Window::s_currShortcut = { key, mods };
|
|
||||||
auto &io = ImGui::GetIO();
|
auto &io = ImGui::GetIO();
|
||||||
io.KeysDown[key] = true;
|
io.KeysDown[key] = true;
|
||||||
io.KeyCtrl = (mods & GLFW_MOD_CONTROL) != 0;
|
io.KeyCtrl = (mods & GLFW_MOD_CONTROL) != 0;
|
||||||
|
@ -24,10 +24,11 @@ target_include_directories(splash PUBLIC include)
|
|||||||
|
|
||||||
add_compile_definitions(IMHEX_FILE_NAME=\"$<TARGET_FILE_NAME:imhex>\")
|
add_compile_definitions(IMHEX_FILE_NAME=\"$<TARGET_FILE_NAME:imhex>\")
|
||||||
set_target_properties(splash PROPERTIES OUTPUT_NAME "imhex")
|
set_target_properties(splash PROPERTIES OUTPUT_NAME "imhex")
|
||||||
|
add_dependencies(splash imhex)
|
||||||
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(splash libstdc++.a libgcc.a libimhex)
|
target_link_libraries(splash libimhex winpthread)
|
||||||
else ()
|
else ()
|
||||||
target_link_libraries(splash libimhex pthread)
|
target_link_libraries(splash libimhex pthread)
|
||||||
endif ()
|
endif ()
|
@ -15,16 +15,17 @@ namespace hex::pre {
|
|||||||
WindowSplash();
|
WindowSplash();
|
||||||
~WindowSplash();
|
~WindowSplash();
|
||||||
|
|
||||||
void loop();
|
bool loop();
|
||||||
|
|
||||||
void addStartupTask(const std::function<bool()> &task) {
|
void addStartupTask(std::string_view taskName, const std::function<bool()> &task) {
|
||||||
this->m_tasks.push_back(task);
|
this->m_tasks.emplace_back(taskName, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLFWwindow *m_window;
|
GLFWwindow *m_window;
|
||||||
std::mutex m_progressMutex;
|
std::mutex m_progressMutex;
|
||||||
float m_progress;
|
float m_progress;
|
||||||
|
std::string m_currTaskName;
|
||||||
|
|
||||||
void initGLFW();
|
void initGLFW();
|
||||||
void initImGui();
|
void initImGui();
|
||||||
@ -34,7 +35,7 @@ namespace hex::pre {
|
|||||||
|
|
||||||
std::future<bool> processTasksAsync();
|
std::future<bool> processTasksAsync();
|
||||||
|
|
||||||
std::vector<std::function<bool()>> m_tasks;
|
std::vector<std::pair<std::string, std::function<bool()>>> m_tasks;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -3,16 +3,22 @@
|
|||||||
#include "splash_window.hpp"
|
#include "splash_window.hpp"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <hex/helpers/net.hpp>
|
||||||
|
#include <hex/helpers/utils.hpp>
|
||||||
|
|
||||||
using namespace std::literals::chrono_literals;
|
using namespace std::literals::chrono_literals;
|
||||||
|
|
||||||
constexpr auto ImHexPath = IMHEX_FILE_NAME;
|
constexpr auto ImHexPath = IMHEX_FILE_NAME;
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
const char *filePath = nullptr;
|
|
||||||
bool skipSplash = false;
|
bool skipSplash = false;
|
||||||
|
std::string fileToOpen;
|
||||||
|
std::vector<std::string> imHexArgs;
|
||||||
|
|
||||||
// Handle command line arguments
|
// Handle command line arguments
|
||||||
{
|
{
|
||||||
@ -20,9 +26,9 @@ int main(int argc, char **argv) {
|
|||||||
// No optional arguments used, use default
|
// No optional arguments used, use default
|
||||||
} else if (argc == 2) {
|
} else if (argc == 2) {
|
||||||
if (argv[1] == std::string("--no-splash")) skipSplash = true;
|
if (argv[1] == std::string("--no-splash")) skipSplash = true;
|
||||||
else filePath = argv[1];
|
else fileToOpen = argv[1];
|
||||||
} else if (argc == 3) {
|
} else if (argc == 3) {
|
||||||
filePath = argv[1];
|
fileToOpen = argv[1];
|
||||||
|
|
||||||
if (argv[2] == std::string("--no-splash")) skipSplash = true;
|
if (argv[2] == std::string("--no-splash")) skipSplash = true;
|
||||||
else {
|
else {
|
||||||
@ -35,19 +41,54 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imHexArgs.emplace_back("git-hash=" GIT_COMMIT_HASH);
|
||||||
|
imHexArgs.emplace_back("git-branch=" GIT_BRANCH);
|
||||||
|
|
||||||
if (!skipSplash) {
|
if (!skipSplash) {
|
||||||
hex::pre::WindowSplash window;
|
hex::pre::WindowSplash window;
|
||||||
|
|
||||||
/* Dummy task */
|
window.addStartupTask("Checking for updates...", [&]{
|
||||||
window.addStartupTask([]{ std::this_thread::sleep_for(1s); return true; });
|
hex::Net net;
|
||||||
|
|
||||||
window.loop();
|
auto releases = net.getJson("https://api.github.com/repos/WerWolv/ImHex/releases/latest");
|
||||||
|
if (releases.code != 200)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!releases.response.contains("tag_name") || !releases.response["tag_name"].is_string())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto currVersion = "v" + std::string(IMHEX_VERSION).substr(0, 5);
|
||||||
|
auto latestVersion = releases.response["tag_name"].get<std::string_view>();
|
||||||
|
|
||||||
|
if (latestVersion != currVersion)
|
||||||
|
imHexArgs.push_back(std::string("update=") + latestVersion.data());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addStartupTask("Creating directories...", []{
|
||||||
|
std::filesystem::create_directories(hex::getPath(hex::ImHexPath::Patterns)[0]);
|
||||||
|
std::filesystem::create_directories(hex::getPath(hex::ImHexPath::PatternsInclude)[0]);
|
||||||
|
std::filesystem::create_directories(hex::getPath(hex::ImHexPath::Magic)[0]);
|
||||||
|
std::filesystem::create_directories(hex::getPath(hex::ImHexPath::Plugins)[0]);
|
||||||
|
std::filesystem::create_directories(hex::getPath(hex::ImHexPath::Resources)[0]);
|
||||||
|
std::filesystem::create_directories(hex::getPath(hex::ImHexPath::Config)[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!window.loop())
|
||||||
|
imHexArgs.emplace_back("tasks-failed");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
imHexArgs.emplace_back("splash-skipped");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Launch ImHex
|
// Launch ImHex
|
||||||
if (filePath == nullptr)
|
std::string packedArgs = "--args=" + hex::combineStrings(imHexArgs, "|");
|
||||||
return execl(ImHexPath, ImHexPath, GIT_COMMIT_HASH, nullptr);
|
|
||||||
|
if (fileToOpen.empty())
|
||||||
|
return execl(ImHexPath, ImHexPath, packedArgs.c_str(), nullptr);
|
||||||
else
|
else
|
||||||
return execl(ImHexPath, ImHexPath, filePath, GIT_COMMIT_HASH, nullptr);
|
return execl(ImHexPath, ImHexPath, fileToOpen.c_str(), packedArgs.c_str(), nullptr);
|
||||||
}
|
}
|
@ -48,19 +48,17 @@ namespace hex::pre {
|
|||||||
this->deinitGLFW();
|
this->deinitGLFW();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawSplashScreen(ImTextureID splashTexture, u32 width, u32 height, float progress) {
|
|
||||||
auto drawList = ImGui::GetOverlayDrawList();
|
|
||||||
|
|
||||||
drawList->AddImage(splashTexture, ImVec2(0, 0), ImVec2(width, height));
|
|
||||||
drawList->AddText(ImVec2(20, 120), 0xFFFFFFFF, hex::format("WerWolv 2020 - {0}\n{1} : {2}@{3}", __DATE__ + 7, IMHEX_VERSION, GIT_COMMIT_HASH, GIT_BRANCH).c_str());
|
|
||||||
drawList->AddRectFilled(ImVec2(0, height - 5), ImVec2(width * progress, height), 0xFFFFFFFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::future<bool> WindowSplash::processTasksAsync() {
|
std::future<bool> WindowSplash::processTasksAsync() {
|
||||||
return std::async(std::launch::async, [this] {
|
return std::async(std::launch::async, [this] {
|
||||||
bool status = true;
|
bool status = true;
|
||||||
|
|
||||||
for (const auto &task : this->m_tasks) {
|
for (const auto &[name, task] : this->m_tasks) {
|
||||||
|
{
|
||||||
|
std::lock_guard guard(this->m_progressMutex);
|
||||||
|
this->m_currTaskName = name;
|
||||||
|
}
|
||||||
|
|
||||||
status = status && task();
|
status = status && task();
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -76,12 +74,22 @@ namespace hex::pre {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSplash::loop() {
|
bool WindowSplash::loop() {
|
||||||
auto [splashTexture, splashWidth, splashHeight] = ImGui::LoadImageFromPath((hex::getPath(hex::ImHexPath::Resources)[0] + "/splash.png").c_str());
|
ImTextureID splashTexture;
|
||||||
|
u32 splashWidth, splashHeight;
|
||||||
|
|
||||||
|
for (const auto &path : hex::getPath(hex::ImHexPath::Resources)) {
|
||||||
|
std::tie(splashTexture, splashWidth, splashHeight) = ImGui::LoadImageFromPath((path + "/splash.png").c_str());
|
||||||
|
if (splashTexture != nullptr)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (splashTexture == nullptr)
|
if (splashTexture == nullptr)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
ON_SCOPE_EXIT { ImGui::UnloadImage(splashTexture); };
|
||||||
|
|
||||||
|
|
||||||
auto done = processTasksAsync();
|
auto done = processTasksAsync();
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(this->m_window)) {
|
while (!glfwWindowShouldClose(this->m_window)) {
|
||||||
@ -93,7 +101,13 @@ namespace hex::pre {
|
|||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard guard(this->m_progressMutex);
|
std::lock_guard guard(this->m_progressMutex);
|
||||||
drawSplashScreen(splashTexture, splashWidth, splashHeight, this->m_progress);
|
|
||||||
|
auto drawList = ImGui::GetOverlayDrawList();
|
||||||
|
|
||||||
|
drawList->AddImage(splashTexture, ImVec2(0, 0), ImVec2(splashWidth, splashHeight));
|
||||||
|
drawList->AddText(ImVec2(15, 120), ImColor(0xFF, 0xFF, 0xFF, 0xFF), hex::format("WerWolv 2020 - {0}\n{1} : {2}@{3}", &__DATE__[7], IMHEX_VERSION, GIT_BRANCH, GIT_COMMIT_HASH).c_str());
|
||||||
|
drawList->AddRectFilled(ImVec2(0, splashHeight - 5), ImVec2(splashWidth * this->m_progress, splashHeight), 0xFFFFFFFF);
|
||||||
|
drawList->AddText(ImVec2(15, splashHeight - 22), ImColor(0xFF, 0xFF, 0xFF, 0xFF), this->m_currTaskName.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
@ -107,13 +121,11 @@ namespace hex::pre {
|
|||||||
glfwSwapBuffers(this->m_window);
|
glfwSwapBuffers(this->m_window);
|
||||||
|
|
||||||
if (done.wait_for(0s) == std::future_status::ready) {
|
if (done.wait_for(0s) == std::future_status::ready) {
|
||||||
if (!done.get()) printf("One or more tasks failed to execute!");
|
return done.get();
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::UnloadImage(splashTexture);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSplash::initGLFW() {
|
void WindowSplash::initGLFW() {
|
||||||
@ -127,6 +139,7 @@ namespace hex::pre {
|
|||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||||
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
|
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
|
||||||
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
|
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
|
||||||
glfwWindowHint(GLFW_FLOATING, GLFW_TRUE);
|
glfwWindowHint(GLFW_FLOATING, GLFW_TRUE);
|
||||||
|
Loading…
Reference in New Issue
Block a user