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_data.hxx,NONE,1.1 resource_mod


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src prefab_data.hxx,NONE,1.1 resource_modifier.cxx,NONE,1.1 resource_modifier.hxx,NONE,1.1
Date: 26 Jun 2002 09:40:34 -0000

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

Added Files:
        prefab_data.hxx resource_modifier.cxx resource_modifier.hxx 
Log Message:
- fixed a few bugs in the rot/flip code
- load save of rot/flip surfaces seems to work
- background color bug on rot/flip surfaces needs a fix in clanlib

--- NEW FILE: prefab_data.hxx ---
//  $Id: prefab_data.hxx,v 1.1 2002/06/26 09:40:32 grumbel Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 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_DATA_HXX
#define HEADER_PREFAB_DATA_HXX

#include "libxmlfwd.hxx"
#include "worldobj_data.hxx"
#include "res_descriptor.hxx"

/** A prefab is a group of WorldObj's which form a bigger object, like
    a generic entrance with background and foreground layer. The
    prefab itself is just an WorldObjGroupData or a list of
    WorldObjData. This class supports some additional information for
    a prefab. Like the location of the thumbnail of it and a name for
    it. This class is manly used to load prefab files into memory. */
class PrefabData : public WorldObjData
{
protected:
  /** A descriptive name of the prefab */
  std::string   name;

  /** The location of a thumbnail for this prefab */
  ResDescriptor thumbnail_desc;

  /** The WorldObjData that represents the prefab itself */
  WorldObjData* data;

public:
  PrefabData (xmlDocPtr doc, xmlNodePtr cur);
};

#endif

/* EOF */

--- NEW FILE: resource_modifier.cxx ---
//  $Id: resource_modifier.cxx,v 1.1 2002/06/26 09:40:32 grumbel Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 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 <assert.h>
#include "resource_modifier.hxx"

namespace Pingus
{
  ResourceModifier horizontal_flip (ResourceModifier modifier)
  {
    switch (modifier)
      {
      case ROT0:
        return ROT0FLIP;
      case ROT90:
        return ROT90FLIP;
      case ROT180:
        return ROT180FLIP;      
      case ROT270:
        return ROT270FLIP;
      case ROT0FLIP:
        return ROT0;
      case ROT90FLIP:
        return ROT90;
      case ROT180FLIP:
        return ROT180;
      case ROT270FLIP:
        return ROT270;
      default:
        assert (0);
        return ROT0;
      }
  }

  ResourceModifier vertical_flip (ResourceModifier modifier)
  {
    switch (modifier)
      {
      case ROT0:
        return ROT180FLIP;
      case ROT90:
        return ROT270FLIP;
      case ROT180:
        return ROT0FLIP;
      case ROT270:
        return ROT90FLIP;
      case ROT0FLIP:
        return ROT180;
      case ROT90FLIP:
        return ROT270;
      case ROT180FLIP:
        return ROT0;
      case ROT270FLIP:
        return ROT90;
      default:
        assert (0);
        return ROT0;
      }
  }

  ResourceModifier rotate_90 (ResourceModifier modifier)
  {
    switch (modifier)
      {
      case ROT0:
        return ROT90;
      case ROT90:
        return ROT180;
      case ROT180:
        return ROT270;                  
      case ROT270:
        return ROT0;
      case ROT0FLIP:
        return ROT270FLIP;
      case ROT90FLIP:
        return ROT0FLIP;
      case ROT180FLIP:
        return ROT90FLIP;
      case ROT270FLIP:
        return ROT180FLIP;
      default:
        assert (0);
        return ROT0;
      }
  }

  ResourceModifier rotate_270 (ResourceModifier modifier)
  {
    switch (modifier)
      {
      case ROT0:
        return ROT270;
      case ROT90:
        return ROT0;
      case ROT180:
        return ROT90;   
      case ROT270:
        return ROT180;
      case ROT0FLIP:
        return ROT90FLIP;
      case ROT90FLIP:
        return ROT180FLIP;
      case ROT180FLIP:
        return ROT270FLIP;
      case ROT270FLIP:
        return ROT0FLIP;
      default:
        assert (0);
        return ROT0;
      }
  }

  std::string rs_to_string (ResourceModifier modifier)
  {
    switch (modifier)
      {
      case ROT0:
        return "ROT0";
      case ROT90:
        return "ROT90";
      case ROT180:
        return "ROT180";        
      case ROT270:
        return "ROT270";
      case ROT0FLIP:
        return "ROT0FLIP";
      case ROT90FLIP:
        return "ROT90FLIP";
      case ROT180FLIP:
        return "ROT180FLIP";
      case ROT270FLIP:
        return "ROT270FLIP";
      default:
        assert (0);
        return "--Error--";
      } 
  }

  ResourceModifier rs_from_string (const std::string& modifier)
  {
    if (modifier == "ROT0")
      return ROT0;
    else if (modifier == "ROT90")
      return ROT90;
    else if (modifier == "ROT180")
      return ROT180;
    else if (modifier == "ROT270")
      return ROT270;
    else if (modifier == "ROT0FLIP")
      return ROT0FLIP;
    else if (modifier == "ROT90FLIP")
      return ROT90FLIP;
    else if (modifier == "ROT180FLIP")
      return ROT180FLIP;
    else if (modifier == "ROT270FLIP")
      return ROT270FLIP;
    else
      {
        assert (0);
        return ROT0;
      }
  }
}

/* EOF */

--- NEW FILE: resource_modifier.hxx ---
//  $Id: resource_modifier.hxx,v 1.1 2002/06/26 09:40:32 grumbel Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 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_PINGUS_RESOURCE_MODIFIER_HXX
#define HEADER_PINGUS_RESOURCE_MODIFIER_HXX

#include <string>

namespace Pingus
{

  /** This array contains possible modifications of a surface */
  typedef enum {  
    ROT0,     
    ROT90,
    ROT180,
    ROT270,
    ROT0FLIP,
    ROT90FLIP,
    ROT180FLIP,
    ROT270FLIP
  } ResourceModifier;

  ResourceModifier horizontal_flip (ResourceModifier);
  ResourceModifier vertical_flip (ResourceModifier);
  ResourceModifier rotate_90 (ResourceModifier);
  ResourceModifier rotate_270 (ResourceModifier);

  // we don't specialize the to_string templates here, since the enum
  // might get confused with 'int'
  std::string rs_to_string (ResourceModifier);
  ResourceModifier rs_from_string (const std::string&);
}

#endif

/* EOF */




reply via email to

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