menu proc
BIN
assets/galax_menu/galaxies/galaxy_0.png
Executable file
After Width: | Height: | Size: 3.6 MiB |
BIN
assets/galax_menu/planets/star_0_0.png
Executable file
After Width: | Height: | Size: 995 KiB |
BIN
assets/galax_menu/planets/star_0_1 — копия.png
Executable file
After Width: | Height: | Size: 1.7 MiB |
BIN
assets/galax_menu/planets/star_0_1.png
Executable file
After Width: | Height: | Size: 870 KiB |
BIN
assets/galax_menu_backup/galaxies/galaxy_0.png
Executable file
After Width: | Height: | Size: 3.7 MiB |
BIN
assets/galax_menu_backup/planets/star_0_0.png
Executable file
After Width: | Height: | Size: 1.0 MiB |
BIN
assets/galax_menu_backup/planets/star_0_1.png
Executable file
After Width: | Height: | Size: 5.5 MiB |
@ -1,22 +1,22 @@
|
||||
{
|
||||
"Space":[
|
||||
{
|
||||
"name": "galaxy_1",
|
||||
"name": "galaxy_0",
|
||||
"position":{
|
||||
"x_coord": 0.5,
|
||||
"y_coord": 0.5
|
||||
"x_coord": 0.0,
|
||||
"y_coord": 0.0
|
||||
},
|
||||
"texture": "galaxy_1.png",
|
||||
"texture": "galaxy_0.png",
|
||||
"scale": 1.0,
|
||||
"Stars": [
|
||||
{
|
||||
"name": "star_1",
|
||||
"name": "star_0_0",
|
||||
"position": {
|
||||
"x_coord": 0.2,
|
||||
"y_coord": 0.3
|
||||
"x_coord": -0.45,
|
||||
"y_coord": 0.18
|
||||
},
|
||||
"texture": "star_1.png",
|
||||
"scale": 1.0,
|
||||
"texture": "star_0_0.png",
|
||||
"scale": 0.06,
|
||||
"levels": [
|
||||
{
|
||||
"name": "level_1"
|
||||
@ -24,13 +24,13 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "star_2",
|
||||
"name": "star_0_1",
|
||||
"position": {
|
||||
"x_coord": 0.2,
|
||||
"y_coord": 0.3
|
||||
"x_coord": 0.25,
|
||||
"y_coord": -0.15
|
||||
},
|
||||
"texture": "star_2.png",
|
||||
"scale": 1.0,
|
||||
"texture": "star_0_1.png",
|
||||
"scale": 0.07,
|
||||
"levels": [
|
||||
{
|
||||
"name": "level_1"
|
||||
|
@ -56,10 +56,14 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
|
||||
}
|
||||
}
|
||||
|
||||
void GalaxyMenu::UpdateGalaxyMenu() {
|
||||
void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height) {
|
||||
/*..Reset..*/
|
||||
galaxies_params.clear();
|
||||
stars_params.clear();
|
||||
|
||||
/*..Menu ancestor geometry..*/
|
||||
float gameScreenWidth = 800.f;
|
||||
float gameScreenHeight = 480.f;
|
||||
float gameScreenWidth = s_width;
|
||||
float gameScreenHeight = s_height;
|
||||
Eigen::Vector2f gameScreenCenter = Eigen::Vector2f(gameScreenWidth/2,gameScreenHeight/2);
|
||||
|
||||
/*..Menu geometry..*/
|
||||
@ -68,30 +72,41 @@ void GalaxyMenu::UpdateGalaxyMenu() {
|
||||
Eigen::Vector2f currentMenuPos = Eigen::Vector2f(gameScreenCenter(0) + (gameScreenWidth/2/*relative to the screen x-dimension*/)*menuPosition(0), gameScreenCenter(1) + (gameScreenHeight/2/*relative to the screen y-dimension*/)*menuPosition(1));
|
||||
|
||||
/*..Galaxies geometry..*/
|
||||
std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> galaxies_params; // ::position/dimensions::
|
||||
std::vector<std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>>> stars_params;
|
||||
|
||||
for (int i = 0; i < galaxies.size(); i++) {
|
||||
*SE::Console << "galaxy_" + std::to_string(i);
|
||||
Eigen::Vector2f tex_size = textureSizeNormalize(
|
||||
Eigen::Vector2f(((float)SE::ResourceManager->TexList.GetTextureWidth("galaxy_texture_" + i)), ((float)SE::ResourceManager->TexList.GetTextureHeight("galaxy_texture_" + i)))
|
||||
Eigen::Vector2f(
|
||||
((float)SE::ResourceManager->TexList.GetTextureWidth("galaxy_" + std::to_string(i))),
|
||||
((float)SE::ResourceManager->TexList.GetTextureHeight("galaxy_" + std::to_string(i))))
|
||||
); // normalized
|
||||
galaxies_params.push_back(std::make_pair(
|
||||
Eigen::Vector2f(currentMenuPos(0) + (xDimension/2)*galaxies[i].position(0), currentMenuPos(1) + (yDimension / 2)*galaxies[i].position(1)),
|
||||
Eigen::Vector2f(
|
||||
tex_size(0)*galaxies[i].scale,
|
||||
tex_size(1)*galaxies[i].scale
|
||||
currentMenuPos(0) + (xDimension/2)*galaxies[i].position(0),
|
||||
currentMenuPos(1) + (yDimension / 2)*galaxies[i].position(1)),
|
||||
Eigen::Vector2f(
|
||||
(tex_size(0)*galaxies[i].scale)*menuScale,
|
||||
(tex_size(1)*galaxies[i].scale)*menuScale
|
||||
)
|
||||
));
|
||||
|
||||
/*..Stars geometry..*/
|
||||
std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> star_params;
|
||||
for (int j = 0; j < galaxies[i].Stars.size(); j++) {
|
||||
*SE::Console << "star_" + std::to_string(i) + "_" + std::to_string(j);
|
||||
tex_size = textureSizeNormalize(
|
||||
Eigen::Vector2f(
|
||||
((float)SE::ResourceManager->TexList.GetTextureWidth("star_" + std::to_string(i) + "_" + std::to_string(j))),
|
||||
((float)SE::ResourceManager->TexList.GetTextureHeight("star_" + std::to_string(i) + "_" + std::to_string(j))))
|
||||
); // normalized
|
||||
star_params.push_back(std::make_pair(
|
||||
Eigen::Vector2f(
|
||||
galaxies_params[i].first(0) + (galaxies_params[i].second(0)/2)*galaxies[i].Stars[j].scale,
|
||||
galaxies_params[i].first(1) + (galaxies_params[i].second(1)/2)*galaxies[i].Stars[j].scale
|
||||
galaxies_params[i].first(0) + (galaxies_params[i].second(0)/2)*galaxies[i].Stars[j].position(0),
|
||||
galaxies_params[i].first(1) + (galaxies_params[i].second(1)/2)*galaxies[i].Stars[j].position(1)
|
||||
),
|
||||
Eigen::Vector2f() // #from here
|
||||
Eigen::Vector2f(
|
||||
(tex_size(0)*galaxies[i].Stars[j].scale)*galaxies[i].scale*menuScale,
|
||||
(tex_size(1)*galaxies[i].Stars[j].scale)*galaxies[i].scale*menuScale
|
||||
)
|
||||
));
|
||||
}
|
||||
stars_params.push_back(star_params);
|
||||
@ -130,6 +145,10 @@ Eigen::Vector2f GalaxyMenu::textureSizeNormalize(Eigen::Vector2f texVec, int t_t
|
||||
y_dim = val_clamp(texVec(1), Ymin, Ymax);
|
||||
x_dim = y_dim * tex_ratio;
|
||||
}
|
||||
*SE::Console << "==============";
|
||||
*SE::Console << std::to_string(texVec(0));
|
||||
*SE::Console << std::to_string(texVec(1));
|
||||
*SE::Console << "--------------";
|
||||
return Eigen::Vector2f(x_dim, y_dim);
|
||||
}
|
||||
|
||||
@ -140,4 +159,49 @@ float GalaxyMenu::val_clamp(float val, float min, float max) {
|
||||
return max;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
void GalaxyMenu::DrawGalaxyMenu() {
|
||||
|
||||
for (int i = 0; i < galaxies_params.size(); i++) {
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["galaxy_" + std::to_string(i)]);
|
||||
/*SE::Console << "c_out::";
|
||||
*SE::Console << std::to_string((galaxies_params[i].second(0)));
|
||||
*SE::Console << std::to_string((galaxies_params[i].first(1) - galaxies_params[i].second(1) / 2));
|
||||
*SE::Console << std::to_string((galaxies_params[i].first(0) + galaxies_params[i].second(0) / 2));
|
||||
*SE::Console << std::to_string((galaxies_params[i].first(1) + galaxies_params[i].second(1) / 2));*/
|
||||
SE::Renderer->DrawRect(
|
||||
Eigen::Vector2f(
|
||||
galaxies_params[i].first(0) - galaxies_params[i].second(0)/2,
|
||||
galaxies_params[i].first(1) - galaxies_params[i].second(1)/2
|
||||
),
|
||||
Eigen::Vector2f(
|
||||
galaxies_params[i].first(0) + galaxies_params[i].second(0)/2,
|
||||
galaxies_params[i].first(1) + galaxies_params[i].second(1)/2
|
||||
)
|
||||
); // DrawRect
|
||||
|
||||
/*..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)]);
|
||||
SE::Renderer->DrawRect(
|
||||
Eigen::Vector2f(
|
||||
stars_params[i][j].first(0) - stars_params[i][j].second(0) / 2,
|
||||
stars_params[i][j].first(1) - stars_params[i][j].second(1) / 2
|
||||
),
|
||||
Eigen::Vector2f(
|
||||
stars_params[i][j].first(0) + stars_params[i][j].second(0) / 2,
|
||||
stars_params[i][j].first(1) + stars_params[i][j].second(1) / 2
|
||||
)
|
||||
); // DrawRect
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GalaxyMenu::InteractWithGalaxy() {
|
||||
|
||||
}
|
@ -25,7 +25,7 @@ public:
|
||||
// ======== Main Methods ========
|
||||
bool InitGalaxyMenu(std::string config_json, float scale = 1.f);
|
||||
void DrawGalaxyMenu();
|
||||
void UpdateGalaxyMenu();
|
||||
void UpdateGalaxyMenu(float s_width, float s_height);
|
||||
// ======== Main Methods ========
|
||||
|
||||
void InteractWithGalaxy(/*..Vector/Vector/Int..*/); // Prototype for mouse/tap events
|
||||
@ -35,6 +35,8 @@ public:
|
||||
float menuScale = 1.f; // (not const!!)
|
||||
float xDimension;
|
||||
float yDimension;
|
||||
std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> galaxies_params; // ::position/dimensions::
|
||||
std::vector<std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>>> stars_params;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <string>
|
||||
|
||||
#include "include/Engine.h"
|
||||
|
||||
@ -116,13 +117,12 @@ void TMyApplication::InnerInit()
|
||||
ResourceManager->FontManager.AddFont("arial32", "arial32.png", "arial32.txt");
|
||||
ResourceManager->FontManager.AddFont("lucon12", "lucon12.png", "lucon12.txt");
|
||||
ResourceManager->FontManager.PushFont("lucon12");
|
||||
ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json");
|
||||
SetButtonsAction();
|
||||
//ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json");
|
||||
//SetButtonsAction();
|
||||
// ------- UI -------
|
||||
|
||||
// TESTS of menu
|
||||
GalaxyMenu menu_ms;
|
||||
if (menu_ms.InitGalaxyMenu("galaxy_ptree.json")) {
|
||||
if (Menu.GalaxMenu.InitGalaxyMenu("galaxy_ptree.json")) {
|
||||
std::cout << "ok" << std::endl;
|
||||
}
|
||||
else {
|
||||
@ -279,6 +279,16 @@ void TMyApplication::LoadResources()
|
||||
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_1") + bg_ext, "shutterstock11"));
|
||||
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_1") + bg_ext, "shutterstock12"));
|
||||
|
||||
/*..galaxies and stars/planets Init..*/ // tmp
|
||||
std::vector<int> galaxies;
|
||||
galaxies.resize(1);
|
||||
galaxies[0] = 2;
|
||||
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)));
|
||||
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>("levelshot1.png", "levelshot1"));
|
||||
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot2.png", "levelshot2"));
|
||||
|
@ -22,17 +22,27 @@ 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
|
||||
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"]);
|
||||
Renderer->DrawRect(Vector2f(Renderer->GetScreenWidth()+bkgShift,0.f), Vector2f(960.f+bkgShift,Renderer->GetScreenHeight()));
|
||||
#else
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/*..GalaxMenu draw..*/
|
||||
GalaxMenu.DrawGalaxyMenu();
|
||||
#endif
|
||||
|
||||
#ifndef NEW_MENU_DRAW
|
||||
if (SelectedGame == 0)
|
||||
{
|
||||
RenderUniform1i("sel", 1);
|
||||
@ -62,6 +72,7 @@ void TGameMenu::Draw()
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["logo_small"]);
|
||||
Renderer->DrawRect(Vector2f(240.f-128.f+15.f, 0.f), Vector2f(240.f+128.f+15.f, 64.f));
|
||||
#endif
|
||||
|
||||
CheckGlError("Draw TGameMenu 2");
|
||||
|
||||
@ -70,6 +81,9 @@ void TGameMenu::Draw()
|
||||
|
||||
void TGameMenu::Update(size_t dt)
|
||||
{
|
||||
/*..Galaxy Menu..*/
|
||||
GalaxMenu.UpdateGalaxyMenu((float)SE::Renderer->GetScreenWidth(), (float)SE::Renderer->GetScreenHeight());
|
||||
|
||||
if (HoldToTap)
|
||||
return;
|
||||
// åñëè êíîïêà íå íàæàòà
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "include/Engine.h"
|
||||
#include "game_area_interface.h"
|
||||
#include "galaxy_menu.h"
|
||||
|
||||
using namespace SE;
|
||||
|
||||
@ -34,6 +35,9 @@ public:
|
||||
int GetMenuItemCount();
|
||||
void SetMenuItemCount(int menuItemCount);
|
||||
|
||||
/*..Galaxy Menu..*/
|
||||
GalaxyMenu GalaxMenu;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|