fGameMenuC.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "fGameMenuC.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLS.BaseClasses"
  9. #pragma link "GLS.BitmapFont"
  10. #pragma link "GLS.Cadencer"
  11. #pragma link "GLS.Coordinates"
  12. #pragma link "GLS.Material"
  13. #pragma link "GLS.Objects"
  14. #pragma link "GLS.Scene"
  15. #pragma link "GLS.SceneViewer"
  16. #pragma link "GLS.WindowsFont"
  17. #pragma resource "*.dfm"
  18. TForm1 *Form1;
  19. //---------------------------------------------------------------------------
  20. __fastcall TForm1::TForm1(TComponent* Owner)
  21. : TForm(Owner)
  22. {
  23. }
  24. //---------------------------------------------------------------------------
  25. void __fastcall TForm1::FormCreate(TObject *Sender)
  26. {
  27. TFileName Path = GetCurrentAssetPath() + "\\texture\\";
  28. SetCurrentDir(Path);
  29. GLMaterialLibrary1->Materials->Items[0]->Material->Texture->Image->LoadFromFile("GLScene.bmp");
  30. GameMenu = (TGLGameMenu *)GLScene1->Objects->AddNewChild(__classid(TGLGameMenu));
  31. GameMenu->MaterialLibrary = GLMaterialLibrary1;
  32. GameMenu->TitleMaterialName = "LibMaterial";
  33. GameMenu->TitleHeight = 80;
  34. GameMenu->TitleWidth = 200;
  35. GameMenu->Font = GLWindowsBitmapFont1;
  36. GameMenu->Items->Add("test line 1");
  37. GameMenu->Items->Add("test line 2");
  38. GameMenu->Items->Add("test line 3");
  39. GameMenu->Items->Add("test line 4");
  40. GameMenu->Items->Add("test line 5");
  41. GameMenu->Items->Add("test line 6");
  42. GameMenu->Spacing = 1;
  43. GameMenu->Selected = 0;
  44. GameMenu->Position->Y = 200;
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
  48. {
  49. if (IsKeyDown('w') || IsKeyDown('W') || IsKeyDown(VK_UP))
  50. GameMenu->SelectPrev();
  51. if (IsKeyDown('s') || IsKeyDown('S') || IsKeyDown(VK_DOWN))
  52. GameMenu->SelectNext();
  53. if (IsKeyDown(VK_RETURN))
  54. {
  55. if (GameMenu->Selected != -1)
  56. ShowMessage("You have selected option: " + GameMenu->SelectedText);
  57. }
  58. }
  59. //---------------------------------------------------------------------------
  60. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  61. const double newTime)
  62. {
  63. GLSceneViewer1->Invalidate();
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TForm1::GLSceneViewer1MouseMove(TObject *Sender, TShiftState Shift,
  67. int X, int Y)
  68. {
  69. GameMenu->MouseMenuSelect(X, Y);
  70. }
  71. //---------------------------------------------------------------------------
  72. void __fastcall TForm1::GLSceneViewer1MouseDown(TObject *Sender, TMouseButton Button,
  73. TShiftState Shift, int X, int Y)
  74. {
  75. GameMenu->MouseMenuSelect(X, Y);
  76. if (GameMenu->Selected != -1)
  77. ShowMessage("You have selected option: " + GameMenu->SelectedText);
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TForm1::ShowTitleCheckboxClick(TObject *Sender)
  81. {
  82. if (GameMenu->TitleHeight == 0)
  83. GameMenu->TitleHeight = 80;
  84. else
  85. GameMenu->TitleHeight = 0;
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TForm1::MainPanelResize(TObject *Sender)
  89. {
  90. GameMenu->Position->X = MainPanel->Width / 2;
  91. }