Merge branch 'develop' into develop_60fps

This commit is contained in:
Lwmte 2024-05-03 10:16:48 +03:00
commit 83b6258de0
3 changed files with 17 additions and 5 deletions

View file

@ -111,7 +111,7 @@
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" ><a href="#ShowString">ShowString(str, time)</a></td>
<td class="name" ><a href="#ShowString">ShowString(str, time, autoDelete)</a></td>
<td class="summary">Show some text on-screen.</td>
</tr>
<tr>
@ -133,7 +133,7 @@
<dl class="function">
<dt>
<a name = "ShowString"></a>
<strong>ShowString(str, time)</strong>
<strong>ShowString(str, time, autoDelete)</strong>
</dt>
<dd>
Show some text on-screen.
@ -153,6 +153,13 @@ If not given, the string will have an "infinite" life, and will show
until <a href="../1 modules/Strings.html#HideString">HideString</a> is called or until the level is finished.
Default: nil (i.e. infinite)
</li>
<li><span class="parameter">autoDelete</span>
<span class="types"><span class="type">bool</span></span>
should be string automatically deleted after timeout is reached.
If not given, the string will remain allocated even after timeout is reached, and can be
shown again without re-initialization.
Default: false
</li>
</ul>

View file

@ -27,6 +27,10 @@ Show some text on-screen.
If not given, the string will have an "infinite" life, and will show
until @{HideString} is called or until the level is finished.
Default: nil (i.e. infinite)
@tparam bool autoDelete should be string automatically deleted after timeout is reached.
If not given, the string will remain allocated even after timeout is reached, and can be
shown again without re-initialization.
Default: false
*/
table.set_function(ScriptReserved_ShowString, &StringsHandler::ShowString, this);
@ -36,7 +40,7 @@ Hide some on-screen text.
@tparam DisplayString str the string object to hide. Must previously have been shown
with a call to @{ShowString}, or this function will have no effect.
*/
table.set_function(ScriptReserved_HideString, [this](const DisplayString& string) { ShowString(string, 0.0f); });
table.set_function(ScriptReserved_HideString, [this](const DisplayString& string) { ShowString(string, 0.0f, false); });
/***
Checks if the string is shown
@ -84,11 +88,12 @@ bool StringsHandler::SetDisplayString(DisplayStringID id, const UserDisplayStrin
return m_userDisplayStrings.insert_or_assign(id, displayString).second;
}
void StringsHandler::ShowString(const DisplayString& str, sol::optional<float> numSeconds)
void StringsHandler::ShowString(const DisplayString& str, sol::optional<float> numSeconds, sol::optional<bool> autoDelete)
{
auto it = m_userDisplayStrings.find(str.GetID());
it->second._timeRemaining = numSeconds.value_or(0.0f);
it->second._isInfinite = !numSeconds.has_value();
it->second._deleteWhenZero = autoDelete.value_or(false);
}
bool StringsHandler::IsStringDisplaying(const DisplayString& displayString)

View file

@ -26,7 +26,7 @@ public:
std::optional<std::reference_wrapper<UserDisplayString>> GetDisplayString(DisplayStringID id);
bool ScheduleRemoveDisplayString(DisplayStringID id);
void ShowString(DisplayString const&, sol::optional<float> nSeconds);
void ShowString(DisplayString const&, sol::optional<float> nSeconds, sol::optional<bool> autoDelete);
bool IsStringDisplaying(DisplayString const& str);