This is a little thing I put together for creating simple UI screens using the BevyEngine. The idea is to define the screens in a sort of poor-man's markup and this crate will then provide some functions to create the UI 'objects'.
For example, the following in a file will create a screen looking like:
with the code:
```sh
// startsystem
fn setup(
mut commands: Commands,
assetserver: Res
let controls = gerg_ui::instantiate_controls_from_file("screen1.ui");
let _entities = gerg_ui::spawn_controls(&mut commands, asset_server, materials, controls, Vec2::new(1920.0, 1080.0), String::from("screen1.ui"));
}
// buttonclicksystem
fn closebuttonclicksystem(
mut commands: Commands,
buttonclickedquery: Query<(Entity, &GergButton, &GergControl), With
commands.entity(entity).remove::<ButtonClicked>();
if button.name == "close_button" {
for (entity, control) in all_controls_query.iter() {
if control.group_name == "screen1.ui" {
commands.entity(entity).insert(DestroyControl);
}
}
}
}
} ```
```sh --globalsettings-- fontname: CrimsonText-Regular.ttf font_size: 30 color: 255;255;255 // WHITE --end--
--picturebox-- name: frame1 texturename: bigframe.png // mandatory size: 1200;782 // mandatory //centerposition: 0;0 // middle of screen is 0;0, defaults to 0;0 if missing, but dockwith (and offset) will override draworder: 0 // defaults to 0 if missing dockwith: screen.topleft<->this.top_left offset: 10;-80 --end--
--picturebox-- name: heading texturename: bigheading.png size: 1200;76 draworder: 0.1 dockwith: frame1.topmiddle<->this.bottom_middle offset: 0;-1 --end--
--button-- name: closebutton texturenamenormal: closebuttonn.png texturenamehover: closebuttonh.png texturenameactive: closebuttona.png texturenamedisabled: closebuttonn.png onclicksound: audio/mouseclick1.mp3 size: 43;44 //boundingbox: 0;0;43;44 boundingcircle: 0;0;20 draworder: 0.2 dockwith: heading.topright<->this.top_right offset: -7;-7 --end--
--picturebox-- name: panelinner texturename: innerframe.png size: 556;740 draworder: 0.3 dockwith: frame1.centerleft<->this.centerleft offset: 20;0 color: BLUE --end--
--label-- name: label3 size: 200;50 textstring: Test1 fontsize: 50 color: CYAN dockwith: panelinner.topleft<->this.topleft offset: 15;-15 --end-- ```