From 3027e0605c2c5e509d7e7a46592a61c188955c92 Mon Sep 17 00:00:00 2001 From: Joseph Davies Date: Thu, 16 Jun 2011 22:16:50 -0700 Subject: [PATCH] Refactor plPlates CreateResource function names. Add support for external resource Cursors. Add support for external resource Progress Linking Book. Add support for external resource Voice Chat indicators. --- Sources/Plasma/Apps/plClient/CMakeLists.txt | 1 + Sources/Plasma/Apps/plClient/winmain.cpp | 4 ++ .../Plasma/PubUtilLib/plAudio/plVoiceChat.cpp | 12 ++--- .../PubUtilLib/plInputCore/plInputDevice.cpp | 8 ++-- .../PubUtilLib/plInputCore/plInputDevice.h | 48 +++++++++---------- .../plInputCore/plInputInterfaceMgr.cpp | 2 +- .../PubUtilLib/plPipeline/plDTProgressMgr.cpp | 6 +-- .../Plasma/PubUtilLib/plPipeline/plPlates.cpp | 8 ++-- .../Plasma/PubUtilLib/plPipeline/plPlates.h | 8 ++-- .../plProgressMgr/plProgressMgr.cpp | 41 ++++++++-------- .../PubUtilLib/plProgressMgr/plProgressMgr.h | 4 +- 11 files changed, 71 insertions(+), 71 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/CMakeLists.txt b/Sources/Plasma/Apps/plClient/CMakeLists.txt index 8398b41e..ca500991 100644 --- a/Sources/Plasma/Apps/plClient/CMakeLists.txt +++ b/Sources/Plasma/Apps/plClient/CMakeLists.txt @@ -123,6 +123,7 @@ target_link_libraries(plClient plAudible) target_link_libraries(plClient plAudio) target_link_libraries(plClient plAudioCore) target_link_libraries(plClient plAvatar) +target_link_libraries(plClient plClientResMgr) #target_link_libraries(plClient plClientKey) target_link_libraries(plClient plCompression) target_link_libraries(plClient plContainer) diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 6a0799b8..77c052f1 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -39,6 +39,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsStream.h" #include "hsUtils.h" #include "plClient.h" +#include "plClientResMgr/plClientResMgr.h" #include "plNetClient/plNetClientMgr.h" #include "plNetClient/plNetLinkingMgr.h" #include "plInputCore/plInputManager.h" @@ -754,6 +755,9 @@ bool InitClient( HWND hWnd ) plResManager *resMgr = TRACKED_NEW plResManager; resMgr->SetDataPath("dat"); hsgResMgr::Init(resMgr); + + plClientResMgr::Instance().ILoadResources("resource.dat"); + gClient = TRACKED_NEW plClient; if( gClient == nil ) return false; diff --git a/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp b/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp index 3d5f7d15..c99190ef 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp @@ -50,8 +50,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plPipeline/plDebugText.h" #include "plStatusLog/plStatusLog.h" -#define MICROPHONE 121 -#define TALKING 122 +#define MICROPHONE "ui_microphone.png" +#define TALKING "ui_speaker.png" #define NUM_CHANNELS 1 #define VOICE_STOP_MS 2000 #define MAX_DATA_SIZE 1024 * 4 // 4 KB @@ -68,13 +68,13 @@ hsBool plVoicePlayer::fEnabled = true; plVoiceRecorder::plVoiceRecorder() { plPlateManager::Instance().CreatePlate( &fDisabledIcon ); - fDisabledIcon->CreateFromResource( MAKEINTRESOURCE( MICROPHONE ) ); + fDisabledIcon->CreateFromResource( MICROPHONE ); fDisabledIcon->SetPosition(-0.90, -0.90); fDisabledIcon->SetSize(0.0675, 0.09); fDisabledIcon->SetVisible(false); plPlateManager::Instance().CreatePlate( &fTalkIcon ); - fTalkIcon->CreateFromResource( MAKEINTRESOURCE( TALKING ) ); + fTalkIcon->CreateFromResource( TALKING ); fTalkIcon->SetPosition(-0.9,-0.9); fTalkIcon->SetSize(0.0675, 0.09); fTalkIcon->SetVisible(false); @@ -192,7 +192,7 @@ void plVoiceRecorder::DrawDisabledIcon(hsBool b) plPlateManager::Instance().CreatePlate( &fDisabledIcon ); if (fDisabledIcon) { - fDisabledIcon->CreateFromResource( MAKEINTRESOURCE( MICROPHONE ) ); + fDisabledIcon->CreateFromResource( MICROPHONE ); fDisabledIcon->SetPosition(-0.90, -0.90); fDisabledIcon->SetSize(0.0675, 0.09); fDisabledIcon->SetVisible(false); @@ -209,7 +209,7 @@ void plVoiceRecorder::DrawTalkIcon(hsBool b) { plPlateManager::Instance().CreatePlate( &fTalkIcon ); if (fTalkIcon) - { fTalkIcon->CreateFromResource( MAKEINTRESOURCE( TALKING ) ); + { fTalkIcon->CreateFromResource( TALKING ); fTalkIcon->SetPosition(-0.9,-0.9); fTalkIcon->SetSize(0.0675, 0.09); fTalkIcon->SetVisible(false); diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp index 99bf7c9e..6f467b35 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp @@ -296,16 +296,16 @@ void plMouseDevice::SetDisplayResolution(hsScalar Width, hsScalar Height) IUpdateCursorSize(); } -void plMouseDevice::CreateCursor( int cursor ) +void plMouseDevice::CreateCursor( char* cursor ) { if( fCursor == nil ) { plPlateManager::Instance().CreatePlate( &fCursor ); - fCursor->CreateFromResource( MAKEINTRESOURCE( cursor ) ); + fCursor->CreateFromResource(cursor); } else { - fCursor->ReloadFromResource( MAKEINTRESOURCE( cursor ) ); + fCursor->ReloadFromResource(cursor); } fCursor->SetPosition( 0, 0, 0 ); IUpdateCursorSize(); @@ -406,7 +406,7 @@ void plMouseDevice::ShowCursor(hsBool override) fInstance->fCursor->SetVisible( true ); } -void plMouseDevice::NewCursor(int cursor) +void plMouseDevice::NewCursor(char* cursor) { fInstance->fCursorID = cursor; fInstance->CreateCursor(cursor); diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h index 3451ce7b..2197cf8a 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h @@ -118,27 +118,27 @@ public: class plPlate; -#define CURSOR_UP IDB_CURSOR_UP -#define CURSOR_DOWN IDB_CURSOR_DOWN -#define CURSOR_RIGHT IDB_CURSOR_RIGHT -#define CURSOR_LEFT IDB_CURSOR_LEFT -#define CURSOR_OPEN IDB_CURSOR_OPEN -#define CURSOR_GRAB IDB_CURSOR_GRAB -#define CURSOR_CLICKED IDB_CURSOR_CLICKED -#define CURSOR_POISED IDB_CURSOR_POISED -#define CURSOR_ARROW IDB_CURSOR_ARROW -#define CURSOR_4WAY_OPEN IDB_CURSOR_4WAYOPEN -#define CURSOR_4WAY_CLOSED IDB_CURSOR_4WAYCLOSED -#define CURSOR_UPDOWN_CLOSED IDB_CURSOR_UPDOWNCLOSED -#define CURSOR_UPDOWN_OPEN IDB_CURSOR_UPDOWNOPEN -#define CURSOR_LEFTRIGHT_CLOSED IDB_CURSOR_LEFTRIGHTCLOSED -#define CURSOR_LEFTRIGHT_OPEN IDB_CURSOR_LEFTRIGHTOPEN -#define CURSOR_OFFER_BOOK IDB_CURSOR_BOOK -#define CURSOR_OFFER_BOOK_HI IDB_CURSOR_BOOK_HIGHLIGHT -#define CURSOR_OFFER_BOOK_CLICKED IDB_CURSOR_BOOK_CLICKED -#define CURSOR_CLICK_DISABLED IDB_CURSOR_DISABLED -#define CURSOR_HAND IDB_CURSOR_HAND -#define CURSOR_UPWARD IDB_CURSOR_UPWARD +#define CURSOR_UP "cursor_up.png" +#define CURSOR_DOWN "cursor_down.png" +#define CURSOR_RIGHT "cursor_right.png" +#define CURSOR_LEFT "cursor_left.png" +#define CURSOR_OPEN "cursor_open.png" +#define CURSOR_GRAB "cursor_grab.png" +#define CURSOR_CLICKED "cursor_clicked.png" +#define CURSOR_POISED "cursor_poised.png" +#define CURSOR_ARROW "cursor_up.png" +#define CURSOR_4WAY_OPEN "bitmap1.png" +#define CURSOR_4WAY_CLOSED "bitmap3.png" +#define CURSOR_UPDOWN_CLOSED "bmp00001.png" +#define CURSOR_UPDOWN_OPEN "bitmap2.png" +#define CURSOR_LEFTRIGHT_CLOSED "bmp00003.png" +#define CURSOR_LEFTRIGHT_OPEN "bmp00002.png" +#define CURSOR_OFFER_BOOK "book.png" +#define CURSOR_OFFER_BOOK_HI "book_hig.png" +#define CURSOR_OFFER_BOOK_CLICKED "book_cli.png" +#define CURSOR_CLICK_DISABLED "cursor_disabled.png" +#define CURSOR_HAND "cursor_up.png" +#define CURSOR_UPWARD "cursor_upward.png" class plInputEventMsg; @@ -171,7 +171,7 @@ public: static void SetMsgAlways(bool b) { plMouseDevice::bMsgAlways = b; } static void ShowCursor(hsBool override = false); - static void NewCursor(int cursor); + static void NewCursor(char* cursor); static void HideCursor(hsBool override = false); static bool GetHideCursor() { return plMouseDevice::bCursorHidden; } static void SetCursorOpacity( hsScalar opacity = 1.f ); @@ -201,11 +201,11 @@ protected: plPlate *fCursor; - int fCursorID; + char* fCursorID; static plMouseDevice* fInstance; static plMouseInfo fDefaultMouseControlMap[]; - void CreateCursor( int cursor ); + void CreateCursor( char* cursor ); void IUpdateCursorSize(); static bool bMsgAlways; static bool bCursorHidden; diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp index f07e81b4..72e85b6f 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp @@ -235,7 +235,7 @@ void plInputInterfaceMgr::ResetClickableState() void plInputInterfaceMgr::IUpdateCursor( Int32 newCursor ) { - int mouseCursorResID; + char* mouseCursorResID; fCurrentCursor = newCursor; diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp index d98c3e43..0ee95f9a 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp @@ -40,8 +40,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plDebugText.h" #include "plPlates.h" -#include "../../Apps/plClient/res/resource.h" - #include "hsTimer.h" @@ -81,7 +79,7 @@ void plDTProgressMgr::Activate() { plPlateManager::Instance().CreatePlate( &fActivePlate ); - fActivePlate->CreateFromJPEGResource( MAKEINTRESOURCE( plProgressMgr::GetLoadingFrameID(fCurrentImage) ), 0 ); + fActivePlate->CreateFromResource(plProgressMgr::GetLoadingFrameID(fCurrentImage)); fActivePlate->SetVisible(true); fActivePlate->SetOpacity(1.0f); fActivePlate->SetSize(0.6, 0.6, true); @@ -143,7 +141,7 @@ void plDTProgressMgr::Draw( plPipeline *p ) fLastDraw = currentMs; - fActivePlate->ReloadFromJPEGResource(MAKEINTRESOURCE(plProgressMgr::GetInstance()->GetLoadingFrameID(fCurrentImage)), 0); + fActivePlate->ReloadFromResource(plProgressMgr::GetLoadingFrameID(fCurrentImage)); fActivePlate->SetVisible(true); fActivePlate->SetOpacity(1.0f); fActivePlate->SetSize(0.6, 0.6, true); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp index c4952ea0..26564ccf 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp @@ -295,7 +295,7 @@ void plPlate::ISetResourceAlphas(UInt32 colorKey) } } -void plPlate::CreateFromResource( const char *resName, UInt32 colorKey ) +void plPlate::CreateFromBMPResource( const char *resName, UInt32 colorKey ) { /* Someday the following might actually work, once we get a plugin that @@ -374,7 +374,7 @@ void plPlate::CreateFromResource( const char *resName, UInt32 colorKey ) //// ReloadFromResource ////////////////////////////////////////////////////// // Creates a plate's material from a resource of the given name. -void plPlate::ReloadFromResource( const char *resName, UInt32 colorKey ) +void plPlate::ReloadFromBMPResource( const char *resName, UInt32 colorKey ) { UInt32 width, height; @@ -528,7 +528,7 @@ void plPlate::ReloadFromJPEGResource( const char *resName, UInt32 colorKey ) } } -void plPlate::CreateFromResourceDat(const char *resName) +void plPlate::CreateFromResource(const char *resName) { if (resName) { @@ -547,7 +547,7 @@ void plPlate::CreateFromResourceDat(const char *resName) } } -void plPlate::ReloadFromResourceDat(const char *resName) +void plPlate::ReloadFromResource(const char *resName) { if (resName) { diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h b/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h index cde53ad9..9e165a87 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h +++ b/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h @@ -127,12 +127,12 @@ class plPlate void SetSize( hsScalar width, hsScalar height, bool adjustByAspectRatio = false ); plMipmap *CreateMaterial( UInt32 width, UInt32 height, hsBool withAlpha, plMipmap* texture = NULL ); - void CreateFromResource( const char *resName, UInt32 colorKey = 0x00ff00ff ); - void ReloadFromResource( const char *resName, UInt32 colorKey = 0x00ff00ff ); + void CreateFromBMPResource( const char *resName, UInt32 colorKey = 0x00ff00ff ); + void ReloadFromBMPResource( 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 ); + void CreateFromResource( const char *resName ); + void ReloadFromResource( const char *resName ); }; //// plGraphPlate Class Definition /////////////////////////////////////////// diff --git a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp index eba00d78..0027509a 100644 --- a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp @@ -50,26 +50,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com plProgressMgr *plProgressMgr::fManager = nil; -int plProgressMgr::fImageRotation[] = { - IDR_LOADING_01, - IDR_LOADING_18, - IDR_LOADING_17, - IDR_LOADING_16, - IDR_LOADING_15, - IDR_LOADING_14, - IDR_LOADING_13, - IDR_LOADING_12, - IDR_LOADING_11, - IDR_LOADING_10, - IDR_LOADING_09, - IDR_LOADING_08, - IDR_LOADING_07, - IDR_LOADING_06, - IDR_LOADING_05, - IDR_LOADING_04, - IDR_LOADING_03, - IDR_LOADING_02 -}; +#define LOADING_RES "xLoading_Linking.%02d.png" +#define LOADING_RES_COUNT 18 + +char* plProgressMgr::fImageRotation[LOADING_RES_COUNT]; int plProgressMgr::fStaticTextIDs[] = { 0, @@ -84,10 +68,23 @@ plProgressMgr::plProgressMgr() fManager = this; fCallbackProc = nil; fCurrentStaticText = kNone; + + // Fill array with pre-computed loading frame IDs + for (int i=0; i < LOADING_RES_COUNT; i++) + { + char* frameID = TRACKED_NEW char[128]; + sprintf(frameID, LOADING_RES, i); + fImageRotation[i] = frameID; + } } plProgressMgr::~plProgressMgr() { + for (int i=0; i < LOADING_RES_COUNT; i++) + { + delete fImageRotation[i]; + } + while( fOperations != nil ) delete fOperations; fManager = nil; @@ -229,9 +226,9 @@ void plProgressMgr::CancelAllOps( void ) fCurrentStaticText = kNone; } -int plProgressMgr::GetLoadingFrameID(int index) +char* plProgressMgr::GetLoadingFrameID(int index) { - if (index < (sizeof(fImageRotation) / sizeof(int))) + if (index < LOADING_RES_COUNT) return fImageRotation[index]; else return fImageRotation[0]; diff --git a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h index 34d526e0..e54e8c97 100644 --- a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h +++ b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h @@ -180,7 +180,7 @@ class plProgressMgr private: static plProgressMgr *fManager; - static int fImageRotation[]; + static char* fImageRotation[]; static int fStaticTextIDs[]; protected: @@ -213,7 +213,7 @@ class plProgressMgr virtual ~plProgressMgr(); static plProgressMgr* GetInstance() { return fManager; } - static int GetLoadingFrameID(int index); + static char* GetLoadingFrameID(int index); static int GetStaticTextID(StaticText staticTextType); virtual void Draw( plPipeline *p ) { }