]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/irrlicht_changes/static_text.h
Inventory: Make addList() consistent (#11382)
[dragonfireclient.git] / src / irrlicht_changes / static_text.h
index c95d5b95f8927b07ab6fd7ce497908d23d37fdf4..83bbf4c3d709a300b3293f2d8f6db91aebd2fc62 100644 (file)
@@ -34,7 +34,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);
@@ -133,10 +134,11 @@ 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;
+
+               #if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR > 8
+               //! Gets the currently used text color
+               virtual video::SColor getActiveColor() const;
                #endif
 
                //! Sets if the static text should use the overide color or the
@@ -201,23 +203,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;
        };
 
 
@@ -239,7 +238,15 @@ inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedS
 
 #else // USE_FREETYPE
 
-inline irr::gui::IGUIStaticText *addStaticText(
+namespace irr
+{
+namespace gui
+{
+
+class StaticText
+{
+public:
+       static irr::gui::IGUIStaticText *add(
                irr::gui::IGUIEnvironment *guienv,
                const EnrichedString &text,
                const core::rect< s32 > &rectangle,
@@ -248,9 +255,14 @@ inline irr::gui::IGUIStaticText *addStaticText(
                irr::gui::IGUIElement *parent = NULL,
                s32 id = -1,
                bool fillBackground = false)
-{
-       return guienv->addStaticText(text.c_str(), rectangle, border, wordWrap, parent, id, fillBackground);
-}
+       {
+               return guienv->addStaticText(text.c_str(), rectangle, border, wordWrap, parent, id, fillBackground);
+       }
+};
+
+} // end namespace gui
+
+} // end namespace irr
 
 inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedString &text)
 {
@@ -261,7 +273,7 @@ inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedS
 
 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_