This commit is contained in:
emil.kabirov committed 2018-10-18 13:24:17 +05:00
1 parent a9f6a9be2b
commit 99cd961d44
9 files changed
+167 -63

No files matched your search

+43 -53
View File
@@ -911,10 +911,10 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
//Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
DrawBuffer();
if (mustShowButtons)
{
DrawPauseButtons();
}
//if (mustShowButtons)
//{
// DrawPauseButtons();
//}
//Renderer->PopMatrix();
CheckGlError();
@@ -1079,12 +1079,12 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
if (!pause && LevelState != CONST_LEVELSTATE_SNAPSHOTTING)
{
RenderUniform1f("Transparency", 1.f);
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_BACK_BTN_TEXTURE]);
const Vector2f BackBtnPos(screenWidth*0.5f, Application->GetGameLevelScreenHeight() - 52.f*(Application->GetGameLevelScreenHeight()/320.f));
const float const_backBtnWidth = CONST_BACK_BTN_WIDTH * Application->GetGameLevelScreenWidth()/480.f;
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);
// RenderUniform1f("Transparency", 1.f);
// glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_BACK_BTN_TEXTURE]);
// const Vector2f BackBtnPos(screenWidth*0.5f, Application->GetGameLevelScreenHeight() - 52.f*(Application->GetGameLevelScreenHeight()/320.f));
//const float const_backBtnWidth = CONST_BACK_BTN_WIDTH * Application->GetGameLevelScreenWidth()/480.f;
//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);
@@ -1104,10 +1104,10 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->ScaleMatrix(OutScale);
Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
DrawBuffer();
if (mustShowButtons)
{
DrawPauseButtons();
}
//if (mustShowButtons)
//{
// DrawPauseButtons();
//}
Renderer->PopMatrix();
RenderBufferReady = true;
CheckGlError();
@@ -1200,6 +1200,10 @@ void TGameLevel::DrawBuffer()
void TGameLevel::SetPause()
{
if (LevelState == CONST_LEVELSTATE_STANDBY)
{
PrevLevelStateIsStandby = true;
}
OutScaleVelocity = 0.f;
OutScale = 1.f;
@@ -1254,7 +1258,7 @@ void TGameLevel::Update(size_t dt)
if (LevelState == CONST_LEVELSTATE_PAUSE)
{
OutScale += OutScaleVelocity * dt;
TryGoToMenu();
//TryGoToMenu();
CheckGlError();
return;
}
@@ -1825,37 +1829,20 @@ void TGameLevel::OnTapDown(Vector2f pos)
if (LevelState == CONST_LEVELSTATE_STANDBY)
{
if (TapInBackBtnArea({ xPos, yPos }))
{
SetPause();
PrevLevelStateIsStandby = true;
}
else
{
LevelState = CONST_LEVELSTATE_PLAYING;
BallList.begin()->Go();
}
LevelState = CONST_LEVELSTATE_PLAYING;
BallList.begin()->Go();
}
else if (LevelState == CONST_LEVELSTATE_PLAYING)
{
if (TapInBackBtnArea({ xPos, yPos }))
{
SetPause();
}
else// if (fabs(ReflectorPos(0) - xPos / Application->GetGameLevelScreenWidth()) > 64.f / Application->GetGameLevelScreenWidth())
{
ReflectorPos(0) = xPos / Application->GetGameLevelScreenWidth();
}
}
else if (LevelState == CONST_LEVELSTATE_PAUSE)
{
if (yPos > 128.f)
{
ReleasePause();
}
ReflectorPos(0) = xPos / Application->GetGameLevelScreenWidth();
}
//else if (LevelState == CONST_LEVELSTATE_PAUSE)
//{
// if (yPos > 128.f)
// {
// ReleasePause();
// }
//}
}
void TGameLevel::OnTapUp(Vector2f pos)
@@ -1886,23 +1873,26 @@ void TGameLevel::OnScroll(Vector2f shift)
OutScale += shift(1)/320.f;
TryGoToMenu();
//TryGoToMenu();
}
}
void TGameLevel::TryGoToMenu()
{
if (OutScale < 0.5f)
{
OutScale = 0.5f;
LevelState = CONST_LEVELSTATE_NODRAW;
Application->GoFromGameToMenu();
}
if (OutScale > 1.f)
{
OutScale = 1.f;
}
LevelState = CONST_LEVELSTATE_NODRAW;
Application->GoFromGameToMenu();
//if (OutScale < 0.5f)
//{
// OutScale = 0.5f;
// LevelState = CONST_LEVELSTATE_NODRAW;
// Application->GoFromGameToMenu();
//}
//if (OutScale > 1.f)
//{
// OutScale = 1.f;
//}
}
bool TBrick::IsAppear() {
+71 -10
View File
@@ -57,6 +57,11 @@ TMyApplication* Application;
int currentStar;
int currentLevel;
boost::property_tree::ptree gamePauseMenuUi;
boost::property_tree::ptree galaxyMenuUi;
bool ignoreTapUp = false;
void TMyApplication::LoadUserProgress()
{
boost::property_tree::ptree userProgressJson;
@@ -143,7 +148,7 @@ void TMyApplication::InnerInit()
#ifdef TARGET_WIN32
#ifdef NDEBUG
ST::PathToResources = "resources/";
//ST::PathToResources = "../../../assets/";
ST::PathToResources = "../../../assets/";
#else
ST::PathToResources = "../../../assets/";
#endif
@@ -203,6 +208,10 @@ void TMyApplication::InnerInit()
EffectsInit();
// ------- UI -------
boost::property_tree::json_parser::read_json(ST::PathToResources + "gui_game_pause_menu.json", gamePauseMenuUi);
boost::property_tree::json_parser::read_json(ST::PathToResources + "gui_main_menu.json", galaxyMenuUi);
ResourceManager->FontManager.AddFont("arial32", "arial32.png", "arial32.txt");
ResourceManager->FontManager.AddFont("lucon12", "lucon12.png", "lucon12.txt");
ResourceManager->FontManager.PushFont("lucon12");
@@ -253,11 +262,21 @@ void TMyApplication::InnerDeinit()
void TMyApplication::InnerOnTapUp(Vector2f p)
{
if (ignoreTapUp)
{
return;
}
OnTapUpSignal(Vector2f(p(0), p(1)));
}
void TMyApplication::InnerOnTapUpAfterMove(Vector2f p)
{
if (ignoreTapUp)
{
return;
}
OnTapUpAfterMoveSignal(Vector2f(p(0), p(1)));
}
@@ -422,9 +441,9 @@ void TMyApplication::LoadResources()
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_WALL_UP_TEXTURE + ".png", CONST_WALL_UP_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_WALL_BONUS_TEXTURE + ".png", CONST_WALL_BONUS_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_REFLECTOR_TEXTURE + ".png", CONST_REFLECTOR_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BACK_BTN_TEXTURE + ".png", CONST_BACK_BTN_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_SLIDE_UP_BTN_TEXTURE + ".png", CONST_SLIDE_UP_BTN_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_TAP_TO_CONTINUE_BTN_TEXTURE + ".png", CONST_TAP_TO_CONTINUE_BTN_TEXTURE));
//TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BACK_BTN_TEXTURE + ".png", CONST_BACK_BTN_TEXTURE));
//TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_SLIDE_UP_BTN_TEXTURE + ".png", CONST_SLIDE_UP_BTN_TEXTURE));
//TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_TAP_TO_CONTINUE_BTN_TEXTURE + ".png", CONST_TAP_TO_CONTINUE_BTN_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_CREDITS_TEXTURE + ".png", CONST_CREDITS_TEXTURE));
#ifdef TARGET_IOS
@@ -577,6 +596,36 @@ void TMyApplication::InnerUpdate(size_t dt)
//CONNECT SLOT
DisapplySignalsToMenu();
ApplySignalsToGame();
ResourceManager->newGuiManager.LoadFromConfig(gamePauseMenuUi);
auto pauseButton = (Button*)ResourceManager->newGuiManager.findWidgetByName("pauseButton").get();
auto resumeButton = (Button*)ResourceManager->newGuiManager.findWidgetByName("resumeButton").get();
auto exitButton = (Button*)ResourceManager->newGuiManager.findWidgetByName("exitButton").get();
auto gameFrame = (WidgetAncestor*)ResourceManager->newGuiManager.findWidgetByName("gameFrame").get();
auto pauseBackground = (WidgetAncestor*)ResourceManager->newGuiManager.findWidgetByName("buttonList").get();
pauseButton->onMouseDownSignal.connect([this, gameFrame, pauseBackground](Vector2f, int) {
GameLevel->SetPause();
gameFrame->setVisibility(false);
pauseBackground->setVisibility(true);
});
resumeButton->onMouseDownSignal.connect([this, gameFrame, pauseBackground](Vector2f, int) {
GameLevel->ReleasePause();
gameFrame->setVisibility(true);
pauseBackground->setVisibility(false);
});
pauseBackground->onMoveSignal.connect([this](Vector2f, Vector2f shift, int) {
SE::GetConsole() << shift.norm();
if (shift.norm() > 15)
{
GameLevel->TryGoToMenu();
}
});
}
}
else if (GameState == CONST_GAMESTATE_FROM_MENU_TO_CREDITS)
@@ -616,7 +665,7 @@ void TMyApplication::InnerUpdate(size_t dt)
void TMyApplication::LoadGalaxyUi()
{
ResourceManager->newGuiManager.Clear();
ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json");
ResourceManager->newGuiManager.LoadFromConfig(galaxyMenuUi);
std::shared_ptr<WidgetAncestor> modal_background = ResourceManager->newGuiManager.findWidgetByName("modal_background");
@@ -756,11 +805,21 @@ void TMyApplication::GoFromGameToMenu()
//#ifndef TARGET_IOS
// ResourceManager->SoundManager.StopMusic("level1ogg.ogg");
//#endif
TrySaveGame();
DisapplySignalsToGame();
ApplySignalsToMenu();
GameState = CONST_GAMESTATE_MENU;
OnDrawSignal.disconnect(boost::bind(&TGameLevel::Draw, boost::ref(GameLevel)));
PerformInMainThreadAsync([this]() {
TrySaveGame();
DisapplySignalsToGame();
ignoreTapUp = true;
LoadGalaxyUi();
Menu.GalaxMenu.UpdateGalaxyMenu(Renderer->GetMatrixWidth(), Renderer->GetMatrixHeight(), 0);
ApplySignalsToMenu();
GameState = CONST_GAMESTATE_MENU;
OnDrawSignal.disconnect(boost::bind(&TGameLevel::Draw, boost::ref(GameLevel)));
});
}
void TMyApplication::GoFromMenuToCredits()
@@ -835,6 +894,8 @@ float TMyApplication::GetGameLevelScreenHeight()
void TMyApplication::InnerOnMouseDown(TMouseState& mouseState) {
ignoreTapUp = false;
OnTapDownSignal(Vector2f(mouseState.X, ((Renderer->GetScreenHeight()) - mouseState.Y))); // Temp mouse down action for WIN32
}