MCPcopy Create free account
hub / github.com/DFHack/dfhack / save_generated_raw

Function save_generated_raw

plugins/generated-creature-renamer.cpp:203–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203command_result save_generated_raw(color_ostream &out, std::vector <std::string> & parameters)
204{
205#ifdef LINUX_BUILD
206 std::string pathSep = "/";
207#else
208 std::string pathSep = "\\";
209#endif
210 int pageWidth = 16;
211 int pageHeight = (descriptors.size() / pageWidth) + ((descriptors.size() % pageWidth > 0) ? 1 : 0);
212 int tileWidth = 24;
213 int tileHeight = 24;
214 std::string fileName = "graphics_procedural_creatures";
215 std::string pageName = "PROCEDURAL_FRIENDLY";
216 size_t repeats = 128;
217
218 std::ofstream outputFile(fileName + ".txt", std::ios::out | std::ios::trunc);
219
220 outputFile << fileName << endl << endl;
221
222 outputFile << "[OBJECT:GRAPHICS]" << endl << endl;
223
224 outputFile << "[TILE_PAGE:" << pageName << "]" << endl;
225 outputFile << " [FILE:procedural_friendly.png]" << endl;
226 outputFile << " [TILE_DIM:" << tileWidth << ":" << tileHeight << "]" << endl;
227 outputFile << " [PAGE_DIM:" << pageWidth << ":" << pageHeight << "]" << endl << endl;
228
229 for (size_t descIndex = 0; descIndex < descriptors.size(); descIndex++)
230 {
231 for (size_t prefIndex = 0; prefIndex < prefixes.size(); prefIndex++)
232 {
233 for (size_t rep = 0; rep < repeats; rep++)
234 {
235 auto descriptor = descriptors[descIndex];
236
237 for (size_t j = 0; j < descriptor.size(); j++)
238 {
239 if (descriptor[j] == ' ')
240 descriptor[j] = '_';
241 else
242 descriptor[j] = toupper(descriptor[j]);
243 }
244
245 auto prefix = prefixes[prefIndex];
246 if (prefix[prefix.length() - 1] != '_')
247 prefix.append("_");
248
249 std::string token = prefix + descriptor;
250 if (rep > 0)
251 token.append("_" + std::to_string(rep));
252
253 outputFile << "[CREATURE_GRAPHICS:" << token << "]" << endl;
254 outputFile << " [DEFAULT:" << pageName << ":" << descIndex % pageWidth << ":" << descIndex / pageWidth << ":ADD_COLOR]" << endl;
255 }
256 outputFile << endl;
257 }
258 outputFile << endl;
259 }
260

Callers

nothing calls this directly

Calls 4

toupperFunction · 0.85
lengthMethod · 0.80
sizeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected