From d4b15b57a22280c040709b97d3baa525395f20fc Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 18 Jun 2001 22:58:36 +0000 Subject: [PATCH] --- makefile.gaz | 3 +- source/gui/pointer.cpp | 2 +- source/map/map.cpp | 63 ++++++++----------- source/map/map.h | 5 +- source/shop/shop.cpp | 54 ++++++++++++++-- source/shop/shop.h | 8 +++ .../spongebob project/spongebob project.dsp | 8 +++ 7 files changed, 97 insertions(+), 46 deletions(-) diff --git a/makefile.gaz b/makefile.gaz index 492eec5e6..403685330 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -223,7 +223,8 @@ gui_src := gbubbles \ greadout \ gsprite \ gtextbox \ - gui + gui \ + pointer jellfish_src := jellfish diff --git a/source/gui/pointer.cpp b/source/gui/pointer.cpp index 1661976cc..5ce00a96e 100644 --- a/source/gui/pointer.cpp +++ b/source/gui/pointer.cpp @@ -136,7 +136,7 @@ void CPointerIcon::render() fh=sb->getFrameHeader(FRM__MAPPOINTER); x=m_pointerPos.vx-(fh->W/2); y=m_pointerPos.vy-(fh->H/2); - ft4=sb->printFT4(fh,x,y,0,0,9); + ft4=sb->printFT4(fh,x,y,0,0,0); if(!m_pointerArrivedAtTarget) { setSemiTrans(ft4,true); diff --git a/source/map/map.cpp b/source/map/map.cpp index 3de06c287..cd86fd267 100644 --- a/source/map/map.cpp +++ b/source/map/map.cpp @@ -58,7 +58,11 @@ #include "sound\sound.h" #endif +#ifndef __GUI_POINTER_H__ +#include "gui\pointer.h" +#endif + /* Std Lib ------- */ @@ -195,8 +199,9 @@ void CMapScene::init() m_currentChapterSelection=s_chapterToStartOn; generateMapScreenImage(); m_currentLevelSelection=s_levelToStartOn; - m_pointerPos=getPointerTargetPosition(); - m_pointerArrivedAtTarget=true; + + m_pointerIcon=new ("MapPointer") CPointerIcon(); + m_pointerIcon->snapToTarget(getPointerTargetPosition()); SetScreenImage((u8*)m_screenImage); @@ -214,6 +219,7 @@ void CMapScene::init() void CMapScene::shutdown() { ClearScreenImage(); + delete m_pointerIcon; MemFree(m_screenImage); m_font->dump(); delete m_font; } @@ -232,6 +238,8 @@ void CMapScene::render() int i; char buf[100]; + m_pointerIcon->render(); + sb=CGameScene::getSpriteBank(); level=&s_mapLevelData[m_currentChapterSelection][0]; @@ -271,7 +279,6 @@ void CMapScene::render() level++; } - renderPointer(); renderInstructions(); @@ -283,28 +290,6 @@ m_font->print(25,25,buf); } -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CMapScene::renderPointer() -{ - SpriteBank *sb; - sFrameHdr *fh; - POLY_FT4 *ft4; - - sb=CGameScene::getSpriteBank(); - fh=sb->getFrameHeader(FRM__MAPPOINTER); - ft4=sb->printFT4(fh,m_pointerPos.vx-(fh->W/2),m_pointerPos.vy-(fh->H/2),0,0,9); - if(!m_pointerArrivedAtTarget) - { - setSemiTrans(ft4,true); - } -} - - /*---------------------------------------------------------------------- Function: Purpose: @@ -428,6 +413,7 @@ void CMapScene::think(int _frames) if(--m_currentLevelSelection<0)m_currentLevelSelection=MAP_NUM_LEVELS_PER_CHAPTER-1; } while(!isLevelOpen(m_currentChapterSelection,m_currentLevelSelection)); + m_pointerIcon->setTarget(getPointerTargetPosition()); } else if(pad&PAD_RIGHT) { @@ -436,22 +422,24 @@ void CMapScene::think(int _frames) if(++m_currentLevelSelection>=MAP_NUM_LEVELS_PER_CHAPTER)m_currentLevelSelection=0; } while(!isLevelOpen(m_currentChapterSelection,m_currentLevelSelection)); + m_pointerIcon->setTarget(getPointerTargetPosition()); } if(lastLevel!=m_currentLevelSelection) { CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__MOVE_CURSOR); - m_pointerArrivedAtTarget=false; - m_pointerSin=0; +// m_pointerArrivedAtTarget=false; +// m_pointerSin=0; } // Calc where the pointer should be - if(m_pointerArrivedAtTarget) - { - m_pointerSin=(m_pointerSin+(_frames*70))&4095; - } - m_pointerTarget=getPointerTargetPosition(); +// if(m_pointerArrivedAtTarget) +// { +// m_pointerSin=(m_pointerSin+(_frames*70))&4095; +// } +// m_pointerIcon->setTarget(getPointerTargetPosition()); // Move the pointer + /* for(int i=0;i<_frames;i++) { int delta; @@ -488,8 +476,10 @@ void CMapScene::think(int _frames) m_pointerArrivedAtTarget=true; } } + */ + m_pointerIcon->think(_frames); - if(m_pointerArrivedAtTarget&& + if(m_pointerIcon->canPointerSelect()&& pad&PAD_CROSS) { CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__OK); @@ -535,8 +525,9 @@ void CMapScene::generateMapScreenImage() } } - m_pointerPos=getPointerTargetPosition(); - m_pointerArrivedAtTarget=true; + m_pointerIcon->snapToTarget(getPointerTargetPosition()); +// m_pointerPos=getPointerTargetPosition(); +// m_pointerArrivedAtTarget=true; } @@ -578,7 +569,7 @@ DVECTOR CMapScene::getPointerTargetPosition() pos=s_mapLevelPositions[m_currentLevelSelection]; pos.vx+=(MAP_LEVEL_WIDTH/2); - pos.vy+=MAP_LEVEL_HEIGHT;//+(msin(m_pointerSin)*4>>12); + pos.vy+=MAP_LEVEL_HEIGHT; return pos; } diff --git a/source/map/map.h b/source/map/map.h index d0ae624a7..35ab1e5d8 100644 --- a/source/map/map.h +++ b/source/map/map.h @@ -104,10 +104,7 @@ private: int m_currentChapterSelection; int m_currentLevelSelection; - DVECTOR m_pointerPos; - DVECTOR m_pointerTarget; - int m_pointerSin; - int m_pointerArrivedAtTarget; + class CPointerIcon *m_pointerIcon; static sMapLevelData s_mapLevelData[MAP_NUM_CHAPTERS][MAP_NUM_LEVELS_PER_CHAPTER]; static DVECTOR s_mapLevelPositions[MAP_NUM_LEVELS_PER_CHAPTER]; diff --git a/source/shop/shop.cpp b/source/shop/shop.cpp index 8d25284dd..776273198 100644 --- a/source/shop/shop.cpp +++ b/source/shop/shop.cpp @@ -78,6 +78,10 @@ #include "backend\party.h" #endif +#ifndef __GUI_POINTER_H__ +#include "gui\pointer.h" +#endif + /* Std Lib ------- */ @@ -205,6 +209,9 @@ void CShopScene::init() m_state=SHOP_STATE__FADING_IN; m_mainUiYOffset=SHOP_STATE__SELECT_ITEM; + + m_pointerIcon=new ("MapPointer") CPointerIcon(); + m_pointerIcon->snapToTarget(getPointerTarget()); } @@ -216,6 +223,8 @@ void CShopScene::init() ---------------------------------------------------------------------- */ void CShopScene::shutdown() { + delete m_pointerIcon; + m_guiCannotAffordFrame->shutdown(); m_guiConfirmPurchaseFrame->shutdown(); m_guiFrame->shutdown(); @@ -259,9 +268,7 @@ void CShopScene::render() { if(m_state==SHOP_STATE__SELECT_ITEM) { - SpriteBank *sb=CGameScene::getSpriteBank(); - sFrameHdr *fh=sb->getFrameHeader(FRM__MAPPOINTER); - sb->printFT4(fh,x-fh->W,y+30,0,0,5); + m_pointerIcon->render(); } // Flash selected item @@ -289,6 +296,41 @@ void CShopScene::render() } } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +DVECTOR CShopScene::getPointerTarget() +{ + int i,x,y,gap; + + x=SHOP_ICON_XBASE; + y=SHOP_ICON_YBASE; + gap=SHOP_ICON_WIDTH/(SHOP_ICON_ITEMS_PER_ROW-1); + + for(i=0;ithink(_frames); + pad=PadGetDown(0); if(pad&PAD_LEFT) { @@ -319,6 +363,7 @@ void CShopScene::think(int _frames) } m_flashSin=0; playSound(CSoundMediator::SFX_FRONT_END__MOVE_CURSOR); + m_pointerIcon->setTarget(getPointerTarget()); } else if(pad&PAD_RIGHT) { @@ -329,8 +374,9 @@ void CShopScene::think(int _frames) } m_flashSin=0; playSound(CSoundMediator::SFX_FRONT_END__MOVE_CURSOR); + m_pointerIcon->setTarget(getPointerTarget()); } - else if(pad&PAD_CROSS) + else if(m_pointerIcon->canPointerSelect()&&pad&PAD_CROSS) { if(isItemAvailableToBuy(m_currentlySelectedItem)) { diff --git a/source/shop/shop.h b/source/shop/shop.h index cacd8b657..38ac102ae 100644 --- a/source/shop/shop.h +++ b/source/shop/shop.h @@ -22,6 +22,10 @@ #include "system\gstate.h" #endif +#ifndef _GLOBAL_HEADER_ +#include "system\global.h" // Doh.. just for DVECTOR :/ +#endif + /* Std Lib ------- */ @@ -62,6 +66,7 @@ public: private: void renderUi(); + DVECTOR getPointerTarget(); int isItemAvailableToBuy(int _itemNumber); void playSound(int _sfxId); @@ -158,6 +163,9 @@ private: }; int m_mainUiYOffset; + + class CPointerIcon *m_pointerIcon; + }; diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index 8164bfe3b..a3da5a8be 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -923,6 +923,14 @@ SOURCE=..\..\..\source\gui\gui.cpp SOURCE=..\..\..\source\gui\gui.h # End Source File +# Begin Source File + +SOURCE=..\..\..\source\gui\pointer.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\gui\pointer.h +# End Source File # End Group # Begin Group "hazard"