feat: Zeichenwerkzeug für Segmente im Whiteboard hinzufügen
- Linksziehen erzeugt gerade Segmente, Züge werden an der Bande geklemmt - Toolbar schaltet Richtung und Kante für das nächste Segment - Darstellung: vorwärts durchgezogen, rückwärts gestrichelt, außen rot, innen blau - Ghosting inaktiver Sections mit 20 % Deckkraft vorbereitet - Undo für das letzte Segment, Statusleiste mit Segmentanzahl und Dauer - Controller-, Drag- und Modelltests ergänzt (135 Assertions)
This commit is contained in:
parent
b1e2bf5221
commit
a0ad7db844
11 changed files with 896 additions and 30 deletions
|
|
@ -91,6 +91,13 @@ eine Abkürzung. So kann die UI Fehler konkret anzeigen.
|
|||
Mittelkreis und behandelt Pan/Zoom (Maus, Touch, Pinch).
|
||||
- **Controller** übersetzt Touch-/Maus-Eingaben in Modelloperationen
|
||||
(Segment anlegen, Kante umschalten, Section wechseln, Playback steuern).
|
||||
- **Erstes Zeichenwerkzeug:** `WhiteboardController` hält eine Draft-Routine
|
||||
mit einer Section. Linksziehen erzeugt ein gerades `PathSegment`; die
|
||||
Toolbar schaltet Richtung (vorwärts/rückwärts) und Kante (innen/außen) für
|
||||
das nächste Segment. Die Dauer wird mit 6 m/s aus der Länge abgeleitet,
|
||||
Züge über die Bande werden per `clamp_point()` auf die Eisfläche begrenzt.
|
||||
- **Darstellung:** vorwärts durchgezogen, rückwärts gestrichelt, außen rot,
|
||||
innen blau. Inaktive Sections werden mit 20 % Deckkraft geghostet.
|
||||
- **Ghosting** ist reine View-Logik: pro Section ein eigener Layer,
|
||||
inaktive Layer auf 20 % Deckkraft, `mouse_filter = IGNORE`.
|
||||
- **Playback** samplet `Curve2D` nach Bogenlänge (`get_baked_length()` /
|
||||
|
|
@ -136,10 +143,12 @@ Headless, ohne Editor und ohne Display:
|
|||
|
||||
Aktueller Stand:
|
||||
|
||||
- **Model:** 36 Assertions für Rink-Geometrie, Segment-Timing,
|
||||
- **Model:** 42 Assertions für Rink-Geometrie, Clamping, Segment-Timing,
|
||||
Section-Aggregation und Routine-Validierung.
|
||||
- **Canvas:** 67 Assertions für Meter→Pixel-Mapping, Fit/Zoom/Pan und die
|
||||
Rink-Kontur inklusive Eckradien.
|
||||
- **Whiteboard:** 26 Assertions für Controller-Verdrahtung, Segmenterzeugung,
|
||||
Klemmen an der Bande, Undo und den Maus-Drag-Pfad.
|
||||
|
||||
Visuelle Smoke-Tests laufen zusätzlich über `xvfb-run` und einen
|
||||
Viewport-Screenshot; sie ersetzen die headless Tests nicht.
|
||||
|
|
@ -151,11 +160,11 @@ Viewport-Screenshot; sie ersetzen die headless Tests nicht.
|
|||
2. **Element-Instanzen:** Aktuell verweist `PathSegment.element_id` auf ein
|
||||
Element. Ob Sprünge/Pirouetten eigene Instanzen mit Position und Zeit
|
||||
brauchen, wird mit dem Regelmodell entschieden.
|
||||
3. **Undo/Redo:** Command-Pattern im Controller oder Resource-Snapshots –
|
||||
Entscheidung vor dem ersten Zeichen-Tool.
|
||||
3. **Undo/Redo:** Aktuell entfernt „Rückgängig“ nur das letzte Segment.
|
||||
Vollständiges Undo/Redo (Command-Pattern oder Snapshots) bleibt offen.
|
||||
4. **Section-Übergänge:** Ob Sections eine explizite Startzeit erhalten oder
|
||||
ausschließlich aus Segmentdauern abgeleitet werden, klärt die
|
||||
Playback-Implementierung.
|
||||
5. **Zeichenwerkzeug:** Ob freie Kurven direkt als Bézier-Segmente oder über
|
||||
Template-Geometrie (Lobe, Bogen, Acht) entstehen, entscheidet der erste
|
||||
Tool-Prototyp. Der 3D-Prototyp ist nicht mehr die Hauptszene.
|
||||
5. **Kurven und Templates:** Das erste Werkzeug erzeugt gerade Segmente.
|
||||
Ob freie Kurven direkt als Bézier-Segmente oder über Template-Geometrie
|
||||
(Lobe, Bogen, Acht) entstehen, ist der nächste Tool-Schritt.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,28 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=7 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://src/whiteboard/view/rink_canvas.gd" id="1_canvas"]
|
||||
[ext_resource type="Script" path="res://src/whiteboard/ctrl/whiteboard_controller.gd" id="1_controller"]
|
||||
[ext_resource type="Script" path="res://src/whiteboard/view/rink_canvas.gd" id="2_canvas"]
|
||||
|
||||
[sub_resource type="ButtonGroup" id="ButtonGroup_direction"]
|
||||
[sub_resource type="ButtonGroup" id="ButtonGroup_edge"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_top"]
|
||||
content_margin_left = 16.0
|
||||
content_margin_top = 8.0
|
||||
content_margin_right = 16.0
|
||||
content_margin_bottom = 8.0
|
||||
bg_color = Color(0.0588235, 0.0901961, 0.164706, 1)
|
||||
border_width_bottom = 1
|
||||
border_color = Color(0.121569, 0.160784, 0.219608, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_status"]
|
||||
content_margin_left = 16.0
|
||||
content_margin_top = 4.0
|
||||
content_margin_right = 16.0
|
||||
content_margin_bottom = 4.0
|
||||
bg_color = Color(0.0431373, 0.0705882, 0.12549, 1)
|
||||
border_width_top = 1
|
||||
border_color = Color(0.121569, 0.160784, 0.219608, 1)
|
||||
|
||||
[node name="Whiteboard" type="Control"]
|
||||
layout_mode = 3
|
||||
|
|
@ -9,24 +31,137 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_controller")
|
||||
|
||||
[node name="RinkCanvas" type="Control" parent="."]
|
||||
[node name="Layout" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
clip_contents = true
|
||||
script = ExtResource("1_canvas")
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="HelpLabel" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 16.0
|
||||
offset_top = 12.0
|
||||
offset_right = 760.0
|
||||
offset_bottom = 40.0
|
||||
theme_override_colors/font_color = Color(0.85098, 0.890196, 0.941176, 1)
|
||||
[node name="TopBar" type="PanelContainer" parent="Layout"]
|
||||
custom_minimum_size = Vector2(0, 72)
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_top")
|
||||
|
||||
[node name="Tools" type="HBoxContainer" parent="Layout/TopBar"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="Title" type="Label" parent="Layout/TopBar/Tools"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.882353, 0.909804, 0.941176, 1)
|
||||
theme_override_font_sizes/font_size = 22
|
||||
text = "Rinkplanner"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="TitleSeparator" type="VSeparator" parent="Layout/TopBar/Tools"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DrawButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(112, 48)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "Rinkplanner – Whiteboard | Pan: mittlere Maustaste / 2 Finger | Zoom: Mausrad / Pinch"
|
||||
mouse_filter = 2
|
||||
toggle_mode = true
|
||||
button_pressed = true
|
||||
text = "Zeichnen"
|
||||
|
||||
[node name="DrawSeparator" type="VSeparator" parent="Layout/TopBar/Tools"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DirectionLabel" type="Label" parent="Layout/TopBar/Tools"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Richtung"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ForwardButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(104, 48)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
toggle_mode = true
|
||||
button_pressed = true
|
||||
button_group = SubResource("ButtonGroup_direction")
|
||||
text = "Vorwärts"
|
||||
|
||||
[node name="BackwardButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(104, 48)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
toggle_mode = true
|
||||
button_group = SubResource("ButtonGroup_direction")
|
||||
text = "Rückwärts"
|
||||
|
||||
[node name="EdgeSeparator" type="VSeparator" parent="Layout/TopBar/Tools"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="EdgeLabel" type="Label" parent="Layout/TopBar/Tools"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Kante"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="InsideButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(88, 48)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
toggle_mode = true
|
||||
button_group = SubResource("ButtonGroup_edge")
|
||||
text = "Innen"
|
||||
|
||||
[node name="OutsideButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(88, 48)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
toggle_mode = true
|
||||
button_pressed = true
|
||||
button_group = SubResource("ButtonGroup_edge")
|
||||
text = "Außen"
|
||||
|
||||
[node name="Spacer" type="Control" parent="Layout/TopBar/Tools"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="UndoButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(120, 48)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "Rückgängig"
|
||||
|
||||
[node name="FitButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(110, 48)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "Einpassen"
|
||||
|
||||
[node name="RinkCanvas" type="Control" parent="Layout"]
|
||||
unique_name_in_owner = true
|
||||
clip_contents = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("2_canvas")
|
||||
|
||||
[node name="StatusBar" type="PanelContainer" parent="Layout"]
|
||||
custom_minimum_size = Vector2(0, 32)
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_status")
|
||||
|
||||
[node name="StatusLabel" type="Label" parent="Layout/StatusBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Abschnitt 1 · 0 Segmente"
|
||||
vertical_alignment = 1
|
||||
|
|
|
|||
|
|
@ -63,6 +63,37 @@ func contains_point(point: Vector2) -> bool:
|
|||
return dx * dx + dy * dy <= radius * radius + BOUNDARY_EPSILON
|
||||
|
||||
|
||||
## Moves a point onto the nearest valid position inside the rink. Used while
|
||||
## drawing so a drag to the boards ends exactly on the surface.
|
||||
func clamp_point(point: Vector2) -> Vector2:
|
||||
if contains_point(point):
|
||||
return point
|
||||
if not is_valid():
|
||||
return point
|
||||
|
||||
var half_length := get_half_length()
|
||||
var half_width := get_half_width()
|
||||
var radius := minf(corner_radius_m, minf(half_length, half_width))
|
||||
var clamped := Vector2(
|
||||
clampf(point.x, -half_length, half_length),
|
||||
clampf(point.y, -half_width, half_width)
|
||||
)
|
||||
|
||||
if radius <= 0.0:
|
||||
return clamped
|
||||
|
||||
var inner_x := half_length - radius
|
||||
var inner_y := half_width - radius
|
||||
if absf(clamped.x) <= inner_x or absf(clamped.y) <= inner_y:
|
||||
return clamped
|
||||
|
||||
var corner_center := Vector2(signf(clamped.x) * inner_x, signf(clamped.y) * inner_y)
|
||||
var direction := clamped - corner_center
|
||||
if direction.length_squared() <= 0.0:
|
||||
return clamped
|
||||
return corner_center + direction.normalized() * radius
|
||||
|
||||
|
||||
## Returns the rink outline as a closed polygon in model coordinates. The
|
||||
## rounded corners are approximated with [param arc_segments] segments each.
|
||||
func get_outline_points(arc_segments: int = 8) -> PackedVector2Array:
|
||||
|
|
|
|||
193
rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd
Normal file
193
rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
class_name WhiteboardController
|
||||
extends Control
|
||||
|
||||
## Root controller for the Phase 1 whiteboard. Owns the draft routine, turns
|
||||
## canvas gestures into model mutations and keeps the toolbar/status in sync.
|
||||
|
||||
const DEFAULT_SPEED_MPS := 6.0
|
||||
const MIN_SEGMENT_LENGTH_M := 0.3
|
||||
|
||||
@onready var rink_canvas: RinkCanvas = %RinkCanvas
|
||||
@onready var draw_button: Button = %DrawButton
|
||||
@onready var forward_button: Button = %ForwardButton
|
||||
@onready var backward_button: Button = %BackwardButton
|
||||
@onready var inside_button: Button = %InsideButton
|
||||
@onready var outside_button: Button = %OutsideButton
|
||||
@onready var undo_button: Button = %UndoButton
|
||||
@onready var fit_button: Button = %FitButton
|
||||
@onready var status_label: Label = %StatusLabel
|
||||
|
||||
var _routine: Routine
|
||||
var _active_section: RoutineSection
|
||||
var _current_segment: PathSegment
|
||||
var _segment_counter: int = 0
|
||||
var _direction: PathSegment.Direction = PathSegment.Direction.FORWARD
|
||||
var _edge: PathSegment.Edge = PathSegment.Edge.OUTSIDE
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_routine = Routine.new()
|
||||
_routine.routine_id = "draft-routine"
|
||||
_routine.title = "Neue Kür"
|
||||
_routine.rink = RinkDimensions.new()
|
||||
|
||||
_active_section = RoutineSection.new()
|
||||
_active_section.section_id = "section-1"
|
||||
_active_section.title = "Abschnitt 1"
|
||||
_active_section.sequence_order = 0
|
||||
|
||||
var sections: Array[RoutineSection] = []
|
||||
sections.append(_active_section)
|
||||
_routine.sections = sections
|
||||
|
||||
rink_canvas.set_routine(_routine)
|
||||
rink_canvas.set_active_section(_active_section.section_id)
|
||||
rink_canvas.set_drawing_enabled(draw_button.button_pressed)
|
||||
|
||||
draw_button.toggled.connect(_on_draw_toggled)
|
||||
forward_button.pressed.connect(
|
||||
_on_direction_pressed.bind(PathSegment.Direction.FORWARD)
|
||||
)
|
||||
backward_button.pressed.connect(
|
||||
_on_direction_pressed.bind(PathSegment.Direction.BACKWARD)
|
||||
)
|
||||
inside_button.pressed.connect(_on_edge_pressed.bind(PathSegment.Edge.INSIDE))
|
||||
outside_button.pressed.connect(_on_edge_pressed.bind(PathSegment.Edge.OUTSIDE))
|
||||
undo_button.pressed.connect(undo_last_segment)
|
||||
fit_button.pressed.connect(rink_canvas.fit_rink)
|
||||
|
||||
rink_canvas.draw_started.connect(_on_draw_started)
|
||||
rink_canvas.draw_updated.connect(_on_draw_updated)
|
||||
rink_canvas.draw_finished.connect(_on_draw_finished)
|
||||
rink_canvas.draw_cancelled.connect(_on_draw_cancelled)
|
||||
|
||||
_update_status()
|
||||
|
||||
|
||||
func get_routine() -> Routine:
|
||||
return _routine
|
||||
|
||||
|
||||
func get_active_section() -> RoutineSection:
|
||||
return _active_section
|
||||
|
||||
|
||||
## Adds a complete segment programmatically. Also used by template tools and
|
||||
## by the visual test harness.
|
||||
func add_segment(
|
||||
start: Vector2,
|
||||
end: Vector2,
|
||||
direction: PathSegment.Direction,
|
||||
edge: PathSegment.Edge
|
||||
) -> PathSegment:
|
||||
var segment := _create_segment(start, direction, edge)
|
||||
_update_segment_end(segment, end)
|
||||
_active_section.segments.append(segment)
|
||||
rink_canvas.refresh()
|
||||
_update_status()
|
||||
return segment
|
||||
|
||||
|
||||
func undo_last_segment() -> void:
|
||||
if _current_segment != null:
|
||||
_on_draw_cancelled()
|
||||
return
|
||||
if _active_section == null or _active_section.segments.is_empty():
|
||||
return
|
||||
|
||||
_active_section.segments.pop_back()
|
||||
rink_canvas.refresh()
|
||||
_update_status()
|
||||
|
||||
|
||||
func _on_draw_toggled(enabled: bool) -> void:
|
||||
rink_canvas.set_drawing_enabled(enabled)
|
||||
|
||||
|
||||
func _on_direction_pressed(direction: PathSegment.Direction) -> void:
|
||||
_direction = direction
|
||||
|
||||
|
||||
func _on_edge_pressed(edge: PathSegment.Edge) -> void:
|
||||
_edge = edge
|
||||
|
||||
|
||||
func _on_draw_started(model_point: Vector2) -> void:
|
||||
if _active_section == null:
|
||||
return
|
||||
_current_segment = _create_segment(model_point, _direction, _edge)
|
||||
_active_section.segments.append(_current_segment)
|
||||
rink_canvas.refresh()
|
||||
|
||||
|
||||
func _on_draw_updated(model_point: Vector2) -> void:
|
||||
if _current_segment == null:
|
||||
return
|
||||
_update_segment_end(_current_segment, model_point)
|
||||
rink_canvas.refresh()
|
||||
|
||||
|
||||
func _on_draw_finished(model_point: Vector2) -> void:
|
||||
if _current_segment == null:
|
||||
return
|
||||
|
||||
_update_segment_end(_current_segment, model_point)
|
||||
if _current_segment.get_length_m() < MIN_SEGMENT_LENGTH_M:
|
||||
_active_section.segments.erase(_current_segment)
|
||||
|
||||
_current_segment = null
|
||||
rink_canvas.refresh()
|
||||
_update_status()
|
||||
|
||||
|
||||
func _on_draw_cancelled() -> void:
|
||||
if _current_segment == null:
|
||||
return
|
||||
|
||||
_active_section.segments.erase(_current_segment)
|
||||
_current_segment = null
|
||||
rink_canvas.refresh()
|
||||
_update_status()
|
||||
|
||||
|
||||
func _create_segment(
|
||||
start: Vector2,
|
||||
direction: PathSegment.Direction,
|
||||
edge: PathSegment.Edge
|
||||
) -> PathSegment:
|
||||
_segment_counter += 1
|
||||
|
||||
var segment := PathSegment.new()
|
||||
segment.segment_id = "seg-%03d" % _segment_counter
|
||||
segment.direction = direction
|
||||
segment.edge = edge
|
||||
|
||||
var clamped_start := _routine.rink.clamp_point(start)
|
||||
var curve := Curve2D.new()
|
||||
curve.add_point(clamped_start)
|
||||
curve.add_point(clamped_start)
|
||||
segment.curve = curve
|
||||
segment.duration_seconds = 0.001
|
||||
return segment
|
||||
|
||||
|
||||
func _update_segment_end(segment: PathSegment, end: Vector2) -> void:
|
||||
if segment == null or segment.curve == null or segment.curve.point_count < 2:
|
||||
return
|
||||
|
||||
segment.curve.set_point_position(1, _routine.rink.clamp_point(end))
|
||||
segment.duration_seconds = maxf(segment.get_length_m() / DEFAULT_SPEED_MPS, 0.001)
|
||||
|
||||
|
||||
func _update_status() -> void:
|
||||
var segment_count := _active_section.segments.size()
|
||||
var segment_word := "Segment" if segment_count == 1 else "Segmente"
|
||||
status_label.text = (
|
||||
"%s · %d %s · %.1f s | Links ziehen: zeichnen · Mitte/2 Finger: pan · Rad/Pinch: zoom"
|
||||
% [
|
||||
_active_section.title,
|
||||
segment_count,
|
||||
segment_word,
|
||||
_routine.get_duration_seconds(),
|
||||
]
|
||||
)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cw2cff380acx
|
||||
|
|
@ -1,30 +1,45 @@
|
|||
class_name RinkCanvas
|
||||
extends Control
|
||||
|
||||
## Phase 1 whiteboard canvas: draws the rink in meters and provides pan/zoom.
|
||||
## Phase 1 whiteboard canvas: draws the rink and authored paths in meters.
|
||||
##
|
||||
## This view owns no routine data. A controller assigns the rink dimensions and,
|
||||
## later, the routine to render. All geometry stays in meters until [_draw].
|
||||
## The view owns no routine data. It renders what the controller assigns and
|
||||
## translates raw pointer gestures into high-level draw signals.
|
||||
|
||||
signal view_changed
|
||||
signal draw_started(model_point: Vector2)
|
||||
signal draw_updated(model_point: Vector2)
|
||||
signal draw_finished(model_point: Vector2)
|
||||
signal draw_cancelled
|
||||
|
||||
const BACKGROUND_COLOR := Color("#0b1220")
|
||||
const ICE_COLOR := Color("#eef6fb")
|
||||
const BOARDS_COLOR := Color("#1e293b")
|
||||
const CENTER_LINE_COLOR := Color("#dc2626")
|
||||
const CIRCLE_COLOR := Color("#94a3b8")
|
||||
const OUTSIDE_EDGE_COLOR := Color("#DC2626")
|
||||
const INSIDE_EDGE_COLOR := Color("#2563EB")
|
||||
const OUTLINE_ARC_SEGMENTS := 12
|
||||
const CENTER_CIRCLE_RADIUS_M := 4.5
|
||||
const CENTER_CIRCLE_SEGMENTS := 64
|
||||
const GHOST_ALPHA := 0.2
|
||||
const CURVE_SAMPLE_STEP_PX := 3.0
|
||||
const MAX_CURVE_SAMPLES := 2000
|
||||
|
||||
@export var fit_padding_px: float = 32.0
|
||||
@export var drawing_enabled: bool = true
|
||||
|
||||
var _rink: RinkDimensions = RinkDimensions.new()
|
||||
var _routine: Routine
|
||||
var _active_section_id: String = ""
|
||||
var _transform: CanvasTransform = CanvasTransform.new()
|
||||
var _auto_fit: bool = true
|
||||
|
||||
var _panning: bool = false
|
||||
var _drawing: bool = false
|
||||
var _touch_points: Dictionary[int, Vector2] = {}
|
||||
var _draw_touch_index: int = -1
|
||||
var _pan_touch_index: int = -1
|
||||
var _pinch_center: Vector2 = Vector2.ZERO
|
||||
var _pinch_distance: float = 0.0
|
||||
|
||||
|
|
@ -49,6 +64,30 @@ func get_rink() -> RinkDimensions:
|
|||
return _rink
|
||||
|
||||
|
||||
func set_routine(routine: Routine) -> void:
|
||||
_routine = routine
|
||||
if routine != null and routine.rink != null:
|
||||
_rink = routine.rink
|
||||
if _active_section_id.is_empty() and routine != null and not routine.sections.is_empty():
|
||||
_active_section_id = routine.sections[0].section_id
|
||||
fit_rink()
|
||||
|
||||
|
||||
func set_active_section(section_id: String) -> void:
|
||||
_active_section_id = section_id
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func set_drawing_enabled(enabled: bool) -> void:
|
||||
drawing_enabled = enabled
|
||||
if not enabled:
|
||||
_cancel_drawing()
|
||||
|
||||
|
||||
func refresh() -> void:
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func get_view_transform() -> CanvasTransform:
|
||||
return _transform
|
||||
|
||||
|
|
@ -74,6 +113,7 @@ func _draw() -> void:
|
|||
|
||||
_draw_center_line()
|
||||
_draw_center_circle()
|
||||
_draw_routine()
|
||||
|
||||
if outline.size() >= 3:
|
||||
# draw_polyline has no closed flag: append the first point explicitly.
|
||||
|
|
@ -119,6 +159,138 @@ func _draw_center_circle() -> void:
|
|||
)
|
||||
|
||||
|
||||
func _draw_routine() -> void:
|
||||
if _routine == null:
|
||||
return
|
||||
|
||||
# Ghost all inactive sections first, then draw the active section on top.
|
||||
for section: RoutineSection in _routine.sections:
|
||||
if section != null and section.section_id != _active_section_id:
|
||||
_draw_section(section, GHOST_ALPHA)
|
||||
|
||||
var active := _get_active_section()
|
||||
if active != null:
|
||||
_draw_section(active, 1.0)
|
||||
|
||||
|
||||
func _draw_section(section: RoutineSection, alpha: float) -> void:
|
||||
for segment: PathSegment in section.segments:
|
||||
if segment != null and segment.curve != null:
|
||||
_draw_segment(segment, alpha)
|
||||
|
||||
|
||||
func _draw_segment(segment: PathSegment, alpha: float) -> void:
|
||||
var points := _sample_curve_screen(segment.curve)
|
||||
if points.is_empty():
|
||||
return
|
||||
|
||||
var color := _edge_color(segment.edge)
|
||||
color.a *= alpha
|
||||
var width := maxf(3.0, 0.12 * _transform.pixels_per_meter)
|
||||
|
||||
if points.size() == 1:
|
||||
draw_circle(points[0], width, color)
|
||||
return
|
||||
|
||||
if segment.direction == PathSegment.Direction.BACKWARD:
|
||||
_draw_dashed_polyline(points, color, width)
|
||||
else:
|
||||
draw_polyline(points, color, width, true)
|
||||
|
||||
draw_circle(points[0], maxf(2.0, width * 0.6), color)
|
||||
|
||||
if points[0].distance_to(points[points.size() - 1]) > 8.0:
|
||||
_draw_arrow_head(points, color)
|
||||
|
||||
|
||||
func _draw_dashed_polyline(
|
||||
points: PackedVector2Array,
|
||||
color: Color,
|
||||
width: float
|
||||
) -> void:
|
||||
var dash_length := maxf(8.0, 0.35 * _transform.pixels_per_meter)
|
||||
var gap_length := maxf(6.0, 0.2 * _transform.pixels_per_meter)
|
||||
var drawing := true
|
||||
var remaining := dash_length
|
||||
|
||||
for index: int in range(points.size() - 1):
|
||||
var from := points[index]
|
||||
var to := points[index + 1]
|
||||
var segment_length := from.distance_to(to)
|
||||
if segment_length <= 0.0:
|
||||
continue
|
||||
|
||||
var position := 0.0
|
||||
while position < segment_length:
|
||||
var step := minf(remaining, segment_length - position)
|
||||
if drawing:
|
||||
var start := from.lerp(to, position / segment_length)
|
||||
var end := from.lerp(to, (position + step) / segment_length)
|
||||
draw_line(start, end, color, width, true)
|
||||
|
||||
position += step
|
||||
remaining -= step
|
||||
if remaining <= 0.0001:
|
||||
drawing = not drawing
|
||||
remaining = dash_length if drawing else gap_length
|
||||
|
||||
|
||||
func _draw_arrow_head(points: PackedVector2Array, color: Color) -> void:
|
||||
var tip := points[points.size() - 1]
|
||||
var base := tip
|
||||
for index: int in range(points.size() - 2, -1, -1):
|
||||
if points[index].distance_to(tip) >= 6.0:
|
||||
base = points[index]
|
||||
break
|
||||
|
||||
var direction := (tip - base).normalized()
|
||||
if direction.length_squared() <= 0.0:
|
||||
return
|
||||
|
||||
var normal := Vector2(-direction.y, direction.x)
|
||||
var size := maxf(8.0, 0.45 * _transform.pixels_per_meter)
|
||||
draw_colored_polygon(
|
||||
PackedVector2Array([
|
||||
tip,
|
||||
tip - direction * size + normal * size * 0.45,
|
||||
tip - direction * size - normal * size * 0.45,
|
||||
]),
|
||||
color
|
||||
)
|
||||
|
||||
|
||||
func _sample_curve_screen(curve: Curve2D) -> PackedVector2Array:
|
||||
var curve_length := curve.get_baked_length()
|
||||
if curve_length <= 0.0:
|
||||
if curve.point_count == 0:
|
||||
return PackedVector2Array()
|
||||
return PackedVector2Array([_transform.model_to_screen(curve.get_point_position(0))])
|
||||
|
||||
var step_m := maxf(0.01, CURVE_SAMPLE_STEP_PX / _transform.pixels_per_meter)
|
||||
var sample_count: int = clampi(ceili(curve_length / step_m), 1, MAX_CURVE_SAMPLES)
|
||||
var points := PackedVector2Array()
|
||||
points.resize(sample_count + 1)
|
||||
for index: int in range(sample_count + 1):
|
||||
var offset := curve_length * float(index) / float(sample_count)
|
||||
points[index] = _transform.model_to_screen(curve.sample_baked(offset))
|
||||
return points
|
||||
|
||||
|
||||
func _edge_color(edge: PathSegment.Edge) -> Color:
|
||||
if edge == PathSegment.Edge.OUTSIDE:
|
||||
return OUTSIDE_EDGE_COLOR
|
||||
return INSIDE_EDGE_COLOR
|
||||
|
||||
|
||||
func _get_active_section() -> RoutineSection:
|
||||
if _routine == null:
|
||||
return null
|
||||
for section: RoutineSection in _routine.sections:
|
||||
if section != null and section.section_id == _active_section_id:
|
||||
return section
|
||||
return null
|
||||
|
||||
|
||||
func _to_screen(model_points: PackedVector2Array) -> PackedVector2Array:
|
||||
var screen_points := PackedVector2Array()
|
||||
screen_points.resize(model_points.size())
|
||||
|
|
@ -128,10 +300,16 @@ func _to_screen(model_points: PackedVector2Array) -> PackedVector2Array:
|
|||
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
# Touch input also produces emulated mouse events. While a finger is down,
|
||||
# the touch handlers own the gesture.
|
||||
if not _touch_points.is_empty():
|
||||
if event is InputEventMouseButton or event is InputEventMouseMotion:
|
||||
return
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
_handle_mouse_button(event as InputEventMouseButton)
|
||||
elif event is InputEventMouseMotion and _panning:
|
||||
_apply_pan((event as InputEventMouseMotion).relative)
|
||||
elif event is InputEventMouseMotion:
|
||||
_handle_mouse_motion(event as InputEventMouseMotion)
|
||||
elif event is InputEventPanGesture:
|
||||
_apply_pan(-(event as InputEventPanGesture).delta * 16.0)
|
||||
elif event is InputEventScreenTouch:
|
||||
|
|
@ -143,24 +321,66 @@ func _gui_input(event: InputEvent) -> void:
|
|||
func _handle_mouse_button(event: InputEventMouseButton) -> void:
|
||||
match event.button_index:
|
||||
MOUSE_BUTTON_WHEEL_UP:
|
||||
if event.pressed:
|
||||
if event.pressed and not _drawing:
|
||||
_zoom_at(event.position, 1.1)
|
||||
accept_event()
|
||||
MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if event.pressed:
|
||||
if event.pressed and not _drawing:
|
||||
_zoom_at(event.position, 1.0 / 1.1)
|
||||
accept_event()
|
||||
MOUSE_BUTTON_MIDDLE:
|
||||
if event.pressed:
|
||||
_cancel_drawing()
|
||||
_panning = event.pressed
|
||||
accept_event()
|
||||
MOUSE_BUTTON_LEFT:
|
||||
if event.pressed:
|
||||
if drawing_enabled and _begin_drawing(event.position):
|
||||
accept_event()
|
||||
else:
|
||||
_panning = true
|
||||
accept_event()
|
||||
else:
|
||||
if _drawing:
|
||||
_finish_drawing(event.position)
|
||||
accept_event()
|
||||
elif _panning:
|
||||
_panning = false
|
||||
accept_event()
|
||||
|
||||
|
||||
func _handle_mouse_motion(event: InputEventMouseMotion) -> void:
|
||||
if _drawing:
|
||||
draw_updated.emit(_transform.screen_to_model(event.position))
|
||||
elif _panning:
|
||||
_apply_pan(event.relative)
|
||||
|
||||
|
||||
func _handle_screen_touch(event: InputEventScreenTouch) -> void:
|
||||
if event.pressed:
|
||||
_touch_points[event.index] = event.position
|
||||
if _touch_points.size() == 1:
|
||||
if drawing_enabled and _begin_drawing(event.position):
|
||||
_draw_touch_index = event.index
|
||||
else:
|
||||
_pan_touch_index = event.index
|
||||
elif _touch_points.size() == 2:
|
||||
_cancel_drawing()
|
||||
_draw_touch_index = -1
|
||||
_pan_touch_index = -1
|
||||
_reset_pinch_reference()
|
||||
else:
|
||||
_touch_points.erase(event.index)
|
||||
_reset_pinch_reference()
|
||||
if event.index == _draw_touch_index:
|
||||
_draw_touch_index = -1
|
||||
_finish_drawing(event.position)
|
||||
if event.index == _pan_touch_index:
|
||||
_pan_touch_index = -1
|
||||
if _touch_points.size() < 2:
|
||||
_reset_pinch_reference()
|
||||
if _touch_points.size() == 1:
|
||||
_pan_touch_index = _touch_points.keys()[0]
|
||||
|
||||
accept_event()
|
||||
|
||||
|
||||
|
|
@ -171,14 +391,39 @@ func _handle_screen_drag(event: InputEventScreenDrag) -> void:
|
|||
var previous: Vector2 = _touch_points[event.index]
|
||||
_touch_points[event.index] = event.position
|
||||
|
||||
if _touch_points.size() == 1:
|
||||
_apply_pan(event.position - previous)
|
||||
if _drawing and event.index == _draw_touch_index:
|
||||
draw_updated.emit(_transform.screen_to_model(event.position))
|
||||
elif _touch_points.size() >= 2:
|
||||
_update_pinch()
|
||||
elif event.index == _pan_touch_index:
|
||||
_apply_pan(event.position - previous)
|
||||
|
||||
accept_event()
|
||||
|
||||
|
||||
func _begin_drawing(screen_point: Vector2) -> bool:
|
||||
var model_point := _transform.screen_to_model(screen_point)
|
||||
if not _rink.contains_point(model_point):
|
||||
return false
|
||||
_drawing = true
|
||||
draw_started.emit(model_point)
|
||||
return true
|
||||
|
||||
|
||||
func _finish_drawing(screen_point: Vector2) -> void:
|
||||
if not _drawing:
|
||||
return
|
||||
_drawing = false
|
||||
draw_finished.emit(_transform.screen_to_model(screen_point))
|
||||
|
||||
|
||||
func _cancel_drawing() -> void:
|
||||
if not _drawing:
|
||||
return
|
||||
_drawing = false
|
||||
draw_cancelled.emit()
|
||||
|
||||
|
||||
func _reset_pinch_reference() -> void:
|
||||
var points := _get_two_touch_points()
|
||||
if points.size() < 2:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ $GODOT --headless --path rinkplanner --script res://tests/run_model_tests.gd
|
|||
|
||||
# Run canvas transform/geometry tests
|
||||
$GODOT --headless --path rinkplanner --script res://tests/run_canvas_tests.gd
|
||||
|
||||
# Run whiteboard controller/scene tests
|
||||
$GODOT --headless --path rinkplanner --script res://tests/run_whiteboard_tests.gd
|
||||
```
|
||||
|
||||
Exit code `0` means all assertions passed. Failures are printed to stderr.
|
||||
|
|
|
|||
|
|
@ -46,6 +46,41 @@ func _test_rink_geometry() -> void:
|
|||
var outside_curve := _make_curve(Vector2(-35.0, 0.0), Vector2(35.0, 0.0))
|
||||
_check(not rink.contains_curve(outside_curve), "curve leaving the rink is rejected")
|
||||
|
||||
_check_vec(
|
||||
rink.clamp_point(Vector2(1.0, 2.0)),
|
||||
Vector2(1.0, 2.0),
|
||||
"clamp leaves points inside the rink unchanged"
|
||||
)
|
||||
_check_vec(
|
||||
rink.clamp_point(Vector2(35.0, 0.0)),
|
||||
Vector2(30.0, 0.0),
|
||||
"clamp moves a point outside the long board onto the board"
|
||||
)
|
||||
_check_vec(
|
||||
rink.clamp_point(Vector2(0.0, 20.0)),
|
||||
Vector2(0.0, 15.0),
|
||||
"clamp moves a point outside the short board onto the board"
|
||||
)
|
||||
|
||||
var clamped_corner := rink.clamp_point(Vector2(35.0, 20.0))
|
||||
_check_approx(
|
||||
clamped_corner.distance_to(Vector2(21.5, 6.5)),
|
||||
8.5,
|
||||
"clamp projects corner points onto the corner arc"
|
||||
)
|
||||
_check(
|
||||
rink.contains_point(clamped_corner),
|
||||
"clamped corner point lies on the rink surface"
|
||||
)
|
||||
|
||||
var rectangular: RinkDimensions = RinkDimensionsModel.new()
|
||||
rectangular.corner_radius_m = 0.0
|
||||
_check_vec(
|
||||
rectangular.clamp_point(Vector2(35.0, 20.0)),
|
||||
Vector2(30.0, 15.0),
|
||||
"clamp falls back to the rectangle without rounded corners"
|
||||
)
|
||||
|
||||
|
||||
func _test_segment_timing() -> void:
|
||||
var segment: PathSegment = PathSegmentModel.new()
|
||||
|
|
@ -222,6 +257,13 @@ func _check_approx(actual: float, expected: float, message: String) -> void:
|
|||
)
|
||||
|
||||
|
||||
func _check_vec(actual: Vector2, expected: Vector2, message: String) -> void:
|
||||
_check(
|
||||
actual.distance_to(expected) <= 0.001,
|
||||
"%s (expected %s, got %s)" % [message, expected, actual]
|
||||
)
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
if _failures.is_empty():
|
||||
print("PASS: %d assertions" % _assertions)
|
||||
|
|
|
|||
203
rinkplanner/tests/run_whiteboard_tests.gd
Normal file
203
rinkplanner/tests/run_whiteboard_tests.gd
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
extends SceneTree
|
||||
|
||||
## Headless test for the whiteboard controller wiring. It instantiates the real
|
||||
## scene, so it also verifies that toolbar nodes and unique names resolve.
|
||||
##
|
||||
## Run with:
|
||||
## godot --headless --path rinkplanner --script res://tests/run_whiteboard_tests.gd
|
||||
|
||||
const WhiteboardScene := preload("res://scenes/whiteboard/whiteboard.tscn")
|
||||
|
||||
var _assertions: int = 0
|
||||
var _failures: PackedStringArray = PackedStringArray()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_run.call_deferred()
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var scene := WhiteboardScene.instantiate()
|
||||
root.add_child(scene)
|
||||
await process_frame
|
||||
|
||||
var controller := scene as WhiteboardController
|
||||
_check(controller != null, "whiteboard scene has a controller")
|
||||
if controller == null:
|
||||
_finish()
|
||||
return
|
||||
|
||||
var routine := controller.get_routine()
|
||||
var section := controller.get_active_section()
|
||||
_check(routine != null, "controller owns a routine")
|
||||
_check(section != null, "controller owns an active section")
|
||||
_check(
|
||||
routine != null and not routine.is_valid(),
|
||||
"empty draft routine is not valid yet"
|
||||
)
|
||||
_check(
|
||||
routine != null and _contains_error(routine.validate(), "at least one segment"),
|
||||
"empty draft reports the missing segment"
|
||||
)
|
||||
|
||||
var first := controller.add_segment(
|
||||
Vector2(-20.0, -5.0),
|
||||
Vector2(-5.0, -5.0),
|
||||
PathSegment.Direction.FORWARD,
|
||||
PathSegment.Edge.OUTSIDE
|
||||
)
|
||||
_check(
|
||||
section.segments.size() == 1,
|
||||
"add_segment appends to the active section"
|
||||
)
|
||||
_check(first.segment_id == "seg-001", "segment ids are generated")
|
||||
_check_approx(first.get_length_m(), 15.0, "segment length comes from the curve")
|
||||
_check_approx(
|
||||
first.duration_seconds,
|
||||
15.0 / WhiteboardController.DEFAULT_SPEED_MPS,
|
||||
"segment duration is derived from the default speed"
|
||||
)
|
||||
_check(
|
||||
first.direction == PathSegment.Direction.FORWARD,
|
||||
"segment keeps the requested direction"
|
||||
)
|
||||
_check(
|
||||
first.edge == PathSegment.Edge.OUTSIDE,
|
||||
"segment keeps the requested edge"
|
||||
)
|
||||
|
||||
var second := controller.add_segment(
|
||||
Vector2(-5.0, -5.0),
|
||||
Vector2(5.0, 5.0),
|
||||
PathSegment.Direction.BACKWARD,
|
||||
PathSegment.Edge.INSIDE
|
||||
)
|
||||
_check(
|
||||
second.direction == PathSegment.Direction.BACKWARD,
|
||||
"second segment can be backward"
|
||||
)
|
||||
_check(
|
||||
second.edge == PathSegment.Edge.INSIDE,
|
||||
"second segment can be inside"
|
||||
)
|
||||
|
||||
var third := controller.add_segment(
|
||||
Vector2(25.0, 10.0),
|
||||
Vector2(40.0, 20.0),
|
||||
PathSegment.Direction.FORWARD,
|
||||
PathSegment.Edge.INSIDE
|
||||
)
|
||||
_check(
|
||||
routine.rink.contains_point(third.curve.get_point_position(1)),
|
||||
"segments drawn beyond the boards are clamped to the rink"
|
||||
)
|
||||
_check(routine.is_valid(), "routine stays valid after adding three segments")
|
||||
_check(
|
||||
controller.status_label.text.contains("3 Segmente"),
|
||||
"status bar reports the segment count"
|
||||
)
|
||||
|
||||
controller.undo_last_segment()
|
||||
_check(
|
||||
section.segments.size() == 2,
|
||||
"undo removes the last segment"
|
||||
)
|
||||
_check(
|
||||
controller.status_label.text.contains("2 Segmente"),
|
||||
"status bar updates after undo"
|
||||
)
|
||||
|
||||
var fourth := controller.add_segment(
|
||||
Vector2(0.0, -10.0),
|
||||
Vector2(10.0, -10.0),
|
||||
PathSegment.Direction.FORWARD,
|
||||
PathSegment.Edge.OUTSIDE
|
||||
)
|
||||
_check(fourth.segment_id == "seg-004", "segment ids stay unique after undo")
|
||||
_check(routine.is_valid(), "routine stays valid after undo and redraw")
|
||||
|
||||
var canvas := controller.rink_canvas
|
||||
_check(
|
||||
canvas.size.x > 0.0 and canvas.size.y > 0.0,
|
||||
"canvas receives a layout size"
|
||||
)
|
||||
|
||||
var view := canvas.get_view_transform()
|
||||
var segment_count_before := section.segments.size()
|
||||
_mouse_button(canvas, view.model_to_screen(Vector2(-15.0, 5.0)), true)
|
||||
_mouse_motion(canvas, view.model_to_screen(Vector2(-5.0, 5.0)))
|
||||
_mouse_button(canvas, view.model_to_screen(Vector2(-5.0, 5.0)), false)
|
||||
|
||||
_check(
|
||||
section.segments.size() == segment_count_before + 1,
|
||||
"mouse drag creates a segment through the controller"
|
||||
)
|
||||
var dragged := section.segments[section.segments.size() - 1]
|
||||
_check_approx(dragged.get_length_m(), 10.0, "dragged segment uses the drag distance")
|
||||
_check(
|
||||
dragged.direction == PathSegment.Direction.FORWARD,
|
||||
"dragged segment uses the active direction"
|
||||
)
|
||||
_check(
|
||||
dragged.edge == PathSegment.Edge.OUTSIDE,
|
||||
"dragged segment uses the active edge"
|
||||
)
|
||||
|
||||
var tap_point := view.model_to_screen(Vector2(0.0, 10.0))
|
||||
var count_before_tap := section.segments.size()
|
||||
_mouse_button(canvas, tap_point, true)
|
||||
_mouse_button(canvas, tap_point, false)
|
||||
_check(
|
||||
section.segments.size() == count_before_tap,
|
||||
"a tap without drag does not create a segment"
|
||||
)
|
||||
|
||||
scene.queue_free()
|
||||
await process_frame
|
||||
_finish()
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
_assertions += 1
|
||||
if not condition:
|
||||
_failures.append(message)
|
||||
|
||||
|
||||
func _check_approx(actual: float, expected: float, message: String) -> void:
|
||||
_check(
|
||||
absf(actual - expected) <= 0.001,
|
||||
"%s (expected %.3f, got %.3f)" % [message, expected, actual]
|
||||
)
|
||||
|
||||
|
||||
func _mouse_button(canvas: RinkCanvas, position: Vector2, pressed: bool) -> void:
|
||||
var event := InputEventMouseButton.new()
|
||||
event.button_index = MOUSE_BUTTON_LEFT
|
||||
event.pressed = pressed
|
||||
event.position = position
|
||||
canvas._gui_input(event)
|
||||
|
||||
|
||||
func _mouse_motion(canvas: RinkCanvas, position: Vector2) -> void:
|
||||
var event := InputEventMouseMotion.new()
|
||||
event.position = position
|
||||
canvas._gui_input(event)
|
||||
|
||||
|
||||
func _contains_error(errors: PackedStringArray, fragment: String) -> bool:
|
||||
for error: String in errors:
|
||||
if error.contains(fragment):
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
if _failures.is_empty():
|
||||
print("PASS: %d assertions" % _assertions)
|
||||
quit(0)
|
||||
return
|
||||
|
||||
for failure: String in _failures:
|
||||
printerr("FAIL: %s" % failure)
|
||||
printerr("%d of %d assertions failed" % [_failures.size(), _assertions])
|
||||
quit(1)
|
||||
1
rinkplanner/tests/run_whiteboard_tests.gd.uid
Normal file
1
rinkplanner/tests/run_whiteboard_tests.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bbpqj84ece6gn
|
||||
|
|
@ -19,3 +19,6 @@ fi
|
|||
|
||||
"$GODOT" --headless --path "$PROJECT_DIR" \
|
||||
--script res://tests/run_canvas_tests.gd
|
||||
|
||||
"$GODOT" --headless --path "$PROJECT_DIR" \
|
||||
--script res://tests/run_whiteboard_tests.gd
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue