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

View File

@ -24,6 +24,7 @@
#include "utils/leak_check.hpp" #include "utils/leak_check.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
#include "utils/types.hpp" #include "utils/types.hpp"
#include "utils/translation.hpp"
#include <irrString.h> #include <irrString.h>
using namespace irr; using namespace irr;
@ -154,10 +155,17 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the name of this player. */ /** Returns the name of this player. */
core::stringw getName() const const core::stringw getName(bool ignore_rtl = false) const
{ {
assert(m_magic_number == 0xABCD1234); 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 } // getName
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -171,9 +179,16 @@ public:
} // isGuestAccount } // isGuestAccount
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the last used online name. */ /** Returns the last used online name. */
const core::stringw& getLastOnlineName() const const core::stringw getLastOnlineName(bool ignore_rtl = false) const
{ {
if (ignore_rtl)
return m_last_online_name; return m_last_online_name;
else
{
const core::stringw fribidized_name =
translations->fribidize(m_last_online_name);
return fribidized_name;
}
} // getLastOnlineName } // getLastOnlineName
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the last used online name. */ /** 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 double click/ctrl click: word select + drag to select whole words, triple click to select line
optional? dragging selected text optional? dragging selected text
numerical numerical
correct the mark position in RTL text, currently you can identify by highlight the text
*/ */
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) #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), PasswordChar(L'*'), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER),
CurrentTextRect(0,0,1,1), FrameRect(rectangle) 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 #ifdef _DEBUG
setDebugName("CGUIEditBox"); setDebugName("CGUIEditBox");
@ -985,20 +990,12 @@ void CGUIEditBox::draw()
startPos = ml ? BrokenTextPositions[i] : 0; startPos = ml ? BrokenTextPositions[i] : 0;
} }
if (m_rtl)
{
font->draw(translations->fribidize(txtLine->c_str()), CurrentTextRect, font->draw(translations->fribidize(txtLine->c_str()), CurrentTextRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
false, true, &localClipRect); false, true, &localClipRect);
} // draw with fribidize no matter what language, because in fribidize function,
else // it will return the input pointer if (this->isRTLLanguage()) from Translations::isRTLText
{ // is false
// draw normal text
font->draw(txtLine->c_str(), CurrentTextRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
false, true, &localClipRect);
}
// draw mark and marked text // draw mark and marked text
if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount) if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount)

View File

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

View File

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

View File

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