00001 /* 00002 * Gui Skinning 00003 * Copyright (C) 2008 The Legend of Mazzeroth Development Team 00004 * Copyright (C) 2009 Aethyra Development Team 00005 * Copyright (C) 2009 The Mana World Development Team 00006 * 00007 * This file is part of The Mana World. 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 #ifndef SKIN_H 00025 #define SKIN_H 00026 00027 #include "graphics.h" 00028 00029 #include <map> 00030 #include <string> 00031 00032 class ConfigListener; 00033 class Image; 00034 00035 class Skin 00036 { 00037 public: 00038 Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, 00039 const std::string &filePath, 00040 const std::string &name = ""); 00041 00042 ~Skin(); 00043 00049 const std::string &getName() const { return mName; } 00050 00054 const std::string &getFilePath() const { return mFilePath; } 00055 00059 const ImageRect &getBorder() const { return mBorder; } 00060 00064 Image *getCloseImage() const { return mCloseImage; } 00065 00069 Image *getStickyImage(bool state) const 00070 { return state ? mStickyImageDown : mStickyImageUp; } 00071 00075 int getMinWidth() const; 00076 00080 int getMinHeight() const; 00081 00085 void updateAlpha(); 00086 00087 int instances; 00088 00089 private: 00090 std::string mFilePath; 00091 std::string mName; 00092 ImageRect mBorder; 00093 Image *mCloseImage; 00094 Image *mStickyImageUp; 00095 Image *mStickyImageDown; 00096 }; 00097 00098 class SkinLoader 00099 { 00100 public: 00101 static SkinLoader *instance(); 00102 static void deleteInstance(); 00103 00107 Skin *load(const std::string &filename, 00108 const std::string &defaultPath); 00109 00113 void updateAlpha(); 00114 00115 private: 00116 SkinLoader(); 00117 ~SkinLoader(); 00118 00119 Skin *readSkin(const std::string &filename); 00120 00121 // Map containing all window skins 00122 typedef std::map<std::string, Skin*> Skins; 00123 typedef Skins::iterator SkinIterator; 00124 00125 Skins mSkins; 00126 00130 ConfigListener *mSkinConfigListener; 00131 00132 static SkinLoader *mInstance; 00133 }; 00134 00135 #endif