diff --git a/data b/data index 3335c35..5774a04 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 3335c35bc91dedb10a91f1528913354a7b7657e7 +Subproject commit 5774a045d436a87c8ac7173df9131543bbebb99f diff --git a/src/application.cpp b/src/application.cpp index c4bc120..8d40418 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -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(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() diff --git a/src/application.hpp b/src/application.hpp index b2ac9bc..cf6c1eb 100644 --- a/src/application.hpp +++ b/src/application.hpp @@ -305,6 +305,9 @@ public: UIImage* contextButtonImage0; UIImage* contextButtonImage1; + UILabel* levelIDLabel; + UILabel* levelNameLabel; + Toolbar* toolbar; PieMenu* pieMenu; diff --git a/src/states/level-select-state.cpp b/src/states/level-select-state.cpp index 8f78b6f..c37d834 100644 --- a/src/states/level-select-state.cpp +++ b/src/states/level-select-state.cpp @@ -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); }