Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit dragging to thing mode #3

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ name: Automatic builds

on:
push:
branches:
- main
pull_request:
branches:
- '*'

jobs:
build_application:
Expand Down
76 changes: 39 additions & 37 deletions Scenes/Selector.gd
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ var preventClickWhenFocusing = false
enum {MODE_TILE, MODE_SUBTILE}
var mode = MODE_TILE


func _ready():
change_mode(MODE_TILE)

Expand Down Expand Up @@ -98,43 +97,46 @@ func mouse_button_on_field():

# Initial on-press button
if Input.is_action_just_pressed("mouse_left"):
draggingInstance = false

var youClickedOnAnAlreadyInspectedThing = false
if oInspector.inspectorSubtile.floor() == cursorSubtile.floor():
if is_instance_valid(oInspector.inspectingInstance):
youClickedOnAnAlreadyInspectedThing = true

if Input.is_action_pressed("place_overlapping"):
canPlace = true

# Check if something is under the cursor and initiate dragging
# If you're clicking on an inspected subtile, then drag the inspected object. (helps with stacked objects))

var thingAtCursor
if youClickedOnAnAlreadyInspectedThing == true:
thingAtCursor = oInspector.inspectingInstance
oInspector.deselect()
else:
thingAtCursor = instance_position(get_global_mouse_position(), "Instance")
if is_instance_valid(thingAtCursor):
holdClickOnInstance = thingAtCursor
drag_init_relative_pos = thingAtCursor.global_position - get_global_mouse_position()

if youClickedOnAnAlreadyInspectedThing == false:
if oSelection.cursorOnInstancesArray.empty() == false and mode == MODE_SUBTILE:
if is_instance_valid(oSelection.cursorOnInstancesArray[0]) == true:
oInspector.inspect_something(oSelection.cursorOnInstancesArray[0])
else:
oInspector.deselect()
match mode:
MODE_TILE:
match oEditingTools.TOOL_SELECTED:
oEditingTools.RECTANGLE:
oRectangleSelection.set_initial_position(cursorTile)
oEditingTools.PAINTBUCKET:
oSelection.construct_shape_for_placement(oSelection.CONSTRUCT_FILL)
MODE_SUBTILE:
draggingInstance = false

var youClickedOnAnAlreadyInspectedThing = false
if oInspector.inspectorSubtile.floor() == cursorSubtile.floor():
if is_instance_valid(oInspector.inspectingInstance):
youClickedOnAnAlreadyInspectedThing = true

if Input.is_action_pressed("place_overlapping"):
canPlace = true

# Check if something is under the cursor and initiate dragging
# If you're clicking on an inspected subtile, then drag the inspected object. (helps with stacked objects))

var thingAtCursor

if youClickedOnAnAlreadyInspectedThing == true:
thingAtCursor = oInspector.inspectingInstance
oInspector.deselect()
else:
thingAtCursor = instance_position(get_global_mouse_position(), "Instance")
if is_instance_valid(thingAtCursor):
holdClickOnInstance = thingAtCursor
drag_init_relative_pos = thingAtCursor.global_position - get_global_mouse_position()

if youClickedOnAnAlreadyInspectedThing == false:
if oSelection.cursorOnInstancesArray.empty() == false:
if is_instance_valid(oSelection.cursorOnInstancesArray[0]) == true:
oInspector.inspect_something(oSelection.cursorOnInstancesArray[0])
else:
oInspector.deselect()

match oEditingTools.TOOL_SELECTED:
oEditingTools.RECTANGLE:
oRectangleSelection.set_initial_position(cursorTile)
oEditingTools.PAINTBUCKET:
if mode == MODE_TILE:
oSelection.construct_shape_for_placement(oSelection.CONSTRUCT_FILL)
pass


# Holding down button
if Input.is_action_pressed("mouse_left"):
Expand Down
Loading