Пример #1
0
            /** Callback for the request to update rank of a player. Shows his
            *   rank and score.
            */
            virtual void callback()
            {
                auto done = m_done.lock();
                // Dialog deleted
                if (!done)
                    return;
                // I18N: In the network player dialog, indiciating a network
                // player has no ranking
                core::stringw result = _("%s has no ranking yet.", m_name);
                if (isSuccess())
                {
                    int rank = -1;
                    float score = 0.0f;
                    getXMLData()->get("rank", &rank);
                    getXMLData()->get("scores", &score);
                    if (rank > 0)
                    {
                        // I18N: In the network player dialog show rank and
                        // score of a player
                        result = _("%s is number %d in the rankings with a score of %f.",
                            m_name, rank, score);
                    }
                }
                *done = true;
                m_info->setText(result, false);

            }   // callback
Пример #2
0
void WaitingForOthersScreen::onUpdate(float dt)
{
    const GameSetup *setup = STKHost::get()->getGameSetup();
    const std::vector<NetworkPlayerProfile*> &all_profiles = setup->getPlayers();

    RaceConfig* config = STKHost::get()->getGameSetup()->getRaceConfig();
    core::stringw w;
    for (unsigned int i = 0; i < all_profiles.size(); i++)
    {
        const NetworkPlayerProfile* profile = all_profiles[i];
        if (profile == NULL)
            continue;
        core::stringw name = profile->getName();


        int playerId = profile->getGlobalPlayerId();
        const std::string &kart = profile->getKartName();
        if (!kart.empty())
            name += StringUtils::insertValues(L" (%s)", core::stringw(kart.c_str()));

        w += name + L" : ";
        const RaceVote& vote = config->getRaceVote(playerId);
        if (vote.hasVotedTrack())
        {
            w += vote.getTrackVote().c_str();
        }
        else
        {
            w += L"...";
        }

        w += "\n";
    }

    GUIEngine::LabelWidget* lbl = getWidget<GUIEngine::LabelWidget>("lblDetails");
    lbl->setText(w.c_str(), true);
}
Пример #3
0
/** Dialog constructor. 
 *  \param server_id ID of the server of which to display the info.
 *  \param host_id ID of the host.
 *  \param from_server_creation: true if the dialog shows the data of this
 *         server (i.e. while it is being created).
 */
ServerInfoDialog::ServerInfoDialog(uint32_t server_id, uint32_t host_id,
                                   bool from_server_creation)
                : ModalDialog(0.8f,0.8f), m_server_id(server_id)
                , m_host_id(host_id)
{
    Log::info("ServerInfoDialog", "Server id is %d, Host id is %d",
               server_id, host_id);
    m_self_destroy = false;
    m_enter_lobby = false;
    m_from_server_creation = from_server_creation;

    loadFromFile("online/server_info_dialog.stkgui");

    GUIEngine::LabelWidget *name = getWidget<LabelWidget>("server_name");
    assert(name);
    const Server * server = ServersManager::get()->getServerByID(m_server_id);
    name->setText(server->getName(),false);

    core::stringw difficulty = race_manager->getDifficultyName(server->getDifficulty());
    GUIEngine::LabelWidget *lbldifficulty = getWidget<LabelWidget>("server_difficulty");
    lbldifficulty->setText(difficulty, false);

    core::stringw mode = RaceManager::getNameOf(server->getRaceMinorMode());
    GUIEngine::LabelWidget *gamemode = getWidget<LabelWidget>("server_game_mode");
    gamemode->setText(mode, false);

    m_info_widget = getWidget<LabelWidget>("info");
    assert(m_info_widget != NULL);
    if (m_from_server_creation)
        m_info_widget->setText(_("Server successfully created. You can now join it."), true);
    m_options_widget = getWidget<RibbonWidget>("options");
    assert(m_options_widget != NULL);
    m_join_widget = getWidget<IconButtonWidget>("join");
    assert(m_join_widget != NULL);
    m_cancel_widget = getWidget<IconButtonWidget>("cancel");
    assert(m_cancel_widget != NULL);
    m_options_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);

}   // ServerInfoDialog
Пример #4
0
void AddonsLoading::beforeAddingWidgets()
{
    /* Init the icon here to be able to load a single image*/
    m_icon             = getWidget<IconButtonWidget> ("icon"    );
    m_progress         = getWidget<ProgressBarWidget>("progress");
    m_back_button      = getWidget<IconButtonWidget> ("back"    );

    RibbonWidget* r = getWidget<RibbonWidget>("actions");
    RatingBarWidget* rating = getWidget<RatingBarWidget>("rating");

    if (m_addon.isInstalled())
    {
        /* only keep the button as "update" if allowed to access the net
         * and  not in error state
         */
        if (m_addon.needsUpdate() && !addons_manager->wasError()
            && UserConfigParams::m_internet_status==RequestManager::IPERM_ALLOWED)
            getWidget<IconButtonWidget> ("install")->setLabel( _("Update") );
        else
            r->removeChildNamed("install");
    }
    else
    {
        r->removeChildNamed("uninstall");
    }

    getWidget<LabelWidget>("name")->setText(m_addon.getName().c_str(), false);
    getWidget<BubbleWidget>("description")
        ->setText(m_addon.getDescription().c_str());
    core::stringw revision = _("Version: %d", m_addon.getRevision());
    getWidget<LabelWidget>("revision")->setText(revision, false);
    rating->setRating(m_addon.getRating());
    rating->setStarNumber(3);

    // Display flags for this addon
    // ============================
    std::vector<core::stringw> l;
    if(UserConfigParams::m_artist_debug_mode)
    {
        // In non artist-debug-mode only approved items will be shown anyway,
        // but give even tester an idea about the status:
        if (!m_addon.testStatus(Addon::AS_APPROVED))
            l.push_back("NOT APPROVED");

        // Note that an approved addon should never have alpha, beta, or
        // RC status - and only one of those should be used
        if(m_addon.testStatus(Addon::AS_ALPHA))
            l.push_back("alpha");
        else if(m_addon.testStatus(Addon::AS_BETA))
            l.push_back("beta");
        else if(m_addon.testStatus(Addon::AS_RC))
            l.push_back("RC");

        // Don't displat those for now, they're more confusing than helpful for the average player
        //if(m_addon.testStatus(Addon::AS_BAD_DIM))
        //    l.push_back("bad-texture");
        //if(!m_addon.testStatus(Addon::AS_DFSG))
        //    l.push_back("non-DFSG");
    }
    if(m_addon.testStatus(Addon::AS_FEATURED))
        l.push_back(_("featured"));

    GUIEngine::LabelWidget *flags = getWidget<LabelWidget>("flags");
    if(flags)
    {
        core::stringw s1("");
        for(unsigned int i=0; i<l.size(); i++)
        {
            s1+=l[i];
            // if it's not the last item, add a ",".
            // Don't test for l.size()-1 - since this is unsigned!
            if(i+1<l.size())
                s1+=", ";
        }
        flags->setText(s1, false);
    }

    // Display the size
    // ================
    int n = m_addon.getSize();
    core::stringw unit="";
    if(n>1024*1024)
    {
        float f = ((int)(n/1024.0f/1024.0f*10.0f+0.5f))/10.0f;
        char s[32];
        sprintf(s, "%.1f", f);
        unit=_("%s MB", s);
    }
    else if(n>1024)
    {
        float f = ((int)(n/1024.0f*10.0f+0.5f))/10.0f;
        char s[32];
        sprintf(s, "%.1f", f);
        unit=_("%s KB", s);
    }
    else
        // Anything smaller just let it be 1 KB
        unit=_("%s KB", 1);
    core::stringw size = _("Size: %s", unit.c_str());
    getWidget<LabelWidget>("size")->setText(size, false);
}   // AddonsLoading