diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-05 13:32:04 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-05 13:32:04 -0500 |
| commit | f7875a6d2f129af47a203a5a31c2785b6e2fcf58 (patch) | |
| tree | 815d7fb1c28b5667dcd31d50aa65b18a802a89bc /src/renderer.cpp | |
| parent | 871943d6a90bdb92b3cc495d4d927199611f8c6b (diff) | |
| download | tanetane-f7875a6d2f129af47a203a5a31c2785b6e2fcf58.tar.gz tanetane-f7875a6d2f129af47a203a5a31c2785b6e2fcf58.tar.bz2 tanetane-f7875a6d2f129af47a203a5a31c2785b6e2fcf58.zip | |
Added speaker header
Diffstat (limited to 'src/renderer.cpp')
| -rw-r--r-- | src/renderer.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
| diff --git a/src/renderer.cpp b/src/renderer.cpp index b22c316..ae18851 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp | |||
| @@ -157,10 +157,35 @@ void Renderer::render(Game& game) { | |||
| 157 | 157 | ||
| 158 | if (game.getSystem<MessageSystem>().getCutsceneBarsProgress() == 1.0 && | 158 | if (game.getSystem<MessageSystem>().getCutsceneBarsProgress() == 1.0 && |
| 159 | !game.getSystem<MessageSystem>().getLines().empty()) { | 159 | !game.getSystem<MessageSystem>().getLines().empty()) { |
| 160 | if (!game.getSystem<MessageSystem>().getSpeaker().empty()) { | ||
| 161 | if (speakerHeaderTex_ == -1) { | ||
| 162 | speakerHeaderTex_ = loadImageFromFile("../res/speaker_header.png"); | ||
| 163 | } | ||
| 164 | |||
| 165 | { | ||
| 166 | SDL_Rect destRect { 0, 111, 57, 13 }; | ||
| 167 | SDL_RenderCopy(ren_.get(), textures_.at(speakerHeaderTex_).get(), nullptr, &destRect); | ||
| 168 | } | ||
| 169 | |||
| 170 | if (speakerHeaderLine_.line != game.getSystem<MessageSystem>().getSpeaker()) { | ||
| 171 | renderMessageLine(speakerHeaderLine_, game.getSystem<MessageSystem>().getSpeaker(), game); | ||
| 172 | } | ||
| 173 | |||
| 174 | { | ||
| 175 | SDL_Rect destRect { | ||
| 176 | 4, | ||
| 177 | 112, | ||
| 178 | MESSAGE_TEXT_WIDTH, | ||
| 179 | game.getFont().getCharacterHeight() }; | ||
| 180 | |||
| 181 | SDL_RenderCopy(ren_.get(), speakerHeaderLine_.renderedTex.get(), nullptr, &destRect); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 160 | int lineIndex = 0; | 185 | int lineIndex = 0; |
| 161 | for (const MessageSystem::MessageLine& line : game.getSystem<MessageSystem>().getLines()) { | 186 | for (const MessageSystem::MessageLine& line : game.getSystem<MessageSystem>().getLines()) { |
| 162 | if (messageLines_[lineIndex].line != line.text) { | 187 | if (messageLines_[lineIndex].line != line.text) { |
| 163 | renderMessageLine(lineIndex, line.text, game); | 188 | renderMessageLine(messageLines_[lineIndex], line.text, game); |
| 164 | } | 189 | } |
| 165 | 190 | ||
| 166 | // 18x, 127y1, 143y2 | 191 | // 18x, 127y1, 143y2 |
| @@ -204,8 +229,7 @@ int Renderer::loadImageFromFile(std::string_view filename) { | |||
| 204 | return texId; | 229 | return texId; |
| 205 | } | 230 | } |
| 206 | 231 | ||
| 207 | void Renderer::renderMessageLine(int lineIndex, const std::string& text, Game& game) { | 232 | void Renderer::renderMessageLine(MessageCache& line, const std::string& text, Game& game) { |
| 208 | MessageCache& line = messageLines_[lineIndex]; | ||
| 209 | line.line = text; | 233 | line.line = text; |
| 210 | 234 | ||
| 211 | line.renderedTex.reset( | 235 | line.renderedTex.reset( |
