- changed the return value of PickupMessage to an FString so that it can interface with scripts.

- use standard convention of prefacing localizable strings with "$" for C_MidPrint.
This commit is contained in:
Christoph Oelckers 2016-11-28 16:19:01 +01:00
commit d2ce78fae7
11 changed files with 44 additions and 19 deletions

View file

@ -475,7 +475,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition)
}
int AInventory::StaticLastMessageTic;
const char *AInventory::StaticLastMessage;
FString AInventory::StaticLastMessage;
IMPLEMENT_CLASS(AInventory, false, true)
@ -1205,10 +1205,10 @@ void AInventory::Touch (AActor *toucher)
if (!(ItemFlags & IF_QUIET))
{
const char * message = PickupMessage ();
FString message = GetPickupMessage ();
if (message != NULL && *message != 0 && localview
&& (StaticLastMessageTic != gametic || StaticLastMessage != message))
if (message.IsNotEmpty() && localview
&& (StaticLastMessageTic != gametic || StaticLastMessage.Compare(message)))
{
StaticLastMessageTic = gametic;
StaticLastMessage = message;
@ -1283,11 +1283,32 @@ void AInventory::DoPickupSpecial (AActor *toucher)
//
//===========================================================================
const char *AInventory::PickupMessage ()
FString AInventory::PickupMessage ()
{
return GetClass()->PickupMessage;
}
DEFINE_ACTION_FUNCTION(AInventory, PickupMessage)
{
PARAM_SELF_PROLOGUE(AInventory);
ACTION_RETURN_STRING(self->PickupMessage());
}
FString AInventory::GetPickupMessage()
{
IFVIRTUAL(AInventory, PickupMessage)
{
VMValue params[1] = { (DObject*)this };
VMReturn ret;
VMFrameStack stack;
FString retval;
ret.StringAt(&retval);
stack.Call(func, params, 1, &ret, 1, nullptr);
return retval;
}
else return PickupMessage();
}
//===========================================================================
//
// AInventory :: PlayPickupSound
@ -1884,7 +1905,7 @@ DEFINE_FIELD(AHealth, PrevHealth)
// AHealth :: PickupMessage
//
//===========================================================================
const char *AHealth::PickupMessage ()
FString AHealth::PickupMessage ()
{
int threshold = GetClass()->LowHealth;