📄 housekeeper.c
字号:
break; case ID_MAP_A: pTempColl = theMap->head; if (GotoCollection(pTempColl)) InvalidateRect(hWnd, NULL, TRUE); break; case ID_MAP_B: pTempColl = theMap->head->next; if (GotoCollection(pTempColl)) InvalidateRect(hWnd, NULL, TRUE); break; case ID_MAP_C: pTempColl = theMap->head->next->next; if (GotoCollection(pTempColl)) InvalidateRect(hWnd, NULL, TRUE); break; case ID_MAP_D: pTempColl = theMap->head->next->next->next; if (GotoCollection(pTempColl)) InvalidateRect(hWnd, NULL, TRUE); break; case ID_MAP_E: pTempColl = theMap->tail->prev->prev->prev; if (GotoCollection(pTempColl)) InvalidateRect(hWnd, NULL, TRUE); break; case ID_MAP_F: pTempColl = theMap->tail->prev->prev; if (GotoCollection(pTempColl)) InvalidateRect(hWnd, NULL, TRUE); break; case ID_MAP_G: pTempColl = theMap->tail->prev; if (GotoCollection(pTempColl)) InvalidateRect(hWnd, NULL, TRUE); break; case ID_MAP_H: pTempColl = theMap->tail; if (GotoCollection(pTempColl)) InvalidateRect(hWnd, NULL, TRUE); break; case ID_ABOUT: MessageBox(HDC_SCREEN, "Song Lixin(zjujoe@263.net)\nHouse Keeper Ver 0.1 (2001/03/06)", "About", MB_OK); break; } return 0; case MSG_LBUTTONDOWN: x = LOWORD(lParam); y = HIWORD(lParam); if (!ptChoosePlace(hWnd, &x, &y)) return 0; //snprintf(strTemp, 50, "%d:%d", x, y); //MessageBox(HDC_SCREEN, strTemp, strTemp, MB_OK); PlayMove(hWnd, x, y); return 0; case MSG_RBUTTONDOWN: PlayUndo(hWnd); return 0; case MSG_PAINT: hdc = BeginPaint(hWnd); OnDraw(hWnd,hdc); EndPaint(hWnd,hdc); return 0; case MSG_KEYDOWN: switch (wParam) { case SCANCODE_CURSORBLOCKUP: iDir = DIR_UP; break; case SCANCODE_CURSORBLOCKLEFT: iDir = DIR_LEFT; break; case SCANCODE_CURSORBLOCKRIGHT: iDir = DIR_RIGHT; break; case SCANCODE_CURSORBLOCKDOWN: iDir = DIR_DOWN; break; default: iDir = -1; } if ((iDir != -1) && (PlayKeyboard(hWnd, iDir) == STEP_TYPE_PUSH)){ if (CheckMissionComplete()) { MessageBox(HDC_SCREEN, "Misson Completed!", "Good", MB_OK); theMap->current->current = theMap->current->current->next; PlayRestart(); InvalidateRect(hWnd, NULL, TRUE); } return 0; } if (wParam == SCANCODE_U) PlayUndo(hWnd); return 0; case MSG_TIMER: return 0; case MSG_CLOSE: OnClose(hWnd); return 0; } return DefaultMainWinProc(hWnd, message, wParam, lParam);}void OnDraw(HWND hWnd,HDC hDC) { RECT rect; POINT poStart1; int iSideLength; ptagLevel cur_level; char strText[50]; int iRow; int iCol; int i, j; int iBmp; GetClientRect(hWnd,&rect); SetBkColor(hDC,RGB2Pixel(HDC_SCREEN, 102, 102, 102)); //SetTextColor(hDC,COLOR_green); SetPenColor(hDC,COLOR_black); poStart1.x = rect.left; poStart1.y = rect.top; cur_level = theMap->currentLevel; snprintf(strText, 50, "Collection %s, Level %d ", theMap->current->strName, cur_level->iNo); TextOut(hDC, rect.left + 40, rect.bottom - 20, strText); rect.bottom -= 20; if (rect.bottom - rect.top < 100) return; iRow = cur_level->row; iCol = cur_level->col; i = RECTH(rect)/iRow; j = RECTW(rect)/iCol; if (i <= j) iSideLength = i; else iSideLength = j; for (i = 0; i < iRow; i++) { for (j = 0; j < iCol; j++) { iBmp = cur_level->data[i * iCol + j]; if (iBmp < B_NOTHING) { FillBoxWithBitmap(hDC, poStart1.x + iSideLength * j \ , poStart1.y + iSideLength * i, iSideLength, iSideLength, &bitmapAll[iBmp]); } } }}void InitMyWinCreateInfo(PMAINWINCREATE pCreateInfo){ pCreateInfo->dwStyle = WS_CAPTION | WS_BORDER | WS_SYSMENU | WS_VISIBLE; pCreateInfo->dwExStyle = WS_EX_NONE; pCreateInfo->spCaption="House Keeper"; pCreateInfo->hMenu = createmenu1(); pCreateInfo->hCursor = GetSystemCursor(0); pCreateInfo->hIcon = 0; pCreateInfo->MainWindowProc = TestMyWinProc; pCreateInfo->lx = 0; pCreateInfo->ty = 0; pCreateInfo->rx = WIDTH_LARGEWIN; pCreateInfo->by = HEIGHT_LARGEWIN; pCreateInfo->iBkColor = RGB2Pixel(HDC_SCREEN, 102, 102, 102); pCreateInfo->dwAddData = 0; pCreateInfo->hHosting = HWND_DESKTOP;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endifint MiniGUIMain (int args, const char* arg[]){ MSG Msg; MAINWINCREATE CreateInfo; HWND hMainWnd;#if defined(_LITE_VERSION) && !(_STAND_ALONE) int i; const char* layer = NULL; RECT max_rect = {0, 0, 0, 0}; for (i = 1; i < args; i++) { if (strcmp (arg[i], "-layer") == 0) { layer = arg[i + 1]; break; } } GetLayerInfo (layer, &max_rect, NULL, NULL, NULL); if (JoinLayer (layer, arg[0], max_rect.left, max_rect.top, max_rect.left + 1024, max_rect.top + 768) == INV_LAYER_HANDLE) { printf ("JoinLayer: invalid layer handle.\n"); exit (1); }#endif InitMyWinCreateInfo(&CreateInfo); hMainWnd = CreateMainWindow(&CreateInfo); if (hMainWnd == HWND_INVALID) return -1; ShowWindow(hMainWnd,SW_SHOWNORMAL); while( GetMessage(&Msg, hMainWnd) ) { TranslateMessage (&Msg); DispatchMessage(&Msg); } MainWindowThreadCleanup(hMainWnd); return 0;}BOOL InitializeApp(void){ if(LoadBitmap(HDC_SCREEN, &bitmapAll[B_GOAL], "res/goal.gif")) return FALSE; if(LoadBitmap(HDC_SCREEN, &bitmapAll[B_MAN], "res/man.gif")) return FALSE; if(LoadBitmap(HDC_SCREEN, &bitmapAll[B_OBJECT], "res/object.gif")) return FALSE; if(LoadBitmap(HDC_SCREEN, &bitmapAll[B_SAVEMAN], "res/saveman.gif")) return FALSE; if(LoadBitmap(HDC_SCREEN, &bitmapAll[B_STONE], "res/stone.gif")) return FALSE; if(LoadBitmap(HDC_SCREEN, &bitmapAll[B_TREASURE], "res/treasure.gif")) return FALSE; InitMap(); return TRUE;}void OnClose(HWND hWnd){ DestroyMap(); UnloadBitmap(&bitmapAll[B_GOAL]); UnloadBitmap(&bitmapAll[B_MAN]); UnloadBitmap(&bitmapAll[B_OBJECT]); UnloadBitmap(&bitmapAll[B_SAVEMAN]); UnloadBitmap(&bitmapAll[B_STONE]); UnloadBitmap(&bitmapAll[B_TREASURE]); DestroyMainWindow (hWnd); PostQuitMessage (hWnd);}void CovertCoord(HWND hWnd,int *px, int *py){ RECT rect; int iSideLength; ptagLevel cur_level; int iRow; int iCol; int i, j; GetClientRect(hWnd,&rect); rect.bottom -= 20; if (rect.bottom - rect.top < 100) return; cur_level = theMap->currentLevel; iRow = cur_level->row; iCol = cur_level->col; i = RECTH(rect)/iRow; j = RECTW(rect)/iCol; if (i <= j) iSideLength = i; else iSideLength = j; i = *px; j = *py; *px = rect.left + i * iSideLength; *py = rect.top + j * iSideLength;}BOOL ptChoosePlace(HWND hWnd, int *px, int *py) { RECT rect; int iSideLength; ptagLevel cur_level; int iRow; int iCol; int i, j; GetClientRect(hWnd,&rect); rect.bottom -= 20; if (rect.bottom - rect.top < 100) return FALSE; cur_level = theMap->currentLevel; iRow = cur_level->row; iCol = cur_level->col; i = RECTH(rect)/iRow; j = RECTW(rect)/iCol; if (i <= j) iSideLength = i; else iSideLength = j; i = *px; j = *py; if ( (i > rect.left) && (i < rect.left + iSideLength * iCol) && (j > rect.top ) && (j < rect.top + iSideLength * iRow) ) { *px = (i - rect.left) / iSideLength; *py = (j - rect.top ) / iSideLength; return TRUE; } return FALSE;}void DrawALittleBlock(HWND hWnd, int x, int y, int itype) { HDC hdc; RECT rect; int iSideLength; ptagLevel cur_level; int iRow; int iCol; int i, j; GetClientRect(hWnd,&rect); rect.bottom -= 20; if (rect.bottom - rect.top < 100) return; cur_level = theMap->currentLevel; iRow = cur_level->row; iCol = cur_level->col; i = RECTH(rect)/iRow; j = RECTW(rect)/iCol; if (i <= j) iSideLength = i; else iSideLength = j; i = x; j = y; x = rect.left + i * iSideLength; y = rect.top + j * iSideLength; hdc = GetClientDC(hWnd); if(itype <= B_NOTHING) { if(itype == B_NOTHING) { SetBrushColor(hdc,RGB2Pixel(HDC_SCREEN, 102, 102, 102)); FillBox(hdc, x, y, iSideLength, iSideLength); } else { FillBoxWithBitmap(hdc, x, y, iSideLength, iSideLength, &bitmapAll[itype]); } } ReleaseDC(hdc);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -