]> git.lizzy.rs Git - minetest.git/blobdiff - src/irrlicht_changes/static_text.h
Drop dependency on IrrCompileConfig
[minetest.git] / src / irrlicht_changes / static_text.h
index 6bb85bd6b1507e343424e18c04e1c7f14b7014a2..3608b271c15bfbbe4201137d555f4657751c2525 100644 (file)
@@ -1,14 +1,11 @@
 // Copyright (C) 2002-2012 Nikolaus Gebhardt
-// Copyright (C) 2016 NathanaĆ«l Courant
+// Copyright (C) 2016 NathanaĆ«lle Courant
 //   Modified this class to work with EnrichedStrings too
 // This file is part of the "Irrlicht Engine".
 // For conditions of distribution and use, see copyright notice in irrlicht.h
 
 #pragma once
 
-#include "IrrCompileConfig.h"
-#ifdef _IRR_COMPILE_WITH_GUI_
-
 #include "IGUIStaticText.h"
 #include "irrArray.h"
 
@@ -20,7 +17,6 @@
 #include "config.h"
 #include <IGUIEnvironment.h>
 
-#if USE_FREETYPE
 
 namespace irr
 {
@@ -34,7 +30,8 @@ namespace gui
        {
        public:
 
-               //! constructor
+               // StaticText is translated by EnrichedString.
+               // No need to use translate_string()
                StaticText(const EnrichedString &text, bool border, IGUIEnvironment* environment,
                        IGUIElement* parent, s32 id, const core::rect<s32>& rectangle,
                        bool background = false);
@@ -92,7 +89,8 @@ namespace gui
                        s32 id = -1,
                        bool fillBackground = false)
                {
-                       return add(guienv, EnrichedString(text), rectangle, border, wordWrap, parent, id, fillBackground);
+                       return add(guienv, EnrichedString(text), rectangle, border, wordWrap, parent,
+                               id, fillBackground);
                }
 
                //! draws the element and its children
@@ -132,11 +130,10 @@ namespace gui
                virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
 
                //! Gets the override color
-               #if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 7
-               virtual const video::SColor& getOverrideColor() const;
-               #else
                virtual video::SColor getOverrideColor() const;
-               #endif
+
+               //! Gets the currently used text color
+               virtual video::SColor getActiveColor() const;
 
                //! Sets if the static text should use the overide color or the
                //! color in the gui skin.
@@ -181,12 +178,6 @@ namespace gui
                //! Checks if the text should be interpreted as right-to-left text
                virtual bool isRightToLeft() const;
 
-               //! Writes attributes of the element.
-               virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
-
-               //! Reads attributes of the element
-               virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
-
                virtual bool hasType(EGUI_ELEMENT_TYPE t) const {
                        return (t == EGUIET_ENRICHED_STATIC_TEXT) || (t == EGUIET_STATIC_TEXT);
                };
@@ -200,23 +191,20 @@ namespace gui
        private:
 
                //! Breaks the single text line.
-               void breakText();
+               void updateText();
 
                EGUI_ALIGNMENT HAlign, VAlign;
                bool Border;
-               bool OverrideColorEnabled;
-               bool OverrideBGColorEnabled;
                bool WordWrap;
                bool Background;
                bool RestrainTextInside;
                bool RightToLeft;
 
-               video::SColor OverrideColor, BGColor;
                gui::IGUIFont* OverrideFont;
                gui::IGUIFont* LastBreakFont; // stored because: if skin changes, line break must be recalculated.
 
-               EnrichedString cText;
-               core::array< EnrichedString > BrokenText;
+               EnrichedString ColoredText;
+               std::vector<EnrichedString> BrokenText;
        };
 
 
@@ -236,31 +224,7 @@ inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedS
        }
 }
 
-#else // USE_FREETYPE
-
-inline irr::gui::IGUIStaticText *addStaticText(
-               irr::gui::IGUIEnvironment *guienv,
-               const EnrichedString &text,
-               const core::rect< s32 > &rectangle,
-               bool border = false,
-               bool wordWrap = true,
-               irr::gui::IGUIElement *parent = NULL,
-               s32 id = -1,
-               bool fillBackground = false)
-{
-       return guienv->addStaticText(text.c_str(), rectangle, border, wordWrap, parent, id, fillBackground);
-}
-
-inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedString &text)
-{
-       static_text->setText(text.c_str());
-}
-
-#endif
-
 inline void setStaticText(irr::gui::IGUIStaticText *static_text, const wchar_t *text)
 {
-       setStaticText(static_text, EnrichedString(text));
+       setStaticText(static_text, EnrichedString(text, static_text->getOverrideColor()));
 }
-
-#endif // _IRR_COMPILE_WITH_GUI_