Files
BluTac10-Xbox_Neo/Minecraft.Client/Common/XUI/XUI_Chat.cpp
Revela e786604228 Add Arabic text shaping support for chat functionality
This commit introduces Arabic text shaping in the chat application by adding `ArabicShaping.cpp` and `ArabicShaping.h` for handling contextual forms and visual reordering.

The rendering logic in `ChatScreen.cpp` is updated to utilize this new functionality, adjusting cursor positions accordingly. Other UI components, including `UIControl_Base.cpp`, `UIControl_Label.cpp`, and `UIControl_SaveList.cpp`, are modified to ensure proper display of Arabic text.

Additionally, `Font.cpp` is enhanced with methods for efficient rendering of pre-shaped text.
2026-03-17 17:08:58 -05:00

73 lines
1.8 KiB
C++

#include "stdafx.h"
#include "XUI_Chat.h"
#include "..\..\Minecraft.h"
#include "..\..\Gui.h"
#include "..\..\..\Minecraft.World\ArabicShaping.h"
HRESULT CScene_Chat::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad = *static_cast<int *>(pInitData->pvInitData);
MapChildControls();
this->SetTimer(0,100);
XuiElementGetPosition(m_hObj,&m_OriginalPosition);
return S_OK;
}
HRESULT CScene_Chat::OnTimer( XUIMessageTimer *pXUIMessageTimer, BOOL &bHandled)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
Gui *pGui = pMinecraft->gui;
//DWORD messagesToDisplay = min( CHAT_LINES_COUNT, pGui->getMessagesCount(m_iPad) );
for( unsigned int i = 0; i < CHAT_LINES_COUNT; ++i )
{
float opacity = pGui->getOpacity(m_iPad, i);
if( opacity > 0 )
{
m_Backgrounds[i].SetOpacity(opacity);
m_Labels[i].SetOpacity(opacity);
wstring shaped = shapeArabicText(pGui->getMessage(m_iPad, i));
m_Labels[i].SetText( shaped.c_str() );
}
else
{
m_Backgrounds[i].SetOpacity(0);
m_Labels[i].SetOpacity(0);
}
}
if(pMinecraft->localplayers[m_iPad]!= nullptr)
{
m_Jukebox.SetText( pGui->getJukeboxMessage(m_iPad).c_str() );
m_Jukebox.SetOpacity( pGui->getJukeboxOpacity(m_iPad) );
}
return S_OK;
}
HRESULT CScene_Chat::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
bHandled=true;
app.ReloadChatScene(m_iPad, bJoining);
return S_OK;
}
HRESULT CScene_Chat::OffsetTextPosition( float xOffset, float yOffset /*= 0.0f*/ )
{
D3DXVECTOR3 vPos;
float fWidth, fHeight;
XuiElementGetBounds( m_Backgrounds[0], &fWidth, &fHeight );
for(unsigned int i = 0; i < CHAT_LINES_COUNT; ++i)
{
XuiElementGetPosition( m_Labels[i], &vPos );
vPos.x = xOffset;
vPos.y += yOffset;
XuiElementSetPosition( m_Labels[i], &vPos );
XuiElementSetBounds( m_Labels[i], fWidth - xOffset, fHeight );
}
return S_OK;
}