Revert "GUI2/Outro: don't keep unnecessary copy of current text"

It's necessary, because text_index isn't always in-bounds for
the text_ vector. See 987827b475
for the bug number.

Note: the build of campaignd is currently broken by commit
3f61aaa8f4, but there's a PR which
should merge shortly to fix that.

This reverts commit 82fa0742a1.
This commit is contained in:
Steve Cotton 2024-03-11 20:07:28 +01:00
parent bb5eea3017
commit 8974d04147
2 changed files with 7 additions and 7 deletions

View file

@ -43,6 +43,7 @@ REGISTER_DIALOG(outro)
outro::outro(const game_classification& info)
: modal_dialog(window_id())
, text_()
, current_text_()
, text_index_(0)
, duration_(info.end_text_duration)
, fade_alpha_(0)
@ -93,6 +94,8 @@ outro::outro(const game_classification& info)
}
}
current_text_ = text_[0];
if(!duration_) {
duration_ = 3500; // 3.5 seconds
}
@ -101,7 +104,7 @@ outro::outro(const game_classification& info)
void outro::pre_show(window& window)
{
window.set_enter_disabled(true);
window.get_canvas(0).set_variable("outro_text", wfl::variant{current_text()});
window.get_canvas(0).set_variable("outro_text", wfl::variant(current_text_));
}
void outro::update()
@ -138,9 +141,10 @@ void outro::update()
window::close();
return;
}
current_text_ = text_[text_index_];
// ...else show the next bit.
window_canvas.set_variable("outro_text", wfl::variant{current_text()});
window_canvas.set_variable("outro_text", wfl::variant(current_text_));
fading_in_ = true;

View file

@ -48,12 +48,8 @@ private:
virtual void post_show(window& window) override;
const std::string& current_text() const
{
return text_[text_index_];
}
std::vector<std::string> text_;
std::string current_text_;
std::size_t text_index_;
unsigned int duration_;