From 508e431a99ac6d2281ec667b5e3733492b9d66ac 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/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 +- 10 files changed, 70 insertions(+), 71 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp index a97c8f59..a4bb21b9 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp @@ -54,6 +54,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" @@ -774,6 +775,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/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp index 54f9ba15..0b037035 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp @@ -66,8 +66,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 @@ -84,13 +84,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); @@ -208,7 +208,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); @@ -225,7 +225,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/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp index e3a25e8f..594198f9 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp @@ -444,16 +444,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(); @@ -554,7 +554,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/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h index 4f8e8699..6f853ecf 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h @@ -142,27 +142,27 @@ protected: 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; @@ -195,7 +195,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 ); @@ -225,11 +225,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/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp index 8215a59f..bc97a01d 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp @@ -251,7 +251,7 @@ void plInputInterfaceMgr::ResetClickableState() void plInputInterfaceMgr::IUpdateCursor( Int32 newCursor ) { - int mouseCursorResID; + char* mouseCursorResID; fCurrentCursor = newCursor; diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp index 6350c354..471f7be1 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp @@ -56,8 +56,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" @@ -97,7 +95,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); @@ -159,7 +157,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/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp index 3090e8c6..b54e16c1 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp @@ -311,7 +311,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 @@ -390,7 +390,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; @@ -544,7 +544,7 @@ void plPlate::ReloadFromJPEGResource( const char *resName, UInt32 colorKey ) } } -void plPlate::CreateFromResourceDat(const char *resName) +void plPlate::CreateFromResource(const char *resName) { if (resName) { @@ -563,7 +563,7 @@ void plPlate::CreateFromResourceDat(const char *resName) } } -void plPlate::ReloadFromResourceDat(const char *resName) +void plPlate::ReloadFromResource(const char *resName) { if (resName) { diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h index c3d2bb02..1fb12137 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h @@ -143,12 +143,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/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp index a72a41c2..8329dd3f 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp @@ -66,26 +66,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, @@ -100,10 +84,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; @@ -245,9 +242,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/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h index 8689f6df..f25992d1 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h @@ -196,7 +196,7 @@ class plProgressMgr private: static plProgressMgr *fManager; - static int fImageRotation[]; + static char* fImageRotation[]; static int fStaticTextIDs[]; protected: @@ -229,7 +229,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 ) { }