Implement Phase 6 features for Stickman Editor
- Updated BUGS.md with new issues related to selection bounding box, touchpad panning speed, and zooming behavior. - Enhanced PROJECT.md with detailed specifications for touchpad controls, recent colors in the color picker, and a status bar for project information. - Modified project.godot to update compatibility version to 4.7. - Added a status bar in stickman_editor.tscn to display cursor coordinates and snap status. - Updated body_part_panel.gd to handle recent colors and cursor detection over drawing areas. - Enhanced stickman_editor.gd to manage cursor coordinates display and recent colors tracking. - Improved whole_stickman_preview.gd to render selection gizmos on top of other parts. - Created master_rig.tscn for the stickman rig structure with bones and IK targets. - Developed master_rig_builder.gd to automate the rig building process with remote transforms and IK modifications.
This commit is contained in:
@@ -19,6 +19,7 @@ signal shape_changed(shape_data: Array)
|
||||
signal shape_selected()
|
||||
signal shape_copy_requested(shape_dict: Dictionary)
|
||||
signal shape_paste_requested(world_pos: Vector2)
|
||||
signal color_selected(color: Color)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Exported / public properties
|
||||
@@ -269,6 +270,13 @@ func set_has_clipboard(state: bool) -> void:
|
||||
_has_clipboard = state
|
||||
|
||||
|
||||
func set_recent_colors(colors_hex: Array) -> void:
|
||||
for preset in color_picker.get_presets():
|
||||
color_picker.erase_preset(preset)
|
||||
for hex_str in colors_hex:
|
||||
color_picker.add_preset(Color.from_string(str(hex_str), Color.BLACK))
|
||||
|
||||
|
||||
func paste_shape(source: Dictionary, target_pos: Vector2) -> void:
|
||||
## Insert a deep copy of the clipboard shape at the given world position.
|
||||
## The shape's points are translated so its center is at target_pos.
|
||||
@@ -293,6 +301,14 @@ func paste_shape(source: Dictionary, target_pos: Vector2) -> void:
|
||||
drawing_area.queue_redraw()
|
||||
_emit_changed()
|
||||
|
||||
|
||||
func is_cursor_over_drawing(global_pos: Vector2) -> bool:
|
||||
return drawing_area.get_global_rect().has_point(global_pos)
|
||||
|
||||
|
||||
func global_to_world(global_pos: Vector2) -> Vector2:
|
||||
return _screen_to_world(global_pos - drawing_area.global_position)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Internal helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -427,6 +443,22 @@ func _draw_polyline(pts: PackedVector2Array, color: Color, closed: bool, width:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
func _on_drawing_area_gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMagnifyGesture:
|
||||
var mag := event as InputEventMagnifyGesture
|
||||
var cursor_local := drawing_area.get_local_mouse_position()
|
||||
var world := _screen_to_world(cursor_local)
|
||||
_zoom = clampf(_zoom * mag.factor, MIN_ZOOM, MAX_ZOOM)
|
||||
_pan_offset = cursor_local - world * _zoom
|
||||
drawing_area.queue_redraw()
|
||||
return
|
||||
|
||||
if event is InputEventPanGesture:
|
||||
var pan := event as InputEventPanGesture
|
||||
_pan_offset -= pan.delta * 3.0
|
||||
_dragging_vertex = -1
|
||||
drawing_area.queue_redraw()
|
||||
return
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
var mb := event as InputEventMouseButton
|
||||
|
||||
@@ -442,11 +474,17 @@ func _on_drawing_area_gui_input(event: InputEvent) -> void:
|
||||
|
||||
# 2. Mouse wheel -> zoom
|
||||
if mb.button_index == MOUSE_BUTTON_WHEEL_UP and mb.pressed:
|
||||
var cursor_local := mb.position
|
||||
var world := _screen_to_world(cursor_local)
|
||||
_zoom = clampf(_zoom * ZOOM_STEP, MIN_ZOOM, MAX_ZOOM)
|
||||
_pan_offset = cursor_local - world * _zoom
|
||||
drawing_area.queue_redraw()
|
||||
return
|
||||
if mb.button_index == MOUSE_BUTTON_WHEEL_DOWN and mb.pressed:
|
||||
var cursor_local := mb.position
|
||||
var world := _screen_to_world(cursor_local)
|
||||
_zoom = clampf(_zoom / ZOOM_STEP, MIN_ZOOM, MAX_ZOOM)
|
||||
_pan_offset = cursor_local - world * _zoom
|
||||
drawing_area.queue_redraw()
|
||||
return
|
||||
|
||||
@@ -468,7 +506,7 @@ func _on_drawing_area_gui_input(event: InputEvent) -> void:
|
||||
var mm := event as InputEventMouseMotion
|
||||
|
||||
if _is_panning:
|
||||
_pan_offset += (mm.position - _pan_start) / _zoom
|
||||
_pan_offset += (mm.position - _pan_start)
|
||||
_pan_start = mm.position
|
||||
drawing_area.queue_redraw()
|
||||
return
|
||||
@@ -878,6 +916,7 @@ func _on_color_picker_changed(new_color: Color) -> void:
|
||||
|
||||
func _on_color_picker_ok() -> void:
|
||||
color_picker_popup.hide()
|
||||
color_selected.emit(color_picker.color)
|
||||
_emit_changed()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user