NewGameSheet.cpp
上传用户:hkb425
上传日期:2007-06-16
资源大小:34191k
文件大小:3k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. // NewGameSheet.cpp: implementation of the CNewGameSheet class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "NewGameSheet.h"
  6. #include "texmanager.h"
  7. //////////////////////////////////////////////////////////////////////
  8. // Construction/Destruction
  9. //////////////////////////////////////////////////////////////////////
  10. CNewGameSheet::CNewGameSheet()
  11. {
  12. }
  13. CNewGameSheet::~CNewGameSheet()
  14. {
  15. }
  16. bool CNewGameSheet::InitSheet()
  17. {
  18. /////////////////Button
  19. RECT rect;
  20. rect.top=555;
  21. rect.bottom=585;
  22. for(int i=0;i<3;i++)
  23. {
  24. rect.left=50+i*250;
  25. rect.right=250+i*250;
  26.     m_cButton[i].SetButtonRect(rect);
  27. }
  28.     m_cButton[0].SetButtonText("Back");
  29. m_cButton[1].SetButtonText("Game Setting");
  30. m_cButton[2].SetButtonText("Start Game");
  31. //////////////////// m_cMissionListBox
  32. rect.left=30;
  33. rect.right=380;
  34. rect.top=70;
  35. rect.bottom=200;
  36. m_cMissionSelectBox.SetSelectBox(rect,"mission/missionlist.txt");
  37. ///////////////// sketch view
  38. rect.left=35;
  39. rect.right=375;
  40. rect.top=245;
  41. rect.bottom=495;
  42. unsigned int texid[6];
  43. CTexManager cTexManager;
  44. texid[0]=cTexManager.GetTextureID(TEX_MISSION_SKETCH_0);
  45. texid[1]=cTexManager.GetTextureID(TEX_MISSION_SKETCH_1);
  46. texid[2]=cTexManager.GetTextureID(TEX_MISSION_SKETCH_2);
  47. texid[3]=cTexManager.GetTextureID(TEX_MISSION_SKETCH_3);
  48. texid[4]=cTexManager.GetTextureID(TEX_MISSION_SKETCH_4);
  49. texid[5]=cTexManager.GetTextureID(TEX_MISSION_SKETCH_5);
  50. m_cSketchBar.SetChangeBar(rect,texid,6,0);
  51.     
  52. /////////////////// m_cMissionViewBox
  53. rect.left=405;
  54. rect.right=770;
  55. rect.top=70;
  56. rect.bottom=520;
  57. m_cMissionViewBox.SetViewBox(rect,"Mission/missionScript1.txt");
  58. ///////////////////////////////////
  59.     m_bActive=false;
  60. m_iSelect=-1;
  61. return true;
  62. }
  63. int  CNewGameSheet::RenderSheet()
  64. {
  65. if(!m_bActive)return -1;
  66. UpdateSheet();
  67. DrawBackground();
  68. for(int i=0;i<3;i++)
  69. {
  70.     m_cButton[i].RenderButton();
  71. }
  72. /////////////////////////////
  73. m_cMissionSelectBox.RenderSelectBox();
  74. m_cSketchBar.RenderChangeBar();
  75. m_cMissionViewBox.RenderViewBox();
  76. for(i=0;i<3;i++)
  77. {
  78.     if(m_cButton[i].m_bSelected)
  79. {
  80. m_cButton[i].m_bSelected=false;
  81. m_iSelect=i;
  82. return i;
  83. }
  84. return -1;
  85. }
  86. void CNewGameSheet::UpdateSheet()
  87. {
  88. if(CInput::m_keys[VK_ESCAPE])
  89. {
  90. CInput::m_keys[VK_ESCAPE]=false;
  91. m_iSelect=0;
  92. return ;
  93. }
  94. if(CInput::m_keys[13]) // key enter pressed
  95. {
  96. CInput::m_keys[13]=false;
  97. m_iSelect=2;
  98. return ;
  99. }
  100. if(m_cMissionSelectBox.m_bValueChanged)
  101. {
  102. int select=m_cMissionSelectBox.GetSelect();
  103. m_cSketchBar.SetItem((select*2)%m_cSketchBar.GetTotalItemNumber());
  104.     char filename[64];
  105. wsprintf(filename,"Mission/missionScript%d.txt",select+1);
  106. m_cMissionViewBox.SetText(filename);
  107. }
  108. }
  109. int CNewGameSheet::GetMissionSelect()
  110. {
  111.     return m_cMissionSelectBox.GetSelect();
  112. }
  113. void CNewGameSheet::DrawBackground()
  114. {
  115. CImgText cText;
  116. glColor3f(1,1,0);
  117. cText.PrintString(20,20,"Mission Select",0,24,0);
  118. glColor3f(0,0.7f,0);
  119. ////////////////
  120. int x0=10,x1=800-x0;
  121. int y0=50,y1=540;
  122.     DrawRectangle( x0, x1, y0, y1);  //  All
  123.     x0=30;  x1=380;
  124. y0=220;  y1=520;
  125.     DrawRectangle( x0, x1, y0, y1);  //  down
  126. }
  127. void CNewGameSheet::DrawRectangle(int x0,int x1,int y0,int y1)
  128. {
  129. glBegin(GL_LINE_LOOP);
  130. glVertex3i(x0-400,300-y0,-520);
  131. glVertex3i(x1-400,300-y0,-520);
  132. glVertex3i(x1-400,300-y1,-520);
  133. glVertex3i(x0-400,300-y1,-520);
  134.     glEnd();
  135. }