Beispiel #1
0
    def name_update(self, context):

        lprint("D SCS Look inventory name update: %s", (self.name, ))

        # convert name to game engine like name
        tokenized_name = _name_utils.tokenize_name(self.name)
        if self.name != tokenized_name:
            self.name = tokenized_name

        # always get scs root to have access to look inventory
        scs_root_obj = _object_utils.get_scs_root(context.active_object)

        # if there is more of variants with same name, make postfixed name (this will cause another name update)
        if len(
                _inventory.get_indices(scs_root_obj.scs_object_look_inventory,
                                       self.name)) == 2:  # duplicate

            i = 1
            new_name = _name_utils.tokenize_name(self.name + "_" +
                                                 str(i).zfill(2))
            while _inventory.get_index(scs_root_obj.scs_object_look_inventory,
                                       new_name) != -1:
                new_name = _name_utils.tokenize_name(self.name + "_" +
                                                     str(i).zfill(2))
                i += 1

            if new_name != self.name:
                self.name = new_name
Beispiel #2
0
    def name_update(self, context):

        lprint("D SCS Part inventory name update: %s", (self.name, ))

        # convert name to game engine like name
        tokenized_name = _name_utils.tokenize_name(
            self.name, default_name=_PART_consts.default_name)
        if self.name != tokenized_name:
            self.name = tokenized_name

        # always get scs root because we allow editing of parts in any child
        scs_root_obj = _object_utils.get_scs_root(context.active_object)

        # if there is more of parts with same name, make postfixed name (this will cause another name update)
        if len(
                _inventory.get_indices(scs_root_obj.scs_object_part_inventory,
                                       self.name)) == 2:  # duplicate

            i = 1
            new_name = _name_utils.tokenize_name(self.name + "_" +
                                                 str(i).zfill(2))
            while _inventory.get_index(scs_root_obj.scs_object_part_inventory,
                                       new_name) != -1:
                new_name = _name_utils.tokenize_name(self.name + "_" +
                                                     str(i).zfill(2))
                i += 1

            if new_name != self.name:
                self.name = new_name

        if "scs_part_old_name" in self:

            if scs_root_obj:

                # fix part name in all children of current root
                children = _object_utils.get_children(scs_root_obj)
                for child in children:

                    # fix part name in child with existing old name
                    if child.scs_props.scs_part == self["scs_part_old_name"]:

                        child.scs_props.scs_part = self.name

                # rename parts in all variants also
                variant_inventory = scs_root_obj.scs_object_variant_inventory
                for variant in variant_inventory:
                    for part in variant.parts:

                        if part.name == self["scs_part_old_name"]:
                            part.name = self.name
                            break

        # backup current name for checking children on next renaming
        self["scs_part_old_name"] = self.name
Beispiel #3
0
    def name_update(self, context):

        lprint("D SCS Part inventory name update: %s", (self.name,))

        # convert name to game engine like name
        tokenized_name = _name_utils.tokenize_name(self.name, default_name=_PART_consts.default_name)
        if self.name != tokenized_name:
            self.name = tokenized_name

        # always get scs root because we allow editing of parts in any child
        scs_root_obj = _object_utils.get_scs_root(context.active_object)

        # if there is more of parts with same name, make postfixed name (this will cause another name update)
        if len(_inventory.get_indices(scs_root_obj.scs_object_part_inventory, self.name)) == 2:  # duplicate

            i = 1
            new_name = _name_utils.tokenize_name(self.name + "_" + str(i).zfill(2))
            while _inventory.get_index(scs_root_obj.scs_object_part_inventory, new_name) != -1:
                new_name = _name_utils.tokenize_name(self.name + "_" + str(i).zfill(2))
                i += 1

            if new_name != self.name:
                self.name = new_name

        if "scs_part_old_name" in self:

            if scs_root_obj:

                # fix part name in all children of current root
                children = _object_utils.get_children(scs_root_obj)
                for child in children:

                    # fix part name in child with existing old name
                    if child.scs_props.scs_part == self["scs_part_old_name"]:

                        child.scs_props.scs_part = self.name

                # rename parts in all variants also
                variant_inventory = scs_root_obj.scs_object_variant_inventory
                for variant in variant_inventory:
                    for part in variant.parts:

                        if part.name == self["scs_part_old_name"]:
                            part.name = self.name
                            break

        # backup current name for checking children on next renaming
        self["scs_part_old_name"] = self.name
Beispiel #4
0
        def update_name(self, context):
            __update_look__(self, context)

            if hasattr(context, "active_object") and hasattr(context.active_object, "active_material"):
                material = context.active_object.active_material
                if material:

                    custom_maps = material.scs_props.custom_tex_coord_maps
                    # force prescribed pattern for name ("tex_coord_X" where X is unsigned integer) and avoid duplicates
                    if not re.match("\Atex_coord_\d+\Z", self.name) or len(_inventory.get_indices(custom_maps, self.name)) == 2:
                        i = 0
                        new_name = "tex_coord_" + str(i)
                        while _inventory.get_index(custom_maps, new_name) != -1:
                            i += 1
                            new_name = "tex_coord_" + str(i)

                        if self.name != new_name:
                            self.name = new_name
Beispiel #5
0
        def update_name(self, context):

            if hasattr(context, "active_object") and hasattr(
                    context.active_object, "active_material"):
                material = context.active_object.active_material
                if material:

                    custom_maps = material.scs_props.shader_custom_tex_coord_maps
                    # force prescribed pattern for name ("tex_coord_X" where X is unsigned integer) and avoid duplicates
                    if not re.match("\Atex_coord_\d+\Z", self.name) or len(
                            _inventory.get_indices(custom_maps,
                                                   self.name)) == 2:
                        i = 0
                        new_name = "tex_coord_" + str(i)
                        while _inventory.get_index(custom_maps,
                                                   new_name) != -1:
                            i += 1
                            new_name = "tex_coord_" + str(i)

                        if self.name != new_name:
                            self.name = new_name
Beispiel #6
0
    def name_update(self, context):

        lprint("D SCS Look inventory name update: %s", (self.name,))

        # convert name to game engine like name
        tokenized_name = _name_utils.tokenize_name(self.name)
        if self.name != tokenized_name:
            self.name = tokenized_name

        # always get scs root to have access to look inventory
        scs_root_obj = _object_utils.get_scs_root(context.active_object)

        # if there is more of variants with same name, make postfixed name (this will cause another name update)
        if len(_inventory.get_indices(scs_root_obj.scs_object_look_inventory, self.name)) == 2:  # duplicate

            i = 1
            new_name = _name_utils.tokenize_name(self.name + "_" + str(i).zfill(2))
            while _inventory.get_index(scs_root_obj.scs_object_look_inventory, new_name) != -1:
                new_name = _name_utils.tokenize_name(self.name + "_" + str(i).zfill(2))
                i += 1

            if new_name != self.name:
                self.name = new_name