00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library 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 GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * ピクチャパス変更フィルタ実装 00022 * @author Junpee 00023 */ 00024 00025 #include "LampBasic.h" 00026 #include "Graphics/SceneFilter/ChangePicturePathFilter/\ 00027 ChangePicturePathFilter.h" 00028 #include "Core/Utility/StringTokenizer.h" 00029 #include "Graphics/Picture/PictureManager.h" 00030 #include "Core/InputOutput/FilePath.h" 00031 00032 namespace Lamp{ 00033 00034 //------------------------------------------------------------------------------ 00035 // コンストラクタ 00036 ChangePicturePathFilter::ChangePicturePathFilter(Scene* scene) : 00037 SceneFilterInterface(scene){ 00038 } 00039 //------------------------------------------------------------------------------ 00040 // デストラクタ 00041 ChangePicturePathFilter::~ChangePicturePathFilter(){ 00042 } 00043 //------------------------------------------------------------------------------ 00044 // フィルタ 00045 bool ChangePicturePathFilter::filter(const String& command){ 00046 StringTokenizer tokenizer_(command); 00047 if(!tokenizer_.hasMoreTokens()){ 00048 ErrorOut("ChangePicturePathFilter::filter() Not found filter name"); 00049 return false; 00050 } 00051 String filterName = tokenizer_.getNextToken(); 00052 if(filterName != "ChangePicturePath"){ 00053 ErrorOut("ChangePicturePathFilter::filter() Invalid filter name %s", 00054 filterName.getBytes()); 00055 return false; 00056 } 00057 if(!tokenizer_.hasMoreTokens()){ 00058 ErrorOut("ChangePicturePathFilter::filter() Not found change path"); 00059 return false; 00060 } 00061 path_ = tokenizer_.getNextToken(); 00062 return filterPicture(); 00063 } 00064 //------------------------------------------------------------------------------ 00065 // ピクチャのフィルタ 00066 bool ChangePicturePathFilter::filterPicture(){ 00067 int count = pictureManager_->getCount(); 00068 // 各ピクチャのチェック 00069 for(int i = 0; i < count; i++){ 00070 Picture* picture = pictureManager_->get(i); 00071 FilePath filePath(picture->getPath()); 00072 picture->setPath(path_ + filePath.getFileName()); 00073 } 00074 return true; 00075 } 00076 //------------------------------------------------------------------------------ 00077 } // End of namespace Lamp 00078 //------------------------------------------------------------------------------