start menu is now working

This commit is contained in:
Alexander Tvorogov 2018-05-30 16:21:50 +05:00
parent 82812eecb0
commit c8d69040b3
24 changed files with 281 additions and 63 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1000 KiB

After

Width:  |  Height:  |  Size: 720 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 615 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1000 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1022 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 KiB

View File

@ -27,6 +27,9 @@
{ {
"name": "level_1" "name": "level_1"
}, },
{
"name": "level_1"
},
{ {
"name": "level_1" "name": "level_1"
} }
@ -35,12 +38,15 @@
{ {
"name": "star_0_1", "name": "star_0_1",
"position": { "position": {
"x_coord": 0.35, "x_coord": 0.28,
"y_coord": 0.25 "y_coord": 0.31
}, },
"texture": "star_0_1.png", "texture": "star_0_1.png",
"scale": 0.18, "scale": 0.18,
"levels": [ "levels": [
{
"name": "level_1"
},
{ {
"name": "level_1" "name": "level_1"
} }
@ -55,6 +61,24 @@
"texture": "star_0_2.png", "texture": "star_0_2.png",
"scale": 0.12, "scale": 0.12,
"levels": [ "levels": [
{
"name": "level_1"
},
{
"name": "level_1"
},
{
"name": "level_1"
},
{
"name": "level_1"
},
{
"name": "level_1"
},
{
"name": "level_1"
},
{ {
"name": "level_1" "name": "level_1"
} }

View File

@ -1,5 +1,6 @@
#include "galaxy_menu.h" #include "galaxy_menu.h"
#include "main_code.h"
#include <algorithm> #include <algorithm>
#include <math.h> #include <math.h>
@ -162,16 +163,16 @@ void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
float x_rpos = (galaxies[i].Stars[j].selectionMenu.border_x_offset + (y - floor((float)y / (float)galaxies[i].Stars[j].selectionMenu.columns)*(float)galaxies[i].Stars[j].selectionMenu.columns)*(button_x_dim + galaxies[i].Stars[j].selectionMenu.buttons_offset) + button_x_dim/2); float x_rpos = (galaxies[i].Stars[j].selectionMenu.border_x_offset + (y - floor((float)y / (float)galaxies[i].Stars[j].selectionMenu.columns)*(float)galaxies[i].Stars[j].selectionMenu.columns)*(button_x_dim + galaxies[i].Stars[j].selectionMenu.buttons_offset) + button_x_dim/2);
//float y_rpos = (/**/ galaxies[i].Stars[j].selectionMenu.border_y_offset + (floor((float)y / (float)galaxies[i].Stars[j].selectionMenu.columns))*(/*..*/ galaxies[i].Stars[j].selectionMenu.buttons_offset + button_x_dim / galaxies[i].Stars[j].selectionMenu.buttons_ratio /*..*/) + button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio/2 /**/); //float y_rpos = (/**/ galaxies[i].Stars[j].selectionMenu.border_y_offset + (floor((float)y / (float)galaxies[i].Stars[j].selectionMenu.columns))*(/*..*/ galaxies[i].Stars[j].selectionMenu.buttons_offset + button_x_dim / galaxies[i].Stars[j].selectionMenu.buttons_ratio /*..*/) + button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio/2 /**/);
float y_rpos = (galaxies[i].Stars[j].selectionMenu.border_y_offset + ((int)floor(((float)y)/((float)galaxies[i].Stars[j].selectionMenu.columns)))*(button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio) + (((int)floor(((float)y) / ((float)galaxies[i].Stars[j].selectionMenu.columns)))-1) * galaxies[i].Stars[j].selectionMenu.border_y_offset + ((button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio)/2.f)); float y_rpos = (galaxies[i].Stars[j].selectionMenu.border_y_offset + ((int)floor(((float)y)/((float)galaxies[i].Stars[j].selectionMenu.columns)))*(button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio) + (((int)floor(((float)y) / ((float)galaxies[i].Stars[j].selectionMenu.columns)))) * galaxies[i].Stars[j].selectionMenu.border_y_offset + ((button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio)/2.f));
buttons_params[y] = std::make_pair( buttons_params[y] = std::make_pair(
Eigen::Vector2f( Eigen::Vector2f(
(galaxies[i].Stars[j].selectionMenu.buttons_plane.first(0) - galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)/2) + galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)*x_rpos, (galaxies[i].Stars[j].selectionMenu.buttons_plane.first(0) - galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)/2) + galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)*x_rpos,
(galaxies[i].Stars[j].selectionMenu.buttons_plane.first(1) + galaxies[i].Stars[j].selectionMenu.buttons_plane.second(1)/2) - galaxies[i].Stars[j].selectionMenu.buttons_plane.second(1)*y_rpos (galaxies[i].Stars[j].selectionMenu.buttons_plane.first(1) + galaxies[i].Stars[j].selectionMenu.buttons_plane.second(1)/2) - galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)*y_rpos
), ),
Eigen::Vector2f( Eigen::Vector2f(
button_x_dim*galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0), button_x_dim*galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0),
(button_x_dim / galaxies[i].Stars[j].selectionMenu.buttons_ratio)*galaxies[i].Stars[j].selectionMenu.buttons_plane.second(1) (button_x_dim / galaxies[i].Stars[j].selectionMenu.buttons_ratio)*galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)
) )
); );
@ -246,7 +247,12 @@ void GalaxyMenu::DrawGalaxyMenu() {
/*..Draw stars..*/ /*..Draw stars..*/
if (stars_params.size() >= i) { if (stars_params.size() >= i) {
for (int j = 0; j < stars_params[i].size(); j++) { for (int j = 0; j < stars_params[i].size(); j++) {
if (planetHoverIndex == j) {
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["star_" + std::to_string(i) + "_" + std::to_string(j) + "_hover"]);
}
else {
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["star_" + std::to_string(i) + "_" + std::to_string(j)]); glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["star_" + std::to_string(i) + "_" + std::to_string(j)]);
}
SE::Renderer->DrawRect( SE::Renderer->DrawRect(
Eigen::Vector2f( Eigen::Vector2f(
stars_params[i][j].first(0) - stars_params[i][j].second(0) / 2, stars_params[i][j].first(0) - stars_params[i][j].second(0) / 2,
@ -261,7 +267,8 @@ void GalaxyMenu::DrawGalaxyMenu() {
} }
/*..Draw level selection menu..*/ /*..Draw level selection menu..*/
drawSelectionMenu(0); drawSelectionMenu(starIndex);
} }
} }
@ -270,22 +277,51 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
if (timer_active) { if (timer_active) {
// ::::::::::::: timer active :::::::::::::: // ::::::::::::: timer active ::::::::::::::
if (menuState == 0) { // main view if (menuState == 0) { // main view
if (currentTapShift(0) == 0.f && currentTapShift(1) == 0.f) { //if (currentTapShift(0) == 0.f && currentTapShift(1) == 0.f) {
if (currentTapShift(0) == totalTapShift(0) && currentTapShift(1) == totalTapShift(1)) {
// OnTapDown-> // OnTapDown->
//int y = findGalaxyByPos(Eigen::Vector2f());
/*../hover\..*/
int phi = findPlanetByPos(lastTapPos - totalTapShift);
if (phi != -1) {
planetHoverIndex = phi;
}
else {
planetHoverIndex = -1;
}
/*..\hover/..*/
} }
else { else {
// OnTapDown->OnMove-> // OnTapDown->OnMove->
totalTapShift = Eigen::Vector2f(totalTapShift(0) + currentTapShift(0), totalTapShift(1) + currentTapShift(1)); //totalTapShift = Eigen::Vector2f(totalTapShift(0) + currentTapShift(0), totalTapShift(1) + currentTapShift(1));
/*../hover\..*/
int phi = findPlanetByPos(lastTapPos - totalTapShift);
if (phi != -1) {
planetHoverIndex = phi;
}
else {
planetHoverIndex = -1;
}
/*..\hover/..*/
} }
} }
if (menuState == 1) { // zoomed galaxy else if (menuState == 1) { // zoomed galaxy
} }
if (menuState == 2) { // level select view else if (menuState == 2) { // level select view
//if (currentTapShift(0) == 0.f && currentTapShift(1) == 0.f) {
if (currentTapShift(0) == totalTapShift(0) && currentTapShift(1) == totalTapShift(1)) {
// OnTapDown->
} }
else {
// OnTapDown->OnMove->
//totalTapShift = Eigen::Vector2f(totalTapShift(0) + currentTapShift(0), totalTapShift(1) + currentTapShift(1));
}
}
// \_/\_/\_/\_/ timer active \_/\_/\_/\_/ // \_/\_/\_/\_/ timer active \_/\_/\_/\_/
} }
@ -296,21 +332,35 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) { if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) {
// OnTapDown->OnTapUp // OnTapDown->OnTapUp
int y = findPlanetByPos(lastTapPos); /*..level select menu open..*/
if (y != -1) { starIndex = findPlanetByPos(lastTapPos);
/*..level selec menu open..*/ if (starIndex != -1) {
planetHoverIndex = starIndex;
menuState = 2;
}
else {
planetHoverIndex = -1;
} }
} }
else { else {
// OnTapDown->OnMove->OnTapUp // OnTapDown->OnMove->OnTapUp
/*..level select menu open..*/
starIndex = findPlanetByPos(lastTapPos - totalTapShift);
if (starIndex != -1) {
planetHoverIndex = starIndex;
menuState = 2;
}
else {
planetHoverIndex = -1;
} }
} }
if (menuState == 1) { // zoomed galaxy
if ((currentTapShift(0) == 0.f) && (currentTapShift(1) == 0.f)) { }
else if (menuState == 1) { // zoomed galaxy
if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) {
// OnTapDown->OnTapUp // OnTapDown->OnTapUp
} }
@ -320,10 +370,25 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
} }
} }
if (menuState == 2) { // level select view else if (menuState == 2) { // level select view
if ((currentTapShift(0) == 0.f) && (currentTapShift(1) == 0.f)) { if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) {
// OnTapDown->OnTapUp // OnTapDown->OnTapUp
int lvl = findLevelButtonByPos(lastTapPos);
if (lvl != -1) {
// then if level is available, load it
starIndex = -1;
menuState = 0;
planetHoverIndex = -1;
Application->GoFromMenuToGame(lvl);
}
else if (!checkMenuBound(lastTapPos)) {
// back to state 0
starIndex = -1;
menuState = 0;
planetHoverIndex = -1;
}
} }
else { else {
// OnTapDown->OnMove->OnTapUp // OnTapDown->OnMove->OnTapUp
@ -365,7 +430,8 @@ void GalaxyMenu::tapUp(Eigen::Vector2f pos) {
void GalaxyMenu::tapMove(Eigen::Vector2f shift) { void GalaxyMenu::tapMove(Eigen::Vector2f shift) {
if (timer_active) { if (timer_active) {
//*SE::Console << "shift = " + std::to_string(shift(0)) + " " + std::to_string(shift(1)); // mt issue //*SE::Console << "shift = " + std::to_string(shift(0)) + " " + std::to_string(shift(1)); // mt issue
currentTapShift = shift; // shift need to be fixed //currentTapShift = shift; // shift need to be fixed
totalTapShift += shift;
} }
} }
@ -490,17 +556,24 @@ int GalaxyMenu::findPlanetByPos(Eigen::Vector2f pos) {
} }
} }
return -1; return -1;
}
void GalaxyMenu::showLevelSelectMenu(int index) {
} }
void GalaxyMenu::drawSelectionMenu(int index) { void GalaxyMenu::drawSelectionMenu(int index) {
int i = index; int i = index;
if (i != -1) { if (i != -1) {
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["matte_screen"]);
SE::Renderer->DrawRect(
Eigen::Vector2f(
0.f,
0.f
),
Eigen::Vector2f(
(float)SE::Renderer->GetScreenWidth(),
(float)SE::Renderer->GetScreenHeight()
)
); // DrawRect
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["red_square"]); glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["red_square"]);
SE::Renderer->DrawRect( SE::Renderer->DrawRect(
Eigen::Vector2f( Eigen::Vector2f(
@ -513,6 +586,20 @@ void GalaxyMenu::drawSelectionMenu(int index) {
) )
); // DrawRect ); // DrawRect
/*..border..*/
drawBorder(
Eigen::Vector2f(
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(0) - galaxies[0].Stars[i].selectionMenu.buttons_plane.second(0) / 2,
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(1) - galaxies[0].Stars[i].selectionMenu.buttons_plane.second(1) / 2
),
Eigen::Vector2f(
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(0) + galaxies[0].Stars[i].selectionMenu.buttons_plane.second(0) / 2,
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(1) + galaxies[0].Stars[i].selectionMenu.buttons_plane.second(1) / 2
),
0.005f,
"outer" /*..inner/outer/center..mode */
);
// buttons // buttons
for (int j = 0; j < galaxies[0].Stars[i].selectionMenu.buttons.size(); j++) { for (int j = 0; j < galaxies[0].Stars[i].selectionMenu.buttons.size(); j++) {
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["black_square"]); glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["black_square"]);
@ -529,17 +616,100 @@ void GalaxyMenu::drawSelectionMenu(int index) {
} }
} }
/* }
// debug
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["red_square"]); int GalaxyMenu::findLevelButtonByPos(Eigen::Vector2f pos) {
SE::Renderer->DrawRect( for (int i = 0; i < galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons.size(); i++) {
Eigen::Vector2f( float x_l = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f;
galaxies[0].Stars[0].selectionMenu.params.first(0) - galaxies[0].Stars[0].selectionMenu.params.second(0) / 2, float x_r = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f;
galaxies[0].Stars[0].selectionMenu.params.first(1) - galaxies[0].Stars[0].selectionMenu.params.second(1) / 2 float y_t = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(1) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(1)*0.5f;
), float y_b = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(1) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(1)*0.5f;
Eigen::Vector2f(
galaxies[0].Stars[0].selectionMenu.params.first(0) + galaxies[0].Stars[0].selectionMenu.params.second(0) / 2, if (pos(0) >= x_l && pos(0) <= x_r) {
galaxies[0].Stars[0].selectionMenu.params.first(1) + galaxies[0].Stars[0].selectionMenu.params.second(1) / 2 if (pos(1) >= y_b && pos(1) <= y_t) {
)); return i;
*/ }
}
}
return -1;
}
bool GalaxyMenu::checkMenuBound(Eigen::Vector2f pos) {
float x_l = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.first(0) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.second(0)*0.5f;
float x_r = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.first(0) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.second(0)*0.5f;
float y_t = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.first(1) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.second(1)*0.5f;
float y_b = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.first(1) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.second(1)*0.5f;
if (pos(0) >= x_l && pos(0) <= x_r) {
if (pos(1) >= y_b && pos(1) <= y_t) {
return true;
}
}
return false;
}
void GalaxyMenu::drawBorder(Eigen::Vector2f lb_, Eigen::Vector2f rt_, float scale, std::string mode) {
std::string border_tex = "black_square";
float width = rt_(0) - lb_(0);
float height = rt_(1) - lb_(1);
if (mode.compare("inner") == 0) {
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList[border_tex]);
SE::Renderer->DrawRect(
Eigen::Vector2f(lb_(0), lb_(1)),
Eigen::Vector2f(lb_(0) + width*scale, rt_(1))
); // left
SE::Renderer->DrawRect(
Eigen::Vector2f(lb_(0), rt_(1) - width*scale),
Eigen::Vector2f(rt_(0), rt_(1))
); // top
SE::Renderer->DrawRect(
Eigen::Vector2f(rt_(0) - width*scale, lb_(1)),
Eigen::Vector2f(rt_(0), rt_(1))
); // right
SE::Renderer->DrawRect(
Eigen::Vector2f(lb_(0), lb_(1)),
Eigen::Vector2f(rt_(0), lb_(1) + width*scale)
); // bottom
}
else if (mode.compare("outer") == 0) {
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList[border_tex]);
SE::Renderer->DrawRect(
Eigen::Vector2f(lb_(0) - width*scale, lb_(1) - width*scale),
Eigen::Vector2f(lb_(0), rt_(1) + width*scale)
); // left
SE::Renderer->DrawRect(
Eigen::Vector2f(lb_(0) - width*scale, rt_(1)),
Eigen::Vector2f(rt_(0) + width*scale, rt_(1)+width*scale)
); // top
SE::Renderer->DrawRect(
Eigen::Vector2f(rt_(0), lb_(1) - width*scale),
Eigen::Vector2f(rt_(0)+width*scale, rt_(1) + width*scale)
); // right
SE::Renderer->DrawRect(
Eigen::Vector2f(lb_(0) - width*scale, lb_(1) - width*scale),
Eigen::Vector2f(rt_(0)+width*scale, lb_(1))
); // bottom
}
else if (mode.compare("center") == 0) {
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList[border_tex]);
SE::Renderer->DrawRect(
Eigen::Vector2f(lb_(0) - width*scale*0.5f, lb_(1) - width * scale*0.5f),
Eigen::Vector2f(lb_(0) + width * scale*0.5f, rt_(1) + width * scale*0.5f)
); // left
SE::Renderer->DrawRect(
Eigen::Vector2f(lb_(0) - width * scale*0.5f, rt_(1) - width * scale*0.5f),
Eigen::Vector2f(rt_(0) + width * scale*0.5f, rt_(1) + width * scale*0.5f)
); // top
SE::Renderer->DrawRect(
Eigen::Vector2f(rt_(0) - width * scale*0.5f, lb_(1) - width * scale*0.5f),
Eigen::Vector2f(rt_(0) + width * scale*0.5f, rt_(1) + width * scale*0.5f)
); // right
SE::Renderer->DrawRect(
Eigen::Vector2f(lb_(0) - width * scale*0.5f, lb_(1) - width * scale*0.5f),
Eigen::Vector2f(rt_(0) + width * scale*0.5f, lb_(1) + width * scale*0.5f)
); // bottom
}
} }

View File

@ -49,8 +49,7 @@ private:
void readSaveData(); // inner init method void readSaveData(); // inner init method
void drawSelectionMenu(int index); /*..calc methodes..*/
Eigen::Vector2f textureSizeNormalize(Eigen::Vector2f texVec, int t_type = 0/*0-galaxy, 1-stars*/); Eigen::Vector2f textureSizeNormalize(Eigen::Vector2f texVec, int t_type = 0/*0-galaxy, 1-stars*/);
float val_clamp(float v, float min, float max); float val_clamp(float v, float min, float max);
Eigen::Vector2f findCorner(int x_c, int y_c); Eigen::Vector2f findCorner(int x_c, int y_c);
@ -58,7 +57,11 @@ private:
float lowerV(float first_v, float second_v); float lowerV(float first_v, float second_v);
int negativeV(float val); int negativeV(float val);
int menuState = 0; // 0 - all galaxies are visible, 1 - zoomed to current galaxy , 2 - level select menu /*..states..*/
int menuState = 0; // 0 - all galaxies are visible, 1 - zoomed to current galaxy(reserved) , 2 - level select menu
int starIndex = -1;
int galaxyIndex = 0; // zoomed galaxy
int planetHoverIndex = -1;
/*..Interact params..*/ /*..Interact params..*/
bool timer_active = false; bool timer_active = false;
@ -74,9 +77,12 @@ private:
void takeInFocus(int g_index, int s_index = -1); void takeInFocus(int g_index, int s_index = -1);
int findGalaxyByPos(Eigen::Vector2f pos); int findGalaxyByPos(Eigen::Vector2f pos);
int findPlanetByPos(Eigen::Vector2f pos); int findPlanetByPos(Eigen::Vector2f pos);
int findLevelButtonByPos(Eigen::Vector2f pos);
bool checkMenuBound(Eigen::Vector2f pos);
/*..level select methods..*/ /*..draw methodes..*/
void showLevelSelectMenu(int index); void drawSelectionMenu(int index);
void drawBorder(Eigen::Vector2f lb_, Eigen::Vector2f rt_, float scale, std::string mode);
}; };

View File

@ -16,17 +16,17 @@ public:
std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> buttons; std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> buttons;
Eigen::Vector2f offset = Eigen::Vector2f(0.f, 0.f); // offset Eigen::Vector2f offset = Eigen::Vector2f(0.f, 0.f); // offset
Eigen::Vector2f dim = Eigen::Vector2f(0.7f, 0.9f); // dimensions, y - is not const, relative to the levels count Eigen::Vector2f dim = Eigen::Vector2f(0.6f, 0.9f); // dimensions, y - is not const, relative to the levels count
/*..buttons plane params..*/ /*..buttons plane params..*/
Eigen::Vector2f plane_size = Eigen::Vector2f(1.f, 1.f); // y- is not const, relative to the levels count Eigen::Vector2f plane_size = Eigen::Vector2f(1.0f, 1.0f); // y- is not const, relative to the levels count
Eigen::Vector2f plane_pos = Eigen::Vector2f(0.f, 0.f); // relative to center Eigen::Vector2f plane_pos = Eigen::Vector2f(0.f, 0.f); // relative to center
/*..buttons params..*/ /*..buttons params..*/
int columns = 3; int columns = 3;
float border_y_offset = 0.03f; float border_y_offset = 0.018f;
float border_x_offset = 0.03f; float border_x_offset = 0.018f;
float buttons_offset = 0.03f; float buttons_offset = 0.018f;
float buttons_ratio = 1.6f; float buttons_ratio = 1.6f;
private: private:

View File

@ -224,7 +224,7 @@ void TMyApplication::ApplySignalsToGame()
OnTapUpSignal.connect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1)); OnTapUpSignal.connect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1));
OnFlingSignal.connect(boost::bind(&TGameLevel::OnFling, boost::ref(GameLevel), _1)); OnFlingSignal.connect(boost::bind(&TGameLevel::OnFling, boost::ref(GameLevel), _1));
OnScrollSignal.connect(boost::bind(&TGameLevel::OnScroll, boost::ref(GameLevel), _1)); OnScrollSignal.connect(boost::bind(&TGameLevel::OnScroll, boost::ref(GameLevel), _1));
//OnTapDownSignal.connect(boost::bind(&TGameLevel::OnTapDown, boost::ref(GameLevel), _1)); OnTapDownSignal.connect(boost::bind(&TGameLevel::OnTapDown, boost::ref(GameLevel), _1));
} }
@ -233,7 +233,7 @@ void TMyApplication::DisapplySignalsToGame()
OnTapUpSignal.disconnect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1)); OnTapUpSignal.disconnect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1));
OnFlingSignal.disconnect(boost::bind(&TGameLevel::OnFling, boost::ref(GameLevel), _1)); OnFlingSignal.disconnect(boost::bind(&TGameLevel::OnFling, boost::ref(GameLevel), _1));
OnScrollSignal.disconnect(boost::bind(&TGameLevel::OnScroll, boost::ref(GameLevel), _1)); OnScrollSignal.disconnect(boost::bind(&TGameLevel::OnScroll, boost::ref(GameLevel), _1));
//OnTapDownSignal.disconnect(boost::bind(&TGameLevel::OnTapDown, boost::ref(GameLevel), _1)); OnTapDownSignal.disconnect(boost::bind(&TGameLevel::OnTapDown, boost::ref(GameLevel), _1));
} }
@ -296,10 +296,12 @@ void TMyApplication::LoadResources()
std::vector<int> galaxies; std::vector<int> galaxies;
galaxies.resize(1); galaxies.resize(1);
galaxies[0] = 3; galaxies[0] = 3;
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/matte_screen.png", "matte_screen"));
for (int i = 0; i < galaxies.size(); i++) { for (int i = 0; i < galaxies.size(); i++) {
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/galaxies/galaxy_" + std::to_string(i) + ".png", "galaxy_" + std::to_string(i))); TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/galaxies/galaxy_" + std::to_string(i) + ".png", "galaxy_" + std::to_string(i)));
for (int j = 0; j < galaxies[i]; j++) { for (int j = 0; j < galaxies[i]; j++) {
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/planets/star_" + std::to_string(i) + "_" + std::to_string(j) + ".png", "star_" + std::to_string(i) + "_" + std::to_string(j))); TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/planets/star_" + std::to_string(i) + "_" + std::to_string(j) + ".png", "star_" + std::to_string(i) + "_" + std::to_string(j)));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/planets/star_" + std::to_string(i) + "_" + std::to_string(j) + "_hover" + ".png", "star_" + std::to_string(i) + "_" + std::to_string(j) + "_hover"));
} }
} }

View File

@ -1,3 +1,10 @@
#define GALAXY_MENU_MODE
#ifdef GALAXY_MENU_MODE // === GALAX MENU MODE ===
#define GALAX_MENU_DRAW
#define GALAX_MENU_UPDATE
#endif // === GALAX MENU MODE ===
#include "menucode.h" #include "menucode.h"
#include "main_code.h" #include "main_code.h"
@ -22,13 +29,12 @@ TGameMenu::TGameMenu()
void TGameMenu::Draw() void TGameMenu::Draw()
{ {
#define NEW_MENU_DRAW
// *SE::Console << "TGameMenu::Draw"; // *SE::Console << "TGameMenu::Draw";
CheckGlError("Draw TGameMenu"); CheckGlError("Draw TGameMenu");
RenderUniform1i("sel", 0); RenderUniform1i("sel", 0);
RenderUniform1f("Transparency", 1.f); RenderUniform1f("Transparency", 1.f);
float bkgShift = MenuPos*0.1f - 100.f; float bkgShift = MenuPos*0.1f - 100.f;
#ifndef NEW_MENU_DRAW #ifndef GALAX_MENU_DRAW
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_left"]); glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_left"]);
Renderer->DrawRect(Vector2f(bkgShift,0.f), Vector2f(Renderer->GetScreenWidth()+bkgShift,Renderer->GetScreenHeight())); Renderer->DrawRect(Vector2f(bkgShift,0.f), Vector2f(Renderer->GetScreenWidth()+bkgShift,Renderer->GetScreenHeight()));
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_right"]); glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_right"]);
@ -42,7 +48,7 @@ void TGameMenu::Draw()
GalaxMenu.DrawGalaxyMenu(); GalaxMenu.DrawGalaxyMenu();
#endif #endif
#ifndef NEW_MENU_DRAW #ifndef GALAX_MENU_DRAW
if (SelectedGame == 0) if (SelectedGame == 0)
{ {
RenderUniform1i("sel", 1); RenderUniform1i("sel", 1);
@ -81,10 +87,11 @@ void TGameMenu::Draw()
void TGameMenu::Update(size_t dt) void TGameMenu::Update(size_t dt)
{ {
#ifdef GALAX_MENU_UPDATE
/*..Galaxy Menu..*/ /*..Galaxy Menu..*/
GalaxMenu.InteractWithGalaxy(dt); GalaxMenu.InteractWithGalaxy(dt);
GalaxMenu.UpdateGalaxyMenu((float)SE::Renderer->GetScreenWidth(), (float)SE::Renderer->GetScreenHeight(), dt); GalaxMenu.UpdateGalaxyMenu((float)SE::Renderer->GetScreenWidth(), (float)SE::Renderer->GetScreenHeight(), dt);
#else
if (HoldToTap) if (HoldToTap)
return; return;
// åñëè êíîïêà íå íàæàòà // åñëè êíîïêà íå íàæàòà
@ -143,13 +150,14 @@ void TGameMenu::Update(size_t dt)
{ {
MenuSpeed += acc*dt; MenuSpeed += acc*dt;
} }
#endif
} }
void TGameMenu::OnTapDown(Vector2f pos) void TGameMenu::OnTapDown(Vector2f pos)
{ {
*SE::Console << "TGameMenu::OnTapDown"; *SE::Console << "TGameMenu::OnTapDown";
#ifndef GALAX_MENU_UPDATE
HoldToTap = true; HoldToTap = true;
if (pos(1)<64.f && pos(0)>=265.f-128.f && pos(0)<=265.f+128.f) if (pos(1)<64.f && pos(0)>=265.f-128.f && pos(0)<=265.f+128.f)
@ -180,12 +188,13 @@ void TGameMenu::OnTapDown(Vector2f pos)
SelectedGame = -1; SelectedGame = -1;
#endif
} }
void TGameMenu::OnTapUp(Vector2f pos) void TGameMenu::OnTapUp(Vector2f pos)
{ {
*SE::Console << "TGameMenu::OnTapUp"; *SE::Console << "TGameMenu::OnTapUp";
#ifndef GALAX_MENU_UPDATE
HoldToTap = false; HoldToTap = false;
if (SelectedGame != -1) if (SelectedGame != -1)
@ -194,6 +203,7 @@ void TGameMenu::OnTapUp(Vector2f pos)
Application->GoFromMenuToGame(SelectedGame); Application->GoFromMenuToGame(SelectedGame);
SelectedGame = -1; SelectedGame = -1;
} }
#endif
} }
void TGameMenu::OnTapUpAfterMove(Vector2f pos) void TGameMenu::OnTapUpAfterMove(Vector2f pos)
@ -205,22 +215,28 @@ void TGameMenu::OnTapUpAfterMove(Vector2f pos)
void TGameMenu::OnFling(Vector2f slideSpeed) void TGameMenu::OnFling(Vector2f slideSpeed)
{ {
*SE::Console << "TGameMenu::OnFling"; *SE::Console << "TGameMenu::OnFling";
#ifndef GALAX_MENU_UPDATE
HoldToTap = false; HoldToTap = false;
MenuSpeed = slideSpeed(0); MenuSpeed = slideSpeed(0);
#endif
} }
void TGameMenu::OnScroll(Vector2f shift) void TGameMenu::OnScroll(Vector2f shift)
{ {
#ifndef GALAX_MENU_UPDATE
MenuPos = MenuPos - shift(0); MenuPos = MenuPos - shift(0);
#endif
} }
void TGameMenu::OpenNextLevel() void TGameMenu::OpenNextLevel()
{ {
*SE::Console << "TGameMenu::OpenNextLevel"; *SE::Console << "TGameMenu::OpenNextLevel";
#ifndef GALAX_MENU_UPDATE
if (MenuItemCount < 12) if (MenuItemCount < 12)
{ {
MenuItemCount++; MenuItemCount++;
} }
#endif
} }
int TGameMenu::GetMenuItemCount() int TGameMenu::GetMenuItemCount()

View File

@ -9,7 +9,7 @@ int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst,
LPSTR lpszCmdLine, int nCmdShow) LPSTR lpszCmdLine, int nCmdShow)
{ {
int width = 800; int width = 1024;
int height = 480; int height = 480;