Browse Source

Enable plDynamicTextMsg sending

Bartek Bok 13 years ago committed by Adam Johnson
parent
commit
6832881e32
  1. 16
      Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp
  2. 23
      Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp
  3. 8
      Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.h
  4. 1
      Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp

16
Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp

@ -815,8 +815,8 @@ bool plDynamicTextMap::MsgReceive( plMessage *msg )
if( textMsg->fCmd & plDynamicTextMsg::kSetTextColor ) if( textMsg->fCmd & plDynamicTextMsg::kSetTextColor )
SetTextColor( textMsg->fColor, textMsg->fBlockRGB ); SetTextColor( textMsg->fColor, textMsg->fBlockRGB );
if( (textMsg->fCmd & plDynamicTextMsg::kSetFont ) && textMsg->fString) if( (textMsg->fCmd & plDynamicTextMsg::kSetFont ) && !textMsg->fString.IsNull())
SetFont( textMsg->fString, textMsg->fX, (uint8_t)(textMsg->fFlags) ); SetFont( textMsg->fString.ToWchar(), textMsg->fX, (uint8_t)(textMsg->fFlags) );
if( textMsg->fCmd & plDynamicTextMsg::kSetLineSpacing ) if( textMsg->fCmd & plDynamicTextMsg::kSetLineSpacing )
SetLineSpacing( textMsg->fLineSpacing ); SetLineSpacing( textMsg->fLineSpacing );
@ -832,16 +832,16 @@ bool plDynamicTextMap::MsgReceive( plMessage *msg )
FrameRect( textMsg->fLeft, textMsg->fTop, textMsg->fRight - textMsg->fLeft + 1, FrameRect( textMsg->fLeft, textMsg->fTop, textMsg->fRight - textMsg->fLeft + 1,
textMsg->fBottom - textMsg->fTop + 1, textMsg->fColor ); textMsg->fBottom - textMsg->fTop + 1, textMsg->fColor );
if( (textMsg->fCmd & plDynamicTextMsg::kDrawString ) && textMsg->fString) if( (textMsg->fCmd & plDynamicTextMsg::kDrawString ) && !textMsg->fString.IsNull())
DrawString( textMsg->fX, textMsg->fY, textMsg->fString ); DrawString( textMsg->fX, textMsg->fY, textMsg->fString.ToWchar() );
if( (textMsg->fCmd & plDynamicTextMsg::kDrawClippedString ) && textMsg->fString) if( (textMsg->fCmd & plDynamicTextMsg::kDrawClippedString ) && !textMsg->fString.IsNull())
DrawClippedString( textMsg->fX, textMsg->fY, textMsg->fString, DrawClippedString( textMsg->fX, textMsg->fY, textMsg->fString.ToWchar(),
textMsg->fLeft, textMsg->fTop, textMsg->fRight - textMsg->fLeft + 1, textMsg->fLeft, textMsg->fTop, textMsg->fRight - textMsg->fLeft + 1,
textMsg->fBottom - textMsg->fTop + 1 ); textMsg->fBottom - textMsg->fTop + 1 );
if( (textMsg->fCmd & plDynamicTextMsg::kDrawWrappedString ) && textMsg->fString) if( (textMsg->fCmd & plDynamicTextMsg::kDrawWrappedString ) && !textMsg->fString.IsNull())
DrawWrappedString( textMsg->fX, textMsg->fY, textMsg->fString, textMsg->fRight, textMsg->fBottom ); DrawWrappedString( textMsg->fX, textMsg->fY, textMsg->fString.ToWchar(), textMsg->fRight, textMsg->fBottom );
if( textMsg->fCmd & plDynamicTextMsg::kDrawImage ) if( textMsg->fCmd & plDynamicTextMsg::kDrawImage )
{ {

23
Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp

@ -65,7 +65,7 @@ void plDynamicTextMsg::SetFont( const char *face, int16_t size, bool isBold )
hsAssert( ( fCmd & ( kPosCmds | kStringCmds | kFlagCmds ) ) == 0, "Attempting to issue conflicting drawText commands" ); hsAssert( ( fCmd & ( kPosCmds | kStringCmds | kFlagCmds ) ) == 0, "Attempting to issue conflicting drawText commands" );
fCmd &= ~( kPosCmds | kStringCmds | kFlagCmds ); fCmd &= ~( kPosCmds | kStringCmds | kFlagCmds );
fCmd |= kSetFont; fCmd |= kSetFont;
fString = hsStringToWString( face ); fString = face;
fX = size; fX = size;
fFlags = (uint32_t)isBold; fFlags = (uint32_t)isBold;
} }
@ -123,9 +123,7 @@ void plDynamicTextMsg::DrawString( int16_t x, int16_t y, const wchar_t *text
fCmd &= ~( kStringCmds | kPosCmds ); fCmd &= ~( kStringCmds | kPosCmds );
fCmd |= kDrawString; fCmd |= kDrawString;
fString = new wchar_t[wcslen(text)+1]; fString = plString::FromWchar(text);
wcscpy( fString, text );
fString[wcslen(text)] = L'\0';
fX = x; fX = x;
fY = y; fY = y;
} }
@ -143,9 +141,7 @@ void plDynamicTextMsg::DrawClippedString( int16_t x, int16_t y, uint16_t clip
fCmd &= ~( kStringCmds | kPosCmds | kRectCmds ); fCmd &= ~( kStringCmds | kPosCmds | kRectCmds );
fCmd |= kDrawClippedString; fCmd |= kDrawClippedString;
fString = new wchar_t[wcslen(text)+1]; fString = plString::FromWchar(text);
wcscpy( fString, text );
fString[wcslen(text)] = L'\0';
fX = x; fX = x;
fY = y; fY = y;
@ -168,9 +164,7 @@ void plDynamicTextMsg::DrawWrappedString( int16_t x, int16_t y, uint16_t wrap
fCmd &= ~( kStringCmds | kPosCmds | kRectCmds ); fCmd &= ~( kStringCmds | kPosCmds | kRectCmds );
fCmd |= kDrawWrappedString; fCmd |= kDrawWrappedString;
fString = new wchar_t[wcslen(text)+1]; fString = plString::FromWchar(text);
wcscpy( fString, text );
fString[wcslen(text)] = L'\0';
fX = x; fX = x;
fY = y; fY = y;
@ -222,7 +216,7 @@ void plDynamicTextMsg::Read( hsStream *s, hsResMgr *mgr )
fClearColor.Read( s ); fClearColor.Read( s );
fColor.Read( s ); fColor.Read( s );
fString = s->ReadSafeWString(); fString = s->ReadSafeWString_TEMP();
fImageKey = mgr->ReadKey( s ); fImageKey = mgr->ReadKey( s );
s->ReadLE( &fFlags ); s->ReadLE( &fFlags );
@ -253,7 +247,8 @@ void plDynamicTextMsg::Write( hsStream *s, hsResMgr *mgr )
fClearColor.Write( s ); fClearColor.Write( s );
fColor.Write( s ); fColor.Write( s );
s->WriteSafeWString( plString::FromWchar(fString) ); s->WriteSafeWString(fString);
mgr->WriteKey( s, fImageKey ); mgr->WriteKey( s, fImageKey );
s->WriteLE( fFlags ); s->WriteLE( fFlags );
@ -306,7 +301,7 @@ void plDynamicTextMsg::ReadVersion(hsStream* s, hsResMgr* mgr)
if (contentFlags.IsBitSet(kDynTextMsgColor)) if (contentFlags.IsBitSet(kDynTextMsgColor))
fColor.Read( s ); fColor.Read( s );
if (contentFlags.IsBitSet(kDynTextMsgString)) if (contentFlags.IsBitSet(kDynTextMsgString))
fString = s->ReadSafeWString(); fString = s->ReadSafeWString_TEMP();
if (contentFlags.IsBitSet(kDynTextMsgImageKey)) if (contentFlags.IsBitSet(kDynTextMsgImageKey))
fImageKey = mgr->ReadKey( s ); fImageKey = mgr->ReadKey( s );
if (contentFlags.IsBitSet(kDynTextMsgFlags)) if (contentFlags.IsBitSet(kDynTextMsgFlags))
@ -360,7 +355,7 @@ void plDynamicTextMsg::WriteVersion(hsStream* s, hsResMgr* mgr)
fColor.Write( s ); fColor.Write( s );
// kDynTextMsgString // kDynTextMsgString
s->WriteSafeWString( plString::FromWchar(fString) ); s->WriteSafeWString( fString );
// kDynTextMsgImageKey // kDynTextMsgImageKey
mgr->WriteKey( s, fImageKey ); mgr->WriteKey( s, fImageKey );

8
Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.h

@ -72,7 +72,7 @@ protected:
hsColorRGBA fColor; hsColorRGBA fColor;
// String // String
wchar_t *fString; plString fString;
// Mipmap // Mipmap
plKey fImageKey; plKey fImageKey;
@ -84,8 +84,10 @@ protected:
int16_t fLineSpacing; int16_t fLineSpacing;
public: public:
plDynamicTextMsg() : plMessage( nil, nil, nil ) { fCmd = 0; fString = nil; fImageKey = nil; fFlags = 0; fBlockRGB = false; } plDynamicTextMsg() :
~plDynamicTextMsg() { delete [] fString; } plMessage(nullptr, nullptr, nullptr),
fCmd(0), fImageKey(nullptr), fFlags(0), fBlockRGB(false)
{ }
CLASSNAME_REGISTER( plDynamicTextMsg ); CLASSNAME_REGISTER( plDynamicTextMsg );
GETINTERFACE_ANY( plDynamicTextMsg, plMessage ); GETINTERFACE_ANY( plDynamicTextMsg, plMessage );

1
Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp

@ -116,6 +116,7 @@ plNetMsgScreener::Answer plNetMsgScreener::IAllowMessageType(int16_t classIndex,
case CLASS_INDEX_SCOPED(plEnableMsg): case CLASS_INDEX_SCOPED(plEnableMsg):
case CLASS_INDEX_SCOPED(plLinkToAgeMsg): case CLASS_INDEX_SCOPED(plLinkToAgeMsg):
case CLASS_INDEX_SCOPED(plSubWorldMsg): case CLASS_INDEX_SCOPED(plSubWorldMsg):
case CLASS_INDEX_SCOPED(plDynamicTextMsg):
return kYes; return kYes;
// conditionally yes, requires further validation of msg contents // conditionally yes, requires further validation of msg contents

Loading…
Cancel
Save