mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-08-04 22:40:56 +03:00
Compare commits
4 Commits
f0257d3e4c
...
676fd280c6
Author | SHA1 | Date | |
---|---|---|---|
![]() |
676fd280c6 | ||
![]() |
967408b2e7 | ||
![]() |
92a3925797 | ||
![]() |
5a36ab2f7c |
115
src/ui/CSimpleMovieFrame.cpp
Normal file
115
src/ui/CSimpleMovieFrame.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSimpleMovieFrame::RenderMovie(void* param) {
|
||||||
|
auto movieFrame = reinterpret_cast<CSimpleMovieFrame*>(param);
|
||||||
|
if (movieFrame->m_isPlaying) {
|
||||||
|
// movieFrame->UpdateTiming();
|
||||||
|
// movieFrame->Render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
return &this->m_onMovieFinished;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(name, "OnMovieShowSubtitle", STORM_MAX_STR)) {
|
||||||
|
data.wrapper = "return function(self,text) %s end";
|
||||||
|
return &this->m_onMovieShowSubtitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(name, "OnMovieHideSubtitle", STORM_MAX_STR)) {
|
||||||
|
return &this->m_onMovieHideSubtitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
this->CSimpleFrame::OnFrameRender(batch, layer);
|
||||||
|
if (layer == DRAWLAYER_ARTWORK) {
|
||||||
|
batch->QueueCallback(&CSimpleMovieFrame::RenderMovie, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CSimpleMovieFrame::CSimpleMovieFrame(CSimpleFrame* parent)
|
||||||
|
: CSimpleFrame(parent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CSimpleMovieFrame::StartMovie(const char* filename, int32_t volume) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSimpleMovieFrame::StopMovie() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CSimpleMovieFrame::ParseAVIFile(const char* filename) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CSimpleMovieFrame::OpenVideo() {
|
||||||
|
return 0;
|
||||||
|
}
|
46
src/ui/CSimpleMovieFrame.hpp
Normal file
46
src/ui/CSimpleMovieFrame.hpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef UI_C_SIMPLE_MOVIE_FRAME_HPP
|
||||||
|
#define UI_C_SIMPLE_MOVIE_FRAME_HPP
|
||||||
|
|
||||||
|
#include "ui/CSimpleFrame.hpp"
|
||||||
|
#include <tempest/Vector.hpp>
|
||||||
|
|
||||||
|
class CRect;
|
||||||
|
class CRenderBatch;
|
||||||
|
|
||||||
|
class CSimpleMovieFrame : public CSimpleFrame {
|
||||||
|
public:
|
||||||
|
// Static variables
|
||||||
|
static int32_t s_metatable;
|
||||||
|
static int32_t s_objectType;
|
||||||
|
|
||||||
|
// Static functions
|
||||||
|
static void CreateScriptMetaTable();
|
||||||
|
static int32_t GetObjectType();
|
||||||
|
static void RegisterScriptMethods(lua_State* L);
|
||||||
|
static void RenderMovie(void* param);
|
||||||
|
|
||||||
|
// Member variables
|
||||||
|
int32_t m_isPlaying = 0;
|
||||||
|
int32_t m_isStopped = 0;
|
||||||
|
int32_t m_enableSubtitles = 0;
|
||||||
|
char m_filename[256];
|
||||||
|
int32_t m_volume = 100;
|
||||||
|
ScriptIx m_onMovieFinished;
|
||||||
|
ScriptIx m_onMovieShowSubtitle;
|
||||||
|
ScriptIx m_onMovieHideSubtitle;
|
||||||
|
|
||||||
|
// Virtual member functions
|
||||||
|
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
||||||
|
virtual bool IsA(int32_t type);
|
||||||
|
virtual int32_t GetScriptMetaTable();
|
||||||
|
virtual void OnFrameRender(CRenderBatch* batch, uint32_t layer);
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
CSimpleMovieFrame(CSimpleFrame* parent);
|
||||||
|
int32_t StartMovie(const char* filename, int32_t volume);
|
||||||
|
void StopMovie();
|
||||||
|
int32_t ParseAVIFile(const char* filename);
|
||||||
|
int32_t OpenVideo();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
47
src/ui/CSimpleMovieFrameScript.cpp
Normal file
47
src/ui/CSimpleMovieFrameScript.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#include "ui/CSimpleMovieFrameScript.hpp"
|
||||||
|
#include "ui/CSimpleMovieFrame.hpp"
|
||||||
|
#include "util/Lua.hpp"
|
||||||
|
#include "util/Unimplemented.hpp"
|
||||||
|
#include "util/StringTo.hpp"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
|
int32_t CSimpleMovieFrame_StartMovie(lua_State* L) {
|
||||||
|
auto type = CSimpleMovieFrame::GetObjectType();
|
||||||
|
auto movieFrame = static_cast<CSimpleMovieFrame*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
|
||||||
|
if (!lua_isstring(L, 2) || !lua_isnumber(L, 3)) {
|
||||||
|
return luaL_error(L, "Usage: %s:StartMovie(\"filename\", volume_0_to_255)", movieFrame->GetDisplayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t volume = static_cast<int32_t>(lua_tointeger(L, 3));
|
||||||
|
const char* filename = lua_tolstring(L, 2, nullptr);
|
||||||
|
|
||||||
|
if (movieFrame->StartMovie(filename, volume)) {
|
||||||
|
lua_pushnumber(L, 1.0);
|
||||||
|
} else {
|
||||||
|
lua_pushnil(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CSimpleMovieFrame_StopMovie(lua_State* L) {
|
||||||
|
auto type = CSimpleMovieFrame::GetObjectType();
|
||||||
|
auto movieFrame = static_cast<CSimpleMovieFrame*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
movieFrame->StopMovie();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CSimpleMovieFrame_EnableSubtitles(lua_State* L) {
|
||||||
|
auto type = CSimpleMovieFrame::GetObjectType();
|
||||||
|
auto movieFrame = static_cast<CSimpleMovieFrame*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
movieFrame->m_enableSubtitles = StringToBOOL(L, 2, 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FrameScript_Method SimpleMovieFrameMethods[NUM_SIMPLE_MOVIE_FRAME_SCRIPT_METHODS] = {
|
||||||
|
{ "StartMovie", &CSimpleMovieFrame_StartMovie },
|
||||||
|
{ "StopMovie", &CSimpleMovieFrame_StopMovie },
|
||||||
|
{ "EnableSubtitles", &CSimpleMovieFrame_EnableSubtitles }
|
||||||
|
};
|
10
src/ui/CSimpleMovieFrameScript.hpp
Normal file
10
src/ui/CSimpleMovieFrameScript.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef UI_C_SIMPLE_MOVIE_FRAME_SCRIPT_HPP
|
||||||
|
#define UI_C_SIMPLE_MOVIE_FRAME_SCRIPT_HPP
|
||||||
|
|
||||||
|
#include "ui/FrameScript.hpp"
|
||||||
|
|
||||||
|
#define NUM_SIMPLE_MOVIE_FRAME_SCRIPT_METHODS 3
|
||||||
|
|
||||||
|
extern FrameScript_Method SimpleMovieFrameMethods[NUM_SIMPLE_MOVIE_FRAME_SCRIPT_METHODS];
|
||||||
|
|
||||||
|
#endif
|
@ -6,6 +6,7 @@
|
|||||||
#include "ui/CSimpleFrame.hpp"
|
#include "ui/CSimpleFrame.hpp"
|
||||||
#include "ui/CSimpleHTML.hpp"
|
#include "ui/CSimpleHTML.hpp"
|
||||||
#include "ui/CSimpleModel.hpp"
|
#include "ui/CSimpleModel.hpp"
|
||||||
|
#include "ui/CSimpleMovieFrame.hpp"
|
||||||
#include "ui/CSimpleScrollFrame.hpp"
|
#include "ui/CSimpleScrollFrame.hpp"
|
||||||
#include "ui/CSimpleSlider.hpp"
|
#include "ui/CSimpleSlider.hpp"
|
||||||
#include "util/CStatus.hpp"
|
#include "util/CStatus.hpp"
|
||||||
@ -109,8 +110,10 @@ CSimpleFrame* Create_SimpleColorSelect(CSimpleFrame* parent) {
|
|||||||
|
|
||||||
CSimpleFrame* Create_SimpleMovieFrame(CSimpleFrame* parent) {
|
CSimpleFrame* Create_SimpleMovieFrame(CSimpleFrame* parent) {
|
||||||
// TODO
|
// TODO
|
||||||
|
// auto m = CDataAllocator::GetData(CSimpleMovie::s_simpleMovieHeap, 0, __FILE__, __LINE__);
|
||||||
|
|
||||||
return nullptr;
|
auto m = SMemAlloc(sizeof(CSimpleMovieFrame), __FILE__, __LINE__, 0x0);
|
||||||
|
return new (m) CSimpleMovieFrame(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLNode* FrameXML_AcquireHashNode(const char* name, const char*& tainted, bool& locked) {
|
XMLNode* FrameXML_AcquireHashNode(const char* name, const char*& tainted, bool& locked) {
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "ui/CSimpleHTML.hpp"
|
#include "ui/CSimpleHTML.hpp"
|
||||||
#include "ui/CSimpleModel.hpp"
|
#include "ui/CSimpleModel.hpp"
|
||||||
#include "ui/CSimpleModelFFX.hpp"
|
#include "ui/CSimpleModelFFX.hpp"
|
||||||
|
#include "ui/CSimpleMovieFrame.hpp"
|
||||||
#include "ui/CSimpleScrollFrame.hpp"
|
#include "ui/CSimpleScrollFrame.hpp"
|
||||||
#include "ui/CSimpleSlider.hpp"
|
#include "ui/CSimpleSlider.hpp"
|
||||||
#include "ui/CSimpleTexture.hpp"
|
#include "ui/CSimpleTexture.hpp"
|
||||||
@ -88,7 +89,7 @@ void RegisterSimpleFrameScriptMethods() {
|
|||||||
// TODO
|
// TODO
|
||||||
// CSimpleStatusBar::CreateScriptMetaTable();
|
// CSimpleStatusBar::CreateScriptMetaTable();
|
||||||
// CSimpleColorSelect::CreateScriptMetaTable();
|
// CSimpleColorSelect::CreateScriptMetaTable();
|
||||||
// CSimpleMovieFrame::CreateScriptMetaTable();
|
CSimpleMovieFrame::CreateScriptMetaTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemRegisterFunctions() {
|
void SystemRegisterFunctions() {
|
||||||
|
@ -118,7 +118,16 @@ int32_t Script_StopGlueMusic(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetMovieResolution(lua_State* L) {
|
int32_t Script_GetMovieResolution(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
auto gxResolution = CVar::Lookup("gxResolution");
|
||||||
|
STORM_ASSERT(gxResolution);
|
||||||
|
auto resolution = gxResolution->GetString();
|
||||||
|
STORM_ASSERT(resolution);
|
||||||
|
|
||||||
|
int32_t width = 0;
|
||||||
|
int32_t height = 0;
|
||||||
|
sscanf(resolution, "%dx%d", &width, &height);
|
||||||
|
lua_pushnumber(L, width);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetScreenWidth(lua_State* L) {
|
int32_t Script_GetScreenWidth(lua_State* L) {
|
||||||
|
Loading…
Reference in New Issue
Block a user