Implementation
List<FWidget<T>> buildDebugCompControls() {
if (targetComp case CTransform<T> t) return [
// position
FRow(app,
gap: 8,
children: [
sizedTitle('Position'),
],
),
FRow(app,
gap: 8,
children: [
// x
sizedTitle(t.position.x.f2, width: 75),
// TODO: (DEBUG) came up with different control, slider is dumb
FSlider(app,
min: 0,
max: screenWidth,
initialValue: t.position.x,
onChangeEndFn: (_, v) => setState(() => t.position.x = v),
),
// y
sizedTitle(t.position.y.f2, width: 75),
// TODO: (DEBUG) came up with different control, slider is dumb
FSlider(app,
min: 0,
max: screenHeight,
initialValue: t.position.y,
onChangeEndFn: (_, v) => setState(() => t.position.y = v),
),
],
),
// rotation (in radians)
FRow(app,
gap: 8,
children: [
sizedTitle('Rotation'),
],
),
FRow(app,
gap: 8,
children: [
sizedTitle(t.rotation.f2, width: 50),
FSlider(app,
min: 0,
max: 2 * math.pi,
initialValue: t.rotation,
onChangeEndFn: (_, v) => setState(() => t.rotation = v),
),
],
),
// scale
FRow(app,
gap: 8,
children: [
sizedTitle('Scale'),
],
),
FRow(app,
gap: 8,
children: [
// x
sizedTitle(t.scale.x.f2, width: 50),
FSlider(app,
min: 0,
max: 10,
initialValue: t.scale.x,
onChangeEndFn: (_, v) => setState(() {
t.entity.getAll<IsComponentScaleMutable<T>>()
.forEach((c) => c.setActive(false));
t.scale.x = v;
}),
),
// y
sizedTitle(t.scale.y.f2, width: 50),
FSlider(app,
min: 0,
max: 10,
initialValue: t.scale.y,
onChangeEndFn: (_, v) => setState(() {
t.entity.getAll<IsComponentScaleMutable<T>>()
.forEach((c) => c.setActive(false));
t.scale.y = v;
}),
),
],
),
];
if (targetComp case CVelocity<T> t) return [
// velocity
FRow(app,
gap: 8,
children: [
sizedTitle('Velocity'),
],
),
FRow(app,
gap: 8,
children: [
// x
sizedTitle(t.velocity.x.f2, width: 50),
FSlider(app,
min: -9999,
max: 9999,
initialValue: t.velocity.x,
onChangeEndFn: (_, v) => setState(() => t.velocity.x = v),
),
// y
sizedTitle(t.velocity.y.f2, width: 50),
FSlider(app,
min: -9999,
max: 9999,
initialValue: t.velocity.y,
onChangeEndFn: (_, v) => setState(() => t.velocity.y = v),
),
],
),
// angularVelocity (in radians)
FRow(app,
gap: 8,
children: [
sizedTitle('Angular Velocity'),
],
),
FRow(app,
gap: 8,
children: [
sizedTitle(t.angularVelocity.f2, width: 50),
FSlider(app,
min: -2 * math.pi,
max: 2 * math.pi,
initialValue: t.angularVelocity,
onChangeEndFn: (_, v) => setState(() => t.angularVelocity = v),
),
],
),
// linearDamping (in radians)
FRow(app,
gap: 8,
children: [
sizedTitle('Linear Damping'),
],
),
FRow(app,
gap: 8,
children: [
sizedTitle(t.linearDamping.f2, width: 50),
FSlider(app,
min: -2 * math.pi,
max: 2 * math.pi,
initialValue: t.linearDamping,
onChangeEndFn: (_, v) => setState(() => t.linearDamping = v),
),
],
),
// angularDamping (in radians)
FRow(app,
gap: 8,
children: [
sizedTitle('Angular Damping'),
],
),
FRow(app,
gap: 8,
children: [
sizedTitle(t.angularDamping.f2, width: 50),
FSlider(app,
min: -2 * math.pi,
max: 2 * math.pi,
initialValue: t.angularDamping,
onChangeEndFn: (_, v) => setState(() => t.angularDamping = v),
),
],
),
// TODO: (DEBUG) maxVelocity (nullable)
];
// TODO: (DEBUG) CRectCollider
// TODO: (DEBUG) CBoundsBounce
// TODO: (DEBUG) CPulse
return [];
// throw UnimplementedError('Unknown component $targetComp for debug info.');
}