void WiiPlatform::Compile(Sprite *obj) { bfs::create_directories(obj->GetOutputPath().parent_path()); std::ostringstream files; std::ostringstream alphas; std::map<const char*, int, LowerThanStringComparator> frames; int id = 0; int as = obj->GetSize(); for (int a = 0; a < as; a++) { Animation *anim = obj->GetAnimation(a); int fs = anim->GetSize(); for (int f = 0; f < fs; f++) { const Frame *frame = anim->GetFrame(f); if (frames.find(frame->GetFilename()) == frames.end()) { frames[frame->GetFilename()] = 1; files << "file " << id << " = " << frame->GetFilename() << ".tga\n"; if (!frame->HasAlpha()) alphas << "image " << id << " = " << id << ", x, RGBA8\n"; else alphas << "image " << id << " = " << id << ", " << id << ", RGBA8\n"; id++; } } } for (int i = 0; i < id; i++) { char tex[32]; snprintf(tex, 32, "texture %d = %d, x\n", id, id); } std::ostringstream fileTmp; fileTmp << "tmp" << PLATFORM_PATH_SEPARATOR_STR << "tmp.tcs"; FILE *fp = fopen(fileTmp.str().c_str(), "w+"); fprintf(fp, "path = %s\\\n", e->GetInputPath(RESOURCE_IMAGE).string().c_str()); fprintf(fp, "%s", files.str().c_str()); fprintf(fp, "%s", alphas.str().c_str()); for (int i = 0; i < id; i++) fprintf(fp, "texture %d = %d, x\n", i, i); fclose(fp); // xunxo mode on /*std::ostringstream tplOut; tplOut << e->GetOutputPath() << PLATFORM_PATH_SEPARATOR_STR << obj->GetName() << PLATFORM_WII_OUTPUT_IMG_EXT; pCache->AddFilename(tplOut.str().c_str());*/ std::ostringstream cmd; cmd << this->GetName() << PLATFORM_PATH_SEPARATOR_STR << "texconv tmp" << PLATFORM_PATH_SEPARATOR_STR << "tmp.tcs "; cmd << e->GetOutputPath() << PLATFORM_PATH_SEPARATOR_STR << obj->GetName() << PLATFORM_WII_OUTPUT_IMG_EXT; BOOL valid = TRUE; for (u32 i = 0; i < obj->GetSize(); i++) { Animation *anim = obj->GetAnimation(i); if (!anim) continue; for (u32 j = 0; j < anim->GetSize(); j++) { Frame *frame = const_cast<Frame*>(anim->GetFrame(j)); if (!frame) continue; // a regular 1024x1024x32 TGA texture has a size of 4MB const Image *img = frame->GetImage(); if (bfs::file_size(img->GetInputPath()) / (1024 * 1024) >= 4) { valid = FALSE; break; } } if (!valid) break; } if (valid) { std::ostringstream tplOut; tplOut << e->GetOutputPath() << PLATFORM_PATH_SEPARATOR_STR << obj->GetName() << PLATFORM_WII_OUTPUT_IMG_EXT; pCache->AddFilename(tplOut.str().c_str()); RUN_COMMAND(cmd); } // xm off if (e->IsCompressionEnabled() && valid) { bfs::path wiiToolsPath(this->GetName()); bfs::path pathNewExtension = obj->GetOutputPath(); pathNewExtension.replace_extension(".lh"); std::ostringstream foo; foo << e->GetOutputPath() << PLATFORM_PATH_SEPARATOR_STR << obj->GetName() << PLATFORM_WII_OUTPUT_IMG_EXT; bfs::path inputTPL(foo.str()); cmd.str(""); //cmd << (wiiToolsPath / LZFTOOL).string() << " \""; // file_string cmd << (wiiToolsPath / COMPRESSTOOL).string() << " \""; // file_string cmd << foo.str(); cmd << "\" -o \"" << pathNewExtension << "\""; RUN_COMMAND(cmd); bfs::remove(inputTPL); bfs::rename(pathNewExtension, inputTPL); } }