Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpers for overlay editing #6

Open
idanarye opened this issue Jun 1, 2022 · 2 comments
Open

Helpers for overlay editing #6

idanarye opened this issue Jun 1, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@idanarye
Copy link
Owner

idanarye commented Jun 1, 2022

e.g. - handles the editor can interact with

@idanarye idanarye added the enhancement New feature or request label Jun 1, 2022
@idanarye
Copy link
Owner Author

idanarye commented Jun 6, 2022

Here is an idea - when selecting an entity, spawn "virtual entities" - lets call them knobs - based on its type and data. These entities could be clicked on and dragged, and that information can be passed back to the edit system.

I say they are "virtual entities" because they will not be created when playing the level. They should not be child entities, because they should not be deleted on despawn_descendants - Yoleck should be the one responsible for despawning them.

Code-wise, I think it should look something like this (this example if for a resize knob):

fn edit_system(edit: YoleckEdit<Example>) {
    edit.edit(|ctx, data, ui| {
        ctx.knob("width", |ctx, cmd| {
            if let Some(pos) ctx.get_passed_data::<Vec2>() {
                data.size.x = pos.x - data.position.x;
            }
            cmd.insert_bundle(SpriteBundle {
                // The X knob of a resize gizmo. Maybe it'll be a 2D mesh, or something compound...
            });
        });
    });
}

The first parameter passed to ctx.knob is an identifier (could be of any type that implements PartialEq). If the identifier already exists the existing entitiy will be modified. If the identifier of a knob was not updated during a frame, Yoleck will despawn it. The entity and system that created the knob will also be part of the identifier (you can't just pass them around)

vpeol_2d and vpeol_3d will contain helpers for creating knobs.

Alternative syntax:

fn edit_system(edit: YoleckEdit<Example>) {
    edit.edit(|ctx, data, ui| {
        {
            let (ctx, cmd) = ctx.knob("width");
            // do knob stuff
        }
    });
}

This syntax is uglier but more powerful. I don't think the first syntax is necessary though - knobs will mostly be created via helpers, which will benefit from the second syntax's power and will be able to hide its ugliness.

@idanarye
Copy link
Owner Author

idanarye commented Jun 7, 2022

I also think knobs need to have a "selected" status. Less important for gizmos, but this supports e.g. editing an enemy's patrol, so we want to allow selecting a path node so one could configure it in the egui frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant