コード例 #1
0
ファイル: SettingScene.cpp プロジェクト: 4Enjoy/Joiny-Flow
bool SettingScene::init()
{
    if (!DrawLayer::init())
    {
        return false;
    }
    this->setKeypadEnabled(true);

    const CCPoint ORIGIN = Screen::getOrigin();
    const CCSize VISIBLE_SIZE = Screen::getVisibleSize();
    const float SCALE = Screen::getScaleFactor();

    _main_menu = CCMenu::create();
    _main_menu->setPosition(ORIGIN);

    //Back Button
    CCMenu* menu = _back.start(this, [this](){this->onButtonBackClicked(0);});
    this->addChild(menu);

//    CCLabelTTF * settings = CCLabelTTF::create(_("Settings"),
//                                               Fonts::getFontName(),
//                                               60);
//    settings->setPosition(ccp(ORIGIN.x + VISIBLE_SIZE.width*0.5 + 25/SCALE,
//                          ORIGIN.y + VISIBLE_SIZE.height - 70/SCALE));
//    settings->setColor(GameInfo::getInstance()->getTitleColor());
//    this->addChild(settings);


    float up_ellements = 120/SCALE;

    CCSprite* music = CCSprite::create("settings-menu/music.png");
    CCSize music_size = music->getContentSize();
    music->removeFromParentAndCleanup(true);

    CCSprite* buttons = CCSprite::create("settings-menu/node.png");
    CCSize buttons_size = buttons->getContentSize();
    buttons->removeFromParentAndCleanup(true);

    float space_between_buttons = buttons_size.height;
    float free_space_sum_y = VISIBLE_SIZE.height -
            up_ellements -
            music_size.height -
            buttons_size.height*4 -
            (space_between_buttons-buttons_size.height)*3;
    float one_free_place = free_space_sum_y/3.0f;
    one_free_place = MIN(one_free_place, VISIBLE_SIZE.height*0.1);

    float music_position_y = VISIBLE_SIZE.height
            - up_ellements
            - one_free_place
            - music_size.height/2.0f;

    float reset_position_y = VISIBLE_SIZE.height
            - up_ellements
            - one_free_place*2
            - music_size.height
            - buttons_size.height/2.0f;

    float restore_position_y = reset_position_y - space_between_buttons;
    float dev_position_y = restore_position_y - space_between_buttons;
    float rate_position_y = dev_position_y - space_between_buttons;

    ///////////////////////////////////////////////////////////////////

    //Music Button
    CCPoint position_music(ccp(VISIBLE_SIZE.width*0.35, music_position_y));
    _music_button = createButton(CCSprite::create("settings-menu/music.png"),
                 menu_selector(SettingScene::onMusicClicked),
                 position_music,
                 "",
                 getMusicColor());

    //////////////////////////////////////////////////////////////////

    //Sound Button
    CCPoint position_sound(ccp(VISIBLE_SIZE.width*0.65, music_position_y));
    _sound_button = createButton(CCSprite::create("settings-menu/sound.png"),
                 menu_selector(SettingScene::onSoundClicked),
                 position_sound,
                 "",
                 getSoundColor());

    //////////////////////////////////////////////////////////////////

    CCPoint position_reset(ccp(VISIBLE_SIZE.width*0.5,reset_position_y));
    AnimatedMenuItem* reset_button = createButton(CCSprite::create("settings-menu/node.png"),
                 menu_selector(SettingScene::onResetClicked),
                 position_reset,
                 _("Reset"),
                 GameInfo::getInstance()->getTitleColor());
    _buttons.push_back(reset_button);


    //////////////////////////////////////////////////////////////////

    if(GameInfo::getVersion() != Version::Premium)
    {
    CCPoint position_restor(ccp(VISIBLE_SIZE.width*0.5,restore_position_y));

    AnimatedMenuItem* restor_button = createButton(CCSprite::create("settings-menu/node.png"),
                 menu_selector(SettingScene::onRestorClicked),
                 position_restor,
                 _("Restore"),
                 GameInfo::getInstance()->getTitleColor());
    _buttons.push_back(restor_button);
    }

    //////////////////////////////////////////////////////////////////

    CCPoint position_dev(ccp(VISIBLE_SIZE.width*0.5,dev_position_y));
    AnimatedMenuItem* developers_button = createButton(CCSprite::create("settings-menu/node.png"),
                 menu_selector(SettingScene::onDevelopersClicked),
                 position_dev,
                 _("Developers"),
                 GameInfo::getInstance()->getTitleColor());
    _buttons.push_back(developers_button);

    //////////////////////////////////////////////////////////////////

    CCPoint position_rate(ccp(VISIBLE_SIZE.width*0.5,rate_position_y));
    AnimatedMenuItem* rate_button = createButton(CCSprite::create("settings-menu/node.png"),
                 menu_selector(SettingScene::onRateMeClicked),
                 position_rate,
                 _("Rate"),
                 GameInfo::getInstance()->getNegativeColor());
    _buttons.push_back(rate_button);


    this->addChild(_main_menu);

    showAnimation();

    return true;
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: rl404/CSC335-CG
void MainWindow::createActions()
{
	openAct = new QAction("&Open", this);
	connect(openAct, SIGNAL(triggered()), this, SLOT(openAndReadFile()));

	exitAct = new QAction("E&xit", this);
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    aboutAct = new QAction("&About", this);
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    statAct = new QAction("&Stat", this);
    connect(statAct, SIGNAL(triggered()), this, SLOT(showStat()));

    resetAct = new QAction("&Reset position", this);
    resetAct->setStatusTip("Reset the position");
    connect(resetAct, SIGNAL(triggered()), this, SLOT(reset()));

    reseteffectAct = new QAction("&Reset", this);
    reseteffectAct->setStatusTip("Reset all material");
    connect(reseteffectAct, SIGNAL(triggered()), this, SLOT(reseteffect()));

    //ANIMATION-----------------------------------------------------
    animationShownAct = new QAction("&Shown", this);
    animationShownAct->setStatusTip("Show animation");
    animationShownAct->setCheckable(true);
    connect(animationShownAct, SIGNAL(triggered()), this, SLOT(showAnimation()));

    animationHiddenAct = new QAction("&Hidden", this);
    animationHiddenAct->setStatusTip("Hide animation");
    animationHiddenAct->setCheckable(true);
    connect(animationHiddenAct, SIGNAL(triggered()), this, SLOT(hideAnimation()));

    animationGroup = new QActionGroup(this);
    animationGroup->addAction(animationShownAct);
    animationGroup->addAction(animationHiddenAct);
    animationHiddenAct->setChecked(true);

    //COLOR-----------------------------------------------------
    color0Act = new QAction("&No light",this);
    color0Act->setStatusTip("No light");
    color0Act->setCheckable(true);
    connect(color0Act, SIGNAL(triggered()), this, SLOT(color0()));

    color1Act = new QAction("&Red",this);
    color1Act->setStatusTip("Red");
    color1Act->setCheckable(true);
    connect(color1Act, SIGNAL(triggered()), this, SLOT(color1()));

    color2Act = new QAction("&Green",this);
    color2Act->setStatusTip("Green");
    color2Act->setCheckable(true);
    connect(color2Act, SIGNAL(triggered()), this, SLOT(color2()));

    color3Act = new QAction("&Blue",this);
    color3Act->setStatusTip("Blue");
    color3Act->setCheckable(true);
    connect(color3Act, SIGNAL(triggered()), this, SLOT(color3()));

    color10Act = new QAction("&White",this);
    color10Act->setStatusTip("White");
    color10Act->setCheckable(true);
    connect(color10Act, SIGNAL(triggered()), this, SLOT(color10()));

    colorGroup = new QActionGroup(this);
    colorGroup->addAction(color0Act);
    colorGroup->addAction(color1Act);
    colorGroup->addAction(color2Act);
    colorGroup->addAction(color3Act);
    colorGroup->addAction(color10Act);
    color10Act->setChecked(true);

    //EFFECT-----------------------------------------------------
    effect0Act = new QAction("&No effect",this);
    effect0Act->setStatusTip("No effect");
    effect0Act->setCheckable(true);
    connect(effect0Act, SIGNAL(triggered()), this, SLOT(effect0()));

    effect1Act = new QAction("&Ambient",this);
    effect1Act->setStatusTip("Ambient");
    effect1Act->setCheckable(true);
    connect(effect1Act, SIGNAL(triggered()), this, SLOT(effect1()));

    effect2Act = new QAction("&Diffuse",this);
    effect2Act->setStatusTip("Diffuse");
    effect2Act->setCheckable(true);
    connect(effect2Act, SIGNAL(triggered()), this, SLOT(effect2()));

    effect10Act = new QAction("&All",this);
    effect10Act->setStatusTip("All effect");
    effect10Act->setCheckable(true);
    connect(effect10Act, SIGNAL(triggered()), this, SLOT(effect10()));

    effectGroup = new QActionGroup(this);
    effectGroup->addAction(effect0Act);
    effectGroup->addAction(effect1Act);
    effectGroup->addAction(effect2Act);
    effectGroup->addAction(effect10Act);
    effect10Act->setChecked(true);

    //AMBIENT-----------------------------------------------------
    ambient0Act = new QAction("&No Ambient",this);
    ambient0Act->setStatusTip("No Ambient");
    ambient0Act->setCheckable(true);
    connect(ambient0Act, SIGNAL(triggered()), this, SLOT(ambient0()));

    ambient1Act = new QAction("&Ambient",this);
    ambient1Act->setStatusTip("Ambient");
    ambient1Act->setCheckable(true);
    connect(ambient1Act, SIGNAL(triggered()), this, SLOT(ambient1()));

    ambient2Act = new QAction("&Ambient Color",this);
    ambient2Act->setStatusTip("Ambient Color");
    ambient2Act->setCheckable(true);
    connect(ambient2Act, SIGNAL(triggered()), this, SLOT(ambient2()));

    ambientGroup = new QActionGroup(this);
    ambientGroup->addAction(ambient0Act);
    ambientGroup->addAction(ambient1Act);
    ambientGroup->addAction(ambient2Act);
    ambient0Act->setChecked(true);

    //DIFFUSE-----------------------------------------------------
    diffuse0Act = new QAction("&No Diffuse",this);
    diffuse0Act->setStatusTip("No Diffuse");
    diffuse0Act->setCheckable(true);
    connect(diffuse0Act, SIGNAL(triggered()), this, SLOT(diffuse0()));

    diffuse1Act = new QAction("&Diffuse",this);
    diffuse1Act->setStatusTip("Diffuse");
    diffuse1Act->setCheckable(true);
    connect(diffuse1Act, SIGNAL(triggered()), this, SLOT(diffuse1()));

    diffuseGroup = new QActionGroup(this);
    diffuseGroup->addAction(diffuse0Act);
    diffuseGroup->addAction(diffuse1Act);
    diffuse0Act->setChecked(true);

    //SPECULAR-----------------------------------------------------
    specular0Act = new QAction("&No Specular",this);
    specular0Act->setStatusTip("No Specular");
    specular0Act->setCheckable(true);
    connect(specular0Act, SIGNAL(triggered()), this, SLOT(specular0()));

    specular1Act = new QAction("&Specular",this);
    specular1Act->setStatusTip("Specular");
    specular1Act->setCheckable(true);
    connect(specular1Act, SIGNAL(triggered()), this, SLOT(specular1()));

    specularGroup = new QActionGroup(this);
    specularGroup->addAction(specular0Act);
    specularGroup->addAction(specular1Act);
    specular0Act->setChecked(true);

    //SPECULAR-----------------------------------------------------
    shininess0Act = new QAction("&No Shininess",this);
    shininess0Act->setStatusTip("No Shininess");
    shininess0Act->setCheckable(true);
    connect(shininess0Act, SIGNAL(triggered()), this, SLOT(shininess0()));

    shininess1Act = new QAction("&Low Shininess",this);
    shininess1Act->setStatusTip("Low Shininess");
    shininess1Act->setCheckable(true);
    connect(shininess1Act, SIGNAL(triggered()), this, SLOT(shininess1()));

    shininess2Act = new QAction("&High Shininess",this);
    shininess2Act->setStatusTip("High Shininess");
    shininess2Act->setCheckable(true);
    connect(shininess2Act, SIGNAL(triggered()), this, SLOT(shininess2()));

    shininessGroup = new QActionGroup(this);
    shininessGroup->addAction(shininess0Act);
    shininessGroup->addAction(shininess1Act);
    shininessGroup->addAction(shininess2Act);
    shininess0Act->setChecked(true);

    //EMISSION-----------------------------------------------------
    emission0Act = new QAction("&No Emission",this);
    emission0Act->setStatusTip("No Emission");
    emission0Act->setCheckable(true);
    connect(emission0Act, SIGNAL(triggered()), this, SLOT(emission0()));

    emission1Act = new QAction("&Emission",this);
    emission1Act->setStatusTip("eEmission");
    emission1Act->setCheckable(true);
    connect(emission1Act, SIGNAL(triggered()), this, SLOT(emission1()));

    emissionGroup = new QActionGroup(this);
    emissionGroup->addAction(emission0Act);
    emissionGroup->addAction(emission1Act);
    emission0Act->setChecked(true);

    //SHADING-------------------------------------------------
    shading0Act = new QAction("&No shading", this);
    shading0Act->setStatusTip("No shading");
    shading0Act->setCheckable(true);
    connect(shading0Act, SIGNAL(triggered()), this, SLOT(shading0()));

    shading1Act = new QAction("&Flat shading", this);
    shading1Act->setStatusTip("Flat shading");
    shading1Act->setCheckable(true);
    connect(shading1Act, SIGNAL(triggered()), this, SLOT(shading1()));

    shading2Act = new QAction("&Smooth shading", this);
    shading2Act->setStatusTip("Smooth shading");
    shading2Act->setCheckable(true);
    connect(shading2Act, SIGNAL(triggered()), this, SLOT(shading2()));

    shadingGroup = new QActionGroup(this);
    shadingGroup->addAction(shading0Act);
    shadingGroup->addAction(shading1Act);
    shadingGroup->addAction(shading2Act);
    shading0Act->setChecked(true);

    //NORMAL----------------------------------------------------
    normal0Act = new QAction("&No normal",this);
    normal0Act->setStatusTip("No normal");
    normal0Act->setCheckable(true);
    connect(normal0Act, SIGNAL(triggered()), this, SLOT(normal0()));

    normal1Act = new QAction("&normal",this);
    normal1Act->setStatusTip("Has normal");
    normal1Act->setCheckable(true);
    connect(normal1Act, SIGNAL(triggered()), this, SLOT(normal1()));

    normalGroup = new QActionGroup(this);
    normalGroup->addAction(normal0Act);
    normalGroup->addAction(normal1Act);
    normal0Act->setChecked(true);
}
コード例 #3
0
void MainWindow::onItemSelected(QModelIndex index)
{
    showAnimation(library_.data(index, Qt::DisplayRole).toString());
}