MarketModel::MarketModel(QObject *parent) : QObject(parent), m_quoteUnit(USD), m_baseUnit(XTS) { //Initialize assetNames list for (int asset = 0; asset < AssetTypeCount; ++asset) m_assetNames.append(assetName(AssetType(asset))); emit assetNamesChanged(m_assetNames); }
/// Load texture data using the specified file name void Texture::threadedLoad(DELEGATE_CBK<void, CachedResource_wptr> onLoadCallback) { TextureLoadInfo info; // Each texture face/layer must be in a comma separated list stringstreamImpl textureLocationList(assetLocation()); stringstreamImpl textureFileList(assetName()); bool loadFromFile = false; vector<stringImpl> fileNames; // We loop over every texture in the above list and store it in this // temporary string stringImpl currentTextureFile; stringImpl currentTextureLocation; stringImpl currentTextureFullPath; while (std::getline(textureLocationList, currentTextureLocation, ',') && std::getline(textureFileList, currentTextureFile, ',')) { Util::Trim(currentTextureFile); // Skip invalid entries if (!currentTextureFile.empty()) { fileNames.push_back( (currentTextureLocation.empty() ? Paths::g_texturesLocation : currentTextureLocation) + "/" + currentTextureFile); _descriptor._sourceFileList.push_back(currentTextureFile); } } loadFromFile = !fileNames.empty(); hashMap<U64, ImageTools::ImageData> dataStorage; for(const stringImpl& file : fileNames) { // Attempt to load the current entry if (!loadFile(info, file, dataStorage[_ID(file.c_str())])) { // Invalid texture files are not handled yet, so stop loading return; } info._layerIndex++; if (_textureData._textureType == TextureType::TEXTURE_CUBE_ARRAY) { if (info._layerIndex == 6) { info._layerIndex = 0; info._cubeMapCount++; } } } if (loadFromFile) { if (_textureData._textureType == TextureType::TEXTURE_CUBE_MAP || _textureData._textureType == TextureType::TEXTURE_CUBE_ARRAY) { if (info._layerIndex != 6) { Console::errorfn( Locale::get(_ID("ERROR_TEXTURE_LOADER_CUBMAP_INIT_COUNT")), resourceName().c_str()); return; } } if (_textureData._textureType == TextureType::TEXTURE_2D_ARRAY || _textureData._textureType == TextureType::TEXTURE_2D_ARRAY_MS) { if (info._layerIndex != _numLayers) { Console::errorfn( Locale::get(_ID("ERROR_TEXTURE_LOADER_ARRAY_INIT_COUNT")), resourceName().c_str()); return; } } if (_textureData._textureType == TextureType::TEXTURE_CUBE_ARRAY) { if (info._cubeMapCount != _numLayers) { Console::errorfn( Locale::get(_ID("ERROR_TEXTURE_LOADER_ARRAY_INIT_COUNT")), resourceName().c_str()); return; } } } }
void parseArgs(int argc, char const *argv[]) { for (int i = 0; i < argc; ++i) { if (argv[i][0] == '-') { if (!strcmp(argv[i], "--size")) { sscanf_s(requireArg(argv, i), " %d x %d", &width, &height); } else if (!strcmp(argv[i], "--scale")) { char const *scl = requireArg(argv, i); float a = 0; float b = 0; int n = sscanf_s(scl, "%f / %f", &a, &b); if (n == 1) { b = 1; } if (n == 0 || b <= 0) { throw std::runtime_error(std::string("bad --scale argument: ") + scl); } gScale = a / b; } else if (!strcmp(argv[i], "--build-asset")) { build_asset(requireArg(argv, i)); quitAfterArgs = true; buildDeps = true; } else if (!strcmp(argv[i], "--quit")) { quitAfterArgs = true; } else if (!strcmp(argv[i], "--no-deps")) { noDeps = true; } else { goto unknown; } } else { unknown: throw std::runtime_error(std::string("Unknown argument: ") + argv[i]); } } if (buildDeps && !noDeps) { for (size_t i = 0; i != Reference::numBuiltItems(); ++i) { std::string assetName(Reference::builtItem(i)); build_asset(assetName); } } if (quitAfterArgs) { fprintf(stderr, "Done.\n"); exit(0); } }