Fix some viewport scaling shenanigans
This commit is contained in:
parent
e2a4d3a422
commit
802ccfa013
2 changed files with 5 additions and 2 deletions
|
@ -66,6 +66,7 @@ script = ExtResource( 1 )
|
||||||
[node name="Panel" type="Panel" parent="."]
|
[node name="Panel" type="Panel" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
margin_bottom = 40.0
|
margin_bottom = 40.0
|
||||||
|
rect_pivot_offset = Vector2( -60, -230 )
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
|
@ -10,7 +10,7 @@ onready var oppHand := $Camera/OppHand
|
||||||
onready var ui := $BoardUI
|
onready var ui := $BoardUI
|
||||||
onready var cards := $Cards
|
onready var cards := $Cards
|
||||||
|
|
||||||
export var mouseHandThreshold = 0.85
|
export var mouseHandThreshold = 0.90
|
||||||
|
|
||||||
var holdingCard: Card = null
|
var holdingCard: Card = null
|
||||||
var focusedCard: Card = null
|
var focusedCard: Card = null
|
||||||
|
@ -61,6 +61,8 @@ func _input(event: InputEvent):
|
||||||
mouseOrigin = get_viewport().get_mouse_position()
|
mouseOrigin = get_viewport().get_mouse_position()
|
||||||
lastCameraTransform = camera.transform
|
lastCameraTransform = camera.transform
|
||||||
|
|
||||||
|
var baseViewport := Vector2(1280, 720)
|
||||||
|
|
||||||
func _process(delta: float):
|
func _process(delta: float):
|
||||||
# If mouse is under a certain area then we're managing our hand
|
# If mouse is under a certain area then we're managing our hand
|
||||||
var absMousePos := get_viewport().get_mouse_position()
|
var absMousePos := get_viewport().get_mouse_position()
|
||||||
|
@ -72,7 +74,7 @@ func _process(delta: float):
|
||||||
# If holding a card, move it between board/hand
|
# If holding a card, move it between board/hand
|
||||||
if holdingCard != null:
|
if holdingCard != null:
|
||||||
# Check if we're selecting our hand while holding a card
|
# Check if we're selecting our hand while holding a card
|
||||||
var relPos: Vector2 = absMousePos / get_viewport().size
|
var relPos := get_viewport().get_mouse_position() / baseViewport
|
||||||
var xMargin = 1.0-HAND_SCREEN_PERC
|
var xMargin = 1.0-HAND_SCREEN_PERC
|
||||||
var selectingHand: bool = relPos.y > mouseHandThreshold and (relPos.x > xMargin/2 and relPos.x < (1.0-xMargin/2))
|
var selectingHand: bool = relPos.y > mouseHandThreshold and (relPos.x > xMargin/2 and relPos.x < (1.0-xMargin/2))
|
||||||
# Move card in/out hand
|
# Move card in/out hand
|
||||||
|
|
Loading…
Reference in a new issue