コード例 #1
0
// ----------------------------------------------------------------------------
void MessageDialog::loadedFromFile()
{
    LabelWidget* message = getWidget<LabelWidget>("title");
    message->setText( m_msg, false );

    // If the dialog is a simple 'OK' dialog, then hide the "Yes" button and
    // change "Cancel" to "OK"
    if (m_type == MessageDialog::MESSAGE_DIALOG_OK)
    {
        ButtonWidget* yesbtn = getWidget<ButtonWidget>("confirm");
        yesbtn->setVisible(false);

        ButtonWidget* cancelbtn = getWidget<ButtonWidget>("cancel");
        cancelbtn->setText(_("OK"));
        cancelbtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
    }
    else if (m_type == MessageDialog::MESSAGE_DIALOG_YESNO)
    {
        ButtonWidget* cancelbtn = getWidget<ButtonWidget>("cancel");
        cancelbtn->setText(_("No"));

    }
    else if (m_type == MessageDialog::MESSAGE_DIALOG_OK_CANCEL)
    {
        // In case of a OK_CANCEL dialog, change the text from 'Yes' to 'Ok'
        ButtonWidget* yesbtn = getWidget<ButtonWidget>("confirm");
        yesbtn->setText(_("OK"));
    }
}
コード例 #2
0
// ----------------------------------------------------------------------------
void CreateServerScreen::init()
{
    Screen::init();
    DemoWorld::resetIdleTime();
    m_info_widget->setText("", false);
    LabelWidget *title = getWidget<LabelWidget>("title");

    title->setText(NetworkConfig::get()->isLAN() ? _("Create LAN Server")
                                                 : _("Create Server")    ,
                   false);

    // I18n: Name of the server. %s is either the online or local user name
    m_name_widget->setText(_("%s's server",
                             NetworkConfig::get()->isLAN() 
                             ? PlayerManager::getCurrentPlayer()->getName()
                             : PlayerManager::getCurrentOnlineUserName()
                             )
                          );


    // -- Difficulty
    RibbonWidget* difficulty = getWidget<RibbonWidget>("difficulty");
    assert(difficulty != NULL);
    difficulty->setSelection(UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER);

    // -- Game modes
    RibbonWidget* gamemode = getWidget<RibbonWidget>("gamemode");
    assert(gamemode != NULL);
    gamemode->setSelection(0, PLAYER_ID_GAME_MASTER);
}   // init
コード例 #3
0
// ----------------------------------------------------------------------------
//
void MainMenuScreen::init()
{
    Screen::init();

    m_user_id = getWidget<ButtonWidget>("user-id");
    assert(m_user_id);

    // reset in case we're coming back from a race
    StateManager::get()->resetActivePlayers();
    input_manager->getDeviceManager()->setAssignMode(NO_ASSIGN);
    input_manager->getDeviceManager()->setSinglePlayer( NULL );
    input_manager->setMasterPlayerOnly(false);

    // Avoid incorrect behaviour in certain race circumstances:
    // If a multi-player game is played with two keyboards, the 2nd
    // player selects his kart last, and only the keyboard is used
    // to select all other settings - then if the next time the kart
    // selection screen comes up, the default device will still be
    // the 2nd player. So if the first player presses 'select', it
    // will instead add a second player (so basically the key
    // binding for the second player become the default, so pressing
    // select will add a new player). See bug 3090931
    // To avoid this, we will clean the last used device, making
    // the key bindings for the first player the default again.
    input_manager->getDeviceManager()->clearLatestUsedDevice();

    if (addons_manager->isLoading())
    {
        IconButtonWidget* w = getWidget<IconButtonWidget>("addons");
        w->setDeactivated();
        w->resetAllBadges();
        w->setBadge(LOADING_BADGE);
    }

    m_online = getWidget<IconButtonWidget>("online");

    if(!m_enable_online)
        m_online->setDeactivated();

    LabelWidget* w = getWidget<LabelWidget>("info_addons");
    const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
    w->setText(news_text, true);
    w->update(0.01f);

    RibbonWidget* r = getWidget<RibbonWidget>("menu_bottomrow");
    // FIXME: why do I need to do this manually
    ((IconButtonWidget*)r->getChildren().get(0))->unfocused(PLAYER_ID_GAME_MASTER, NULL);
    ((IconButtonWidget*)r->getChildren().get(1))->unfocused(PLAYER_ID_GAME_MASTER, NULL);
    ((IconButtonWidget*)r->getChildren().get(2))->unfocused(PLAYER_ID_GAME_MASTER, NULL);

    r = getWidget<RibbonWidget>("menu_toprow");
    r->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
    DemoWorld::resetIdleTime();

#if _IRR_MATERIAL_MAX_TEXTURES_ < 8
    getWidget<IconButtonWidget>("logo")->setImage("gui/logo_broken.png",
        IconButtonWidget::ICON_PATH_TYPE_RELATIVE);
#endif

}   // init
コード例 #4
0
ファイル: main_menu_screen.cpp プロジェクト: langresser/stk
// ----------------------------------------------------------------------------
void MainMenuScreen::onUpdate(float delta,  irr::video::IVideoDriver* driver)
{
    IconButtonWidget* addons_icon = getWidget<IconButtonWidget>("addons");
    if (addons_icon != NULL)
    {
        if (addons_manager->wasError())
        {
            addons_icon->setActivated();
            addons_icon->resetAllBadges();
            addons_icon->setBadge(BAD_BADGE);
        }
        else if (addons_manager->isLoading() && UserConfigParams::m_internet_status
                == INetworkHttp::IPERM_ALLOWED)
        {
            // Addons manager is still initialising/downloading.
            addons_icon->setDeactivated();
            addons_icon->resetAllBadges();
            addons_icon->setBadge(LOADING_BADGE);
        }
        else 
        {
            addons_icon->setActivated();
            addons_icon->resetAllBadges();
        }
        // maybe add a new badge when not allowed to access the net
    }

    LabelWidget* w = getWidget<LabelWidget>("info_addons");
    w->update(delta);
    if(w->scrolledOff())
    {
        const core::stringw &news_text = news_manager->getNextNewsMessage();
        w->setText(news_text, true);
    }
}   // onUpdate
コード例 #5
0
// ----------------------------------------------------------------------------
void MainMenuScreen::onUpdate(float delta)

{
    PlayerProfile *player = PlayerManager::getCurrentPlayer();
    if(PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST  ||
       PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
    {
        m_user_id->setText(player->getLastOnlineName() + "@stk");
        m_online->setActivated();
        m_online->setLabel( _("Online"));
    }
    else if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_OUT)
    {
        m_online->setActivated();
        m_online->setLabel( _("Login" ));
        m_user_id->setText(player->getName());
    }
    else 
    {
        // now must be either logging in or logging out
        m_online->setDeactivated();
        m_user_id->setText(player->getName());
    }

    m_online->setLabel(PlayerManager::getCurrentOnlineId() ? _("Online")
                                                           : _("Login" )  );
    IconButtonWidget* addons_icon = getWidget<IconButtonWidget>("addons");
    if (addons_icon != NULL)
    {
        if (addons_manager->wasError())
        {
            addons_icon->setActivated();
            addons_icon->resetAllBadges();
            addons_icon->setBadge(BAD_BADGE);
        }
        else if (addons_manager->isLoading() && UserConfigParams::m_internet_status
            == Online::RequestManager::IPERM_ALLOWED)
        {
            // Addons manager is still initialising/downloading.
            addons_icon->setDeactivated();
            addons_icon->resetAllBadges();
            addons_icon->setBadge(LOADING_BADGE);
        }
        else
        {
            addons_icon->setActivated();
            addons_icon->resetAllBadges();
        }
        // maybe add a new badge when not allowed to access the net
    }

    LabelWidget* w = getWidget<LabelWidget>("info_addons");
    w->update(delta);
    if(w->scrolledOff())
    {
        const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
        w->setText(news_text, true);
    }
}   // onUpdate
コード例 #6
0
// -----------------------------------------------------------------------------
void EnterGPNameDialog::onEnterPressedInternal()
{
    //Cancel button pressed
    ButtonWidget* cancelButton = getWidget<ButtonWidget>("cancel");
    if (GUIEngine::isFocusedForPlayer(cancelButton, PLAYER_ID_GAME_MASTER))
    {
        std::string fakeEvent = "cancel";
        processEvent(fakeEvent);
        return;
    }

    //Otherwise, see if we can accept the new name
    TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
    assert(textCtrl != NULL);
    stringw name = textCtrl->getText().trim();
    if (name.size() > 0)
    {
        // check for duplicate names
        for (int i = 0; i < grand_prix_manager->getNumberOfGrandPrix(); i++)
        {
            const GrandPrixData* gp = grand_prix_manager->getGrandPrix(i);
            if (gp->getName() == name)
            {
                LabelWidget* label = getWidget<LabelWidget>("title");
                assert(label != NULL);
                label->setText(_("Another grand prix with this name already exists."), false);
                sfx_manager->quickSound("anvil");
                return;
            }
        }

        // It's unsafe to delete from inside the event handler so we do it
        // in onUpdate (which checks for m_self_destroy)
        m_self_destroy = true;
    }
    else
    {
        LabelWidget* label = getWidget<LabelWidget>("title");
        assert(label != NULL);
        label->setText(_("Cannot add a grand prix with this name"), false);
        sfx_manager->quickSound("anvil");
    }
}
コード例 #7
0
void MessageDialog::doInit(MessageDialogType type,
                           IConfirmDialogListener* listener, bool own_listener)
{
    if (StateManager::get()->getGameState() == GUIEngine::GAME)
    {
        World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE);
    }


    loadFromFile("confirm_dialog.stkgui");

    m_listener = listener;
    m_own_listener = own_listener;

    LabelWidget* message = getWidget<LabelWidget>("title");
    message->setText( m_msg.c_str(), false );

    // If the dialog is a simple 'OK' dialog, then hide the "Yes" button and
    // change "Cancel" to "OK"
    if (type == MessageDialog::MESSAGE_DIALOG_OK)
    {
        ButtonWidget* yesbtn = getWidget<ButtonWidget>("confirm");
        yesbtn->setVisible(false);

        ButtonWidget* cancelbtn = getWidget<ButtonWidget>("cancel");
        cancelbtn->setText(_("OK"));
        cancelbtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
    }
    else if (type == MessageDialog::MESSAGE_DIALOG_YESNO)
    {
        ButtonWidget* yesbtn = getWidget<ButtonWidget>("confirm");

        ButtonWidget* cancelbtn = getWidget<ButtonWidget>("cancel");
        cancelbtn->setText(_("No"));

    }
    else if (type == MessageDialog::MESSAGE_DIALOG_OK_CANCEL)
    {
        // In case of a OK_CANCEL dialog, change the text from 'Yes' to 'Ok'
        ButtonWidget* yesbtn = getWidget<ButtonWidget>("confirm");
        yesbtn->setText(_("OK"));
    }
}
コード例 #8
0
// ----------------------------------------------------------------------------
void CreateServerScreen::init()
{
    Screen::init();
    DemoWorld::resetIdleTime();
    m_info_widget->setText("", false);
    LabelWidget *title = getWidget<LabelWidget>("title");

    title->setText(NetworkConfig::get()->isLAN() ? _("Create LAN Server")
                                                 : _("Create Server")    ,
                   false);

    // I18n: Name of the server. %s is either the online or local user name
    m_name_widget->setText(_("%s's server",
                             NetworkConfig::get()->isLAN() 
                             ? PlayerManager::getCurrentPlayer()->getName()
                             : PlayerManager::getCurrentOnlineUserName()
                             )
                          );
}   // init
コード例 #9
0
ファイル: edit_gp_screen.cpp プロジェクト: Berulacks/stk-code
// -----------------------------------------------------------------------------
void EditGPScreen::init()
{
    if (m_action.empty())
    {
        LabelWidget* header = getWidget<LabelWidget>("title");
        assert(header != NULL);
        header->setText(m_gp->getName(), true);

        IconButtonWidget* button = getWidget<IconButtonWidget>("save");
        assert(button != NULL);
        button->setDeactivated();

        loadList(0);
        setModified(false);
    }
    else
    {
        EditTrackScreen* edit = EditTrackScreen::getInstance();
        assert(edit != NULL);

        if (edit->getResult())
        {
            if (m_action == "add")
            {
                m_gp->addTrack(edit->getTrack(), edit->getLaps(), edit->getReverse(),
                    m_selected);
                setSelected(m_selected + 1);
            }
            else if (m_action == "edit")
            {
                m_gp->editTrack(m_selected, edit->getTrack(), edit->getLaps(),
                    edit->getReverse());
            }
            setModified(true);
        }
        loadList(m_selected);
        m_action.clear();
    }
}
コード例 #10
0
void MessageDialog::doInit(irr::core::stringw msg, MessageDialogType type,
                           IConfirmDialogListener* listener, bool own_listener)
{
    loadFromFile("confirm_dialog.stkgui");

    m_listener = listener;
    m_own_listener = own_listener;
    
    LabelWidget* message = getWidget<LabelWidget>("title");
    message->setText( msg.c_str(), false );

    // If the dialog is a simple 'OK' dialog, then hide the "Yes" button and
    // change "Cancel" to "OK"
    if (type == MessageDialog::MESSAGE_DIALOG_OK)
    {
        ButtonWidget* yesbtn = getWidget<ButtonWidget>("confirm");
        yesbtn->setVisible(false);

        ButtonWidget* cancelbtn = getWidget<ButtonWidget>("cancel");
        cancelbtn->setText(_("OK"));
        cancelbtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
    }
}
コード例 #11
0
GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const float h) : ModalDialog(w, h)
{
    doInit();
    m_curr_time = 0.0f;

    const int y1 = m_area.getHeight()/7;
    const int y2 = m_area.getHeight()*6/7;

    m_gp_ident = gpIdent;

    const GrandPrixData* gp = grand_prix_manager->getGrandPrix(gpIdent);
    if (gp == NULL)
    {
        assert(false);
        std::cerr << "ERROR at " << __FILE__ << " : " << __LINE__ << "; trying to continue\n";
        ModalDialog::dismiss();
        return;
    }

    // ---- GP Name
    core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1);
    IGUIStaticText* title = GUIEngine::getGUIEnv()->addStaticText( translations->fribidize(gp->getName()),
                                                               area_top, false, true, // border, word wrap
                                                               m_irrlicht_window);
    title->setTabStop(false);
    title->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);


    // ---- Track listings
    const std::vector<std::string>& tracks = gp->getTrackNames();
    const int trackAmount = tracks.size();

    int height_of_one_line = (y2 - y1)/(trackAmount+1);
    const int textHeight = GUIEngine::getFontHeight();
    if (height_of_one_line > (int)(textHeight*1.5f)) height_of_one_line = (int)(textHeight*1.5f);

    bool gp_ok = true;

    for (int t=0; t<trackAmount; t++)
    {
        const int from_y = y1 + height_of_one_line*(t+1);

        Track* track = track_manager->getTrack(tracks[t]);
        stringw lineText;
        if (track == NULL)
        {
            lineText = L"MISSING : ";
            lineText.append( stringw(tracks[t].c_str()) );
            gp_ok = false;
        }
        else
        {
            lineText = track->getName();
        }

        LabelWidget* widget = new LabelWidget();
        widget->setText(translations->fribidize(lineText), false);
        widget->m_x = 20;
        widget->m_y = from_y;
        widget->m_w = m_area.getWidth()/2 - 20;
        widget->m_h = height_of_one_line;
        widget->setParent(m_irrlicht_window);

        m_widgets.push_back(widget);
        widget->add();

        // IGUIStaticText* line = GUIEngine::getGUIEnv()->addStaticText( lineText.c_str(),
        //                                       entry_area, false , true , // border, word wrap
        //                                       m_irrlicht_window);
    }

    // ---- Track screenshot

    m_screenshot_widget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
                                               false /* tab stop */, false /* focusable */,
                                               IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE /* Track gives us absolute paths */);
    // images are saved squared, but must be stretched to 4:3
    m_screenshot_widget->setCustomAspectRatio(4.0f / 3.0f);

    m_screenshot_widget->m_x = m_area.getWidth()/2;
    m_screenshot_widget->m_y = y1;
    m_screenshot_widget->m_w = m_area.getWidth()/2;
    m_screenshot_widget->m_h = y2 - y1 - 10;

    Track* track = track_manager->getTrack(tracks[0]);

    m_screenshot_widget->m_properties[PROP_ICON] = (track  != NULL ?
                                                    track->getScreenshotFile().c_str() :
                                                    file_manager->getAsset(FileManager::GUI,"main_help.png"));
    m_screenshot_widget->setParent(m_irrlicht_window);
    m_screenshot_widget->add();
    m_widgets.push_back(m_screenshot_widget);


    // ---- Start button
    ButtonWidget* okBtn = new ButtonWidget();
    ButtonWidget* continueBtn = new ButtonWidget();

    SavedGrandPrix* saved_gp = SavedGrandPrix::getSavedGP( StateManager::get()
                                               ->getActivePlayerProfile(0)
                                               ->getUniqueID(),
                                               gpIdent,
                                               race_manager->getDifficulty(),
                                               race_manager->getNumberOfKarts(),
                                               race_manager->getNumLocalPlayers());

    if (gp_ok)
    {
        okBtn->m_properties[PROP_ID] = "start";
        okBtn->setText(_("Start Grand Prix"));

        continueBtn->m_properties[PROP_ID] = "continue";
        continueBtn->setText(_("Continue"));
    }
    else
    {
        okBtn->m_properties[PROP_ID] = "cannot_start";
        okBtn->setText(_("This Grand Prix is broken!"));
        okBtn->setBadge(BAD_BADGE);
    }

    if (saved_gp && gp_ok)
    {
        continueBtn->m_x = m_area.getWidth()/2 + 110;
        continueBtn->m_y = y2;
        continueBtn->m_w = 200;
        continueBtn->m_h = m_area.getHeight() - y2 - 15;
        continueBtn->setParent(m_irrlicht_window);
        m_widgets.push_back(continueBtn);
        continueBtn->add();
        continueBtn->getIrrlichtElement()->setTabStop(true);
        continueBtn->getIrrlichtElement()->setTabGroup(false);
        
        okBtn->m_x = m_area.getWidth()/2 - 310;
    }
    else
    {
        okBtn->m_x = m_area.getWidth()/2 - 200;
    }
    
    okBtn->m_y = y2;
    okBtn->m_w = 400;
    okBtn->m_h = m_area.getHeight() - y2 - 15;
    okBtn->setParent(m_irrlicht_window);
    m_widgets.push_back(okBtn);
    okBtn->add();
    okBtn->getIrrlichtElement()->setTabStop(true);
    okBtn->getIrrlichtElement()->setTabGroup(false);

    okBtn->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
    
}
コード例 #12
0
SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
                                             const float percentHeight,
                                             std::string challenge_id) :
    ModalDialog(percentWidth, percentHeight)
{
    loadFromFile("select_challenge.stkgui");
    m_challenge_id = challenge_id;
    World::getWorld()->schedulePause(WorldStatus::IN_GAME_MENU_PHASE);

    switch (UserConfigParams::m_difficulty)
    {
        case 0:
            getWidget("novice")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
            break;
        case 1:
            getWidget("intermediate")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
            break;
        case 2:
            getWidget("expert")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
            break;
    }

    const ChallengeStatus* c = PlayerManager::getCurrentPlayer()
                             ->getChallengeStatus(challenge_id);

    if (c->isSolved(RaceManager::DIFFICULTY_EASY))
    {
        IconButtonWidget* btn = getWidget<IconButtonWidget>("novice");
        btn->setImage(file_manager->getAsset(FileManager::GUI, "cup_bronze.png"),
                     IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
    }

    if (c->isSolved(RaceManager::DIFFICULTY_MEDIUM))
    {
        IconButtonWidget* btn = getWidget<IconButtonWidget>("intermediate");
        btn->setImage(file_manager->getAsset(FileManager::GUI,"cup_silver.png"),
                     IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
    }

    if (c->isSolved(RaceManager::DIFFICULTY_HARD))
    {
        IconButtonWidget* btn = getWidget<IconButtonWidget>("expert");
        btn->setImage(file_manager->getAsset(FileManager::GUI,"cup_gold.png"),
                     IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
    }


    LabelWidget* novice_label = getWidget<LabelWidget>("novice_label");
    LabelWidget* medium_label = getWidget<LabelWidget>("intermediate_label");
    LabelWidget* expert_label = getWidget<LabelWidget>("difficult_label");

    novice_label->setText( getLabel(RaceManager::DIFFICULTY_EASY,   c->getData()), false );
    medium_label->setText( getLabel(RaceManager::DIFFICULTY_MEDIUM, c->getData()), false );
    expert_label->setText( getLabel(RaceManager::DIFFICULTY_HARD,   c->getData()), false );

    if (c->getData()->isGrandPrix())
    {
        const GrandPrixData* gp = grand_prix_manager->getGrandPrix(c->getData()->getGPId());
        getWidget<LabelWidget>("title")->setText( gp->getName(), true );
    }
    else
    {
        const wchar_t* track_name = track_manager->getTrack(c->getData()->getTrackId())->getName();
        getWidget<LabelWidget>("title")->setText( track_name, true );
    }

    LabelWidget* typeLbl = getWidget<LabelWidget>("race_type_val");
    if (c->getData()->isGrandPrix())
        typeLbl->setText(_("Grand Prix"), false );
    else if (c->getData()->getEnergy(RaceManager::DIFFICULTY_EASY) > 0)
        typeLbl->setText(_("Nitro challenge"), false );
    else
        typeLbl->setText( RaceManager::getNameOf(c->getData()->getMinorMode()), false );

}
コード例 #13
0
void OptionsScreenInput2::init()
{
    Screen::init();
    RibbonWidget* tabBar = getWidget<RibbonWidget>("options_choice");
    if (tabBar != NULL)  tabBar->select( "tab_controls",
                                        PLAYER_ID_GAME_MASTER );

    tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") );
    tabBar->getRibbonChildren()[1].setTooltip( _("Audio") );
    tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") );
    tabBar->getRibbonChildren()[3].setTooltip( _("Players") );


    ButtonWidget* deleteBtn = getWidget<ButtonWidget>("delete");
    if (m_config->getType() != DEVICE_CONFIG_TYPE_KEYBOARD)
    {
        core::stringw label = (m_config->isEnabled()
                            ? //I18N: button to disable a gamepad configuration
                              _("Disable Device")
                            : //I18N: button to enable a gamepad configuration
                              _("Enable Device"));

        // Make sure button is wide enough as the text is being changed away
        // from the original value
        core::dimension2d<u32> size =
            GUIEngine::getFont()->getDimension(label.c_str());
        const int needed = size.Width + deleteBtn->getWidthNeededAroundLabel();
        if (deleteBtn->m_w < needed) deleteBtn->m_w = needed;

        deleteBtn->setLabel(label);
    }
    else
    {
        deleteBtn->setLabel(_("Delete Configuration"));

        if (input_manager->getDeviceList()->getKeyboardAmount() < 2)
        {
            // don't allow deleting the last config
            deleteBtn->setDeactivated();
        }
        else
        {
            deleteBtn->setActivated();
        }
    }

    // Make the two buttons the same length, not strictly needed but will
    // look nicer...
    ButtonWidget* backBtn = getWidget<ButtonWidget>("back_to_device_list");
    if (backBtn->m_w < deleteBtn->m_w) backBtn->m_w   = deleteBtn->m_w;
    else                               deleteBtn->m_w = backBtn->m_w;

    backBtn->moveIrrlichtElement();
    deleteBtn->moveIrrlichtElement();

    LabelWidget* label = getWidget<LabelWidget>("title");
    label->setText( m_config->getName().c_str(), false );

    GUIEngine::ListWidget* actions =
        getWidget<GUIEngine::ListWidget>("actions");
    assert( actions != NULL );

    // ---- create list skeleton (right number of items, right internal names)
    //      their actualy contents will be adapted as needed after

    //I18N: Key binding section
    addListItemSubheader(actions, "game_keys_section", _("Game Keys"));
    addListItem(actions, PA_STEER_LEFT);
    addListItem(actions, PA_STEER_RIGHT);
    addListItem(actions, PA_ACCEL);
    addListItem(actions, PA_BRAKE);
    addListItem(actions, PA_FIRE);
    addListItem(actions, PA_NITRO);
    addListItem(actions, PA_DRIFT);
    addListItem(actions, PA_LOOK_BACK);
    addListItem(actions, PA_RESCUE);
    addListItem(actions, PA_PAUSE_RACE);


    //I18N: Key binding section
    addListItemSubheader(actions, "menu_keys_section", _("Menu Keys"));
    addListItem(actions, PA_MENU_UP);
    addListItem(actions, PA_MENU_DOWN);
    addListItem(actions, PA_MENU_LEFT);
    addListItem(actions, PA_MENU_RIGHT);
    addListItem(actions, PA_MENU_SELECT);
    addListItem(actions, PA_MENU_CANCEL);

    updateInputButtons();

    // Disable deletion keyboard configurations
    if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
    {
        getWidget<ButtonWidget>("delete")->setDeactivated();
    } else
    {
        getWidget<ButtonWidget>("delete")->setActivated();
    }
}   // init
コード例 #14
0
    Impl(Public *i, Mode mode) : Base(i)
    {
        ScrollAreaWidget &area = self().area();

        // Create the widgets.
        area.add(autoCheck   = new ToggleWidget);
        area.add(freqs       = new ChoiceWidget);
        area.add(lastChecked = new LabelWidget);
        area.add(channels    = new ChoiceWidget);
        area.add(autoDown    = new ToggleWidget);
        //area.add(paths       = new ChoiceWidget);
        area.add(deleteAfter = new ToggleWidget);

        // The updater Config is changed when the widget state is modified.
        QObject::connect(autoCheck,   SIGNAL(stateChangedByUser(ToggleWidget::ToggleState)), thisPublic, SLOT(apply()));
        QObject::connect(freqs,       SIGNAL(selectionChangedByUser(uint)),                  thisPublic, SLOT(apply()));
        QObject::connect(channels,    SIGNAL(selectionChangedByUser(uint)),                  thisPublic, SLOT(apply()));
        QObject::connect(autoDown,    SIGNAL(stateChangedByUser(ToggleWidget::ToggleState)), thisPublic, SLOT(apply()));
        //QObject::connect(paths,       SIGNAL(selectionChangedByUser(uint)),                  thisPublic, SLOT(apply()));
        QObject::connect(deleteAfter, SIGNAL(stateChangedByUser(ToggleWidget::ToggleState)), thisPublic, SLOT(apply()));

        LabelWidget *releaseLabel = new LabelWidget;
        area.add(releaseLabel);

        /*LabelWidget *pathLabel = new LabelWidget;
        area.add(pathLabel);*/

        autoCheck->setText(tr("Check for Updates:"));

        freqs->items()
                << new ChoiceItem(tr("At startup"), UpdaterSettings::AtStartup)
                << new ChoiceItem(tr("Daily"),      UpdaterSettings::Daily)
                << new ChoiceItem(tr("Biweekly"),   UpdaterSettings::Biweekly)
                << new ChoiceItem(tr("Weekly"),     UpdaterSettings::Weekly)
                << new ChoiceItem(tr("Monthly"),    UpdaterSettings::Monthly);

        lastChecked->margins().setTop("");
        lastChecked->setFont("separator.annotation");
        lastChecked->setTextColor("altaccent");

        releaseLabel->setText("Release Type:");

        channels->items()
                << new ChoiceItem(tr("Stable only"),      UpdaterSettings::Stable)
                << new ChoiceItem(tr("RC or stable"),     UpdaterSettings::StableOrCandidate)
                << new ChoiceItem(tr("Unstable/nightly"), UpdaterSettings::Unstable);

        /*pathLabel->setText(tr("Download location:"));
        paths->items()
                << new ChoiceItem(defaultLocationName(),
                                  UpdaterSettings::defaultDownloadPath().toString());*/

        autoDown->setText(tr("Download Automatically"));
        deleteAfter->setText(tr("Delete File After Install"));

        fetch();

        autoCheck->audienceForToggle() += this;

        // Place the widgets into a grid.
        GridLayout layout(area.contentRule().left(), area.contentRule().top());
        layout.setGridSize(2, 0);
        layout.setColumnAlignment(0, ui::AlignRight); // Labels aligned to the right.

        layout << *autoCheck    << *freqs
               << Const(0)      << *lastChecked
               << *releaseLabel << *channels
               << Const(0)      << *autoDown
               << Const(0)      << *deleteAfter;
               //<< *pathLabel    << *paths;

        area.setContentSize(layout);

        self().buttons()
                << new DialogButtonItem(DialogWidget::Default | DialogWidget::Accept, tr("Close"));

        if (mode == WithApplyAndCheckButton)
        {
            self().buttons()
                    << new DialogButtonItem(DialogWidget::Action, tr("Check Now"),
                                            new SignalAction(thisPublic, SLOT(applyAndCheckNow())));
        }
    }