Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use legacy image implementation when not using 9-slice image #12608

Merged
merged 2 commits into from
Jul 31, 2022

Conversation

x2048
Copy link
Contributor

@x2048 x2048 commented Jul 28, 2022

Fixes #12581

To do

This PR is Ready for Review.

How to test

  1. Set gui_scaling_filter = true
  2. Start Repixture game
  3. Open inventory
  4. Notice that inventory slots do not have dark border (see Inventory slots in Repixture look different in 5.6.0-dev (with gui_scaling_filter = true) #12581).

@x2048 x2048 added this to the 5.6.0 milestone Jul 28, 2022
@SmallJoker
Copy link
Member

This could also be fixed the other way around: by specifying whether or not to scale&filter GUIAnimatedImage:

diff --git a/src/gui/guiAnimatedImage.cpp b/src/gui/guiAnimatedImage.cpp
index 890763e71..d68009085 100644
--- a/src/gui/guiAnimatedImage.cpp
+++ b/src/gui/guiAnimatedImage.cpp
@@ -36,8 +36,12 @@ void GUIAnimatedImage::draw()
 	if (m_middle.getArea() == 0) {
 		const video::SColor color(255, 255, 255, 255);
 		const video::SColor colors[] = {color, color, color, color};
-		draw2DImageFilterScaled(driver, m_texture, AbsoluteRect, rect, cliprect,
-			colors, true);
+		if (m_scale_image) {
+			driver->draw2DImage(m_texture, AbsoluteRect, rect, cliprect, colors, true);
+		} else {
+			draw2DImageFilterScaled(driver, m_texture, AbsoluteRect, rect, cliprect,
+				colors, true);
+		}
 	} else {
 		draw2DImage9Slice(driver, m_texture, AbsoluteRect, rect, m_middle, cliprect);
 	}
diff --git a/src/gui/guiAnimatedImage.h b/src/gui/guiAnimatedImage.h
index 885aedece..d66a4cca1 100644
--- a/src/gui/guiAnimatedImage.h
+++ b/src/gui/guiAnimatedImage.h
@@ -16,6 +16,8 @@ class GUIAnimatedImage : public gui::IGUIElement {
 	void setTexture(video::ITexture *texture) { m_texture = texture; };
 	video::ITexture *getTexture() const { return m_texture; };
 
+	void setScaleImage(bool do_scale) { m_scale_image = do_scale; }
+
 	void setMiddleRect(const core::rect<s32> &middle) { m_middle = middle; };
 	core::rect<s32> getMiddleRect() const { return m_middle; };
 
@@ -30,6 +32,7 @@ class GUIAnimatedImage : public gui::IGUIElement {
 
 private:
 	video::ITexture *m_texture = nullptr;
+	bool m_scale_image = false;
 
 	u64 m_global_time = 0;
 	s32 m_frame_idx = 0;
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index a635cda48..ca026aca5 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -831,6 +831,7 @@ void GUIFormSpecMenu::parseImage(parserData* data, const std::string &element)
 
 	e->setTexture(texture);
 	e->setMiddleRect(middle);
+	e->setScaleImage(middle.getArea() == 0);
 
 	auto style = getDefaultStyleForElement("image", spec.fname);
 	e->setNotClipped(style.getBool(StyleSpec::NOCLIP, m_formspec_version < 3));

Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (not tested)

@x2048 x2048 merged commit 839600e into minetest:master Jul 31, 2022
@x2048 x2048 deleted the gui_scaling_image branch July 31, 2022 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inventory slots in Repixture look different in 5.6.0-dev (with gui_scaling_filter = true)
3 participants