2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 02:27:43 +00:00

Windows fixes for refactor

This commit is contained in:
Jack Andersen
2019-05-09 18:07:48 -10:00
parent 92e2c03a01
commit f596cbff83
13 changed files with 30 additions and 2644 deletions

View File

@@ -2,10 +2,15 @@ import bpy, sys, os, re, struct, traceback
ARGS_PATTERN = re.compile(r'''(?:"([^"]+)"|'([^']+)'|(\S+))''')
# Background mode seems to require quit() in some 2.80 builds
def _quitblender():
bpy.ops.wm.quit_blender()
quit()
# Extract pipe file descriptors from arguments
print('HECL Blender Launch', sys.argv)
if '--' not in sys.argv:
bpy.ops.wm.quit_blender()
_quitblender()
args = sys.argv[sys.argv.index('--')+1:]
readfd = int(args[0])
writefd = int(args[1])
@@ -29,7 +34,7 @@ def readpipestr():
read_bytes = os.read(readfd, 4)
if len(read_bytes) != 4:
print('HECL connection lost or desynchronized')
bpy.ops.wm.quit_blender()
_quitblender()
read_len = struct.unpack('I', read_bytes)[0]
return os.read(readfd, read_len)
@@ -44,7 +49,7 @@ def writepipebuf(linebytes):
def quitblender():
writepipestr(b'QUITTING')
bpy.ops.wm.quit_blender()
_quitblender()
class PathHasher:
def hashpath32(self, path):
@@ -62,6 +67,11 @@ class PathHasher:
return int(read_str[0:16], 16)
return 0
# Ensure Blender 2.8 is being used
if bpy.app.version < (2, 80, 0):
writepipestr(b'NOT280')
_quitblender()
# If there's a third argument, use it as the .zip path containing the addon
did_install = False
if len(args) >= 4 and args[3] != 'SKIPINSTALL':
@@ -80,12 +90,12 @@ try:
import hecl
except:
writepipestr(b'NOADDON')
bpy.ops.wm.quit_blender()
_quitblender()
# Quit if just installed
if did_install:
writepipestr(b'ADDONINSTALLED')
bpy.ops.wm.quit_blender()
_quitblender()
# Intro handshake
writepipestr(b'READY')
@@ -108,7 +118,7 @@ def read_cmdargs():
cmdline = readpipestr()
if cmdline == b'':
print('HECL connection lost')
bpy.ops.wm.quit_blender()
_quitblender()
cmdargs = []
for match in ARGS_PATTERN.finditer(cmdline.decode()):
cmdargs.append(match.group(match.lastindex))