Friz64 / ecsvulk

"hobby" engine
Do What The F*ck You Want To Public License
2 stars 0 forks source link

make config gen macro #2

Closed Friz64 closed 5 years ago

Friz64 commented 6 years ago

i am repeating myself frequently in config.rs, in theory everything could be replaced with a single macro

maybe it'll look something like this:

gen_config! {
    ConfigControls {
        ConfigControlsMovement {
            forwards Input
            backwards Input
            left Input
            right Input
            speed_up Input
            speed_down Input
        },
        ConfigControlsSensitivity {
            mouse_speed f32
            movement_speed f32
        }
    }
}
Friz64 commented 6 years ago

I've been working on this and unfortunately i dont think its gonna be completely possible due to different behaviours based on different types and rust being a statically typed languange, i got the option part automated tho, so thats a plus. I'm gonna clean the code up, test everything, commit and carry on with other stuff.

Friz64 commented 6 years ago

closing with https://github.com/Friz64/ecsvulk/commit/3c501fb61ea174db791197b4875a77de7d37906a

i am quite satisfied with the end result, it's definitely a lot cleaner than the old version, although not perfect

Friz64 commented 5 years ago

I'm not really satisfied with the hack after all, there must be a better way to do this

impl UpdateConfigHack for bool {
    fn update_key(&mut self, _: Option<VirtualKeyCode>, _: ElementState) {}
    fn update_mouse(&mut self, _: MouseButton, _: ElementState) {}
    fn update_scroll(&mut self, _: f32) {}
    fn update_status(&mut self) {}
}
Friz64 commented 5 years ago

it now became another macro

ignore!(f32, i32, String, bool);