mirror of https://github.com/AxioDL/metaforce.git
Added hecl_startup.blend
This commit is contained in:
parent
fec49c542e
commit
7c31740dbb
|
@ -33,14 +33,34 @@ extern "C" size_t HECL_BLENDERSHELL_SZ;
|
||||||
extern "C" uint8_t HECL_ADDON[];
|
extern "C" uint8_t HECL_ADDON[];
|
||||||
extern "C" size_t HECL_ADDON_SZ;
|
extern "C" size_t HECL_ADDON_SZ;
|
||||||
|
|
||||||
static bool InstallAddon(const SystemChar* path)
|
extern "C" uint8_t HECL_STARTUP[];
|
||||||
|
extern "C" size_t HECL_STARTUP_SZ;
|
||||||
|
|
||||||
|
static void InstallBlendershell(const SystemChar* path)
|
||||||
|
{
|
||||||
|
FILE* fp = HECL::Fopen(path, _S("w"));
|
||||||
|
if (!fp)
|
||||||
|
BlenderLog.report(LogVisor::FatalError, _S("unable to open %s for writing"), path);
|
||||||
|
fwrite(HECL_BLENDERSHELL, 1, HECL_BLENDERSHELL_SZ, fp);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void InstallAddon(const SystemChar* path)
|
||||||
{
|
{
|
||||||
FILE* fp = HECL::Fopen(path, _S("wb"));
|
FILE* fp = HECL::Fopen(path, _S("wb"));
|
||||||
if (!fp)
|
if (!fp)
|
||||||
BlenderLog.report(LogVisor::FatalError, _S("Unable to install blender addon at '%s'"), path);
|
BlenderLog.report(LogVisor::FatalError, _S("Unable to install blender addon at '%s'"), path);
|
||||||
fwrite(HECL_ADDON, 1, HECL_ADDON_SZ, fp);
|
fwrite(HECL_ADDON, 1, HECL_ADDON_SZ, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
static void InstallStartup(const char* path)
|
||||||
|
{
|
||||||
|
FILE* fp = fopen(path, "wb");
|
||||||
|
if (!fp)
|
||||||
|
BlenderLog.report(LogVisor::FatalError, "Unable to place hecl_startup.blend at '%s'", path);
|
||||||
|
fwrite(HECL_STARTUP, 1, HECL_STARTUP_SZ, fp);
|
||||||
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BlenderConnection::_readLine(char* buf, size_t bufSz)
|
size_t BlenderConnection::_readLine(char* buf, size_t bufSz)
|
||||||
|
@ -137,16 +157,17 @@ BlenderConnection::BlenderConnection(bool silenceBlender)
|
||||||
#endif
|
#endif
|
||||||
HECL::SystemString blenderShellPath(TMPDIR);
|
HECL::SystemString blenderShellPath(TMPDIR);
|
||||||
blenderShellPath += _S("/hecl_blendershell.py");
|
blenderShellPath += _S("/hecl_blendershell.py");
|
||||||
FILE* fp = HECL::Fopen(blenderShellPath.c_str(), _S("w"));
|
InstallBlendershell(blenderShellPath.c_str());
|
||||||
if (!fp)
|
|
||||||
BlenderLog.report(LogVisor::FatalError, _S("unable to open %s for writing"), blenderShellPath.c_str());
|
|
||||||
fwrite(HECL_BLENDERSHELL, 1, HECL_BLENDERSHELL_SZ, fp);
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
HECL::SystemString blenderAddonPath(TMPDIR);
|
HECL::SystemString blenderAddonPath(TMPDIR);
|
||||||
blenderAddonPath += _S("/hecl_blenderaddon.zip");
|
blenderAddonPath += _S("/hecl_blenderaddon.zip");
|
||||||
InstallAddon(blenderAddonPath.c_str());
|
InstallAddon(blenderAddonPath.c_str());
|
||||||
|
|
||||||
|
HECL::SystemString blenderStartupPath(TMPDIR);
|
||||||
|
m_startupBlend = TMPDIR;
|
||||||
|
m_startupBlend += _S("/hecl_startup.blend");
|
||||||
|
InstallStartup(m_startupBlend.c_str());
|
||||||
|
|
||||||
int installAttempt = 0;
|
int installAttempt = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -321,7 +342,7 @@ bool BlenderConnection::createBlend(const SystemString& path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HECL::SystemUTF8View pathView(path);
|
HECL::SystemUTF8View pathView(path);
|
||||||
_writeLine(("CREATE \"" + pathView.str() + "\"").c_str());
|
_writeLine(("CREATE \"" + pathView.str() + "\" \"" + m_startupBlend + "\"").c_str());
|
||||||
char lineBuf[256];
|
char lineBuf[256];
|
||||||
_readLine(lineBuf, sizeof(lineBuf));
|
_readLine(lineBuf, sizeof(lineBuf));
|
||||||
if (!strcmp(lineBuf, "FINISHED"))
|
if (!strcmp(lineBuf, "FINISHED"))
|
||||||
|
|
|
@ -34,6 +34,7 @@ class BlenderConnection
|
||||||
int m_readpipe[2];
|
int m_readpipe[2];
|
||||||
int m_writepipe[2];
|
int m_writepipe[2];
|
||||||
SystemString m_loadedBlend;
|
SystemString m_loadedBlend;
|
||||||
|
std::string m_startupBlend;
|
||||||
size_t _readLine(char* buf, size_t bufSz);
|
size_t _readLine(char* buf, size_t bufSz);
|
||||||
size_t _writeLine(const char* buf);
|
size_t _writeLine(const char* buf);
|
||||||
size_t _readBuf(char* buf, size_t len);
|
size_t _readBuf(char* buf, size_t len);
|
||||||
|
|
|
@ -18,6 +18,7 @@ add_custom_command(OUTPUT hecl.zip DEPENDS ${PY_SOURCES}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
COMMENT "Generating addon package")
|
COMMENT "Generating addon package")
|
||||||
bintoc(hecl_addon.c "${CMAKE_CURRENT_BINARY_DIR}/hecl.zip" HECL_ADDON)
|
bintoc(hecl_addon.c "${CMAKE_CURRENT_BINARY_DIR}/hecl.zip" HECL_ADDON)
|
||||||
|
bintoc(hecl_startup.c hecl_startup.blend HECL_STARTUP)
|
||||||
|
|
||||||
add_library(HECLBlender
|
add_library(HECLBlender
|
||||||
BlenderConnection.cpp
|
BlenderConnection.cpp
|
||||||
|
@ -27,4 +28,5 @@ add_library(HECLBlender
|
||||||
zip_package.py
|
zip_package.py
|
||||||
hecl.zip
|
hecl.zip
|
||||||
hecl_addon.c
|
hecl_addon.c
|
||||||
|
hecl_startup.c
|
||||||
${PY_SOURCES})
|
${PY_SOURCES})
|
||||||
|
|
|
@ -126,6 +126,9 @@ while True:
|
||||||
writepipeline(b'CANCELLED')
|
writepipeline(b'CANCELLED')
|
||||||
|
|
||||||
elif cmdargs[0] == 'CREATE':
|
elif cmdargs[0] == 'CREATE':
|
||||||
|
if len(cmdargs) >= 3:
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=cmdargs[2])
|
||||||
|
else:
|
||||||
bpy.ops.wm.read_homefile()
|
bpy.ops.wm.read_homefile()
|
||||||
bpy.context.user_preferences.filepaths.save_version = 0
|
bpy.context.user_preferences.filepaths.save_version = 0
|
||||||
if 'FINISHED' in bpy.ops.wm.save_as_mainfile(filepath=cmdargs[1]):
|
if 'FINISHED' in bpy.ops.wm.save_as_mainfile(filepath=cmdargs[1]):
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue