class Mafia4ds_GlobalMaterialProperties(types.PropertyGroup): UseDiffuseTex : props.BoolProperty (name = "Use Diffuse Tex", default = True) Coloring : props.BoolProperty (name = "Coloring", default = False) AmbientColor : props.FloatVectorProperty(name = "Ambient Color", default = (1.0, 1.0, 1.0), subtype = "COLOR", size = 3) DiffuseColor : props.FloatVectorProperty(name = "Diffuse Color", default = (1.0, 1.0, 1.0), subtype = "COLOR", size = 3) MipMapping : props.BoolProperty (name = "Mip Mapping", default = True) TwoSided : props.BoolProperty (name = "Two Sided", default = False) AddEffect : props.BoolProperty (name = "Add Effect", default = False) ColorKey : props.BoolProperty (name = "Color Key", default = False) AdditiveBlend : props.BoolProperty (name = "Additive Blend", default = False) UseAlphaTexture : props.BoolProperty (name = "Use Alpha Texture", default = False) AlphaTexture : props.StringProperty (name = "Alpha Texture", default = "", subtype = "FILE_PATH") UseEnvTexture : props.BoolProperty (name = "Use Env Texture", default = False) EnvDefaultMode : props.BoolProperty (name = "Env Default Mode", default = True) EnvMultiplyMode : props.BoolProperty (name = "Env Multiply Mode", default = False) EnvAdditiveMode : props.BoolProperty (name = "Env Additive Mode", default = False) EnvYAxisRefl : props.BoolProperty (name = "Env Y Axis Refl", default = True) EnvYAxisProj : props.BoolProperty (name = "Env Y Axis Proj", default = False) EnvZAxisProj : props.BoolProperty (name = "Env Z Axis Proj", default = False) EnvTexture : props.StringProperty (name = "Env Texture", default = "", subtype = "FILE_PATH") AnimatedDiffuse : props.BoolProperty (name = "Animated Diffuse", default = False) AnimatedAlpha : props.BoolProperty (name = "Animated Alpha", default = False) AnimatedFrames : props.IntProperty (name = "Animated Frames", default = 0) AnimFrameLength : props.IntProperty (name = "Anim Frame Length", default = 100)
class ParallelRenderPreferences(types.AddonPreferences): bl_idname = __name__ ffmpeg_executable = props.StringProperty( name="Path to ffmpeg executable", default="", update=lambda self, context: self.update(context), subtype='FILE_PATH', ) ffmpeg_status = props.StringProperty(default="") ffmpeg_valid = props.BoolProperty(default=False) def update(self, context): error = _is_valid_ffmpeg_executable(self.ffmpeg_executable) if error is None: self.ffmpeg_valid = True info = subprocess.check_output( (self.ffmpeg_executable, '-version')).decode('utf-8') self.ffmpeg_status = 'Version: {}'.format(info) else: self.ffmpeg_valid = False self.ffmpeg_status = error context.scene.parallel_render_panel.update(context) def draw(self, context): layout = self.layout layout.prop(self, "ffmpeg_executable") icon = 'INFO' if self.ffmpeg_valid else 'ERROR' layout.label(self.ffmpeg_status, icon=icon)
class HiveNodeTree(types.NodeTree): bl_idname = 'HiveNodeTree' bl_label = 'Custom Node Tree' bl_icon = 'GAME' previous_name = props.StringProperty() unique_id = props.StringProperty(INVALID_NODE_TREE_ID)
class TemplateAttributeDefault(types.PropertyGroup): @property def hash(self): return str(hash(getattr(self, self.value_name))) @property def value_name(self): return "value_{}".format(self.type.lower()) @property def value(self): return getattr(self, self.value_name) @value.setter def value(self, value): setattr(self, self.value_name, value) name = props.StringProperty( description="Name of template attribute default value") type = props.EnumProperty( description="Data type of template attribute default value", items=TYPE_ENUMS) value_int = props.IntProperty() value_float = props.FloatProperty() value_string = props.StringProperty() value_bool = props.BoolProperty()
class EXPORT_OT_skl(bpy.types.Operator, ExportHelper): '''Export a skeleton as a League of Legends .skl file''' bl_idname = "export.skl" bl_label = "Export .skl" OUTPUT_FILE = props.StringProperty( name='Export File', description='File to which skeleton will be exported') INPUT_FILE = props.StringProperty( name='Import File', description='File to import certain metadata from') MODEL_DIR = props.StringProperty() filename_ext = '.skl' def draw(self, context): layout = self.layout fileProps = context.space_data.params self.MODEL_DIR = fileProps.directory selectedFileExt = path.splitext(fileProps.filename)[-1].lower() self.OUTPUT_FILE = fileProps.filename box = layout.box() box.prop(self.properties, 'OUTPUT_FILE') box.prop(self.properties, 'INPUT_FILE') def execute(self, context): export_skl(MODEL_DIR=self.MODEL_DIR, OUTPUT_FILE=self.OUTPUT_FILE, INPUT_FILE=self.INPUT_FILE) return {'FINISHED'}
class RPCArgumentGroup(types.PropertyGroup): """PropertyGroup for RPC arguments""" name = props.StringProperty(description="Name of game property") type = props.StringProperty(description="Data type of RPC argument") replicate = props.BoolProperty( default=False, description="Replicate this game property with RPC call")
class EPOCHListItem(bpy.types.PropertyGroup): """ Group of properties representing an item in the list """ name: prop.StringProperty( name="Name", description="A name for this item", default="Untitled") id: prop.StringProperty( name="id", description="A description for this item", default="Empty") min_y: prop.FloatProperty( name="code for icon", description="", default=0.0) max_y: prop.FloatProperty( name="code for icon", description="", default=0.0) height: prop.FloatProperty( name="height of epoch row", description="", default=0.0) epoch_color: prop.StringProperty( name="color of epoch row", description="", default="Empty") use_toggle: BoolProperty(name="", default=True) is_locked: BoolProperty(name="", default=True) is_selected: BoolProperty(name="", default=False) epoch_soloing: BoolProperty(name="", default=False) rm_models: BoolProperty(name="", default=False) reconstruction_on: BoolProperty(name="", default=False) unique_id: StringProperty(default="") epoch_RGB_color: FloatVectorProperty( name="epoch_color", subtype="COLOR", size=3, min=0.0, max=1.0, default=(0.5, 0.5, 0.5) ) wire_color: FloatVectorProperty( name="wire", subtype='COLOR', default=(0.2, 0.2, 0.2), min=0.0, max=1.0, description="wire color of the group" )
class PANOListItem(bpy.types.PropertyGroup): """ Group of properties representing an item in the list """ name = prop.StringProperty(name="Name", description="A name for this item", default="Untitled") icon = prop.StringProperty(name="code for icon", description="", default="GROUP_UVS")
class ListItem(bpy.types.PropertyGroup): """ Group of properties representing an item in the list """ name = prop.StringProperty(name="Name", description="A name for this item", default="Untitled") random_prop = prop.StringProperty( name="random_prop", description="Any other property you want", default="XX")
class IMPORT_OT_egg(bpy.types.Operator, ImportHelper): """Import .egg Operator""" bl_idname = "import_scene.egg" bl_label = "Import .egg" bl_description = "Import a Panda3D .egg file" bl_options = {'REGISTER', 'UNDO'} filename_ext = ".egg" filter_glob = props.StringProperty(default="*.egg;*.egg.pz;*.egg.gz", options={'HIDDEN'}) directory = props.StringProperty(name="Directory", options={'HIDDEN'}) files = props.CollectionProperty(type=bpy.types.OperatorFileListElement, options={'HIDDEN'}) load_external = props.BoolProperty( name="Load external references", description= "Loads other .egg files referenced by this file as separate scenes, and instantiates them using DupliGroups." ) def execute(self, context): context = importer.EggContext() context.info = lambda msg: self.report({'INFO'}, msg) context.warn = lambda msg: self.report({'WARNING'}, msg) context.error = lambda msg: self.report({'ERROR'}, msg) context.search_dir = self.directory roots = [] for file in self.files: path = os.path.join(self.directory, file.name) root = context.read_file(path) roots.append(root) for root in roots: root.build_tree(context) context.assign_vertex_groups() if self.load_external: context.load_external_references() context.final_report() return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager wm.fileselect_add(self) return {'RUNNING_MODAL'} def draw(self, context): layout = self.layout row = layout.row() row.prop(self, "load_external")
class EMreusedUS(bpy.types.PropertyGroup): """ Group of properties representing an item in the list """ epoch: prop.StringProperty( name="epoch", description="Epoch", default="Untitled") em_element: prop.StringProperty( name="em_element", description="", default="Empty")
class AttributeGroup(types.PropertyGroup): """PropertyGroup for Actor attributes""" name = props.StringProperty(description="Name of game property") type = props.StringProperty(description="Data type of game property") replicate = props.BoolProperty(default=False, description="Replicate this game property") replicate_for_owner = props.BoolProperty( default=False, description="Replicate this game property to the owner" "client") replicate_after_initial = props.BoolProperty( default=True, description="Replicate this game property after initial " "replication")
class IMPORT_OT_lol(bpy.types.Operator, ImportHelper): bl_label = "Import LoL" bl_idname = "import.lol" SKN_FILE = props.StringProperty(name='Mesh', description='Model .skn file') SKL_FILE = props.StringProperty(name='Skeleton', description='Model .skl file') DDS_FILE = props.StringProperty(name='Texture', description='Model .dds file') MODEL_DIR = props.StringProperty() CLEAR_SCENE = props.BoolProperty( name='ClearScene', description='Clear current scene before importing?', default=True) APPLY_WEIGHTS = props.BoolProperty( name='LoadWeights', description='Load default bone weights from .skn file', default=True) def draw(self, context): layout = self.layout fileProps = context.space_data.params self.MODEL_DIR = fileProps.directory selectedFileExt = path.splitext(fileProps.filename)[-1].lower() if selectedFileExt == '.skn': self.SKN_FILE = fileProps.filename elif selectedFileExt == '.skl': self.SKL_FILE = fileProps.filename elif selectedFileExt == '.dds': self.DDS_FILE = fileProps.filename box = layout.box() box.prop(self.properties, 'SKN_FILE') box.prop(self.properties, 'SKL_FILE') box.prop(self.properties, 'DDS_FILE') box.prop(self.properties, 'CLEAR_SCENE', text='Clear scene before importing') box.prop(self.properties, 'APPLY_WEIGHTS', text='Load mesh weights') def execute(self, context): import_char(MODEL_DIR=self.MODEL_DIR, SKN_FILE=self.SKN_FILE, SKL_FILE=self.SKL_FILE, DDS_FILE=self.DDS_FILE, CLEAR_SCENE=self.CLEAR_SCENE, APPLY_WEIGHTS=self.APPLY_WEIGHTS) return {'FINISHED'}
class StateGroup(types.PropertyGroup): """PropertyGroup for RPC calls""" netmode = props.StringProperty( description="Netmode to which these states belong") states = props.BoolVectorProperty(size=30) simulated_states = props.BoolVectorProperty(size=30)
class ExportEGG(bpy.types.Operator, ExportHelper): """ Export selected to the Panda3D EGG format """ bl_idname = "export.panda3d_egg" bl_label = "Export to Panda3D EGG" filename_ext = ".egg" filter_glob = props.StringProperty(default="*.egg", options={'HIDDEN'},) export_format = 'ASCII' scene_key = 'exportpanda3deggsetting' def execute(self, context): # TODO: Gather export settings export_settings = {} export_settings['egg_file_format'] = 'UTF-8' export_settings['egg_filepath'] = bpy.path.ensure_ext(self.filepath, self.filename_ext) export_settings['egg_exportdir'] = os.path.dirname(export_settings['egg_filepath']) + '/' save(context, export_settings) return {'FINISHED'} def invoke(self, context, event): return ExportHelper.invoke(self, context, event) def draw(self, context): pass
class Mafia4ds_GlobalMeshProperties(types.PropertyGroup): Type: props.EnumProperty( name="Type", items=[ ("0x01", "Visual", ""), #("0x05", "Sector", ""), ("0x06", "Dummy", ""), #("0x07", "Target", ""), #("0x0a", "Joint", "") ]) VisualType: props.EnumProperty( name="Visual Type", items=[ ("0x00", "Mesh", ""), #("0x02", "SingleMesh", ""), #("0x03", "SingleMorph", ""), #("0x04", "Billboard", ""), #("0x05", "Morph", ""), #("0x06", "Glow", ""), #("0x08", "Mirror", "") ]) Parameters: props.StringProperty(name="Parameters", default="") RenderFlags: props.IntProperty(name="Render Flags", default=0x2a00) CullingFlags: props.IntProperty(name="Culling Flags", default=0x09) InstanceIdx: props.IntProperty(name="Instance Idx", default=0) LodRatio: props.FloatProperty(name="Lod Ratio", default=0.0)
class TemplateClass(types.PropertyGroup): """PropertyGroup for Template items""" import_path = props.StringProperty(description="Import Path") defaults = props.CollectionProperty(type=TemplateAttributeDefault) defaults_active = props.IntProperty()
class NODE_OT_AddHiveNode(types.Operator): bl_idname = "hive.add_node" bl_label = "Add Hive Node" import_path = props.StringProperty(default="dragonfly.std.Buffer", name="Import path") @classmethod def poll(cls, context): return True def execute(self, context): hive_cls = import_from_path(self.import_path) init_info = get_pre_init_info(hive_cls) if not (init_info['parameters'] or init_info['cls_args']): add_hive_node(context, self.import_path) else: ops.hive.config_and_add_node('INVOKE_DEFAULT', import_path=self.import_path) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self)
class ParameterGroup(types.PropertyGroup): name = props.StringProperty(name="Name") data_type = props.EnumProperty(items=enum_data_types) value_str = props.StringProperty() value_int = props.IntProperty() value_bool = props.BoolProperty() value_float = props.FloatProperty() @property def value(self): return getattr(self, "value_{}".format(self.data_type)) @value.setter def value(self, value): setattr(self, "value_{}".format(self.data_type), value)
class EDGESListItem(bpy.types.PropertyGroup): """ Group of properties an item in the list """ id_node: prop.StringProperty( name="id", description="A description for this item", default="Empty") source: prop.StringProperty( name="source", description="A description for this item", default="Empty") target: prop.StringProperty( name="target", description="A description for this item", default="Empty")
class EXPORT_OT_lol(bpy.types.Operator, ExportHelper): '''Export a mesh as a League of Legends .skn file''' bl_idname = "export.lol" bl_label = "Export .skn" VERSION = props.IntProperty(name='Version No.', description='.SKN version number', default=4) OUTPUT_FILE = props.StringProperty( name='Export File', description='File to which model will be exported') BASE_ON_IMPORT = props.BoolProperty( name='Base On Imported SKN', description='Base writing on an imported SKN of choice', default=True) INPUT_FILE = props.StringProperty( name='Import File', description='File to import certain metadata from') MODEL_DIR = props.StringProperty() filename_ext = '.skn' def draw(self, context): layout = self.layout fileProps = context.space_data.params self.MODEL_DIR = fileProps.directory selectedFileExt = path.splitext(fileProps.filename)[-1].lower() self.OUTPUT_FILE = fileProps.filename box = layout.box() box.prop(self.properties, 'VERSION') box.prop(self.properties, 'OUTPUT_FILE') box.prop(self.properties, 'BASE_ON_IMPORT') box.prop(self.properties, 'INPUT_FILE') def execute(self, context): export_char(MODEL_DIR=self.MODEL_DIR, OUTPUT_FILE=self.OUTPUT_FILE, INPUT_FILE=self.INPUT_FILE, BASE_ON_IMPORT=self.BASE_ON_IMPORT, VERSION=self.VERSION) return {'FINISHED'}
class MediaInfoPreferences(types.AddonPreferences): bl_idname = __name__ mediainfo_executable = props.StringProperty( name="MediaInfo_Command_Line_Executable", description="Path to MediaInfo executable", default="MediaInfo.exe", update=lambda self, context: self.update(context), subtype='FILE_PATH') #bpy.ops.file.make_paths_absolute() # Paths will be wrong without this mediainfo_status = props.StringProperty(default="") mediainfo_valid = props.BoolProperty(default=False) def update(self, context): # check media info path print("update") global media_info_path mi_exe_path = bpy.path.abspath( self.mediainfo_executable) #convert to absolute path error = "" error = _is_valid_mediainfo_executable(mi_exe_path) if error is None: # path is ok error is None and info = subprocess.check_output(mi_exe_path + ' --Version').decode('utf-8') self.mediainfo_valid = True self.mediainfo_status = 'Version: {}'.format(info) media_info_path = mi_exe_path else: # path is not ok media_info_path = "" self.mediainfo_executable.setvalue = '' self.mediainfo_valid = False self.mediainfo_status = error context.scene.media_info_panel.update(context) def draw(self, context): # add info to properties layout = self.layout layout.prop(self, "mediainfo_executable") if self.mediainfo_valid: icon = 'INFO' else: icon = 'ERROR' layout.label(self.mediainfo_status, icon=icon)
class EXPORT_OT_lolanm(bpy.types.Operator, ImportHelper): bl_label = "Export LoL Animation" bl_idname = "export.lolanm" OUTPUT_FILE = props.StringProperty( name='Export File', description='File to which animation will be exported') INPUT_FILE = props.StringProperty( name='Import File', description='File to import certain metadata from') OVERWRITE_FILE_VERSION = props.BoolProperty( name='Overwrite File Version', description='Write a version different from the imported file', default=False) VERSION = props.IntProperty(name='File Version', description='Overwrite file version', default=3) filename_ext = '.anm' def draw(self, context): layout = self.layout fileProps = context.space_data.params self.MODEL_DIR = fileProps.directory selectedFileExt = path.splitext(fileProps.filename)[-1].lower() self.OUTPUT_FILE = fileProps.filename box = layout.box() box.prop(self.properties, 'OUTPUT_FILE') box.prop(self.properties, 'INPUT_FILE') box.prop(self.properties, 'OVERWRITE_FILE_VERSION') if self.OVERWRITE_FILE_VERSION: box.prop(self.properties, 'VERSION') def execute(self, context): export_animation(MODEL_DIR=self.MODEL_DIR, OUTPUT_FILE=self.OUTPUT_FILE, INPUT_FILE=self.INPUT_FILE, OVERWRITE_FILE_VERSION=self.OVERWRITE_FILE_VERSION, VERSION=self.VERSION) return {'FINISHED'}
class ExportEGGPreferences(bpy.types.AddonPreferences): """ Preferences class for saving addon preferences. """ bl_idname = __name__ test = props.StringProperty(name='Test property', description='for testing purposes', default='this is default') def draw(self, context): layout = self.layout layout.prop(self, "test")
class IDPropertyOpMixin(object): bl_label = "" to_populate_data = p.StringProperty() to_populate_field = p.StringProperty() @property def ob(self): data = eval(self.to_populate_data) ob_name = getattr(data, self.to_populate_field) return bpy.data.objects.get(ob_name) @ob.setter def ob(self, new_ob): ob_name = new_ob.name if new_ob else "" data = eval(self.to_populate_data) setattr(data, self.to_populate_field, ob_name) @classmethod def poll(self, ctx): return has_active_3d_view()
class EMListParadata(bpy.types.PropertyGroup): """ Group of properties representing a paradata element in the list """ name: prop.StringProperty( name="Name", description="A name for this item", default="Untitled") description: prop.StringProperty( name="Description", description="A description for this item", default="Empty") icon: prop.StringProperty( name="code for icon", description="", default="RESTRICT_INSTANCED_ON") icon_url: prop.StringProperty( name="code for icon url", description="", default="CHECKBOX_DEHLT") url: prop.StringProperty( name="url", description="An url behind this item", default="Empty") id_node: prop.StringProperty( name="id_node", description="The id node of this item", default="Empty")
class NODE_OT_ConfigHiveNode(types.Operator): bl_idname = "hive.config_and_add_node" bl_label = "Configure Hive Node" import_path = props.StringProperty(name="Import path") arguments_index = props.IntProperty() arguments = props.CollectionProperty(type=ArgumentGroup) parameters_index = props.IntProperty() parameters = props.CollectionProperty(type=ParameterGroup) def draw(self, context): layout = self.layout layout.label("Parameters") layout.template_list("HIVE_UL_parameters", "", self, "parameters", self, "parameters_index") layout.label("Class Arguments") layout.template_list("HIVE_UL_arguments", "", self, "arguments", self, "arguments_index") def execute(self, context): params = {} for parameter in self.parameters: params[parameter.name] = parameter.value for argument in self.arguments: params[argument.name] = eval(argument.value_repr) add_hive_node(context, self.import_path, params) return {'FINISHED'} def invoke(self, context, event): hive_cls = import_from_path(self.import_path) init_info = get_pre_init_info(hive_cls) for name, info in init_info['parameters'].items(): argument = self.parameters.add() argument.data_type = info['data_type'][0] argument.name = name argument.value = info['start_value'] for name, info in init_info['cls_args'].items(): argument = self.arguments.add() argument.name = name argument.value_repr = '' wm = context.window_manager return wm.invoke_props_dialog(self)
class EMviqListErrors(bpy.types.PropertyGroup): """ Group of properties representing list of errors in exporting the RM """ name: prop.StringProperty( name="Object", description="The object with an error", default="Empty") description: prop.StringProperty( name="Description", description="A description of the error", default="Empty") material: prop.StringProperty( name="material", description="", default="Empty") texture_type: prop.StringProperty( name="texture_type", description="", default="Empty")
class IMPORT_OT_lolanm(bpy.types.Operator, ImportHelper): bl_label = "Import LoL Animation" bl_idname = "import.lolanm" ANM_FILE = props.StringProperty(name='Animation', description='Animation .anm file') MODEL_DIR = props.StringProperty() def draw(self, context): layout = self.layout fileProps = context.space_data.params self.MODEL_DIR = fileProps.directory selectedFileExt = path.splitext(fileProps.filename)[-1].lower() if selectedFileExt == '.anm': self.ANM_FILE = fileProps.filename box = layout.box() box.prop(self.properties, 'ANM_FILE') def execute(self, context): import_animation(MODEL_DIR=self.MODEL_DIR, ANM_FILE=self.ANM_FILE) return {'FINISHED'}
class RPCGroup(types.PropertyGroup): """PropertyGroup for RPC calls""" name = props.StringProperty("name", default="RPC", description="Name of RPC call") reliable = props.BoolProperty(default=False, description="Guarantee delivery of RPC call") simulated = props.BoolProperty( default=False, description="Allow execution for simulated proxies") target = props.EnumProperty(items=NETWORK_ENUMS, description="Netmode of RPC target") arguments = props.CollectionProperty(type=RPCArgumentGroup) arguments_index = props.IntProperty()