Massive conversion from std::string to stringw for all strings that need to be translated. Currently, translation is broken (strings i try to transalte appear as junk) -- since irrlicht GUI widgets all use wchar_t, using std::string in UTF-8 just didn't make it

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3963 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-08-30 18:21:59 +00:00
parent 06aea85a37
commit c3f0f7ab82
49 changed files with 399 additions and 210 deletions

View File

@ -43,7 +43,7 @@ void Challenge::addUnlockTrackReward(const std::string &track_name)
//-----------------------------------------------------------------------------
void Challenge::addUnlockModeReward(const std::string &internal_mode_name,
const std::string &user_mode_name)
const irr::core::stringw &user_mode_name)
{
UnlockableFeature feature;
feature.name = internal_mode_name;
@ -56,14 +56,18 @@ void Challenge::addUnlockModeReward(const std::string &internal_mode_name,
void Challenge::addUnlockGPReward(const std::string &gp_name)
{
UnlockableFeature feature;
feature.name = _(gp_name.c_str());
// FIXME : why are we translation an internal name here??
//feature.name = _(gp_name.c_str());
feature.name = gp_name.c_str();
feature.type = UNLOCK_GP;
m_feature.push_back(feature);
}
//-----------------------------------------------------------------------------
void Challenge::addUnlockDifficultyReward(const std::string &internal_name,
const std::string &user_name)
const irr::core::stringw &user_name)
{
UnlockableFeature feature;
feature.name = internal_name;
@ -74,7 +78,7 @@ void Challenge::addUnlockDifficultyReward(const std::string &internal_name,
//-----------------------------------------------------------------------------
void Challenge::addUnlockKartReward(const std::string &internal_name,
const std::string &user_name)
const irr::core::stringw &user_name)
{
UnlockableFeature feature;
feature.name = internal_name;
@ -84,9 +88,9 @@ void Challenge::addUnlockKartReward(const std::string &internal_name,
}
//-----------------------------------------------------------------------------
const std::string Challenge::getUnlockedMessage() const
const irr::core::stringw Challenge::getUnlockedMessage() const
{
std::string unlocked_message;
irr::core::stringw unlocked_message;
const unsigned int amount = (unsigned int)m_feature.size();
for(unsigned int n=0; n<amount; n++)
@ -94,7 +98,7 @@ const std::string Challenge::getUnlockedMessage() const
// add line break if we are showing multiple messages
if(n>0) unlocked_message+='\n';
std::string message;
irr::core::stringw message;
// write message depending on feature type
switch(m_feature[n].type)
@ -104,32 +108,32 @@ const std::string Challenge::getUnlockedMessage() const
Track* track = track_manager->getTrack( m_feature[n].name );
message = StringUtils::insertValues(
_("New track '%s'\nnow available"),
_(track->getName().c_str()) );
track->getName().c_str() ); // FIXME : insertValues can't handle wide strings
break;
}
case UNLOCK_MODE:
message = StringUtils::insertValues(
_("New game mode\n'%s'\nnow available"),
m_feature[n].user_name);
m_feature[n].user_name.c_str()); // FIXME : insertValues can't handle wide strings
break;
case UNLOCK_GP:
{
std::string gp_user_name = grand_prix_manager->getGrandPrix(m_feature[n].name)->getName();
const irr::core::stringw& gp_user_name = grand_prix_manager->getGrandPrix(m_feature[n].name)->getName();
message = StringUtils::insertValues(
_("New Grand Prix '%s'\nnow available"),
gp_user_name);
gp_user_name.c_str()); // FIXME : insertValues can't handle wide strings
break;
}
case UNLOCK_DIFFICULTY:
message = StringUtils::insertValues(
_("New difficulty\n'%s'\nnow available"),
m_feature[n].user_name);
m_feature[n].user_name.c_str()); // FIXME : insertValues can't handle wide strings
break;
case UNLOCK_KART:
const KartProperties *kp=kart_properties_manager->getKart(m_feature[n].name );
message = StringUtils::insertValues(
_("New kart\n'%s'\nnow available"),
kp->getName());
kp->getName().c_str()); // FIXME : insertValues can't handle wide strings
break;
} // switch
unlocked_message += message;

View File

@ -23,6 +23,7 @@
#include <string>
#include <vector>
#include <fstream>
#include <irrlicht.h>
class XMLNode;
@ -36,7 +37,7 @@ enum REWARD_TYPE
struct UnlockableFeature
{
std::string name; // internal name
std::string user_name; // not all types of feature have one
irr::core::stringw user_name; // not all types of feature have one
REWARD_TYPE type;
};
@ -64,14 +65,14 @@ public:
void setId(const std::string& s) { m_Id = s; }
void addUnlockTrackReward(const std::string &track_name);
void addUnlockModeReward(const std::string &internal_mode_name,
const std::string &user_mode_name);
const irr::core::stringw &user_mode_name);
void addUnlockGPReward(const std::string &gp_name);
void addUnlockDifficultyReward(const std::string &internal_name,
const std::string &user_name);
const irr::core::stringw &user_name);
void addUnlockKartReward(const std::string &internal_name,
const std::string &user_name);
const irr::core::stringw &user_name);
const std::string getUnlockedMessage() const;
const irr::core::stringw getUnlockedMessage() const;
const std::vector<UnlockableFeature>&
getFeatures() const { return m_feature; }
void setChallengeDescription(const std::string& d)

View File

@ -29,6 +29,7 @@
#include "race/grand_prix_manager.hpp"
#include "tracks/track.hpp"
#include "tracks/track_manager.hpp"
#include "utils/translation.hpp"
ChallengeData::ChallengeData(const std::string& filename)
{
@ -194,7 +195,8 @@ void ChallengeData::getUnlocks(const XMLNode *root, const std:: string type,
case UNLOCK_GP: addUnlockGPReward (data[0] ); break;
case UNLOCK_MODE: if(1<data.size())
{
addUnlockModeReward (data[0], data[1]);
irr::core::stringw user_name = _(data[1].c_str());
addUnlockModeReward (data[0], user_name);
break;
}
else
@ -202,14 +204,16 @@ void ChallengeData::getUnlocks(const XMLNode *root, const std:: string type,
break;
case UNLOCK_DIFFICULTY: if(1<data.size())
{
addUnlockDifficultyReward(data[0], data[1]);
irr::core::stringw user_name = _(data[1].c_str());
addUnlockDifficultyReward(data[0], user_name);
}
else
fprintf(stderr, "Difficult name missing.\n");
break;
case UNLOCK_KART: if(1<data.size())
{
addUnlockKartReward(data[0], data[1]);
irr::core::stringw user_name = _(data[1].c_str());
addUnlockKartReward(data[0], user_name);
}
else
fprintf(stderr, "Kart name missing.\n");

View File

@ -2,15 +2,15 @@
//==== D E V I C E C O N F I G =================================================
std::string DeviceConfig::getBindingAsString (const PlayerAction action) const
irr::core::stringw DeviceConfig::getBindingAsString (const PlayerAction action) const
{
std::string returnString = "";
irr::core::stringw returnString = "";
if ((action < PA_COUNT) && (action >= 0))
{
returnString = returnString.append( Input::getInputAsString(m_bindings[action].type,
m_bindings[action].id,
m_bindings[action].dir) );
returnString += Input::getInputAsString(m_bindings[action].type,
m_bindings[action].id,
m_bindings[action].dir);
}
return returnString;
@ -18,17 +18,17 @@ std::string DeviceConfig::getBindingAsString (const PlayerAction action) const
//------------------------------------------------------------------------------
std::string DeviceConfig::toString ()
irr::core::stringw DeviceConfig::toString ()
{
std::string returnString = "";
irr::core::stringw returnString = "";
for (int n = 0; n < PA_COUNT; n++)
{
returnString = returnString.append(KartActionStrings[n]);
returnString = returnString.append(": ");
returnString = returnString.append(Input::getInputAsString(m_bindings[n].type,
m_bindings[n].id,
m_bindings[n].dir));
returnString = returnString.append("\n");
returnString += KartActionStrings[n].c_str();
returnString += ": ";
returnString += Input::getInputAsString(m_bindings[n].type,
m_bindings[n].id,
m_bindings[n].dir);
returnString += "\n";
}
return returnString;
}
@ -263,11 +263,11 @@ GamepadConfig::GamepadConfig(irr::io::IrrXMLReader* xml)
//------------------------------------------------------------------------------
std::string GamepadConfig::toString ()
irr::core::stringw GamepadConfig::toString ()
{
std::string returnString = "";
returnString = returnString.append(getName());
returnString = returnString.append("\n");
returnString = returnString.append(DeviceConfig::toString());
irr::core::stringw returnString = "";
returnString += getName().c_str();
returnString += "\n";
returnString += DeviceConfig::toString();
return returnString;
}

View File

@ -6,7 +6,7 @@
#include <iostream>
#include <fstream>
#include "io/xml_node.hpp"
#include <irrString.h>
struct KeyBinding
{
@ -35,8 +35,8 @@ class DeviceConfig
public:
std::string getName() const { return m_name; };
std::string getBindingAsString (const PlayerAction action) const;
std::string toString ();
irr::core::stringw getBindingAsString (const PlayerAction action) const;
irr::core::stringw toString ();
void serialize (std::ofstream& stream);
bool deserializeAction (irr::io::IrrXMLReader* xml);
@ -88,7 +88,7 @@ class GamepadConfig : public DeviceConfig
public:
std::string toString ();
irr::core::stringw toString ();
int getAxisCount() const { return m_axis_count; };
int getButtonCount() const { return m_button_count; };
void serialize (std::ofstream& stream);

View File

@ -283,7 +283,7 @@ private:
public:
std::string m_warning;
irr::core::stringw m_warning;
int CheckAndCreateDir();
UserConfig();
@ -296,10 +296,9 @@ public:
void saveConfig() { saveConfig(m_filename); }
void saveConfig(const std::string& filename);
const std::string
&getWarning() { return m_warning; }
void resetWarning() { m_warning=""; }
void setWarning(std::string& warning) { m_warning=warning; }
const irr::core::stringw& getWarning() { return m_warning; }
void resetWarning() { m_warning=""; }
void setWarning(irr::core::stringw& warning) { m_warning=warning; }
};

View File

@ -169,7 +169,7 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = prop_name; else widget.m_
READ_PROPERTY(y, PROP_Y);
READ_PROPERTY(layout, PROP_LAYOUT);
READ_PROPERTY(align, PROP_ALIGN);
READ_PROPERTY(text, PROP_TEXT);
READ_PROPERTY(icon, PROP_ICON);
READ_PROPERTY(text_align, PROP_TEXT_ALIGN);
READ_PROPERTY(min_value, PROP_MIN_VALUE);
@ -179,11 +179,33 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = prop_name; else widget.m_
READ_PROPERTY(max_width, PROP_MAX_WIDTH);
READ_PROPERTY(max_height, PROP_MAX_HEIGHT);
#undef READ_PROPERTY
const char* text = xml->getAttributeValue( "text" );
if (text != NULL)
{
widget.m_text = text; //_(text);
}
/*
if (widget.m_properties[PROP_TEXT].size() > 0)
{
std::cout << "Raw print : ";
for (wchar_t* ptr = utf16; *ptr != 0; ptr++)
{
std::cout << (*ptr & 0xFF) << " / " << ((*ptr >> 8) & 0xFF) << " / ";
}
std::cout << "\nIrr strinw print : ";
stringc irrstrc = irrstr.c_str();
for (u32 n=0; n<irrstrc.size(); n++)
{
std::cout << irrstrc[n] << " (" << (int)irrstrc[n] << ") ";
}
std::cout << std::endl;
widget.m_properties[PROP_TEXT] = _(widget.m_properties[PROP_TEXT].c_str());
}
}*/
/* a new div starts here, continue parsing with this new div as new parent */
if( widget.m_type == WTYPE_DIV || widget.m_type == WTYPE_RIBBON)

View File

@ -248,13 +248,13 @@ void Widget::readCoords(Widget* parent)
// ---- if this widget has a label, get text length. this can helpful determine its optimal size
int label_w = -1, label_h = -1;
if(m_properties[PROP_TEXT].size() > 0)
if (m_text.size() > 0)
{
IGUIFont* font = GUIEngine::getFont();
#ifdef IRR_SVN
core::dimension2d< u32 > dim = font->getDimension( stringw(m_properties[PROP_TEXT].c_str()).c_str() );
core::dimension2d< u32 > dim = font->getDimension( m_text.c_str() );
#else
core::dimension2d< s32 > dim = font->getDimension( stringw(m_properties[PROP_TEXT].c_str()).c_str() );
core::dimension2d< s32 > dim = font->getDimension( m_text.c_str() );
#endif
label_w = dim.Width;
// FIXME - won't work with multiline labels. thus, for now, when multiple

View File

@ -66,7 +66,7 @@ namespace GUIEngine
PROP_Y,
PROP_LAYOUT,
PROP_ALIGN,
PROP_TEXT,
// PROP_TEXT, // this one is a bit special, can't go along others since it's wide strings
PROP_ICON,
PROP_TEXT_ALIGN,
PROP_MIN_VALUE,
@ -240,6 +240,10 @@ namespace GUIEngine
/** A map that holds values for all specified widget properties (in the XML file)*/
std::map<Property, std::string> m_properties;
/** PROP_TEXT is a special case : since it can be transalted it can't go in the map above, which
uses narrow strings */
stringw m_text;
static void resetIDCounters();
/**

View File

@ -27,7 +27,7 @@ ButtonWidget::ButtonWidget()
void ButtonWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
stringw message = m_properties[PROP_TEXT].c_str();
stringw& message = m_text;
m_element = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, getNewID(), message.c_str(), L"");
id = m_element->getID();
@ -35,8 +35,9 @@ void ButtonWidget::add()
m_element->setTabGroup(false);
}
// -----------------------------------------------------------------------------
void ButtonWidget::setLabel(const char* label)
void ButtonWidget::setLabel(irr::core::stringw label)
{
m_element->setText( stringw(label).c_str() );
m_element->setText( label.c_str() );
m_text = label;
}

View File

@ -40,7 +40,7 @@ namespace GUIEngine
void add();
/** Change the label on the button */
void setLabel(const char* label);
void setLabel(const irr::core::stringw label);
};
}

View File

@ -29,7 +29,7 @@ CheckBoxWidget::CheckBoxWidget()
void CheckBoxWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
stringw message = m_properties[PROP_TEXT].c_str();
//stringw& message = m_text;
//m_element = GUIEngine::getGUIEnv()->addCheckBox(true /* checked */, widget_size, NULL, ++id_counter, message.c_str());
m_element = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, getNewID(), L"");

View File

@ -51,7 +51,7 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const int max_rows)
// -----------------------------------------------------------------------------
void DynamicRibbonWidget::add()
{
m_has_label = (m_properties[PROP_TEXT] == "bottom");
m_has_label = (m_text == "bottom");
m_label_height = m_has_label ? 25 : 0; // FIXME : get height from font, don't hardcode
// ----- add dynamic label at bottom
@ -213,7 +213,7 @@ void DynamicRibbonWidget::setSubElements()
// set size to get proper ratio (as most textures are saved scaled down to 256x256)
icon->m_properties[PROP_WIDTH] = m_properties[PROP_CHILD_WIDTH];
icon->m_properties[PROP_HEIGHT] = m_properties[PROP_CHILD_HEIGHT];
if(m_properties[PROP_TEXT] == "all") icon->m_properties[PROP_TEXT] = " ";
if (m_text == "all") icon->m_text = " ";
// std::cout << "ribbon text = " << m_properties[PROP_TEXT].c_str() << std::endl;
@ -227,7 +227,7 @@ void DynamicRibbonWidget::setSubElements()
}
// -----------------------------------------------------------------------------
void DynamicRibbonWidget::addItem( std::string user_name, std::string code_name, std::string image_file )
void DynamicRibbonWidget::addItem( const irr::core::stringw& user_name, const std::string& code_name, const std::string& image_file )
{
ItemDescription desc;
desc.m_user_name = user_name;
@ -257,13 +257,13 @@ const std::string& DynamicRibbonWidget::getSelectionIDString(const int playerID)
return nothing;
}
// -----------------------------------------------------------------------------
const std::string& DynamicRibbonWidget::getSelectionText(const int playerID)
const irr::core::stringw& DynamicRibbonWidget::getSelectionText(const int playerID)
{
RibbonWidget* row = (RibbonWidget*)(m_rows.size() == 1 ? m_rows.get(0) : getSelectedRibbon(playerID));
if(row != NULL) return row->getSelectionText(playerID);
if (row != NULL) return row->getSelectionText(playerID);
static const std::string nothing = "";
static const irr::core::stringw nothing = "";
return nothing;
}
// -----------------------------------------------------------------------------
@ -574,7 +574,7 @@ void DynamicRibbonWidget::updateItemDisplay()
button->setPressedImage( GUIEngine::getDriver()->getTexture( track_sshot.c_str()) );
icon->m_properties[PROP_ID] = m_items[icon_id].m_code_name;
icon->m_properties[PROP_TEXT] = m_items[icon_id].m_user_name;
icon->m_text = m_items[icon_id].m_user_name;
row.setLabel(i, m_items[icon_id].m_user_name);
}

View File

@ -40,13 +40,13 @@ namespace GUIEngine
public:
virtual ~DynamicRibbonHoverListener() {}
virtual void onSelectionChanged(DynamicRibbonWidget* theWidget, const std::string& selectionID,
const std::string& selectionText, const int playerID) = 0;
const irr::core::stringw& selectionText, const int playerID) = 0;
};
/** The description of an item added to a DynamicRibbonWidget */
struct ItemDescription
{
std::string m_user_name;
irr::core::stringw m_user_name;
std::string m_code_name;
std::string m_sshot_file;
};
@ -150,7 +150,7 @@ namespace GUIEngine
/** Dynamically add an item to the ribbon's list of items (will not be visible until you
call 'updateItemDisplay' or 'add') */
void addItem( std::string user_name, std::string code_name, std::string image_file );
void addItem( const irr::core::stringw& user_name, const std::string& code_name, const std::string& image_file );
/** Clears all items added through 'addItem'. You can then add new items with 'addItem' and call
'updateItemDisplay' to update the display. */
@ -173,7 +173,7 @@ namespace GUIEngine
const std::string& getSelectionIDString(const int playerID);
/** Get the user-visible text of the selected item */
const std::string& getSelectionText(const int playerID);
const irr::core::stringw& getSelectionText(const int playerID);
/** Select an item from its numerical ID. Only for [1-row] combo ribbons.
ID ranges from {0} to {number of items added through 'addItem' - 1} */

View File

@ -66,7 +66,7 @@ void IconButtonWidget::add()
}
// ---- label if any
stringw message = m_properties[PROP_TEXT].c_str();
stringw& message = m_text;
if (message.size() > 0)
{
widget_size += position2d<s32>(0, widget_size.getHeight());

View File

@ -28,7 +28,7 @@ void LabelWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
const bool word_wrap = m_properties[PROP_WORD_WRAP] == "true";
stringw message = m_properties[PROP_TEXT].c_str();
stringw& message = m_text;
EGUI_ALIGNMENT align = EGUIA_UPPERLEFT;
if(m_properties[PROP_TEXT_ALIGN] == "center") align = EGUIA_CENTER;
@ -50,5 +50,5 @@ void LabelWidget::setText(stringw newText)
IGUIStaticText* irrwidget = Widget::getIrrlichtElement<IGUIStaticText>();
irrwidget->setText(newText.c_str());
m_properties[PROP_TEXT] = stringc(newText.c_str()).c_str();
m_text = newText;
}

View File

@ -37,7 +37,7 @@ ModelViewWidget::~ModelViewWidget()
void ModelViewWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
stringw message = m_properties[PROP_TEXT].c_str();
//stringw& message = m_text;
IGUIImage* btn = GUIEngine::getGUIEnv()->addImage(widget_size, m_parent, getNewNoFocusID());
m_element = btn;

View File

@ -95,7 +95,7 @@ void RibbonWidget::add()
rect<s32> subsize = rect<s32>(widget_x - one_button_space/2+2, 0,
widget_x + one_button_space/2-2, h);
stringw message = m_children[i].m_properties[PROP_TEXT].c_str();
stringw& message = m_children[i].m_text;
if(m_children[i].m_type == WTYPE_BUTTON)
{
@ -143,7 +143,7 @@ void RibbonWidget::add()
}
else if(m_children[i].m_type == WTYPE_ICON_BUTTON)
{
const bool has_label = m_children[i].m_properties[PROP_TEXT].size() > 0;
const bool has_label = m_children[i].m_text.size() > 0;
// how much space to keep for the label under the button
const int needed_space_under_button = has_label ? 30 : 10; // quite arbitrary for now
@ -169,7 +169,7 @@ void RibbonWidget::add()
(int)((button_y + m_children[i].h)*zoom) + 5 /* leave 5 pixels between button and label */,
widget_x + (int)(one_button_space/2.0f), h);
stringw message = m_children[i].m_properties[PROP_TEXT].c_str();
stringw& message = m_children[i].m_text;
IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), subsize, false, true, btn);
label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
label->setTabStop(false);
@ -335,13 +335,14 @@ bool RibbonWidget::transmitEvent(Widget* w, std::string& originator, const int p
return true;
}
// -----------------------------------------------------------------------------
void RibbonWidget::setLabel(const int id, std::string new_name)
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( stringw(new_name.c_str()).c_str() );
m_labels[id].setText( new_name.c_str() );
m_text = new_name;
}
// -----------------------------------------------------------------------------
int RibbonWidget::findItemNamed(const char* internalName)

View File

@ -85,7 +85,7 @@ namespace GUIEngine
const std::string& getSelectionIDString(const int playerID);
/** Returns the user-visible text of the selection */
const std::string& getSelectionText(const int playerID) { return m_children[m_selection[playerID]].m_properties[PROP_TEXT]; }
const stringw& getSelectionText(const int playerID) { return m_children[m_selection[playerID]].m_text; }
/** Sets the ID of the selected item within the ribbon */
void setSelection(const int i, const int playerID) { m_selection[playerID] = i; updateSelection(); }
@ -97,7 +97,7 @@ namespace GUIEngine
(especially used in scrolling ribbons, when scrolling occurs by renaming
items - note that this statis ribbon doesn't support scrolling, only
superclasses/wrappers of this do.) */
void setLabel(const int id, std::string new_name);
void setLabel(const int id, irr::core::stringw new_name);
/** Returns the ID of the item, or -1 if not found */
int findItemNamed(const char* internalName);

View File

@ -210,7 +210,7 @@ void SpinnerWidget::setValue(const int new_value)
{
m_value = new_value;
if(m_graphical)
if (m_graphical)
{
std::ostringstream icon;
icon << file_manager->getDataDir() << "/" << m_properties[PROP_ICON];
@ -218,14 +218,14 @@ void SpinnerWidget::setValue(const int new_value)
//((IGUIButton*)(m_children[1].m_element))->setImage(GUIEngine::getDriver()->getTexture(imagefile));
((IGUIImage*)(m_children[1].m_element))->setImage(irr_driver->getTexture(imagefile));
}
else if(m_labels.size() > 0)
else if (m_labels.size() > 0)
{
m_children[1].m_element->setText( stringw(m_labels[new_value].c_str()).c_str() );
}
else if(m_properties[PROP_TEXT].size() > 0)
else if (m_text.size() > 0)
{
std::string text = StringUtils::insertValues(_(m_properties[PROP_TEXT].c_str()), m_value);
m_children[1].m_element->setText( stringw(text.c_str()).c_str() );
stringw text = StringUtils::insertValues(m_text.c_str(), m_value);
m_children[1].m_element->setText( text.c_str() );
}
else
{

View File

@ -29,7 +29,7 @@ void TextBoxWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
stringw text = m_properties[PROP_TEXT].c_str();
stringw& text = m_text;
m_element = GUIEngine::getGUIEnv()->addEditBox(text.c_str(), widget_size,
true /* border */, m_parent, getNewID());
id = m_element->getID();

View File

@ -28,9 +28,9 @@ using namespace irr;
// -----------------------------------------------------------------------------
std::string Input::getInputAsString(const Input::InputType type, const int id, const Input::AxisDirection dir)
irr::core::stringw Input::getInputAsString(const Input::InputType type, const int id, const Input::AxisDirection dir)
{
std::string s;
irr::core::stringw s;
switch (type)
{

View File

@ -21,6 +21,7 @@
#define HEADER_INPUT_HPP
#include <string>
#include <irrString.h>
const int DEADZONE_MOUSE = 150;
const int DEADZONE_MOUSE_SENSE = 200;
@ -88,7 +89,7 @@ struct Input
// Nothing to do.
}
static std::string getInputAsString(const Input::InputType type, const int id, const Input::AxisDirection dir=AD_NEUTRAL);
static irr::core::stringw getInputAsString(const Input::InputType type, const int id, const Input::AxisDirection dir=AD_NEUTRAL);
};

View File

@ -274,10 +274,10 @@ void ItemManager::setStyle()
}
catch(std::runtime_error)
{
fprintf(stderr, "The grand prix '%s' contains an invalid item style '%s'.\n",
fprintf(stderr, "The grand prix '%ls' contains an invalid item style '%s'.\n",
race_manager->getGrandPrix()->getName().c_str(),
race_manager->getItemStyle().c_str());
fprintf(stderr, "Please fix the file '%s'.\n",
fprintf(stderr, "Please fix the file 'l%s'.\n",
race_manager->getGrandPrix()->getFilename().c_str());
}
}
@ -289,7 +289,7 @@ void ItemManager::setStyle()
}
catch(std::runtime_error)
{
fprintf(stderr, "The track '%s' contains an invalid item style '%s'.\n",
fprintf(stderr, "The track '%ls' contains an invalid item style '%s'.\n",
RaceManager::getTrack()->getName().c_str(),
RaceManager::getTrack()->getItemStyle().c_str());
fprintf(stderr, "Please fix the file '%s'.\n",

View File

@ -271,7 +271,7 @@ public:
void updatedWeight ();
void forceRescue ();
void handleExplosion (const Vec3& pos, bool direct_hit);
const std::string& getName () const {return m_kart_properties->getName();}
const irr::core::stringw& getName() const {return m_kart_properties->getName();}
const std::string& getIdent () const {return m_kart_properties->getIdent();}
virtual bool isPlayerKart () const {return false; }
// addMessages gets called by world to add messages to the gui

View File

@ -32,6 +32,7 @@
//#include "lisp/lisp.hpp"
#include "io/xml_node.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
float KartProperties::UNDEFINED = -99.9f;
@ -203,7 +204,11 @@ void KartProperties::load(const std::string &filename, const std::string &node)
void KartProperties::getAllData(const XMLNode * root)
{
root->get("version", &m_version);
root->get("name", &m_name);
std::string temp_name;
root->get("name", &temp_name);
m_name = _(temp_name.c_str());
root->get("icon-file", &m_icon_file);
root->get("shadow-file", &m_shadow_file);
@ -333,7 +338,11 @@ void KartProperties::getAllData(const lisp::Lisp* lisp)
// Only load the kart_model data if the .kart file has the appropriate
if(m_version>=1)
m_kart_model.loadInfo(lisp);
lisp->get("name", m_name);
std::string temp_name;
lisp->get("name", temp_name);
m_name = _(temp_name.c_str());
lisp->get("icon-file", m_icon_file);
lisp->get("shadow-file", m_shadow_file);
Vec3 c;

View File

@ -62,7 +62,7 @@ private:
// Display and gui
// ---------------
std::string m_name; /**< The human readable Name of the kart
irr::core::stringw m_name; /**< The human readable Name of the kart
* driver. */
std::string m_ident; /**< The computer readable-name of the
* kart driver. */
@ -174,16 +174,16 @@ public:
void getAllData (const XMLNode * root);
void checkAllSet(const std::string &filename);
float getMaxSteerAngle (float speed) const;
Material* getIconMaterial () const {return m_icon_material; }
float getMaxSteerAngle (float speed) const;
Material* getIconMaterial () const {return m_icon_material; }
/** Returns a pointer to the KartModel object. */
KartModel* getKartModel () const {return &m_kart_model; }
const std::string& getName () const {return m_name; }
const std::string& getIdent () const {return m_ident; }
const std::string& getShadowFile() const {return m_shadow_file; }
const std::string& getIconFile () const {return m_icon_file; }
KartModel* getKartModel () const {return &m_kart_model; }
const irr::core::stringw& getName() const {return m_name; }
const std::string& getIdent () const {return m_ident; }
const std::string& getShadowFile () const {return m_shadow_file; }
const std::string& getIconFile () const {return m_icon_file; }
const int getCustomSfxId (SFXManager::CustomSFX type)
const {return m_custom_sfx_id[type]; }
const {return m_custom_sfx_id[type]; }
/** Returns the version of the .kart file. */
int getVersion () const {return m_version; }

View File

@ -107,7 +107,7 @@ namespace lisp
<< ": No string inside translation.";
throw std::runtime_error(msg.str());
}
const char* trans=_(next->m_v.m_string);
const char* trans = irr::core::stringc(_(next->m_v.m_string)).c_str();
const size_t LEN = strlen(trans) + 1;
result->m_v.m_string = new char[LEN];
memcpy(result->m_v.m_string, trans, LEN);

View File

@ -353,7 +353,7 @@ int handleCmdLine(int argc, char **argv)
const Track *track = track_manager->getTrack(i);
if (!unlock_manager->isLocked(track->getIdent()))
{
fprintf ( stdout, "\t%10s: %s\n",
fprintf ( stdout, "\t%10s: %ls\n",
track->getIdent().c_str(),
track->getName().c_str());
}
@ -367,7 +367,7 @@ int handleCmdLine(int argc, char **argv)
for (unsigned int i = 0; NULL != kart_properties_manager->getKartById(i); i++)
{
const KartProperties* KP= kart_properties_manager->getKartById(i);
fprintf (stdout, "\t%10s: %s\n", KP->getIdent().c_str(), KP->getName().c_str());
fprintf (stdout, "\t%10s: %ls\n", KP->getIdent().c_str(), KP->getName().c_str());
}
fprintf ( stdout, "\n" );
}

View File

@ -251,9 +251,11 @@ void LinearWorld::newLap(unsigned int kart_index)
2.0f, 40, video::SColor(255, 100, 210, 100));
std::string s = StringUtils::timeToString(time_per_lap);
std::ostringstream m_fastest_lap_message;
m_fastest_lap_message << s << ": " << kart->getName();
m_race_gui->addMessage(m_fastest_lap_message.str(), NULL,
irr::core::stringw m_fastest_lap_message;
m_fastest_lap_message += (s + ": ").c_str();
m_fastest_lap_message += kart->getName();
m_race_gui->addMessage(m_fastest_lap_message, NULL,
2.0f, 40, video::SColor(255, 100, 210, 100));
} // end if new fastest lap
}
@ -357,9 +359,9 @@ RaceGUI::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
raceHasLaps())
{ // Display for 5 seconds
std::string str;
if(position==1)
if(position == 1)
{
str = " "+StringUtils::timeToString(getTimeAtLapForKart(kart->getWorldKartId()));
str = " " + StringUtils::timeToString( getTimeAtLapForKart(kart->getWorldKartId()) );
}
else
{
@ -368,9 +370,9 @@ RaceGUI::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
? getTimeAtLapForKart(kart->getWorldKartId())
: getTime())
- time_of_leader;
str="+"+StringUtils::timeToString(timeBehind);
str = "+" + StringUtils::timeToString(timeBehind);
}
rank_info.time = str;
rank_info.time = irr::core::stringw(str.c_str());
}
else
{

View File

@ -445,8 +445,8 @@ void World::removeKart(int kart_number)
}
else
{
std::string s = _("'%s' has\nbeen eliminated.");
m_race_gui->addMessage(StringUtils::insertValues(s, kart->getName()),
irr::core::stringw s = _("'%s' has\nbeen eliminated.");
m_race_gui->addMessage(StringUtils::insertValues(s, kart->getName().c_str()), // FIXME : insertValues can't handle wide strings
*i, 2.0f, 60);
}
} // for i in kart

View File

@ -28,6 +28,7 @@
#include "lisp/lisp.hpp"
#include "tracks/track_manager.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
GrandPrixData::GrandPrixData(const std::string filename)
{
@ -45,7 +46,10 @@ GrandPrixData::GrandPrixData(const std::string filename)
throw std::runtime_error("No supertuxkart-grand-prix node");
}
lisp->get ("name", m_name );
std::string temp_name;
lisp->get ("name", temp_name );
m_name = _(temp_name.c_str());
lisp->get ("description", m_description );
lisp->get ("item", m_item_style);
lisp->getVector("tracks", m_tracks );
@ -72,7 +76,7 @@ bool GrandPrixData::checkConsistency()
catch(std::exception& e)
{
(void)e;
fprintf(stderr, "Grand Prix '%s': Track '%s' does not exist!\n",
fprintf(stderr, "Grand Prix '%ls': Track '%s' does not exist!\n",
m_name.c_str(), m_tracks[i].c_str());
fprintf(stderr, "This Grand Prix will not be available.\n");
return false;

View File

@ -24,12 +24,13 @@
#include <string>
#include <vector>
#include <cassert>
#include <irrString.h>
/** Simple class that hold the data relevant to a 'grand_prix', aka. a number
of races that has to be completed one after the other */
class GrandPrixData
{
std::string m_name; // The name of the grand prix - might be translated!
irr::core::stringw m_name; // The name of the grand prix - might be translated!
std::string m_id; // Internal name of the grand prix, not translated
std::string m_filename; // Original filename, only for error handling needed
std::string m_description; // Description for this track
@ -47,7 +48,7 @@ public:
/** Load the GrandPrixData from the given filename */
GrandPrixData (const std::string filename);
GrandPrixData () {}; // empty for initialising
const std::string& getName () const { return m_name; }
const irr::core::stringw& getName () const { return m_name; }
const std::string& getId () const { return m_id; }
const std::string& getDescription () const { return m_description; }
const std::string& getItemStyle () const { return m_item_style; }

View File

@ -104,7 +104,7 @@ void HighscoreManager::Load()
if (!node->get("file-version",v) || v<(int)CURRENT_HSCORE_FILE_VERSION)
{
fprintf(stderr, "Highscore file format too old, a new one will be created.\n");
std::string warning = _("The highscore file was too old,\nall highscores have been erased.");
irr::core::stringw warning = _("The highscore file was too old,\nall highscores have been erased.");
user_config->setWarning( warning );
// since we haven't had the chance to load the current scores yet,

View File

@ -35,7 +35,7 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
LabelWidget* widget = new LabelWidget();
//I18N: In the 'add new player' dialog
widget->m_properties[PROP_TEXT] = _("Enter the new player's name");
widget->m_text = _("Enter the new player's name");
widget->m_properties[PROP_TEXT_ALIGN] = "center";
widget->x = 0;
@ -55,7 +55,7 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
const int textAreaYFrom = m_area.getHeight()/2 - textHeight/2;
textCtrl = new TextBoxWidget();
textCtrl->m_properties[PROP_TEXT] = "";
textCtrl->m_text = "";
textCtrl->x = 50;
textCtrl->y = textAreaYFrom - 10;
textCtrl->w = m_area.getWidth()-100;
@ -69,7 +69,7 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
cancelButton = new ButtonWidget();
cancelButton->m_properties[PROP_ID] = "cancel";
cancelButton->m_properties[PROP_TEXT] = _("Cancel");
cancelButton->m_text = _("Cancel");
cancelButton->x = 15;
cancelButton->y = m_area.getHeight() - textHeight - 12;
cancelButton->w = m_area.getWidth() - 30;

View File

@ -21,6 +21,7 @@
#include "guiengine/widget.hpp"
#include "states_screens/options_screen.hpp"
#include "states_screens/dialogs/player_info_dialog.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
using namespace GUIEngine;
@ -48,7 +49,7 @@ void PlayerInfoDialog::showRegularDialog()
{
textCtrl = new TextBoxWidget();
textCtrl->m_properties[PROP_ID] = "renameplayer";
textCtrl->m_properties[PROP_TEXT] = m_player->getName();
textCtrl->m_text = m_player->getName();
textCtrl->x = 50;
textCtrl->y = y1 - textHeight/2;
textCtrl->w = m_area.getWidth()-100;
@ -62,10 +63,11 @@ void PlayerInfoDialog::showRegularDialog()
{
ButtonWidget* widget = new ButtonWidget();
widget->m_properties[PROP_ID] = "renameplayer";
//I18N: In the player info dialog
widget->m_properties[PROP_TEXT] = _("Rename");
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
//I18N: In the player info dialog
widget->m_text = _("Rename");
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y2;
@ -78,9 +80,9 @@ void PlayerInfoDialog::showRegularDialog()
{
ButtonWidget* widget = new ButtonWidget();
widget->m_properties[PROP_ID] = "cancel";
widget->m_properties[PROP_TEXT] = _("Cancel");
widget->m_text = _("Cancel");
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y3;
@ -96,9 +98,9 @@ void PlayerInfoDialog::showRegularDialog()
widget->m_properties[PROP_ID] = "removeplayer";
//I18N: In the player info dialog
widget->m_properties[PROP_TEXT] = _("Remove");
widget->m_text = _("Remove");
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y4;
@ -121,12 +123,12 @@ void PlayerInfoDialog::showConfirmDialog()
const int buttonHeight = textHeight + 10;
char message[256];
//I18N: In the player info dialog (when deleting)
sprintf(message, _("Do you really want to delete player '%s' ?"), m_player->getName());
irr::core::stringw message =
//I18N: In the player info dialog (when deleting)
StringUtils::insertValues( _("Do you really want to delete player '%s' ?"), m_player->getName());
core::rect< s32 > area_left(5, 0, m_area.getWidth()-5, m_area.getHeight()/2);
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( stringw(message).c_str(),
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( message.c_str(),
area_left, false /* border */, true /* word wrap */,
m_irrlicht_window);
a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
@ -134,10 +136,11 @@ void PlayerInfoDialog::showConfirmDialog()
{
ButtonWidget* widget = new ButtonWidget();
widget->m_properties[PROP_ID] = "confirmremove";
//I18N: In the player info dialog (when deleting)
widget->m_properties[PROP_TEXT] = _("Confirm Remove");
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
//I18N: In the player info dialog (when deleting)
widget->m_text = _("Confirm Remove");
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = m_area.getHeight()/2;
@ -151,10 +154,11 @@ void PlayerInfoDialog::showConfirmDialog()
{
ButtonWidget* widget = new ButtonWidget();
widget->m_properties[PROP_ID] = "cancelremove";
//I18N: In the player info dialog (when deleting)
widget->m_properties[PROP_TEXT] = _("Cancel Remove");
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
//I18N: In the player info dialog (when deleting)
widget->m_text = _("Cancel Remove");
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = m_area.getHeight()*3/4;

View File

@ -28,7 +28,7 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
ModalDialog(w, h)
{
LabelWidget* widget = new LabelWidget();
widget->m_properties[PROP_TEXT] = _("Press a key");
widget->m_text = _("Press a key");
widget->m_properties[PROP_TEXT_ALIGN] = "center";
widget->x = 0;
widget->y = 0;
@ -45,7 +45,7 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
ButtonWidget* widget2 = new ButtonWidget();
widget2->m_properties[PROP_ID] = "cancel";
widget2->m_properties[PROP_TEXT] = _("Press ESC to cancel");
widget2->m_text = _("Press ESC to cancel");
widget2->x = 15;
widget2->y = m_area.getHeight() - textHeight - 12;
widget2->w = m_area.getWidth() - 30;

View File

@ -28,6 +28,7 @@
#include "states_screens/state_manager.hpp"
#include "tracks/track.hpp"
#include "tracks/track_manager.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
#include "irrlicht.h"
@ -36,7 +37,8 @@ using namespace irr::gui;
using namespace GUIEngine;
TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trackName, ITexture* screenshot, const float w, const float h) : ModalDialog(w, h)
TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core::stringw& trackName,
ITexture* screenshot, const float w, const float h) : ModalDialog(w, h)
{
const int y1 = m_area.getHeight()/7;
const int y2 = m_area.getHeight()*5/7;
@ -54,7 +56,9 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac
spinner->m_properties[PROP_MIN_VALUE] = "1";
spinner->m_properties[PROP_MAX_VALUE] = "99";
spinner->m_properties[PROP_TEXT] = "%i laps";
//I18N: In the track setup screen (number of laps choice, where %i is the number)
spinner->m_text = _("%i laps");
m_children.push_back(spinner);
spinner->add();
@ -65,7 +69,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac
// ---- Start button
ButtonWidget* okBtn = new ButtonWidget();
okBtn->m_properties[PROP_ID] = "start";
okBtn->m_properties[PROP_TEXT] = _("Start Race");
okBtn->m_text = _("Start Race");
okBtn->x = m_area.getWidth()/2 - 200;
okBtn->y = y3;
okBtn->w = 400;
@ -80,9 +84,9 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac
// ---- Track title
core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1);
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( stringw(trackName).c_str(),
area_top, false, true, // border, word warp
m_irrlicht_window);
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( trackName.c_str(),
area_top, false, true, // border, word warp
m_irrlicht_window);
a->setTabStop(false);
// ---- High Scores & track info
@ -115,8 +119,6 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac
std::string name;
float time;
char buffer[128];
// fill highscore entries
for (int n=0; n<HIGHSCORE_COUNT; n++)
{
@ -135,9 +137,13 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac
core::rect< s32 > entry_area(icon_size + 10, from_y, m_area.getWidth()/2, next_from_y);
irr::core::stringw line;
// Check if this entry is filled or still empty
if (n < amount)
{
char buffer[256];
highscores->getEntry(n, kart_name, name, &time);
sprintf(buffer, "%s : %.2f s\n", name.c_str(), time);
@ -149,15 +155,16 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
m_kart_icons[n]->setImage(kart_icon_texture);
}
line = buffer;
}
else
{
//I18N: for empty highscores entries
sprintf(buffer, "%s\n", _("(Empty)"));
line = _("(Empty)");
line += "\n";
}
text = buffer;
m_highscore_entries[n] = GUIEngine::getGUIEnv()->addStaticText( text.c_str(), entry_area,
m_highscore_entries[n] = GUIEngine::getGUIEnv()->addStaticText( line.c_str(), entry_area,
false , true , // border, word warp
m_irrlicht_window);
@ -168,8 +175,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac
core::rect< s32 > creator_info_area(0, hscores_y_to, m_area.getWidth()/2, y2);
//I18N: when showing who is the author of track '%s' (place %s where the name of the author should appear)
sprintf(buffer, _("Track by %s"), track->getDesigner().c_str());
text = buffer;
text = StringUtils::insertValues(_("Track by %s"), track->getDesigner().c_str());
IGUIStaticText* b = GUIEngine::getGUIEnv()->addStaticText( text.c_str(),
creator_info_area, false , true , // border, word warp

View File

@ -35,7 +35,8 @@ public:
/**
* Creates a modal dialog with given percentage of screen width and height
*/
TrackInfoDialog(const std::string& trackIdent, const char* trackName, irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight);
TrackInfoDialog(const std::string& trackIdent, const irr::core::stringw& trackName,
irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight);
void onEnterPressedInternal();
void processEvent(std::string& eventSource);
};

View File

@ -115,7 +115,7 @@ namespace KartSelectionScreen
playerIDLabel = new LabelWidget();
playerIDLabel->m_properties[PROP_TEXT] =
playerIDLabel->m_text =
//I18N: In kart selection screen (Will read like 'Player 1 (foobartech gamepad)')
StringUtils::insertValues(_("Player %i (%s)"), playerID + 1, deviceName.c_str());
@ -158,7 +158,8 @@ namespace KartSelectionScreen
// Init kart model
std::string& default_kart = UserConfigParams::m_default_kart;
KartModel* kartModel = kart_properties_manager->getKart(default_kart)->getKartModel();
const KartProperties* props = kart_properties_manager->getKart(default_kart);
KartModel* kartModel = props->getKartModel();
this->modelView->addModel( kartModel->getModel() );
this->modelView->addModel( kartModel->getWheelModel(0), kartModel->getWheelGraphicsPosition(0) );
@ -167,7 +168,7 @@ namespace KartSelectionScreen
this->modelView->addModel( kartModel->getWheelModel(3), kartModel->getWheelGraphicsPosition(3) );
kartName = new LabelWidget();
kartName->m_properties[PROP_TEXT] = default_kart;
kartName->m_text = props->getName();
kartName->m_properties[PROP_TEXT_ALIGN] = "center";
kartName->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_kartname", playerID);
kartName->x = kart_name_x;
@ -207,8 +208,8 @@ namespace KartSelectionScreen
playerID = newPlayerID;
//I18N: In kart selection screen (Will read like 'Player 1 (foobartech gamepad)')
std::string newLabel = StringUtils::insertValues(_("Player %i (%s)"), playerID + 1, deviceName.c_str());
playerIDLabel->setText( newLabel.c_str() );
irr::core::stringw newLabel = StringUtils::insertValues(_("Player %i (%s)"), playerID + 1, deviceName.c_str());
playerIDLabel->setText( newLabel );
playerIDLabel->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_label", playerID);
}
@ -414,7 +415,7 @@ class KartHoverListener : public DynamicRibbonHoverListener
{
public:
void onSelectionChanged(DynamicRibbonWidget* theWidget, const std::string& selectionID,
const std::string& selectionText, const int playerID)
const irr::core::stringw& selectionText, const int playerID)
{
ModelViewWidget* w3 = g_player_karts[playerID].modelView;
assert( w3 != NULL );
@ -633,7 +634,7 @@ void menuEventKarts(Widget* widget, const std::string& name)
{
std::string icon_path = file_manager->getDataDir() ;
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str());
w->addItem(prop->getName(), prop->getIdent().c_str(), icon_path.c_str());
break;
}
}
@ -646,7 +647,7 @@ void menuEventKarts(Widget* widget, const std::string& name)
{
std::string icon_path = file_manager->getDataDir() ;
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str());
w->addItem(prop->getName(), prop->getIdent().c_str(), icon_path.c_str());
}
}

View File

@ -35,6 +35,7 @@
#include <iostream>
#include <sstream>
using namespace GUIEngine;
@ -235,39 +236,39 @@ namespace OptionsScreen
{
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_up");
btn->setLabel( config->getBindingAsString(PA_ACCEL).c_str() );
btn->setLabel( config->getBindingAsString(PA_ACCEL) );
}
{
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_down");
btn->setLabel( config->getBindingAsString(PA_BRAKE).c_str() );
btn->setLabel( config->getBindingAsString(PA_BRAKE) );
}
{
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_left");
btn->setLabel( config->getBindingAsString(PA_LEFT).c_str() );
btn->setLabel( config->getBindingAsString(PA_LEFT) );
}
{
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_right");
btn->setLabel( config->getBindingAsString(PA_RIGHT).c_str() );
btn->setLabel( config->getBindingAsString(PA_RIGHT) );
}
{
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_fire");
btn->setLabel( config->getBindingAsString(PA_FIRE).c_str() );
btn->setLabel( config->getBindingAsString(PA_FIRE) );
}
{
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_nitro");
btn->setLabel( config->getBindingAsString(PA_NITRO).c_str() );
btn->setLabel( config->getBindingAsString(PA_NITRO) );
}
{
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_drift");
btn->setLabel( config->getBindingAsString(PA_DRIFT).c_str() );
btn->setLabel( config->getBindingAsString(PA_DRIFT) );
}
{
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_rescue");
btn->setLabel( config->getBindingAsString(PA_RESCUE).c_str() );
btn->setLabel( config->getBindingAsString(PA_RESCUE) );
}
{
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_look_back");
btn->setLabel( config->getBindingAsString(PA_LOOK_BACK).c_str() );
btn->setLabel( config->getBindingAsString(PA_LOOK_BACK) );
}
}
@ -290,10 +291,14 @@ namespace OptionsScreen
// Don't display the configuration if a matching device is not available
if (config->isInUse())
{
std::string name = config->getName();
char internal_name[32];
sprintf(internal_name, "gamepad%i", i);
devices->addItem(name,internal_name, file_manager->getDataDir() + "/gui/gamepad.png");
const irr::core::stringw name = config->getName().c_str();
std::ostringstream gpname;
gpname << "gamepad" << i;
const std::string internal_name = gpname.str();
const std::string iconpath = file_manager->getDataDir() + "/gui/gamepad.png";
devices->addItem(name, internal_name, iconpath);
}
}

View File

@ -264,7 +264,7 @@ void RaceGUI::drawPlayerIcons (const KartIconDisplayInfo* info)
y = 20 + ( (position == -1 ? i : position-1)*(ICON_PLAYER_WIDTH+2));
if(info[i].time.length()>0)
if (info[i].time.size() > 0)
{
static video::SColor color = video::SColor(255, (int)(255*info[i].r),
(int)(255*info[i].g),
@ -274,7 +274,7 @@ void RaceGUI::drawPlayerIcons (const KartIconDisplayInfo* info)
font->draw(s.c_str(), pos, color);
}
if(info[i].special_title.length() >0)
if (info[i].special_title.size() > 0)
{
static video::SColor color = video::SColor(255, 255, 0, 0);
core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5, x+ICON_PLAYER_WIDTH, y+5);
@ -561,7 +561,7 @@ void RaceGUI::drawAllMessages(Kart* player_kart, int offset_x, int offset_y,
* certain amount of time (unless time<0, then the message is displayed
* once).
**/
void RaceGUI::addMessage(const std::string &msg, const Kart *kart, float time,
void RaceGUI::addMessage(const irr::core::stringw &msg, const Kart *kart, float time,
int font_size, const video::SColor &color)
{
m_messages.push_back(TimedMessage(msg, kart, time, font_size, color));

View File

@ -45,9 +45,9 @@ public:
*/
struct KartIconDisplayInfo
{
std::string time;
irr::core::stringw time;
float r, g, b;
std::string special_title;
irr::core::stringw special_title;
/** Current lap of this kart, or -1 if irrelevant
*/
int lap;
@ -57,16 +57,16 @@ private:
class TimedMessage
{
public:
std::string m_message; // message to display
float m_remaining_time; // time remaining before removing this message from screen
video::SColor m_color; // color of message
int m_font_size; // size
const Kart *m_kart;
irr::core::stringw m_message; // message to display
float m_remaining_time; // time remaining before removing this message from screen
video::SColor m_color; // color of message
int m_font_size; // size
const Kart *m_kart;
// -----------------------------------------------------
// std::vector needs standard copy-ctor and std-assignment op.
// let compiler create defaults .. they'll do the job, no
// deep copies here ..
TimedMessage(const std::string &message,
TimedMessage(const irr::core::stringw &message,
const Kart *kart, float time, int size,
const video::SColor &color)
{
@ -166,7 +166,7 @@ public:
void render();
void update(float dt);
Camera *addCamera(unsigned int index, Kart *kart);
void addMessage(const std::string &m, const Kart *kart, float time,
void addMessage(const irr::core::stringw &m, const Kart *kart, float time,
int fonst_size,
const video::SColor &color=video::SColor(255, 255, 0, 255));

View File

@ -50,6 +50,7 @@ using namespace irr;
#include "tracks/quad_graph.hpp"
#include "tracks/quad_set.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
const float Track::NOHIT = -99999.9f;
@ -211,7 +212,10 @@ void Track::loadTrackInfo(const std::string &filename)
o<<"Can't load track '"<<filename<<"', no track element.";
throw std::runtime_error(o.str());
}
root->get("name", &m_name);
std::string temp_name;
root->get("name", &temp_name);
m_name = _(temp_name.c_str());
root->get("description", &m_description);
root->get("designer", &m_designer);
root->get("version", &m_version);

View File

@ -108,17 +108,17 @@ private:
/** If a sky dome is used, percentage of the texture to be used. */
float m_sky_texture_percent;
std::string m_name;
bool m_use_fog;
float m_fog_density;
float m_fog_start;
float m_fog_end;
core::vector3df m_sun_position;
video::SColorf m_ambient_color;
video::SColorf m_specular_color;
video::SColorf m_diffuse_color;
video::SColorf m_sky_color;
video::SColor m_fog_color;
irr::core::stringw m_name;
bool m_use_fog;
float m_fog_density;
float m_fog_start;
float m_fog_end;
core::vector3df m_sun_position;
video::SColorf m_ambient_color;
video::SColorf m_specular_color;
video::SColorf m_diffuse_color;
video::SColorf m_sky_color;
video::SColor m_fog_color;
/** The texture for the mini map, which is displayed in the race gui. */
video::ITexture *m_mini_map;
@ -173,8 +173,7 @@ public:
const std::string& getIdent () const {return m_ident; }
/** Returns the name of the track, which is e.g. displayed on the screen. */
const std::string& getName () const {return m_name; }
const irr::core::stringw& getName () const {return m_name; }
/** Returns all groups this track belongs to. */
const std::vector<std::string>

View File

@ -137,6 +137,31 @@ namespace StringUtils
return result;
} // split
/** Same as above, but for wide strings */
std::vector<irr::core::stringw> split(const irr::core::stringw& s, char c)
{
std::vector<irr::core::stringw> result;
irr::s32 start = 0;
while (start < (irr::s32)s.size())
{
irr::s32 i = s.findNext(c, start);
if (i != -1)
{
result.push_back( s.subString(start, i-start) );
start = i+1;
}
else
{
result.push_back( s.subString(start, s.size()-start) );
return result;
//start = i+1;
}
}
return result;
} // split
// ------------------------------------------------------------------------
/** Splits a : separated string (like PATH) into its individual components.
* It especially handles Windows-style paths (c:/mydir1:d:/mydir2)

View File

@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <sstream>
#include <irrString.h>
namespace StringUtils
{
@ -78,6 +79,8 @@ namespace StringUtils
std::vector<std::string> split(const std::string& s, char c);
std::vector<std::string> splitPath(const std::string& path);
std::vector<irr::core::stringw> split(const irr::core::stringw& s, char c);
// ------------------------------------------------------------------------
/** Replaces the first %s or %d in the string with the first value
* converted to a string), the 2nd %s or %d with the second value etc.
@ -145,6 +148,93 @@ namespace StringUtils
{
return insertValues(s, v1, "", "");
}
/** Like the other one above but for wide strings */
template <class T1, class T2, class T3>
irr::core::stringw insertValues(const irr::core::stringw &s, const T1 &v1,
const T2 &v2, const T3 &v3)
{
std::vector<std::string> all_vals;
std::ostringstream dummy;
dummy<<v1; all_vals.push_back(dummy.str()); dummy.str("");
dummy<<v2; all_vals.push_back(dummy.str()); dummy.str("");
dummy<<v3; all_vals.push_back(dummy.str());
std::vector<irr::core::stringw> sv = StringUtils::split(s, '%');
irr::core::stringw new_string="";
for (unsigned int i=0; i<sv.size(); i++)
{
if (sv[i][0]=='s' || sv[i][0]=='d' || sv[i][0]=='i')
{
new_string += all_vals[0].c_str();
new_string += sv[i].subString(1, sv[i].size()-1);
all_vals.erase(all_vals.begin());
}
else
new_string+=sv[i];
}
return new_string;
}
template <class T1, class T2>
irr::core::stringw insertValues(const irr::core::stringw &s, const T1 &v1,
const T2 &v2)
{
return insertValues(s, v1, v2, "");
}
template <class T1>
irr::core::stringw insertValues(const irr::core::stringw &s, const T1 &v1)
{
return insertValues(s, v1, "", "");
}
template <class T1, class T2, class T3>
irr::core::stringw insertValues(const wchar_t* chars, const T1 &v1,
const T2 &v2, const T3 &v3)
{
irr::core::stringw s(chars);
return insertValues(s, v1, v2, v3);
}
template <class T1, class T2>
irr::core::stringw insertValues(const wchar_t* chars, const T1 &v1,
const T2 &v2)
{
irr::core::stringw s(chars);
return insertValues(s, v1, v2, "");
}
template <class T1>
irr::core::stringw insertValues(const wchar_t* chars, const T1 &v1)
{
irr::core::stringw s(chars);
return insertValues(s, v1, "", "");
}
template <class T1, class T2, class T3>
std::string insertValues(const char* chars, const T1 &v1,
const T2 &v2, const T3 &v3)
{
std::string s(chars);
return insertValues(s, v1, v2, v3);
}
template <class T1, class T2>
std::string insertValues(const char* chars, const T1 &v1,
const T2 &v2)
{
std::string s(chars);
return insertValues(s, v1, v2, "");
}
template <class T1>
std::string insertValues(const char* chars, const T1 &v1)
{
std::string s(chars);
return insertValues(s, v1, "", "");
}
} // namespace StringUtils
#endif

View File

@ -44,7 +44,8 @@ Translations::Translations() {
#endif
bindtextdomain (PACKAGE, file_manager->getTranslationDir().c_str());
textdomain (PACKAGE);
bind_textdomain_codeset(PACKAGE, "iso-8859-1");
printf("gettext codeset : %s \n", bind_textdomain_codeset(PACKAGE, "UTF-16"));
#endif
} // Translations

View File

@ -28,7 +28,7 @@
# include <libintl.h>
#endif
# define _(String) gettext(String)
# define _(String) (wchar_t*)gettext(String)
# define gettext_noop(String) String
# define N_(String) gettext_noop (String)
// libintl defines its own fprintf, which doesn't work for me :(
@ -36,7 +36,7 @@
# undef fprintf
# endif
#else
# define _(String) (String)
# define _(String) (L##String)
# define gettext_noop(String) String
# define N_(String) String
#endif