From 197e24a74606e7ebba97d8aa6998ba9a9622d234 Mon Sep 17 00:00:00 2001 From: Joseph Davies Date: Thu, 16 Jun 2011 22:05:49 -0700 Subject: [PATCH] Add functions to load a specified resource from the plClientResMgr onto a plate. --- .../Plasma/PubUtilLib/plPipeline/plPlates.cpp | 29 +++++++++++++++++++ .../Plasma/PubUtilLib/plPipeline/plPlates.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp index 58b6a0aa..3090e8c6 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp @@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plPlates.h" #include "../plJPEG/plJPEG.h" +#include "../plGImage/plPNG.h" #include "../plGImage/plMipmap.h" #include "../plSurface/plLayer.h" #include "../plSurface/hsGMaterial.h" @@ -59,6 +60,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsGDeviceRef.h" #include "hsResMgr.h" #include "plPipeDebugFlags.h" +#include "../plClientResMgr/plClientResMgr.h" // A bit of a hack so that we will have the correct instance in the SceneViewer @@ -542,6 +544,33 @@ void plPlate::ReloadFromJPEGResource( const char *resName, UInt32 colorKey ) } } +void plPlate::CreateFromResourceDat(const char *resName) +{ + if (resName) + { + plMipmap* resTexture = TRACKED_NEW plMipmap; + resTexture->CopyFrom(plClientResMgr::Instance().getResource(resName)); + + char keyName[128]; + sprintf( keyName, "PlateResource#%d", fMagicUniqueKeyInt++ ); + hsgResMgr::ResMgr()->NewKey(keyName, resTexture, plLocation::kGlobalFixedLoc); + CreateMaterial(resTexture->GetWidth(), resTexture->GetHeight(), true, resTexture); + } + else + { + // Null resource request - Create a blank Material instead + CreateMaterial(32, 32, true); + } +} + +void plPlate::ReloadFromResourceDat(const char *resName) +{ + if (resName) + { + fMipmap->CopyFrom(plClientResMgr::Instance().getResource(resName)); + } +} + //// ILink /////////////////////////////////////////////////////////////////// // Links a plate into a plate list, but also sorts by decreasing depth, // so the plate won't actually necessarily be added after the pointer diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h index 1c0819ff..c3d2bb02 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h @@ -147,6 +147,8 @@ class plPlate void ReloadFromResource( const char *resName, UInt32 colorKey = 0x00ff00ff ); void CreateFromJPEGResource( const char *resName, UInt32 colorKey = 0x00ff00ff ); void ReloadFromJPEGResource( const char *resName, UInt32 colorKey = 0x00ff00ff ); + void CreateFromResourceDat( const char *resName ); + void ReloadFromResourceDat( const char *resName ); }; //// plGraphPlate Class Definition ///////////////////////////////////////////