1 /* 2 Copyright © 2015 Igor Paliychuk 3 4 This file is part of FLARE. 5 6 FLARE is free software: you can redistribute it and/or modify it under the terms 7 of the GNU General Public License as published by the Free Software Foundation, 8 either version 3 of the License, or (at your option) any later version. 9 10 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY 11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along with 15 FLARE. If not, see http://www.gnu.org/licenses/ 16 */ 17 18 /* 19 * class MapSaver 20 */ 21 22 #ifdef FLARE_MAP_SAVER 23 24 #ifndef MAP_SAVER_H 25 #define MAP_SAVER_H 26 27 #include "Map.h" 28 29 class MapSaver { 30 public: 31 MapSaver(Map* _map); 32 ~MapSaver(); 33 34 bool saveMap(std::string tileset_definitions); 35 bool saveMap(std::string file, std::string tileset_definitions); 36 37 private: 38 void writeHeader(std::ofstream& map_file); 39 void writeTilesets(std::ofstream& map_file, std::string tileset_definitions); 40 void writeLayers(std::ofstream& map_file); 41 void writeEnemies(std::ofstream& map_file); 42 void writeNPCs(std::ofstream& map_file); 43 void writeEvents(std::ofstream& map_file); 44 void writeEventComponents(std::ofstream& map_file, int eventID); 45 46 Map* map; 47 std::string dest_file; 48 49 static const int EC_COUNT = 43; 50 51 std::string EVENT_COMPONENT_NAME[EC_COUNT]; 52 53 class EC { 54 public: 55 enum { 56 NONE = 0, 57 TOOLTIP = 1, 58 POWER_PATH = 2, 59 POWER_DAMAGE = 3, 60 INTERMAP = 4, 61 INTRAMAP = 5, 62 MAPMOD = 6, 63 SOUNDFX = 7, 64 LOOT = 8, 65 LOOT_COUNT = 9, 66 MSG = 10, 67 SHAKYCAM = 11, 68 REQUIRES_STATUS = 12, 69 REQUIRES_NOT_STATUS = 13, 70 REQUIRES_LEVEL = 14, 71 REQUIRES_NOT_LEVEL = 15, 72 REQUIRES_CURRENCY = 16, 73 REQUIRES_NOT_CURRENCY = 17, 74 REQUIRES_ITEM = 18, 75 REQUIRES_NOT_ITEM = 19, 76 REQUIRES_CLASS = 20, 77 REQUIRES_NOT_CLASS = 21, 78 SET_STATUS = 22, 79 UNSET_STATUS = 23, 80 REMOVE_CURRENCY = 24, 81 REMOVE_ITEM = 25, 82 REWARD_XP = 26, 83 REWARD_CURRENCY = 27, 84 REWARD_ITEM = 28, 85 REWARD_LOOT = 29, 86 REWARD_LOOT_COUNT = 30, 87 RESTORE = 31, 88 POWER = 32, 89 SPAWN = 33, 90 STASH = 34, 91 NPC = 35, 92 MUSIC = 36, 93 CUTSCENE = 37, 94 REPEAT = 38, 95 SAVE_GAME = 39, 96 BOOK = 40, 97 SCRIPT = 41, 98 CHANCE_EXEC = 42, 99 RESPEC = 43, 100 }; 101 102 int type; 103 std::string s; 104 StatusID status; 105 int x; 106 int y; 107 int z; 108 int a; 109 int b; 110 int c; 111 float f; 112 EC()113 EC() 114 : type(NONE) 115 , s("") 116 , status(0) 117 , x(0) 118 , y(0) 119 , z(0) 120 , a(0) 121 , b(0) 122 , c(0) 123 , f(0) { 124 } 125 }; 126 127 }; 128 129 #endif //MAP_SAVER 130 131 #endif //FLARE_MAP_SAVER 132