mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Add autodelete parameter to ShowString
This commit is contained in:
parent
37267e99f1
commit
57cf323d73
3 changed files with 17 additions and 5 deletions
|
@ -109,7 +109,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>
|
||||
|
@ -131,7 +131,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.
|
||||
|
@ -151,6 +151,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>
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue