- 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;

View file

@ -173,7 +173,8 @@ public:
virtual void DoEffect ();
virtual bool Grind(bool items);
virtual const char *PickupMessage ();
virtual FString PickupMessage ();
FString GetPickupMessage();
virtual void PlayPickupSound (AActor *toucher);
bool DoRespawn ();
@ -228,7 +229,7 @@ protected:
private:
static int StaticLastMessageTic;
static const char *StaticLastMessage;
static FString StaticLastMessage;
};
class AStateProvider : public AInventory
@ -438,7 +439,7 @@ class AHealth : public AInventory
public:
int PrevHealth;
virtual bool TryPickup (AActor *&other);
virtual const char *PickupMessage ();
virtual FString PickupMessage ();
};
// HealthPickup is some item that gives the player health when used.

View file

@ -177,7 +177,7 @@ bool AWeaponPiece::PrivateShouldStay ()
//
//===========================================================================
const char *AWeaponPiece::PickupMessage ()
FString AWeaponPiece::PickupMessage ()
{
if (FullWeapon)
{

View file

@ -22,7 +22,7 @@ public:
bool TryPickup (AActor *&toucher);
bool TryPickupRestricted (AActor *&toucher);
bool ShouldStay ();
virtual const char *PickupMessage ();
virtual FString PickupMessage ();
virtual void PlayPickupSound (AActor *toucher);
int PieceValue;