2016-09-12 02:24:20 +02:00
|
|
|
# Embedded player in Armory Space
|
|
|
|
import bpy
|
|
|
|
from bpy.types import Header
|
|
|
|
from bpy.app.translations import contexts as i18n_contexts
|
2017-03-15 12:30:14 +01:00
|
|
|
import arm.utils
|
|
|
|
import arm.make as make
|
|
|
|
import arm.make_state as state
|
|
|
|
import arm.log as log
|
2016-09-12 02:24:20 +02:00
|
|
|
|
2016-10-19 13:28:06 +02:00
|
|
|
class ArmorySpaceHeader(Header):
|
|
|
|
bl_space_type = 'VIEW_ARMORY'
|
2016-09-12 20:12:13 +02:00
|
|
|
|
2016-09-12 02:24:20 +02:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
view = context.space_data
|
|
|
|
obj = context.active_object
|
|
|
|
toolsettings = context.tool_settings
|
|
|
|
|
|
|
|
row = layout.row(align=True)
|
2016-11-20 18:04:37 +01:00
|
|
|
row.template_header()
|
2016-09-12 02:24:20 +02:00
|
|
|
row.operator('arm.space_stop', icon='MESH_PLANE')
|
2016-10-19 17:46:13 +02:00
|
|
|
if state.is_paused:
|
2016-09-12 20:12:13 +02:00
|
|
|
row.operator('arm.space_resume', icon="PLAY")
|
|
|
|
else:
|
|
|
|
row.operator('arm.space_pause', icon="PAUSE")
|
|
|
|
|
2017-03-15 12:30:14 +01:00
|
|
|
layout.label(log.header_info_text)
|
2016-09-12 02:24:20 +02:00
|
|
|
|
|
|
|
class ArmorySpaceStopButton(bpy.types.Operator):
|
2016-09-23 00:34:42 +02:00
|
|
|
'''Switch back to 3D view'''
|
2016-09-12 02:24:20 +02:00
|
|
|
bl_idname = 'arm.space_stop'
|
|
|
|
bl_label = 'Stop'
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
area = bpy.context.area
|
2016-09-23 00:34:42 +02:00
|
|
|
if area == None:
|
2016-10-19 13:28:06 +02:00
|
|
|
area = state.play_area
|
2016-09-12 02:24:20 +02:00
|
|
|
area.type = 'VIEW_3D'
|
2016-10-19 17:46:13 +02:00
|
|
|
state.is_paused = False
|
|
|
|
log.clear()
|
2016-09-12 20:12:13 +02:00
|
|
|
return{'FINISHED'}
|
|
|
|
|
|
|
|
class ArmorySpacePauseButton(bpy.types.Operator):
|
2016-09-23 00:34:42 +02:00
|
|
|
'''Pause rendering'''
|
2016-09-12 20:12:13 +02:00
|
|
|
bl_idname = 'arm.space_pause'
|
|
|
|
bl_label = 'Pause'
|
|
|
|
|
|
|
|
def execute(self, context):
|
2016-10-19 17:46:13 +02:00
|
|
|
state.is_paused = True
|
2016-09-12 20:12:13 +02:00
|
|
|
return{'FINISHED'}
|
|
|
|
|
|
|
|
class ArmorySpaceResumeButton(bpy.types.Operator):
|
2016-09-23 00:34:42 +02:00
|
|
|
'''Resume rendering'''
|
2016-09-12 20:12:13 +02:00
|
|
|
bl_idname = 'arm.space_resume'
|
|
|
|
bl_label = 'Resume'
|
|
|
|
|
|
|
|
def execute(self, context):
|
2016-10-19 17:46:13 +02:00
|
|
|
state.is_paused = False
|
2016-09-12 02:24:20 +02:00
|
|
|
return{'FINISHED'}
|
|
|
|
|
|
|
|
def register():
|
2017-03-15 12:30:14 +01:00
|
|
|
if arm.utils.with_krom():
|
|
|
|
bpy.utils.register_class(ArmorySpaceHeader)
|
|
|
|
bpy.utils.register_class(ArmorySpaceStopButton)
|
|
|
|
bpy.utils.register_class(ArmorySpacePauseButton)
|
|
|
|
bpy.utils.register_class(ArmorySpaceResumeButton)
|
2016-09-12 02:24:20 +02:00
|
|
|
|
|
|
|
def unregister():
|
2017-03-15 12:30:14 +01:00
|
|
|
if arm.utils.with_krom():
|
|
|
|
bpy.utils.unregister_class(ArmorySpaceHeader)
|
|
|
|
bpy.utils.unregister_class(ArmorySpaceStopButton)
|
|
|
|
bpy.utils.unregister_class(ArmorySpacePauseButton)
|
|
|
|
bpy.utils.unregister_class(ArmorySpaceResumeButton)
|