Browse Source

Movie filename in plMovieMsg and plBinkPlayer => plString

Michael Hansen 11 years ago
parent
commit
d8113a5ab7
  1. 8
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 35
      Sources/Plasma/FeatureLib/pfPython/pyMoviePlayer.cpp
  3. 12
      Sources/Plasma/FeatureLib/pfPython/pyMoviePlayer.h
  4. 2
      Sources/Plasma/FeatureLib/pfPython/pyMoviePlayerGlue.cpp
  5. 26
      Sources/Plasma/PubUtilLib/plMessage/plMovieMsg.h
  6. 15
      Sources/Plasma/PubUtilLib/plPipeline/plBinkPlayer.h

8
Sources/Plasma/Apps/plClient/plClient.cpp

@ -860,7 +860,7 @@ bool plClient::MsgReceive(plMessage* msg)
//============================================================================ //============================================================================
bool plClient::IHandleMovieMsg(plMovieMsg* mov) bool plClient::IHandleMovieMsg(plMovieMsg* mov)
{ {
if( !(mov->GetFileName() && *mov->GetFileName()) ) if (mov->GetFileName().IsEmpty())
return true; return true;
int i; int i;
@ -869,7 +869,7 @@ bool plClient::IHandleMovieMsg(plMovieMsg* mov)
{ {
for( i = 0; i < fMovies.GetCount(); i++ ) for( i = 0; i < fMovies.GetCount(); i++ )
{ {
if( !stricmp(mov->GetFileName(), fMovies[i]->GetFileName()) ) if (mov->GetFileName().CompareI(fMovies[i]->GetFileName()) == 0)
break; break;
} }
} }
@ -929,7 +929,7 @@ bool plClient::IHandleMovieMsg(plMovieMsg* mov)
// If a movie has lost its filename, it means something went horribly wrong // If a movie has lost its filename, it means something went horribly wrong
// with playing it and it has shutdown. Or we just stopped it. Either way, // with playing it and it has shutdown. Or we just stopped it. Either way,
// we need to clear it out of our list. // we need to clear it out of our list.
if( !(fMovies[i]->GetFileName() && *fMovies[i]->GetFileName()) ) if (fMovies[i]->GetFileName().IsEmpty())
{ {
delete fMovies[i]; delete fMovies[i];
fMovies.Remove(i); fMovies.Remove(i);
@ -1948,7 +1948,7 @@ void plClient::IServiceMovies()
int i; int i;
for( i = 0; i < fMovies.GetCount(); i++ ) for( i = 0; i < fMovies.GetCount(); i++ )
{ {
hsAssert(fMovies[i]->GetFileName() && *fMovies[i]->GetFileName(), "Lost our movie"); hsAssert(!fMovies[i]->GetFileName().IsEmpty(), "Lost our movie");
if( !fMovies[i]->NextFrame() ) if( !fMovies[i]->NextFrame() )
{ {
delete fMovies[i]; delete fMovies[i];

35
Sources/Plasma/FeatureLib/pfPython/pyMoviePlayer.cpp

@ -54,12 +54,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plMovieMsg.h" #include "plMessage/plMovieMsg.h"
#include "pfMessage/pfMovieEventMsg.h" #include "pfMessage/pfMovieEventMsg.h"
pyMoviePlayer::pyMoviePlayer(const char* movieName,pyKey& selfKey) pyMoviePlayer::pyMoviePlayer(const plString& movieName, pyKey& selfKey)
{ {
fMovieName = hsStrcpy(movieName); fMovieName = movieName;
fSelfKey = selfKey.getKey(); fSelfKey = selfKey.getKey();
// make the movie // make the movie
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -75,17 +75,14 @@ pyMoviePlayer::pyMoviePlayer(const char* movieName,pyKey& selfKey)
pyMoviePlayer::~pyMoviePlayer() pyMoviePlayer::~pyMoviePlayer()
{ {
Stop(); Stop();
delete [] fMovieName;
} }
void pyMoviePlayer::MakeMovie(const char* movieName, pyKey& selfKey) void pyMoviePlayer::MakeMovie(const plString& movieName, pyKey& selfKey)
{ {
Stop(); Stop();
if (fMovieName) fMovieName = movieName;
delete [] fMovieName;
fMovieName = hsStrcpy(movieName);
fSelfKey = selfKey.getKey(); fSelfKey = selfKey.getKey();
if (fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -99,7 +96,7 @@ void pyMoviePlayer::MakeMovie(const char* movieName, pyKey& selfKey)
void pyMoviePlayer::SetCenter(float x, float y) void pyMoviePlayer::SetCenter(float x, float y)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMove); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMove);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -111,7 +108,7 @@ void pyMoviePlayer::SetCenter(float x, float y)
void pyMoviePlayer::SetScale(float width, float height) void pyMoviePlayer::SetScale(float width, float height)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kScale); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kScale);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -123,7 +120,7 @@ void pyMoviePlayer::SetScale(float width, float height)
void pyMoviePlayer::SetColor(pyColor color) void pyMoviePlayer::SetColor(pyColor color)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kColor); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kColor);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -134,7 +131,7 @@ void pyMoviePlayer::SetColor(pyColor color)
void pyMoviePlayer::SetVolume(float volume) void pyMoviePlayer::SetVolume(float volume)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kVolume); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kVolume);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -145,7 +142,7 @@ void pyMoviePlayer::SetVolume(float volume)
void pyMoviePlayer::SetOpacity(float opacity) void pyMoviePlayer::SetOpacity(float opacity)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kOpacity); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kOpacity);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -157,7 +154,7 @@ void pyMoviePlayer::SetOpacity(float opacity)
void pyMoviePlayer::Play() void pyMoviePlayer::Play()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -167,7 +164,7 @@ void pyMoviePlayer::Play()
void pyMoviePlayer::PlayPaused() void pyMoviePlayer::PlayPaused()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart | plMovieMsg::kPause); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart | plMovieMsg::kPause);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -177,7 +174,7 @@ void pyMoviePlayer::PlayPaused()
void pyMoviePlayer::Pause() void pyMoviePlayer::Pause()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kPause); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kPause);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -187,7 +184,7 @@ void pyMoviePlayer::Pause()
void pyMoviePlayer::Resume() void pyMoviePlayer::Resume()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kResume); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kResume);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -197,7 +194,7 @@ void pyMoviePlayer::Resume()
void pyMoviePlayer::Stop() void pyMoviePlayer::Stop()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStop); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStop);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);

12
Sources/Plasma/FeatureLib/pfPython/pyMoviePlayer.h

@ -56,24 +56,24 @@ class pyColor;
class pyMoviePlayer class pyMoviePlayer
{ {
protected: protected:
char* fMovieName; plString fMovieName;
plKey fSelfKey; plKey fSelfKey;
pyMoviePlayer(): fMovieName(nil), fSelfKey(nil) {} // only used by python glue, do NOT call pyMoviePlayer(): fSelfKey(nil) {} // only used by python glue, do NOT call
pyMoviePlayer(const char* movieName,pyKey& selfKey); pyMoviePlayer(const plString& movieName, pyKey& selfKey);
public: public:
~pyMoviePlayer(); ~pyMoviePlayer();
// required functions for PyObject interoperability // required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMoviePlayer); PYTHON_CLASS_NEW_FRIEND(ptMoviePlayer);
static PyObject *New(const char* movieName, pyKey& selfKey); static PyObject *New(const plString& movieName, pyKey& selfKey);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMoviePlayer object PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMoviePlayer object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMoviePlayer); // converts a PyObject to a pyMoviePlayer (throws error if not correct type) PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMoviePlayer); // converts a PyObject to a pyMoviePlayer (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m); static void AddPlasmaClasses(PyObject *m);
static void AddPlasmaConstantsClasses(PyObject *m); static void AddPlasmaConstantsClasses(PyObject *m);
void MakeMovie(const char* movieName, pyKey& selfKey); // only used by python glue, do NOT call void MakeMovie(const plString& movieName, pyKey& selfKey); // only used by python glue, do NOT call
// getters and setters // getters and setters
virtual void SetCenter(float x, float y); virtual void SetCenter(float x, float y);

2
Sources/Plasma/FeatureLib/pfPython/pyMoviePlayerGlue.cpp

@ -164,7 +164,7 @@ PYTHON_END_METHODS_TABLE;
PLASMA_DEFAULT_TYPE(ptMoviePlayer, "Params: movieName,selfKey\nAccessor class to play in the MoviePlayer"); PLASMA_DEFAULT_TYPE(ptMoviePlayer, "Params: movieName,selfKey\nAccessor class to play in the MoviePlayer");
// required functions for PyObject interoperability // required functions for PyObject interoperability
PyObject *pyMoviePlayer::New(const char* movieName, pyKey& selfKey) PyObject *pyMoviePlayer::New(const plString& movieName, pyKey& selfKey)
{ {
ptMoviePlayer *newObj = (ptMoviePlayer*)ptMoviePlayer_type.tp_new(&ptMoviePlayer_type, NULL, NULL); ptMoviePlayer *newObj = (ptMoviePlayer*)ptMoviePlayer_type.tp_new(&ptMoviePlayer_type, NULL, NULL);
newObj->fThis->MakeMovie(movieName, selfKey); newObj->fThis->MakeMovie(movieName, selfKey);

26
Sources/Plasma/PubUtilLib/plMessage/plMovieMsg.h

@ -78,35 +78,35 @@ protected:
hsColorRGBA fColor; hsColorRGBA fColor;
hsColorRGBA fFadeInColor; hsColorRGBA fFadeInColor;
float fFadeInSecs; float fFadeInSecs;
hsColorRGBA fFadeOutColor; hsColorRGBA fFadeOutColor;
float fFadeOutSecs; float fFadeOutSecs;
float fVolume; float fVolume;
char* fFileName; plString fFileName;
uint16_t fCmd; uint16_t fCmd;
hsTArray<plMessage*> fCallbacks; hsTArray<plMessage*> fCallbacks;
public: public:
plMovieMsg(const char* n, uint16_t cmd) plMovieMsg(const plString& name, uint16_t cmd)
: plMessage(nil, nil, nil) : plMessage(nil, nil, nil)
{ {
fFileName = hsStrcpy(n); fFileName = name;
SetCmd(cmd).MakeDefault(); SetCmd(cmd).MakeDefault();
} }
plMovieMsg() : fFileName(nil), fCmd(kIgnore)
plMovieMsg() : fCmd(kIgnore)
{ {
MakeDefault(); MakeDefault();
} }
virtual ~plMovieMsg() virtual ~plMovieMsg()
{ {
delete [] fFileName; for (int i = 0; i < fCallbacks.GetCount(); i++)
int i;
for( i = 0; i < fCallbacks.GetCount(); i++ )
{ {
hsRefCnt_SafeUnRef(fCallbacks[i]); hsRefCnt_SafeUnRef(fCallbacks[i]);
} }
@ -157,8 +157,8 @@ public:
// Include the movie folder, e.g. "avi/porno.bik" // Include the movie folder, e.g. "avi/porno.bik"
// String is copied, not pointer copy. // String is copied, not pointer copy.
const char* GetFileName() const { return fFileName; } plString GetFileName() const { return fFileName; }
plMovieMsg& SetFileName(const char* n) { delete [] fFileName; fFileName = hsStrcpy(n); return *this; } plMovieMsg& SetFileName(const plString& name) { fFileName = name; return *this; }
// Color is mostly useful for alpha fade up and down. // Color is mostly useful for alpha fade up and down.
const hsColorRGBA& GetColor() const { return fColor; } const hsColorRGBA& GetColor() const { return fColor; }

15
Sources/Plasma/PubUtilLib/plPipeline/plBinkPlayer.h

@ -57,8 +57,7 @@ class plBinkPlayer
{ {
public: public:
plBinkPlayer() : fFileName(nil) { } plBinkPlayer() { }
~plBinkPlayer() { delete [] fFileName; }
static bool Init( hsWindowHndl hWnd) { return true; } static bool Init( hsWindowHndl hWnd) { return true; }
static bool DeInit() { return true; } static bool DeInit() { return true; }
@ -83,14 +82,12 @@ class plBinkPlayer
for (int i = 0; i < fCallbacks.GetCount(); i++) for (int i = 0; i < fCallbacks.GetCount(); i++)
fCallbacks[i]->Send(); fCallbacks[i]->Send();
fCallbacks.Reset(); fCallbacks.Reset();
delete [] fFileName; fFileName = plString::Null;
fFileName = nil;
return false; return false;
} }
void SetFileName(const char* filename) { void SetFileName(const plString& filename) {
delete [] fFileName; fFileName = filename;
fFileName = hsStrcpy(filename);
} }
void SetColor(const hsColorRGBA& c) { } void SetColor(const hsColorRGBA& c) { }
void SetPosition(float x, float y) { } void SetPosition(float x, float y) { }
@ -102,7 +99,7 @@ class plBinkPlayer
void SetPosition(const hsPoint2& p) { } void SetPosition(const hsPoint2& p) { }
void SetScale(const hsPoint2& s) { } void SetScale(const hsPoint2& s) { }
const char* GetFileName() const { return fFileName; } plString GetFileName() const { return fFileName; }
const hsColorRGBA GetColor() const { return hsColorRGBA(); } const hsColorRGBA GetColor() const { return hsColorRGBA(); }
const hsPoint2 GetPosition() const { return hsPoint2(); } const hsPoint2 GetPosition() const { return hsPoint2(); }
const hsPoint2 GetScale() const { return hsPoint2(); } const hsPoint2 GetScale() const { return hsPoint2(); }
@ -125,7 +122,7 @@ class plBinkPlayer
hsColorRGBA GetFadeToColor() const { return hsColorRGBA(); } hsColorRGBA GetFadeToColor() const { return hsColorRGBA(); }
private: private:
char* fFileName; plString fFileName;
hsTArray<plMessage*> fCallbacks; hsTArray<plMessage*> fCallbacks;
}; };

Loading…
Cancel
Save