void GameUIConfig::SaveOptions()
{
    setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText());
    setValue("video/fullscreen", vid_Fullscreen());

    setValue("video/quality", Form->ui.pageOptions->SLQuality->value());
    setValue("video/stereo", stereoMode());

    setValue("frontend/effects", isFrontendEffects());

    setValue("misc/weaponTooltips", Form->ui.pageOptions->WeaponTooltip->isChecked());

    bool ffscr = isFrontendFullscreen();
    setValue("frontend/fullscreen", ffscr);
    emit frontendFullscreen(ffscr);
    if (!ffscr) {
      setValue("frontend/width", Form->width());
      setValue("frontend/height", Form->height());
    } else {
      //resizeToConfigValues(); // TODO: why this has been made?
    }

    setValue("audio/sound", isSoundEnabled());
    setValue("frontend/sound", isFrontendSoundEnabled());
    setValue("audio/music", isMusicEnabled());
    setValue("frontend/music", isFrontendMusicEnabled());
    setValue("audio/volume", Form->ui.pageOptions->volumeBox->value());

    setValue("net/nick", netNick());
    setValue("net/ip", *netHost);
    setValue("net/port", netPort);
    setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text());
    setValue("net/serverport", Form->ui.pageNetServer->sbPort->value());

    setValue("fps/show", isShowFPSEnabled());
    setValue("fps/limit", Form->ui.pageOptions->fpsedit->value());

    setValue("misc/altdamage", isAltDamageEnabled());
    setValue("misc/appendTimeToRecords", appendDateTimeToRecordName());
    setValue("misc/locale", language());

#ifdef SPARKLE_ENABLED
        setValue("misc/autoUpdate", isAutoUpdateEnabled());
#endif
    Form->gameSettings->sync();
}
bool MainMenu::init() {
    if(!LayerColor::initWithColor(MENU_BACKGROUND_COLOR)) {
        return false;
    }
    
    auto titleFinalPosition = Point(VisibleRect::top().x, 1920 - 202);
    auto titleSprite = sprite("Title", Point(titleFinalPosition.x, titleFinalPosition.y + 300));
    
    addChild(titleSprite);
    
    titleSprite->runAction(EaseSineOut::create(MoveTo::create(DEFAULT_ANIMATION_TIME, titleFinalPosition)));
    
    auto menuBackground = sprite("MenuBackground", Point(VisibleRect::center().x, 1920 - 966));
    menuBackground->setScale(1.0f, 0.1);
    menuBackground->runAction(ScaleTo::create(DEFAULT_ANIMATION_TIME, 1.0f));
    addChild(menuBackground);

    auto arcadeButtonFinalPosition = Point(335, 1288);
    
    auto arcadeButton = MenuItemSprite::create(sprite("ArcadeButtonNormal"), sprite("ArcadeButtonPressed"), [=] (Ref* sender) {
        auto userDefault = UserDefault::getInstance();
        userDefault->setIntegerForKey("mode", GameMode::ARCADE);
        onPlayPress(sender);
    });
    arcadeButton->setPosition(arcadeButtonFinalPosition.x, arcadeButtonFinalPosition.y + 2000);
    arcadeButton->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME), EaseBounceOut::create(MoveTo::create(DEFAULT_ANIMATION_TIME, arcadeButtonFinalPosition)), CallFunc::create([=](){
        arcadeButton->runAction(RepeatForever::create(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 4), RotateTo::create(DEFAULT_ANIMATION_TIME / 2, TILE_ROTATION_DEGREE), RotateTo::create(DEFAULT_ANIMATION_TIME, -TILE_ROTATION_DEGREE),RotateTo::create(DEFAULT_ANIMATION_TIME / 2, 0.0f),NULL)));
    }), NULL) );
    
    auto timeAttackButtonFinalPosition = Point(788, 1920 - 932);
    auto timeAttackButton = MenuItemSprite::create(sprite("TimeAttackButtonNormal"), sprite("TimeAttackButtonPressed"), [=] (Ref* sender) {
        auto userDefault = UserDefault::getInstance();
        userDefault->setIntegerForKey("mode", GameMode::TIME_ATTACK);
        onPlayPress(sender);
    });
    timeAttackButton->setPosition(timeAttackButtonFinalPosition.x, timeAttackButtonFinalPosition.y + 2000);
    
    timeAttackButton->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 2), EaseBounceOut::create(MoveTo::create(DEFAULT_ANIMATION_TIME, timeAttackButtonFinalPosition)), CallFunc::create([=](){
        timeAttackButton->runAction(RepeatForever::create(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 4), RotateTo::create(DEFAULT_ANIMATION_TIME / 2, TILE_ROTATION_DEGREE), RotateTo::create(DEFAULT_ANIMATION_TIME, -TILE_ROTATION_DEGREE),RotateTo::create(DEFAULT_ANIMATION_TIME / 2, 0.0f),NULL)));
    }), NULL) );

    auto zenButtonFinalPosition = Point(335, 1920 - 1251);
    auto zenButton = MenuItemSprite::create(sprite("ZenButtonNormal"), sprite("ZenButtonPressed"), [=] (Ref* sender) {
        auto userDefault = UserDefault::getInstance();
        userDefault->setIntegerForKey("mode", GameMode::ZEN);
        onPlayPress(sender);
    });
    zenButton->setPosition(zenButtonFinalPosition.x, zenButtonFinalPosition.y + 2000);
    zenButton->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 3), EaseBounceOut::create(MoveTo::create(DEFAULT_ANIMATION_TIME, zenButtonFinalPosition)), CallFunc::create([=](){
        zenButton->runAction(RepeatForever::create(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 4), RotateTo::create(DEFAULT_ANIMATION_TIME / 2, TILE_ROTATION_DEGREE), RotateTo::create(DEFAULT_ANIMATION_TIME, -TILE_ROTATION_DEGREE),RotateTo::create(DEFAULT_ANIMATION_TIME / 2, 0.0f),NULL)));
    }), NULL) );
    
    auto arcadeLabel = label("ARCADE")->size(MENU_FONT_SIZE)->position(Point(timeAttackButtonFinalPosition.x, arcadeButtonFinalPosition.y))->color(ARCADE_TEXT_COLOR)->addTo(this);
    arcadeLabel->setVisible(false);
    arcadeLabel->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 3),  Show::create(), NULL));
    
    auto timeAttackLabel = label("  TIME\nATTACK")->size(MENU_FONT_SIZE)->position(Point(arcadeButtonFinalPosition.x, timeAttackButtonFinalPosition.y))->color(TIME_ATTACK_TEXT_COLOR)->addTo(this);
    timeAttackLabel->setVisible(false);
    timeAttackLabel->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 4),  Show::create(), NULL));
    
    auto zenLabel = label("ZEN")->size(MENU_FONT_SIZE)->position(Point(timeAttackButtonFinalPosition.x, zenButtonFinalPosition.y))->color(ZEN_TEXT_COLOR)->addTo(this);
    zenLabel->setVisible(false);
    zenLabel->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 5),  Show::create(), NULL));
    
    auto soundManager = SoundManager::sharedSoundManager();
    
    auto soundButtonOn = MenuItemSprite::create(sprite("SoundButtonOn"), nullptr);
    auto soundButton = MenuItemToggle::createWithCallback([=](Ref* sender) {
        auto button = (MenuItemToggle*) sender;
        if(button->getSelectedItem() == soundButtonOn) {
            soundManager->unmuteSound();
        } else {
            soundManager->muteSound();
        }
        playSoundEffect("Click");
    }, soundButtonOn, MenuItemSprite::create(sprite("SoundButtonOff"), nullptr), NULL);
    
    if(soundManager->isSoundEnabled()) {
        soundButton->setSelectedIndex(0);
    } else {
        soundButton->setSelectedIndex(1);
    }
    
    soundButton->setPosition(Point(291, 1920 - 1710));
    
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
    auto leaderBoardButton = MenuItemSprite::create(sprite("LeaderboardButtonNormal"), sprite("LeaderboardButtonPressed"), [=] (Ref* sender) {
        playSoundEffect("Click");
        NativeUtils::showLeaderboards();
    });
    leaderBoardButton->setPosition(Point(796, 1920 - 1710));
    
    auto menu = Menu::create(arcadeButton, timeAttackButton, zenButton, soundButton, leaderBoardButton, NULL);
    menu->setPosition(Point::ZERO);
    addChild(menu);
#else
    
    auto menu = Menu::create(arcadeButton, timeAttackButton, zenButton, soundButton, NULL);
    menu->setPosition(Point::ZERO);
    addChild(menu);
    
#endif
    
    
    runAction(RepeatForever::create(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 12), CallFunc::create([=] () {
        playSoundEffect("Giggle");
    }) , NULL)));
    
    return true;
}
Exemple #3
0
void GameUIConfig::SaveOptions()
{
    setValue("video/fullscreenResolution", Form->ui.pageOptions->CBResolution->currentText());
    setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->text());
    setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->text());
    setValue("video/fullscreen", vid_Fullscreen());

    setValue("video/quality", Form->ui.pageOptions->SLQuality->value());
    setValue("video/stereo", stereoMode());

    setValue("frontend/effects", isFrontendEffects());

    setValue("misc/weaponTooltips", Form->ui.pageOptions->WeaponTooltip->isChecked());

    bool ffscr = isFrontendFullscreen();
    setValue("frontend/fullscreen", ffscr);
    emit frontendFullscreen(ffscr);
    if (!ffscr)
    {
        setValue("frontend/width", Form->width());
        setValue("frontend/height", Form->height());
    }
    else
    {
        //resizeToConfigValues(); // TODO: why this has been made?
    }

    setValue("audio/sound", isSoundEnabled());
    setValue("frontend/sound", isFrontendSoundEnabled());
    setValue("audio/music", isMusicEnabled());
    setValue("frontend/music", isFrontendMusicEnabled());
    setValue("audio/volume", Form->ui.pageOptions->SLVolume->value());

    setValue("net/nick", netNick());
    if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
        setPasswordHash(netPasswordHash());
    }
    else if(!Form->ui.pageOptions->CBSavePassword->isChecked()) {
        clearPasswordHash();
    }

    setValue("net/savepassword", Form->ui.pageOptions->CBSavePassword->isChecked());
    setValue("net/ip", *netHost);
    setValue("net/port", netPort);
    setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text());
    setValue("net/serverport", Form->ui.pageNetServer->sbPort->value());

    setValue("fps/show", isShowFPSEnabled());
    setValue("fps/limit", Form->ui.pageOptions->fpsedit->value());

    setValue("misc/altdamage", isAltDamageEnabled());

    setValue("misc/teamtag",   Form->ui.pageOptions->CBTeamTag->isChecked());
    setValue("misc/hogtag",    Form->ui.pageOptions->CBHogTag->isChecked());
    setValue("misc/healthtag", Form->ui.pageOptions->CBHealthTag->isChecked());
    setValue("misc/tagopacity",Form->ui.pageOptions->CBTagOpacity->isChecked());

    setValue("misc/appendTimeToRecords", appendDateTimeToRecordName());
    setValue("misc/locale", language());

#ifdef SPARKLE_ENABLED
    setValue("misc/autoUpdate", isAutoUpdateEnabled());
#endif

    { // setup proxy
        int proxyType = Form->ui.pageOptions->cbProxyType->currentIndex();
        setValue("proxy/type", proxyType);

        if(proxyType == PageOptions::Socks5Proxy || proxyType == PageOptions::HTTPProxy)
        {
            setValue("proxy/host", Form->ui.pageOptions->leProxy->text());
            setValue("proxy/port", Form->ui.pageOptions->sbProxyPort->value());
            setValue("proxy/login", Form->ui.pageOptions->leProxyLogin->text());
            setValue("proxy/password", Form->ui.pageOptions->leProxyPassword->text());
        }

        applyProxySettings();
    }

    { // save colors
        QStandardItemModel * model = DataManager::instance().colorsModel();
        for(int i = model->rowCount() - 1; i >= 0; --i)
            setValue(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>().name());
    }

    sync();
}