-
Notifications
You must be signed in to change notification settings - Fork 11
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
Exclusive input mode for edit systems #22
Labels
enhancement
New feature or request
Comments
I imagine the syntax as something like this: fn edit_system_with_exclusive_mode(
mut ui: ResMut<YoleckUi>,
mut edit: YoleckEdit<&mut OtherEntityUuid>,
mut exclusive: YoleckExclusive, // this captures the system (like `YoleckMarking` does)
uuid_query: Query<&VpeolUuid>,
) {
let Ok(mut other_entity_uuid) = edit.get_single_mut() else { return };
if let Some(exclusive) = exclusive.exclusive() {
// Or maybe this should use passed-data?
if let Some(clicked_entity) = exclusive.get_clicked() {
if let Ok(uuid) = uuid_query.get(clicked_entity) {
other_entity_uuid.0 = uuid.0;
exclusive.finish();
}
}
} else {
if ui.button("Pick Other Entity").clicked() {
exclusive.start();
}
}
} |
This was referenced Apr 13, 2023
Alternatively, maybe this can be combined with #20's mechanism? fn edit_system_that_initiates_the_exclusive_mode(
mut ui: ResMut<YoleckUi>,
mut edit: YoleckEdit<With<&OtherEntityUuid>>,
mut exclusive: YoleckExclusive,
uuid_query: Query<&VpeolUuid>,
) {
let Ok(_) = edit.get_single_mut() else { return };
if ui.button("Pick Other Entity").clicked() {
exclusive.enqueue(edit_system_for_the_exclusive_mode);
}
}
fn edit_system_for_the_exclusive_mode(
mut exclusive_input: Res<YoleckExclusiveInput>,
mut edit: YoleckEdit<&mut OtherEntityUuid>,
) -> Option<YoleckExclusiveVeredict> {
let mut other_entity_uuid = edit.get_single_mut()?;
if let Some(clicked_entity) = exclusive_input.get_clicked() {
if let Ok(uuid) = uuid_query.get(clicked_entity) {
other_entity_uuid.0 = uuid.0;
return Some(YoleckExclusiveVeredict::Done);
}
}
None
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usecase - #21. When an entity refers to another entity, we want the first entity to click the second entity, we want to be able to do this by editing the target entity, doing something to indicate that we want to pick an entity to refer to, and then click on the other entity.
For this, we need to be able to send an edit system to an "exclusive input mode". In that mode:
The text was updated successfully, but these errors were encountered: