Major changes

This commit is contained in:
vladislav.khorev committed 2018-07-23 01:56:46 +05:00
1 parent d605cf62f6
commit ea6e4ff654
55 files changed
+363 -332

No files matched your search

+17 -215
View File
@@ -52,9 +52,8 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
std::string levelName = levels_pt.second.get<std::string>("name", "empty");
TGameLevel lvl;
lvl.FillWithFile(ST::PathToResources + levelName + ".txt");
lvl.setBackground("shutterstock" + std::to_string(levelIndex++));
std::shared_ptr<TGameLevel> lvl = std::make_shared<TGameLevel>();
lvl->FillWithFile(ST::PathToResources + levelName + ".txt");
star.selectionMenu.gameLevels.push_back(lvl);
}
@@ -63,6 +62,7 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
galaxies.push_back(galax);
}
return true;
}
catch (boost::property_tree::ptree_error) {
@@ -70,6 +70,9 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
}
}
void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
/*..Reset..*/
galaxies_params.clear();
@@ -136,106 +139,6 @@ void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
stars_params.push_back(star_params);
}
/*..Level list geometry..*/
for (int i = 0; i < galaxies.size(); i++) {
for (int j = 0; j < galaxies[i].Stars.size(); j++) {
float button_x_dim = ((1.f - (galaxies[i].Stars[j].selectionMenu.border_x_offset * 2 + (galaxies[i].Stars[j].selectionMenu.columns - 1)*galaxies[i].Stars[j].selectionMenu.buttons_offset)) / galaxies[i].Stars[j].selectionMenu.columns); // relative size
int rows_count = (int)ceil((float)galaxies[i].Stars[j].selectionMenu.gameLevels.size() / (float)galaxies[i].Stars[j].selectionMenu.columns);
galaxies[i].Stars[j].selectionMenu.params = std::make_pair(
Eigen::Vector2f(
gameScreenCenter(0) + (galaxies[i].Stars[j].selectionMenu.offset(0) * gameScreenWidth / 2),
gameScreenCenter(1) + (galaxies[i].Stars[j].selectionMenu.offset(1) * gameScreenHeight / 2)
),
Eigen::Vector2f(
gameScreenWidth * galaxies[i].Stars[j].selectionMenu.dim(0),
//gameScreenHeight * galaxies[i].Stars[j].selectionMenu.dim(1)
//gameScreenHeight * galaxies[i].Stars[j].selectionMenu.dim(1) * (galaxies[i].Stars[j].selectionMenu.border_y_offset * 2 + (ceil(galaxies[i].Stars[j].selectionMenu.levels.size() / galaxies[i].Stars[j].selectionMenu.columns) - 1)*galaxies[i].Stars[j].selectionMenu.buttons_offset) + galaxies[i].Stars[j].selectionMenu.dim(0)*(ceil(galaxies[i].Stars[j].selectionMenu.levels.size() / galaxies[i].Stars[j].selectionMenu.columns)*(button_x_dim / galaxies[i].Stars[j].selectionMenu.buttons_ratio))
gameScreenWidth * galaxies[i].Stars[j].selectionMenu.dim(0) * (galaxies[i].Stars[j].selectionMenu.border_y_offset * 2 + rows_count*(button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio) + (rows_count-1)*galaxies[i].Stars[j].selectionMenu.border_y_offset)
)
);
/*..buttons plane..*/
galaxies[i].Stars[j].selectionMenu.buttons_plane = std::make_pair(
Eigen::Vector2f(
galaxies[i].Stars[j].selectionMenu.params.first(0) + galaxies[i].Stars[j].selectionMenu.params.second(0) / 2 * galaxies[i].Stars[j].selectionMenu.plane_pos(0),
galaxies[i].Stars[j].selectionMenu.params.first(1) + galaxies[i].Stars[j].selectionMenu.params.second(1) / 2 * galaxies[i].Stars[j].selectionMenu.plane_pos(1)
),
Eigen::Vector2f(
galaxies[i].Stars[j].selectionMenu.params.second(0) * galaxies[i].Stars[j].selectionMenu.plane_size(0),
galaxies[i].Stars[j].selectionMenu.params.second(1) * galaxies[i].Stars[j].selectionMenu.plane_size(1)
)
);
// buttons
std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> buttons_params;
std::vector<std::vector<GameLevelInterior>> interior_params;
int levelsCount = galaxies[i].Stars[j].selectionMenu.gameLevels.size();
buttons_params.resize(levelsCount);
interior_params.resize(levelsCount);
for (int v = 0; v < interior_params.size(); v++) {
interior_params[v].resize(CONST_BRICKMATRIX_HEIGHT*CONST_BRICKMATRIX_WIDTH);
}
for (int y = 0; y < levelsCount; y++) {
GameLevelInterior levelInter;
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)))) * 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(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(0)
)
);
/*..Interior params..*/
/*.matrix init.*/
int brickMatr[CONST_BRICKMATRIX_WIDTH][CONST_BRICKMATRIX_HEIGHT];
for (int w = 0; w < CONST_BRICKMATRIX_WIDTH; w++)
{
for (int h = 0; h < CONST_BRICKMATRIX_HEIGHT; h++)
{
if (galaxies[i].Stars[j].selectionMenu.gameLevels[y].BlockMatrix[w][h].IsAppear()) {
brickMatr[w][h] = 1;
}
else {
brickMatr[w][h] = 0;
}
}
}
/*.params init.*/
float brick_w = 0.06f;
float brick_ratio = 1.6f;
float brick_h = brick_w / brick_ratio;
float xb_offset = 0.01f; // x border offset * 0.5
float yb_offset = 0.01f; // offset from top
int loop_itr = 0;
for (int w = 0; w < CONST_BRICKMATRIX_WIDTH; w++) {
for (int h = 0; h < CONST_BRICKMATRIX_HEIGHT; h++) {
levelInter.position = Eigen::Vector2f(
(buttons_params[y].first(0) - buttons_params[y].second(0)*0.5f) + (xb_offset + brick_w * w + brick_w * 0.5f) * buttons_params[y].second(0),
(buttons_params[y].first(1) + buttons_params[y].second(1)*0.5f) - (yb_offset + brick_h * h + brick_h * 0.5f)*buttons_params[y].second(1)
);
levelInter.dimensions = Eigen::Vector2f(
buttons_params[y].second(0)*brick_w/* * brickMatr[w][h]*/, //drawable block coefficient - #NOW NEED TO BE FIXED AT (matrix init) sections#
buttons_params[y].second(1)*brick_h/* * brickMatr[w][h]*/
);
//inited
interior_params[y][loop_itr++] = levelInter;
}
}
}
galaxies[i].Stars[j].selectionMenu.levelInterior = interior_params;
galaxies[i].Stars[j].selectionMenu.buttons = buttons_params;
}
}
}
Eigen::Vector2f GalaxyMenu::textureSizeNormalize(Eigen::Vector2f texVec, int t_type) {
@@ -359,6 +262,7 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
}
}
/*
else if (menuState == 1) { // zoomed galaxy
}
@@ -372,7 +276,7 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
// OnTapDown->OnMove->
//totalTapShift = Eigen::Vector2f(totalTapShift(0) + currentTapShift(0), totalTapShift(1) + currentTapShift(1));
}
}
}*/
// \_/\_/\_/\_/ timer active \_/\_/\_/\_/
}
@@ -385,22 +289,19 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
/*..level select menu open..*/
starIndex = findPlanetByPos(lastTapPos);
if (starIndex != -1) {
planetHoverIndex = starIndex;
menuState = 2;
}
else {
planetHoverIndex = -1;
}
if (starIndex != -1)
{
Application->SetupGalaxyUi(starIndex);
ResourceManager->newGuiManager.findWidgetByName("modal_background")->setVisibility(true);
}
timer_active = false;
}
}/*
else if (menuState == 1) { // zoomed galaxy
if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) {
// OnTapDown->OnTapUp
@@ -413,6 +314,8 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
}
else if (menuState == 2) { // level select view
if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) {
// OnTapDown->OnTapUp
@@ -437,7 +340,7 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
}
}
}*/
}
// \_/\_/\_/\_/ timer inactive \_/\_/\_/\_/
}
@@ -599,107 +502,6 @@ int GalaxyMenu::findPlanetByPos(Eigen::Vector2f pos) {
return -1;
}
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(
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
)
); // 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
int j = 0;
for (auto &button : galaxies[0].Stars[i].selectionMenu.buttons)
{
//std::string levelName = "shutterstock" + galaxies[0].Stars[i].selectionMenu.levels[j].substr(itr + 1);
//glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList[levelName]);
std::string &levelName = galaxies[0].Stars[i].selectionMenu.gameLevels[j].levelName;
std::string levelPrerender = galaxies[0].Stars[i].selectionMenu.gameLevels[j].levelName + "_prerender";
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList[levelPrerender]);
SE::Renderer->DrawRect(
Eigen::Vector2f(
button.first(0) - button.second(0) / 2,
button.first(1) - button.second(1) / 2
),
Eigen::Vector2f(
button.first(0) + button.second(0) / 2,
button.first(1) + button.second(1) / 2
)
); // DrawRect
/*..draw level interior..*/
//drawLevelInterior(i,j);
/*std::list<std::pair<PairColorTexture, TTriangleList>>::iterator colorBlockIterator;
for (colorBlockIterator = galaxies[0].Stars[i].selectionMenu.levelInterior[j].BlockInstansingList.ColorBlockList.begin(); colorBlockIterator != galaxies[0].Stars[i].selectionMenu.levelInterior[j].BlockInstansingList.ColorBlockList.end(); ++colorBlockIterator)
{
RenderUniform4fv("BrickColor", colorBlockIterator->first.first.data());
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList[colorBlockIterator->first.second]);
Renderer->DrawTriangleList(colorBlockIterator->second);
}*/
++j;
}
}
}
TGameLevel* GalaxyMenu::findLevelByButtonPos(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 &galaxies[galaxyIndex].Stars[starIndex].selectionMenu.gameLevels[i];
}
}
}
return nullptr;
}
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;
+3 -2
View File
@@ -27,6 +27,8 @@ public:
bool InitGalaxyMenu(std::string config_json, float scale = 1.f);
void DrawGalaxyMenu();
void UpdateGalaxyMenu(float s_width, float s_height, size_t dt);
// ======== Main Methods ========
void InteractWithGalaxy(size_t dt); // Prototype for mouse/tap events
@@ -79,11 +81,10 @@ private:
void takeInFocus(int g_index, int s_index = -1);
int findGalaxyByPos(Eigen::Vector2f pos);
int findPlanetByPos(Eigen::Vector2f pos);
TGameLevel* findLevelByButtonPos(Eigen::Vector2f pos);
bool checkMenuBound(Eigen::Vector2f pos);
/*..draw methodes..*/
void drawSelectionMenu(int index);
void drawBorder(Eigen::Vector2f lb_, Eigen::Vector2f rt_, float scale, std::string mode);
void drawLevelInterior(int star = -1, int button = -1);
+1 -1
View File
@@ -12,7 +12,7 @@ public:
/*..LEVELS..*/
/*..levels interior info..*/
std::vector<TGameLevel> gameLevels;
std::vector<std::shared_ptr<TGameLevel>> gameLevels;
std::vector<std::vector<GameLevelInterior>> levelInterior;
// #params
+69 -26
View File
@@ -442,7 +442,7 @@ void TBall::Update(size_t dt)
TGameLevel::TGameLevel()
{
BkgTexture = "bkg";
BkgTexture = "";
RenderBufferReady = false;
PrevLevelStateIsStandby = false;
@@ -623,6 +623,18 @@ void TGameLevel::ReloadLevel()
}
std::vector<std::string>::iterator rowIterator = rows.begin();
if (BkgTexture != "")
{
ResourceManager->TexList.DeleteTexture(BkgTexture);
}
BkgTexture = *rowIterator;
ResourceManager->TexList.AddTexture("level_background/" + BkgTexture);
++rowIterator;
BallColor = ParseColor(*rowIterator);
++rowIterator;
@@ -668,11 +680,11 @@ void TGameLevel::ReloadLevel()
}
/*
void TGameLevel::setBackground(const std::string& textureName)
{
BkgTexture = textureName;
LevelScreenTexture = textureName;
}
}*/
void TGameLevel::FillWithFile(const std::string& filename)
{
@@ -759,27 +771,33 @@ void TGameLevel::drawOutline(int screenWidth, int screenHeight) {
);
}
void TGameLevel::DrawSnapshot(const std::string& assignedSnapshotFrameBuffer)
void TGameLevel::DrawSnapshot(const std::string& assignedSnapshotFrameBuffer, bool blackAndWhite)
{
InitLevel(768, 480);
int prevState = LevelState;
LevelState = CONST_LEVELSTATE_SNAPSHOTTING;
InnerDraw(768, 480, 768, 480);
InnerDraw(768, 480, 768, 480, blackAndWhite);
LevelState = prevState;
prerenderedImage =
ResourceManager->FrameManager.GetFrameTextureCopy(assignedSnapshotFrameBuffer, levelName + "_prerender");
std::string texName = levelName + "_prerender";
if (blackAndWhite)
{
texName += "_blackandwhite";
}
prerenderedImage = ResourceManager->FrameManager.GetFrameTextureCopy(assignedSnapshotFrameBuffer, texName);
}
void TGameLevel::Draw()
{
InnerDraw(Renderer->GetScreenWidth(), Renderer->GetScreenHeight(), Renderer->GetMatrixWidth(), Renderer->GetMatrixHeight());
InnerDraw(Renderer->GetScreenWidth(), Renderer->GetScreenHeight(), Renderer->GetMatrixWidth(), Renderer->GetMatrixHeight(), false);
}
void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, int matrixHeight)
void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, int matrixHeight, bool blackAndWhite)
{
// Scaling math
@@ -815,9 +833,9 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->TranslateMatrix(Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
Renderer->ScaleMatrix(scale);
Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[LevelScreenTexture]);
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[levelName + "_prerendered"]);
Renderer->DrawRect(Vector2f(xlOffset, ylOffset), Vector2f(xlOffset+tSW, ylOffset+tSH), Vector2f (0.f,0.f), Vector2f(1.f,1.f)); // Game Screen Scale
Renderer->PopMatrix();
Renderer->PopMatrix();
CheckGlError();
return;
}
@@ -830,7 +848,7 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
bool renderBufferReady = RenderBufferReady;
/*
if (pause && renderBufferReady)
{
@@ -847,6 +865,8 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
}
Renderer->PopMatrix();
CheckGlError();
drawOutline(screenWidth, screenHeight);
return;
}
@@ -858,7 +878,7 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
CheckGlError();
}*/
}
// Level background
// :::::::::::
@@ -907,7 +927,16 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
std::list<std::pair<PairColorTexture, TTriangleList>>::iterator colorBlockIterator;
for (colorBlockIterator = BlockInstansingList.ColorBlockList.begin(); colorBlockIterator != BlockInstansingList.ColorBlockList.end(); ++colorBlockIterator)
{
RenderUniform4fv("BrickColor", colorBlockIterator->first.first.data());
Vector4f color = colorBlockIterator->first.first;
if (blackAndWhite)
{
float c = (color(0) * 0.3 + color(1) * 0.59 + color(2) * 0.11);
color(0) = c;
color(1) = c;
color(2) = c;
}
RenderUniform4fv("BrickColor", color.data());
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[colorBlockIterator->first.second]);
Renderer->DrawTriangleList(colorBlockIterator->second);
@@ -923,7 +952,9 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Application->EffectsDraw();
DrawBallInstancingList();
DrawBallInstancingList(blackAndWhite);
Renderer->PopShader();
@@ -962,7 +993,7 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
}
/*/
if (!pause && LevelState != CONST_LEVELSTATE_SNAPSHOTTING)
{
RenderUniform1f("Transparency", 1.f);
@@ -972,19 +1003,21 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
const float const_backBtnHeight = CONST_BACK_BTN_HEIGHT * Application->GetGameLevelScreenHeight()/320.f;
Renderer->DrawRect(Vector2f(-const_backBtnWidth*0.5f, -const_backBtnHeight*0.5f)+BackBtnPos, Vector2f(const_backBtnWidth*0.5f, const_backBtnHeight*0.5f)+BackBtnPos);
}
drawOutline(screenWidth, screenHeight);
if (pause && !renderBufferReady)
{
//ololo
//See also above (same method)
Renderer->SwitchToScreen();
Renderer->SetFullScreenViewport();
Renderer->PushMatrix();
//Renderer->LoadIdentity();
Renderer->TranslateMatrix(Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
//Renderer->TranslateMatrix(Vector3f(Application->GetGameLevelScreenWidth(), Application->GetGameLevelScreenHeight(), 0));
Renderer->ScaleMatrix(OutScale);
Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
DrawBuffer();
@@ -995,12 +1028,11 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->PopMatrix();
RenderBufferReady = true;
CheckGlError();
}*/
}
drawOutline(screenWidth, screenHeight);
CheckGlError();
}
@@ -1016,11 +1048,22 @@ void TGameLevel::DrawPauseButtons() //continue from
}
void TGameLevel::DrawBallInstancingList()
void TGameLevel::DrawBallInstancingList(bool blackAndWhite)
{
RenderUniform1f("Transparency", 1.f);
RenderUniform4fv("BrickColor", BallColor.data());
Vector4f color = BallColor;
if (blackAndWhite)
{
float c = (color(0) * 0.3 + color(1) * 0.59 + color(2) * 0.11);
color(0) = c;
color(1) = c;
color(2) = c;
}
RenderUniform4fv("BrickColor", color.data());
if (BonusGothroughTimer > 0.f)
{
@@ -1237,11 +1280,11 @@ void TGameLevel::Update(size_t dt)
//Bonus floor pos
if (BonusFloorTimer/CONST_BONUS_GOTHROUGH_TIME < 0.2f)
{
//Bonus must go down until 0.f
if (BonusFloorPosY > 0.f)
//Bonus must go down until - 20.f
if (BonusFloorPosY > -20.f)
{
BonusFloorPosY -= CONST_BONUS_FLOOR_APPEAR_SPEED * dt / 1000.f;
BonusFloorPosY = max_t(BonusFloorPosY, 0.f);
BonusFloorPosY = max_t(BonusFloorPosY, -20.f);
}
}
+6 -6
View File
@@ -32,7 +32,7 @@ const float CONST_BONUS_CATCH_DISTANCE_X = 65.f;
const float CONST_BONUS_CATCH_DISTANCE_Y = 20.f;
const float CONST_BONUS_FLOOR_TIME = 8000.f;
const float CONST_BONUS_FLOOR_APPEAR_SPEED = 50.f;
const float CONST_BONUS_FLOOR_APPEAR_SPEED = 80.f;
const int CONST_BONUS_TYPE_MULTIPLIER = 0;
const int CONST_BONUS_TYPE_GOTHROUGH = 1;
@@ -127,7 +127,7 @@ protected:
float lvlWidth;
float lvlHeight;
std::string BkgTexture;
std::string LevelScreenTexture;
//std::string LevelScreenTexture;
std::string LevelFileName;
GLuint prerenderedImage;
@@ -152,7 +152,7 @@ protected:
void DrawBuffer();
void DrawPauseButtons();
void DrawBallInstancingList();
void DrawBallInstancingList(bool blackAndWhite);
void drawOutline(int screenWidth, int screenHeight);
@@ -194,7 +194,7 @@ public:
~TGameLevel();
void FillWithFile(const std::string& filename);
void setBackground(const std::string& assignedShutterstock);
//void setBackground(const std::string& assignedShutterstock);
//void SetLevelScale();
//Vector2f GetLevelScale();
@@ -204,8 +204,8 @@ public:
bool IsLoaded();
virtual void Draw();
void InnerDraw(int screenWidth, int screenHeight, int matrixWidth, int matrixHeight);
void DrawSnapshot(const std::string& assignedSnapshotFrameBuffer);
void InnerDraw(int screenWidth, int screenHeight, int matrixWidth, int matrixHeight, bool blackAndWhite);
void DrawSnapshot(const std::string& assignedSnapshotFrameBuffer, bool blackAndWhite);
void SetPause();
bool IsPaused();
+154 -35
View File
@@ -61,8 +61,8 @@ void TMyApplication::InnerInit()
#ifdef TARGET_WIN32
#ifdef NDEBUG
//ST::PathToResources = "resources/";
ST::PathToResources = "../../../assets/";
ST::PathToResources = "resources/";
//ST::PathToResources = "../../../assets/";
#else
ST::PathToResources = "../../../assets/";
#endif
@@ -93,6 +93,7 @@ void TMyApplication::InnerInit()
//ResourceManager->ShaderManager.AddShader("DefaultShader", "shaders/texture-shader.vertex", "shaders/texture-shader.fragment");
ResourceManager->ShaderManager.AddShader("DefaultShader", "shaders/gui_transparent.vertex", "shaders/gui_transparent.fragment");
ResourceManager->ShaderManager.AddShader("BlackAndWhiteShader", "shaders/gui_transparent_blackandwhite.vertex", "shaders/gui_transparent_blackandwhite.fragment");
ResourceManager->ShaderManager.AddShader("ColorShader", "shaders/color-shader.vertex", "shaders/color-shader.fragment");
ResourceManager->ShaderManager.AddShader("FrameShader", "shaders/frameshader_vertex.txt", "shaders/frameshader_fragment.txt");
ResourceManager->ShaderManager.AddShader("BrickShader", "shaders/brickshader_vertex.txt", "shaders/brickshader_fragment.txt");
@@ -107,7 +108,7 @@ void TMyApplication::InnerInit()
ResourceManager->TexList.AddTexture("white.bmp");
ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 512, 512);
ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 256, 256);
//OnDrawSignal.connect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
Inited = true;
@@ -125,7 +126,7 @@ void TMyApplication::InnerInit()
ResourceManager->FontManager.PushFont("lucon12");
//ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json");
ResourceManager->newGuiManager.LoadFromConfig("gui_loading.json");
//SetButtonsAction();
// ------- UI -------
// TESTS of menu
@@ -266,7 +267,7 @@ void TMyApplication::LoadResources()
boost::property_tree::ptree Textures_pt = SE::ReadJsonFile(ST::PathToResources + "bg_textures_config.json");
//boost::property_tree::json_parser::read_json(ST::PathToResources + "bg_textures_config.json", Textures_pt);
std::string bg_ext = ".jpeg";
std::string bg_ext = ".jpg";
// :::::::::::::::::::::::::::::::::::::
@@ -450,8 +451,8 @@ void TMyApplication::InnerUpdate(size_t dt)
TextureNamesToLoad.erase(TextureNamesToLoad.begin());
}
else
{
else
{
Renderer->SwitchToFrameBuffer("LevelBuffer");
@@ -461,23 +462,27 @@ void TMyApplication::InnerUpdate(size_t dt)
for (auto &star : Menu.GalaxMenu.galaxies[0].Stars)
{
for (auto &level : star.selectionMenu.gameLevels)
for (auto level : star.selectionMenu.gameLevels)
{
level.DrawSnapshot("LevelBuffer");
break;
level->DrawSnapshot("LevelBuffer", false);
Renderer->PushShader("BlackAndWhiteShader");
level->DrawSnapshot("LevelBuffer", true);
Renderer->PopShader();
}
break;
}
Renderer->SwitchToScreen();
Renderer->SetOrthoProjection();
GameState = CONST_GAMESTATE_MENU;
ApplySignalsToMenu();
ResourceManager->newGuiManager.Clear();
ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json");
//OnDrawSignal.disconnect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
GameState = CONST_GAMESTATE_MENU;
ApplySignalsToMenu();
LoadGalaxyUi();
OnDrawSignal.connect(0, boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
StateTimer = 0.f;
Loaded = true;
@@ -540,7 +545,122 @@ void TMyApplication::InnerUpdate(size_t dt)
}
void TMyApplication::GoFromMenuToGame(TGameLevel* level)
void TMyApplication::LoadGalaxyUi()
{
ResourceManager->newGuiManager.Clear();
ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json");
std::shared_ptr<WidgetAncestor> modal_background = ResourceManager->newGuiManager.findWidgetByName("modal_background");
modal_background->onMouseUpSignal.connect(
[modal_background](Vector2f v, int i) {
modal_background->visible = false;
});
}
void TMyApplication::SetupGalaxyUi(size_t levelStar)
{
std::shared_ptr<WidgetAncestor> modal_background = ResourceManager->newGuiManager.findWidgetByName("modal_background");
std::shared_ptr<WidgetAncestor> row2 = ResourceManager->newGuiManager.findWidgetByName("row2");
std::shared_ptr<WidgetAncestor> row3 = ResourceManager->newGuiManager.findWidgetByName("row3");
std::shared_ptr<WidgetAncestor> row4 = ResourceManager->newGuiManager.findWidgetByName("row4");
size_t levelCount = this->Menu.GalaxMenu.galaxies[0].Stars[levelStar].selectionMenu.gameLevels.size();
if (levelCount <= 3)
{
row2->setVisibility(false);
}
else
{
row2->setVisibility(true);
}
if (levelCount <= 6)
{
row3->setVisibility(false);
}
else
{
row3->setVisibility(true);
}
if (levelCount <= 9)
{
row4->setVisibility(false);
}
else
{
row4->setVisibility(true);
}
std::string levelStarString = boost::lexical_cast<std::string>(levelStar);
for (size_t levelIndex = 0; levelIndex < 12; levelIndex++)
{
std::string levelIndexString = boost::lexical_cast<std::string>(levelIndex);
std::shared_ptr<WidgetAncestor> currentLevelButton = ResourceManager->newGuiManager.findWidgetByName("button" + levelIndexString);
currentLevelButton->onMouseUpSignal.disconnect_all_slots();
if (levelIndex < levelCount)
{
std::string levelName = this->Menu.GalaxMenu.galaxies[0].Stars[levelStar].selectionMenu.gameLevels[levelIndex]->levelName;
if (IsLevelOpened(levelStar, levelIndex))
{
currentLevelButton->setVisibility(true);
currentLevelButton->setBackground(levelName + "_prerender");
currentLevelButton->onMouseUpSignal.connect(
[this, modal_background, levelStar, levelIndex](Vector2f v, int i) {
modal_background->visible = false;
std::shared_ptr<TGameLevel> lvl = this->Menu.GalaxMenu.galaxies[0].Stars[levelStar].selectionMenu.gameLevels[levelIndex];
lvl->ReloadLevel();
this->GoFromMenuToGame(lvl);
});
}
else
{
currentLevelButton->setBackground(levelName + "_prerender_blackandwhite");
}
//currentLevelButton->OnMouseUp(Vector2f(), 0);
}
else
{
currentLevelButton->setVisibility(false);
}
}
}
void TMyApplication::GoFromMenuToGame(std::shared_ptr<TGameLevel> level)
{
//#ifndef TARGET_IOS
// ResourceManager->SoundManager.PlayMusicLooped("level1ogg.ogg");
@@ -637,14 +757,7 @@ float TMyApplication::GetGameLevelScreenHeight()
}
void TMyApplication::InnerOnMouseDown(TMouseState& mouseState) {
/*
if (mouseState.LeftButtonPressed) {
if ((float)mouseState.X >= (Renderer->GetScreenWidth())*0.25f && (float)mouseState.X <= (Renderer->GetScreenWidth())*0.75f && (float)mouseState.Y >= (Renderer->GetScreenHeight())*0.25f && (float)mouseState.Y <= (Renderer->GetScreenHeight())*0.75f) {
// some tmp code
Application->GoFromMenuToGame(1);
}
}
*/
OnTapDownSignal(Vector2f(mouseState.X, ((Renderer->GetScreenHeight()) - mouseState.Y))); // Temp mouse down action for WIN32
}
@@ -652,6 +765,22 @@ void TMyApplication::InnerOnMouseMove(TMouseState& mouseState) {
}
bool TMyApplication::IsLevelOpened(int levelStar, int levelIndex)
{
if (levelStar == 0)
{
return true;
}
if (levelStar == 1 && levelIndex < 3)
{
return true;
}
return false;
}
void TMyApplication::EffectsInit() {
boost::property_tree::ptree JSONsource;
@@ -738,13 +867,3 @@ void TMyApplication::fireworkEffect() {
lvlFirework.stopSpawn();
lvlFirework.startSpawn();
}
void TMyApplication::SetButtonsAction () {
auto backBtn = ResourceManager->newGuiManager.findWidgetByName("backButton");
if (backBtn) {
backBtn->onMouseDownSignal.connect([this, backBtn](Vector2f pos, int touchNumber) {
this->GameLevel->SetPause();
this->GameLevel->PrevLevelStateIsStandby = true;
});
}
}
+12 -3
View File
@@ -98,7 +98,7 @@ protected:
ParticleEffect lvlFirework; // Level finished effect
TGameMenu Menu;
TGameLevel* GameLevel;
std::shared_ptr<TGameLevel> GameLevel;
TGameCredits GameCredits;
TGameLoading GameLoading;
@@ -119,13 +119,20 @@ protected:
void ApplySignalsToCredits();
void DisapplySignalsToCredits();
void EffectsInit();
// Mouse new methods
virtual void InnerOnMouseDown(TMouseState& mouseState);
virtual void InnerOnMouseMove(TMouseState& mouseState);
bool IsLevelOpened(int levelStar, int levelIndex);
public:
bool Loaded;
@@ -139,7 +146,7 @@ public:
virtual void InnerUpdate(size_t dt);
void GoFromMenuToGame(TGameLevel* level);
void GoFromMenuToGame(std::shared_ptr<TGameLevel> gameLevel);
void GoFromGameToMenu();
void GoFromMenuToCredits();
void GoFromCreditsToMenu();
@@ -180,7 +187,9 @@ public:
float GetGameLevelScreenHeight();
void SetGameLevelScreenScale();
void SetButtonsAction();
void LoadGalaxyUi();
void SetupGalaxyUi(size_t levelStar);
};