| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <tchar.h>
- #pragma hdrstop
- #include "fGameMenuC.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "GLS.BaseClasses"
- #pragma link "GLS.BitmapFont"
- #pragma link "GLS.Cadencer"
- #pragma link "GLS.Coordinates"
- #pragma link "GLS.Material"
- #pragma link "GLS.Objects"
- #pragma link "GLS.Scene"
- #pragma link "GLS.SceneViewer"
- #pragma link "GLS.WindowsFont"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- TFileName Path = GetCurrentAssetPath() + "\\texture\\";
- SetCurrentDir(Path);
- GLMaterialLibrary1->Materials->Items[0]->Material->Texture->Image->LoadFromFile("GLScene.bmp");
- GameMenu = (TGLGameMenu *)GLScene1->Objects->AddNewChild(__classid(TGLGameMenu));
- GameMenu->MaterialLibrary = GLMaterialLibrary1;
- GameMenu->TitleMaterialName = "LibMaterial";
- GameMenu->TitleHeight = 80;
- GameMenu->TitleWidth = 200;
- GameMenu->Font = GLWindowsBitmapFont1;
- GameMenu->Items->Add("test line 1");
- GameMenu->Items->Add("test line 2");
- GameMenu->Items->Add("test line 3");
- GameMenu->Items->Add("test line 4");
- GameMenu->Items->Add("test line 5");
- GameMenu->Items->Add("test line 6");
- GameMenu->Spacing = 1;
- GameMenu->Selected = 0;
- GameMenu->Position->Y = 200;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
- {
- if (IsKeyDown('w') || IsKeyDown('W') || IsKeyDown(VK_UP))
- GameMenu->SelectPrev();
- if (IsKeyDown('s') || IsKeyDown('S') || IsKeyDown(VK_DOWN))
- GameMenu->SelectNext();
- if (IsKeyDown(VK_RETURN))
- {
- if (GameMenu->Selected != -1)
- ShowMessage("You have selected option: " + GameMenu->SelectedText);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
- const double newTime)
- {
- GLSceneViewer1->Invalidate();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::GLSceneViewer1MouseMove(TObject *Sender, TShiftState Shift,
- int X, int Y)
- {
- GameMenu->MouseMenuSelect(X, Y);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::GLSceneViewer1MouseDown(TObject *Sender, TMouseButton Button,
- TShiftState Shift, int X, int Y)
- {
- GameMenu->MouseMenuSelect(X, Y);
- if (GameMenu->Selected != -1)
- ShowMessage("You have selected option: " + GameMenu->SelectedText);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::ShowTitleCheckboxClick(TObject *Sender)
- {
- if (GameMenu->TitleHeight == 0)
- GameMenu->TitleHeight = 80;
- else
- GameMenu->TitleHeight = 0;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::MainPanelResize(TObject *Sender)
- {
- GameMenu->Position->X = MainPanel->Width / 2;
- }
|