コード例 #1
0
    def get_resource_key(resource_type: Types,
                         instance_id: int) -> _resourceman.Key:
        """get_resource_key(resource_type, instance_id)

        Retrieve the resource key of a resource in the format: 00000000(Type):00000000(Group):00000000000000000(Instance Guid)

        .. note::

            Possible Usages:

            - Retrieve the identifier of an Icon to display next to an Interaction in the Pie Menu.
            - Retrieve the identifier of an Image for display in Dialogs or Notifications.

        :Example Usage:

        .. highlight:: python
        .. code-block:: python

            # This will retrieve the key for the image with identifier 1234
            icon_key = CommonResourceUtils.get_resource_key(Types.PNG, 1234)

        :param resource_type: The type of resource being loaded.
        :type resource_type: Types
        :param instance_id: The decimal identifier of the resource.
        :type instance_id: int
        :return: The resource key of an instance or None if no instance was found.
        :rtype: _resourceman.Key
        """
        return get_resource_key(instance_id, resource_type)
コード例 #2
0
    def get_resource_key(resource_type: Types, instance_id: int) -> _resourceman.Key:
        """
            Retrieve the resource key of a resource in the format: 00000000:00000000:00000000000000000

            Possible Usages:
            - Retrieve the identifier of an Icon to display next to an Interaction in the Pie Menu.
            - Retrieve the identifier of an Image for display in Dialogs or Notifications.

            Example Usage:
            icon_key = CommonResourceUtils.get_resource_key(Types.PNG, 1234)
        :param resource_type: The type of resource being loaded.
        :param instance_id: The decimal identifier of the resource.
        :return: The resource key of an instance (format: 00000000(Type):00000000(Group):00000000000000000(Instance Guid)) or None if no instance was found.
        """
        return get_resource_key(instance_id, resource_type)
コード例 #3
0
ファイル: Registration.py プロジェクト: NeonOcean/S4.Order
    def RegisterToObjects(cls) -> None:
        """
		Add this interaction to the appropriate objects.
		"""

        definitionManager = services.definition_manager(
        )  # type: definition_manager.DefinitionManager

        for registrationInformation in cls.ObjectRegistrationInformation:  # type: RegistrationInformation
            relevantObjects = set(
            )  # type: typing.Set[typing.Type[script_object.ScriptObject]]

            for relevantObjectInstanceID in registrationInformation.GetRelevantObjectInstanceIDs(
            ):  # type: int
                relevantObjectKey = resources.get_resource_key(
                    relevantObjectInstanceID, resources.Types.OBJECT)
                matchingObject = definitionManager.types.get(
                    relevantObjectKey, None
                )  # type: typing.Optional[typing.Type[script_object.ScriptObject]]

                if matchingObject is None:
                    continue

                relevantObjects.add(matchingObject)

            for relevantObject in relevantObjects:  # type: typing.Type[script_object.ScriptObject]
                registeredInteractionLists = cls._registeredObjects.get(
                    relevantObject,
                    None)  # type: typing.Optional[typing.List[str]]

                if registeredInteractionLists is not None:
                    if registrationInformation.InteractionListAttribute in registeredInteractionLists:
                        continue

                registrationInformation.RegisterObject(relevantObject, cls)

                if registeredInteractionLists is not None:
                    registeredInteractionLists.append(
                        registrationInformation.InteractionListAttribute)
                else:
                    cls._registeredObjects[relevantObject] = {
                        registrationInformation.InteractionListAttribute
                    }
コード例 #4
0
 def get_resource_key(instance_type, instance_id):
     return get_resource_key(instance_id, instance_type)