def watch_patch(mode): state.compileproc.wait() log.print_progress(100) # result = state.compileproc.poll() state.compileproc = None state.compileproc_finished = True on_compiled(mode)
def watch_compile(mode): state.compileproc.wait() log.print_progress(100) if state.compileproc == None: ## return result = state.compileproc.poll() state.compileproc = None state.compileproc_finished = True if result == 0: bpy.data.worlds['Arm'].arm_recompile = False state.compileproc_success = True on_compiled(mode) else: state.compileproc_success = False log.print_info('Build failed, check console')
def build_project(is_play=False, is_publish=False, is_render=False, is_render_anim=False, in_viewport=False): wrd = bpy.data.worlds['Arm'] state.is_render = is_render state.is_render_anim = is_render_anim # Clear flag state.in_viewport = False # Save blend if arm.utils.get_save_on_build() and not state.krom_running: bpy.ops.wm.save_mainfile() log.clear() # Set camera in active scene active_scene = arm.utils.get_active_scene() if active_scene.camera == None: for o in active_scene.objects: if o.type == 'CAMERA': active_scene.camera = o break # Get paths sdk_path = arm.utils.get_sdk_path() raw_shaders_path = sdk_path + '/armory/Shaders/' # Set dir fp = arm.utils.get_fp() os.chdir(fp) # Create directories sources_path = 'Sources/' + arm.utils.safestr(wrd.arm_project_package) if not os.path.exists(sources_path): os.makedirs(sources_path) # Save external scripts edited inside Blender write_texts = False for text in bpy.data.texts: if text.filepath != '' and text.is_dirty: write_texts = True break if write_texts: area = bpy.context.area old_type = area.type area.type = 'TEXT_EDITOR' for text in bpy.data.texts: if text.filepath != '' and text.is_dirty and os.path.isfile( text.filepath): area.spaces[0].text = text bpy.ops.text.save() area.type = old_type # Save internal Haxe scripts for text in bpy.data.texts: if text.filepath == '' and text.name[-3:] == '.hx': with open( 'Sources/' + arm.utils.safestr(wrd.arm_project_package) + '/' + text.name, 'w') as f: f.write(text.as_string()) # Export data export_data(fp, sdk_path, is_play=is_play, is_publish=is_publish, in_viewport=in_viewport) if state.target == 'html5': w, h = arm.utils.get_render_resolution(arm.utils.get_active_scene()) write_data.write_indexhtml(w, h) # Bundle files from include dir if os.path.isdir('include'): for fn in glob.iglob(os.path.join('include', '**'), recursive=False): shutil.copy( fn, arm.utils.build_dir() + '/html5/' + os.path.basename(fn)) if state.playproc == None: log.print_progress(50)
def build_project(is_play=False, is_publish=False, in_viewport=False, target=None): wrd = bpy.data.worlds['Arm'] # Set target if target == None: state.target = wrd.arm_project_target.lower() # Clear flag state.in_viewport = False # Save blend if arm.utils.get_save_on_build(): bpy.ops.wm.save_mainfile() log.clear() # Set camera in active scene active_scene = bpy.context.screen.scene if wrd.arm_play_active_scene else bpy.data.scenes[wrd.arm_project_scene] if active_scene.camera == None: for o in active_scene.objects: if o.type == 'CAMERA': active_scene.camera = o break # Get paths sdk_path = arm.utils.get_sdk_path() raw_shaders_path = sdk_path + '/armory/Shaders/' # Set dir fp = arm.utils.get_fp() os.chdir(fp) # Create directories sources_path = 'Sources/' + wrd.arm_project_package if not os.path.exists(sources_path): os.makedirs(sources_path) # Compile path tracer shaders if len(bpy.data.cameras) > 0 and bpy.data.cameras[0].renderpath_path == 'pathtrace_path': path_tracer.compile(raw_shaders_path + 'pt_trace_pass/pt_trace_pass.frag.glsl') # Save external scripts edited inside Blender write_texts = False for text in bpy.data.texts: if text.filepath != '' and text.is_dirty: write_texts = True break if write_texts: area = bpy.context.area old_type = area.type area.type = 'TEXT_EDITOR' for text in bpy.data.texts: if text.filepath != '' and text.is_dirty and os.path.isfile(text.filepath): area.spaces[0].text = text bpy.ops.text.save() area.type = old_type # Save internal Haxe scripts for text in bpy.data.texts: if text.filepath == '' and text.name[-3:] == '.hx': with open('Sources/' + bpy.data.worlds['Arm'].arm_project_package + '/' + text.name, 'w') as f: f.write(text.as_string()) # Export data export_data(fp, sdk_path, is_play=is_play, is_publish=is_publish, in_viewport=in_viewport) if state.playproc == None: log.print_progress(50)