From 5261a7d4d9f5492b908a7ebbd9b750e5d35eed55 Mon Sep 17 00:00:00 2001 From: Nick Winter <livelily@gmail.com> Date: Tue, 7 Oct 2014 10:41:16 -0700 Subject: [PATCH] Snap to integer meters in the level editor when holding shift. --- app/views/editor/level/thangs/ThangsTabView.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/editor/level/thangs/ThangsTabView.coffee b/app/views/editor/level/thangs/ThangsTabView.coffee index 5d790009f..23e0ae6a9 100644 --- a/app/views/editor/level/thangs/ThangsTabView.coffee +++ b/app/views/editor/level/thangs/ThangsTabView.coffee @@ -399,9 +399,14 @@ module.exports = class ThangsTabView extends CocoView thang adjustThangPos: (sprite, thang, pos) -> - snap = sprite?.data?.snap or sprite?.thangType?.get('snap') or {x: 0.01, y: 0.01} # Centimeter resolution by default - pos.x = Math.round((pos.x - (thang.width ? 1) / 2) / snap.x) * snap.x + (thang.width ? 1) / 2 - pos.y = Math.round((pos.y - (thang.height ? 1) / 2) / snap.y) * snap.y + (thang.height ? 1) / 2 + if key.shift + # Meter resolution when holding shift, not caring about thang size. + pos.x = Math.round pos.x + pos.y = Math.round pos.y + else + snap = sprite?.data?.snap or sprite?.thangType?.get('snap') or x: 0.01, y: 0.01 # Centimeter resolution by default + pos.x = Math.round((pos.x - (thang.width ? 1) / 2) / snap.x) * snap.x + (thang.width ? 1) / 2 + pos.y = Math.round((pos.y - (thang.height ? 1) / 2) / snap.y) * snap.y + (thang.height ? 1) / 2 pos.z = thang.depth / 2 thang.pos = pos thang.stateChanged = true