Menu.cpp
上传用户:hkb425
上传日期:2007-06-16
资源大小:34191k
文件大小:24k
- // Menu.cpp: implementation of the CMenu class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Menu.h"
- #include "Audio.h"
- #include "math.h"
- #include "RasterText.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CMenu::CMenu(float FOVangle)
- {
- }
- CMenu::~CMenu()
- {
- }
- ////////////////////////////////////////////////////////
- int CMenu::DoMenu(HWND hWnd,HDC hDC,bool IsMainMenu)
- {
- if(IsMainMenu)m_iCurMenu=m_iOldMenu=0;
- else m_iCurMenu=m_iOldMenu=1;
- m_bExit=false;
- GameReturn=1;
- cSelect.Init(hWnd,2);
- cBkg.Init(hWnd, 1);
- cSelect.Create(1,"menu/1.wav",false);
- cSelect.Create(0,"menu/0.wav",false);
- cBkg.Create(0,"menu/piano.wav",false);
- cBkg.Play(0,50);
- ShowCursor(true);
- glDisable(GL_DEPTH_TEST);
- while(!m_bExit)
- {
- switch(m_iCurMenu)
- {
- case 0: DoMainMenu(hDC);break;
- // case 1: DoSaveAndLoadMenu(hDC);break;
- case 2: DoSinglePlayerMenu(hDC);break;
- case 3: DoMultiPlayerMenu(hDC);break;
- case 4: DoOptionMenu(hDC);break;
- case 5: DoAboutMenu(hDC,true);break;
- case 6: DoAboutMenu(hDC,false);break;
- case 7: DoExitMenu();break;
- case 8: DoNewGameMenu(hDC);break;
- case 9: DoLoadGameMenu(hDC);break;
- // case 10: DoSaveGameMenu(hDC);break;
- }
- }
- glEnable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- cSelect.Shutdown();
- cBkg.Shutdown();
- return GameReturn;
- }
- ///////////////////////////////////////////////////////////
- void CMenu::DoMainMenu(HDC hDC)
- {
- AUX_RGBImageRec * pMainMenu=NULL;
- AUX_RGBImageRec * pItemDown=NULL;
- AUX_RGBImageRec * pItemOn=NULL;
- pMainMenu=auxDIBImageLoad("menu/mainmenu.bmp");
- pItemDown=auxDIBImageLoad("menu/down.bmp");
- pItemOn=auxDIBImageLoad("menu/on.bmp");
- // if(!LoadPicture("menu/mainmenu.bmp",pMainMenu))return;
- // if(!LoadPicture("menu/down.bmp",pItemDown))return;
- // if(!LoadPicture("menu/on.bmp",pItemOn))return;
- int curItem=-1;
- int oldItem=-1;
- RECT rectItem[6];
- for(int i=0;i<6;i++)
- {
- rectItem[i].left=360;
- rectItem[i].right=720;
- rectItem[i].top=140+i*60;
- rectItem[i].bottom=195+i*60;
- }
- bool done=true;
- m_bLBtnDown=m_bLBtnUp=false;
- ////////////////////////
- // ::ShowCursor(true);
- MSG msg;
- while(done) // Loop That Runs While done=FALSE
- {
-
- if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
- {
- if (msg.message==WM_QUIT) // Have We Received A Quit Message?
- {
- done=false; // If So done=TRUE
- }
- else if(msg.message==WM_LBUTTONDOWN)
- {
- m_bLBtnDown=true;
- m_bLBtnUp=false;
- }
- else if(msg.message==WM_LBUTTONUP)
- {
- m_bLBtnDown=false;
- m_bLBtnUp=true;
- }
- else if(msg.message==WM_MOUSEMOVE)
- {
- m_bLBtnUp=false;
- }
- else // If Not, Deal With Window Messages
- {
- TranslateMessage(&msg); // Translate The Message
- DispatchMessage(&msg); // Dispatch The Message
- }
- }
- else // If There Are No Messages
- {
-
- glClearColor(0.0f,0.0f,0.0f,1.0f);//设置背景颜色为黑色
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- DrawPicture(0,600,pMainMenu);
- glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_DST_COLOR);
- // glEnable(GL_BLEND);
- GetCursorPos(&m_mpos);
- curItem=-1;
- for(int index=0;index<6;index++)
- {
- if(m_mpos.x>rectItem[index].left &&m_mpos.x<rectItem[index].right &&
- m_mpos.y>rectItem[index].top && m_mpos.y<rectItem[index].bottom)
- curItem=index;
- }
- if(oldItem!=curItem)
- {
- if(curItem!=-1)cSelect.Play(0,1);
- oldItem=curItem;
- }
- //////////////////////
- if(curItem!=-1)
- {
- if(m_bLBtnDown)DrawPicture(360,195+curItem*62,pItemDown);
- else DrawPicture(360,195+curItem*62,pItemOn);
- if(m_bLBtnUp )
- {
- done=false;
- cSelect.Play(1,1);
- m_iCurMenu=curItem+2;
- if(m_iCurMenu==7)m_bExit=true;
- }
- }
- //////////text
-
- glDisable(GL_BLEND);
- SwapBuffers(hDC);
- }
- }
- // Shutdown
- DeletePicture(pMainMenu);
- DeletePicture(pItemDown);
- DeletePicture(pItemOn);
- }
- //////////////////////// DoSinglePlayerMenu ////////////////////////
- void CMenu::DoSinglePlayerMenu(HDC hDC)
- {
- AUX_RGBImageRec * pMainMenu=NULL;
- AUX_RGBImageRec * pItemDown=NULL;
- AUX_RGBImageRec * pItemOn=NULL;
- pMainMenu=auxDIBImageLoad("menu/singleplayer.bmp");
- pItemDown=auxDIBImageLoad("menu/downmidle.bmp");
- pItemOn=auxDIBImageLoad("menu/onmidle.bmp");
- /*
- if(!LoadPicture("menu/singleplayer.bmp",pMainMenu))
- {
- MessageBox(NULL,"Load err.","ERROR",MB_OK|MB_ICONEXCLAMATION);
- m_bExit=true;
- return;
- }
- if(!LoadPicture("menu/downmidl.bmp",pItemDown))return;
- if(!LoadPicture("menu/onmid.bmp",pItemOn))return;*/
- int curItem=-1;
- int oldItem=-1;
- RECT rectItem[3];
- for(int i=0;i<3;i++)
- {
- rectItem[i].left=56+i*252;
- rectItem[i].right=236+i*252;
- rectItem[i].top=465;
- rectItem[i].bottom=525;
- }
- bool done=true;
- m_bLBtnDown=m_bLBtnUp=false;
- ////////////////////////
- // ::ShowCursor(true);
- MSG msg;
- while(done) // Loop That Runs While done=FALSE
- {
-
- if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
- {
- if (msg.message==WM_QUIT) // Have We Received A Quit Message?
- {
- done=false; // If So done=TRUE
- }
- else if(msg.message==WM_LBUTTONDOWN)
- {
- m_bLBtnDown=true;
- m_bLBtnUp=false;
- }
- else if(msg.message==WM_LBUTTONUP)
- {
- m_bLBtnDown=false;
- m_bLBtnUp=true;
- }
- else if(msg.message==WM_MOUSEMOVE)
- {
- m_bLBtnUp=false;
- }
- else // If Not, Deal With Window Messages
- {
- TranslateMessage(&msg); // Translate The Message
- DispatchMessage(&msg); // Dispatch The Message
- }
- }
- else // If There Are No Messages
- {
-
- glClearColor(0.0f,0.0f,0.0f,1.0f);//设置背景颜色为黑色
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- DrawPicture(0,600,pMainMenu);
- glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_DST_COLOR);
- // glEnable(GL_BLEND);
- GetCursorPos(&m_mpos);
- curItem=-1;
- for(int index=0;index<3;index++)
- {
- if(m_mpos.x>rectItem[index].left &&m_mpos.x<rectItem[index].right &&
- m_mpos.y>rectItem[index].top && m_mpos.y<rectItem[index].bottom)
- curItem=index;
- }
- if(oldItem!=curItem)
- {
- if(curItem!=-1)cSelect.Play(0,1);
- oldItem=curItem;
- }
- //////////////////////
- if(curItem!=-1)
- {
- if(m_bLBtnDown)DrawPicture(56+curItem*252,525,pItemDown);
- else DrawPicture(56+curItem*252,525,pItemOn);
- if(m_bLBtnUp )
- {
- done=false;
- cSelect.Play(1,1);
- if(curItem==0)m_iCurMenu=0;
- else
- {
- if(curItem==1)
- {m_iCurMenu=9; }
- else m_iCurMenu=8;
-
- }
- }
- }
- //////////text
- glDisable(GL_BLEND);
- SwapBuffers(hDC);
- }
- }
- // Shutdown
- DeletePicture(pMainMenu);
- DeletePicture(pItemDown);
- DeletePicture(pItemOn);
- }
- //////////////////////// DoNewGameMenu ////////////////////////
- void CMenu::DoNewGameMenu(HDC hDC)
- {
- AUX_RGBImageRec * pMainMenu=NULL;
- AUX_RGBImageRec * pItemDown=NULL;
- AUX_RGBImageRec * pItemOn=NULL;
- AUX_RGBImageRec * pLoading=NULL;
- pMainMenu=auxDIBImageLoad("menu/NewGame.bmp");
- pItemDown=auxDIBImageLoad("menu/downmidle.bmp");
- pItemOn=auxDIBImageLoad("menu/onmidle.bmp");
- pLoading=auxDIBImageLoad("menu/Loading.bmp");
- /*
- if(!LoadPicture("menu/singleplayer.bmp",pMainMenu))
- {
- MessageBox(NULL,"Load err.","ERROR",MB_OK|MB_ICONEXCLAMATION);
- m_bExit=true;
- return;
- }
- if(!LoadPicture("menu/downmidl.bmp",pItemDown))return;
- if(!LoadPicture("menu/onmid.bmp",pItemOn))return;*/
- int curItem=-1;
- int oldItem=-1;
- RECT rectItem[2];
- rectItem[0].left=84; rectItem[0].right=264;
- rectItem[0].top=522; rectItem[0].bottom=580;
- rectItem[1].left=525; rectItem[1].right=705;
- rectItem[1].top=522; rectItem[1].bottom=580;
- bool done=true;
- m_bLBtnDown=m_bLBtnUp=false;
- ////////////////////////
- // ::ShowCursor(true);
- MSG msg;
- while(done) // Loop That Runs While done=FALSE
- {
-
- if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
- {
- if (msg.message==WM_QUIT) // Have We Received A Quit Message?
- {
- done=false; // If So done=TRUE
- }
- else if(msg.message==WM_LBUTTONDOWN)
- {
- m_bLBtnDown=true;
- m_bLBtnUp=false;
- }
- else if(msg.message==WM_LBUTTONUP)
- {
- m_bLBtnDown=false;
- m_bLBtnUp=true;
- }
- else if(msg.message==WM_MOUSEMOVE)
- {
- m_bLBtnUp=false;
- }
- else // If Not, Deal With Window Messages
- {
- TranslateMessage(&msg); // Translate The Message
- DispatchMessage(&msg); // Dispatch The Message
- }
- }
- else // If There Are No Messages
- {
-
- glClearColor(0.0f,0.0f,0.0f,1.0f);//设置背景颜色为黑色
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- DrawPicture(0,600,pMainMenu);
- glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_DST_COLOR);
- // glEnable(GL_BLEND);
- GetCursorPos(&m_mpos);
- curItem=-1;
- for(int index=0;index<2;index++)
- {
- if(m_mpos.x>rectItem[index].left &&m_mpos.x<rectItem[index].right &&
- m_mpos.y>rectItem[index].top && m_mpos.y<rectItem[index].bottom)
- curItem=index;
- }
- if(oldItem!=curItem)
- {
- if(curItem!=-1)cSelect.Play(0,1);
- oldItem=curItem;
- }
- //////////////////////
- if(curItem!=-1)
- {
- if(m_bLBtnDown)DrawPicture(84+curItem*440,580,pItemDown);
- else DrawPicture(84+curItem*440,580,pItemOn);
- if(m_bLBtnUp )
- {
- done=false;
- cSelect.Play(1,1);
- if(curItem==0)m_iCurMenu=2;
- else
- {
- m_bExit=true;
- glDisable(GL_BLEND);
- DrawPicture(0,600,pLoading);
- ShowCursor(false);
- }
- }
- }
- //////////text
- glDisable(GL_BLEND);
- SwapBuffers(hDC);
- }
- }
- // Shutdown
- DeletePicture(pMainMenu);
- DeletePicture(pItemDown);
- DeletePicture(pItemOn);
- DeletePicture(pLoading);
- }
- /////////////////////////////////////////////////
- //////////////////////// DoLoadGameMenu ////////////////////////
- void CMenu::DoLoadGameMenu(HDC hDC)
- {
- AUX_RGBImageRec * pMainMenu=NULL;
- AUX_RGBImageRec * pItemDown=NULL;
- AUX_RGBImageRec * pItemOn=NULL;
- AUX_RGBImageRec * pLoading=NULL;
- pMainMenu=auxDIBImageLoad("menu/LoadGame.bmp");
- pItemDown=auxDIBImageLoad("menu/downmidle.bmp");
- pItemOn=auxDIBImageLoad("menu/onmidle.bmp");
- pLoading=auxDIBImageLoad("menu/Loading.bmp");
- /*
- if(!LoadPicture("menu/singleplayer.bmp",pMainMenu))
- {
- MessageBox(NULL,"Load err.","ERROR",MB_OK|MB_ICONEXCLAMATION);
- m_bExit=true;
- return;
- }
- if(!LoadPicture("menu/downmidl.bmp",pItemDown))return;
- if(!LoadPicture("menu/onmid.bmp",pItemOn))return;*/
- int curItem=-1;
- int oldItem=-1;
- RECT rectItem[2];
- rectItem[0].left=75; rectItem[0].right=252;
- rectItem[0].top=525; rectItem[0].bottom=582;
- rectItem[1].left=548; rectItem[1].right=725;
- rectItem[1].top=525; rectItem[1].bottom=582;
- bool done=true;
- m_bLBtnDown=m_bLBtnUp=false;
- ////////////////////////
- // ::ShowCursor(true);
- MSG msg;
- while(done) // Loop That Runs While done=FALSE
- {
-
- if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
- {
- if (msg.message==WM_QUIT) // Have We Received A Quit Message?
- {
- done=false; // If So done=TRUE
- }
- else if(msg.message==WM_LBUTTONDOWN)
- {
- m_bLBtnDown=true;
- m_bLBtnUp=false;
- }
- else if(msg.message==WM_LBUTTONUP)
- {
- m_bLBtnDown=false;
- m_bLBtnUp=true;
- }
- else if(msg.message==WM_MOUSEMOVE)
- {
- m_bLBtnUp=false;
- }
- else // If Not, Deal With Window Messages
- {
- TranslateMessage(&msg); // Translate The Message
- DispatchMessage(&msg); // Dispatch The Message
- }
- }
- else // If There Are No Messages
- {
-
- glClearColor(0.0f,0.0f,0.0f,1.0f);//设置背景颜色为黑色
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- DrawPicture(0,600,pMainMenu);
- glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_DST_COLOR);
- // glEnable(GL_BLEND);
- GetCursorPos(&m_mpos);
- curItem=-1;
- for(int index=0;index<2;index++)
- {
- if(m_mpos.x>rectItem[index].left &&m_mpos.x<rectItem[index].right &&
- m_mpos.y>rectItem[index].top && m_mpos.y<rectItem[index].bottom)
- curItem=index;
- }
- if(oldItem!=curItem)
- {
- if(curItem!=-1)cSelect.Play(0,1);
- oldItem=curItem;
- }
- //////////////////////
- if(curItem!=-1)
- {
- if(m_bLBtnDown)DrawPicture(75+curItem*473,582,pItemDown);
- else DrawPicture(75+curItem*473,582,pItemOn);
- if(m_bLBtnUp )
- {
- done=false;
- cSelect.Play(1,1);
- if(curItem==0)m_iCurMenu=2;
- else
- {
- m_bExit=true;
- glDisable(GL_BLEND);
- DrawPicture(0,600,pLoading);
- ShowCursor(false);
- }
-
- }
- }
- //////////text
- glDisable(GL_BLEND);
- SwapBuffers(hDC);
- }
- }
- // Shutdown
- DeletePicture(pMainMenu);
- DeletePicture(pItemDown);
- DeletePicture(pItemOn);
- DeletePicture(pLoading);
- }
- //////////////////////// DomultiPlayerMenu ////////////////////////
- void CMenu::DoMultiPlayerMenu(HDC hDC)
- {
- AUX_RGBImageRec * pMainMenu=NULL;
- AUX_RGBImageRec * pItemDown=NULL;
- AUX_RGBImageRec * pItemOn=NULL;
- pMainMenu=auxDIBImageLoad("menu/multiplayer.bmp");
- pItemDown=auxDIBImageLoad("menu/downmidle.bmp");
- pItemOn=auxDIBImageLoad("menu/onmidle.bmp");
- /*
- if(!LoadPicture("menu/singleplayer.bmp",pMainMenu))
- {
- MessageBox(NULL,"Load err.","ERROR",MB_OK|MB_ICONEXCLAMATION);
- m_bExit=true;
- return;
- }
- if(!LoadPicture("menu/downmidl.bmp",pItemDown))return;
- if(!LoadPicture("menu/onmid.bmp",pItemOn))return;*/
- int curItem=-1;
- int oldItem=-1;
- RECT rectItem[2];
- rectItem[0].left=35; rectItem[0].right=212;
- rectItem[0].top=514; rectItem[0].bottom=572;
- rectItem[1].left=221; rectItem[1].right=400;
- rectItem[1].top=514; rectItem[1].bottom=572;
- bool done=true;
- m_bLBtnDown=m_bLBtnUp=false;
- ////////////////////////
- // ::ShowCursor(true);
- MSG msg;
- while(done) // Loop That Runs While done=FALSE
- {
-
- if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
- {
- if (msg.message==WM_QUIT) // Have We Received A Quit Message?
- {
- done=false; // If So done=TRUE
- }
- else if(msg.message==WM_LBUTTONDOWN)
- {
- m_bLBtnDown=true;
- m_bLBtnUp=false;
- }
- else if(msg.message==WM_LBUTTONUP)
- {
- m_bLBtnDown=false;
- m_bLBtnUp=true;
- }
- else if(msg.message==WM_MOUSEMOVE)
- {
- m_bLBtnUp=false;
- }
- else // If Not, Deal With Window Messages
- {
- TranslateMessage(&msg); // Translate The Message
- DispatchMessage(&msg); // Dispatch The Message
- }
- }
- else // If There Are No Messages
- {
-
- glClearColor(0.0f,0.0f,0.0f,1.0f);//设置背景颜色为黑色
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- DrawPicture(0,600,pMainMenu);
- glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_DST_COLOR);
- // glEnable(GL_BLEND);
- GetCursorPos(&m_mpos);
- curItem=-1;
- for(int index=0;index<2;index++)
- {
- if(m_mpos.x>rectItem[index].left &&m_mpos.x<rectItem[index].right &&
- m_mpos.y>rectItem[index].top && m_mpos.y<rectItem[index].bottom)
- curItem=index;
- }
- if(oldItem!=curItem)
- {
- if(curItem!=-1)cSelect.Play(0,1);
- oldItem=curItem;
- }
- //////////////////////
- if(curItem!=-1)
- {
- if(m_bLBtnDown)DrawPicture(35+curItem*186,572,pItemDown);
- else DrawPicture(35+curItem*186,572,pItemOn);
- if(m_bLBtnUp )
- {
- done=false;
- cSelect.Play(1,1);
- if(curItem==0)m_iCurMenu=0;
- else
- {
- // if(curItem==1)
- // {m_iCurMenu=9; }
- //else m_iCurMenu=8;
-
- }
- }
- }
- //////////text
- glDisable(GL_BLEND);
- SwapBuffers(hDC);
- }
- }
- // Shutdown
- DeletePicture(pMainMenu);
- DeletePicture(pItemDown);
- DeletePicture(pItemOn);
- }
- //////////////////////// DoOptionMenu ////////////////////////
- void CMenu::DoOptionMenu(HDC hDC)
- {
- AUX_RGBImageRec * pMainMenu=NULL;
- AUX_RGBImageRec * pItemDown=NULL;
- AUX_RGBImageRec * pItemOn=NULL;
- pMainMenu=auxDIBImageLoad("menu/Option.bmp");
- pItemDown=auxDIBImageLoad("menu/downmidle.bmp");
- pItemOn=auxDIBImageLoad("menu/onmidle.bmp");
- /*
- if(!LoadPicture("menu/singleplayer.bmp",pMainMenu))
- {
- MessageBox(NULL,"Load err.","ERROR",MB_OK|MB_ICONEXCLAMATION);
- m_bExit=true;
- return;
- }
- if(!LoadPicture("menu/downmidl.bmp",pItemDown))return;
- if(!LoadPicture("menu/onmid.bmp",pItemOn))return;*/
- int curItem=-1;
- int oldItem=-1;
- RECT rectItem[3];
- for(int i=0;i<3;i++)
- {
- rectItem[i].left=90+i*215;
- rectItem[i].right=270+i*215;
- rectItem[i].top=510;
- rectItem[i].bottom=568;
- }
- bool done=true;
- m_bLBtnDown=m_bLBtnUp=false;
- ////////////////////////
- // ::ShowCursor(true);
- MSG msg;
- while(done) // Loop That Runs While done=FALSE
- {
-
- if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
- {
- if (msg.message==WM_QUIT) // Have We Received A Quit Message?
- {
- done=false; // If So done=TRUE
- }
- else if(msg.message==WM_LBUTTONDOWN)
- {
- m_bLBtnDown=true;
- m_bLBtnUp=false;
- }
- else if(msg.message==WM_LBUTTONUP)
- {
- m_bLBtnDown=false;
- m_bLBtnUp=true;
- }
- else if(msg.message==WM_MOUSEMOVE)
- {
- m_bLBtnUp=false;
- }
- else // If Not, Deal With Window Messages
- {
- TranslateMessage(&msg); // Translate The Message
- DispatchMessage(&msg); // Dispatch The Message
- }
- }
- else // If There Are No Messages
- {
-
- glClearColor(0.0f,0.0f,0.0f,1.0f);//设置背景颜色为黑色
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- DrawPicture(0,600,pMainMenu);
- glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_DST_COLOR);
- // glEnable(GL_BLEND);
- GetCursorPos(&m_mpos);
- curItem=-1;
- for(int index=0;index<3;index++)
- {
- if(m_mpos.x>rectItem[index].left &&m_mpos.x<rectItem[index].right &&
- m_mpos.y>rectItem[index].top && m_mpos.y<rectItem[index].bottom)
- curItem=index;
- }
- if(oldItem!=curItem)
- {
- if(curItem!=-1)cSelect.Play(0,1);
- oldItem=curItem;
- }
- //////////////////////
- if(curItem!=-1)
- {
- if(m_bLBtnDown)DrawPicture(90+curItem*215,568,pItemDown);
- else DrawPicture(90+curItem*215,568,pItemOn);
- if(m_bLBtnUp )
- {
- done=false;
- cSelect.Play(1,1);
- if(curItem==0)m_iCurMenu=0;
- else
- {
- // if(curItem==1)
- // {m_iCurMenu=9; }
- //else m_iCurMenu=8;
-
- }
- }
- }
- //////////text
- glDisable(GL_BLEND);
- SwapBuffers(hDC);
- }
- }
- // Shutdown
- DeletePicture(pMainMenu);
- DeletePicture(pItemDown);
- DeletePicture(pItemOn);
- }
- //////////////////////// DoAboutMenu ////////////////////////
- void CMenu::DoAboutMenu(HDC hDC,bool IsAboutEngine)
- {
- AUX_RGBImageRec * pMainMenu=NULL;
- AUX_RGBImageRec * pItemDown=NULL;
- AUX_RGBImageRec * pItemOn=NULL;
- if(IsAboutEngine) pMainMenu=auxDIBImageLoad("menu/AboutEngine.bmp");
- else pMainMenu=auxDIBImageLoad("menu/AboutMe.bmp");
- pItemDown=auxDIBImageLoad("menu/downmidle.bmp");
- pItemOn=auxDIBImageLoad("menu/onmidle.bmp");
- /*
- if(!LoadPicture("menu/singleplayer.bmp",pMainMenu))
- {
- MessageBox(NULL,"Load err.","ERROR",MB_OK|MB_ICONEXCLAMATION);
- m_bExit=true;
- return;
- }
- if(!LoadPicture("menu/downmidl.bmp",pItemDown))return;
- if(!LoadPicture("menu/onmid.bmp",pItemOn))return;*/
- int curItem=-1;
- int oldItem=-1;
- RECT rectItem[1];
- rectItem[0].left=305; rectItem[0].right=485;
- rectItem[0].top=514; rectItem[0].bottom=572;
- bool done=true;
- m_bLBtnDown=m_bLBtnUp=false;
- ////////////////////////
- // ::ShowCursor(true);
- MSG msg;
- while(done) // Loop That Runs While done=FALSE
- {
-
- if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
- {
- if (msg.message==WM_QUIT) // Have We Received A Quit Message?
- {
- done=false; // If So done=TRUE
- }
- else if(msg.message==WM_LBUTTONDOWN)
- {
- m_bLBtnDown=true;
- m_bLBtnUp=false;
- }
- else if(msg.message==WM_LBUTTONUP)
- {
- m_bLBtnDown=false;
- m_bLBtnUp=true;
- }
- else if(msg.message==WM_MOUSEMOVE)
- {
- m_bLBtnUp=false;
- }
- else // If Not, Deal With Window Messages
- {
- TranslateMessage(&msg); // Translate The Message
- DispatchMessage(&msg); // Dispatch The Message
- }
- }
- else // If There Are No Messages
- {
-
- glClearColor(0.0f,0.0f,0.0f,1.0f);//设置背景颜色为黑色
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- DrawPicture(0,600,pMainMenu);
- glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_DST_COLOR);
- // glEnable(GL_BLEND);
- GetCursorPos(&m_mpos);
- curItem=-1;
- for(int index=0;index<1;index++)
- {
- if(m_mpos.x>rectItem[index].left &&m_mpos.x<rectItem[index].right &&
- m_mpos.y>rectItem[index].top && m_mpos.y<rectItem[index].bottom)
- curItem=index;
- }
- if(oldItem!=curItem)
- {
- if(curItem!=-1)cSelect.Play(0,1);
- oldItem=curItem;
- }
- //////////////////////
- if(curItem!=-1)
- {
- if(m_bLBtnDown)DrawPicture(305,572,pItemDown);
- else DrawPicture(305,572,pItemOn);
- if(m_bLBtnUp )
- {
- done=false;
- cSelect.Play(1,1);
- if(curItem==0)m_iCurMenu=0;
- else
- {
- // if(curItem==1)
- // {m_iCurMenu=9; }
- //else m_iCurMenu=8;
-
- }
- }
- }
- //////////text
- glDisable(GL_BLEND);
- SwapBuffers(hDC);
- }
- }
- // Shutdown
- DeletePicture(pMainMenu);
- DeletePicture(pItemDown);
- DeletePicture(pItemOn);
- }
- /////////////////////////////////////////////////
- void CMenu::DoExitMenu()
- {
- m_bExit=true;
- GameReturn=100;
- }
- /////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////
- void CMenu::DeletePicture(AUX_RGBImageRec *pData)
- {
- if (pData) { // If Texture Exists
- if (pData->data) delete pData->data; // If Texture Image Exists
- delete pData;
- }
- }
- bool CMenu::LoadPicture(char* filename,AUX_RGBImageRec *pData)
- {
- pData=auxDIBImageLoad(filename);
- if(!pData) return false;
- return true;
- }
- void CMenu::DrawPicture(int xpos,int ypos,AUX_RGBImageRec *pData)
- {
- glRasterPos3i(xpos-400,300-ypos,-300);
- glDrawPixels(pData->sizeX,pData->sizeY,GL_RGB,GL_UNSIGNED_BYTE,pData->data);
- }