00001 //////////////////////////////////////////////////////////////////////////////// 00002 // Scorched3D (c) 2000-2009 00003 // 00004 // This file is part of Scorched3D. 00005 // 00006 // Scorched3D is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // Scorched3D is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with Scorched3D; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 //////////////////////////////////////////////////////////////////////////////// 00020 00021 #include <GLW/GLWWindowSkinManager.h> 00022 #include <GLW/GLWWindowManager.h> 00023 #include <XML/XMLFile.h> 00024 #include <common/Defines.h> 00025 00026 GLWWindowSkinManager *GLWWindowSkinManager::defaultinstance_ = 0; 00027 GLWWindowSkinManager *GLWWindowSkinManager::modinstance_ = 0; 00028 00029 GLWWindowSkinManager *GLWWindowSkinManager::defaultinstance() 00030 { 00031 if (!defaultinstance_) defaultinstance_ = new GLWWindowSkinManager(); 00032 return defaultinstance_; 00033 } 00034 00035 GLWWindowSkinManager *GLWWindowSkinManager::modinstance() 00036 { 00037 if (!modinstance_) modinstance_ = new GLWWindowSkinManager(); 00038 return modinstance_; 00039 } 00040 00041 GLWWindowSkinManager::GLWWindowSkinManager() 00042 { 00043 } 00044 00045 GLWWindowSkinManager::~GLWWindowSkinManager() 00046 { 00047 } 00048 00049 bool GLWWindowSkinManager::loadWindows() 00050 { 00051 XMLFile file; 00052 std::string fileName = S3D::getDataFile("data/windows.xml"); 00053 if (!file.readFile(fileName) || 00054 !file.getRootNode()) 00055 { 00056 S3D::dialogMessage("GLWWindowSkinManager", S3D::formatStringBuffer( 00057 "Failed to parse \"%s\"\n%s", 00058 fileName.c_str(), 00059 file.getParserError())); 00060 return false; 00061 } 00062 00063 // Itterate all of the windows in the file 00064 std::list<XMLNode *>::iterator childrenItor; 00065 std::list<XMLNode *> &children = file.getRootNode()->getChildren(); 00066 for (childrenItor = children.begin(); 00067 childrenItor != children.end(); 00068 childrenItor++) 00069 { 00070 // For each node named window 00071 XMLNode *currentNode = (*childrenItor); 00072 00073 GLWWindowSkin *window = new GLWWindowSkin; 00074 if (!window->initFromXML(currentNode)) 00075 { 00076 return false; 00077 } 00078 00079 if (!currentNode->failChildren()) return false; 00080 windows_.push_back(window); 00081 } 00082 00083 return true; 00084 } 00085 00086 std::list<GLWWindowSkin *> GLWWindowSkinManager::getStateWindows(const char *state) 00087 { 00088 std::list<GLWWindowSkin *> windows; 00089 std::list<GLWWindowSkin *>::iterator itor; 00090 for (itor = windows_.begin(); 00091 itor != windows_.end(); 00092 itor++) 00093 { 00094 GLWWindowSkin *window = (GLWWindowSkin *) *itor; 00095 if (window->inState(state)) 00096 { 00097 windows.push_back(window); 00098 } 00099 } 00100 return windows; 00101 }
1.5.3