Jump to content

Multi Text Line


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 131
  • Eyes 2
  • Dislove 1
  • Angry 1
  • Confused 1
  • Scream 1
  • Good 23
  • Love 5
  • Love 74

 

Link to comment
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
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
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

Link to comment
Share on other sites

  • Bronze

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
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
Share on other sites

  • 10 months later...
  • 6 months later...
  • 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 1
  • Good 1
  • Love 3
Link to comment
Share on other sites

  • 7 months later...
  • 1 month later...

Announcements



×
×
  • 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.