From 4f2b92a25ab1b43ed0aa68f189224bcdda4fa7b7 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Tue, 2 Sep 2014 05:18:29 -0600 Subject: [PATCH] Added __screen__ special texture name. Added AMV:GetTexture, RageTexture:Reload, and Screen:SetNextScreenName lua functions. --- Docs/Luadoc/Lua.xml | 3 +++ Docs/Luadoc/LuaDocumentation.xml | 9 +++++++++ src/ActorMultiVertex.cpp | 14 ++++++++++++++ src/ActorMultiVertex.h | 1 + src/RageBitmapTexture.cpp | 12 ++++++++++-- src/RageTexture.cpp | 6 ++++++ src/RageTextureManager.cpp | 21 ++++++++++++++++++++- src/RageTextureManager.h | 3 +++ src/Screen.cpp | 7 +++++++ src/Screen.h | 1 + 10 files changed, 74 insertions(+), 3 deletions(-) diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 3e9d5c4669..d7a2d0c7de 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -490,6 +490,7 @@ + @@ -1297,6 +1298,7 @@ + @@ -1316,6 +1318,7 @@ + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index b0ad156762..45ca9c8976 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -1538,6 +1538,9 @@ save yourself some time, copy this for undocumented things: Get the NumToDraw of the current tween state. + + Returns the ActorMultiVertex's texture. + Sets the EffectMode of the ActorMultiVertex. @@ -3724,6 +3727,9 @@ save yourself some time, copy this for undocumented things: Sets the animation or movie playback rate to fRate. + + Reloads the texture. + @@ -3779,6 +3785,9 @@ save yourself some time, copy this for undocumented things: This removes the callback from the list. + + Sets the NextScreen value to name. + [02 Other.lua] Gets a string from the current Screen in the current language. diff --git a/src/ActorMultiVertex.cpp b/src/ActorMultiVertex.cpp index 4d1f932b45..0470c5ba25 100644 --- a/src/ActorMultiVertex.cpp +++ b/src/ActorMultiVertex.cpp @@ -645,6 +645,19 @@ public: p->SetTexture( Texture ); return 0; } + static int GetTexture(T* p, lua_State *L) + { + RageTexture *texture = p->GetTexture(); + if(texture != NULL) + { + texture->PushSelf(L); + } + else + { + lua_pushnil(L); + } + return 1; + } LunaActorMultiVertex() { @@ -668,6 +681,7 @@ public: // Copy from RageTexture ADD_METHOD( SetTexture ); + ADD_METHOD( GetTexture ); // Load from file path ADD_METHOD( LoadTexture ); } diff --git a/src/ActorMultiVertex.h b/src/ActorMultiVertex.h index 58d4158889..176d2a7cad 100644 --- a/src/ActorMultiVertex.h +++ b/src/ActorMultiVertex.h @@ -75,6 +75,7 @@ public: void FinishTweening(); void SetTexture( RageTexture *Texture ); + RageTexture* GetTexture() { return _Texture; }; void LoadFromTexture( RageTextureID ID ); void UnloadTexture(); diff --git a/src/RageBitmapTexture.cpp b/src/RageBitmapTexture.cpp index 07d0ca16a5..3c58fc0b82 100644 --- a/src/RageBitmapTexture.cpp +++ b/src/RageBitmapTexture.cpp @@ -65,7 +65,15 @@ void RageBitmapTexture::Create() /* Load the image into a RageSurface. */ RString error; - RageSurface *pImg = RageSurfaceUtils::LoadFile( actualID.filename, error ); + RageSurface *pImg= NULL; + if(actualID.filename == TEXTUREMAN->GetScreenTextureID().filename) + { + pImg= TEXTUREMAN->GetScreenSurface(); + } + else + { + pImg= RageSurfaceUtils::LoadFile(actualID.filename, error); + } /* Tolerate corrupt/unknown images. */ if( pImg == NULL ) @@ -122,7 +130,7 @@ void RageBitmapTexture::Create() m_iSourceWidth = pImg->w; m_iSourceHeight = pImg->h; - /* in-game imsage dimensions are the same as the source graphic */ + /* in-game image dimensions are the same as the source graphic */ m_iImageWidth = m_iSourceWidth; m_iImageHeight = m_iSourceHeight; diff --git a/src/RageTexture.cpp b/src/RageTexture.cpp index 944f54c180..88d17d97d2 100644 --- a/src/RageTexture.cpp +++ b/src/RageTexture.cpp @@ -84,6 +84,11 @@ public: lua_pushnumber(L, p->GetNumFrames()); return 1; } + static int Reload(T* p, lua_State* L) + { + p->Reload(); + return 0; + } LunaRageTexture() { @@ -92,6 +97,7 @@ public: ADD_METHOD( rate ); ADD_METHOD( GetTextureCoordRect ); ADD_METHOD( GetNumFrames ); + ADD_METHOD( Reload ); } }; diff --git a/src/RageTextureManager.cpp b/src/RageTextureManager.cpp index 5e66e33275..51134de06b 100644 --- a/src/RageTextureManager.cpp +++ b/src/RageTextureManager.cpp @@ -100,6 +100,17 @@ RageTextureID RageTextureManager::GetDefaultTextureID() return RageTextureID( g_sDefaultTextureName ); } +static const RString g_ScreenTextureName = "__screen__"; +RageTextureID RageTextureManager::GetScreenTextureID() +{ + return RageTextureID(g_ScreenTextureName); +} + +RageSurface* RageTextureManager::GetScreenSurface() +{ + return DISPLAY->CreateScreenshot(); +} + class RageTexture_Default: public RageTexture { public: @@ -141,11 +152,19 @@ RageTexture* RageTextureManager::LoadTextureInternal( RageTextureID ID ) RageTexture* pTexture; if( ID.filename == g_sDefaultTextureName ) + { pTexture = new RageTexture_Default; - else if( sExt == "ogv" || sExt == "avi" || sExt == "mpg" || sExt == "mpeg" || sExt == "mp4" || sExt == "mkv" || sExt == "mov" || sExt == "flv" || sExt == "f4v") + } + else if(sExt == "ogv" || sExt == "avi" || sExt == "mpg" || + sExt == "mpeg" || sExt == "mp4" || sExt == "mkv" || sExt == "mov" || + sExt == "flv" || sExt == "f4v") + { pTexture = RageMovieTexture::Create( ID ); + } else + { pTexture = new RageBitmapTexture( ID ); + } m_mapPathToTexture[ID] = pTexture; diff --git a/src/RageTextureManager.h b/src/RageTextureManager.h index dd41149834..8ce1ae8e1c 100644 --- a/src/RageTextureManager.h +++ b/src/RageTextureManager.h @@ -4,6 +4,7 @@ #define RAGE_TEXTURE_MANAGER_H #include "RageTexture.h" +#include "RageSurface.h" struct RageTextureManagerPrefs { @@ -81,6 +82,8 @@ public: bool GetOddDimensionWarning() const { return m_iNoWarnAboutOddDimensions == 0; } RageTextureID GetDefaultTextureID(); + RageTextureID GetScreenTextureID(); + RageSurface* GetScreenSurface(); private: void DeleteTexture( RageTexture *t ); diff --git a/src/Screen.cpp b/src/Screen.cpp index 3568fa0f9d..1100cdb350 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -268,6 +268,11 @@ RString Screen::GetNextScreenName() const return NEXT_SCREEN; } +void Screen::SetNextScreenName(RString const& name) +{ + m_sNextScreen= name; +} + RString Screen::GetPrevScreen() const { if( !m_sPrevScreen.empty() ) @@ -403,6 +408,7 @@ class LunaScreen: public Luna { public: static int GetNextScreenName( T* p, lua_State *L ) { lua_pushstring(L, p->GetNextScreenName() ); return 1; } + static int SetNextScreenName( T* p, lua_State *L ) { p->SetNextScreenName(SArg(1)); return 0; } static int GetPrevScreenName( T* p, lua_State *L ) { lua_pushstring(L, p->GetPrevScreen() ); return 1; } static int lockinput( T* p, lua_State *L ) { p->SetLockInputSecs(FArg(1)); return 0; } DEFINE_METHOD( GetScreenType, GetScreenType() ) @@ -438,6 +444,7 @@ public: LunaScreen() { ADD_METHOD( GetNextScreenName ); + ADD_METHOD( SetNextScreenName ); ADD_METHOD( GetPrevScreenName ); ADD_METHOD( PostScreenMessage ); ADD_METHOD( lockinput ); diff --git a/src/Screen.h b/src/Screen.h index 0de9447f06..7c5d56b02b 100644 --- a/src/Screen.h +++ b/src/Screen.h @@ -123,6 +123,7 @@ protected: public: RString GetNextScreenName() const; RString GetPrevScreen() const; + void SetNextScreenName(RString const& name); bool PassInputToLua(const InputEventPlus& input); void AddInputCallbackFromStack(lua_State* L);