Browse Source

pfGameGUIMsg => plString

Michael Hansen 11 years ago
parent
commit
82029b56ff
  1. 14
      Sources/Plasma/FeatureLib/pfConsole/pfGameConsoleCommands.cpp
  2. 6
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGameGUIMgr.cpp
  3. 34
      Sources/Plasma/FeatureLib/pfMessage/pfGameGUIMsg.h

14
Sources/Plasma/FeatureLib/pfConsole/pfGameConsoleCommands.cpp

@ -136,7 +136,7 @@ PF_CONSOLE_CMD( Game, LoadDialog, "string dlgName", "Loads the given GUI dialog
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog );
msg->SetString( params[ 0 ] ); msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
} }
} }
@ -148,8 +148,8 @@ PF_CONSOLE_CMD( Game, LoadLocalDialog, "string ageName, string dlgName", "Loads
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog );
msg->SetString( params[ 1 ] ); msg->SetString( (const char *)params[ 1 ] );
msg->SetAge( params[ 0 ] ); msg->SetAge( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
} }
} }
@ -161,7 +161,7 @@ PF_CONSOLE_CMD( Game, ShowDialog, "string dlgName", "Shows the given GUI dialog"
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog );
msg->SetString( params[ 0 ] ); msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
} }
} }
@ -173,7 +173,7 @@ PF_CONSOLE_CMD( Game, HideDialog, "string dlgName", "Hides the given GUI dialog"
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog );
msg->SetString( params[ 0 ] ); msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
} }
} }
@ -187,11 +187,11 @@ PF_CONSOLE_CMD( Game, SwitchDialog, "string olddlgName, string newdlgName", "Hid
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog );
msg->SetString( params[ 0 ] ); msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
pfGameGUIMsg *msg2 = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog ); pfGameGUIMsg *msg2 = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog );
msg2->SetString( params[ 1 ] ); msg2->SetString( (const char *)params[ 1 ] );
plgDispatch::MsgSend( msg2 ); plgDispatch::MsgSend( msg2 );
} }
} }

6
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGameGUIMgr.cpp

@ -181,11 +181,11 @@ bool pfGameGUIMgr::MsgReceive( plMessage* pMsg )
if( guiMsg != nil ) if( guiMsg != nil )
{ {
if( guiMsg->GetCommand() == pfGameGUIMsg::kLoadDialog ) if( guiMsg->GetCommand() == pfGameGUIMsg::kLoadDialog )
LoadDialog( guiMsg->GetString(), nil, guiMsg->GetAge() ); LoadDialog(guiMsg->GetString().c_str(), nil, guiMsg->GetAge().c_str());
else if( guiMsg->GetCommand() == pfGameGUIMsg::kShowDialog ) else if( guiMsg->GetCommand() == pfGameGUIMsg::kShowDialog )
IShowDialog( guiMsg->GetString() ); IShowDialog(guiMsg->GetString().c_str());
else if( guiMsg->GetCommand() == pfGameGUIMsg::kHideDialog ) else if( guiMsg->GetCommand() == pfGameGUIMsg::kHideDialog )
IHideDialog( guiMsg->GetString() ); IHideDialog(guiMsg->GetString().c_str());
return true; return true;
} }

34
Sources/Plasma/FeatureLib/pfMessage/pfGameGUIMsg.h

@ -52,13 +52,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h" #include "hsStream.h"
#include "pnMessage/plMessage.h" #include "pnMessage/plMessage.h"
#define GAME_GUI_MSG_STRING_SIZE (128)
class pfGameGUIMsg : public plMessage class pfGameGUIMsg : public plMessage
{ {
protected: protected:
uint8_t fCommand; uint8_t fCommand;
char fString[ 128 ]; plString fString;
char *fAge; plString fAge;
public: public:
enum enum
@ -68,9 +70,8 @@ class pfGameGUIMsg : public plMessage
kLoadDialog kLoadDialog
}; };
pfGameGUIMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fAge = nil; } pfGameGUIMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); }
pfGameGUIMsg( plKey &receiver, uint8_t command ) : plMessage( nil, nil, nil ) { AddReceiver( receiver ); fCommand = command; fAge = nil; } pfGameGUIMsg(plKey &receiver, uint8_t command) : plMessage(nil, nil, nil) { AddReceiver(receiver); fCommand = command; }
~pfGameGUIMsg() { delete [] fAge; }
CLASSNAME_REGISTER( pfGameGUIMsg ); CLASSNAME_REGISTER( pfGameGUIMsg );
GETINTERFACE_ANY( pfGameGUIMsg, plMessage ); GETINTERFACE_ANY( pfGameGUIMsg, plMessage );
@ -79,25 +80,30 @@ class pfGameGUIMsg : public plMessage
{ {
plMessage::IMsgRead( s, mgr ); plMessage::IMsgRead( s, mgr );
s->ReadLE( &fCommand ); s->ReadLE( &fCommand );
s->Read( sizeof( fString ), fString ); char buffer[GAME_GUI_MSG_STRING_SIZE];
fAge = s->ReadSafeString(); s->Read(sizeof(buffer), buffer);
buffer[GAME_GUI_MSG_STRING_SIZE - 1] = 0;
fString = buffer;
fAge = s->ReadSafeString_TEMP();
} }
virtual void Write(hsStream* s, hsResMgr* mgr) virtual void Write(hsStream* s, hsResMgr* mgr)
{ {
plMessage::IMsgWrite( s, mgr ); plMessage::IMsgWrite( s, mgr );
s->WriteLE( fCommand ); s->WriteLE( fCommand );
s->Write( sizeof( fString ), fString ); char buffer[GAME_GUI_MSG_STRING_SIZE];
strncpy(buffer, fString.c_str(), GAME_GUI_MSG_STRING_SIZE);
s->Write(sizeof(buffer), buffer);
s->WriteSafeString( fAge ); s->WriteSafeString( fAge );
} }
uint8_t GetCommand( void ) { return fCommand; } uint8_t GetCommand() const { return fCommand; }
void SetString( const char *str ) { hsStrncpy( fString, str, sizeof( fString ) - 1 ); } void SetString(const plString &str) { fString = str; }
const char *GetString( void ) { return fString; } plString GetString() const { return fString; }
void SetAge( const char *str ) { delete [] fAge; if( str == nil ) fAge = nil; else fAge = hsStrcpy( str ); } void SetAge(const plString &age) { fAge = age; }
const char *GetAge( void ) { return fAge; } plString GetAge() const { return fAge; }
}; };
#endif // _pfGameGUIMsg_h #endif // _pfGameGUIMsg_h

Loading…
Cancel
Save