2024-02-19 14:28:35 +01:00
|
|
|
import typing as typ
|
|
|
|
|
2024-02-26 16:16:06 +01:00
|
|
|
import bpy
|
2024-02-19 14:28:35 +01:00
|
|
|
import pydantic as pyd
|
|
|
|
|
|
|
|
from .. import base
|
|
|
|
from ... import contracts
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Socket
|
|
|
|
####################
|
|
|
|
class IntegerNumberBLSocket(base.BLSocket):
|
|
|
|
socket_type = contracts.SocketType.IntegerNumber
|
|
|
|
bl_label = "IntegerNumber"
|
|
|
|
|
2024-02-26 16:16:06 +01:00
|
|
|
####################
|
|
|
|
# - Properties
|
|
|
|
####################
|
|
|
|
raw_value: bpy.props.IntProperty(
|
|
|
|
name="Integer",
|
|
|
|
description="Represents an integer",
|
|
|
|
default=0,
|
|
|
|
update=(lambda self, context: self.trigger_updates()),
|
|
|
|
)
|
|
|
|
|
2024-02-19 14:28:35 +01:00
|
|
|
####################
|
|
|
|
# - Default Value
|
|
|
|
####################
|
|
|
|
@property
|
|
|
|
def default_value(self) -> None:
|
2024-02-26 16:16:06 +01:00
|
|
|
return self.raw_value
|
2024-02-19 14:28:35 +01:00
|
|
|
|
|
|
|
@default_value.setter
|
|
|
|
def default_value(self, value: typ.Any) -> None:
|
2024-02-26 16:16:06 +01:00
|
|
|
self.raw_value = int(value)
|
2024-02-19 14:28:35 +01:00
|
|
|
|
|
|
|
####################
|
|
|
|
# - Socket Configuration
|
|
|
|
####################
|
|
|
|
class IntegerNumberSocketDef(pyd.BaseModel):
|
|
|
|
socket_type: contracts.SocketType = contracts.SocketType.IntegerNumber
|
|
|
|
label: str
|
|
|
|
|
2024-02-26 16:16:06 +01:00
|
|
|
default_value: int = 0
|
|
|
|
|
2024-02-19 14:28:35 +01:00
|
|
|
def init(self, bl_socket: IntegerNumberBLSocket) -> None:
|
2024-02-26 16:16:06 +01:00
|
|
|
bl_socket.raw_value = self.default_value
|
2024-02-19 14:28:35 +01:00
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Registration
|
|
|
|
####################
|
|
|
|
BL_REGISTER = [
|
|
|
|
IntegerNumberBLSocket
|
|
|
|
]
|