diff options
-rw-r--r-- | res/scripts/default.lua | 2 | ||||
-rw-r--r-- | res/scripts/script0001.lua | 6 | ||||
-rw-r--r-- | res/scripts/test_trigger.lua | 2 | ||||
-rw-r--r-- | src/message_system.cpp | 11 | ||||
-rw-r--r-- | src/message_system.h | 1 | ||||
-rw-r--r-- | 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 @@ | |||
1 | function default() | 1 | function default() |
2 | StartCutscene() | 2 | StartCutscene() |
3 | DisplayMessage("No problem here.", "", SpeakerType.NONE) | 3 | DisplayMessage("* No problem here.", "", SpeakerType.NONE) |
4 | HideCutsceneBars() | 4 | HideCutsceneBars() |
5 | end | 5 | 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() | |||
4 | local barkingNoise = LoopSound("barking_at_hallucination.wav") | 4 | local barkingNoise = LoopSound("barking_at_hallucination.wav") |
5 | 5 | ||
6 | SetAnimation("flint", "talk") | 6 | SetAnimation("flint", "talk") |
7 | 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) | 7 | 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) |
8 | ShowChoice("Yes", "No") | 8 | ShowChoice("Yes", "No") |
9 | WaitForEndOfMessage() | 9 | WaitForEndOfMessage() |
10 | 10 | ||
@@ -13,9 +13,9 @@ function script0001() | |||
13 | PlaySound("boney_growl.wav") | 13 | PlaySound("boney_growl.wav") |
14 | 14 | ||
15 | if GetChoiceSelection() == 0 then | 15 | if GetChoiceSelection() == 0 then |
16 | 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) | 16 | 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) |
17 | else | 17 | else |
18 | 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) | 18 | 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) |
19 | end | 19 | end |
20 | 20 | ||
21 | WaitForEndOfMessage() | 21 | 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 @@ | |||
1 | function test_trigger() | 1 | function test_trigger() |
2 | StartCutscene() | 2 | StartCutscene() |
3 | PlaySound("boney_growl.wav") | 3 | PlaySound("boney_growl.wav") |
4 | DisplayMessage("Hi! Welcome to the funky zone.", "", SpeakerType.NONE) | 4 | DisplayMessage("* Hi! Welcome to the funky zone.", "", SpeakerType.NONE) |
5 | WaitForEndOfMessage() | 5 | WaitForEndOfMessage() |
6 | HideCutsceneBars() | 6 | HideCutsceneBars() |
7 | end | 7 | 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 | |||
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++; |