diff --git a/hecl/CMakeLists.txt b/hecl/CMakeLists.txt index 85018ec90..9c89f5e91 100644 --- a/hecl/CMakeLists.txt +++ b/hecl/CMakeLists.txt @@ -12,6 +12,7 @@ set(LOG_VISOR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/LogVisor/include) set(ANGELSCRIPT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/AngelScript/angelscript/include) set(SQUISH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/libSquish) add_definitions(-DAS_USE_NAMESPACE=1 -DAS_NO_EXCEPTIONS=1) +add_subdirectory(bintoc) add_subdirectory(extern) include_directories(include ${LOG_VISOR_INCLUDE_DIR} ${ATHENA_INCLUDE_DIR} ${ANGELSCRIPT_INCLUDE_DIR}) add_subdirectory(lib) diff --git a/hecl/bintoc/CMakeLists.txt b/hecl/bintoc/CMakeLists.txt new file mode 100644 index 000000000..0a26da063 --- /dev/null +++ b/hecl/bintoc/CMakeLists.txt @@ -0,0 +1,6 @@ +add_executable(bintoc bintoc.c) +macro(bintoc out in sym) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${out} + COMMAND $ ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${in} ${CMAKE_CURRENT_BINARY_DIR}/${out} ${sym} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${in}) +endmacro() diff --git a/hecl/bintoc/bintoc.c b/hecl/bintoc/bintoc.c new file mode 100644 index 000000000..a5ae59e37 --- /dev/null +++ b/hecl/bintoc/bintoc.c @@ -0,0 +1,39 @@ +#include +#include + +int main(int argc, char** argv) +{ + if (argc < 4) + { + fprintf(stderr, "Usage: bintoc \n"); + return 1; + } + FILE* fin = fopen(argv[1], "rb"); + if (!fin) + { + fprintf(stderr, "Unable to open %s for reading\n", argv[1]); + return 1; + } + FILE* fout = fopen(argv[2], "wb"); + if (!fout) + { + fprintf(stderr, "Unable to open %s for writing\n", argv[2]); + return 1; + } + fprintf(fout, "#include \n#include \nconst uint8_t %s[] =\n{\n", argv[3]); + size_t totalSz = 0; + size_t readSz; + uint8_t buf[32]; + while ((readSz = fread(buf, 1, 32, fin))) + { + fprintf(fout, " "); + totalSz += readSz; + for (int b=0 ; b bufGetter, const std::string& expectedType, const std::string& platform, diff --git a/hecl/blender/BlenderConnection.hpp b/hecl/blender/BlenderConnection.hpp index 27a527a5c..c669ba466 100644 --- a/hecl/blender/BlenderConnection.hpp +++ b/hecl/blender/BlenderConnection.hpp @@ -46,6 +46,7 @@ public: bool createBlend(const SystemString& path); bool openBlend(const SystemString& path); + bool saveBlend(); enum CookPlatform { CP_MODERN = 0, @@ -120,6 +121,7 @@ public: free(result); va_end(ap); } + void linkBlend(const SystemString& target, const std::string& objName, bool link=true); }; inline PyOutStream beginPythonOut() { diff --git a/hecl/blender/CMakeLists.txt b/hecl/blender/CMakeLists.txt index 650036474..32a9d8410 100644 --- a/hecl/blender/CMakeLists.txt +++ b/hecl/blender/CMakeLists.txt @@ -11,8 +11,11 @@ list(APPEND PY_SOURCES addon/sact/SACTEvent.py addon/sact/SACTSubtype.py) +bintoc(blendershell.c blendershell.py BLENDERSHELL) + add_library(HECLBlender BlenderConnection.cpp BlenderConnection.hpp blendershell.py + blendershell.c ${PY_SOURCES}) diff --git a/hecl/blender/blendershell.py b/hecl/blender/blendershell.py index e95dd579c..798c7f2ab 100644 --- a/hecl/blender/blendershell.py +++ b/hecl/blender/blendershell.py @@ -1,4 +1,4 @@ -import bpy, sys, os, re +import bpy, sys, os, re, code ARGS_PATTERN = re.compile(r'''(?:"([^"]+)"|'([^']+)'|(\S+))''') @@ -71,18 +71,43 @@ while True: else: writepipeline(b'CANCELLED') + elif cmdargs[0] == 'SAVE': + bpy.context.user_preferences.filepaths.save_version = 0 + if 'FINISHED' in bpy.ops.wm.save_mainfile(check_existing=False): + writepipeline(b'FINISHED') + else: + writepipeline(b'CANCELLED') + elif cmdargs[0] == 'PYBEGIN': writepipeline(b'READY') globals = dict() - locals = dict() + compbuf = str() + prev_leading_spaces = 0 while True: try: line = readpipeline() if line == b'PYEND': writepipeline(b'DONE') break - co = compile(line+b'\n', '', 'single') - exec(co, globals, locals) + linestr = line.decode() + if linestr.isspace() or not len(linestr): + writepipeline(b'OK') + continue + leading_spaces = len(linestr) - len(linestr.lstrip()) + if prev_leading_spaces and not leading_spaces: + compbuf += '\n' + co = code.compile_command(compbuf, filename='') + if co is not None: + exec(co, globals) + compbuf = str() + prev_leading_spaces = leading_spaces + if len(compbuf): + compbuf += '\n' + compbuf += linestr + co = code.compile_command(compbuf, filename='') + if co is not None: + exec(co, globals) + compbuf = str() except Exception as e: writepipeline(b'EXCEPTION') raise diff --git a/hecl/extern/Athena b/hecl/extern/Athena index 3d220841c..f06afb429 160000 --- a/hecl/extern/Athena +++ b/hecl/extern/Athena @@ -1 +1 @@ -Subproject commit 3d220841c01037af77b5299ea029144e3795242f +Subproject commit f06afb429ccddad1be6878d1b9d6ffebb245909b diff --git a/hecl/extern/RetroCommon b/hecl/extern/RetroCommon index 73185fc32..8e89d7efd 160000 --- a/hecl/extern/RetroCommon +++ b/hecl/extern/RetroCommon @@ -1 +1 @@ -Subproject commit 73185fc32cfa438b54c9336ed4627135c1011d9d +Subproject commit 8e89d7efd060d756bf756c09c0d285eb944f6610 diff --git a/hecl/include/HECL/HECL.hpp b/hecl/include/HECL/HECL.hpp index 41309eb08..1906f9d5e 100644 --- a/hecl/include/HECL/HECL.hpp +++ b/hecl/include/HECL/HECL.hpp @@ -498,6 +498,19 @@ public: */ void getGlobResults(std::vector& outPaths) const; + /** + * @brief Count how many directory levels deep in project path is + * @return Level Count + */ + inline size_t levelCount() const + { + size_t count = 0; + for (SystemChar ch : m_relPath) + if (ch == _S('/') || ch == _S('\\')) + ++count; + return count; + } + /** * @brief Create directory at path *