Show "Fribidized" user name and enable input for it

This commit is contained in:
Benau 2015-12-14 02:56:42 +08:00
parent f0abbad937
commit 7fccddb734
6 changed files with 47 additions and 32 deletions

View File

@ -269,7 +269,7 @@ void PlayerManager::save()
if(m_current_player)
{
players_file << L" <current player=\""
<< StringUtils::xmlEncode(m_current_player->getName()) << L"\"/>\n";
<< StringUtils::xmlEncode(m_current_player->getName(true/*ignoreRTL*/)) << L"\"/>\n";
}
// Save all non-guest players
@ -327,7 +327,7 @@ void PlayerManager::enforceCurrentPlayer()
if (!player->isGuestAccount())
{
Log::info("PlayerManager", "Enforcing current player '%ls'.",
player->getName().c_str() );
player->getName(true/*ignoreRTL*/).c_str());
m_current_player = player;
return;
}
@ -341,7 +341,7 @@ void PlayerManager::enforceCurrentPlayer()
if (!player->isGuestAccount())
{
Log::info("PlayerManager", "Enforcing current player '%s'.",
player->getName().c_str());
player->getName(true/*ignoreRTL*/).c_str());
m_current_player = player;
return;
}
@ -454,7 +454,7 @@ PlayerProfile *PlayerManager::getPlayer(const irr::core::stringw &name)
{
for (PlayerProfile* player : m_all_players)
{
if(player->getName()==name)
if(player->getName(true/*ignoreRTL*/)==name)
return player;
}
return NULL;

View File

@ -24,6 +24,7 @@
#include "utils/leak_check.hpp"
#include "utils/no_copy.hpp"
#include "utils/types.hpp"
#include "utils/translation.hpp"
#include <irrString.h>
using namespace irr;
@ -154,10 +155,17 @@ public:
// ------------------------------------------------------------------------
/** Returns the name of this player. */
core::stringw getName() const
const core::stringw getName(bool ignore_rtl = false) const
{
assert(m_magic_number == 0xABCD1234);
return m_local_name.c_str();
if (ignore_rtl)
return m_local_name;
else
{
const core::stringw fribidized_name =
translations->fribidize(m_local_name);
return fribidized_name;
}
} // getName
// ------------------------------------------------------------------------
@ -171,9 +179,16 @@ public:
} // isGuestAccount
// ------------------------------------------------------------------------
/** Returns the last used online name. */
const core::stringw& getLastOnlineName() const
const core::stringw getLastOnlineName(bool ignore_rtl = false) const
{
return m_last_online_name;
if (ignore_rtl)
return m_last_online_name;
else
{
const core::stringw fribidized_name =
translations->fribidize(m_last_online_name);
return fribidized_name;
}
} // getLastOnlineName
// ------------------------------------------------------------------------
/** Sets the last used online name. */

View File

@ -24,6 +24,7 @@
double click/ctrl click: word select + drag to select whole words, triple click to select line
optional? dragging selected text
numerical
correct the mark position in RTL text, currently you can identify by highlight the text
*/
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
@ -53,7 +54,11 @@ CGUIEditBox::CGUIEditBox(const wchar_t* text, bool border,
PasswordChar(L'*'), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER),
CurrentTextRect(0,0,1,1), FrameRect(rectangle)
{
m_rtl = is_rtl;
//m_rtl = is_rtl;
m_rtl = false;
// FIXME quick hack to enable mark movement with keyboard and mouse for rtl language,
// don't know why it's disabled in the first place, because STK fail
// to input unicode characters before?
#ifdef _DEBUG
setDebugName("CGUIEditBox");
@ -985,20 +990,12 @@ void CGUIEditBox::draw()
startPos = ml ? BrokenTextPositions[i] : 0;
}
if (m_rtl)
{
font->draw(translations->fribidize(txtLine->c_str()), CurrentTextRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
false, true, &localClipRect);
}
else
{
// draw normal text
font->draw(txtLine->c_str(), CurrentTextRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
false, true, &localClipRect);
}
font->draw(translations->fribidize(txtLine->c_str()), CurrentTextRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
false, true, &localClipRect);
// draw with fribidize no matter what language, because in fribidize function,
// it will return the input pointer if (this->isRTLLanguage()) from Translations::isRTLText
// is false
// draw mark and marked text
if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount)

View File

@ -153,7 +153,8 @@ namespace Online
PlayerProfile *player = PlayerManager::get()->getPlayer(i);
if(player != current &&
player->hasSavedSession() &&
player->getLastOnlineName() == current->getLastOnlineName())
player->getLastOnlineName(true/*ignoreRTL*/) ==
current->getLastOnlineName(true/*ignoreRTL*/))
{
player->clearSession();
}

View File

@ -84,7 +84,7 @@ void RegisterScreen::init()
stringw username = "";
if(m_existing_player)
{
username = m_existing_player->getName();
username = m_existing_player->getName(true/*ignoreRTL*/);
}
else if (PlayerManager::get()->getNumPlayers() == 0)
{

View File

@ -198,7 +198,7 @@ void BaseUserScreen::selectUser(int index)
focus_it);
if (!m_new_registered_data)
m_username_tb->setText(profile->getLastOnlineName());
m_username_tb->setText(profile->getLastOnlineName(true/*ignoreRTL*/));
if (!m_new_registered_data)
{
@ -401,16 +401,18 @@ void BaseUserScreen::login()
// If a different player is connecting, or the same local player with
// a different online account, log out the current player.
if(current && current->isLoggedIn() &&
(player!=current || current->getLastOnlineName()!=new_username) )
(player!=current ||
current->getLastOnlineName(true/*ignoreRTL*/)!=new_username) )
{
m_sign_out_name = current->getLastOnlineName();
m_sign_out_name = current->getLastOnlineName(true/*ignoreRTL*/);
current->requestSignOut();
m_state = (UserScreenState)(m_state | STATE_LOGOUT);
// If the online user name was changed, reset the save data
// for this user (otherwise later the saved session will be
// resumed, not logging the user with the new account).
if(player==current && current->getLastOnlineName()!=new_username)
if(player==current &&
current->getLastOnlineName(true/*ignoreRTL*/)!=new_username)
current->clearSession();
}
PlayerManager::get()->setCurrentPlayer(player);
@ -422,7 +424,7 @@ void BaseUserScreen::login()
{
if(player->isLoggedIn())
{
m_sign_out_name =player->getLastOnlineName();
m_sign_out_name =player->getLastOnlineName(true/*ignoreRTL*/);
player->requestSignOut();
m_state =(UserScreenState)(m_state| STATE_LOGOUT);
}
@ -449,7 +451,7 @@ void BaseUserScreen::login()
// can decide what to do about them.
if (player->hasSavedSession())
{
m_sign_in_name = player->getLastOnlineName();
m_sign_in_name = player->getLastOnlineName(true/*ignoreRTL*/);
// Online login with saved token
player->requestSavedSession();
}
@ -569,7 +571,7 @@ void BaseUserScreen::deletePlayer()
PlayerProfile *player = getSelectedPlayer();
irr::core::stringw message =
//I18N: In the player info dialog (when deleting)
_("Do you really want to delete player '%s' ?", player->getName());
_("Do you really want to delete player '%s' ?", player->getName(true/*ignoreRTL*/));
class ConfirmServer : public MessageDialog::IConfirmDialogListener
{