This commit is contained in:
parent
4007258a64
commit
d5edfef48d
1 changed files with 75 additions and 34 deletions
|
@ -218,7 +218,7 @@ void CShopScene::render()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Darken item if already bought
|
// Darken item if already bought
|
||||||
if(!isItemAvailableToBut(i))
|
if(!isItemAvailableToBuy(i))
|
||||||
{
|
{
|
||||||
setRGB0(ft4,shopboughtrgb,shopboughtrgb,shopboughtrgb);
|
setRGB0(ft4,shopboughtrgb,shopboughtrgb,shopboughtrgb);
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ int CShopScene::readyToShutdown()
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Function:
|
Function:
|
||||||
Purpose:
|
Purpose: Ugh...
|
||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
|
@ -297,13 +297,16 @@ typedef struct
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
tokenx,tokeny,
|
tokenx,tokeny,
|
||||||
|
itemx,itemy,
|
||||||
pricex,pricey,
|
pricex,pricey,
|
||||||
|
boxx,boxy,boxw,boxh,
|
||||||
gaptoreadout,
|
gaptoreadout,
|
||||||
instructionsx,instructionsy,
|
instructionsy,
|
||||||
instructionsygap,
|
instructionsygap,
|
||||||
instructionsbuttonyoffset,
|
instructionsbuttonyoffset,
|
||||||
instructionsbuttonspace,
|
instructionsbuttonspace,
|
||||||
instructionsbuttongap,
|
instructionsbuttongap,
|
||||||
|
xborder,
|
||||||
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
@ -311,48 +314,45 @@ typedef struct
|
||||||
|
|
||||||
shopdata shop=
|
shopdata shop=
|
||||||
{
|
{
|
||||||
10,10, // tokenx,tokeny,
|
10,42, // tokenx,tokeny,
|
||||||
40,10, // pricex,pricey,
|
10,6, // itemx,itemy,
|
||||||
|
110,17, // pricex,pricey,
|
||||||
|
10,5,180,500, // boxx,boxy,boxw,boxh,
|
||||||
5, // gaptoreadout
|
5, // gaptoreadout
|
||||||
250,7, // instructionsx,instructionsy,
|
7, // instructionsy,
|
||||||
16, // instructionsygap,
|
16, // instructionsygap,
|
||||||
3, // instructionsbuttonyoffset,
|
3, // instructionsbuttonyoffset,
|
||||||
10, // instructionsbuttonspace,
|
10, // instructionsbuttonspace,
|
||||||
5, // instructionsbuttongap,
|
5, // instructionsbuttongap,
|
||||||
|
10, // xborder,
|
||||||
};
|
};
|
||||||
|
|
||||||
void CShopScene::renderUi()
|
void CShopScene::renderUi()
|
||||||
{
|
{
|
||||||
int xbase,ybase;
|
int xbase,ybase;
|
||||||
SpriteBank *sb;
|
SpriteBank *sb;
|
||||||
|
int w1,w2,w3,instructionsWidth,instructionsXBase;
|
||||||
sFrameHdr *fh1,*fh2;
|
sFrameHdr *fh1,*fh2;
|
||||||
int x,y;
|
int x,y;
|
||||||
char buf[10];
|
char buf[100];
|
||||||
|
|
||||||
|
|
||||||
xbase=fx;
|
xbase=fx;
|
||||||
ybase=fy;
|
ybase=fy;
|
||||||
sb=CGameScene::getSpriteBank();
|
sb=CGameScene::getSpriteBank();
|
||||||
|
|
||||||
|
// Instructions
|
||||||
m_font->setJustification(FontBank::JUST_LEFT);
|
m_font->setJustification(FontBank::JUST_LEFT);
|
||||||
|
|
||||||
// Token count
|
w1=m_font->getStringWidth(STR__SHOP_SCREEN__LEFT_RIGHT_TO_SELECT_ITEM);
|
||||||
fh1=sb->getFrameHeader(FRM__TOKEN);
|
w2=m_font->getStringWidth(STR__SHOP_SCREEN__CROSS_TO_PURCHASE);
|
||||||
x=xbase+shop.tokenx;
|
w3=m_font->getStringWidth(STR__SHOP_SCREEN__TRIANGLE_TO_EXIT);
|
||||||
y=ybase+shop.tokeny;
|
instructionsWidth=w1;
|
||||||
sb->printFT4(fh1,x,y,0,0,0);
|
if(w2>instructionsWidth)instructionsWidth=w2;
|
||||||
sprintf(buf,"x%d",99);
|
if(w3>instructionsWidth)instructionsWidth=w3;
|
||||||
// x+=fh1->W+shop.gaptoreadout;
|
instructionsXBase=fw-instructionsWidth-shop.xborder;
|
||||||
// y+=fh1->H+m_font->getStringHeight(buf);
|
|
||||||
PAUL_DBGMSG("%d,%d",fh1->H,m_font->getStringHeight(buf));
|
|
||||||
m_font->print(x,y,buf);
|
|
||||||
|
|
||||||
|
x=xbase+instructionsXBase;
|
||||||
// Item price
|
|
||||||
m_font->print(xbase+shop.pricex,ybase+shop.pricey,STR__SHOP_SCREEN__PRICE);
|
|
||||||
|
|
||||||
|
|
||||||
// Instructions
|
|
||||||
x=xbase+shop.instructionsx;
|
|
||||||
y=ybase+shop.instructionsy;
|
y=ybase+shop.instructionsy;
|
||||||
m_font->print(x,y,STR__SHOP_SCREEN__LEFT_RIGHT_TO_SELECT_ITEM);
|
m_font->print(x,y,STR__SHOP_SCREEN__LEFT_RIGHT_TO_SELECT_ITEM);
|
||||||
fh1=sb->getFrameHeader(FRM__BUTL);
|
fh1=sb->getFrameHeader(FRM__BUTL);
|
||||||
|
@ -362,23 +362,64 @@ PAUL_DBGMSG("%d,%d",fh1->H,m_font->getStringHeight(buf));
|
||||||
sb->printFT4(fh2,x,y,0,0,0);
|
sb->printFT4(fh2,x,y,0,0,0);
|
||||||
x-=shop.instructionsbuttongap+fh1->W;
|
x-=shop.instructionsbuttongap+fh1->W;
|
||||||
sb->printFT4(fh1,x,y,0,0,0);
|
sb->printFT4(fh1,x,y,0,0,0);
|
||||||
|
int maxInstructionsWidth=xbase+fy-x;
|
||||||
|
|
||||||
x=xbase+shop.instructionsx;
|
x=xbase+instructionsXBase;
|
||||||
y=ybase+shop.instructionsy+shop.instructionsygap;
|
y=ybase+shop.instructionsy+shop.instructionsygap;
|
||||||
m_font->print(x,y,STR__SHOP_SCREEN__CROSS_TO_PURCHASE);
|
m_font->print(x,y,STR__SHOP_SCREEN__CROSS_TO_PURCHASE);
|
||||||
fh1=sb->getFrameHeader(FRM__BUTX);
|
fh1=sb->getFrameHeader(FRM__BUTX);
|
||||||
x-=shop.instructionsbuttonspace+fh2->W;
|
x-=shop.instructionsbuttonspace+fh2->W;
|
||||||
y+=shop.instructionsbuttonyoffset;
|
y+=shop.instructionsbuttonyoffset;
|
||||||
sb->printFT4(fh1,x,y,0,0,0);
|
sb->printFT4(fh1,x-1,y,0,0,0);
|
||||||
|
|
||||||
x=xbase+shop.instructionsx;
|
x=xbase+instructionsXBase;
|
||||||
y=ybase+shop.instructionsy+(shop.instructionsygap*2);
|
y=ybase+shop.instructionsy+(shop.instructionsygap*2);
|
||||||
m_font->print(x,y,STR__SHOP_SCREEN__TRIANGLE_TO_EXIT);
|
m_font->print(x,y,STR__SHOP_SCREEN__TRIANGLE_TO_EXIT);
|
||||||
fh1=sb->getFrameHeader(FRM__BUTT);
|
fh1=sb->getFrameHeader(FRM__BUTT);
|
||||||
x-=shop.instructionsbuttonspace+fh2->W;
|
x-=shop.instructionsbuttonspace+fh2->W;
|
||||||
y+=shop.instructionsbuttonyoffset;
|
y+=shop.instructionsbuttonyoffset;
|
||||||
|
sb->printFT4(fh1,x-1,y,0,0,0);
|
||||||
|
|
||||||
|
|
||||||
|
// Item price
|
||||||
|
int x1,x2;
|
||||||
|
x1=shop.xborder;
|
||||||
|
x2=fy-maxInstructionsWidth-(shop.xborder*1);
|
||||||
|
m_font->setJustification(FontBank::JUST_CENTRE);
|
||||||
|
if(isItemAvailableToBuy(m_currentlySelectedItem))
|
||||||
|
{
|
||||||
|
SHOPITEM *shopItem;
|
||||||
|
shopItem=&s_shopItems[m_currentlySelectedItem];
|
||||||
|
fh1=m_spriteBank->getFrameHeader(shopItem->m_frame);
|
||||||
|
x=xbase+shop.itemx;
|
||||||
|
y=ybase+shop.itemy;
|
||||||
sb->printFT4(fh1,x,y,0,0,0);
|
sb->printFT4(fh1,x,y,0,0,0);
|
||||||
|
|
||||||
|
x1+=32;
|
||||||
|
|
||||||
|
m_font->setPrintArea(xbase+x1,ybase,x2-x1,100);
|
||||||
|
m_font->print((x2-x1)/2,3,STR__SHOP_SCREEN__PRICE);
|
||||||
|
|
||||||
|
sprintf(buf,"%d",shopItem->m_cost);
|
||||||
|
m_font->print((x2-x1)/2,5+m_font->getStringHeight(STR__SHOP_SCREEN__PRICE),buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_font->setPrintArea(xbase+x1,ybase,x2-x1,100);
|
||||||
|
m_font->print((x2-x1)/2,3,STR__SHOP_SCREEN__ITEM_ALREADY_PURCHASED);
|
||||||
|
}
|
||||||
|
m_font->setPrintArea(0,0,512,256);
|
||||||
|
|
||||||
|
// Available token count
|
||||||
|
x=xbase+shop.tokenx;
|
||||||
|
y=ybase+shop.tokeny;
|
||||||
|
fh1=m_spriteBank->getFrameHeader(FRM_SMALLTOKEN);
|
||||||
|
m_spriteBank->printFT4(fh1,x,y,0,0,0);
|
||||||
|
x+=fh1->W;
|
||||||
|
sprintf(buf,"x%d",99);
|
||||||
|
m_font->setJustification(FontBank::JUST_LEFT);
|
||||||
|
m_font->print(x,y,buf);
|
||||||
|
|
||||||
m_guiFrame->render();
|
m_guiFrame->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +430,7 @@ PAUL_DBGMSG("%d,%d",fh1->H,m_font->getStringHeight(buf));
|
||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
int CShopScene::isItemAvailableToBut(int _itemNumber)
|
int CShopScene::isItemAvailableToBuy(int _itemNumber)
|
||||||
{
|
{
|
||||||
return _itemNumber!=3;
|
return _itemNumber!=3;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue