Jump to content

Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )
This is the hidden content, please
( GitHub )

24021568747470733a2f2f7075752e73682f4647

Just add \n example:

Spoiler
Quote

this is test message\ntest heree\ntestttt

 

 

  • Metin2 Dev 237
  • Eyes 3
  • Dislove 1
  • Angry 1
  • Confused 1
  • Scream 1
  • Good 46
  • muscle 1
  • Love 13
  • Love 129

 

Link to comment
https://metin2.dev/topic/23676-multi-text-line/
Share on other sites

  • Honorable Member

Also if you are smart enough as the webzen developers weren't, you will put an exception where the render of the textline class will skip the splitting on special places like whisper nameinput :).

Doesn't matter if they have added the DisableEnterToken if they didn't apply everywhere where they supposed to.

And when you report this problem on their forum(gayforge obv..), they delete the topic, and giving a single piece of nothing about it.

  • Love 2
Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-127417
Share on other sites

  • Honorable Member
1 hour ago, xP3NG3Rx said:

Also if you are smart enough as the webzen developers weren't, you will put an exception where the render of the textline class will skip the splitting on special places like whisper nameinput :).

Doesn't matter if they have added the DisableEnterToken if they didn't apply everywhere where they supposed to.

And when you report this problem on their forum(gayforge obv..), they delete the topic, and giving a single piece of nothing about it.

thanks for reply :)

I was just thinking about this, and I added an option SetEnterToken(bool)

Default setting(m_EnterToken) is false, you can change at GrpTextInstance.cpp, or simply add code at ui/TextLine constructor

For Enable Example:

Testt = ui.TextLine()
Testt.SetParent(self)
Testt.SetEnterToken(True) ### this
Testt.SetText("this is test message\ntest here\ntesttt")

 

  • Love 2

 

Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-127419
Share on other sites

  • Forum Moderator

The idea behind it is really cool and way cleaner than the official way of doing it. However, here are a few inconsistensies that you can see with this function. Of course it needs to be enhanced with further checks (as xP3NG3Rx said above) and your function is neat.

064345Screenshot-4.png


064345Screenshot-6.png


064345Screenshot-7.png


064345Screenshot-8.png

 

For example, with the official (not fully) reversed WJ_MULTI_TEXTLINE and a few checks I came up with this :

 

064820Screenshot-9.png

 

Good idea and method however, thank you!

 

Edit : Well you answered two minutes before my post and updated your repo, this message may be unrelevant now

Edited by Gurgarath
  • Love 1

Gurgarath
coming soon
My Services

Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-127420
Share on other sites

If you split only by "\n" and not "\\n" you won't need to add that check for editline.

Also I know default open file function from python 2.7 escape \n automaticaly but you can fix the \n in two ways: (I'm talking about locale_game / locale_interface)

1. replace all "\\n" in line with "\n"

2. open the file with codecs.open and encoding "string_escape"

 

One ideea though for your code: split the code where the text is initialized and after this save only the positions where \n was in a vector, after that in Render function you can use the position vector to rearange the text y position. Something like this (https://metin2.download/picture/f9LxxwZljyoXvU1nuSq3rwgoHx7xQYov/.png)

 

PS: I don't know how official did it but they seem stupid ?

 

Good job ?

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 1
  • Not Good 1
  • Good 2
  • Love 2
Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-127422
Share on other sites

  • Honorable Member

Especially their guild comment window, you can spam \n and the text will look so buggy.
This is how it looks like rofl.

 

f6roR0c.png

Obs: This "system" was implemented some time ago and this print is from today rofl... still the same and like penger said, you report the problem and they ignore your report.

 

For the chat window I had to disable the token from the input and even from text tail, since it's a good ideia.

By looking through the official python root they cleary forgot to add the DisableEnterToken() on some scripts....

# Simply disabling the token in the functions did the trick.
 
# @ PythonChat.cpp
  
# @ void CWhisper::AppendChat
#ifdef WJ_MULTI_TEXTLINE
	pChatLine->Instance.DisableEnterToken();
#endif

# @ void CPythonChat::AppendChat
#ifdef WJ_MULTI_TEXTLINE
	pChatLine->Instance.DisableEnterToken();
#endif

# @ PythonTextTail.cpp
# @ void CPythonTextTail::RegisterInfoTail
#ifdef WJ_MULTI_TEXTLINE
		pTextTail->pTextInstance->DisableEnterToken();
#endif

# @ CPythonTextTail::TTextTail * CPythonTextTail::RegisterTextTail
#ifdef WJ_MULTI_TEXTLINE
	pTextTail->pTextInstance->DisableEnterToken();
#endif

# @ void CPythonTextTail::RegisterChatTail
#ifdef WJ_MULTI_TEXTLINE
		pTextTail->pTextInstance->DisableEnterToken();
#endif

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 2
Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-127437
Share on other sites

  • 10 months later...
  • 6 months later...

Thanks, Work Great ?

ba9bde0bce5d5e4e159a27f5205ba8a8.png

would there be any way to add color? for curiosity

Edited by Metin2 Dev
Core X - External 2 Internal

KH.jpg

Nicks: Nazox™ Krone™ Nagato™ Yahiko™ Yakiro™
Proyecto: Trabajando en el.
Compañeros & firma: DreamHQ  - 2009-2015 [Nostalgia]

Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-144106
Share on other sites

  • 1 year later...
  • Honorable Member

Here is a little update for the tooltips and a small correction for horizontal & vertical positions.

EterLib/GrpTextInstance.cpp

Spoiler
/// 1.
// Search @ WORD CGraphicTextInstance::GetTextLineCount
	return wLineCount;

// Add above
#if defined(WJ_MULTI_TEXTLINE)
	wLineCount += multi_text.size();
#endif

/// 4.
// Search
void CGraphicTextInstance::SetPosition

// Replace entire function with
void CGraphicTextInstance::SetPosition(float fx, float fy, float fz)
{
	m_v3Position.x = fx;
	m_v3Position.y = fy;
	m_v3Position.z = fz;

#if defined(WJ_MULTI_TEXTLINE)
	for (std::size_t i = 0; i < multi_text.size(); i++)
	{
		const auto& it = multi_text.at(i);
		it->SetPosition(fx, fy + (i + 1) * m_textHeight, fz);

		it->SetHorizonalAlign(m_hAlign);
		it->SetVerticalAlign(m_vAlign);

		it->SetOutline(m_isOutline);
		it->SetFeather(m_fFontFeather);
	}
#endif
}

 

EterLib/GrpTextInstance.h

Spoiler
/// 1.
// Search
	WORD GetTextLineCount();

// Add below
	WORD GetLineHeight() { return m_textHeight; }
	void SetLineHeight(const int c_iLineHeight) { m_textHeight = c_iLineHeight; }

 

EterLib/PythonWindow.cpp

Spoiler
/// 1.
// Search
	void CTextLine::SetMultiLine(BOOL bFlag)
	{
		m_TextInstance.SetMultiLine(bFlag ? true : false);
	}

// Add below
	WORD CTextLine::GetTextLineCount() { return m_TextInstance.GetTextLineCount(); }
	WORD CTextLine::GetLineHeight() { return m_TextInstance.GetLineHeight(); }
	void CTextLine::SetLineHeight(int iHeight) { m_TextInstance.SetLineHeight(iHeight); }

 

EterLib/PythonWindow.h

Spoiler
/// 1.
// Search
		void GetTextSize(int* pnWidth, int* pnHeight);

// Add below
		WORD GetTextLineCount();
		WORD GetLineHeight();
		void SetLineHeight(int iHeight);

 

Root/uiToolTip.py

Spoiler
""" 1. """
# Search
def SplitDescription(desc, limit):

# Replace the entire method with
def SplitDescription(desc, limit):
	total_tokens = desc.split()
	line_tokens = []
	line_len = 0
	lines = []

	for token in total_tokens:
		if "|" in token:
			sep_pos = token.find("|")
			line_tokens.append(token[:sep_pos])
			lines.append(" ".join(line_tokens))
			line_len = len(token) - (sep_pos + 1)
			line_tokens = [token[sep_pos+1:]]
		elif app.WJ_MULTI_TEXTLINE and "\\n" in token:
			sep_pos = token.find("\\n")
			line_tokens.append(token[:sep_pos])

			lines.append(" ".join(line_tokens))
			line_len = len(token) - (sep_pos + 2)
			line_tokens = [token[sep_pos+2:]]
		else:
			line_len += len(token)
			if len(line_tokens) + line_len > limit:
				lines.append(" ".join(line_tokens))
				line_len = len(token)
				line_tokens = [token]
			else:
				line_tokens.append(token)

	if line_tokens:
		lines.append(" ".join(line_tokens))

	return lines

""" 2. """
# Search
	def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = True):

# Replace the entire method with
	def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = True):
		textLine = ui.TextLine()
		textLine.SetParent(self)
		textLine.SetFontName(self.defFontName)
		textLine.SetPackedFontColor(color)
		textLine.SetText(text)
		textLine.SetOutline()
		textLine.SetFeather(False)
		if app.WJ_MULTI_TEXTLINE:
			textLine.SetLineHeight(self.TEXT_LINE_HEIGHT)

		if centerAlign:
			textLine.SetPosition(self.toolTipWidth / 2, self.toolTipHeight)
			textLine.SetHorizontalAlignCenter()
		else:
			textLine.SetPosition(10, self.toolTipHeight)

		textLine.Show()

		self.childrenList.append(textLine)

		if app.WJ_MULTI_TEXTLINE:
			lineCount = textLine.GetTextLineCount()
			self.toolTipHeight += self.TEXT_LINE_HEIGHT * lineCount
		else:
			self.toolTipHeight += self.TEXT_LINE_HEIGHT

		self.ResizeToolTip()

		return textLine

 

 

  • Metin2 Dev 2
  • Good 1
  • Love 4
Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-155515
Share on other sites

  • 7 months later...
  • Premium

Vertical align broken ?

text_align_broken.png

First line is aligned correctly but next ones are off.

Fixed ?

 text_align_fixed.png

This is the hidden content, please

Edited by Metin2 Dev International
Core X - External 2 Internal
  • Metin2 Dev 57
  • Good 7
  • Love 13
Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-160186
Share on other sites

  • 1 month later...
  • 5 months later...
On 2/23/2023 at 1:59 AM, Owsap said:

Here is a little update for the tooltips and a small correction for horizontal & vertical positions.

EterLib/GrpTextInstance.cpp

  Reveal hidden contents
/// 1.
// Search @ WORD CGraphicTextInstance::GetTextLineCount
	return wLineCount;

// Add above
#if defined(WJ_MULTI_TEXTLINE)
	wLineCount += multi_text.size();
#endif

/// 4.
// Search
void CGraphicTextInstance::SetPosition

// Replace entire function with
void CGraphicTextInstance::SetPosition(float fx, float fy, float fz)
{
	m_v3Position.x = fx;
	m_v3Position.y = fy;
	m_v3Position.z = fz;

#if defined(WJ_MULTI_TEXTLINE)
	for (std::size_t i = 0; i < multi_text.size(); i++)
	{
		const auto& it = multi_text.at(i);
		it->SetPosition(fx, fy + (i + 1) * m_textHeight, fz);

		it->SetHorizonalAlign(m_hAlign);
		it->SetVerticalAlign(m_vAlign);

		it->SetOutline(m_isOutline);
		it->SetFeather(m_fFontFeather);
	}
#endif
}

 

EterLib/GrpTextInstance.h

  Reveal hidden contents
/// 1.
// Search
	WORD GetTextLineCount();

// Add below
	WORD GetLineHeight() { return m_textHeight; }
	void SetLineHeight(const int c_iLineHeight) { m_textHeight = c_iLineHeight; }

 

EterLib/PythonWindow.cpp

  Reveal hidden contents
/// 1.
// Search
	void CTextLine::SetMultiLine(BOOL bFlag)
	{
		m_TextInstance.SetMultiLine(bFlag ? true : false);
	}

// Add below
	WORD CTextLine::GetTextLineCount() { return m_TextInstance.GetTextLineCount(); }
	WORD CTextLine::GetLineHeight() { return m_TextInstance.GetLineHeight(); }
	void CTextLine::SetLineHeight(int iHeight) { m_TextInstance.SetLineHeight(iHeight); }

 

EterLib/PythonWindow.h

  Reveal hidden contents
/// 1.
// Search
		void GetTextSize(int* pnWidth, int* pnHeight);

// Add below
		WORD GetTextLineCount();
		WORD GetLineHeight();
		void SetLineHeight(int iHeight);

 

Root/uiToolTip.py

  Reveal hidden contents
""" 1. """
# Search
def SplitDescription(desc, limit):

# Replace the entire method with
def SplitDescription(desc, limit):
	total_tokens = desc.split()
	line_tokens = []
	line_len = 0
	lines = []

	for token in total_tokens:
		if "|" in token:
			sep_pos = token.find("|")
			line_tokens.append(token[:sep_pos])
			lines.append(" ".join(line_tokens))
			line_len = len(token) - (sep_pos + 1)
			line_tokens = [token[sep_pos+1:]]
		elif app.WJ_MULTI_TEXTLINE and "\\n" in token:
			sep_pos = token.find("\\n")
			line_tokens.append(token[:sep_pos])

			lines.append(" ".join(line_tokens))
			line_len = len(token) - (sep_pos + 2)
			line_tokens = [token[sep_pos+2:]]
		else:
			line_len += len(token)
			if len(line_tokens) + line_len > limit:
				lines.append(" ".join(line_tokens))
				line_len = len(token)
				line_tokens = [token]
			else:
				line_tokens.append(token)

	if line_tokens:
		lines.append(" ".join(line_tokens))

	return lines

""" 2. """
# Search
	def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = True):

# Replace the entire method with
	def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = True):
		textLine = ui.TextLine()
		textLine.SetParent(self)
		textLine.SetFontName(self.defFontName)
		textLine.SetPackedFontColor(color)
		textLine.SetText(text)
		textLine.SetOutline()
		textLine.SetFeather(False)
		if app.WJ_MULTI_TEXTLINE:
			textLine.SetLineHeight(self.TEXT_LINE_HEIGHT)

		if centerAlign:
			textLine.SetPosition(self.toolTipWidth / 2, self.toolTipHeight)
			textLine.SetHorizontalAlignCenter()
		else:
			textLine.SetPosition(10, self.toolTipHeight)

		textLine.Show()

		self.childrenList.append(textLine)

		if app.WJ_MULTI_TEXTLINE:
			lineCount = textLine.GetTextLineCount()
			self.toolTipHeight += self.TEXT_LINE_HEIGHT * lineCount
		else:
			self.toolTipHeight += self.TEXT_LINE_HEIGHT

		self.ResizeToolTip()

		return textLine

 

 

ui.py?

Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-165299
Share on other sites

  • 10 months later...
  • Premium
On 5/22/2024 at 6:09 PM, Filachilla said:

ui.py?

Hello I think i had the same issue, 

I try to update with What Owsap posted and had errors regarding module for SetLineHeight.

I cooked something to make it work but i don't know if this is fine (i am no dev).

 

PythonWindowManagerModule.cpp:

Spoiler
//search:
#if defined(WJ_MULTI_TEXTLINE)
PyObject* wndSetEnterToken(PyObject* poSelf, PyObject* poArgs)
{
  ...
}


//Add:
PyObject* wndSetLineHeight(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWindow;
	int value;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow) || !PyTuple_GetInteger(poArgs, 1, &value))
		return Py_BuildException();

	((UI::CTextLine*)pWindow)->SetLineHeight(value);

	return Py_BuildNone();
}

PyObject* wndGetTextLineCount(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	return Py_BuildValue("i", ((UI::CTextLine*)pWindow)->GetTextLineCount());
}

PyObject* wndGetLineHeight(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	return Py_BuildValue("i", ((UI::CTextLine*)pWindow)->GetLineHeight());
}


//Search in void initwndMgr():
#if defined(WJ_MULTI_TEXTLINE)
		{ "SetEnterToken",				wndSetEnterToken,					METH_VARARGS },


//Add:
		{ "SetLineHeight",				wndSetLineHeight,					METH_VARARGS },
		{ "GetTextLineCount",			wndGetTextLineCount,				METH_VARARGS },
		{ "GetLineHeight",				wndGetLineHeight,					METH_VARARGS },

 

 

ui.py:

Spoiler
##Search:
	if app.WJ_MULTI_TEXTLINE:
		def SetEnterToken(self, bool):
			wndMgr.SetEnterToken(self.hWnd, bool)

##Add:
		def SetLineHeight(self, value):
			wndMgr.SetLineHeight(self.hWnd, value)

		def GetLineHeight(self):
			return wndMgr.GetLineHeight(self.hWnd)

		def GetTextLineCount(self):
			return wndMgr.GetTextLineCount(self.hWnd)

 

 

It's working fine for me now but if i can get an opinion about it,

i just watch how other module were made in the same files and "produce" that. 

 

Thanks for this system and and for the updates made by Owsap and filipw1.

 

Best regards, ARiver

 

Edit: 

I looked further into this :

 

 

Those functions can be found here ! I left what i've write here but better take  the 3 functions from johnny post i guess.

Edited by ARiver
Found the functions in another post
Link to comment
https://metin2.dev/topic/23676-multi-text-line/#findComment-170230
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.