Planeshift

pawstexturemanager.h

Go to the documentation of this file.
00001 /*
00002  * pawstexturemanager.h - Author: Andrew Craig
00003  *
00004  * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 // pawstexturemanager.h: interface for the pawsTextureManager class.
00020 //
00022 
00023 #ifndef PAWS_TEXTURE_MANAGER
00024 #define PAWS_TEXTURE_MANAGER
00025 
00026 #include <csutil/ref.h>
00027 #include <csutil/csstring.h>
00028 #include <csutil/objreg.h>
00029 #include <csutil/parray.h>
00030 #include <cstool/cspixmap.h>
00031 #include <igraphic/image.h>
00032 #include <csgeom/csrectrg.h>
00033 
00034 #include <ivideo/texture.h>
00035 #include <iutil/vfs.h>
00036 #include <iutil/document.h>
00037 
00038 class pawsTextureManager;
00039 
00044 struct iPawsImage : public virtual iBase
00045 {
00046     SCF_INTERFACE(iPawsImage, 1, 0, 0);
00047     virtual const char* GetName() const = 0;
00048 
00049     virtual void Draw(int x, int y, int alpha=-1) = 0;
00050     virtual void Draw(csRect rect, int alpha=-1) = 0;
00051     virtual void Draw(int x, int y, int newWidth, int newHeight, int alpha=-1) = 0;
00052 
00053     virtual int  GetWidth() const = 0;
00054     virtual int  GetHeight() const = 0;
00055     virtual void ExpandClipRect(csRect &clipRect) = 0;
00056 
00057     virtual int GetDefaultAlpha() const = 0;
00058     virtual bool IsLoaded() const = 0;
00059 };
00060 
00061 class pawsTextureManager
00062 {
00063 public:
00064     pawsTextureManager(iObjectRegistry* objectReg);
00065     virtual ~pawsTextureManager();
00066 
00081     bool LoadImageList(const char* listName);
00082 
00091     void Remove(const char* name);
00092 
00093     csPtr<iPawsImage> GetPawsImage(const char* name);
00094     csPtr<iPawsImage> GetOrAddPawsImage(const char* name);
00095     bool AddImage(const char* resource);
00096     void AddPawsImage(csRef<iPawsImage> &element);
00097 
00098 public:
00099     iObjectRegistry* objectReg;
00100 
00101     csRef<iVFS> vfs;
00102     csRef<iDocumentSystem>  xml;
00103 
00104     csHash<csRef<iPawsImage>, csString> elementList;
00105 };
00106 
00109 #endif
00110 
00111