From 19be2ac58b09c5240a32e6a4f41cd9f6cda03d07 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 12 Feb 2021 00:14:38 -0500 Subject: Added message bullets --- res/scripts/default.lua | 2 +- res/scripts/script0001.lua | 6 +++--- res/scripts/test_trigger.lua | 2 +- src/message_system.cpp | 11 +++++++++-- src/message_system.h | 1 + src/renderer.cpp | 33 ++++++++++++++++++++++----------- 6 files changed, 37 insertions(+), 18 deletions(-) diff --git a/res/scripts/default.lua b/res/scripts/default.lua index 936a543..b8f7768 100644 --- a/res/scripts/default.lua +++ b/res/scripts/default.lua @@ -1,5 +1,5 @@ function default() StartCutscene() - DisplayMessage("No problem here.", "", SpeakerType.NONE) + DisplayMessage("* No problem here.", "", SpeakerType.NONE) HideCutsceneBars() end diff --git a/res/scripts/script0001.lua b/res/scripts/script0001.lua index 0be8382..bf6a0c2 100644 --- a/res/scripts/script0001.lua +++ b/res/scripts/script0001.lua @@ -4,7 +4,7 @@ function script0001() local barkingNoise = LoopSound("barking_at_hallucination.wav") SetAnimation("flint", "talk") - DisplayMessage("Lucas. It's me, Flint. Your father.\n\fI found Claus. He's here. After three years I've finally found your brother.\n\fAre you ready to see him again?", "Flint", SpeakerType.MAN) + DisplayMessage("* Lucas. It's me, Flint. Your father.\n\f* I found Claus. He's here. After three years I've finally found your brother.\n\fAre you ready to see him again?", "Flint", SpeakerType.MAN) ShowChoice("Yes", "No") WaitForEndOfMessage() @@ -13,9 +13,9 @@ function script0001() PlaySound("boney_growl.wav") if GetChoiceSelection() == 0 then - DisplayMessage("I can hear the tremor in your voice, Lucas.\n\fLies are little games a mouth plays while the person attached withers away slowly.\n\fClaus is coming, whether you like it or not.\nWill you be able to look him in the eye?", "Flint", SpeakerType.MAN) + DisplayMessage("* I can hear the tremor in your voice, Lucas.\n\fLies are little games a mouth plays while the person attached withers away slowly.\n\fClaus is coming, whether you like it or not.\nWill you be able to look him in the eye?", "Flint", SpeakerType.MAN) else - DisplayMessage("Look at me when I'm talking to you, Lucas.\n\fWhen Claus gets home, we won't need you anymore.\nYou're nothing compared to him.", "Flint", SpeakerType.MAN) + DisplayMessage("* Look at me when I'm talking to you, Lucas.\n\f* When Claus gets home, we won't need you anymore.\nYou're nothing compared to him.", "Flint", SpeakerType.MAN) end WaitForEndOfMessage() diff --git a/res/scripts/test_trigger.lua b/res/scripts/test_trigger.lua index 58325e5..4d9d06c 100644 --- a/res/scripts/test_trigger.lua +++ b/res/scripts/test_trigger.lua @@ -1,7 +1,7 @@ function test_trigger() StartCutscene() PlaySound("boney_growl.wav") - DisplayMessage("Hi! Welcome to the funky zone.", "", SpeakerType.NONE) + DisplayMessage("* Hi! Welcome to the funky zone.", "", SpeakerType.NONE) WaitForEndOfMessage() HideCutsceneBars() end diff --git a/src/message_system.cpp b/src/message_system.cpp index a969427..98b5f83 100644 --- a/src/message_system.cpp +++ b/src/message_system.cpp @@ -124,6 +124,12 @@ void MessageSystem::displayMessage(std::string_view msg, std::string speakerName } } + bool bulleted = false; + if (text.substr(0, 2) == "* ") { + text.erase(0, 2); + bulleted = true; + } + auto words = splitStr>(text, " "); std::string curLine; @@ -145,9 +151,10 @@ void MessageSystem::displayMessage(std::string_view msg, std::string speakerName } if (nextWidth > MESSAGE_TEXT_WIDTH) { - lines_.push_back({.text = curLine}); + lines_.push_back({.text = curLine, .bulleted = bulleted}); curLine = word; curWidth = wordWidth + game_.getFont().getCharacterWidth(' '); + bulleted = false; if (shouldAddBlank) { shouldAddBlank = false; @@ -166,7 +173,7 @@ void MessageSystem::displayMessage(std::string_view msg, std::string speakerName firstWord = false; } - lines_.push_back({.text = curLine}); + lines_.push_back({.text = curLine, .bulleted = bulleted}); if (shouldAddBlank) { shouldAddBlank = false; diff --git a/src/message_system.h b/src/message_system.h index ea27f14..7f9d287 100644 --- a/src/message_system.h +++ b/src/message_system.h @@ -24,6 +24,7 @@ struct MessageLine { bool pause = false; bool isChoice = false; int choicePos[2] = {-1, -1}; + bool bulleted = false; }; class MessageSystem : public System { diff --git a/src/renderer.cpp b/src/renderer.cpp index 0c70ef5..0e77bb9 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -201,17 +201,28 @@ void Renderer::render(Game& game) { // 18x, 127y1, 143y2 if (line.charsRevealed > 0) { - SDL_Rect srcRect { - 0, 0, messageLines_[lineIndex].charIndexToWidth[line.charsRevealed], - game.getFont().getCharacterHeight() - }; - SDL_Rect destRect { - 18, - 127 + 16 * lineIndex, - srcRect.w, - srcRect.h }; - - SDL_RenderCopy(ren_.get(), messageLines_[lineIndex].renderedTex.get(), &srcRect, &destRect); + { + SDL_Rect srcRect { + 0, 0, messageLines_[lineIndex].charIndexToWidth[line.charsRevealed], + game.getFont().getCharacterHeight() + }; + SDL_Rect destRect { + 18, + 127 + 16 * lineIndex, + srcRect.w, + srcRect.h }; + + SDL_RenderCopy(ren_.get(), messageLines_[lineIndex].renderedTex.get(), &srcRect, &destRect); + } + + if (line.bulleted) { + vec2i charLoc = game.getFont().getCharacterLocation('^'); + vec2i charSize = game.getFont().getCharacterSize('^'); + SDL_Rect srcRect { charLoc.x(), charLoc.y(), charSize.w(), charSize.h() }; + SDL_Rect destRect { 13, 127 + 16 * lineIndex, charSize.w(), charSize.h() }; + + SDL_RenderCopy(ren_.get(), textures_.at(game.getFont().getTextureId()).get(), &srcRect, &destRect); + } } lineIndex++; -- cgit 1.4.1