mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-14 11:45:01 +01:00
more
This commit is contained in:
parent
63866fe572
commit
e8e276eae2
1 changed files with 3 additions and 35 deletions
|
|
@ -43,25 +43,11 @@ pub fn derive_inspect(input: TokenStream) -> TokenStream {
|
||||||
if ui.add(::egui::Label::new(stringify!(#f)).sense(::egui::Sense::click())).clicked() {
|
if ui.add(::egui::Label::new(stringify!(#f)).sense(::egui::Sense::click())).clicked() {
|
||||||
ui.output_mut(|o| o.copied_text = format!("{:?}", self.#memb));
|
ui.output_mut(|o| o.copied_text = format!("{:?}", self.#memb));
|
||||||
}
|
}
|
||||||
::egui_inspect::Inspect::inspect_mut(&mut self.#memb, ui, #i as u64)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
FieldInspectKind::Opaque => {
|
|
||||||
exprs.push(quote! {
|
|
||||||
ui.horizontal(|ui| {
|
|
||||||
ui.label(concat!(stringify!(#memb), " <opaque>"));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
FieldInspectKind::WithFn(fun) => {
|
|
||||||
exprs.push(quote! {
|
|
||||||
ui.horizontal(|ui| {
|
|
||||||
ui.label(stringify!(#memb));
|
|
||||||
#fun(&mut self.#memb, ui, #i as u64)
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
FieldInspectKind::Opaque => {}
|
||||||
|
FieldInspectKind::WithFn(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
quote! {
|
quote! {
|
||||||
|
|
@ -70,25 +56,7 @@ pub fn derive_inspect(input: TokenStream) -> TokenStream {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Data::Enum(e) => {
|
_ => panic!(),
|
||||||
let mut sel_name_match_exprs = Vec::new();
|
|
||||||
let mut selectable_value_exprs = Vec::new();
|
|
||||||
for var in &e.variants {
|
|
||||||
let name = &var.ident;
|
|
||||||
sel_name_match_exprs.push(quote! {Self::#name => stringify!(#name)});
|
|
||||||
selectable_value_exprs
|
|
||||||
.push(quote! {ui.selectable_value(self, Self::#name, stringify!(#name))});
|
|
||||||
}
|
|
||||||
quote! {
|
|
||||||
let sel_text = match self {
|
|
||||||
#(#sel_name_match_exprs,)*
|
|
||||||
};
|
|
||||||
::egui::ComboBox::new(id_source, stringify!(#ty_ident)).selected_text(sel_text).show_ui(ui, |ui| {
|
|
||||||
#(#selectable_value_exprs;)*
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Data::Union(_) => panic!("Unions are not supported"),
|
|
||||||
};
|
};
|
||||||
let (intro_generics, forward_generics, where_clauses) = input.generics.split_for_impl();
|
let (intro_generics, forward_generics, where_clauses) = input.generics.split_for_impl();
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue