Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- UI, ingame + menu #11

Closed
3 tasks done
Tracked by #10
odecay opened this issue Jun 26, 2022 · 16 comments · Fixed by #50
Closed
3 tasks done
Tracked by #10

- UI, ingame + menu #11

odecay opened this issue Jun 26, 2022 · 16 comments · Fixed by #50
Assignees
Labels
help wanted It would be great if somebody could help out with this one!
Milestone

Comments

@odecay
Copy link
Collaborator

odecay commented Jun 26, 2022

This issue consists of two parts.

Ingame HUD/UI consisting of:
Floating health bars + player/character portraits, likely made using bevy's native UI features.

Reference:
cc_ui

Menus Using bevy_egui
A Main Menu with which to start the game.
A pause menu with which to exit the game.
Eventually this could include submenus to set options, controller bindings.

Character and level select screens will likely be needed as well.

@odecay odecay mentioned this issue Jun 26, 2022
4 tasks
@erlend-sh erlend-sh added the help wanted It would be great if somebody could help out with this one! label Jun 27, 2022
@zicklag
Copy link
Member

zicklag commented Jun 27, 2022

Hey there! This is something I could work on. I've been doing some work with Bevy and Egui recently:

bevy retro egui

I've found egui really nice to use.

Floating health bars + player/character portraits, likely made using bevy's native UI features.

Is there a reason we wouldn't use Egui for those as well, so that we don't have to worry about understanding and using two different UI systems?

Also, what kind of skin are you thinking for the UI? Would we borrow from the FishFight UI theme?

@odecay
Copy link
Collaborator Author

odecay commented Jun 27, 2022

Is there a reason we wouldn't use Egui for those as well, so that we don't have to worry about understanding and using two different UI systems?

It seems to me that the HUD will require ninepatch + image backgrounds as well as absolute screen positioning. It seemed like it might be simpler to have the HUD in bevy native ui. HUD and menus dont have to interact at all so I was hoping it wouldnt be an issue.

I did however see someone patch egui to support ninepatch rendering the other day though so thats something to consider. https://discord.com/channels/691052431525675048/885021580353237032/989112997458874390
https://github.com/freiksenet/lands_of_mana/tree/main/src/gui/widgets relevant sections being window.rs and nine_patch.rs

Also, what kind of skin are you thinking for the UI? Would we borrow from the FishFight UI theme?

I think that is the idea for the egui side but afaik the theming has not actually been done in FishFight yet.

The menu in above looks really good btw! How did you go about theming it?

@zicklag
Copy link
Member

zicklag commented Jun 27, 2022

I've got 9-patch versions of Egui frames and buttons working as shown in the screenshot above, so that shouldn't be an issue. And absolute positioning is simple, too.

The ninepatch frame of mine cost about 300 lines of code ( see here ), it's just a simple modification of the built-in egui frame code. Buttons are a similar story.

And using it super simple:

BorderedFrame::new(&ui_theme.panel_bg)
.margin(outer_margin)
.padding(Rect::all(8.0))
.show(ui, |ui| {
    // Make sure the frame ocupies the entire rect that we allocated for it.
    //
    // Without this it would only take up enough size to fit it's content.
    ui.set_min_size(ui.available_size());


    // Create a vertical list of items, centered horizontally
    ui.vertical_centered(|ui| {
        ui.retro_label("Bevy Retro + Egui = ♥", &ui_theme.font);


        ui.add_space(10.0);
        RetroLabel::new("Click a button to scale the background", &ui_theme.font)
            .color(egui::Color32::GREEN)
            .show(ui);


        // Now switch the layout to bottom_up so that we can start adding widgets
        // from the bottom of the frame.
        ui.with_layout(egui::Layout::bottom_up(egui::Align::Center), |ui| {
            ui.add_space(4.0);


            if RetroButton::new("Scale Down", &ui_theme.font)
                .padding(Rect::all(7.0))
                .border(&ui_theme.button_up_bg)
                .on_click_border(&ui_theme.button_down_bg)
                .show(ui)
                .clicked()
            {
                map_transform.scale -= Vec3::splat(0.2);
            }


            if RetroButton::new("Scale Up", &ui_theme.font)
                .padding(Rect::all(7.0))
                .border(&ui_theme.button_up_bg)
                .on_click_border(&ui_theme.button_down_bg)
                .show(ui)
                .clicked()
            {
                map_transform.scale += Vec3::splat(0.2);
            }
        });
    });
})

But I'm good using whatever you want to, just let me know. 👍

@odecay
Copy link
Collaborator Author

odecay commented Jun 27, 2022

Those were my only concerns about egui so if you already know how to do ninepatch with it id say go for it.

@erlend-sh erlend-sh added this to the v0.0.2 milestone Jun 28, 2022
@odecay
Copy link
Collaborator Author

odecay commented Jun 29, 2022

@zicklag do you want to be assigned this as well? I am interested in learning egui but im sure there will be plenty of opportunity and I personally would appreciate the benefit of your experience here.

@odecay odecay self-assigned this Jun 29, 2022
@zicklag
Copy link
Member

zicklag commented Jun 29, 2022

Yep, I can take it. I enjoy writing nice UIs. :)

I'll start working on that, I just want to get basic character hot-reloading working first so that I don't have to come back to it later. ( It should take less than an hour )

@zicklag
Copy link
Member

zicklag commented Jun 29, 2022

Oh, do we have any UI skin assets yet? Should I just copy them from FishFight?

@odecay
Copy link
Collaborator Author

odecay commented Jun 29, 2022

I'll start working on that, I just want to get basic character hot-reloading working first so that I don't have to come back to it later. ( It should take less than an hour )

no pressure on when to start just making sure my assumption on this were in line with yours so I can prioritize 👍

Oh, do we have any UI skin assets yet? Should I just copy them from FishFight?

We definitely don't have anything specific to punchy UI skin wise, last I heard they hadn't gotten to skinning egui yet in FishFight either but I could be wrong on that.

@erlend-sh
Copy link
Member

Yep, just copy from fishfight. If you have other requirements you can use any free thing in itch.io, as that’s all we’re using in fishfight for now anyway.

@zicklag
Copy link
Member

zicklag commented Jul 1, 2022

Still a little bit of work to do, but I've got a lot of the UI system fleshed out!
punchy-ui

It's totally themeable with YAML resources, including hot reload.

@zicklag
Copy link
Member

zicklag commented Jul 2, 2022

About the in-game UI, who gets a portrait and health bar at the top of the screen? Just the players, and not the enemies right?

Is there any sort of life display for enemies. Like a thin, floating life bar above their head or something like that?

@erlend-sh
Copy link
Member

Just players, yep. The Castle Crashers reference up top is very fitting.

Enemies don’t need any health bars. Maybe later we will occasionally show them when dealing critical dmg and that sort of thing.

@zicklag
Copy link
Member

zicklag commented Jul 3, 2022

I've got the start to in-game HUD. Just need to get life-bars implemented now:

image

@odecay
Copy link
Collaborator Author

odecay commented Jul 3, 2022

Looking good!

@zicklag
Copy link
Member

zicklag commented Jul 4, 2022

Lifebars are working! #50

image

Now we just need a way to hurt the player so we can see the lifebar move. :)

@zicklag zicklag mentioned this issue Jul 4, 2022
3 tasks
@odecay odecay closed this as completed in #50 Jul 5, 2022
@odecay
Copy link
Collaborator Author

odecay commented Jul 6, 2022

Now we just need a way to hurt the player so we can see the lifebar move. :)

basic enemy ai and attacks are in, healthbar works as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted It would be great if somebody could help out with this one!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants