Exemple #1
0
void ButtonWidget::setLabel(const irr::core::stringw &label)
{
    // This method should only be called AFTER a widget is added
    assert(m_element != NULL);

    m_element->setText( label.c_str() );
    setText(label);
}
// -----------------------------------------------------------------------------
void RibbonWidget::setLabel(const int id, irr::core::stringw new_name)
{
    if (m_labels.size() == 0) return; // ignore this call for ribbons without labels
    
    assert(id >= 0);
    assert(id < m_labels.size());
    m_labels[id].setText( new_name.c_str() );
    m_text = new_name;
}
// -----------------------------------------------------------------------------
void ListWidget::renameCell(const int row_index, const int col_index, const irr::core::stringw newName, const int icon)
{
    // May only be called AFTER this widget has been add()ed
    assert(m_element != NULL);

    CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
    assert(list != NULL);

    list->setCell(row_index, col_index, newName.c_str(), icon);

    list->setItemOverrideColor( row_index, EGUI_LBC_TEXT          , video::SColor(255,0,0,0) );
    list->setItemOverrideColor( row_index, EGUI_LBC_TEXT_HIGHLIGHT, video::SColor(255,255,255,255) );
}
Exemple #4
0
void FeatureUnlockedCutScene::addUnlockedPicture(irr::video::ITexture* picture,
                                                 float w, float h,
                                                 irr::core::stringw msg)
{
    if (picture == NULL)
    {
        Log::warn("FeatureUnlockedCutScene::addUnlockedPicture", "Unlockable has no picture: %s",
            core::stringc(msg.c_str()).c_str());
        picture = irr_driver->getTexture(file_manager->getAsset(FileManager::GUI,"main_help.png"));

    }

    m_unlocked_stuff.push_back( new UnlockedThing(picture, w, h, msg) );
}   // addUnlockedPicture
Exemple #5
0
void FeatureUnlockedCutScene::addUnlockedPicture(irr::video::ITexture* picture,
                                                 float w, float h,
                                                 irr::core::stringw msg)
{
    if (picture == NULL)
    {
        std::cerr << "[FeatureUnlockedCutScene::addUnlockedPicture] WARNING: unlockable has no picture : "
                  << core::stringc(msg.c_str()).c_str() << "\n";
        picture = irr_driver->getTexture(file_manager->getAsset(FileManager::GUI,"main_help.png"));

    }

    m_unlocked_stuff.push_back( new UnlockedThing(picture, w, h, msg) );
}   // addUnlockedPicture
Exemple #6
0
void SpinnerWidget::setValue(irr::core::stringw new_value)
{
    const int size = (int)m_labels.size();
    for (int n=0; n<size; n++)
    {
        if (m_labels[n] == new_value)
        {
            setValue(n);
            return;
        }
    }

    Log::fatal("SpinnerWidget::setValue", "Cannot find element named '%s'",
        irr::core::stringc(new_value.c_str()).c_str());
}
void SpinnerWidget::setValue(irr::core::stringw new_value)
{
    const int size = (int)m_labels.size();
    for (int n=0; n<size; n++)
    {
        if (m_labels[n] == new_value)
        {
            setValue(n);
            return;
        }
    }

    std::cerr << "ERROR [SpinnerWidget::setValue] : cannot find element named '"
              <<  irr::core::stringc(new_value.c_str()).c_str() << "'\n";
    assert(false);
}
Exemple #8
0
// ----------------------------------------------------------------------------
void RibbonWidget::setLabel(const unsigned int id, irr::core::stringw new_name)
{
    if (m_element == NULL)
    {
        // before adding
        m_children[id].setText(new_name);
    }
    else
    {
        // after adding
        // ignore this call for ribbons without labels
        if (m_labels.size() == 0) return;

        assert(id < m_labels.size());
        m_labels[id].setText(new_name.c_str());
        //m_text = new_name;
    }
}   // setLabel
/**
 * \param original Message to translate
 * \param context  Optional, can be set to differentiate 2 strings that are identical
 *                 in English but could be different in other languages
 */
const wchar_t* Translations::w_gettext(const char* original, const char* context)
{
    if (original[0] == '\0') return L"";

#if TRANSLATE_VERBOSE
    Log::info("Translations", "Translating %s", original);
#endif

    const std::string& original_t = (context == NULL ?
                                     m_dictionary.translate(original) :
                                     m_dictionary.translate_ctxt(context, original));

    if (original_t == original)
    {
        static irr::core::stringw converted_string;
        converted_string = StringUtils::utf8ToWide(original);

#if TRANSLATE_VERBOSE
        std::wcout << L"  translation : " << converted_string << std::endl;
#endif
        return converted_string.c_str();
    }

    // print
    //for (int n=0;; n+=4)

    static core::stringw original_tw;
    original_tw = StringUtils::utf8ToWide(original_t);

    const wchar_t* out_ptr = original_tw.c_str();
    if (REMOVE_BOM) out_ptr++;

#if TRANSLATE_VERBOSE
    std::wcout << L"  translation : " << out_ptr << std::endl;
#endif

    return out_ptr;
}
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);
    }
}
 /** Returns the description of this achievement. */
 irr::core::stringw getDescription() const { return _(m_description.c_str()); }
 /** Returns the name of this achievement. */
 irr::core::stringw getName() const { return _LTR(m_name.c_str()); }
Exemple #13
0
 bool               isRTLText(const irr::core::stringw &str) { return isRTLText(str.c_str()); }
Exemple #14
0
void ListWidget::selectItemWithLabel(const irr::core::stringw& name)
{
    CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
    assert(list != NULL);
    return list->setSelectedByCellText( name.c_str() );
}
Exemple #15
0
std::string stringw_to_stdstring(irr::core::stringw sw)
{
    std::stringstream ss;
        ss << sw.c_str();
        return ss.str();
}
Exemple #16
0
// ----------------------------------------------------------------------------
void KartSelectionScreen::updateKartWidgetModel(int widget_id,
                const std::string& selection,
                const irr::core::stringw& selectionText)
{
    // Update the displayed model
    ModelViewWidget* w3 = m_kart_widgets[widget_id].m_model_view;
    assert( w3 != NULL );

    if (selection == RANDOM_KART_ID)
    {
        // Random kart
        scene::IMesh* model =
            ItemManager::getItemModel(Item::ITEM_BONUS_BOX);

        w3->clearModels();
        w3->addModel( model, Vec3(0.0f, -12.0f, 0.0f),
                      Vec3(35.0f, 35.0f, 35.0f) );
        w3->update(0);
        m_kart_widgets[widget_id].m_kart_name
        ->setText( _("Random Kart"), false );
    }
    // selection contains the name of the kart, so check only for substr
    else if (StringUtils::startsWith(selection, ID_LOCKED) && !m_multiplayer)
    {
        w3->clearModels();
        w3->addModel(irr_driver->getAnimatedMesh(
                         file_manager->getAsset(FileManager::MODEL, "chest.b3d") )->getMesh(20),
                     Vec3(0,0,0), Vec3(15.0f, 15.0f, 15.0f) );
        w3->update(0);

        if (m_multiplayer)
        {
            m_kart_widgets[widget_id].m_kart_name
            ->setText(_("Locked"), false );
        }
        else
        {
            m_kart_widgets[widget_id].m_kart_name
            ->setText(_("Locked : solve active challenges to gain access to more!"), false );
        }
    }
    else
    {
        const KartProperties *kp =
            kart_properties_manager->getKart(selection);
        if (kp != NULL)
        {
            const KartModel &kart_model = kp->getMasterKartModel();

            float scale = 35.0f;
            if (kart_model.getLength() > 1.45f)
            {
                // if kart is too long, size it down a bit so that it fits
                scale = 30.0f;
            }

            w3->clearModels();
            w3->addModel( kart_model.getModel(), Vec3(0,0,0),
                Vec3(scale, scale, scale),
                          kart_model.getBaseFrame() );
            w3->addModel( kart_model.getWheelModel(0),
                          kart_model.getWheelGraphicsPosition(0) );
            w3->addModel( kart_model.getWheelModel(1),
                          kart_model.getWheelGraphicsPosition(1) );
            w3->addModel( kart_model.getWheelModel(2),
                          kart_model.getWheelGraphicsPosition(2) );
            w3->addModel( kart_model.getWheelModel(3),
                          kart_model.getWheelGraphicsPosition(3) );
            for (size_t i = 0; i < kart_model.getSpeedWeightedObjectsCount(); i++)
            {
                const SpeedWeightedObject&  obj = kart_model.getSpeedWeightedObject((int)i);
                w3->addModel(obj.m_model, obj.m_position);
            }
            //w3->update(0);

            m_kart_widgets[widget_id].m_kart_name
            ->setText( selectionText.c_str(), false );
        }
        else
            Log::warn("KartSelectionScreen", "could not "
                      "find a kart named '%s'",
                      selection.c_str());
    }
}
Exemple #17
0
 // ------------------------------------------------------------------------
 const irr::core::stringw
       getChallengeDescription() const 
                               {return _(m_challenge_description.c_str()); }
void ProgressBarWidget::setLabel(irr::core::stringw label)
{
    m_element->setText( label.c_str() );
    m_text = label;
}
Exemple #19
0
 /** Returns the name of the challenge. */
 const irr::core::stringw getName() const
                           { return irr::core::stringw(_(m_name.c_str())); }
 /** 
   * Sets the text of a widget from a stringw.
   * \note This method uses the virtual setText(wchar_t*) function, so only the latter
   *       needs to be overwritten by other classes.
   * \note Not all widgets use strings, so some widgets may ignore this text property
   * \note Changing the text property will only take effect the next time this widget
   *       is add()ed
   */
 virtual void setText(const irr::core::stringw &s) { setText(s.c_str()); }
    // ------------------------------------------------------------------------
    irr::core::stringw insertValues(const irr::core::stringw &s,
                                    std::vector<irr::core::stringw>& all_vals)
    {
        try
        {
            unsigned int insertValID = 0;

            const std::vector<irr::core::stringw> sv =
                                              StringUtils::split(s, '%', true);

            irr::core::stringw new_string="";

            const unsigned int size = sv.size();
            for (unsigned int i=0; i<size; i++)
            {
                if(sv[i][0] != '%')
                {
                    new_string += sv[i];
                }
                else
                {
                    if (sv[i][1]=='s' || sv[i][1]=='d' || sv[i][1]=='i')
                    {
                        if (insertValID >= all_vals.size())
                        {
                            Log::warn("StringUtils", "insertValues: "
                                      "Invalid number of arguments in '%s'\n",
                                      irr::core::stringc(s.c_str()).c_str());
                            new_string += "??";
                            new_string += sv[i].subString(2, sv[i].size()-2);
                        }
                        else
                        {
                            new_string += all_vals[insertValID].c_str();
                            new_string += sv[i].subString(2, sv[i].size()-2);
                        }
                        insertValID++;
                    }
                    else if(irr::core::isdigit(sv[i][1]))
                    {
                        irr::core::stringw rest =
                                            sv[i].subString(2, sv[i].size()-2);
                        int delta = 0;

                        if (sv[i].size() >= 4 && sv[i][2]=='$')
                        {
                            rest = sv[i].subString(4, sv[i].size()-4);
                            delta = -1;
                        }

                        const unsigned int index =
                                 irr::core::stringc(sv[i].c_str()).c_str()[1]
                                 - '0' + delta;
                        if (index >= all_vals.size())
                        {
                            Log::warn("StringUtils", "insertValues: "
                                      "Invalid argument ID in '%s' : %i\n",
                                      irr::core::stringc(s.c_str()).c_str(),
                                      index);
                            new_string += "??";
                            new_string += rest;
                        }
                        else
                        {
                            new_string += all_vals[index] + rest;
                        }
                    }
                    else
                    {
                        new_string+=sv[i];
                    }
                }
            }
            return new_string;
        }
        catch (std::exception& e)
        {
            (void)e;  // avoid warning about unused variable
            Log::fatal("StringUtils",
                       "Fatal error in insertValues(stringw) : %s @ line %i.",
                       __FILE__, __LINE__);
            exit(1);
        }
    }
Exemple #22
0
TrackInfoDialog::TrackInfoDialog(const std::string& ribbonItem, const std::string& trackIdent,
                                 const irr::core::stringw& trackName, ITexture* screenshot,
                                 const float w, const float h) : ModalDialog(w, h)
{
    loadFromFile("track_info_dialog.stkgui");

    const bool has_laps       = race_manager->modeHasLaps();
    const bool has_highscores = race_manager->modeHasHighscores();

    m_track_ident = trackIdent;
    m_ribbon_item = ribbonItem;

    getWidget<LabelWidget>("name")->setText(trackName.c_str(), false);

    Track* track = track_manager->getTrack(trackIdent);
    //I18N: when showing who is the author of track '%s' (place %s where the name of the author should appear)
    getWidget<LabelWidget>("author")->setText( _("Track by %s", track->getDesigner().c_str()), false );


    // ---- Track screenshot
    Widget* screenshot_div = getWidget("screenshot_div");
    IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
                                                              false /* tab stop */, false /* focusable */);
    // images are saved squared, but must be stretched to 4:
    screenshotWidget->setCustomAspectRatio(4.0f / 3.0f);

    screenshotWidget->m_x = screenshot_div->m_x;
    screenshotWidget->m_y = screenshot_div->m_y;
    screenshotWidget->m_w = screenshot_div->m_w;
    screenshotWidget->m_h = screenshot_div->m_h;

    // temporary icon, will replace it just after (but it will be shown if the given icon is not found)
    screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png";
    screenshotWidget->setParent(m_irrlicht_window);
    screenshotWidget->add();

    if (screenshot != NULL)
    {
        screenshotWidget->setImage(screenshot);
    }
    m_widgets.push_back(screenshotWidget);


    // ---- Lap count m_spinner
    if (has_laps)
    {
        m_spinner = getWidget<SpinnerWidget>("lapcountspinner");

        m_spinner->m_properties[PROP_ID] = "lapcountspinner";
        if (UserConfigParams::m_artist_debug_mode)
        {
            m_spinner->setMin(0);
        }

        //I18N: In the track setup screen (number of laps choice, where %i is the number)
        //m_spinner->setText( _("%i laps") );
        m_spinner->setValue( UserConfigParams::m_num_laps );
        //m_spinner->getIrrlichtElement()->setTabStop(true);
        //m_spinner->getIrrlichtElement()->setTabGroup(false);

        const int num_laps = m_spinner->getValue();
        race_manager->setNumLaps(num_laps);
    }
    else
    {
        getWidget<SpinnerWidget>("lapcountspinner")->setVisible(false);
        m_spinner = NULL;
    }


    // Reverse track
    const bool reverse_available = track->reverseAvailable() &&
               race_manager->getMinorMode() != RaceManager::MINOR_MODE_EASTER_EGG;
    if (reverse_available)
    {
        m_checkbox = getWidget<CheckBoxWidget>("reverse");
        m_checkbox->setState(race_manager->getReverseTrack());
    }
    else
    {
        getWidget<CheckBoxWidget>("reverse")->setVisible(false);
        getWidget<LabelWidget>("reverse-text")->setVisible(false);
        m_checkbox = NULL;
        race_manager->setReverseTrack(false);
    }

    // ---- High Scores
    if (has_highscores)
    {
        m_kart_icons[0] = getWidget<IconButtonWidget>("iconscore1");
        m_kart_icons[1] = getWidget<IconButtonWidget>("iconscore2");
        m_kart_icons[2] = getWidget<IconButtonWidget>("iconscore3");

        m_highscore_entries[0] = getWidget<LabelWidget>("highscore1");
        m_highscore_entries[1] = getWidget<LabelWidget>("highscore2");
        m_highscore_entries[2] = getWidget<LabelWidget>("highscore3");

        updateHighScores();

    }
    else
    {
        getWidget<IconButtonWidget>("iconscore1")->setVisible(false);
        getWidget<IconButtonWidget>("iconscore2")->setVisible(false);
        getWidget<IconButtonWidget>("iconscore3")->setVisible(false);

        getWidget<LabelWidget>("highscores")->setVisible(false);
        getWidget<LabelWidget>("highscore1")->setVisible(false);
        getWidget<LabelWidget>("highscore2")->setVisible(false);
        getWidget<LabelWidget>("highscore3")->setVisible(false);
    }

    getWidget<ButtonWidget>("start")->setFocusForPlayer( PLAYER_ID_GAME_MASTER );

}   // TrackInfoDialog
Exemple #23
0
/** Sets an error message for the gui.
 */
void STKHost::setErrorMessage(const irr::core::stringw &message)
{
    irr::core::stringc s(message.c_str());
    Log::error("STKHost", "%s", s.c_str());
    m_error_message = message;
}   // setErrorMessage