Browse Source

Add titles to level select screen

master
C. J. Howard 6 years ago
parent
commit
483473c646
4 changed files with 52 additions and 7 deletions
  1. +1
    -1
      data
  2. +34
    -2
      src/application.cpp
  3. +3
    -0
      src/application.hpp
  4. +14
    -4
      src/states/level-select-state.cpp

+ 1
- 1
data

@ -1 +1 @@
Subproject commit 3335c35bc91dedb10a91f1528913354a7b7657e7
Subproject commit 5774a045d436a87c8ac7173df9131543bbebb99f

+ 34
- 2
src/application.cpp View File

@ -1023,14 +1023,32 @@ bool Application::loadUI()
contextButtonImage0->setDimensions(Vector2(mouseLeftTexture->getWidth(), mouseLeftTexture->getHeight()));
contextButtonImage0->setTranslation(Vector2(0.0f, -16.0f));
contextButtonImage0->setTexture(mouseLeftTexture);
uiRootElement->addChild(contextButtonImage0);
//uiRootElement->addChild(contextButtonImage0);
foodIndicatorImage = new UIImage();
foodIndicatorImage->setAnchor(Vector2(1.0f, 0.0f));
foodIndicatorImage->setDimensions(Vector2(foodIndicatorTexture->getWidth(), foodIndicatorTexture->getHeight()));
foodIndicatorImage->setTranslation(Vector2(-16.0f, 16.0f));
foodIndicatorImage->setTexture(foodIndicatorTexture);
uiRootElement->addChild(foodIndicatorImage);
//uiRootElement->addChild(foodIndicatorImage);
// Create level ID
levelIDLabel = new UILabel();
levelIDLabel->setAnchor(Vector2(0.5f, 0.0f));
levelIDLabel->setFont(menuFont);
levelIDLabel->setTranslation(Vector2(0.0f, (int)(height * (1.0f / 4.0f) - menuFont->getMetrics().getHeight() * 1.5f)));
levelIDLabel->setText("");
levelIDLabel->setVisible(false);
uiRootElement->addChild(levelIDLabel);
// Create level name label
levelNameLabel = new UILabel();
levelNameLabel->setAnchor(Vector2(0.5f, 0.0f));
levelNameLabel->setFont(menuFont);
levelNameLabel->setTranslation(Vector2(0.0f, (int)(height * (1.0f / 4.0f) - menuFont->getMetrics().getHeight() * 0.5f)));
levelNameLabel->setText("");
levelNameLabel->setVisible(false);
uiRootElement->addChild(levelNameLabel);
// Create toolbar
toolbar = new Toolbar();
@ -1589,6 +1607,20 @@ void Application::selectLevel(std::size_t index)
{
levelPlaceholderModelInstances[i].setTranslation(Vector3(ANTKEEPER_LEVEL_SPACING, 0.0f, 0.0f) * static_cast<float>(previewLevelIndices[i]));
}
// Set level ID label
std::stringstream stream;
stream << (currentWorldIndex + 1) << "-" << (currentLevelIndex + 1);
levelIDLabel->setText(stream.str());
// Set level name label
char levelIDBuffer[6];
std::sprintf(levelIDBuffer, "%02d-%02d", currentWorldIndex + 1, currentLevelIndex + 1);
std::string levelID(levelIDBuffer);
std::string levelName;
strings.get(levelIDBuffer, &levelName);
std::cout << levelID << std::endl;
levelNameLabel->setText(levelName);
}
void Application::selectNextLevel()

+ 3
- 0
src/application.hpp View File

@ -305,6 +305,9 @@ public:
UIImage* contextButtonImage0;
UIImage* contextButtonImage1;
UILabel* levelIDLabel;
UILabel* levelNameLabel;
Toolbar* toolbar;
PieMenu* pieMenu;

+ 14
- 4
src/states/level-select-state.cpp View File

@ -18,6 +18,7 @@
*/
#include "level-select-state.hpp"
#include "main-menu-state.hpp"
#include "../application.hpp"
LevelSelectState::LevelSelectState(Application* application):
@ -29,16 +30,19 @@ LevelSelectState::~LevelSelectState()
void LevelSelectState::enter()
{
levelRotation = 0.0f;
for (int i = 0; i < 5; ++i)
{
ModelInstance* instance = &application->levelPlaceholderModelInstances[i];
instance->setRotation(glm::angleAxis(levelRotation, Vector3(0, 1, 0)));
application->defaultLayer->addObject(instance);
}
application->camera.lookAt(Vector3(0, 8, 12), Vector3(0, 1, 0), Vector3(0, 1, 0));
application->levelIDLabel->setVisible(true);
application->levelNameLabel->setVisible(true);
application->selectLevel(0);
levelRotation = 0.0f;
application->camera.lookAt(Vector3(0, 8, 12), Vector3(0, 1, 0), Vector3(0, 1, 0));
}
void LevelSelectState::execute()
@ -68,7 +72,7 @@ void LevelSelectState::execute()
}
else if (application->menuCancel.isTriggered() && !application->menuCancel.wasTriggered())
{
application->changeState(application->mainMenuState);
}
// Rotate levels
@ -82,5 +86,11 @@ void LevelSelectState::execute()
void LevelSelectState::exit()
{
for (int i = 0; i < 5; ++i)
{
ModelInstance* instance = &application->levelPlaceholderModelInstances[i];
application->defaultLayer->removeObject(instance);
}
application->levelIDLabel->setVisible(false);
application->levelNameLabel->setVisible(false);
}

Loading…
Cancel
Save