diff --git a/src/ui.cpp b/src/ui.cpp index b5d607f..7f9d463 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -34,14 +34,9 @@ static Rectangle next_in_layout(VerticalLayout *layout, float width, float heigh return rect; } -static void ui_draw(World *world, Visuals *visuals, UI *ui) { - if (!ui->show_panel) { - ui->show_panel = GuiButton({ 20, 20, 30, 30 }, GuiIconText(ICON_PENCIL_BIG, "")); - return; - } - - float panel_height = 315; - ui->show_panel = !GuiWindowBox({ 20, 20, 660, panel_height }, "Control panel"); +static void ui_draw_control_panel(World *world, Visuals *visuals, UI *ui, Rectangle rect) { + float panel_height = rect.height; + ui->show_panel = !GuiWindowBox(rect, "Control panel"); float group_height = panel_height - 45; @@ -66,7 +61,6 @@ static void ui_draw(World *world, Visuals *visuals, UI *ui) { GuiColorPicker(bg_color_rect, NULL, &visuals->bg_color); GuiLabel(rect_with_offset({ 80, 10, 80, 16 }, bg_color_rect.x, bg_color_rect.y), "BG color"); - // TODO: Add show FPS // TODO: Add showing out of bounds boids } @@ -100,6 +94,25 @@ static void ui_draw(World *world, Visuals *visuals, UI *ui) { gui_valuebox_float(next_in_layout(&layout, 50, 15), "Separation strength", &world->separation_strength, 0, 100, &ui->separation_strength_edit); gui_valuebox_float(next_in_layout(&layout, 50, 15), "Collision avoidance strength", &world->collision_avoidance_strength, 0, 100, &ui->collision_avoidance_strength_edit); } +} + +static void ui_draw_controls_guide(Rectangle rect) { + GuiPanel(rect, "Controls"); + + VerticalLayout layout = { .x = rect.x + 10, .y = rect.y + 30, .gap = 6 }; + GuiLabel(next_in_layout(&layout, 250, 12), "R - reset camera view"); + GuiLabel(next_in_layout(&layout, 250, 12), "Scroll middle mouse - zoom camera"); + GuiLabel(next_in_layout(&layout, 250, 12), "Hold middle mouse & move - move camera"); +} + +static void ui_draw(World *world, Visuals *visuals, UI *ui) { + if (!ui->show_panel) { + ui->show_panel = GuiButton({ 20, 20, 30, 30 }, GuiIconText(ICON_PENCIL_BIG, "")); + return; + } + + ui_draw_control_panel(world, visuals, ui, { 20, 20, 660, 315 }); + ui_draw_controls_guide({ 20, 340, 275, 120 }); float window_width = GetScreenWidth(); float window_height = GetScreenHeight(); @@ -109,6 +122,6 @@ static void ui_draw(World *world, Visuals *visuals, UI *ui) { snprintf(boid_label, sizeof(boid_label), "%lu boids", world->boids.size()); DrawText(boid_label, window_width - 125, 35, 20, GREEN); - DrawText("W.I.P.", 20, window_height - 50, 20, RED); + DrawText("Beware!", 20, window_height - 50, 20, RED); DrawText("May crash sometimes", 20, window_height - 30, 20, RED); }