Skip to content
Permalink
Browse files
Remove unused (de)serializeAttributes() methods
  • Loading branch information
rollerozxa committed Dec 29, 2021
1 parent 9b650b9 commit 05573d6d8d9e5a756ab1b03b159b127144f8e775
@@ -632,85 +632,6 @@ bool GUIButton::isDrawingBorder() const
}


//! Writes attributes of the element.
void GUIButton::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
IGUIButton::serializeAttributes(out,options);

out->addBool ("PushButton", IsPushButton );
if (IsPushButton)
out->addBool("Pressed", Pressed);

for ( u32 i=0; i<(u32)EGBIS_COUNT; ++i )
{
if ( ButtonImages[i].Texture )
{
core::stringc name( GUIButtonImageStateNames[i] );
out->addTexture(name.c_str(), ButtonImages[i].Texture);
name += "Rect";
out->addRect(name.c_str(), ButtonImages[i].SourceRect);
}
}

out->addBool ("UseAlphaChannel", UseAlphaChannel);
out->addBool ("Border", DrawBorder);
out->addBool ("ScaleImage", ScaleImage);

for ( u32 i=0; i<(u32)EGBS_COUNT; ++i )
{
if ( ButtonSprites[i].Index >= 0 )
{
core::stringc nameIndex( GUIButtonStateNames[i] );
nameIndex += "Index";
out->addInt(nameIndex.c_str(), ButtonSprites[i].Index );

core::stringc nameColor( GUIButtonStateNames[i] );
nameColor += "Color";
out->addColor(nameColor.c_str(), ButtonSprites[i].Color );

core::stringc nameLoop( GUIButtonStateNames[i] );
nameLoop += "Loop";
out->addBool(nameLoop.c_str(), ButtonSprites[i].Loop );

core::stringc nameScale( GUIButtonStateNames[i] );
nameScale += "Scale";
out->addBool(nameScale.c_str(), ButtonSprites[i].Scale );
}
}

// out->addString ("OverrideFont", OverrideFont);
}


//! Reads attributes of the element
void GUIButton::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
IGUIButton::deserializeAttributes(in,options);

IsPushButton = in->getAttributeAsBool("PushButton");
Pressed = IsPushButton ? in->getAttributeAsBool("Pressed") : false;

core::rect<s32> rec = in->getAttributeAsRect("ImageRect");
if (rec.isValid())
setImage( in->getAttributeAsTexture("Image"), rec);
else
setImage( in->getAttributeAsTexture("Image") );

rec = in->getAttributeAsRect("PressedImageRect");
if (rec.isValid())
setPressedImage( in->getAttributeAsTexture("PressedImage"), rec);
else
setPressedImage( in->getAttributeAsTexture("PressedImage") );

setDrawBorder(in->getAttributeAsBool("Border"));
setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel"));
setScaleImage(in->getAttributeAsBool("ScaleImage"));

// setOverrideFont(in->getAttributeAsString("OverrideFont"));

updateAbsolutePosition();
}

// PATCH
GUIButton* GUIButton::addButton(IGUIEnvironment *environment,
const core::rect<s32>& rectangle, ISimpleTextureSource *tsrc,
@@ -221,14 +221,6 @@ class GUIButton : public gui::IGUIButton
return ClickControlState;
}

//! Writes attributes of the element.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const override;

//! Reads attributes of the element
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) override;



void setColor(video::SColor color);
// PATCH
//! Set element properties from a StyleSpec corresponding to the button state
@@ -846,54 +846,3 @@ void GUIEditBox::updateVScrollBar()
}
}
}

void GUIEditBox::deserializeAttributes(
io::IAttributes *in, io::SAttributeReadWriteOptions *options = 0)
{
IGUIEditBox::deserializeAttributes(in, options);

setOverrideColor(in->getAttributeAsColor("OverrideColor"));
enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled"));
setMax(in->getAttributeAsInt("MaxChars"));
setWordWrap(in->getAttributeAsBool("WordWrap"));
setMultiLine(in->getAttributeAsBool("MultiLine"));
setAutoScroll(in->getAttributeAsBool("AutoScroll"));
core::stringw ch = in->getAttributeAsStringW("PasswordChar");

if (ch.empty())
setPasswordBox(in->getAttributeAsBool("PasswordBox"));
else
setPasswordBox(in->getAttributeAsBool("PasswordBox"), ch[0]);

setTextAlignment((EGUI_ALIGNMENT)in->getAttributeAsEnumeration(
"HTextAlign", GUIAlignmentNames),
(EGUI_ALIGNMENT)in->getAttributeAsEnumeration(
"VTextAlign", GUIAlignmentNames));

setWritable(in->getAttributeAsBool("Writable"));
// setOverrideFont(in->getAttributeAsFont("OverrideFont"));
}

//! Writes attributes of the element.
void GUIEditBox::serializeAttributes(
io::IAttributes *out, io::SAttributeReadWriteOptions *options = 0) const
{
// IGUIEditBox::serializeAttributes(out,options);

out->addBool("OverrideColorEnabled", m_override_color_enabled);
out->addColor("OverrideColor", m_override_color);
// out->addFont("OverrideFont",m_override_font);
out->addInt("MaxChars", m_max);
out->addBool("WordWrap", m_word_wrap);
out->addBool("MultiLine", m_multiline);
out->addBool("AutoScroll", m_autoscroll);
out->addBool("PasswordBox", m_passwordbox);
core::stringw ch = L" ";
ch[0] = m_passwordchar;
out->addString("PasswordChar", ch.c_str());
out->addEnum("HTextAlign", m_halign, GUIAlignmentNames);
out->addEnum("VTextAlign", m_valign, GUIAlignmentNames);
out->addBool("Writable", m_writable);

IGUIEditBox::serializeAttributes(out, options);
}
@@ -130,14 +130,6 @@ class GUIEditBox : public IGUIEditBox
//! called if an event happened.
virtual bool OnEvent(const SEvent &event);

//! 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 acceptsIME() { return isEnabled() && m_writable; };

protected:
@@ -652,26 +652,6 @@ void GUIEditBoxWithScrollBar::setBackgroundColor(const video::SColor &bg_color)
m_bg_color_used = true;
}

//! Writes attributes of the element.
void GUIEditBoxWithScrollBar::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options = 0) const
{
out->addBool("Border", m_border);
out->addBool("Background", m_background);
// out->addFont("OverrideFont", OverrideFont);

GUIEditBox::serializeAttributes(out, options);
}


//! Reads attributes of the element
void GUIEditBoxWithScrollBar::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options = 0)
{
GUIEditBox::deserializeAttributes(in, options);

setDrawBorder(in->getAttributeAsBool("Border"));
setDrawBackground(in->getAttributeAsBool("Background"));
}

bool GUIEditBoxWithScrollBar::isDrawBackgroundEnabled() const { return false; }
bool GUIEditBoxWithScrollBar::isDrawBorderEnabled() const { return false; }
void GUIEditBoxWithScrollBar::setCursorChar(const wchar_t cursorChar) { }
@@ -31,12 +31,6 @@ class GUIEditBoxWithScrollBar : public GUIEditBox
//! Change the background color
virtual void setBackgroundColor(const video::SColor &bg_color);

//! 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 isDrawBackgroundEnabled() const;
virtual bool isDrawBorderEnabled() const;
virtual void setCursorChar(const wchar_t cursorChar);
@@ -1024,48 +1024,6 @@ void GUISkin::draw2DRectangle(IGUIElement* element,
}


//! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes.
void GUISkin::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
{
u32 i;
for (i=0; i<EGDC_COUNT; ++i)
out->addColor(GUISkinColorNames[i], Colors[i]);

for (i=0; i<EGDS_COUNT; ++i)
out->addInt(GUISkinSizeNames[i], Sizes[i]);

for (i=0; i<EGDT_COUNT; ++i)
out->addString(GUISkinTextNames[i], Texts[i].c_str());

for (i=0; i<EGDI_COUNT; ++i)
out->addInt(GUISkinIconNames[i], Icons[i]);
}


//! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes.
void GUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
{
// TODO: This is not nice code for downward compatibility, whenever new values are added and users
// load an old skin the corresponding values will be set to 0.
u32 i;
for (i=0; i<EGDC_COUNT; ++i)
Colors[i] = in->getAttributeAsColor(GUISkinColorNames[i]);

for (i=0; i<EGDS_COUNT; ++i)
Sizes[i] = in->getAttributeAsInt(GUISkinSizeNames[i]);

for (i=0; i<EGDT_COUNT; ++i)
Texts[i] = in->getAttributeAsStringW(GUISkinTextNames[i]);

for (i=0; i<EGDI_COUNT; ++i)
Icons[i] = in->getAttributeAsInt(GUISkinIconNames[i]);
}


//! gets the colors
// PATCH
void GUISkin::getColors(video::SColor* colors)
@@ -290,16 +290,6 @@ namespace gui
//! get the type of this skin
virtual EGUI_SKIN_TYPE getType() const;

//! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;

//! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);

//! gets the colors
virtual void getColors(video::SColor* colors); // ::PATCH:

@@ -588,50 +588,6 @@ s32 StaticText::getTextWidth() const
}


//! Writes attributes of the element.
//! Implement this to expose the attributes of your element for
//! scripting languages, editors, debuggers or xml serialization purposes.
void StaticText::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
IGUIStaticText::serializeAttributes(out,options);

out->addBool ("Border", Border);
out->addBool ("OverrideColorEnabled",true);
out->addBool ("OverrideBGColorEnabled",ColoredText.hasBackground());
out->addBool ("WordWrap", WordWrap);
out->addBool ("Background", Background);
out->addBool ("RightToLeft", RightToLeft);
out->addBool ("RestrainTextInside", RestrainTextInside);
out->addColor ("OverrideColor", ColoredText.getDefaultColor());
out->addColor ("BGColor", ColoredText.getBackground());
out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames);
out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames);

// out->addFont ("OverrideFont", OverrideFont);
}


//! Reads attributes of the element
void StaticText::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
IGUIStaticText::deserializeAttributes(in,options);

Border = in->getAttributeAsBool("Border");
setWordWrap(in->getAttributeAsBool("WordWrap"));
Background = in->getAttributeAsBool("Background");
RightToLeft = in->getAttributeAsBool("RightToLeft");
RestrainTextInside = in->getAttributeAsBool("RestrainTextInside");
if (in->getAttributeAsBool("OverrideColorEnabled"))
ColoredText.setDefaultColor(in->getAttributeAsColor("OverrideColor"));
if (in->getAttributeAsBool("OverrideBGColorEnabled"))
ColoredText.setBackground(in->getAttributeAsColor("BGColor"));

setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames),
(EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames));

// OverrideFont = in->getAttributeAsFont("OverrideFont");
}

} // end namespace gui

#endif // USE_FREETYPE
@@ -184,12 +184,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);
};

0 comments on commit 05573d6

Please sign in to comment.