29#include "Pac-Man_Evolution.h"
30#include "ResourceManager.h"
35 Main &mC64 = Main::Instance();
36 Archive::Block myBlock;
40 strcpy(myBlock.sParam1,
"HoF.dat");
41 strcpy(myBlock.sParam2,
"C64_FILE");
44 memset(scores, 0,
sizeof(scores));
45 idCDC = mC64.IArchiveMgr().load(PME_CONFIG);
46 mCDC = mC64.IArchiveMgr().get(idCDC);
49 if(mCDC->blockLoad(myBlock) == 0)
51 if(myBlock.iSize ==
sizeof(scores)) memcpy(scores, myBlock.pData, myBlock.iSize);
52 mCDC->blockLoadReleaseData(myBlock);
55 if(idCDC > 0) mC64.IArchiveMgr().close(idCDC);
58 if(scores[0][0].iPoints == 0)
60 for(i = 0; i < 2; i++)
62 for(j = 0; j < PME_HOF_SCORES; j++)
64 switch(mC64.ITool().randMWC() % 8)
67 strcpy(scores[i][j].sName,
"Soraya");
70 strcpy(scores[i][j].sName,
"Lorena");
73 strcpy(scores[i][j].sName,
"Eduardo");
76 strcpy(scores[i][j].sName,
"Alvaro");
79 strcpy(scores[i][j].sName,
"Bob");
82 strcpy(scores[i][j].sName,
"Arturo");
85 strcpy(scores[i][j].sName,
"Diego");
88 strcpy(scores[i][j].sName,
"Shelly");
91 scores[i][j].iPoints = (500 * PME_HOF_SCORES) - (j * 500);
100 Main &mC64 = Main::Instance();
101 Archive::Block myBlock;
105 strcpy(myBlock.sParam1,
"HoF.dat");
106 strcpy(myBlock.sParam2,
"C64_FILE");
109 idCDC = mC64.IArchiveMgr().load(PME_CONFIG);
110 if(idCDC < 0) idCDC = mC64.IArchiveMgr().create(PME_CONFIG);
111 mCDC = mC64.IArchiveMgr().get(idCDC);
114 myBlock.iSize =
sizeof(scores);
115 myBlock.pData = scores;
116 mCDC->blockAdd(myBlock);
118 if(idCDC > 0) mC64.IArchiveMgr().close(idCDC);
121Sint32 HoF::store(Sint32 iGameType, Sint32 iPoints,
char* szName)
126 if(iGameType < PME_GAME_EVOLUTION) iGameType = 0;
129 for(i = 0; i < PME_HOF_SCORES; i++)
131 if(iPoints > scores[iGameType][i].iPoints)
133 insert(iGameType, i, iPoints, szName);
142Sint32 HoF::getHighest(Sint32 iGameType)
145 if(iGameType < PME_GAME_EVOLUTION) iGameType = 0;
147 return scores[iGameType][0].iPoints;
151Sint32 HoF::getLowest(Sint32 iGameType)
154 if(iGameType < PME_GAME_EVOLUTION) iGameType = 0;
156 return scores[iGameType][PME_HOF_SCORES - 1].iPoints;
162#define SCORES_X_SPACE 440
163#define SCORES_Y_SPACE 43
164Sint32 HoF::render(Sint32 iMode)
166 int iGT, i, iPos, iX, iLX, iY, iMaxPos, iMaxName, iMaxPoints;
167 Main &mC64 = Main::Instance();
172 Sint32 iSW = 0, iSH = 0;
173 Screen* pScreen = Main::Instance().IConfigMgr().get();
174 if(pScreen !=
nullptr) pScreen->getSize(&iSW, &iSH);
177 iX = SCORES_X; iY = SCORES_Y;
180 fontScore = mC64.IFontMgr().get(ResourceManager::Instance().get(RM_FONT_SCORE));
181 fontPlayer = mC64.IFontMgr().get(ResourceManager::Instance().get(RM_FONT_INFO));
185 for(iPos = 0; iPos < PME_HOF_SCORES; iPos++)
187 mC64.ITool().intToStrDec(iPos + 1, sTmp);
188 i = fontScore->getWidth(sTmp);
189 if(i > iMaxPos) iMaxPos = i;
193 Image* pImage = Main::Instance().IImageMgr().get(ResourceManager::Instance().get(RM_IMG_HOF));
194 if(pImage !=
nullptr)
196 rDst.w = pImage->getSurface()->w;
197 rDst.h = pImage->getSurface()->h;
198 rDst.x = (iSW - rDst.w) / 2;
199 rDst.y = (iSH - rDst.h) / 2;
200 pImage->render(0,
nullptr, &rDst);
204 for(iGT = 0; iGT < 2; iGT++)
208 iMaxName = iMaxPoints = 0;
209 for(iPos = 0; iPos < PME_HOF_SCORES; iPos++)
211 i = fontPlayer->getWidth(scores[iGT][iPos].sName);
212 if(i > iMaxName) iMaxName = i;
213 mC64.ITool().intToStrDec(scores[iGT][iPos].iPoints, sTmp);
214 i = fontPlayer->getWidth(sTmp);
215 if(i > iMaxPoints) iMaxPoints = i;
219 for(iPos = 0; iPos < PME_HOF_SCORES; iPos++)
224 mC64.ITool().intToStrDec(iPos + 1, sTmp);
225 fontPlayer->setPosition(iLX - (fontScore->getWidth(sTmp) - iMaxPos), iY);
226 fontPlayer->render(sTmp);
227 iLX = iLX + iMaxPos + 10;
230 fontPlayer->setPosition(iLX - (fontPlayer->getWidth(scores[iGT][iPos].sName) - iMaxName), iY);
231 fontPlayer->render(scores[iGT][iPos].sName);
232 iLX = iLX + iMaxName + 15;
235 mC64.ITool().intToStrDec(scores[iGT][iPos].iPoints, sTmp);
236 fontScore->setPosition(iLX - (fontScore->getWidth(sTmp) - iMaxPoints), iY);
237 fontScore->render(sTmp);
239 iY = iY + SCORES_Y_SPACE;
242 iX = iX + SCORES_X_SPACE;
249Sint32 HoF::insert(Sint32 iGameType, Sint32 iPos, Sint32 iPoints,
char* szName)
254 for(i = PME_HOF_SCORES - 1; i > iPos; i--)
256 scores[iGameType][i].iPoints = scores[iGameType][i - 1].iPoints;
257 strcpy(scores[iGameType][i].sName, scores[iGameType][i - 1].sName);
261 scores[iGameType][iPos].iPoints = iPoints;
262 strcpy(scores[iGameType][iPos].sName, szName);