pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src prefab.cxx,NONE,1.1 prefab.hxx,NONE,1


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src prefab.cxx,NONE,1.1 prefab.hxx,NONE,1.1 prefab_data.hxx,1.2,NONE
Date: 15 Sep 2002 15:30:23 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv10202

Added Files:
        prefab.cxx prefab.hxx 
Removed Files:
        prefab_data.hxx 
Log Message:
some prefab framework

--- NEW FILE: prefab.cxx ---
//  $Id: prefab.cxx,v 1.1 2002/09/15 15:30:21 grumbel Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#include "prefab.hxx"

namespace EditorNS {

Prefab::Prefab (const std::string& filename)
{
  std::cout << "Prefab::create: " << filename << std::endl;
  xmlDocPtr doc = xmlParseFile(filename.c_str ());

  if (doc)
    {
      xmlNodePtr cur = doc->ROOT;
      WorldObjGroupData* group = new WorldObjGroupData (doc, cur);
      const EditorObjLst& temp = group->create_EditorObj ();
      editor_objs.insert(editor_objs.end(),temp.begin(), temp.end());
      delete group;
    }
  else
    {
      std::cout << "ObjectManager::add_prefab_from_file: read error: " << 
filename << std::endl;
    }
}

EditorObj*
Prefab::create (const std::string& filename)
{
  std::cout << "Prefab::create: " << filename << std::endl;
  xmlDocPtr doc = xmlParseFile(filename.c_str ());

  if (doc)
    {
      xmlNodePtr cur = doc->ROOT;
      WorldObjGroupData* group = new WorldObjGroupData (doc, cur);
      const EditorObjLst& temp = group->create_EditorObj ();
      editor_objs.insert(editor_objs.end(),temp.begin(), temp.end());
      delete group;
    }
  else
    {
      std::cout << "ObjectManager::add_prefab_from_file: read error: " << 
filename << std::endl;
    }
}

} // namespace EditorNS

/* EOF */

--- NEW FILE: prefab.hxx ---
//  $Id: prefab.hxx,v 1.1 2002/09/15 15:30:21 grumbel Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
// 
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#ifndef HEADER_PREFAB_HXX
#define HEADER_PREFAB_HXX

namespace EditorNS {

/** The prefab class represents a prefab description file. The prefab
    file consist of a black of meta data (author, description, name,
    etc.) along with a group of worldobj_data.

    The position of objects in the prefab should/must be relative to
    0/0. On creation of a prefab the object positions should be fixed
    to the center of the prefab. */
class Prefab
{
private:
public:
  /** Create a Prefab object from a given prefab description file
      @param filename The fully qualitfied filename of the prefab
      description file */
  Prefab (const std::string& filename);

  /** Create a prefab object from a given uid, name must be the uniq
      identifer of the prefab, like "stony-entrance", not a
      filename.

      FIXME: a bit confusing with the constructor... */
  static Prefab* create (const std::string& uid);

  /** @return the descriptive name of this prefabe (shown in the
      selection) */
  std::string get_name ();

  /** @return the uniq identifer of this prefab */
  std::string get_uid ();

  /** @return a description of this prefab, where and how it should be
      used and things like that. */
  std::string get_description ();

  /** @return a pointer to the WorldObjData of this Prefab */
  WorldObjData* get_data ();
  
private:
  Prefab (const Prefab&);
  Prefab operator= (const Prefab&);
};

} // namespace EditorNS

#endif

/* EOF */

--- prefab_data.hxx DELETED ---





reply via email to

[Prev in Thread] Current Thread [Next in Thread]