2018-05-30 11:21:50 +00:00
|
|
|
|
#define GALAXY_MENU_MODE
|
|
|
|
|
|
|
|
|
|
#ifdef GALAXY_MENU_MODE // === GALAX MENU MODE ===
|
|
|
|
|
#define GALAX_MENU_DRAW
|
|
|
|
|
#define GALAX_MENU_UPDATE
|
|
|
|
|
#endif // === GALAX MENU MODE ===
|
|
|
|
|
|
2017-01-10 12:43:06 +00:00
|
|
|
|
#include "menucode.h"
|
|
|
|
|
#include "main_code.h"
|
|
|
|
|
|
2018-03-30 11:16:49 +00:00
|
|
|
|
|
2017-01-10 12:43:06 +00:00
|
|
|
|
const float CONST_SPEED_NEG_ACCELERATION_K = 0.03f;
|
|
|
|
|
|
|
|
|
|
const float CONST_MENU_POS_K = 0.25f;
|
|
|
|
|
|
|
|
|
|
const float CONST_MENU_WINDOW_DISTANCE = 240.f + 40.f;
|
|
|
|
|
|
|
|
|
|
const float CONST_SHIFT_ON_SIDE = 0.f;
|
|
|
|
|
|
|
|
|
|
TGameMenu::TGameMenu()
|
|
|
|
|
: MenuSpeed(0)
|
|
|
|
|
, MenuPos(0)
|
|
|
|
|
, HoldToTap(false)
|
|
|
|
|
, MenuItemCount(1)
|
|
|
|
|
, SelectedGame(-1)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TGameMenu::Draw()
|
|
|
|
|
{
|
2017-11-14 17:04:04 +00:00
|
|
|
|
// *SE::Console << "TGameMenu::Draw";
|
2017-01-10 12:43:06 +00:00
|
|
|
|
CheckGlError("Draw TGameMenu");
|
|
|
|
|
RenderUniform1i("sel", 0);
|
|
|
|
|
RenderUniform1f("Transparency", 1.f);
|
|
|
|
|
float bkgShift = MenuPos*0.1f - 100.f;
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#ifndef GALAX_MENU_DRAW
|
2017-01-10 12:43:06 +00:00
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_left"]);
|
2018-03-21 12:55:54 +00:00
|
|
|
|
Renderer->DrawRect(Vector2f(bkgShift,0.f), Vector2f(Renderer->GetScreenWidth()+bkgShift,Renderer->GetScreenHeight()));
|
2017-01-10 12:43:06 +00:00
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_right"]);
|
2018-03-21 12:55:54 +00:00
|
|
|
|
Renderer->DrawRect(Vector2f(Renderer->GetScreenWidth()+bkgShift,0.f), Vector2f(960.f+bkgShift,Renderer->GetScreenHeight()));
|
2018-05-24 11:44:58 +00:00
|
|
|
|
#else
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
2018-05-24 11:44:58 +00:00
|
|
|
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
2018-05-24 11:44:58 +00:00
|
|
|
|
/*..GalaxMenu draw..*/
|
|
|
|
|
GalaxMenu.DrawGalaxyMenu();
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#ifndef GALAX_MENU_DRAW
|
2017-01-10 12:43:06 +00:00
|
|
|
|
if (SelectedGame == 0)
|
|
|
|
|
{
|
|
|
|
|
RenderUniform1i("sel", 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RenderUniform1i("sel", 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<MenuItemCount; i++)
|
|
|
|
|
{
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["levelshot"+tostr(i+1)]);
|
2017-11-14 17:04:04 +00:00
|
|
|
|
Renderer->DrawRect(Vector2f(160.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*i,80.f), Vector2f(160.f+240.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*i, 240.f));
|
2017-01-10 12:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (MenuItemCount == 12)
|
|
|
|
|
{
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["game_end"]);
|
2017-11-14 17:04:04 +00:00
|
|
|
|
Renderer->DrawRect(Vector2f(160.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*12,160.f - 64.f), Vector2f(160.f+256.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*12, 160.f + 64.f));
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["select_level"]);
|
2017-11-14 17:04:04 +00:00
|
|
|
|
Renderer->DrawRect(Vector2f(240.f-128.f, 241.f), Vector2f(240.f+128.f, 305.f));
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["logo_small"]);
|
2017-11-14 17:04:04 +00:00
|
|
|
|
Renderer->DrawRect(Vector2f(240.f-128.f+15.f, 0.f), Vector2f(240.f+128.f+15.f, 64.f));
|
2018-05-24 11:44:58 +00:00
|
|
|
|
#endif
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
|
|
CheckGlError("Draw TGameMenu 2");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
|
void TGameMenu::Update(size_t dt)
|
2017-01-10 12:43:06 +00:00
|
|
|
|
{
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#ifdef GALAX_MENU_UPDATE
|
2018-05-24 11:44:58 +00:00
|
|
|
|
/*..Galaxy Menu..*/
|
2018-05-25 11:51:26 +00:00
|
|
|
|
GalaxMenu.InteractWithGalaxy(dt);
|
2018-10-17 03:59:08 +00:00
|
|
|
|
//GalaxMenu.UpdateGalaxyMenu((float)SE::Renderer->GetScreenWidth(), (float)SE::Renderer->GetScreenHeight(), dt);
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#else
|
2017-01-10 12:43:06 +00:00
|
|
|
|
if (HoldToTap)
|
|
|
|
|
return;
|
2017-11-14 17:04:04 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2017-01-10 12:43:06 +00:00
|
|
|
|
float k;
|
|
|
|
|
|
|
|
|
|
MenuPos = MenuPos + MenuSpeed*dt/1000.f;
|
2017-11-14 17:04:04 +00:00
|
|
|
|
|
2017-01-10 12:43:06 +00:00
|
|
|
|
int menuItemToShowCount;
|
|
|
|
|
|
|
|
|
|
if (MenuItemCount == 12)
|
|
|
|
|
{
|
|
|
|
|
menuItemToShowCount = 13;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
menuItemToShowCount = MenuItemCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float acc;
|
|
|
|
|
|
|
|
|
|
if (MenuItemCount == 1)
|
|
|
|
|
{
|
|
|
|
|
k = 3;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
k = fabs( - MenuPos - ((menuItemToShowCount-1)*CONST_MENU_WINDOW_DISTANCE*0.5f)) / ((MenuItemCount-1)*CONST_MENU_WINDOW_DISTANCE*0.5f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
acc = -MenuSpeed * CONST_SPEED_NEG_ACCELERATION_K * k;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float xleft = (- MenuPos + CONST_SHIFT_ON_SIDE - (menuItemToShowCount-1)*CONST_MENU_WINDOW_DISTANCE);
|
|
|
|
|
|
|
|
|
|
if (xleft < 0)
|
|
|
|
|
{
|
|
|
|
|
xleft = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
acc += xleft*CONST_MENU_POS_K;
|
|
|
|
|
|
|
|
|
|
float xright = (MenuPos - CONST_SHIFT_ON_SIDE);
|
|
|
|
|
|
|
|
|
|
if (xright < 0)
|
|
|
|
|
{
|
|
|
|
|
xright = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
acc -= xright*CONST_MENU_POS_K;
|
|
|
|
|
|
|
|
|
|
if ((MenuSpeed + acc*dt) * MenuSpeed < 0) //Check if MenuSpeed changes direction
|
|
|
|
|
{
|
|
|
|
|
MenuSpeed = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MenuSpeed += acc*dt;
|
|
|
|
|
}
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#endif
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
|
void TGameMenu::OnTapDown(Vector2f pos)
|
2017-01-10 12:43:06 +00:00
|
|
|
|
{
|
2018-07-14 11:53:59 +00:00
|
|
|
|
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#ifndef GALAX_MENU_UPDATE
|
2017-02-26 23:07:37 +00:00
|
|
|
|
HoldToTap = true;
|
2018-03-30 11:16:49 +00:00
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
|
if (pos(1)<64.f && pos(0)>=265.f-128.f && pos(0)<=265.f+128.f)
|
2017-01-10 12:43:06 +00:00
|
|
|
|
{
|
|
|
|
|
Application->GoFromMenuToCredits();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-11-14 17:04:04 +00:00
|
|
|
|
|
|
|
|
|
Vector2f realPos = pos - Vector2f(MenuPos, 0);
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
|
if (realPos(1) >= 80.f && realPos(1) <= 240.f)
|
2017-01-10 12:43:06 +00:00
|
|
|
|
{
|
2017-11-14 17:04:04 +00:00
|
|
|
|
float x = realPos(0) - 160.f;
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
|
|
int p = 0;
|
|
|
|
|
while (x >280.f)
|
|
|
|
|
{
|
|
|
|
|
x -= 280.f;
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (x <= 240.f && x >= 0.f && (p<MenuItemCount))
|
|
|
|
|
{
|
|
|
|
|
SelectedGame = p;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SelectedGame = -1;
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#endif
|
2017-01-10 12:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
|
void TGameMenu::OnTapUp(Vector2f pos)
|
2017-01-10 12:43:06 +00:00
|
|
|
|
{
|
2018-07-14 11:53:59 +00:00
|
|
|
|
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#ifndef GALAX_MENU_UPDATE
|
2017-01-10 12:43:06 +00:00
|
|
|
|
HoldToTap = false;
|
2018-03-30 11:16:49 +00:00
|
|
|
|
|
2017-01-10 12:43:06 +00:00
|
|
|
|
if (SelectedGame != -1)
|
|
|
|
|
{
|
|
|
|
|
MenuPos = -CONST_MENU_WINDOW_DISTANCE*SelectedGame-40.f;
|
|
|
|
|
Application->GoFromMenuToGame(SelectedGame);
|
|
|
|
|
SelectedGame = -1;
|
|
|
|
|
}
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#endif
|
2017-01-10 12:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
|
void TGameMenu::OnTapUpAfterMove(Vector2f pos)
|
2017-02-26 23:07:37 +00:00
|
|
|
|
{
|
|
|
|
|
HoldToTap = false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
|
void TGameMenu::OnFling(Vector2f slideSpeed)
|
2017-01-10 12:43:06 +00:00
|
|
|
|
{
|
2018-07-14 11:53:59 +00:00
|
|
|
|
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#ifndef GALAX_MENU_UPDATE
|
2017-01-10 12:43:06 +00:00
|
|
|
|
HoldToTap = false;
|
2017-11-14 17:04:04 +00:00
|
|
|
|
MenuSpeed = slideSpeed(0);
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#endif
|
2017-01-10 12:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
|
void TGameMenu::OnScroll(Vector2f shift)
|
2017-01-10 12:43:06 +00:00
|
|
|
|
{
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#ifndef GALAX_MENU_UPDATE
|
2017-11-14 17:04:04 +00:00
|
|
|
|
MenuPos = MenuPos - shift(0);
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#endif
|
2017-01-10 12:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TGameMenu::OpenNextLevel()
|
|
|
|
|
{
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#ifndef GALAX_MENU_UPDATE
|
2017-01-10 12:43:06 +00:00
|
|
|
|
if (MenuItemCount < 12)
|
|
|
|
|
{
|
|
|
|
|
MenuItemCount++;
|
|
|
|
|
}
|
2018-05-30 11:21:50 +00:00
|
|
|
|
#endif
|
2017-01-10 12:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TGameMenu::GetMenuItemCount()
|
|
|
|
|
{
|
|
|
|
|
return MenuItemCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TGameMenu::SetMenuItemCount(int menuItemCount)
|
|
|
|
|
{
|
|
|
|
|
MenuItemCount = menuItemCount;
|
|
|
|
|
}
|