SBSPSS/source/shop/shop.cpp

638 lines
15 KiB
C++
Raw Normal View History

2001-06-05 18:13:55 +02:00
/*=========================================================================
gameover.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "shop\shop.h"
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
#endif
#ifndef __PAD_PADS_H__
#include "pad\pads.h"
#endif
#ifndef __GFX_FADER_H__
#include "gfx\fader.h"
#endif
#ifndef _FILEIO_HEADER_
#include "fileio\fileio.h"
#endif
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
#ifndef __MATHTABLE_HEADER__
#include "utils\mathtab.h"
#endif
#ifndef __LOCALE_TEXTDBASE_H__
#include "locale\textdbase.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-06-05 21:26:14 +02:00
#ifndef __GUI_GFRAME_H__
#include "gui\gframe.h"
#endif
#ifndef __GUI_GFACTORY_H__
#include "gui\gfactory.h"
#endif
#ifndef __GUI_GTEXTBOX_H__
#include "gui\gtextbox.h"
#endif
2001-06-06 04:11:50 +02:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
#ifndef __GAME_GAMESLOT_H__
#include "game\gameslot.h"
#endif
#ifndef __MAP_MAP_H__
#include "map\map.h"
#endif
2001-06-19 00:58:36 +02:00
#ifndef __GUI_POINTER_H__
#include "gui\pointer.h"
#endif
2001-06-05 18:13:55 +02:00
/* Std Lib
------- */
/* Data
---- */
#ifndef __SPR_SHOP_H__
#include <shop.h>
#endif
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
#endif
#ifndef __STRING_ENUMS__
#include <trans.h>
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
2001-07-04 18:27:35 +02:00
// 125 tokens in total
2001-06-05 18:13:55 +02:00
CShopScene::SHOPITEM CShopScene::s_shopItems[NUM_SHOP_ITEM_IDS]=
{
2001-07-13 17:42:58 +02:00
{ 5, FRM_TEDDY }, // SHOPITEM_TEDDY
{ 8, FRM_SARNIE }, // SHOPITEM_SARNIE
{ 10, FRM_CUPCAKE }, // SHOPITEM_CUPCAKE
{ 12, FRM_PREZZIE }, // SHOPITEM_PREZZIE
{ 16, FRM_JELLY2 }, // SHOPITEM_JELLY2
{ 20, FRM_CAKE }, // SHOPITEM_CAKE
{ 24, FRM_BLOWER }, // SHOPITEM_BLOWER
{ 30, FRM_PARTYHAT }, // SHOPITEM_PARTYHAT
2001-06-05 18:13:55 +02:00
};
2001-06-06 04:11:50 +02:00
xmPlayingId s_playId;
2001-06-05 18:13:55 +02:00
CShopScene ShopScene;
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-06-06 04:11:50 +02:00
int fx=76;
int fy=80;
int fw=200;
int fh=20;
2001-06-05 18:13:55 +02:00
void CShopScene::init()
{
2001-07-28 18:45:46 +02:00
m_image=LoadPakScreen(BACKDROP_SHOP_GFX);
2001-06-05 18:13:55 +02:00
ASSERT(m_image);
SetScreenImage((u8*)m_image);
m_font=new ("shop font") ScalableFontBank();
m_font->initialise(&standardFont);
m_font->setJustification(ScalableFontBank::JUST_CENTRE);
m_spriteBank=new ("shop sprites") SpriteBank();
m_spriteBank->load(SHOP_SHOP_SPR);
2001-06-06 04:11:50 +02:00
2001-06-05 21:26:14 +02:00
// GUI Frame
2001-06-06 04:11:50 +02:00
m_guiFrame=new ("Token count frame") CGUIGroupFrame();
2001-06-05 21:26:14 +02:00
m_guiFrame->init(0);
m_guiFrame->setFlags(CGUIObject::FLAG_DRAWBORDER);
2001-06-06 04:11:50 +02:00
m_guiFrame->setObjectXYWH(SHOP_MAIN_UI_X,SHOP_MAIN_UI_Y,SHOP_MAIN_UI_W,SHOP_MAIN_UI_H);
m_guiConfirmPurchaseFrame=new ("Confirm purchase frame") CGUIControlFrame();
m_guiConfirmPurchaseFrame->init(0);
m_guiConfirmPurchaseFrame->setFlags(CGUIObject::FLAG_DRAWBORDER);
m_guiConfirmPurchaseFrame->setObjectXYWH(SHOP_QUERY_UI_X,SHOP_QUERY_UI_Y,SHOP_QUERY_UI_W,SHOP_QUERY_UI_H);
CGUIFactory::createValueButtonFrame(m_guiConfirmPurchaseFrame,
fx,fy+fh,fw,fh,
STR__NO,
&m_queryAnswer,
ANSWER_NO);
2001-07-10 21:28:28 +02:00
CGUIFactory::createValueButtonFrame(m_guiConfirmPurchaseFrame,
fx,fy,fw,fh,
STR__YES,
&m_queryAnswer,
ANSWER_YES);
2001-06-06 04:11:50 +02:00
m_guiCannotAffordFrame=new ("Cannot afford frame") CGUIControlFrame();
m_guiCannotAffordFrame->init(0);
m_guiCannotAffordFrame->setFlags(CGUIObject::FLAG_DRAWBORDER);
m_guiCannotAffordFrame->setObjectXYWH(SHOP_QUERY_UI_X,SHOP_QUERY_UI_Y,SHOP_QUERY_UI_W,SHOP_QUERY_UI_H);
CGUIFactory::createValueButtonFrame(m_guiCannotAffordFrame,
fx,fy,fw,fh,
STR__OK,
&m_queryAnswer,
ANSWER_OK);
2001-06-05 21:26:14 +02:00
2001-06-05 18:13:55 +02:00
m_readyToExit=false;
2001-06-21 00:57:27 +02:00
CFader::setFadingIn();
2001-06-05 18:13:55 +02:00
m_currentlySelectedItem=0;
m_flashSin=0;
2001-06-06 04:11:50 +02:00
s_playId=NOT_PLAYING;
m_state=SHOP_STATE__FADING_IN;
m_mainUiYOffset=SHOP_STATE__SELECT_ITEM;
2001-06-19 00:58:36 +02:00
m_pointerIcon=new ("MapPointer") CPointerIcon();
m_pointerIcon->snapToTarget(getPointerTarget());
2001-07-02 18:34:37 +02:00
CSoundMediator::setSong(CSoundMediator::SONG_SHOPSCREEN);
CSoundMediator::playSong();
2001-06-05 18:13:55 +02:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CShopScene::shutdown()
{
2001-07-02 18:34:37 +02:00
CSoundMediator::dumpSong();
2001-06-19 00:58:36 +02:00
delete m_pointerIcon;
2001-06-06 04:11:50 +02:00
m_guiCannotAffordFrame->shutdown();
m_guiConfirmPurchaseFrame->shutdown();
2001-06-05 21:26:14 +02:00
m_guiFrame->shutdown();
2001-06-05 18:13:55 +02:00
m_spriteBank->dump(); delete m_spriteBank;
m_font->dump(); delete m_font;
MemFree(m_image);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CShopScene::render()
{
SHOPITEM *shopItem;
int i,x,y,gap;
POLY_FT4 *ft4;
2001-06-06 04:11:50 +02:00
renderUi();
2001-06-05 18:13:55 +02:00
shopItem=s_shopItems;
2001-06-06 04:11:50 +02:00
x=SHOP_ICON_XBASE;
y=SHOP_ICON_YBASE;
gap=SHOP_ICON_WIDTH/(SHOP_ICON_ITEMS_PER_ROW-1);
2001-06-05 18:13:55 +02:00
for(i=0;i<NUM_SHOP_ITEM_IDS;i++)
{
// Icon
sFrameHdr *fh=m_spriteBank->getFrameHeader(shopItem->m_frame);
2001-06-06 04:11:50 +02:00
ft4=m_spriteBank->printFT4(fh,x-fh->W/2,y,0,0,5);
2001-06-05 18:13:55 +02:00
// Cursor?
if(i==m_currentlySelectedItem)
{
2001-06-06 04:11:50 +02:00
if(!CFader::isFading())
{
if(m_state==SHOP_STATE__SELECT_ITEM)
{
2001-06-19 00:58:36 +02:00
m_pointerIcon->render();
2001-06-06 04:11:50 +02:00
}
// Flash selected item
int rgb=((msin(m_flashSin)*SHOP_ICON_FLASH_COLOUR_RANGE)>>12)+SHOP_ICON_FLASH_COLOUR_BASE;
setRGB0(ft4,rgb,rgb,rgb);
}
2001-06-05 18:13:55 +02:00
}
// Darken item if already bought
2001-06-06 01:01:16 +02:00
if(!isItemAvailableToBuy(i))
2001-06-05 18:13:55 +02:00
{
2001-06-06 04:11:50 +02:00
setRGB0(ft4,SHOP_ICON_PURCHASED_RGB,SHOP_ICON_PURCHASED_RGB,SHOP_ICON_PURCHASED_RGB);
2001-06-05 18:13:55 +02:00
}
shopItem++;
2001-06-06 04:11:50 +02:00
if(i%SHOP_ICON_ITEMS_PER_ROW==SHOP_ICON_ITEMS_PER_ROW-1)
2001-06-05 18:13:55 +02:00
{
2001-06-06 04:11:50 +02:00
x=SHOP_ICON_XBASE;
y+=SHOP_ICON_Y_GAP;
2001-06-05 18:13:55 +02:00
}
else
{
x+=gap;
}
}
}
2001-06-19 00:58:36 +02:00
/*----------------------------------------------------------------------
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;
}
}
2001-06-19 16:23:01 +02:00
DVECTOR ret={x-15,y+35};
2001-06-19 00:58:36 +02:00
return ret;
}
2001-06-05 18:13:55 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CShopScene::think(int _frames)
{
2001-06-06 04:11:50 +02:00
if(m_state==SHOP_STATE__FADING_IN)
{
if(!CFader::isFading())
{
m_state=SHOP_STATE__SELECT_ITEM;
}
}
else if(m_state==SHOP_STATE__SELECT_ITEM&&!CFader::isFading())
{
int pad;
2001-06-05 18:13:55 +02:00
2001-06-19 00:58:36 +02:00
m_pointerIcon->think(_frames);
2001-06-06 04:11:50 +02:00
pad=PadGetDown(0);
if(pad&PAD_LEFT)
{
m_currentlySelectedItem--;
if(m_currentlySelectedItem<0)
{
m_currentlySelectedItem=NUM_SHOP_ITEM_IDS-1;
}
m_flashSin=0;
playSound(CSoundMediator::SFX_FRONT_END__MOVE_CURSOR);
2001-06-19 00:58:36 +02:00
m_pointerIcon->setTarget(getPointerTarget());
2001-06-06 04:11:50 +02:00
}
else if(pad&PAD_RIGHT)
{
m_currentlySelectedItem++;
if(m_currentlySelectedItem>=NUM_SHOP_ITEM_IDS)
{
m_currentlySelectedItem=0;
}
m_flashSin=0;
playSound(CSoundMediator::SFX_FRONT_END__MOVE_CURSOR);
2001-06-19 00:58:36 +02:00
m_pointerIcon->setTarget(getPointerTarget());
2001-06-06 04:11:50 +02:00
}
2001-06-19 00:58:36 +02:00
else if(m_pointerIcon->canPointerSelect()&&pad&PAD_CROSS)
2001-06-06 04:11:50 +02:00
{
if(isItemAvailableToBuy(m_currentlySelectedItem))
{
int cost,available;
cost=s_shopItems[m_currentlySelectedItem].m_cost;
available=CGameSlotManager::getSlotData()->getNumberOfKelpTokensHeld();
if(available>=cost)
{
playSound(CSoundMediator::SFX_FRONT_END__SELECT);
m_state=SHOP_STATE__CONFIRM_PURCHASE;
m_queryAnswer=ANSWER_NONE;
m_guiConfirmPurchaseFrame->select();
}
else
{
playSound(CSoundMediator::SFX_FRONT_END__ERROR);
m_state=SHOP_STATE__CANNOT_AFFORD_ITEM;
m_queryAnswer=ANSWER_NONE;
m_guiCannotAffordFrame->select();
}
}
else
{
playSound(CSoundMediator::SFX_FRONT_END__ERROR);
}
}
else if(pad&PAD_TRIANGLE)
{
m_readyToExit=true;
CFader::setFadingOut();
2001-08-02 17:46:19 +02:00
GameState::setNextScene(&MapScene);
2001-06-06 04:11:50 +02:00
}
m_guiFrame->think(_frames);
}
else if(m_state==SHOP_STATE__CONFIRM_PURCHASE)
2001-06-05 18:13:55 +02:00
{
2001-06-06 04:11:50 +02:00
m_guiConfirmPurchaseFrame->think(_frames);
if(m_queryAnswer==ANSWER_YES)
2001-06-05 18:13:55 +02:00
{
2001-06-06 04:11:50 +02:00
CGameSlotManager::getSlotData()->buyPartyItem(m_currentlySelectedItem);
CGameSlotManager::getSlotData()->useKelpTokens(s_shopItems[m_currentlySelectedItem].m_cost);
m_state=SHOP_STATE__SELECT_ITEM;
m_guiConfirmPurchaseFrame->unselect();
}
else if(m_queryAnswer==ANSWER_NO)
{
m_state=SHOP_STATE__SELECT_ITEM;
m_guiConfirmPurchaseFrame->unselect();
2001-06-05 18:13:55 +02:00
}
}
2001-06-06 04:11:50 +02:00
else if(m_state==SHOP_STATE__CANNOT_AFFORD_ITEM)
2001-06-05 18:13:55 +02:00
{
2001-06-06 04:11:50 +02:00
m_guiCannotAffordFrame->think(_frames);
if(m_queryAnswer==ANSWER_OK)
2001-06-05 18:13:55 +02:00
{
2001-06-06 04:11:50 +02:00
m_state=SHOP_STATE__SELECT_ITEM;
m_guiCannotAffordFrame->unselect();
2001-06-05 18:13:55 +02:00
}
}
2001-06-05 21:26:14 +02:00
2001-06-06 04:11:50 +02:00
m_flashSin=(m_flashSin+(_frames*SHOP_ICON_FLASH_SPEED))&4095;
// Slide the main UI menu about..
if(m_state!=SHOP_STATE__SELECT_ITEM||m_readyToExit)
{
m_mainUiYOffset+=30*_frames;
if(m_mainUiYOffset>MAIN_UI_MAX_Y_OFFSET)
{
m_mainUiYOffset=MAIN_UI_MAX_Y_OFFSET;
}
}
else
{
m_mainUiYOffset-=30*_frames;
if(m_mainUiYOffset<0)
{
m_mainUiYOffset=0;
}
}
2001-06-05 18:13:55 +02:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CShopScene::readyToShutdown()
{
return m_readyToExit&&!CFader::isFading();
}
2001-06-05 21:26:14 +02:00
/*----------------------------------------------------------------------
Function:
2001-06-06 04:11:50 +02:00
Purpose: Ugh... I *really* hope this works ok with all languages, otherwise
it might just be easier to start again :/
2001-06-05 21:26:14 +02:00
Params:
Returns:
---------------------------------------------------------------------- */
void CShopScene::renderUi()
{
int xbase,ybase;
SpriteBank *sb;
2001-06-06 01:01:16 +02:00
int w1,w2,w3,instructionsWidth,instructionsXBase;
2001-06-06 04:11:50 +02:00
int maxInstructionsWidth;
2001-06-05 21:26:14 +02:00
sFrameHdr *fh1,*fh2;
int x,y;
2001-06-06 01:01:16 +02:00
char buf[100];
2001-06-05 21:26:14 +02:00
2001-06-06 04:11:50 +02:00
m_font->setPrintArea(SHOP_QUERY_UI_X+10,SHOP_QUERY_UI_Y+5,SHOP_QUERY_UI_W-20,SHOP_QUERY_UI_H-10);
m_font->setJustification(FontBank::JUST_CENTRE);
if(m_state==SHOP_STATE__CONFIRM_PURCHASE)
{
int cost,available;
char buf[100];
cost=s_shopItems[m_currentlySelectedItem].m_cost;
available=CGameSlotManager::getSlotData()->getNumberOfKelpTokensHeld();
sprintf(buf,TranslationDatabase::getString(STR__SHOP_SCREEN__CONFIRM_PURCHASE),cost,available);
m_font->print((SHOP_QUERY_UI_W-20)/2,0,buf);
m_guiConfirmPurchaseFrame->render();
}
else if(m_state==SHOP_STATE__CANNOT_AFFORD_ITEM)
{
int cost,available;
char buf[100];
cost=s_shopItems[m_currentlySelectedItem].m_cost;
available=CGameSlotManager::getSlotData()->getNumberOfKelpTokensHeld();
2001-08-10 00:12:44 +02:00
sprintf(buf,TranslationDatabase::getString(available!=1?STR__SHOP_SCREEN__CANNOT_AFFORD_PURCHASE:STR__SHOP_SCREEN__CANNOT_AFFORD_PURCHASE_SINGULAR),cost,available);
2001-06-06 04:11:50 +02:00
m_font->print((SHOP_QUERY_UI_W-20)/2,0,buf);
m_guiCannotAffordFrame->render();
}
m_font->setPrintArea(0,0,512,256);
m_guiFrame->setObjectXYWH(SHOP_MAIN_UI_X,SHOP_MAIN_UI_Y+m_mainUiYOffset,SHOP_MAIN_UI_W,SHOP_MAIN_UI_H);
xbase=SHOP_MAIN_UI_X;
ybase=SHOP_MAIN_UI_Y+m_mainUiYOffset;
2001-06-05 21:26:14 +02:00
sb=CGameScene::getSpriteBank();
2001-06-06 01:01:16 +02:00
// Instructions
2001-06-05 21:26:14 +02:00
m_font->setJustification(FontBank::JUST_LEFT);
2001-06-06 01:01:16 +02:00
w1=m_font->getStringWidth(STR__SHOP_SCREEN__LEFT_RIGHT_TO_SELECT_ITEM);
w2=m_font->getStringWidth(STR__SHOP_SCREEN__CROSS_TO_PURCHASE);
w3=m_font->getStringWidth(STR__SHOP_SCREEN__TRIANGLE_TO_EXIT);
instructionsWidth=w1;
if(w2>instructionsWidth)instructionsWidth=w2;
if(w3>instructionsWidth)instructionsWidth=w3;
2001-06-06 04:11:50 +02:00
instructionsXBase=SHOP_MAIN_UI_W-instructionsWidth-SHOP_XBORDER;
2001-06-05 21:26:14 +02:00
2001-06-06 01:01:16 +02:00
x=xbase+instructionsXBase;
2001-06-06 04:11:50 +02:00
y=ybase+SHOP_INSTRUCTIONS_Y_BASE;
2001-06-05 21:26:14 +02:00
m_font->print(x,y,STR__SHOP_SCREEN__LEFT_RIGHT_TO_SELECT_ITEM);
fh1=sb->getFrameHeader(FRM__BUTL);
fh2=sb->getFrameHeader(FRM__BUTR);
2001-06-06 04:11:50 +02:00
x-=SHOP_SPACE_BETWEEN_INSTRUCTIONS_AND_BUTTONS+fh2->W;
y+=SHOP_Y_BUTTON_OFFSET_FORM_TOP_OF_TEXT;
2001-06-26 21:18:56 +02:00
sb->printFT4(fh2,x,y,0,0,0);
2001-06-06 04:11:50 +02:00
x-=SHOP_GAP_BETWEEN_INSTRUCTION_BUTTONS+fh1->W;
2001-06-26 21:18:56 +02:00
sb->printFT4(fh1,x,y,0,0,0);
2001-06-06 04:11:50 +02:00
maxInstructionsWidth=xbase+SHOP_MAIN_UI_Y-x;
2001-06-05 21:26:14 +02:00
2001-06-06 01:01:16 +02:00
x=xbase+instructionsXBase;
2001-06-06 04:11:50 +02:00
y=ybase+SHOP_INSTRUCTIONS_Y_BASE+SHOP_Y_GAP_BETWEEN_INSTRUCTION_LINES;
2001-06-05 21:26:14 +02:00
m_font->print(x,y,STR__SHOP_SCREEN__CROSS_TO_PURCHASE);
fh1=sb->getFrameHeader(FRM__BUTX);
2001-06-06 04:11:50 +02:00
x-=SHOP_SPACE_BETWEEN_INSTRUCTIONS_AND_BUTTONS+fh2->W;
y+=SHOP_Y_BUTTON_OFFSET_FORM_TOP_OF_TEXT;
2001-06-26 21:18:56 +02:00
sb->printFT4(fh1,x-1,y,0,0,0);
2001-06-05 21:26:14 +02:00
2001-06-06 01:01:16 +02:00
x=xbase+instructionsXBase;
2001-06-06 04:11:50 +02:00
y=ybase+SHOP_INSTRUCTIONS_Y_BASE+(SHOP_Y_GAP_BETWEEN_INSTRUCTION_LINES*2);
2001-06-05 21:26:14 +02:00
m_font->print(x,y,STR__SHOP_SCREEN__TRIANGLE_TO_EXIT);
fh1=sb->getFrameHeader(FRM__BUTT);
2001-06-06 04:11:50 +02:00
x-=SHOP_SPACE_BETWEEN_INSTRUCTIONS_AND_BUTTONS+fh2->W;
y+=SHOP_Y_BUTTON_OFFSET_FORM_TOP_OF_TEXT;
2001-06-26 21:18:56 +02:00
sb->printFT4(fh1,x-1,y,0,0,0);
2001-06-06 01:01:16 +02:00
// Item price
int x1,x2;
2001-06-06 04:11:50 +02:00
x1=SHOP_XBORDER;
x2=SHOP_MAIN_UI_Y-maxInstructionsWidth-(SHOP_XBORDER*1);
2001-06-06 01:01:16 +02:00
m_font->setJustification(FontBank::JUST_CENTRE);
if(isItemAvailableToBuy(m_currentlySelectedItem))
{
SHOPITEM *shopItem;
shopItem=&s_shopItems[m_currentlySelectedItem];
fh1=m_spriteBank->getFrameHeader(shopItem->m_frame);
2001-06-06 04:11:50 +02:00
x=xbase+SHOP_ITEM_X_POS;
y=ybase+SHOP_ITEM_Y_POS;
2001-06-26 21:18:56 +02:00
sb->printFT4(fh1,x,y,0,0,0);
2001-06-06 01:01:16 +02:00
x1+=32;
m_font->setPrintArea(xbase+x1,ybase,x2-x1,100);
2001-06-06 04:11:50 +02:00
m_font->print((x2-x1)/2,SHOP_PRICE_Y_GAP_FROM_TOP,STR__SHOP_SCREEN__PRICE);
2001-06-06 01:01:16 +02:00
sprintf(buf,"%d",shopItem->m_cost);
2001-06-06 04:11:50 +02:00
m_font->print((x2-x1)/2,SHOP_PRICE_Y_GAP_FROM_TOP+m_font->getStringHeight(STR__SHOP_SCREEN__PRICE),buf);
2001-06-06 01:01:16 +02:00
}
else
{
m_font->setPrintArea(xbase+x1,ybase,x2-x1,100);
2001-06-06 04:11:50 +02:00
m_font->print((x2-x1)/2,SHOP_PRICE_Y_GAP_FROM_TOP,STR__SHOP_SCREEN__ITEM_ALREADY_PURCHASED);
2001-06-06 01:01:16 +02:00
}
m_font->setPrintArea(0,0,512,256);
// Available token count
2001-06-06 04:11:50 +02:00
x=xbase+SHOP_TOKEN_COUNT_X_POS;
y=ybase+SHOP_TOKEN_COUNT_Y_POS;
2001-06-06 01:01:16 +02:00
fh1=m_spriteBank->getFrameHeader(FRM_SMALLTOKEN);
2001-06-26 21:18:56 +02:00
m_spriteBank->printFT4(fh1,x,y,0,0,0);
2001-06-06 01:01:16 +02:00
x+=fh1->W;
2001-06-06 04:11:50 +02:00
sprintf(buf,"x%d",CGameSlotManager::getSlotData()->getNumberOfKelpTokensHeld());
2001-06-06 01:01:16 +02:00
m_font->setJustification(FontBank::JUST_LEFT);
m_font->print(x,y,buf);
2001-06-05 21:26:14 +02:00
m_guiFrame->render();
}
2001-06-05 18:13:55 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-06-06 01:01:16 +02:00
int CShopScene::isItemAvailableToBuy(int _itemNumber)
2001-06-05 18:13:55 +02:00
{
2001-06-06 04:11:50 +02:00
return !CGameSlotManager::getSlotData()->isPartyItemHeld(_itemNumber);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CShopScene::playSound(int _sfxId)
{
if(s_playId!=NOT_PLAYING)
{
CSoundMediator::stopAndUnlockSfx(s_playId);
}
s_playId=CSoundMediator::playSfx((CSoundMediator::SFXID)_sfxId,true);
/*
if(s_playId)
{
PAUL_DBGMSG("Didn't play..!?");
}
*/
2001-06-05 18:13:55 +02:00
}
/*===========================================================================
end */