/// @description Handle Manager Step Event
// Check that the oPlacer object exists [oPlacer is the main editor controller object]
// NOTE : valid() is a helper function, it checks that an instance id is not set to noone,
// and that the instance exists.
if ( valid(oPlacer) )
{
// Grab the currently in-focus object from the Editor
// target is an instance id of one of the level objects.
var target = oPlacer.focused_object;
// Check that the in-focus object is valid.
if ( valid ( target ) )
{
// If the user is not currently dragging (they haven't started rotation yet)
if ( !dragging )
{
with ( target )
{
// ROTATION ACTIVATE CHECK
// Check if the mouse is greater than the min distance for rotation to take place.
var min_left = bbox_left - other.min_rotate_distance;
var min_top = bbox_top - other.min_rotate_distance;
var min_bot = bbox_bottom + other.min_rotate_distance;
var min_right = bbox_right + other.min_rotate_distance;
var max_left = min_left - other.max_rotate_distance;
var max_top = min_top - other.max_rotate_distance;
var max_right = min_right + other.max_rotate_distance;
var max_bot = min_bot + other.max_rotate_distance;
// Check if the mouse is greater than the min distance for rotation to take place.
if ( !point_in_rectangle(mouse_x, mouse_y, min_left, min_top, min_right, min_bot) &&
// and check if the mouse is less than the max distance for rotation to take place.
point_in_rectangle(mouse_x, mouse_y, max_left, max_top, max_right, max_bot) )
{
// Mouse is in position - so change the cursor and mode to show the user they can
// initiate rotation by left-clicking and dragging.
other.mode = GrabMode.Rotate;
o_cursor.image_index = 4
// ** oPlacer.ignore_editor ** NOTE:
// This tells the main editor object to ignore clicks temporarily
// Otherwise, when the user clicks to rotate the object, and their click would
// have selected another object, or in the case of there being nothing under the
// cursor, deselecting all objects, it would prevent the rotation tool from working.
// TODO : Would prefer to have this uncoupled from the editor like this eventually.
oPlacer.ignore_editor = true;
}
else
{
// Cursor is not "in the zone" for rotating, so reset the mouse cursor to normal
// and resume normal editor functions.
other.mode = GrabMode.None;
oPlacer.ignore_editor = false;
o_cursor.image_index = 0
}
}
}
// Check for dragging
if ( mouse_check_button_pressed(mb_left) )
{
dragging = true;
start_angle = point_direction(target.x, target.y, mouse_x, mouse_y)
target_start_angle = target.angle;
}
// Check for stop dragging
if ( mouse_check_button_released(mb_left) )
{
dragging = false;
mode = GrabMode.None;
oPlacer.ignore_editor = false;
o_cursor.image_index = 0
}
// Calculate how far the mouse angle has changed from the point where dragging started.
if ( dragging )
{
var current_angle = point_direction(target.x, target.y, mouse_x, mouse_y)
angle_change = angle_difference(start_angle, current_angle)
}
// Apply the appropriate action.
switch ( mode )
{
case GrabMode.None:
window_set_cursor(cr_default);
break;
case GrabMode.Rotate:
window_set_cursor(cr_cross);
target.angle = target_start_angle - angle_change;
break;
}
debug_draw("DRAGGING : " + string(dragging))
debug_draw("ANGLE CHANGE : " + string(angle_change))
}
}