This commit is contained in:
parent
6e15a583c0
commit
d4b15b57a2
7 changed files with 97 additions and 46 deletions
|
@ -223,7 +223,8 @@ gui_src := gbubbles \
|
|||
greadout \
|
||||
gsprite \
|
||||
gtextbox \
|
||||
gui
|
||||
gui \
|
||||
pointer
|
||||
|
||||
jellfish_src := jellfish
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -58,6 +58,10 @@
|
|||
#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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;i<NUM_SHOP_ITEM_IDS;i++)
|
||||
{
|
||||
if(i==m_currentlySelectedItem)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(i%SHOP_ICON_ITEMS_PER_ROW==SHOP_ICON_ITEMS_PER_ROW-1)
|
||||
{
|
||||
x=SHOP_ICON_XBASE;
|
||||
y+=SHOP_ICON_Y_GAP;
|
||||
}
|
||||
else
|
||||
{
|
||||
x+=gap;
|
||||
}
|
||||
}
|
||||
|
||||
DVECTOR ret={x-5,y+30};
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
|
@ -309,6 +351,8 @@ void CShopScene::think(int _frames)
|
|||
{
|
||||
int pad;
|
||||
|
||||
m_pointerIcon->think(_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))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue