69 lines
2.2 KiB
C++
69 lines
2.2 KiB
C++
#ifndef HUD_CLASS
|
|
#define HUD_CLASS
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
#include "StatBar.h"
|
|
|
|
class Font;
|
|
class Character;
|
|
class Box;
|
|
class TextBox;
|
|
class Texture;
|
|
class Camera;
|
|
|
|
// The player's health in the top left corner, the moves it has along the bottom, and everyone else's health
|
|
// over their heads
|
|
class Hud {
|
|
public:
|
|
// Makes its GUI, and GUI draws in the order it was made, so make this before whatever should cover it.
|
|
// The health bars are drawn from healthFill and healthFrame, plain bars if they're nullptr.
|
|
Hud(Font* font, Texture* healthFill = nullptr, Texture* healthFrame = nullptr);
|
|
|
|
// Once a frame, dt in real time. nullptr hides it all.
|
|
// With everyone and the camera, the rest of them get bars over their heads.
|
|
// With the cursor, in window pixels, hovering over a move pops up what it does.
|
|
void Update(float dt, const Character* character,
|
|
const std::vector<Character*>* everyone = nullptr, Camera* camera = nullptr, const glm::vec2* cursor = nullptr);
|
|
|
|
private:
|
|
// One move in the list: the key it's on, its name, and its cooldown covering it from the top
|
|
struct MoveSlot {
|
|
Box* background = nullptr;
|
|
Box* cooldown = nullptr;
|
|
TextBox* key = nullptr;
|
|
TextBox* name = nullptr;
|
|
float flash = 0.0f; // 1 just as it comes off cooldown, fades to 0
|
|
bool wasReady = true;
|
|
};
|
|
|
|
// A bar over someone's head, kept on whoever it showed last so a new face doesn't show a loss
|
|
struct Overhead {
|
|
std::unique_ptr<StatBar> bar;
|
|
const Character* shown = nullptr;
|
|
float opacity = 0.0f;
|
|
};
|
|
|
|
void UpdateMoves(float dt, const Character* character, const glm::vec2* cursor);
|
|
void UpdateOverheads(float dt, const Character* player, const std::vector<Character*>* everyone, Camera* camera);
|
|
|
|
StatBar health;
|
|
std::vector<MoveSlot> moves;
|
|
std::vector<Overhead> overheads;
|
|
|
|
// What the move under the cursor does
|
|
Font* font = nullptr;
|
|
Box* tooltip = nullptr;
|
|
TextBox* tooltipTitle = nullptr;
|
|
TextBox* tooltipText = nullptr;
|
|
|
|
const Character* shown = nullptr;
|
|
float opacity = 0.0f;
|
|
};
|
|
|
|
#endif
|