| 2148 | } |
| 2149 | |
| 2150 | void TSShapeConstructor::ChangeSet::write(TSShape* shape, Stream& stream, const String& savePath) |
| 2151 | { |
| 2152 | // First make a copy of the change-set |
| 2153 | ChangeSet output; |
| 2154 | for ( S32 i = 0; i < mCommands.size(); i++ ) |
| 2155 | output.add(mCommands[i]); |
| 2156 | |
| 2157 | // Remove all __backup__ sequences (used during Shape Editing) |
| 2158 | if (shape) |
| 2159 | { |
| 2160 | for (S32 i = 0; i < shape->sequences.size(); i++) |
| 2161 | { |
| 2162 | const char* seqName = shape->getName( shape->sequences[i].nameIndex ); |
| 2163 | if ( dStrStartsWith( seqName, "__backup__" ) ) |
| 2164 | { |
| 2165 | Command cmd( "removeSequence" ); |
| 2166 | cmd.addArgs( seqName ); |
| 2167 | output.add( cmd ); |
| 2168 | } |
| 2169 | } |
| 2170 | } |
| 2171 | |
| 2172 | // Write the final change set to the stream |
| 2173 | for (U32 i = 0; i < output.mCommands.size(); i++) |
| 2174 | { |
| 2175 | const Command& cmd = output.mCommands[i]; |
| 2176 | |
| 2177 | // Write the command |
| 2178 | stream.writeTabs( 1 ); |
| 2179 | stream.writeText( "%this." ); |
| 2180 | |
| 2181 | stream.writeText( cmd.name ); |
| 2182 | stream.writeText( "(" ); |
| 2183 | |
| 2184 | if ( cmd.argc > 0 ) |
| 2185 | { |
| 2186 | // Use relative paths when possible |
| 2187 | String str( cmd.argv[0] ); |
| 2188 | if ( str.startsWith( savePath ) ) |
| 2189 | { |
| 2190 | // Need to add "./" to a local file for the script file system. Otherwise |
| 2191 | // it will be assumed to be a full and complete path when it comes to loading. |
| 2192 | str = "./" + str.substr( savePath.length() + 1 ); |
| 2193 | } |
| 2194 | |
| 2195 | stream.writeText( "\"" ); |
| 2196 | stream.write( str.length(), str.c_str() ); |
| 2197 | stream.writeText( "\"" ); |
| 2198 | |
| 2199 | // Write remaining arguments and newline |
| 2200 | for (U32 j = 1; j < cmd.argc; j++) |
| 2201 | { |
| 2202 | // Use relative paths when possible |
| 2203 | String str( cmd.argv[j] ); |
| 2204 | if ( str.startsWith( savePath ) ) |
| 2205 | str = str.substr( savePath.length() + 1 ); |
| 2206 | |
| 2207 | stream.writeText( ", \"" ); |
no test coverage detected