diff --git a/assets/galax_menu/matte_screen.png b/assets/galax_menu/matte_screen.png new file mode 100755 index 0000000..56bfa62 Binary files /dev/null and b/assets/galax_menu/matte_screen.png differ diff --git a/assets/galax_menu/planets/star_0_0.png b/assets/galax_menu/planets/star_0_0.png index 2ad0444..31c5189 100755 Binary files a/assets/galax_menu/planets/star_0_0.png and b/assets/galax_menu/planets/star_0_0.png differ diff --git a/assets/galax_menu/planets/star_0_0_hover.png b/assets/galax_menu/planets/star_0_0_hover.png new file mode 100755 index 0000000..6f0347a Binary files /dev/null and b/assets/galax_menu/planets/star_0_0_hover.png differ diff --git a/assets/galax_menu/planets/star_0_1.png b/assets/galax_menu/planets/star_0_1.png index 3ebbc6b..e25fbac 100755 Binary files a/assets/galax_menu/planets/star_0_1.png and b/assets/galax_menu/planets/star_0_1.png differ diff --git a/assets/galax_menu/planets/star_0_1_hover.png b/assets/galax_menu/planets/star_0_1_hover.png new file mode 100755 index 0000000..f131d58 Binary files /dev/null and b/assets/galax_menu/planets/star_0_1_hover.png differ diff --git a/assets/galax_menu/planets/star_0_2.png b/assets/galax_menu/planets/star_0_2.png index 3876f64..dca96be 100755 Binary files a/assets/galax_menu/planets/star_0_2.png and b/assets/galax_menu/planets/star_0_2.png differ diff --git a/assets/galax_menu/planets/star_0_2_hover.png b/assets/galax_menu/planets/star_0_2_hover.png new file mode 100755 index 0000000..471160d Binary files /dev/null and b/assets/galax_menu/planets/star_0_2_hover.png differ diff --git a/assets/galax_menu_backup/galaxies/galaxy_0.png b/assets/galax_menu_backup/galaxies/galaxy_0.png index 7a753ef..b6dab3b 100755 Binary files a/assets/galax_menu_backup/galaxies/galaxy_0.png and b/assets/galax_menu_backup/galaxies/galaxy_0.png differ diff --git a/assets/galax_menu_backup/planets/star_0_0.png b/assets/galax_menu_backup/planets/star_0_0.png index 4c2c901..2ad0444 100755 Binary files a/assets/galax_menu_backup/planets/star_0_0.png and b/assets/galax_menu_backup/planets/star_0_0.png differ diff --git a/assets/galax_menu_backup/planets/star_0_1.png b/assets/galax_menu_backup/planets/star_0_1.png index 6bd46f0..3ebbc6b 100755 Binary files a/assets/galax_menu_backup/planets/star_0_1.png and b/assets/galax_menu_backup/planets/star_0_1.png differ diff --git a/assets/galax_menu_backup/planets/star_0_2.png b/assets/galax_menu_backup/planets/star_0_2.png new file mode 100755 index 0000000..3876f64 Binary files /dev/null and b/assets/galax_menu_backup/planets/star_0_2.png differ diff --git a/assets/galax_menu_backup/planets/star_1_0.png b/assets/galax_menu_backup/planets/star_1_0.png deleted file mode 100755 index 3ebbc6b..0000000 Binary files a/assets/galax_menu_backup/planets/star_1_0.png and /dev/null differ diff --git a/assets/galax_menu_backup_2/galaxies/galaxy_0.png b/assets/galax_menu_backup_2/galaxies/galaxy_0.png new file mode 100755 index 0000000..b6dab3b Binary files /dev/null and b/assets/galax_menu_backup_2/galaxies/galaxy_0.png differ diff --git a/assets/galax_menu_backup_2/galaxies/galaxy_1.png b/assets/galax_menu_backup_2/galaxies/galaxy_1.png new file mode 100755 index 0000000..018337f Binary files /dev/null and b/assets/galax_menu_backup_2/galaxies/galaxy_1.png differ diff --git a/assets/galax_menu_backup_2/planets/star_0_0.png b/assets/galax_menu_backup_2/planets/star_0_0.png new file mode 100755 index 0000000..8325f70 Binary files /dev/null and b/assets/galax_menu_backup_2/planets/star_0_0.png differ diff --git a/assets/galax_menu_backup_2/planets/star_0_1.png b/assets/galax_menu_backup_2/planets/star_0_1.png new file mode 100755 index 0000000..04dc33a Binary files /dev/null and b/assets/galax_menu_backup_2/planets/star_0_1.png differ diff --git a/assets/galax_menu_backup_2/planets/star_0_2.png b/assets/galax_menu_backup_2/planets/star_0_2.png new file mode 100755 index 0000000..e3f7f30 Binary files /dev/null and b/assets/galax_menu_backup_2/planets/star_0_2.png differ diff --git a/assets/galaxy_ptree.json b/assets/galaxy_ptree.json index 80f1491..bc7f8f4 100755 --- a/assets/galaxy_ptree.json +++ b/assets/galaxy_ptree.json @@ -27,6 +27,9 @@ { "name": "level_1" }, + { + "name": "level_1" + }, { "name": "level_1" } @@ -35,12 +38,15 @@ { "name": "star_0_1", "position": { - "x_coord": 0.35, - "y_coord": 0.25 + "x_coord": 0.28, + "y_coord": 0.31 }, "texture": "star_0_1.png", "scale": 0.18, "levels": [ + { + "name": "level_1" + }, { "name": "level_1" } @@ -55,6 +61,24 @@ "texture": "star_0_2.png", "scale": 0.12, "levels": [ + { + "name": "level_1" + }, + { + "name": "level_1" + }, + { + "name": "level_1" + }, + { + "name": "level_1" + }, + { + "name": "level_1" + }, + { + "name": "level_1" + }, { "name": "level_1" } diff --git a/game/galaxy_menu.cpp b/game/galaxy_menu.cpp index 3db5477..1e458d3 100755 --- a/game/galaxy_menu.cpp +++ b/game/galaxy_menu.cpp @@ -1,5 +1,6 @@ #include "galaxy_menu.h" +#include "main_code.h" #include #include @@ -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 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( 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(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( 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..*/ if (stars_params.size() >= i) { for (int j = 0; j < stars_params[i].size(); j++) { - glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["star_" + std::to_string(i) + "_" + std::to_string(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)]); + } SE::Renderer->DrawRect( Eigen::Vector2f( stars_params[i][j].first(0) - stars_params[i][j].second(0) / 2, @@ -261,7 +267,8 @@ void GalaxyMenu::DrawGalaxyMenu() { } /*..Draw level selection menu..*/ - drawSelectionMenu(0); + drawSelectionMenu(starIndex); + } } @@ -270,21 +277,50 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) { if (timer_active) { // ::::::::::::: timer active :::::::::::::: 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-> - //int y = findGalaxyByPos(Eigen::Vector2f()); + + /*../hover\..*/ + int phi = findPlanetByPos(lastTapPos - totalTapShift); + if (phi != -1) { + planetHoverIndex = phi; + } + else { + planetHoverIndex = -1; + } + /*..\hover/..*/ } else { // 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 \_/\_/\_/\_/ @@ -293,24 +329,38 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) { // ::::::::::::: timer inactive :::::::::::::: if (lastTapPos != Eigen::Vector2f(-9999.9f, -9999.9f)) { if (menuState == 0) {// main view - if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f){ + if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) { // OnTapDown->OnTapUp - int y = findPlanetByPos(lastTapPos); - if (y != -1) { - /*..level selec menu open..*/ - + /*..level select menu open..*/ + starIndex = findPlanetByPos(lastTapPos); + if (starIndex != -1) { + planetHoverIndex = starIndex; + menuState = 2; + } + else { + planetHoverIndex = -1; } } else { // 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 } @@ -320,10 +370,25 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) { } } - if (menuState == 2) { // level select view - if ((currentTapShift(0) == 0.f) && (currentTapShift(1) == 0.f)) { + else if (menuState == 2) { // level select view + if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) { // 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 { // OnTapDown->OnMove->OnTapUp @@ -365,7 +430,8 @@ void GalaxyMenu::tapUp(Eigen::Vector2f pos) { void GalaxyMenu::tapMove(Eigen::Vector2f shift) { if (timer_active) { //*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; -} - -void GalaxyMenu::showLevelSelectMenu(int index) { - - - } void GalaxyMenu::drawSelectionMenu(int index) { int i = index; 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"]); SE::Renderer->DrawRect( Eigen::Vector2f( @@ -513,6 +586,20 @@ void GalaxyMenu::drawSelectionMenu(int index) { ) ); // 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 for (int j = 0; j < galaxies[0].Stars[i].selectionMenu.buttons.size(); j++) { 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"]); - SE::Renderer->DrawRect( - Eigen::Vector2f( - galaxies[0].Stars[0].selectionMenu.params.first(0) - galaxies[0].Stars[0].selectionMenu.params.second(0) / 2, - galaxies[0].Stars[0].selectionMenu.params.first(1) - galaxies[0].Stars[0].selectionMenu.params.second(1) / 2 - ), - Eigen::Vector2f( - galaxies[0].Stars[0].selectionMenu.params.first(0) + galaxies[0].Stars[0].selectionMenu.params.second(0) / 2, - galaxies[0].Stars[0].selectionMenu.params.first(1) + galaxies[0].Stars[0].selectionMenu.params.second(1) / 2 - )); - */ +} + +int GalaxyMenu::findLevelButtonByPos(Eigen::Vector2f pos) { + for (int i = 0; i < galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons.size(); i++) { + float x_l = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f; + float x_r = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f; + 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; + + if (pos(0) >= x_l && pos(0) <= x_r) { + 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 + } } \ No newline at end of file diff --git a/game/galaxy_menu.h b/game/galaxy_menu.h index b2d304c..6edc845 100755 --- a/game/galaxy_menu.h +++ b/game/galaxy_menu.h @@ -49,8 +49,7 @@ private: 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*/); float val_clamp(float v, float min, float max); Eigen::Vector2f findCorner(int x_c, int y_c); @@ -58,7 +57,11 @@ private: float lowerV(float first_v, float second_v); 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..*/ bool timer_active = false; @@ -74,9 +77,12 @@ private: void takeInFocus(int g_index, int s_index = -1); int findGalaxyByPos(Eigen::Vector2f pos); int findPlanetByPos(Eigen::Vector2f pos); + int findLevelButtonByPos(Eigen::Vector2f pos); + bool checkMenuBound(Eigen::Vector2f pos); - /*..level select methods..*/ - void showLevelSelectMenu(int index); + /*..draw methodes..*/ + void drawSelectionMenu(int index); + void drawBorder(Eigen::Vector2f lb_, Eigen::Vector2f rt_, float scale, std::string mode); }; diff --git a/game/galaxy_objects.h b/game/galaxy_objects.h index dd3a903..dcaedcc 100755 --- a/game/galaxy_objects.h +++ b/game/galaxy_objects.h @@ -16,18 +16,18 @@ public: std::vector> buttons; 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..*/ - Eigen::Vector2f plane_size = Eigen::Vector2f(1.f, 1.f); // y- is not const, relative to the levels count + /*..buttons plane params..*/ + 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 - /*..buttons params..*/ + /*..buttons params..*/ int columns = 3; - float border_y_offset = 0.03f; - float border_x_offset = 0.03f; - float buttons_offset = 0.03f; - float buttons_ratio = 1.6f; + float border_y_offset = 0.018f; + float border_x_offset = 0.018f; + float buttons_offset = 0.018f; + float buttons_ratio = 1.6f; private: diff --git a/game/main_code.cpp b/game/main_code.cpp index cecbf47..5012086 100644 --- a/game/main_code.cpp +++ b/game/main_code.cpp @@ -224,7 +224,7 @@ void TMyApplication::ApplySignalsToGame() OnTapUpSignal.connect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1)); OnFlingSignal.connect(boost::bind(&TGameLevel::OnFling, 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)); OnFlingSignal.disconnect(boost::bind(&TGameLevel::OnFling, 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 galaxies; galaxies.resize(1); galaxies[0] = 3; + TextureNamesToLoad.push_back(std::pair("/galax_menu/matte_screen.png", "matte_screen")); for (int i = 0; i < galaxies.size(); i++) { TextureNamesToLoad.push_back(std::pair("/galax_menu/galaxies/galaxy_" + std::to_string(i) + ".png", "galaxy_" + std::to_string(i))); for (int j = 0; j < galaxies[i]; j++) { TextureNamesToLoad.push_back(std::pair("/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("/galax_menu/planets/star_" + std::to_string(i) + "_" + std::to_string(j) + "_hover" + ".png", "star_" + std::to_string(i) + "_" + std::to_string(j) + "_hover")); } } diff --git a/game/menucode.cpp b/game/menucode.cpp index b741a6c..aebd589 100644 --- a/game/menucode.cpp +++ b/game/menucode.cpp @@ -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 "main_code.h" @@ -22,13 +29,12 @@ TGameMenu::TGameMenu() void TGameMenu::Draw() { -#define NEW_MENU_DRAW // *SE::Console << "TGameMenu::Draw"; CheckGlError("Draw TGameMenu"); RenderUniform1i("sel", 0); RenderUniform1f("Transparency", 1.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"]); Renderer->DrawRect(Vector2f(bkgShift,0.f), Vector2f(Renderer->GetScreenWidth()+bkgShift,Renderer->GetScreenHeight())); glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_right"]); @@ -42,7 +48,7 @@ void TGameMenu::Draw() GalaxMenu.DrawGalaxyMenu(); #endif -#ifndef NEW_MENU_DRAW +#ifndef GALAX_MENU_DRAW if (SelectedGame == 0) { RenderUniform1i("sel", 1); @@ -81,10 +87,11 @@ void TGameMenu::Draw() void TGameMenu::Update(size_t dt) { +#ifdef GALAX_MENU_UPDATE /*..Galaxy Menu..*/ GalaxMenu.InteractWithGalaxy(dt); GalaxMenu.UpdateGalaxyMenu((float)SE::Renderer->GetScreenWidth(), (float)SE::Renderer->GetScreenHeight(), dt); - +#else if (HoldToTap) return; // если кнопка не нажата @@ -143,13 +150,14 @@ void TGameMenu::Update(size_t dt) { MenuSpeed += acc*dt; } - +#endif } void TGameMenu::OnTapDown(Vector2f pos) { *SE::Console << "TGameMenu::OnTapDown"; +#ifndef GALAX_MENU_UPDATE HoldToTap = true; 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; - +#endif } void TGameMenu::OnTapUp(Vector2f pos) { *SE::Console << "TGameMenu::OnTapUp"; +#ifndef GALAX_MENU_UPDATE HoldToTap = false; if (SelectedGame != -1) @@ -194,6 +203,7 @@ void TGameMenu::OnTapUp(Vector2f pos) Application->GoFromMenuToGame(SelectedGame); SelectedGame = -1; } +#endif } void TGameMenu::OnTapUpAfterMove(Vector2f pos) @@ -205,22 +215,28 @@ void TGameMenu::OnTapUpAfterMove(Vector2f pos) void TGameMenu::OnFling(Vector2f slideSpeed) { *SE::Console << "TGameMenu::OnFling"; +#ifndef GALAX_MENU_UPDATE HoldToTap = false; MenuSpeed = slideSpeed(0); +#endif } void TGameMenu::OnScroll(Vector2f shift) { +#ifndef GALAX_MENU_UPDATE MenuPos = MenuPos - shift(0); +#endif } void TGameMenu::OpenNextLevel() { *SE::Console << "TGameMenu::OpenNextLevel"; +#ifndef GALAX_MENU_UPDATE if (MenuItemCount < 12) { MenuItemCount++; } +#endif } int TGameMenu::GetMenuItemCount() diff --git a/windows/DoubleHitBalls-win/DoubleHitBalls-win/main.cpp b/windows/DoubleHitBalls-win/DoubleHitBalls-win/main.cpp index 05fd3a9..f32def5 100755 --- a/windows/DoubleHitBalls-win/DoubleHitBalls-win/main.cpp +++ b/windows/DoubleHitBalls-win/DoubleHitBalls-win/main.cpp @@ -9,7 +9,7 @@ int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, LPSTR lpszCmdLine, int nCmdShow) { - int width = 800; + int width = 1024; int height = 480;