-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script API: implemented VideoPlayer API
- Loading branch information
1 parent
8e144cb
commit 6b569f9
Showing
21 changed files
with
879 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//============================================================================= | ||
// | ||
// Adventure Game Studio (AGS) | ||
// | ||
// Copyright (C) 1999-2011 Chris Jones and 2011-2024 various contributors | ||
// The full list of copyright holders can be found in the Copyright.txt | ||
// file, which is part of this source code distribution. | ||
// | ||
// The AGS source code is provided under the Artistic License 2.0. | ||
// A copy of this license can be found in the file License.txt and at | ||
// https://opensource.org/license/artistic-2-0/ | ||
// | ||
//============================================================================= | ||
#include "ac/dynobj/scriptvideoplayer.h" | ||
#include "ac/dynobj/dynobj_manager.h" | ||
#include "media/video/video.h" | ||
#include "util/stream.h" | ||
|
||
using namespace AGS::Common; | ||
|
||
const char *ScriptVideoPlayer::GetType() | ||
{ | ||
return "VideoPlayer"; | ||
} | ||
|
||
int ScriptVideoPlayer::Dispose(void* /*address*/, bool /*force*/) | ||
{ | ||
if (_id >= 0) | ||
{ | ||
video_stop(_id); | ||
} | ||
|
||
delete this; | ||
return 1; | ||
} | ||
|
||
size_t ScriptVideoPlayer::CalcSerializeSize(const void* /*address*/) | ||
{ | ||
return sizeof(int32_t); | ||
} | ||
|
||
void ScriptVideoPlayer::Serialize(const void* /*address*/, Stream *out) | ||
{ | ||
out->WriteInt32(_id); | ||
} | ||
|
||
void ScriptVideoPlayer::Unserialize(int index, Stream *in, size_t /*data_sz*/) | ||
{ | ||
_id = in->ReadInt32(); | ||
ccRegisterUnserializedObject(index, this, this); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//============================================================================= | ||
// | ||
// Adventure Game Studio (AGS) | ||
// | ||
// Copyright (C) 1999-2011 Chris Jones and 2011-2024 various contributors | ||
// The full list of copyright holders can be found in the Copyright.txt | ||
// file, which is part of this source code distribution. | ||
// | ||
// The AGS source code is provided under the Artistic License 2.0. | ||
// A copy of this license can be found in the file License.txt and at | ||
// https://opensource.org/license/artistic-2-0/ | ||
// | ||
//============================================================================= | ||
#ifndef __AC_SCRIPTVIDEOPLAYER_H | ||
#define __AC_SCRIPTVIDEOPLAYER_H | ||
|
||
#include "ac/dynobj/cc_agsdynamicobject.h" | ||
|
||
struct ScriptVideoPlayer final : AGSCCDynamicObject | ||
{ | ||
public: | ||
ScriptVideoPlayer(int id) : _id(id) {} | ||
// Get videoplayer's index; negative means the video was removed | ||
int GetID() const { return _id; } | ||
// Reset videoplayer's index to indicate that this reference is no longer valid | ||
void Invalidate() { _id = -1; } | ||
|
||
const char *GetType() override; | ||
int Dispose(void *address, bool force) override; | ||
void Unserialize(int index, AGS::Common::Stream *in, size_t data_sz) override; | ||
|
||
private: | ||
// Calculate and return required space for serialization, in bytes | ||
size_t CalcSerializeSize(const void *address) override; | ||
// Write object data into the provided stream | ||
void Serialize(const void *address, AGS::Common::Stream *out) override; | ||
|
||
int _id = -1; // index of videoplayer in the video subsystem | ||
}; | ||
|
||
#endif // __AC_SCRIPTVIDEOPLAYER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.