mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 20:35:02 +01:00
more
This commit is contained in:
parent
dc3348cbd2
commit
7b98a4c423
1 changed files with 4 additions and 22 deletions
|
|
@ -1,33 +1,15 @@
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::{parse_macro_input, Attribute, Data, DeriveInput, Member};
|
|
||||||
|
|
||||||
#[proc_macro_derive(Inspect)]
|
#[proc_macro_derive(Inspect)]
|
||||||
pub fn derive_inspect(input: TokenStream) -> TokenStream {
|
pub fn derive_inspect(input: TokenStream) -> TokenStream {
|
||||||
let input = parse_macro_input!(input as DeriveInput);
|
|
||||||
|
|
||||||
let ts = match input.data {
|
|
||||||
Data::Struct(s) => {
|
|
||||||
let mut exprs = Vec::new();
|
|
||||||
for (i, f) in s.fields.iter().enumerate() {
|
|
||||||
let ident = &f.ident;
|
|
||||||
exprs.push(quote! {
|
|
||||||
ui.output_mut(|o| o.copied_text = format!("{:?}", self.#ident));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
quote! {
|
|
||||||
::egui::CollapsingHeader::new("").id_source(0).show(ui, |ui| {
|
|
||||||
#(#exprs)*
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => panic!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
impl ::egui_inspect::Inspect for GameState {
|
impl ::egui_inspect::Inspect for GameState {
|
||||||
fn inspect_mut(&mut self, ui: &mut ::egui::Ui, id_source: u64) {
|
fn inspect_mut(&mut self, ui: &mut ::egui::Ui, id_source: u64) {
|
||||||
#ts
|
::egui::CollapsingHeader::new("").id_source(0).show(ui, |ui| {
|
||||||
|
ui.output_mut(|o| o.copied_text = format!("{:?}", self.camera_offset));
|
||||||
|
ui.output_mut(|o| o.copied_text = format!("{:?}", self.tile_db));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue