diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/message_system.cpp | 11 | ||||
| -rw-r--r-- | src/message_system.h | 1 | ||||
| -rw-r--r-- | src/renderer.cpp | 33 | 
3 files changed, 32 insertions, 13 deletions
| 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 | |||
| 124 | } | 124 | } | 
| 125 | } | 125 | } | 
| 126 | 126 | ||
| 127 | bool bulleted = false; | ||
| 128 | if (text.substr(0, 2) == "* ") { | ||
| 129 | text.erase(0, 2); | ||
| 130 | bulleted = true; | ||
| 131 | } | ||
| 132 | |||
| 127 | auto words = splitStr<std::list<std::string>>(text, " "); | 133 | auto words = splitStr<std::list<std::string>>(text, " "); | 
| 128 | 134 | ||
| 129 | std::string curLine; | 135 | std::string curLine; | 
| @@ -145,9 +151,10 @@ void MessageSystem::displayMessage(std::string_view msg, std::string speakerName | |||
| 145 | } | 151 | } | 
| 146 | 152 | ||
| 147 | if (nextWidth > MESSAGE_TEXT_WIDTH) { | 153 | if (nextWidth > MESSAGE_TEXT_WIDTH) { | 
| 148 | lines_.push_back({.text = curLine}); | 154 | lines_.push_back({.text = curLine, .bulleted = bulleted}); | 
| 149 | curLine = word; | 155 | curLine = word; | 
| 150 | curWidth = wordWidth + game_.getFont().getCharacterWidth(' '); | 156 | curWidth = wordWidth + game_.getFont().getCharacterWidth(' '); | 
| 157 | bulleted = false; | ||
| 151 | 158 | ||
| 152 | if (shouldAddBlank) { | 159 | if (shouldAddBlank) { | 
| 153 | shouldAddBlank = false; | 160 | shouldAddBlank = false; | 
| @@ -166,7 +173,7 @@ void MessageSystem::displayMessage(std::string_view msg, std::string speakerName | |||
| 166 | firstWord = false; | 173 | firstWord = false; | 
| 167 | } | 174 | } | 
| 168 | 175 | ||
| 169 | lines_.push_back({.text = curLine}); | 176 | lines_.push_back({.text = curLine, .bulleted = bulleted}); | 
| 170 | 177 | ||
| 171 | if (shouldAddBlank) { | 178 | if (shouldAddBlank) { | 
| 172 | shouldAddBlank = false; | 179 | 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 { | |||
| 24 | bool pause = false; | 24 | bool pause = false; | 
| 25 | bool isChoice = false; | 25 | bool isChoice = false; | 
| 26 | int choicePos[2] = {-1, -1}; | 26 | int choicePos[2] = {-1, -1}; | 
| 27 | bool bulleted = false; | ||
| 27 | }; | 28 | }; | 
| 28 | 29 | ||
| 29 | class MessageSystem : public System { | 30 | 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) { | |||
| 201 | 201 | ||
| 202 | // 18x, 127y1, 143y2 | 202 | // 18x, 127y1, 143y2 | 
| 203 | if (line.charsRevealed > 0) { | 203 | if (line.charsRevealed > 0) { | 
| 204 | SDL_Rect srcRect { | 204 | { | 
| 205 | 0, 0, messageLines_[lineIndex].charIndexToWidth[line.charsRevealed], | 205 | SDL_Rect srcRect { | 
| 206 | game.getFont().getCharacterHeight() | 206 | 0, 0, messageLines_[lineIndex].charIndexToWidth[line.charsRevealed], | 
| 207 | }; | 207 | game.getFont().getCharacterHeight() | 
| 208 | SDL_Rect destRect { | 208 | }; | 
| 209 | 18, | 209 | SDL_Rect destRect { | 
| 210 | 127 + 16 * lineIndex, | 210 | 18, | 
| 211 | srcRect.w, | 211 | 127 + 16 * lineIndex, | 
| 212 | srcRect.h }; | 212 | srcRect.w, | 
| 213 | 213 | srcRect.h }; | |
| 214 | SDL_RenderCopy(ren_.get(), messageLines_[lineIndex].renderedTex.get(), &srcRect, &destRect); | 214 | |
| 215 | SDL_RenderCopy(ren_.get(), messageLines_[lineIndex].renderedTex.get(), &srcRect, &destRect); | ||
| 216 | } | ||
| 217 | |||
| 218 | if (line.bulleted) { | ||
| 219 | vec2i charLoc = game.getFont().getCharacterLocation('^'); | ||
| 220 | vec2i charSize = game.getFont().getCharacterSize('^'); | ||
| 221 | SDL_Rect srcRect { charLoc.x(), charLoc.y(), charSize.w(), charSize.h() }; | ||
| 222 | SDL_Rect destRect { 13, 127 + 16 * lineIndex, charSize.w(), charSize.h() }; | ||
| 223 | |||
| 224 | SDL_RenderCopy(ren_.get(), textures_.at(game.getFont().getTextureId()).get(), &srcRect, &destRect); | ||
| 225 | } | ||
| 215 | } | 226 | } | 
| 216 | 227 | ||
| 217 | lineIndex++; | 228 | lineIndex++; | 
