60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#include "ui/ui_window.h"
|
|
#include "metafile/nml.h"
|
|
#include "log/log.h"
|
|
|
|
using namespace GS::NML;
|
|
using namespace GS::S2D;
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
bool Window::FromMetaTag(Tag &tag)
|
|
{
|
|
if (tag.name != "Window")
|
|
__ERR__(__LOG_E__ << "Could not parse window, incorrect root tag (" << tag.name << ").\n", false)
|
|
|
|
// Parse root tags.
|
|
NMLTagForeach(pt, tag)
|
|
{
|
|
if (pt->name == "Sprite")
|
|
Sprite::FromMetaTag(*pt);
|
|
|
|
else if (pt->name == "Flag")
|
|
{
|
|
NMLTagForeach(st, *pt)
|
|
{
|
|
if (st->name == "NoDecoration")
|
|
window_flags |= FlagNoDecoration;
|
|
else if (st->name == "NoTitle")
|
|
window_flags |= FlagNoTitleBar;
|
|
}
|
|
}
|
|
else
|
|
__LOG_W__ << "Unknown tag '" << pt->name << "' in <Window>.\n";
|
|
}
|
|
return true;
|
|
}
|
|
Tag *Window::AsMetaTag() const
|
|
{
|
|
Tag *root = new Tag("Window");
|
|
if (!root)
|
|
__ERR__(__LOG_E__ << "Could not create root tag to serialize.\n", NULL)
|
|
|
|
root->AddChild(Sprite::AsMetaTag());
|
|
|
|
if (Tag *style_tag = new Tag("Flag"))
|
|
{
|
|
if (window_flags.IsSet(FlagNoDecoration))
|
|
style_tag->AddChild("NoDecoration");
|
|
if (window_flags.IsSet(FlagNoTitleBar))
|
|
style_tag->AddChild("NoTitle");
|
|
}
|
|
return root;
|
|
}
|
|
//------------------------------------------------------------------------------
|