Beispiel #1
0
SettingsMenu::SettingsMenu(int w, int h)
    : GuiFrame(w, h)
    , categorySelectionFrame(w, h)
    , particleBgImage(w, h, 50)
    , buttonClickSound(Resources::GetSound("settings_click_2.mp3"))
    , quitImageData(Resources::GetImageData("quitButton.png"))
    , categoryImageData(Resources::GetImageData("settingsCategoryButton.png"))
    , categoryBgImageData(Resources::GetImageData("settingsCategoryBg.png"))
    , quitImage(quitImageData)
    , quitButton(quitImage.getWidth(), quitImage.getHeight())
    , touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
    , wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
    , buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true)
    , buttonBTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_B, true)
    , buttonLTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_L, true)
    , buttonRTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_R, true)
    , buttonLeftTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_LEFT | GuiTrigger::STICK_L_LEFT, true)
    , buttonRightTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_RIGHT | GuiTrigger::STICK_L_RIGHT, true)
    , leftArrowImageData(Resources::GetImageData("leftArrow.png"))
    , rightArrowImageData(Resources::GetImageData("rightArrow.png"))
    , leftArrowImage(leftArrowImageData)
    , rightArrowImage(rightArrowImageData)
    , leftArrowButton(leftArrowImage.getWidth(), leftArrowImage.getHeight())
    , rightArrowButton(rightArrowImage.getWidth(), rightArrowImage.getHeight())
    , DPADButtons(w,h)
{
    currentPosition = 0;
    targetPosition = 0;
    selectedCategory = 0;
    animationSpeed = 25;
    bUpdatePositions = true;

    quitButton.setImage(&quitImage);
    quitButton.setAlignment(ALIGN_BOTTOM | ALIGN_LEFT);
    quitButton.clicked.connect(this, &SettingsMenu::OnQuitButtonClick);
    quitButton.setTrigger(&touchTrigger);
    quitButton.setTrigger(&wpadTouchTrigger);
    quitButton.setEffectGrow();
    quitButton.setSoundClick(buttonClickSound);
    categorySelectionFrame.append(&quitButton);

    versionText.setColor(glm::vec4(0.6f, 0.6f, 0.6f, 1.0f));
    versionText.setFontSize(42);
    versionText.setAlignment(ALIGN_TOP | ALIGN_RIGHT);
    versionText.setPosition(-50, -80);
    versionText.setText("Loadiine GX2 " LOADIINE_VERSION);
    categorySelectionFrame.append(&versionText);

    const u32 cuCategoriesCount = sizeof(stSettingsCategories) / sizeof(stSettingsCategories[0]);

    if(cuCategoriesCount > 0) selectedCategory = 0;

    for(u32 idx = 0; idx < cuCategoriesCount; idx++)
    {
        settingsCategories.resize(idx + 1);
        GuiSettingsCategory & category = settingsCategories[idx];

        std::vector<std::string> splitDescriptions = stringSplit(stSettingsCategories[idx].descriptions, "\n");

        category.categoryIconData = Resources::GetImageData(stSettingsCategories[idx].icon);
        category.categoryIconGlowData = Resources::GetImageData(stSettingsCategories[idx].iconGlow);

        category.categoryLabel = new GuiText(tr(stSettingsCategories[idx].name), 46, glm::vec4(0.8f, 0.8f, 0.8f, 1.0f));
        category.categoryLabel->setPosition(0, -120);

        category.categoryBgImage = new GuiImage(categoryBgImageData);
        category.categoryImages = new GuiImage(categoryImageData);
        category.categoryIcon = new GuiImage(category.categoryIconData);
        category.categoryIconGlow = new GuiImage(category.categoryIconGlowData);
        category.categoryButton = new GuiButton(category.categoryImages->getWidth(), category.categoryImages->getHeight());

        category.categoryIcon->setPosition(0, 40);
        category.categoryIconGlow->setPosition(0, 40);

        category.categoryButton->setLabel(category.categoryLabel);
        category.categoryButton->setImage(category.categoryImages);
        category.categoryButton->setPosition(-300, 0);
        category.categoryButton->setIcon(category.categoryIcon);
        category.categoryButton->setIconOver(category.categoryIconGlow);
        category.categoryButton->setTrigger(&touchTrigger);
        category.categoryButton->setTrigger(&wpadTouchTrigger);
        category.categoryButton->setSoundClick(buttonClickSound);
        category.categoryButton->setEffectGrow();
        category.categoryButton->clicked.connect(this, &SettingsMenu::OnCategoryClick);

        categorySelectionFrame.append(category.categoryBgImage);
        categorySelectionFrame.append(category.categoryButton);

        category.categoryButton->setParent(category.categoryBgImage);
        category.categoryBgImage->setPosition(currentPosition + (category.categoryBgImage->getWidth() + 40) * idx, 0);

        for(u32 n = 0; n < splitDescriptions.size(); n++)
        {
            GuiText * descr = new GuiText(tr(splitDescriptions[n].c_str()), 46, glm::vec4(0.8f, 0.8f, 0.8f, 1.0f));
            descr->setAlignment(ALIGN_MIDDLE | ALIGN_LEFT);
            descr->setPosition(category.categoryBgImage->getWidth() * 0.5f - 50.0f, category.categoryBgImage->getHeight() * 0.5f - 100.0f - n * 60.0f);
            categorySelectionFrame.append(descr);
            descr->setParent(category.categoryBgImage);
            category.descriptions.push_back(descr);
        }

        GuiImage *smallIconOver = new GuiImage(category.categoryIconGlowData);
        GuiImage *smallIcon = new GuiImage(category.categoryIconData);
        GuiButton *smallIconButton = new GuiButton(smallIcon->getWidth() * smallIconScale, smallIcon->getHeight() * smallIconScale);
        smallIcon->setScale(smallIconScale);
        smallIconOver->setScale(smallIconScale);
        smallIconButton->setImage(smallIcon);
        smallIconButton->setEffectGrow();
        smallIconButton->setTrigger(&touchTrigger);
        smallIconButton->setTrigger(&wpadTouchTrigger);
        smallIconButton->setSoundClick(buttonClickSound);
        smallIconButton->clicked.connect(this, &SettingsMenu::OnSmallIconClick);
        categorySelectionFrame.append(smallIconButton);

        categorySmallImages.push_back(smallIcon);
        categorySmallImagesOver.push_back(smallIconOver);
        categorySmallButtons.push_back(smallIconButton);
    }

    leftArrowButton.setImage(&leftArrowImage);
    leftArrowButton.setEffectGrow();
    leftArrowButton.setPosition(40, 0);
    leftArrowButton.setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    leftArrowButton.setTrigger(&touchTrigger);
    leftArrowButton.setTrigger(&wpadTouchTrigger);

    leftArrowButton.setSoundClick(buttonClickSound);
    leftArrowButton.clicked.connect(this, &SettingsMenu::OnCategoryLeftClick);
    categorySelectionFrame.append(&leftArrowButton);

    rightArrowButton.setImage(&rightArrowImage);
    rightArrowButton.setEffectGrow();
    rightArrowButton.setPosition(-40, 0);
    rightArrowButton.setAlignment(ALIGN_RIGHT | ALIGN_MIDDLE);
    rightArrowButton.setTrigger(&touchTrigger);
    rightArrowButton.setTrigger(&wpadTouchTrigger);
    rightArrowButton.setSoundClick(buttonClickSound);
    rightArrowButton.clicked.connect(this, &SettingsMenu::OnCategoryRightClick);
    categorySelectionFrame.append(&rightArrowButton);

    DPADButtons.setTrigger(&buttonATrigger);
    DPADButtons.setTrigger(&buttonBTrigger);
    DPADButtons.setTrigger(&buttonLTrigger);
    DPADButtons.setTrigger(&buttonRTrigger);
    DPADButtons.setTrigger(&buttonLeftTrigger);
    DPADButtons.setTrigger(&buttonRightTrigger);
    DPADButtons.clicked.connect(this, &SettingsMenu::OnDPADClick);
    append(&DPADButtons);
	categorySelectionFrame.append(&DPADButtons);
    setTargetPosition(0);
    moving = false;

    //! the particle BG is always appended in all sub menus
    append(&particleBgImage);
    append(&categorySelectionFrame);
}
CreditsMenu::CreditsMenu(int w, int h, const std::string & title)
    : GuiFrame(w, h)
    , creditsMusic(Resources::GetSound("credits_music.ogg"))
    , buttonClickSound(Resources::GetSound("settings_click_2.mp3"))
    , backImageData(Resources::GetImageData("backButton.png"))
    , backImage(backImageData)
    , backButton(backImage.getWidth(), backImage.getHeight())
    , titleImageData(Resources::GetImageData("settingsTitle.png"))
    , titleImage(titleImageData)
    , touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
{
    Application::instance()->getBgMusic()->Pause();

    creditsMusic->SetLoop(true);
    creditsMusic->Play();
    creditsMusic->SetVolume(50);

    titleText.setColor(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
    titleText.setFontSize(46);
    titleText.setPosition(0, 10);
    titleText.setBlurGlowColor(5.0f, glm::vec4(0.0, 0.0, 0.0f, 1.0f));
    titleText.setText(title.c_str());
    append(&titleImage);
    append(&titleText);

    titleText.setParent(&titleImage);
    titleImage.setAlignment(ALIGN_CENTER | ALIGN_TOP);

    backButton.setImage(&backImage);
    backButton.setAlignment(ALIGN_BOTTOM | ALIGN_LEFT);
    backButton.clicked.connect(this, &CreditsMenu::OnBackButtonClick);
    backButton.setTrigger(&touchTrigger);
    backButton.setSoundClick(buttonClickSound);
    backButton.setEffectGrow();
    append(&backButton);

    GuiText *text = NULL;

    f32 positionY = 230.0f;
    f32 positionX = 50.0f;
    f32 positionX2 = 350.0f;

    int fontSize = 40;
    glm::vec4 textColor = glm::vec4(1.0f);

    text = new GuiText("Loadiine GX2", 56, textColor);
    text->setPosition(0, positionY);
    text->setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 100;

    text = new GuiText("Official Site:", fontSize, textColor);
    text->setPosition(positionX, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);

    text = new GuiText("https://gbatemp.net/threads/413823", fontSize, textColor);
    text->setPosition(positionX2, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 50;

    text = new GuiText("Coding:", fontSize, textColor);
    text->setPosition(positionX, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);

    text = new GuiText("Dimok", fontSize, textColor);
    text->setPosition(positionX2, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 50;

    text = new GuiText("Design:", fontSize, textColor);
    text->setPosition(positionX, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);

    text = new GuiText("Some guy who doesn't want to be named.", fontSize, textColor);
    text->setPosition(positionX2, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 50;

    text = new GuiText("Testing:", fontSize, textColor);
    text->setPosition(positionX, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);

    text = new GuiText("Cyan / Maschell / n1ghty / OnionKnight and many more", fontSize, textColor);
    text->setPosition(positionX2, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 50;

    text = new GuiText("Social Presence:", fontSize, textColor);
    text->setPosition(positionX, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);

    text = new GuiText("Cyan", fontSize, textColor);
    text->setPosition(positionX2, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 50;

    text = new GuiText("Based on:", fontSize, textColor);
    text->setPosition(positionX, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);

    text = new GuiText("Loadiine v4.0 by Golden45 and Dimok", fontSize, textColor);
    text->setPosition(positionX2, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 50;

    text = new GuiText("Big thanks to:", fontSize, textColor);
    text->setPosition(positionX, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);

    text = new GuiText("lustar for GameTDB and hosting covers / disc images", fontSize, textColor);
    text->setPosition(positionX2, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 50;

    text = new GuiText("Marionumber1 for his kernel exploit", fontSize, textColor);
    text->setPosition(positionX2, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 50;

    text = new GuiText("The whole libwiiu team and it's contributors.", fontSize, textColor);
    text->setPosition(positionX2, positionY);
    text->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    creditsText.push_back(text);
    append(text);
    positionY -= 50;
}