Clean up UI, work on tutorial
This commit is contained in:
1 parent
cfbd29d5b1
commit
619de45221
79 files changed
+5122
-316
No files matched your search
@@ -19,9 +19,14 @@ bool DialogueOverlay::init(Renderer& renderer, const std::string& zipFile) {
|
||||
zipFilename = zipFile;
|
||||
|
||||
textboxTexture = renderer.textureManager.LoadFromPng("resources/dialogue/textbox_bg.png", zipFile);
|
||||
choiceMainTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_main.png", zipFile);
|
||||
textboxChoiceTexture = renderer.textureManager.LoadFromPng("resources/dialogue/DialogChoice001.png", zipFile);
|
||||
/*choiceMainTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_main.png", zipFile);
|
||||
choiceOptionalTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_optional.png", zipFile);
|
||||
choiceSelectedTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_selected.png", zipFile);
|
||||
*/
|
||||
choiceMainTexture = renderer.textureManager.LoadFromPng("resources/dialogue/ChoiceNormal001.png", zipFile);
|
||||
choiceOptionalTexture = renderer.textureManager.LoadFromPng("resources/dialogue/ChoiceNormal001.png", zipFile);
|
||||
choiceSelectedTexture = renderer.textureManager.LoadFromPng("resources/dialogue/ChoiceSelected001.png", zipFile);
|
||||
|
||||
nameRenderer = std::make_unique<TextRenderer>();
|
||||
bodyRenderer = std::make_unique<TextRenderer>();
|
||||
@@ -57,6 +62,7 @@ void DialogueOverlay::draw(Renderer& renderer, const PresentationModel& model) {
|
||||
|
||||
UiRect portraitRect{ 24.0f + 90, 24.0f + 16, 176.0f, 176.0f };
|
||||
UiRect textboxRect{ 30.f, -48.f, 1222.f, 340.0f };
|
||||
UiRect textboxChoiceRect{ 30.f, -48.f, 1200.f, 619.5f };
|
||||
|
||||
lastDialogueAdvanceRect = { portraitRect.x, portraitRect.y, textboxRect.x + textboxRect.w - portraitRect.x, textboxRect.h };
|
||||
|
||||
@@ -69,6 +75,11 @@ void DialogueOverlay::draw(Renderer& renderer, const PresentationModel& model) {
|
||||
textboxQuad.rebuild(textboxRect);
|
||||
}
|
||||
|
||||
if (!textboxChoiceQuad.initialized || textboxChoiceQuad.rect.w != textboxChoiceRect.w || textboxChoiceQuad.rect.h != textboxChoiceRect.h ||
|
||||
textboxChoiceQuad.rect.x != textboxChoiceRect.x || textboxChoiceQuad.rect.y != textboxChoiceRect.y) {
|
||||
textboxChoiceQuad.rebuild(textboxChoiceRect);
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
renderer.shaderManager.PushShader(defaultShaderName);
|
||||
renderer.RenderUniform1i(textureUniformName, 0);
|
||||
@@ -77,45 +88,77 @@ void DialogueOverlay::draw(Renderer& renderer, const PresentationModel& model) {
|
||||
renderer.LoadIdentity();
|
||||
renderer.RenderUniform1f("uAlpha", 1.0f);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, textboxTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(textboxQuad.mesh);
|
||||
if (model.mode == PresentationMode::Choice)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, textboxTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(textboxChoiceQuad.mesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, textboxTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(textboxQuad.mesh);
|
||||
}
|
||||
|
||||
{
|
||||
renderer.PushMatrix();
|
||||
|
||||
if (model.mode == PresentationMode::Choice)
|
||||
{
|
||||
renderer.TranslateMatrix(Vector3f{ 0, 230, 0 });
|
||||
}
|
||||
|
||||
auto portrait = loadTextureCached(model.portraitPath);
|
||||
if (portrait) {
|
||||
glBindTexture(GL_TEXTURE_2D, portrait->getTexID());
|
||||
renderer.DrawVertexRenderStruct(portraitQuad.mesh);
|
||||
}
|
||||
renderer.PopMatrix();
|
||||
}
|
||||
|
||||
renderer.PopMatrix();
|
||||
renderer.PopProjectionMatrix();
|
||||
renderer.shaderManager.PopShader();
|
||||
|
||||
const float nameX = 312;
|
||||
|
||||
const float nameX = 312+8;
|
||||
const float nameY = 232 - 38.0f;
|
||||
const float bodyX = 312;
|
||||
const float bodyX = 312+8;
|
||||
const float bodyY = 232 - 78.0f;
|
||||
|
||||
lastChoiceRects.clear();
|
||||
|
||||
if (!model.speaker.empty()) {
|
||||
nameRenderer->drawText(model.speaker, nameX, nameY, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f });
|
||||
|
||||
if (model.mode == PresentationMode::Choice)
|
||||
{
|
||||
nameRenderer->drawText(model.speaker, nameX+x, nameY+230, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
nameRenderer->drawText(model.speaker, nameX+x, nameY, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f });
|
||||
}
|
||||
}
|
||||
|
||||
const float bodyMaxWidthPx = W - nameX - 48.f - ZL::x - 60.f;
|
||||
const float bodyMaxWidthPx = W - nameX - 48.f - 60.f;
|
||||
const std::string wrappedBody = wrapTextToWidth(model.visibleText, *bodyRenderer, bodyMaxWidthPx, 1.0f);
|
||||
bodyRenderer->drawText(wrappedBody, bodyX, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f });
|
||||
|
||||
lastChoiceRects.clear();
|
||||
|
||||
if (model.mode == PresentationMode::Choice) {
|
||||
const float choiceStartY = textboxRect.y + 56.0f;
|
||||
const float choiceHeight = 30.0f;
|
||||
const float choiceSpacing = 8.0f;
|
||||
const float choiceWidth = textboxRect.w - 48.0f;
|
||||
const float choiceStartY = 270.f-35;
|
||||
const float choiceHeight = 121.f*0.9;
|
||||
const float choiceSpacing = -30.f;
|
||||
const float choiceWidth = 913.f * 0.9;
|
||||
|
||||
//UiRect textboxRect{ 30.f, -48.f, 1222.f, 340.0f };
|
||||
|
||||
|
||||
if (choiceQuads.size() < model.choices.size()) {
|
||||
choiceQuads.resize(model.choices.size());
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
renderer.shaderManager.PushShader(defaultShaderName);
|
||||
renderer.RenderUniform1i(textureUniformName, 0);
|
||||
renderer.PushProjectionMatrix(0.0f, W, 0.0f, Environment::projectionHeight, -10.0f, 10.0f);
|
||||
@@ -124,7 +167,7 @@ void DialogueOverlay::draw(Renderer& renderer, const PresentationModel& model) {
|
||||
|
||||
for (size_t i = 0; i < model.choices.size(); ++i) {
|
||||
const float cy = choiceStartY + (choiceHeight + choiceSpacing) * static_cast<float>(model.choices.size() - 1 - i);
|
||||
UiRect rect{ textboxRect.x + 20.0f, cy, choiceWidth, choiceHeight };
|
||||
UiRect rect{ 300.f, cy, choiceWidth, choiceHeight };
|
||||
lastChoiceRects.push_back(rect);
|
||||
choiceQuads[i].rebuild(rect);
|
||||
|
||||
@@ -149,7 +192,7 @@ void DialogueOverlay::draw(Renderer& renderer, const PresentationModel& model) {
|
||||
|
||||
const std::string wrappedChoice = wrapTextToWidth(model.choices[i].text, *choiceRenderer, rect.w - 28.0f, 1.0f);
|
||||
choiceRenderer->drawText(
|
||||
wrappedChoice, rect.x + 14.0f, rect.y + 9.0f, 1.0f, false,
|
||||
wrappedChoice, rect.x + 32.0f, rect.y + 50.f, 1.5f, false,
|
||||
isHighlighted ? std::array<float, 4>{1.0f, 1.0f, 1.0f, 1.0f} : color
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ private:
|
||||
std::string zipFilename;
|
||||
|
||||
std::shared_ptr<Texture> textboxTexture;
|
||||
std::shared_ptr<Texture> textboxChoiceTexture;
|
||||
|
||||
std::shared_ptr<Texture> choiceMainTexture;
|
||||
std::shared_ptr<Texture> choiceOptionalTexture;
|
||||
std::shared_ptr<Texture> choiceSelectedTexture;
|
||||
@@ -42,6 +44,7 @@ private:
|
||||
|
||||
UiQuad portraitQuad;
|
||||
UiQuad textboxQuad;
|
||||
UiQuad textboxChoiceQuad;
|
||||
mutable std::vector<UiQuad> choiceQuads;
|
||||
|
||||
std::shared_ptr<Texture> loadTextureCached(const std::string& path);
|
||||
|
||||
Reference in new issue
Block a user