diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-21 10:40:31 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-21 10:40:31 -0400 |
| commit | 5e37c9a7034edfc4eec4d4ed15224b0f63c736af (patch) | |
| tree | faf00bd8cbd75cecec6b17bfca51d7a4cb0b3d18 /src | |
| parent | 38e6691fd3b713fe72cb955214c59cdee8b435b4 (diff) | |
| download | ether-5e37c9a7034edfc4eec4d4ed15224b0f63c736af.tar.gz ether-5e37c9a7034edfc4eec4d4ed15224b0f63c736af.tar.bz2 ether-5e37c9a7034edfc4eec4d4ed15224b0f63c736af.zip | |
fancier textboxes
Diffstat (limited to 'src')
| -rw-r--r-- | src/renderer.cpp | 25 | ||||
| -rw-r--r-- | src/renderer.h | 2 | ||||
| -rw-r--r-- | src/sign.cpp | 23 | ||||
| -rw-r--r-- | src/sign.h | 4 |
4 files changed, 44 insertions, 10 deletions
| diff --git a/src/renderer.cpp b/src/renderer.cpp index 2fc6023..afc022e 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp | |||
| @@ -121,6 +121,8 @@ void Renderer::loadAllTextures() { | |||
| 121 | loadTextureFromFile("read_instruction.png", readInstruction_); | 121 | loadTextureFromFile("read_instruction.png", readInstruction_); |
| 122 | loadTextureFromFile("menu.png", menuBg_); | 122 | loadTextureFromFile("menu.png", menuBg_); |
| 123 | loadTextureFromFile("help.png", help_); | 123 | loadTextureFromFile("help.png", help_); |
| 124 | loadTextureFromFile("message.png", messageBg_); | ||
| 125 | loadTextureFromFile("feather.png", feather_); | ||
| 124 | 126 | ||
| 125 | loadTextureFromFile("title0.png", titles_[0]); | 127 | loadTextureFromFile("title0.png", titles_[0]); |
| 126 | SDL_QueryTexture(titles_[0].get(), nullptr, nullptr, &titleWidths_[0], &titleHeights_[0]); | 128 | SDL_QueryTexture(titles_[0].get(), nullptr, nullptr, &titleWidths_[0], &titleHeights_[0]); |
| @@ -455,16 +457,8 @@ void Renderer::renderGame( | |||
| 455 | opacity = game.sign.signDisplayFade.getProgress(255, 0); | 457 | opacity = game.sign.signDisplayFade.getProgress(255, 0); |
| 456 | } | 458 | } |
| 457 | 459 | ||
| 458 | SDL_Rect signRect { | 460 | SDL_SetTextureAlphaMod(messageBg_.get(), opacity); |
| 459 | 0, | 461 | SDL_RenderCopy(ren_.get(), messageBg_.get(), nullptr, nullptr); |
| 460 | GAME_HEIGHT / 2 - (45 * 2 + 1 + MESSAGE_MARGIN * 2) / 2, | ||
| 461 | GAME_WIDTH, | ||
| 462 | 45 * 2 + 1 + MESSAGE_MARGIN * 2 | ||
| 463 | }; | ||
| 464 | |||
| 465 | SDL_SetRenderDrawBlendMode(ren_.get(), SDL_BLENDMODE_BLEND); | ||
| 466 | SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, opacity); | ||
| 467 | SDL_RenderFillRect(ren_.get(), &signRect); | ||
| 468 | 462 | ||
| 469 | if (game.sign.signDisplayState == SignInstructionState::Visible) { | 463 | if (game.sign.signDisplayState == SignInstructionState::Visible) { |
| 470 | int lineIndex = 0; | 464 | int lineIndex = 0; |
| @@ -493,6 +487,17 @@ void Renderer::renderGame( | |||
| 493 | 487 | ||
| 494 | lineIndex++; | 488 | lineIndex++; |
| 495 | } | 489 | } |
| 490 | |||
| 491 | if (game.sign.showNextArrow) { | ||
| 492 | SDL_Rect destRect { | ||
| 493 | GAME_WIDTH - MESSAGE_MARGIN - 32, | ||
| 494 | GAME_HEIGHT / 2 + (45 + 1 + MESSAGE_MARGIN) / 2 + game.sign.nextArrowBobPos - 32, | ||
| 495 | 64, | ||
| 496 | 64 }; | ||
| 497 | |||
| 498 | SDL_SetRenderTarget(ren_.get(), overlays.get()); | ||
| 499 | SDL_RenderCopy(ren_.get(), feather_.get(), nullptr, &destRect); | ||
| 500 | } | ||
| 496 | } | 501 | } |
| 497 | } | 502 | } |
| 498 | 503 | ||
| diff --git a/src/renderer.h b/src/renderer.h index 549f64a..136d0bf 100644 --- a/src/renderer.h +++ b/src/renderer.h | |||
| @@ -188,6 +188,8 @@ private: | |||
| 188 | texture_ptr readInstruction_; | 188 | texture_ptr readInstruction_; |
| 189 | texture_ptr menuBg_; | 189 | texture_ptr menuBg_; |
| 190 | texture_ptr help_; | 190 | texture_ptr help_; |
| 191 | texture_ptr messageBg_; | ||
| 192 | texture_ptr feather_; | ||
| 191 | 193 | ||
| 192 | std::array<texture_ptr, NUM_TITLES> titles_; | 194 | std::array<texture_ptr, NUM_TITLES> titles_; |
| 193 | std::array<int, NUM_TITLES> titleWidths_; | 195 | std::array<int, NUM_TITLES> titleWidths_; |
| diff --git a/src/sign.cpp b/src/sign.cpp index b9299d6..e488108 100644 --- a/src/sign.cpp +++ b/src/sign.cpp | |||
| @@ -92,6 +92,8 @@ void Sign::update(size_t dt, Game& game) { | |||
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | if (fullyRevealed) { | 94 | if (fullyRevealed) { |
| 95 | showNextArrow = false; | ||
| 96 | |||
| 95 | if (linesToShow.back().pause) { | 97 | if (linesToShow.back().pause) { |
| 96 | linesToShow.back().pause = false; | 98 | linesToShow.back().pause = false; |
| 97 | // Play a sound | 99 | // Play a sound |
| @@ -126,6 +128,27 @@ void Sign::update(size_t dt, Game& game) { | |||
| 126 | } | 128 | } |
| 127 | linesToShow.push_back(lines.front()); | 129 | linesToShow.push_back(lines.front()); |
| 128 | lines.pop_front(); | 130 | lines.pop_front(); |
| 131 | } else { | ||
| 132 | showNextArrow = true; | ||
| 133 | } | ||
| 134 | } | ||
| 135 | } | ||
| 136 | |||
| 137 | if (showNextArrow) { | ||
| 138 | nextArrowBobTimer_.accumulate(dt); | ||
| 139 | while (nextArrowBobTimer_.step()) { | ||
| 140 | if (nextArrowBobDown_) { | ||
| 141 | nextArrowBobPos++; | ||
| 142 | |||
| 143 | if (nextArrowBobPos >= 4) { | ||
| 144 | nextArrowBobDown_ = false; | ||
| 145 | } | ||
| 146 | } else { | ||
| 147 | nextArrowBobPos--; | ||
| 148 | |||
| 149 | if (nextArrowBobPos <= 0) { | ||
| 150 | nextArrowBobDown_ = true; | ||
| 151 | } | ||
| 129 | } | 152 | } |
| 130 | } | 153 | } |
| 131 | } | 154 | } |
| diff --git a/src/sign.h b/src/sign.h index c90a8fd..8a69fd3 100644 --- a/src/sign.h +++ b/src/sign.h | |||
| @@ -35,11 +35,15 @@ public: | |||
| 35 | Interpolation signDisplayFade; | 35 | Interpolation signDisplayFade; |
| 36 | std::list<SignLine> lines; | 36 | std::list<SignLine> lines; |
| 37 | std::list<SignLine> linesToShow; | 37 | std::list<SignLine> linesToShow; |
| 38 | bool showNextArrow = false; | ||
| 39 | int nextArrowBobPos = 0; | ||
| 38 | 40 | ||
| 39 | private: | 41 | private: |
| 40 | 42 | ||
| 41 | TTF_Font* font_; | 43 | TTF_Font* font_; |
| 42 | Timer textAdvTimer_ { 15 }; | 44 | Timer textAdvTimer_ { 15 }; |
| 45 | bool nextArrowBobDown_ = true; | ||
| 46 | Timer nextArrowBobTimer_ { 125 }; | ||
| 43 | }; | 47 | }; |
| 44 | 48 | ||
| 45 | #endif /* end of include guard: SIGN_H_B0491849 */ | 49 | #endif /* end of include guard: SIGN_H_B0491849 */ |
