2025-04-24 00:14:09 +04:00
|
|
|
#include "ui/CSimpleMovieFrame.hpp"
|
|
|
|
|
#include "ui/CSimpleMovieFrameScript.hpp"
|
|
|
|
|
|
|
|
|
|
int32_t CSimpleMovieFrame::s_metatable;
|
|
|
|
|
int32_t CSimpleMovieFrame::s_objectType;
|
|
|
|
|
|
|
|
|
|
void CSimpleMovieFrame::CreateScriptMetaTable() {
|
|
|
|
|
lua_State* L = FrameScript_GetContext();
|
|
|
|
|
int32_t ref = FrameScript_Object::CreateScriptMetaTable(L, &CSimpleMovieFrame::RegisterScriptMethods);
|
|
|
|
|
CSimpleMovieFrame::s_metatable = ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t CSimpleMovieFrame::GetObjectType() {
|
|
|
|
|
if (!CSimpleMovieFrame::s_objectType) {
|
|
|
|
|
CSimpleMovieFrame::s_objectType = ++FrameScript_Object::s_objectTypes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CSimpleMovieFrame::s_objectType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSimpleMovieFrame::RegisterScriptMethods(lua_State* L) {
|
|
|
|
|
CSimpleFrame::RegisterScriptMethods(L);
|
|
|
|
|
FrameScript_Object::FillScriptMethodTable(L, SimpleMovieFrameMethods, NUM_SIMPLE_MOVIE_FRAME_SCRIPT_METHODS);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-24 01:30:45 +04:00
|
|
|
void CSimpleMovieFrame::RenderMovie(void* param) {
|
|
|
|
|
auto movieFrame = reinterpret_cast<CSimpleMovieFrame*>(param);
|
|
|
|
|
if (movieFrame->m_isPlaying) {
|
|
|
|
|
// movieFrame->UpdateTiming();
|
|
|
|
|
// movieFrame->Render();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-24 00:14:09 +04:00
|
|
|
FrameScript_Object::ScriptIx* CSimpleMovieFrame::GetScriptByName(const char* name, ScriptData& data) {
|
|
|
|
|
auto parentScript = CSimpleFrame::GetScriptByName(name, data);
|
|
|
|
|
|
|
|
|
|
if (parentScript) {
|
|
|
|
|
return parentScript;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!SStrCmpI(name, "OnMovieFinished", STORM_MAX_STR)) {
|
2025-04-24 00:42:23 +04:00
|
|
|
return &this->m_onMovieFinished;
|
2025-04-24 00:14:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!SStrCmpI(name, "OnMovieShowSubtitle", STORM_MAX_STR)) {
|
|
|
|
|
data.wrapper = "return function(self,text) %s end";
|
2025-04-24 00:42:23 +04:00
|
|
|
return &this->m_onMovieShowSubtitle;
|
2025-04-24 00:14:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!SStrCmpI(name, "OnMovieHideSubtitle", STORM_MAX_STR)) {
|
2025-04-24 00:42:23 +04:00
|
|
|
return &this->m_onMovieHideSubtitle;
|
2025-04-24 00:14:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CSimpleMovieFrame::IsA(int32_t type) {
|
|
|
|
|
return type == CSimpleMovieFrame::s_objectType
|
|
|
|
|
|| type == CSimpleFrame::s_objectType
|
|
|
|
|
|| type == CScriptRegion::s_objectType
|
|
|
|
|
|| type == CScriptObject::s_objectType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t CSimpleMovieFrame::GetScriptMetaTable() {
|
|
|
|
|
return CSimpleMovieFrame::s_metatable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSimpleMovieFrame::OnFrameRender(CRenderBatch* batch, uint32_t layer) {
|
2025-04-24 01:30:45 +04:00
|
|
|
this->CSimpleFrame::OnFrameRender(batch, layer);
|
|
|
|
|
if (layer == DRAWLAYER_ARTWORK) {
|
|
|
|
|
batch->QueueCallback(&CSimpleMovieFrame::RenderMovie, this);
|
|
|
|
|
}
|
2025-04-24 00:14:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSimpleMovieFrame::CSimpleMovieFrame(CSimpleFrame* parent)
|
|
|
|
|
: CSimpleFrame(parent) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t CSimpleMovieFrame::StartMovie(const char* filename, int32_t volume) {
|
2025-04-24 01:02:26 +04:00
|
|
|
if (!this->ParseAVIFile(filename) || !this->OpenVideo()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SStrCopy(this->m_filename, filename, 256);
|
|
|
|
|
this->m_volume = volume;
|
|
|
|
|
|
|
|
|
|
// this->OpenAudio(this, filename, volume, 0);
|
|
|
|
|
// this->OpenCaptions(this, filename);
|
|
|
|
|
|
|
|
|
|
this->m_isPlaying = 1;
|
|
|
|
|
return 1;
|
2025-04-24 00:14:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSimpleMovieFrame::StopMovie() {
|
2025-04-24 01:30:45 +04:00
|
|
|
if (!this->m_isPlaying) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UnloadDivxDecoder
|
|
|
|
|
// CloseAudio
|
|
|
|
|
// CloseCaptions
|
|
|
|
|
this->m_isStopped = 0;
|
|
|
|
|
this->m_isPlaying = 0;
|
|
|
|
|
if (this->m_onMovieFinished.luaRef) {
|
|
|
|
|
this->RunScript(this->m_onMovieFinished, 0, nullptr);
|
|
|
|
|
}
|
2025-04-24 00:14:09 +04:00
|
|
|
}
|
2025-04-24 01:02:26 +04:00
|
|
|
|
|
|
|
|
int32_t CSimpleMovieFrame::ParseAVIFile(const char* filename) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t CSimpleMovieFrame::OpenVideo() {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|