Пример #1
0
/*
  Picture node example :
  <Picture file="menu/image.png"
           alpha="false"
           x="0" y="0"
           width="100" height="100"
           scale="true"
           antialiasing="true" />
*/
bool PictureWidget::LoadXMLConfiguration()
{
  if (NULL == profile || NULL == widgetNode) {
    //TODO error ... xml attributs not initialized !
    return false;
  }
  XmlReader * xmlFile = profile->GetXMLDocument();

  std::string file("menu/pic_not_found.png");
  xmlFile->ReadStringAttr(widgetNode, "file", file);

  bool activeAlpha = false;
  xmlFile->ReadBoolAttr(widgetNode, "alpha", activeAlpha);

  file = profile->relative_path + file;
  Surface surface(file.c_str());

  if (!activeAlpha) {
    surface = surface.DisplayFormat();
  } else {
    surface = surface.DisplayFormatAlpha();
  }

  ParseXMLGeometry();
  ParseXMLMisc();

  bool activeScale = false;
  xmlFile->ReadBoolAttr(widgetNode, "scale", activeScale);

  SetSurface(surface, activeScale ? FIT_SCALING : NO_SCALING);
  return true;
}
Пример #2
0
/*
  <ButtonPic x="250px" y="50px"
             width="120px" height="110px"
             action="localGame"
             picture="menu/i_play.png"
             text="Play" />
*/
bool ButtonPic::LoadXMLConfiguration(void)
{
  if (NULL == profile || NULL == widgetNode) {
    //TODO error ... xml attributs not initialized !
    return false;
  }
  XmlReader * xmlFile = profile->GetXMLDocument();

  ParseXMLGeometry();
  ParseXMLMisc();
  ParseXMLBorder();
  ParseXMLBackground();

  std::string picture("menu/pic_not_found.png");
  if (!xmlFile->ReadStringAttr(widgetNode, "picture", picture)) {
    //TODO error
    return false;
  }

  picture = profile->relative_path + picture;
  Surface surface(picture.c_str());
  m_img_normal = surface;

  std::string labelText("No Text");
  xmlFile->ReadStringAttr(widgetNode, "text", labelText);
  txt_label = new Text(_(labelText.c_str()), dark_gray_color, Font::FONT_SMALL, Font::FONT_BOLD, false);
  //txt_label->SetMaxWidth(size.x);

  return true;
}