1 /* 2 * Holotz's Castle 3 * Copyright (C) 2004 Juan Carlos Seijo P�rez 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License as published by the Free 7 * Software Foundation; either version 2 of the License, or (at your option) 8 * any later version. 9 * 10 * This program is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 59 17 * Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * 19 * Juan Carlos Seijo P�rez 20 * jacob@mainreactor.net 21 */ 22 23 /** Playlist for Holotz's castle. 24 * @file HCPlaylist.h 25 * @author Juan Carlos Seijo P�rez 26 * @date 25/08/2004 27 * @version 0.0.1 - 25/08/2004 - First version. 28 */ 29 30 #ifndef _HCPLAYLIST_INCLUDED 31 #define _HCPLAYLIST_INCLUDED 32 33 #include <vector> 34 #include <JLib/Util/JTypes.h> 35 #include <JLib/Util/JTextFile.h> 36 #include <JLib/Util/JObject.h> 37 #include <HCUtil.h> 38 39 #include <string.h> 40 41 #ifndef HC_DATA_DIR 42 #define HC_DATA_DIR "res/" 43 #endif 44 45 #define HCPLAYLIST_DEFFILENAME "playlist.txt" 46 47 class HCPlaylist 48 { 49 protected: 50 std::vector<char *> stories; /**< Playlist with the stories ordered. */ 51 s32 curStory; /**< Current story playing. */ 52 char storyDir[4096]; 53 54 public: 55 /** Creates an empty playlist object. Load must be called before using it. 56 */ HCPlaylist()57 HCPlaylist() : curStory(0) 58 { strncpy(storyDir, HC_DATA_DIR, sizeof(storyDir)); } 59 60 /** Return the current story directory. 61 */ StoryDir()62 const char * StoryDir() { return storyDir;} 63 64 /** Return the current story name. 65 */ StoryName()66 const char * StoryName() {return stories[curStory];} 67 68 /** Advances to the next story. 69 * @return <true> if there was another story, <b>false</b> otherwise. 70 */ 71 bool NextStory(); 72 73 /** Loads the playlist from the specified file. 74 * @param file Name of the file with the playlist. 75 * @return <b>true</b> if succeeded, <b>false</b>otherwise. 76 */ 77 bool Load(const char *file = HCPLAYLIST_DEFFILENAME); 78 79 /** Goes to the first story. 80 */ Reset()81 void Reset() {curStory = 0;} 82 83 /** Goes to the given story. 84 * @param _storyName Name of the story to go to. 85 * @return <b>true</b> if the story exists, <b>false</b> otherwise. 86 */ 87 bool GoTo(const char *_storyName); 88 89 /** Destroys the object. 90 */ 91 void Destroy(); 92 93 /** Returns the size of the playlist. 94 * @return Size of the playlist. 95 */ Size()96 s32 Size() {return stories.size();} 97 98 /** Returns the element at position index. 99 * @param index Position of the element to retrieve. 100 * @return Element at position index. 101 */ 102 char * operator[](s32 index) {return stories[index];} 103 104 /** Orders alphabetically the stories. 105 */ 106 void OrderStories(); 107 108 /** Destroys the object. 109 */ ~HCPlaylist()110 ~HCPlaylist() {Destroy();} 111 }; 112 113 #endif // _HCPLAYLIST_INCLUDED 114