SettingsState::SettingsState(StateStack& stack, Context context) : State(stack, context) , mGUIContainer() { mBackgroundSprite.setTexture(context.textures->get(Textures::TitleScreen)); // Build key binding buttons and labels addButtonLabel(Player::MoveLeft, 150.f, "Move Left", context); addButtonLabel(Player::MoveRight, 200.f, "Move Right", context); addButtonLabel(Player::MoveUp, 250.f, "Move Up", context); addButtonLabel(Player::MoveDown, 300.f, "Move Down", context); updateLabels(); auto backButton = std::make_shared<GUI::Button>(*context.fonts, *context.textures); backButton->setPosition(80.f, 375.f); backButton->setText("Back"); backButton->setCallback(std::bind(&SettingsState::requestStackPop, this)); mGUIContainer.pack(backButton); }
SettingsState::SettingsState(StateStack& stack, Context context) : State(stack, context), backgroundSprite(), guiContainer(), bindingButtons(), bindingLabels() { backgroundSprite.setTexture(context.textures->get(Textures::TitleScreen)); // Build key binding buttons and labels for(std::size_t x=0; x<2; ++x) { addButtonLabel(PlayerActions::MoveLeft, x, 0, "Move Left", context); addButtonLabel(PlayerActions::MoveRight, x, 1, "Move Right", context); addButtonLabel(PlayerActions::MoveUp, x, 2, "Move Up", context); addButtonLabel(PlayerActions::MoveDown, x, 3, "Move Down", context); addButtonLabel(PlayerActions::Fire, x, 4, "Fire", context); addButtonLabel(PlayerActions::LaunchMissile, x, 5, "Missile", context); } updateLabels(); auto backButton = std::make_shared<GUI::Button>(context); backButton->setPosition(80.f, 620.f); backButton->setText("Back"); backButton->setCallback(std::bind(&SettingsState::requestStackPop, this)); guiContainer.pack(backButton); }
SettingsState::SettingsState(StateStack& stack, Context context) : State(stack, context), mGUIContainer() { mBackgroundSprite.setTexture(context.textures->get(Textures::TitleScreen)); sf::Vector2f windowSize(context.window->getSize()); // Labeling according to button addButtonLabel(Player::MoveLeft, 300.f, "Move Left", context); addButtonLabel(Player::MoveRight, 350.f, "Move Right", context); addButtonLabel(Player::MoveUp, 400.f, "Move Up", context); addButtonLabel(Player::MoveDown, 450.f, "Move Down", context); addButtonLabel(Player::Fire, 500.f, "Fire", context); addButtonLabel(Player::Special, 550.f, "Special", context); updateLabels(); auto backButton = std::make_shared<GUI::Button>(context); backButton->setPosition(0.4f * windowSize.x, 0.8f * windowSize.y); backButton->setText("Back"); backButton->setCallback(std::bind(&SettingsState::requestStackPop, this)); mGUIContainer.pack(backButton); }