Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
ScoreListWnd.c
Package: pfly523.rar [view]
Upload User: shyhai1508
Upload Date: 2007-06-11
Package Size: 48k
Code Size: 4k
Category:
BREW
Development Platform:
Visual C++
- #include "ScoreListWnd.h"
- #include "AEEStdlib.h"
- #include "pfly.h"
- #include "pfly_res.h"
- static boolean ScoreListWnd_HandleKeyEvent(pthis, eCode, wParam);
- static void ScoreListWnd_Update(ScoreListWnd* pthis);
- static void ScoreListWnd_LoadList(ScoreListWnd* pthis);
- static void ScoreListWnd_SaveList(ScoreListWnd* pthis);
- boolean ScoreListWnd_New(ScoreListWnd *pthis, PflyApp* pMe)
- {
- pthis->pMe = pMe;
- MEMSET(pthis->scorelist, 0, sizeof(pthis->scorelist));
- ScoreListWnd_LoadList(pthis);
- return TRUE;
- }
- boolean ScoreListWnd_HandleEvent(ScoreListWnd* pthis, AEEEvent eCode, uint16 wParam, uint32 dwParam)
- {
- switch (eCode) {
- case EVT_APP_SUSPEND:
- return TRUE;
- case EVT_APP_RESUME:
- ScoreListWnd_Update(pthis);
- return TRUE;
- default:
- return ScoreListWnd_HandleKeyEvent(pthis, eCode, wParam);
- }
- }
- static boolean ScoreListWnd_HandleKeyEvent(ScoreListWnd* pthis, AEEEvent eCode, uint16 wParam)
- {
- if( eCode == EVT_KEY) {
- switch(wParam) {
- case AVK_CLR:
- return Pfly_SetActiveWnd(pthis->pMe, IDW_MAINMENU);
- default:
- return FALSE;
- }
- }
- return FALSE;
- }
- boolean ScoreListWnd_Open(ScoreListWnd* pthis)
- {
- ScoreListWnd_Update(pthis);
- return TRUE;
- }
- static void ScoreListWnd_Update(ScoreListWnd* pthis)
- {
- int loop;
- int screenX, screenY ,centerX, centerY;
- int stepH, stepW;
- AEEDeviceInfo deviceInfo;
- AECHAR str[MAX_STRING_SIZE];
- char temp[MAX_STRING_SIZE];
- IDisplay *m_pIDisplay = pthis->pMe->a.m_pIDisplay;
- IShell *m_pIShell = pthis->pMe->a.m_pIShell;
- ISHELL_GetDeviceInfo(m_pIShell, &deviceInfo);
- screenX = deviceInfo.cxScreen;
- screenY = deviceInfo.cyScreen;
- centerX = screenX/2;
- centerY = screenY/2;
- stepH = IDISPLAY_GetFontMetrics(m_pIDisplay, AEE_FONT_NORMAL, NULL, NULL);
- stepW = stepH;
- IDISPLAY_ClearScreen(m_pIDisplay);
- IDISPLAY_FillRect(m_pIDisplay, NULL, MAKE_RGB(128,138,238));
- ISHELL_LoadResString(m_pIShell, PFLY_RES_FILE, IDS_MENU_SCOREVIEW, str, MAX_STRING_SIZE);
- IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_BOLD, str, -1, 0,
- 5, NULL, IDF_ALIGN_CENTER | IDF_TEXT_TRANSPARENT);
- for(loop = 0; loop < MAX_LIST_LENGTH; loop ++) {
- SPRINTF(temp, "%d", loop+1);
- STRTOWSTR(temp, str, MAX_STRING_SIZE);
- IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, str, -1, 0, (2+loop)*stepH, NULL, IDF_TEXT_TRANSPARENT);
- SPRINTF(temp, "%d", pthis->scorelist[loop]);
- STRTOWSTR(temp, str, MAX_STRING_SIZE);
- IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, str, -1, screenX-stepW*2, (2+loop)*stepH, NULL, IDF_TEXT_TRANSPARENT);
- }
- IDISPLAY_Update(m_pIDisplay);
- }
- void ScoreListWnd_Close(ScoreListWnd* pthis)
- {
- }
- void ScoreListWnd_Free(ScoreListWnd* pthis)
- {
- }
- static void ScoreListWnd_LoadList(ScoreListWnd* pthis)
- {
- IFileMgr *pFileMgr = NULL;
- IFile *pFile = NULL;
- IShell *pIShell = pthis->pMe->a.m_pIShell;
- int i;
- if(ISHELL_CreateInstance(pIShell, AEECLSID_FILEMGR, (void **)&pFileMgr) != SUCCESS)
- {
- return;
- }
- if((pFile = IFILEMGR_OpenFile(pFileMgr, LIST_FILE, _OFM_READWRITE)) == NULL){
- IFILEMGR_Release(pFileMgr);
- return;
- }
- for(i = 0; i < MAX_LIST_LENGTH; i ++)
- {
- IFILE_Read(pFile, &pthis->scorelist[i], sizeof(int));
- }
- IFILE_Release(pFile);
- IFILEMGR_Release(pFileMgr);
- }
- static void ScoreListWnd_SaveList(ScoreListWnd* pthis)
- {
- IFileMgr *pFileMgr = NULL;
- IFile *pFile = NULL;
- IShell *pIShell = pthis->pMe->a.m_pIShell;
- int i;
- if(ISHELL_CreateInstance(pIShell, AEECLSID_FILEMGR, (void **)&pFileMgr) != SUCCESS)
- {
- return;
- }
- if((pFile = IFILEMGR_OpenFile(pFileMgr, LIST_FILE, _OFM_READWRITE)) == NULL){
- IFILEMGR_Release(pFileMgr);
- return;
- }
- for(i = 0; i < MAX_LIST_LENGTH; i ++)
- {
- IFILE_Write(pFile, &pthis->scorelist[i], sizeof(int));
- }
- IFILE_Release(pFile);
- IFILEMGR_Release(pFileMgr);
- }
- boolean ScoreListWnd_AddToList(ScoreListWnd* pthis, int score)
- {
- int i, j;
- for(i = 0; i < MAX_LIST_LENGTH; i++)
- {
- if(score > pthis->scorelist[i]){
- break;
- }
- }
- if(i < MAX_LIST_LENGTH){
- for(j = MAX_LIST_LENGTH-1; j > i; j --)
- {
- pthis->scorelist[j] = pthis->scorelist[j-1];
- }
- pthis->scorelist[i] = score;
- ScoreListWnd_SaveList(pthis);
- return TRUE;
- }
- return FALSE;
- }