55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "dialogue/DialogueRuntime.h"
|
|
#include "render/Renderer.h"
|
|
#include "render/TextRenderer.h"
|
|
#include "render/TextureManager.h"
|
|
#include "render/UiQuad.h"
|
|
#include "UiManager.h"
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace ZL::Dialogue {
|
|
|
|
class DialogueOverlay {
|
|
public:
|
|
bool init(Renderer& renderer, const std::string& zipFile = "");
|
|
void update(const PresentationModel& model, int deltaMs);
|
|
void draw(Renderer& renderer, const PresentationModel& model);
|
|
|
|
void handlePointerDown(float x, float y, const PresentationModel& model);
|
|
void handlePointerMoved(float x, float y, const PresentationModel& model);
|
|
bool handlePointerReleased(float x, float y, const PresentationModel& model, int& outChoiceIndex, bool& outAdvanceDialogue);
|
|
|
|
private:
|
|
Renderer* rendererRef = nullptr;
|
|
std::string zipFilename;
|
|
|
|
std::shared_ptr<Texture> textboxTexture;
|
|
std::shared_ptr<Texture> choiceMainTexture;
|
|
std::shared_ptr<Texture> choiceOptionalTexture;
|
|
std::shared_ptr<Texture> choiceSelectedTexture;
|
|
|
|
mutable std::vector<UiRect> lastChoiceRects;
|
|
mutable UiRect lastDialogueAdvanceRect{};
|
|
|
|
int hoveredChoiceIndex = -1;
|
|
|
|
std::unique_ptr<TextRenderer> nameRenderer;
|
|
std::unique_ptr<TextRenderer> bodyRenderer;
|
|
std::unique_ptr<TextRenderer> choiceRenderer;
|
|
|
|
UiQuad portraitQuad;
|
|
UiQuad textboxQuad;
|
|
mutable std::vector<UiQuad> choiceQuads;
|
|
|
|
std::shared_ptr<Texture> loadTextureCached(const std::string& path);
|
|
|
|
static std::string wrapTextToWidth(const std::string& input, const TextRenderer& textRenderer,
|
|
float maxWidthPx, float scale);
|
|
static bool rectContains(const UiRect& rect, float x, float y);
|
|
};
|
|
|
|
} // namespace ZL::Dialogue
|