forked from metin-server/m2dev-client-src
Various fixes and improvements
This commit is contained in:
@@ -793,10 +793,22 @@ void CGraphicTextInstance::Render(RECT * pClipRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- Selection background (Ctrl+A / shift-select) ---
|
// --- Selection background (Ctrl+A / shift-select) ---
|
||||||
if (m_isCursor && CIME::ms_bCaptureInput)
|
// MR-15: Expose text selection highlighting to Python
|
||||||
{
|
{
|
||||||
int selBegin = CIME::GetSelBegin();
|
// Determine selection range: IME state for active input fields, local state otherwise
|
||||||
int selEnd = CIME::GetSelEnd();
|
int selBegin, selEnd;
|
||||||
|
|
||||||
|
if (m_isCursor && CIME::ms_bCaptureInput)
|
||||||
|
{
|
||||||
|
selBegin = CIME::GetSelBegin();
|
||||||
|
selEnd = CIME::GetSelEnd();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
selBegin = m_selStart;
|
||||||
|
selEnd = m_selEnd;
|
||||||
|
}
|
||||||
|
// MR-15: -- END OF -- Expose text selection highlighting to Python
|
||||||
|
|
||||||
if (selBegin > selEnd) std::swap(selBegin, selEnd);
|
if (selBegin > selEnd) std::swap(selBegin, selEnd);
|
||||||
|
|
||||||
@@ -818,18 +830,39 @@ void CGraphicTextInstance::Render(RECT * pClipRect)
|
|||||||
__GetTextPos(visualSelBegin, &sx, &sy);
|
__GetTextPos(visualSelBegin, &sx, &sy);
|
||||||
__GetTextPos(visualSelEnd, &ex, &sy);
|
__GetTextPos(visualSelEnd, &ex, &sy);
|
||||||
|
|
||||||
// Handle RTL - use the computed direction for this text instance
|
// MR-15: Expose text highlighting to Python
|
||||||
|
// Apply horizontal alignment (must match text rendering offset)
|
||||||
|
float alignOffset = 0.0f;
|
||||||
|
|
||||||
if (m_computedRTL)
|
if (m_computedRTL)
|
||||||
{
|
{
|
||||||
sx += m_v3Position.x - m_textWidth;
|
switch (m_hAlign)
|
||||||
ex += m_v3Position.x - m_textWidth;
|
{
|
||||||
|
case HORIZONTAL_ALIGN_LEFT:
|
||||||
|
alignOffset = -(float)m_textWidth;
|
||||||
|
break;
|
||||||
|
case HORIZONTAL_ALIGN_CENTER:
|
||||||
|
alignOffset = -float(m_textWidth / 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sx += m_v3Position.x;
|
switch (m_hAlign)
|
||||||
ex += m_v3Position.x;
|
{
|
||||||
|
case HORIZONTAL_ALIGN_RIGHT:
|
||||||
|
alignOffset = -(float)m_textWidth;
|
||||||
|
break;
|
||||||
|
case HORIZONTAL_ALIGN_CENTER:
|
||||||
|
alignOffset = -float(m_textWidth / 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sx += m_v3Position.x + alignOffset;
|
||||||
|
ex += m_v3Position.x + alignOffset;
|
||||||
|
// MR-15: -- END OF -- Expose text highlighting to Python
|
||||||
|
|
||||||
// Apply vertical alignment
|
// Apply vertical alignment
|
||||||
float top = m_v3Position.y;
|
float top = m_v3Position.y;
|
||||||
float bot = m_v3Position.y + m_textHeight;
|
float bot = m_v3Position.y + m_textHeight;
|
||||||
@@ -1076,6 +1109,18 @@ void CGraphicTextInstance::HideCursor()
|
|||||||
m_isCursor = false;
|
m_isCursor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGraphicTextInstance::SetSelection(int iStart, int iEnd)
|
||||||
|
{
|
||||||
|
m_selStart = iStart;
|
||||||
|
m_selEnd = iEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphicTextInstance::ClearSelection()
|
||||||
|
{
|
||||||
|
m_selStart = 0;
|
||||||
|
m_selEnd = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void CGraphicTextInstance::ShowOutLine()
|
void CGraphicTextInstance::ShowOutLine()
|
||||||
{
|
{
|
||||||
m_isOutline = true;
|
m_isOutline = true;
|
||||||
@@ -1317,6 +1362,9 @@ void CGraphicTextInstance::__Initialize()
|
|||||||
m_isSecret = false;
|
m_isSecret = false;
|
||||||
m_isMultiLine = false;
|
m_isMultiLine = false;
|
||||||
|
|
||||||
|
m_selStart = 0;
|
||||||
|
m_selEnd = 0;
|
||||||
|
|
||||||
m_isOutline = false;
|
m_isOutline = false;
|
||||||
m_fFontFeather = c_fFontFeather;
|
m_fFontFeather = c_fFontFeather;
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ class CGraphicTextInstance
|
|||||||
void ShowCursor();
|
void ShowCursor();
|
||||||
void HideCursor();
|
void HideCursor();
|
||||||
|
|
||||||
|
// MR-15: Expose text highlighting to Python
|
||||||
|
void SetSelection(int iStart, int iEnd);
|
||||||
|
void ClearSelection();
|
||||||
|
// MR-15: -- END OF -- Expose text highlighting to Python
|
||||||
|
|
||||||
void ShowOutLine();
|
void ShowOutLine();
|
||||||
void HideOutLine();
|
void HideOutLine();
|
||||||
|
|
||||||
@@ -120,6 +125,9 @@ class CGraphicTextInstance
|
|||||||
bool m_isSecret;
|
bool m_isSecret;
|
||||||
bool m_isMultiLine;
|
bool m_isMultiLine;
|
||||||
|
|
||||||
|
int m_selStart;
|
||||||
|
int m_selEnd;
|
||||||
|
|
||||||
bool m_isOutline;
|
bool m_isOutline;
|
||||||
float m_fFontFeather;
|
float m_fFontFeather;
|
||||||
|
|
||||||
|
|||||||
@@ -1126,6 +1126,18 @@ namespace UI
|
|||||||
return m_TextInstance.PixelPositionToCharacterPosition(lx);
|
return m_TextInstance.PixelPositionToCharacterPosition(lx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MR-15: Expose text highlighting to Python
|
||||||
|
void CTextLine::SetSelection(int iStart, int iEnd)
|
||||||
|
{
|
||||||
|
m_TextInstance.SetSelection(iStart, iEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextLine::ClearSelection()
|
||||||
|
{
|
||||||
|
m_TextInstance.ClearSelection();
|
||||||
|
}
|
||||||
|
// MR-15: -- END OF -- Expose text highlighting to Python
|
||||||
|
|
||||||
void CTextLine::SetBaseDirection(int iDir)
|
void CTextLine::SetBaseDirection(int iDir)
|
||||||
{
|
{
|
||||||
if (iDir == 2)
|
if (iDir == 2)
|
||||||
|
|||||||
@@ -292,6 +292,11 @@ namespace UI
|
|||||||
void HideCursor();
|
void HideCursor();
|
||||||
int GetCursorPosition();
|
int GetCursorPosition();
|
||||||
|
|
||||||
|
// MR-15: Expose text highlighting to Python
|
||||||
|
void SetSelection(int iStart, int iEnd);
|
||||||
|
void ClearSelection();
|
||||||
|
// MR-15: -- END OF -- Expose text highlighting to Python
|
||||||
|
|
||||||
void SetText(const char * c_szText);
|
void SetText(const char * c_szText);
|
||||||
const char * GetText();
|
const char * GetText();
|
||||||
|
|
||||||
|
|||||||
@@ -1899,6 +1899,40 @@ PyObject * wndTextGetCursorPosition(PyObject * poSelf, PyObject * poArgs)
|
|||||||
return Py_BuildValue("i", ((UI::CTextLine*)pWindow)->GetCursorPosition());
|
return Py_BuildValue("i", ((UI::CTextLine*)pWindow)->GetCursorPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject * wndTextSetSelection(PyObject * poSelf, PyObject * poArgs)
|
||||||
|
{
|
||||||
|
UI::CWindow * pWindow;
|
||||||
|
|
||||||
|
if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
|
||||||
|
return Py_BuildException();
|
||||||
|
|
||||||
|
int iStart;
|
||||||
|
|
||||||
|
if (!PyTuple_GetInteger(poArgs, 1, &iStart))
|
||||||
|
return Py_BuildException();
|
||||||
|
|
||||||
|
int iEnd;
|
||||||
|
|
||||||
|
if (!PyTuple_GetInteger(poArgs, 2, &iEnd))
|
||||||
|
return Py_BuildException();
|
||||||
|
|
||||||
|
((UI::CTextLine*)pWindow)->SetSelection(iStart, iEnd);
|
||||||
|
|
||||||
|
return Py_BuildNone();
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject * wndTextClearSelection(PyObject * poSelf, PyObject * poArgs)
|
||||||
|
{
|
||||||
|
UI::CWindow * pWindow;
|
||||||
|
|
||||||
|
if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
|
||||||
|
return Py_BuildException();
|
||||||
|
|
||||||
|
((UI::CTextLine*)pWindow)->ClearSelection();
|
||||||
|
|
||||||
|
return Py_BuildNone();
|
||||||
|
}
|
||||||
|
|
||||||
PyObject * wndNumberSetNumber(PyObject * poSelf, PyObject * poArgs)
|
PyObject * wndNumberSetNumber(PyObject * poSelf, PyObject * poArgs)
|
||||||
{
|
{
|
||||||
UI::CWindow * pWindow;
|
UI::CWindow * pWindow;
|
||||||
@@ -2567,6 +2601,10 @@ void initwndMgr()
|
|||||||
{ "GetTextSize", wndTextGetTextSize, METH_VARARGS },
|
{ "GetTextSize", wndTextGetTextSize, METH_VARARGS },
|
||||||
{ "ShowCursor", wndTextShowCursor, METH_VARARGS },
|
{ "ShowCursor", wndTextShowCursor, METH_VARARGS },
|
||||||
{ "HideCursor", wndTextHideCursor, METH_VARARGS },
|
{ "HideCursor", wndTextHideCursor, METH_VARARGS },
|
||||||
|
// MR-15: Expose text highlighting to Python
|
||||||
|
{ "SetSelection", wndTextSetSelection, METH_VARARGS },
|
||||||
|
{ "ClearSelection", wndTextClearSelection, METH_VARARGS },
|
||||||
|
// MR-15: -- END OF -- Expose text highlighting to Python
|
||||||
{ "GetCursorPosition", wndTextGetCursorPosition, METH_VARARGS },
|
{ "GetCursorPosition", wndTextGetCursorPosition, METH_VARARGS },
|
||||||
// NumberLine
|
// NumberLine
|
||||||
{ "SetNumber", wndNumberSetNumber, METH_VARARGS },
|
{ "SetNumber", wndNumberSetNumber, METH_VARARGS },
|
||||||
|
|||||||
Reference in New Issue
Block a user