key control and ENTER confirmation when defining points

This commit is contained in:
2025-11-13 08:59:15 -06:00
parent 8ea0280beb
commit 02466903b8
5 changed files with 108 additions and 47 deletions

View File

@@ -49,7 +49,7 @@ interface Director<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSourc
function enterString(prompt:String, submit:String->Void):Void;
function defineStagePosition(camera:Camera, submit:StagePosition->Void, ?oldPosition:StagePosition):Void;
function defineLightSource(submit:LightSource->Void):Void;
function defineLightSource(camera:Camera, submit:LightSource->Void):Void;
function loadSet(path:String):Set;
function cloneSet(set:Set):Set;

View File

@@ -1734,7 +1734,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
} else null;
doingSomething = true;
lastCommand = defineLightSource;
director.defineLightSource(function(source:LightSource) return {
director.defineLightSource(_currentScene().camera, function(source:LightSource) return {
{
{
final arr = lightSources.get(sceneKey);
@@ -2030,7 +2030,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
};
};
default:{
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1017:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1018:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
};
};
};
@@ -2102,7 +2102,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
delayHandling = switch hollywoo.Movie.playMode {
case s124___Movie if (Prelude.truthy(Prelude.isNull(s124___Movie))):{
{
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1187:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1188:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
};
};
case Read:{
@@ -2112,7 +2112,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
AutoWithSkip;
};
default:{
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1187:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1188:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
};
};
cc();
@@ -2121,7 +2121,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
delayHandling = switch mode {
case s129___Movie if (Prelude.truthy(Prelude.isNull(s129___Movie))):{
{
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1195:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1196:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
};
};
case Read:{
@@ -2131,7 +2131,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
AutoWithSkip;
};
default:{
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1195:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1196:13: Assertion failed: \nFrom:[(never otherwise)]", 4);
};
};
cc();
@@ -2330,7 +2330,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
switch _currentScene() {
case s163___Movie if (Prelude.truthy(Prelude.isNull(s163___Movie))):{
{
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1318:9: Assertion failed: \nFrom:[(never otherwise)]", 4);
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1319:9: Assertion failed: \nFrom:[(never otherwise)]", 4);
};
};
case { characters : characters, props : props, propOrder : propOrder, actorAndPropPositionKeys : actorAndPropPositionKeys }:{
@@ -2382,7 +2382,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
};
};
default:{
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1318:9: Assertion failed: \nFrom:[(never otherwise)]", 4);
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1319:9: Assertion failed: \nFrom:[(never otherwise)]", 4);
};
};
}
@@ -2401,7 +2401,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
{
final s171___Movie = Prelude.lesserEqual(0, volumeMod, 1);
{
if (Prelude.truthy(s171___Movie)) s171___Movie else throw kiss.Prelude.runtimeInsertAssertionMessage("", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1322:5: Assertion failed: \nFrom:[(assert (<= 0 volumeMod 1))]", 4);
if (Prelude.truthy(s171___Movie)) s171___Movie else throw kiss.Prelude.runtimeInsertAssertionMessage("", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1323:5: Assertion failed: \nFrom:[(assert (<= 0 volumeMod 1))]", 4);
};
};
{
@@ -2625,7 +2625,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
{
final s204___Movie = Prelude.lesserEqual(0, volumeMod, 1);
{
if (Prelude.truthy(s204___Movie)) s204___Movie else throw kiss.Prelude.runtimeInsertAssertionMessage("", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1420:5: Assertion failed: \nFrom:[(assert (<= 0 volumeMod 1))]", 4);
if (Prelude.truthy(s204___Movie)) s204___Movie else throw kiss.Prelude.runtimeInsertAssertionMessage("", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1421:5: Assertion failed: \nFrom:[(assert (<= 0 volumeMod 1))]", 4);
};
};
currentSong = FuzzyMapTools.bestMatch(songs, name);
@@ -3093,7 +3093,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
switch headingLineData {
case s361___Movie if (Prelude.truthy(Prelude.isNull(s361___Movie))):{
{
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1724:41: Assertion failed: \nFrom:[(never otherwise)]", 4);
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1725:41: Assertion failed: \nFrom:[(never otherwise)]", 4);
};
};
case [heading, ""]:{
@@ -3109,7 +3109,7 @@ class Movie<Set, Actor, Sound, Song, Prop, VoiceTrack, Camera, LightSource:Jsona
hdPush(new kiss.List(["", credit]));
};
default:{
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1724:41: Assertion failed: \nFrom:[(never otherwise)]", 4);
throw kiss.Prelude.runtimeInsertAssertionMessage("case should never match pattern otherwise", "/Users/nat/repos/hollywoo-flixel/src/hollywoo/Movie.kiss:1725:41: Assertion failed: \nFrom:[(never otherwise)]", 4);
};
};
};

View File

@@ -843,6 +843,7 @@
(set doingSomething true)
(set lastCommand defineLightSource)
(director.defineLightSource
.camera (_currentScene)
->[:LightSource source] {
(let [arr (lightSources.get sceneKey)]
(arr.elements.push source)

View File

@@ -206,7 +206,7 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
};
actionManager.resetOnStateSwitch = NONE;
{
for (i in Prelude.range(0, Prelude.add(1, LAYER_MAX), 1)) {
for (i in Prelude.range(Prelude.add(1, LAYER_MAX))) {
{
final g = new FlxTypedGroup<FlxBasic>();
{
@@ -978,13 +978,30 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
};
}, { wrapPrompt : true });
}
public function defineFlxPoint(submit:(flixel.math.FlxPoint)->Void):Void {
public var marker:flixel.FlxSprite = null;
private var __submit:()->Void = null;
public function defineFlxPoint(marker:flixel.FlxSprite, submit:(flixel.math.FlxPoint)->Void):Void {
if (Prelude.truthy(!Prelude.truthy(mm))) {
mm = new FlxMouseEventManager();
} else null;
this.marker = marker;
final screen = new flixel.FlxSprite();
function _submit() return {
this.marker = null;
mm.remove(screen);
flixel.FlxG.state.remove(screen, true);
{
for (camera in flixel.FlxG.cameras.list) {
camera.zoom = 1;
};
null;
};
submit(new flixel.math.FlxPoint(marker.x, marker.y));
};
__submit = _submit;
flixel.FlxG.state.add(mm);
{
final screen = new flixel.FlxSprite();
final speed = 200;
{
screen.makeGraphic(flixel.FlxG.width, flixel.FlxG.height, flixel.util.FlxColor.fromRGBFloat(0, 1, 0, 0.2));
screen.cameras = new kiss.List([cast(movie, FlxMovie).uiCamera]);
@@ -1000,18 +1017,11 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
cast(movie, FlxMovie).spriteChangeDebugCamera.zoom = 1;
mm.add(screen, function(screen) return {
{
mm.remove(screen);
flixel.FlxG.state.remove(screen, true);
{
final pos = flixel.FlxG.mouse.getScreenPosition(flixel.FlxG.camera);
{
{
for (camera in flixel.FlxG.cameras.list) {
camera.zoom = 1;
};
null;
};
submit(pos);
marker.x = pos.x;
marker.y = pos.y;
};
};
};
@@ -1027,11 +1037,12 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
final db = new DebugLayer();
{
db.cameras = new kiss.List([camera]);
if (Prelude.truthy(oldPos)) {
db.drawCircle(oldPos.x, oldPos.y, 4, flixel.util.FlxColor.YELLOW, 2);
if (Prelude.truthy(!Prelude.truthy(oldPos))) {
oldPos = new StagePosition(0, 0, 0);
} else null;
final marker = db.drawCircle(oldPos.x, oldPos.y, 4, flixel.util.FlxColor.YELLOW, 2);
flixel.FlxG.state.add(db);
defineFlxPoint(function(point) return {
defineFlxPoint(marker, function(point) return {
{
flixel.FlxG.state.remove(db, true);
submit(new StagePosition(point.x, point.y, {
@@ -1050,13 +1061,16 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
};
};
}
public function defineLightSource(submit:(FlxLightSource)->Void):Void {
public function defineLightSource(camera:flixel.FlxCamera, submit:(FlxLightSource)->Void):Void {
{
final points = new kiss.List([]);
final points = new kiss.List([]); final db = new DebugLayer();
{
db.cameras = new kiss.List([camera]);
flixel.FlxG.state.add(db);
{
function getNextPoint() return {
defineFlxPoint(function(point) return {
final marker = db.drawCircle(0, 0, 4, flixel.util.FlxColor.YELLOW, 2);
defineFlxPoint(marker, function(point) return {
{
points.push(point);
getNextPoint();
@@ -1064,7 +1078,7 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
});
};
getNextPoint();
sh.registerItem("{enter} submit light source", {
sh.registerItem("{space} submit light source", {
var s55___FlxDirector = false;
{
function(cc) return {
@@ -1079,6 +1093,7 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
if (Prelude.truthy(points)) {
submit(new FlxLightSource(points, flixel.util.FlxColor.TRANSPARENT));
} else null;
flixel.FlxG.state.remove(db, true);
cc();
} else null;
};
@@ -1398,6 +1413,23 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
inputIcon?.scale.set(currentScale, currentScale);
};
};
if (Prelude.truthy(marker)) {
if (Prelude.truthy(flixel.FlxG.keys.justPressed.ENTER)) {
__submit();
} else null;
if (Prelude.truthy(flixel.FlxG.keys.pressed.LEFT)) {
marker.x = Prelude.subtract(marker.x, Prelude.multiply(flixel.FlxG.elapsed, 200));
} else null;
if (Prelude.truthy(flixel.FlxG.keys.pressed.RIGHT)) {
marker.x = Prelude.add(marker.x, Prelude.multiply(flixel.FlxG.elapsed, 200));
} else null;
if (Prelude.truthy(flixel.FlxG.keys.pressed.UP)) {
marker.y = Prelude.subtract(marker.y, Prelude.multiply(flixel.FlxG.elapsed, 200));
} else null;
if (Prelude.truthy(flixel.FlxG.keys.pressed.DOWN)) {
marker.y = Prelude.add(marker.y, Prelude.multiply(flixel.FlxG.elapsed, 200));
} else null;
} else null;
if (Prelude.truthy(movie.skipTarget)) {
barProgress = Prelude.add(barProgress, Prelude.subtract(movie.lastInstructionPointer, lastIp));
lastIp = movie.lastInstructionPointer;
@@ -1814,7 +1846,7 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
{
final s89___FlxDirector = !Prelude.truthy(Prelude.areEqual(0, song.length));
{
if (Prelude.truthy(s89___FlxDirector)) s89___FlxDirector else throw kiss.Prelude.runtimeInsertAssertionMessage((Prelude.add("song from ", Std.string(path), " has 0 length! avoid mp3s for this reason") : String), "/Users/nat/repos/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss:878:9: Assertion failed: \nFrom:[(assert (not (= 0 song.length)) (the String (+ \"song from \" (Std.string path) \" has 0 length! avoid mp3s for this reason\")))]", 4);
if (Prelude.truthy(s89___FlxDirector)) s89___FlxDirector else throw kiss.Prelude.runtimeInsertAssertionMessage((Prelude.add("song from ", Std.string(path), " has 0 length! avoid mp3s for this reason") : String), "/Users/nat/repos/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss:906:9: Assertion failed: \nFrom:[(assert (not (= 0 song.length)) (the String (+ \"song from \" (Std.string path) \" has 0 length! avoid mp3s for this reason\")))]", 4);
};
};
song.persist = true;
@@ -2155,7 +2187,7 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSo
{
final s105___FlxDirector = Prelude.areEqual(s103___FlxDirector, s104___FlxDirector);
{
if (Prelude.truthy(s105___FlxDirector)) s105___FlxDirector else throw kiss.Prelude.runtimeInsertAssertionMessage(Prelude.add("expected ", s103___FlxDirector, " but it was ", s104___FlxDirector), "/Users/nat/repos/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss:1027:13: Assertion failed: \nFrom:[(assert (= s103___FlxDirector s104___FlxDirector) (+ \"expected \" s103___FlxDirector \" but it was \" s104___FlxDirector))]", 4);
if (Prelude.truthy(s105___FlxDirector)) s105___FlxDirector else throw kiss.Prelude.runtimeInsertAssertionMessage(Prelude.add("expected ", s103___FlxDirector, " but it was ", s104___FlxDirector), "/Users/nat/repos/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss:1055:13: Assertion failed: \nFrom:[(assert (= s103___FlxDirector s104___FlxDirector) (+ \"expected \" s103___FlxDirector \" but it was \" s104___FlxDirector))]", 4);
};
};
};

View File

@@ -422,11 +422,23 @@
->s {(sh.start)(submit s)}
(object wrapPrompt true))))
(method :Void defineFlxPoint [:FlxPoint->Void submit]
(prop &mut :FlxSprite marker null)
(prop &mut :Void->Void __submit null)
(method :Void defineFlxPoint [:FlxSprite marker :FlxPoint->Void submit]
(unless mm
(set mm (new FlxMouseEventManager)))
(set this.marker marker)
(localVar screen (new FlxSprite))
(localFunction _submit []
(set this.marker null)
(mm.remove screen)
(FlxG.state.remove screen true)
(doFor camera FlxG.cameras.list (set camera.zoom 1))
(submit (new FlxPoint marker.x marker.y)))
(set __submit _submit)
(FlxG.state.add mm)
(let [screen (new FlxSprite)]
(let [speed 200]
(screen.makeGraphic FlxG.width FlxG.height (FlxColor.fromRGBFloat 0 1 0 0.2))
(set screen.cameras [flxMovie.uiCamera])
@@ -436,11 +448,9 @@
(set flxMovie.spriteChangeDebugCamera.zoom 1)
(mm.add screen
->screen {
(mm.remove screen)
(FlxG.state.remove screen true)
(let [pos (FlxG.mouse.getScreenPosition FlxG.camera)]
(doFor camera FlxG.cameras.list (set camera.zoom 1))
(submit pos))
(set marker.x pos.x)
(set marker.y pos.y))
})
(FlxG.state.add screen)
})))
@@ -448,20 +458,24 @@
(method :Void defineStagePosition [:FlxCamera camera :StagePosition->Void submit &opt :StagePosition oldPos]
(let [db (new DebugLayer)]
(set db.cameras [camera])
(when oldPos
(db.drawCircle oldPos.x oldPos.y 4 FlxColor.YELLOW 2))
(unless oldPos (set oldPos (new StagePosition 0 0 0)))
(localVar marker (db.drawCircle oldPos.x oldPos.y 4 FlxColor.YELLOW 2))
(FlxG.state.add db)
(defineFlxPoint
(defineFlxPoint marker
->point
{(FlxG.state.remove db true)
(submit (new StagePosition point.x point.y (or oldPos?.z 5.0)))})))
(method :Void defineLightSource [:FlxLightSource->Void submit]
(let [points []]
(method :Void defineLightSource [:FlxCamera camera :FlxLightSource->Void submit]
(let [points []
db (new DebugLayer)]
(set db.cameras [camera])
(FlxG.state.add db)
(withFunctions
[
(getNextPoint []
(defineFlxPoint
(localVar marker (db.drawCircle 0 0 4 FlxColor.YELLOW 2))
(defineFlxPoint marker
->point
{
(points.push point)
@@ -470,12 +484,14 @@
]
(getNextPoint)
(sh.registerItem
"{enter} submit light source"
"{space} submit light source"
(onceLambda [cc]
(doFor camera FlxG.cameras.list (set camera.zoom 1))
(when points
// TODO allow color choice
(submit (new FlxLightSource points FlxColor.TRANSPARENT)))
(FlxG.state.remove db true)
(cc)) true))))
(method :Void showLighting [:SceneTime sceneTime :Array<FlxLightSource> lightSources :FlxCamera camera]
@@ -654,6 +670,18 @@
(let [currentScale (+ 1.0 (* inputIconFluctuation (Math.sin (* inputIconFluctuationSpeed inputIconElapsed))))]
(inputIcon?.scale.set currentScale currentScale))
(when marker
(when FlxG.keys.justPressed.ENTER
(__submit))
(when FlxG.keys.pressed.LEFT
(-= marker.x $>d (* FlxG.elapsed 200)))
(when FlxG.keys.pressed.RIGHT
(+= marker.x $d))
(when FlxG.keys.pressed.UP
(-= marker.y $d))
(when FlxG.keys.pressed.DOWN
(+= marker.y $d)))
(when movie.skipTarget
(+= barProgress (- movie.lastInstructionPointer lastIp))
(set lastIp movie.lastInstructionPointer)