remove extra flags for secondary rect and rotation
This commit is contained in:
parent
6dfeab105e
commit
10e4038fea
@ -155,7 +155,7 @@ func load_props(_props: KeyProps, init_pos: Vector3, default_angle: float) -> vo
|
||||
props = _props
|
||||
|
||||
_skeleton_primary.visible = true
|
||||
_skeleton_secondary.visible = props.secondary_rect
|
||||
_skeleton_secondary.visible = props.has_secondary_rect()
|
||||
_set_bones()
|
||||
_nub_mesh.visible = props.homing_nub
|
||||
|
||||
@ -253,7 +253,7 @@ func _set_bones() -> void:
|
||||
|
||||
_set_bones_from_rect(rect, _skeleton_primary)
|
||||
|
||||
if props.secondary_rect:
|
||||
if props.has_secondary_rect():
|
||||
var rect_secondary := Rect2(
|
||||
rect.position.x + props.x2 * keyboard.key_size,
|
||||
rect.position.y + props.y2 * keyboard.key_size,
|
||||
|
||||
@ -155,14 +155,14 @@ func _iterate_row(
|
||||
pos.x = pivot.x
|
||||
|
||||
for key_props in row:
|
||||
if key_props.has_pivot_x:
|
||||
pivot.x = key_props.pivot_x
|
||||
if key_props.has_pivot_y:
|
||||
pivot.y = key_props.pivot_y
|
||||
if key_props.has_pivot_x or key_props.has_pivot_y:
|
||||
pos = pivot
|
||||
if key_props.has_angle:
|
||||
if key_props.has_angle():
|
||||
angle = -deg_to_rad(key_props.angle)
|
||||
if key_props.has_pivot_x():
|
||||
pivot.x = key_props.pivot_x
|
||||
if key_props.has_pivot_y():
|
||||
pivot.y = key_props.pivot_y
|
||||
if key_props.has_pivot_x() or key_props.has_pivot_y():
|
||||
pos = pivot
|
||||
|
||||
var key_pos := Vector3(pos.x + key_size / 2, 0, pos.y + key_size / 2)
|
||||
key_pos.x += (
|
||||
|
||||
@ -14,14 +14,10 @@ enum {
|
||||
H,
|
||||
X,
|
||||
Y,
|
||||
SECONDARY_RECT,
|
||||
W2,
|
||||
H2,
|
||||
X2,
|
||||
Y2,
|
||||
HAS_ANGLE,
|
||||
HAS_PIVOT_X,
|
||||
HAS_PIVOT_Y,
|
||||
R,
|
||||
PX,
|
||||
PY,
|
||||
@ -36,20 +32,14 @@ var height: float = 1
|
||||
var x: float = 0
|
||||
var y: float = 0
|
||||
|
||||
var secondary_rect: bool = false
|
||||
var width2: float = 1
|
||||
var width_init2: float = 1
|
||||
var height2: float = 1
|
||||
var height_init2: float = 1
|
||||
var x2: float = 0
|
||||
var y2: float = 0
|
||||
|
||||
var has_angle: bool = false
|
||||
var has_pivot_x: bool = false
|
||||
var has_pivot_y: bool = false
|
||||
var angle: float = 0
|
||||
var pivot_x: float = 0
|
||||
var pivot_y: float = 0
|
||||
var angle: float = -INF
|
||||
var pivot_x: float = -INF
|
||||
var pivot_y: float = -INF
|
||||
|
||||
var homing_nub: bool = false
|
||||
|
||||
@ -63,6 +53,22 @@ func is_char() -> bool:
|
||||
return OS.is_keycode_unicode(physical_keycode)
|
||||
|
||||
|
||||
func has_secondary_rect() -> bool:
|
||||
return width2 != 1 or height2 != 1 or x2 != 0 or y2 != 0
|
||||
|
||||
|
||||
func has_angle() -> bool:
|
||||
return angle != -INF
|
||||
|
||||
|
||||
func has_pivot_x() -> bool:
|
||||
return pivot_x != -INF
|
||||
|
||||
|
||||
func has_pivot_y() -> bool:
|
||||
return pivot_y != -INF
|
||||
|
||||
|
||||
func props_from_dict(dict: Dictionary) -> KeyProps:
|
||||
if dict.has(KEY):
|
||||
physical_keycode = dict[KEY]
|
||||
@ -78,25 +84,15 @@ func props_from_dict(dict: Dictionary) -> KeyProps:
|
||||
if dict.has(Y):
|
||||
y = dict[Y]
|
||||
|
||||
if dict.has(SECONDARY_RECT):
|
||||
secondary_rect = dict[SECONDARY_RECT]
|
||||
if dict.has(W2):
|
||||
width2 = dict[W2]
|
||||
width_init2 = dict[W2]
|
||||
if dict.has(H2):
|
||||
height2 = dict[H2]
|
||||
height_init2 = dict[H2]
|
||||
if dict.has(X2):
|
||||
x2 = dict[X2]
|
||||
if dict.has(Y2):
|
||||
y2 = dict[Y2]
|
||||
|
||||
if dict.has(HAS_ANGLE):
|
||||
has_angle = dict[HAS_ANGLE]
|
||||
if dict.has(HAS_PIVOT_X):
|
||||
has_pivot_x = dict[HAS_PIVOT_X]
|
||||
if dict.has(HAS_PIVOT_Y):
|
||||
has_pivot_y = dict[HAS_PIVOT_Y]
|
||||
if dict.has(R):
|
||||
angle = dict[R]
|
||||
if dict.has(PX):
|
||||
|
||||
@ -19,7 +19,6 @@ func get_rows() -> Array[Array]:
|
||||
KeyProps.W: 1.25,
|
||||
KeyProps.H: 2,
|
||||
KeyProps.X: 0.25,
|
||||
KeyProps.SECONDARY_RECT: true,
|
||||
KeyProps.W2: 1.5,
|
||||
KeyProps.X2: -0.25,
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ func get_rows() -> Array[Array]:
|
||||
KeyProps.KEY: KEY_ENTER,
|
||||
KeyProps.W: 1.5,
|
||||
KeyProps.H: 2,
|
||||
KeyProps.SECONDARY_RECT: true,
|
||||
KeyProps.W2: 2.25,
|
||||
KeyProps.Y2: 1,
|
||||
KeyProps.X2: -0.75,
|
||||
|
||||
@ -19,7 +19,6 @@ func get_rows() -> Array[Array]:
|
||||
KeyProps.W: 1.25,
|
||||
KeyProps.H: 2,
|
||||
KeyProps.X: 0.25,
|
||||
KeyProps.SECONDARY_RECT: true,
|
||||
KeyProps.W2: 1.5,
|
||||
KeyProps.X2: -0.25,
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ func get_rows() -> Array[Array]:
|
||||
KeyProps.W: 1.25,
|
||||
KeyProps.H: 2,
|
||||
KeyProps.X: 0.25,
|
||||
KeyProps.SECONDARY_RECT: true,
|
||||
KeyProps.W2: 1.5,
|
||||
KeyProps.X2: -0.25,
|
||||
}
|
||||
|
||||
@ -163,26 +163,19 @@ func _deserialize_key(data_key: Dictionary) -> Dictionary:
|
||||
|
||||
if data_key.has(W2):
|
||||
key_dict[KeyProps.W2] = data_key[W2]
|
||||
key_dict[KeyProps.SECONDARY_RECT] = true
|
||||
if data_key.has(H2):
|
||||
key_dict[KeyProps.H2] = data_key[H2]
|
||||
key_dict[KeyProps.SECONDARY_RECT] = true
|
||||
if data_key.has(X2):
|
||||
key_dict[KeyProps.X2] = data_key[X2]
|
||||
key_dict[KeyProps.SECONDARY_RECT] = true
|
||||
if data_key.has(Y2):
|
||||
key_dict[KeyProps.Y2] = data_key[Y2]
|
||||
key_dict[KeyProps.SECONDARY_RECT] = true
|
||||
|
||||
if data_key.has(R):
|
||||
key_dict[KeyProps.R] = data_key[R]
|
||||
key_dict[KeyProps.HAS_ANGLE] = true
|
||||
if data_key.has(RX):
|
||||
key_dict[KeyProps.PX] = data_key[RX]
|
||||
key_dict[KeyProps.HAS_PIVOT_X] = true
|
||||
if data_key.has(RY):
|
||||
key_dict[KeyProps.PY] = data_key[RY]
|
||||
key_dict[KeyProps.HAS_PIVOT_Y] = true
|
||||
|
||||
if data_key.has(N):
|
||||
key_dict[KeyProps.NUB] = data_key[N]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user