1
0
mirror of synced 2024-11-12 02:00:52 +01:00

impr: Restructure and cleanup script loader and templates

This commit is contained in:
WerWolv 2024-03-24 15:51:05 +01:00
parent ccb78246ab
commit 8b9d09aa97
10 changed files with 36 additions and 11 deletions

View File

@ -27,9 +27,13 @@ find_package(Python3 COMPONENTS Interpreter Development.Embed)
if (Python3_FOUND)
set(IMHEX_PYTHON_SCRIPT_SUPPORT ON)
add_romfs_resource(${CMAKE_CURRENT_SOURCE_DIR}/support/python/imhex.py "python/imhex.py")
get_target_property(PYTHON_LIBRARY Python3::Python IMPORTED_LOCATION)
get_target_property(PYTHON_INCLUDE_DIR Python3::Python INTERFACE_INCLUDE_DIRECTORIES)
endif()
add_subdirectory(support/c)
add_imhex_plugin(
NAME
@ -37,22 +41,20 @@ add_imhex_plugin(
SOURCES
source/plugin_script_loader.cpp
source/script_api/v1/mem.cpp
source/script_api/v1/bookmarks.cpp
source/script_api/v1/ui.cpp
source/script_api/v1/logger.cpp
INCLUDES
include
LIBRARIES
c_api
fonts
ui
FEATURES
DOTNET
PYTHON
)
if (IMHEX_DOTNET_SCRIPT_SUPPORT)
message(STATUS "Enabling .NET Scripting support!")
@ -77,9 +79,6 @@ if (IMHEX_PYTHON_SCRIPT_SUPPORT)
source/loaders/python/library_wrapper.cpp
)
get_target_property(PYTHON_LIBRARY Python3::Python IMPORTED_LOCATION)
get_target_property(PYTHON_INCLUDE_DIR Python3::Python INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(script_loader PRIVATE ${PYTHON_INCLUDE_DIR})
target_compile_definitions(script_loader PRIVATE PYTHON_LIBRARY_PATH="${PYTHON_LIBRARY}")
enable_plugin_feature(PYTHON)

View File

@ -0,0 +1,14 @@
project(c_api)
add_library(c_api OBJECT
source/script_api/v1/bookmarks.cpp
source/script_api/v1/logger.cpp
source/script_api/v1/mem.cpp
source/script_api/v1/ui.cpp
)
target_include_directories(c_api PUBLIC
include
)
target_link_libraries(c_api PRIVATE libimhex ui)
target_compile_definitions(c_api PRIVATE IMHEX_PROJECT_NAME="Script")

View File

@ -1,5 +1,4 @@
using ImHex;
using ImGuiNET;
class Script {

View File

@ -6,6 +6,7 @@ from abc import ABC, abstractmethod
_script_loader = ctypes.CDLL("Script Loader", ctypes.DEFAULT_MODE, int(__script_loader__))
_callback_refs = []
class Color:
def __init__(self, r: int, g: int, b: int, a: int):
self.r = r
@ -16,6 +17,7 @@ class Color:
def to_int(self):
return (self.a << 24) | (self.b << 16) | (self.g << 8) | self.r
class UI:
@staticmethod
def show_message_box(message: str):

View File

@ -0,0 +1,11 @@
import imhex
# ImHex executes the entire script when it's being loaded and only adds it to the
# Run Script menu if there is a main function.
def main():
"""
This is the main function that will be called when the script is executed
"""
pass