mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 09:15:29 +01:00 
			
		
		
		
	Fix hypertext in the mainmenu (#13731)
This commit is contained in:
		@@ -1670,8 +1670,6 @@ void GUIFormSpecMenu::parseField(parserData* data, const std::string &element,
 | 
			
		||||
 | 
			
		||||
void GUIFormSpecMenu::parseHyperText(parserData *data, const std::string &element)
 | 
			
		||||
{
 | 
			
		||||
	MY_CHECKCLIENT("hypertext");
 | 
			
		||||
 | 
			
		||||
	std::vector<std::string> parts;
 | 
			
		||||
	if (!precheckElement("hypertext", element, 4, 4, parts))
 | 
			
		||||
		return;
 | 
			
		||||
 
 | 
			
		||||
@@ -600,8 +600,7 @@ u32 ParsedText::parseTag(const wchar_t *text, u32 cursor)
 | 
			
		||||
 | 
			
		||||
TextDrawer::TextDrawer(const wchar_t *text, Client *client,
 | 
			
		||||
		gui::IGUIEnvironment *environment, ISimpleTextureSource *tsrc) :
 | 
			
		||||
		m_text(text),
 | 
			
		||||
		m_client(client), m_environment(environment)
 | 
			
		||||
		m_text(text), m_client(client), m_tsrc(tsrc), m_guienv(environment)
 | 
			
		||||
{
 | 
			
		||||
	// Size all elements
 | 
			
		||||
	for (auto &p : m_text.m_paragraphs) {
 | 
			
		||||
@@ -632,7 +631,7 @@ TextDrawer::TextDrawer(const wchar_t *text, Client *client,
 | 
			
		||||
 | 
			
		||||
				if (e.type == ParsedText::ELEMENT_IMAGE) {
 | 
			
		||||
					video::ITexture *texture =
 | 
			
		||||
						m_client->getTextureSource()->
 | 
			
		||||
						m_tsrc->
 | 
			
		||||
							getTexture(stringw_to_utf8(e.text));
 | 
			
		||||
					if (texture)
 | 
			
		||||
						dim = texture->getOriginalSize();
 | 
			
		||||
@@ -914,7 +913,7 @@ void TextDrawer::place(const core::rect<s32> &dest_rect)
 | 
			
		||||
void TextDrawer::draw(const core::rect<s32> &clip_rect,
 | 
			
		||||
		const core::position2d<s32> &dest_offset)
 | 
			
		||||
{
 | 
			
		||||
	irr::video::IVideoDriver *driver = m_environment->getVideoDriver();
 | 
			
		||||
	irr::video::IVideoDriver *driver = m_guienv->getVideoDriver();
 | 
			
		||||
	core::position2d<s32> offset = dest_offset;
 | 
			
		||||
	offset.Y += m_voffset;
 | 
			
		||||
 | 
			
		||||
@@ -958,10 +957,10 @@ void TextDrawer::draw(const core::rect<s32> &clip_rect,
 | 
			
		||||
 | 
			
		||||
			case ParsedText::ELEMENT_IMAGE: {
 | 
			
		||||
				video::ITexture *texture =
 | 
			
		||||
						m_client->getTextureSource()->getTexture(
 | 
			
		||||
						m_tsrc->getTexture(
 | 
			
		||||
								stringw_to_utf8(el.text));
 | 
			
		||||
				if (texture != 0)
 | 
			
		||||
					m_environment->getVideoDriver()->draw2DImage(
 | 
			
		||||
					m_guienv->getVideoDriver()->draw2DImage(
 | 
			
		||||
							texture, rect,
 | 
			
		||||
							irr::core::rect<s32>(
 | 
			
		||||
									core::position2d<s32>(0, 0),
 | 
			
		||||
@@ -970,15 +969,15 @@ void TextDrawer::draw(const core::rect<s32> &clip_rect,
 | 
			
		||||
			} break;
 | 
			
		||||
 | 
			
		||||
			case ParsedText::ELEMENT_ITEM: {
 | 
			
		||||
				IItemDefManager *idef = m_client->idef();
 | 
			
		||||
				ItemStack item;
 | 
			
		||||
				item.deSerialize(stringw_to_utf8(el.text), idef);
 | 
			
		||||
				if (m_client) {
 | 
			
		||||
					IItemDefManager *idef = m_client->idef();
 | 
			
		||||
					ItemStack item;
 | 
			
		||||
					item.deSerialize(stringw_to_utf8(el.text), idef);
 | 
			
		||||
 | 
			
		||||
				drawItemStack(
 | 
			
		||||
						m_environment->getVideoDriver(),
 | 
			
		||||
						g_fontengine->getFont(), item, rect, &clip_rect,
 | 
			
		||||
						m_client, IT_ROT_OTHER, el.angle, el.rotation
 | 
			
		||||
				);
 | 
			
		||||
					drawItemStack(m_guienv->getVideoDriver(),
 | 
			
		||||
							g_fontengine->getFont(), item, rect, &clip_rect, m_client,
 | 
			
		||||
							IT_ROT_OTHER, el.angle, el.rotation);
 | 
			
		||||
				}
 | 
			
		||||
			} break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -993,7 +992,7 @@ GUIHyperText::GUIHyperText(const wchar_t *text, IGUIEnvironment *environment,
 | 
			
		||||
		IGUIElement *parent, s32 id, const core::rect<s32> &rectangle,
 | 
			
		||||
		Client *client, ISimpleTextureSource *tsrc) :
 | 
			
		||||
		IGUIElement(EGUIET_ELEMENT, environment, parent, id, rectangle),
 | 
			
		||||
		m_client(client), m_vscrollbar(nullptr),
 | 
			
		||||
		m_tsrc(tsrc), m_vscrollbar(nullptr),
 | 
			
		||||
		m_drawer(text, client, environment, tsrc), m_text_scrollpos(0, 0)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -188,8 +188,9 @@ protected:
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	ParsedText m_text;
 | 
			
		||||
	Client *m_client;
 | 
			
		||||
	gui::IGUIEnvironment *m_environment;
 | 
			
		||||
	Client *m_client; ///< null in the mainmenu
 | 
			
		||||
	ISimpleTextureSource *m_tsrc;
 | 
			
		||||
	gui::IGUIEnvironment *m_guienv;
 | 
			
		||||
	s32 m_height;
 | 
			
		||||
	s32 m_voffset;
 | 
			
		||||
	std::vector<RectWithMargin> m_floating;
 | 
			
		||||
@@ -216,7 +217,7 @@ public:
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
	// GUI members
 | 
			
		||||
	Client *m_client;
 | 
			
		||||
	ISimpleTextureSource *m_tsrc;
 | 
			
		||||
	GUIScrollBar *m_vscrollbar;
 | 
			
		||||
	TextDrawer m_drawer;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user