/** * @fn void AnimationManager::addAnim(std::shared_ptr<Animation> animation, const char filename[], std::vector< sf::Rect<int> > rects, const char name[]) * * @brief Adds an animation. * * @param animation The animation. * @param filename Filename of the file. * @param rects The rectangles. * @param name The name. */ void AnimationManager::addAnim(std::shared_ptr<Animation> animation, const char filename[], std::vector< sf::Rect<int> > rects, const char name[]) { //Convertion const char to string std::string stringFilename( filename, strlen(filename)); std::string stringName( name, strlen(name)); std::shared_ptr<Anim> anim = createAnim(stringFilename, rects, stringName); animation->addAnim(name, anim); }
// -------------------------------------------------------- // Print content to out stream ostream& BSquare:: print(ostream& out) const { out << "BSquare " + stringName() + ": "; out << "in "; for (std::vector<Cluster*>::const_iterator it = clu.begin(); it < clu.end(); it++) { out << (*it)->stringName(); if (it != clu.end() - 1 ) out << ", "; else out << "; "; } Square::print(out); return out; }
void ShaderD3D::setMatrix(const char* name, const MatrixFloat& mat) const { MatrixFloat matrix = mat.transpose(); std::string stringName(name); if (stringName.compare("worldMatrix") == 0) { m_Matrices.worldMatrix = matrix; } else if (stringName.compare("normalWorldMatrix") == 0) { m_Matrices.normalWorldMatrix = matrix; } else if (stringName.compare("viewMatrix") == 0) { m_Matrices.viewMatrix = matrix; } else if (stringName.compare("projMatrix") == 0) { m_Matrices.projMatrix = matrix; } mapConstantBufferMatrix(); }
void DirModel::fetchMore(const QModelIndex &parent) { qDebug() << "DirModel::fetchMore parent:" << parent << "Name:" << data(parent, Qt::DisplayRole); qDebug() << "DirModel::fetchMore parents parent:" << parent.parent(); QModelIndex parentTraversal = parent; QString pathTillRoot; do { qDebug() << "parent traversal.."; QVariant currentName = data(parent, Qt::DisplayRole); QString stringName("/"); if(currentName.canConvert(QVariant::String)) { stringName.prepend(currentName.toString()); pathTillRoot.prepend(stringName); } parentTraversal = parent.parent(); } while(parentTraversal.isValid() && parent != parentTraversal); ParentHelper* idx = static_cast<ParentHelper*>(parentTraversal.internalPointer()); if(!idx) { qFatal("(ParentHelper) Failed to do parent lookup."); } KDirectory* rootDir = d->m_lister->directory(idx->row); if(!rootDir) { qFatal("(KDirectory) Failed to do parent lookup."); } QString newUrl = rootDir->url() + pathTillRoot; d->m_lister->openUrl(newUrl); // qDebug() << "--> root dir:" << rootDir->url(); // qDebug() << "--> pathTillRoot:" << pathTillRoot; }
std::string RtMidiOut :: getPortName( unsigned int portNumber ) { unsigned int nDevices = midiOutGetNumDevs(); if ( portNumber >= nDevices ) { std::ostringstream ost; ost << "RtMidiOut::getPortName: the 'portNumber' argument (" << portNumber << ") is invalid."; errorString_ = ost.str(); error( RtError::INVALID_PARAMETER ); } MIDIOUTCAPS deviceCaps; midiOutGetDevCaps( portNumber, &deviceCaps, sizeof(MIDIOUTCAPS)); // For some reason, we need to copy character by character with // UNICODE (thanks to Eduardo Coutinho!). //std::string stringName = std::string( deviceCaps.szPname ); char nameString[MAXPNAMELEN]; for( int i=0; i<MAXPNAMELEN; ++i ) nameString[i] = (char)( deviceCaps.szPname[i] ); std::string stringName( nameString ); return stringName; }
bool XMLConfigurationFileHandler::startElement( const QString & , const QString & name, const QString & , const QXmlAttributes & attributes) { string stringName(toString(name)); XMLCFGLOGINIT; LTRACE << "start element " << stringName; // set the current module name and create its entry if necessary if (stringName == string("module")) { m_moduleName = attributes.value("name").toUtf8().constData(); LTRACE << "XMLConfigurationFileHandler::startElement module name is " << m_moduleName; if ((m_configuration. find(m_moduleName)) == (m_configuration. end())) { m_configuration.insert(make_pair(m_moduleName, ModuleConfigurationStructure(m_moduleName))); } } // set the current group name inside moduleName and creates its entry if necessary else if (stringName == "group") { m_groupName = toString(attributes.value("name")); LTRACE << "group name is " << m_groupName; int32_t indName=attributes.index("name"); // index for the attribute 'name' (not always the first) m_configuration.addGroupNamedForModuleNamed(m_groupName, m_moduleName); for (int32_t i=0;i<attributes.length();i++) { if (i==indName) { // if attribute 'name', ignored (already treated) continue; } string key=toString(attributes.localName(i)); string value=toString(attributes.value(i)); m_configuration.addAttributeForGroupInModule(key,value,m_groupName,m_moduleName); } } // creates a new parameter inside the current module and group else if (stringName == "param") { string key = toString(attributes.value("key")); string value = toString(attributes.value("value")); LTRACE << "param key is " << key; m_configuration.addParamValuePairForModuleAndGroup(key, value, m_moduleName, m_groupName); } else if (stringName == "list") { m_listName = toString(attributes.value("name")); LTRACE << "list name is " << m_listName; m_firstItem=true; m_itemWithAttributes=false; } else if (stringName == "item") { uint32_t nbAtt=attributes.length(); if (m_firstItem) { // decide if list is simple list or list of items with attributes if (nbAtt==1) { LTRACE << "add simple list "<< m_listName; m_configuration.addListNamedForModuleAndGroup(m_listName, m_moduleName, m_groupName); } else { LTRACE << "add list of items with attributes"<< m_listName; m_configuration.addListOfItemsForModuleAndGroup(m_listName, m_moduleName, m_groupName); m_itemWithAttributes=true; } m_firstItem=false; } else if (nbAtt>1 && !m_itemWithAttributes) { // was indeed in list of item with attributes => has to change m_configuration.changeListToListOfItems(m_listName,m_moduleName,m_groupName); m_itemWithAttributes=true; } if (m_itemWithAttributes) { string itemName=toString(attributes.value("value")); ItemWithAttributes item(itemName); for (uint32_t i=1; i<nbAtt; i++) { item.addAttribute(toString(attributes.localName(i)), toString(attributes.value(i))); } m_configuration.addItemInListOfItemsForModuleAndGroup(item, m_listName, m_moduleName, m_groupName); } else { string value = toString(attributes.value("value")); m_configuration.addItemInListNamedForModuleAndGroup(value, m_listName, m_moduleName, m_groupName); } } else if (stringName == "map") { m_mapName = toString(attributes.value("name")); LTRACE << "map name is " << m_mapName; m_firstItem=true; m_itemWithAttributes=false; } else if (stringName == "entry") { LTRACE << "entry in map"; uint32_t nbAtt=attributes.length(); if (m_firstItem) { // decide if map is simple map or map of entries with attributes if (nbAtt==2) { // name+value => simple map LTRACE << "add map list "<< m_mapName.c_str(); m_configuration.addMapNamedForModuleAndGroup(m_mapName,m_moduleName,m_groupName); } else { LTRACE << "add map of items with attributes "<< m_mapName; m_configuration.addMapOfItemsForModuleAndGroup(m_mapName,m_moduleName,m_groupName); m_itemWithAttributes=true; } m_firstItem=false; } else if (nbAtt>2 && !m_itemWithAttributes) { // was indeed in list of item with attributes => has to change m_configuration.changeMapToMapOfItems(m_mapName,m_moduleName,m_groupName); m_itemWithAttributes=true; } if (m_itemWithAttributes) { string key=toString(attributes.value("key")); string value=toString(attributes.value("value")); ItemWithAttributes item(value); for (uint32_t i=1; i<nbAtt; i++) { string attName=toString(attributes.localName(i)); if (attName != "key" && attName != "value") { item.addAttribute(attName, toString(attributes.value(i))); } } m_configuration.addEntryInMapOfItemsForModuleAndGroup(key,item,m_mapName,m_moduleName,m_groupName); } else { string key = toString(attributes.value("key")); string value = toString(attributes.value("value")); m_configuration.addEntryInMapNamedForModuleAndGroup(key,value,m_mapName,m_moduleName,m_groupName); } } return true; }
void LootItemTemplate::readObject(lua_State* L) { minimumLevel = LuaParser::getIntField(L, "minimumLevel"); maximumLevel = LuaParser::getIntField(L, "maximumLevel"); customObjectName = LuaParser::getStringField(L, "customObjectName"); directObjectTemplate = LuaParser::getStringField(L, "directObjectTemplate"); lua_pushstring(L, "craftingValues"); lua_gettable(L, -2); if (lua_istable(L, -1) == 1) { int n = luaL_getn(L, -1); for (int i = 1; i <= n; ++i) { lua_rawgeti(L, -1, i); if (lua_istable(L, -1) == 1) { lua_rawgeti(L, -1, 1); QString subGroupTitle(lua_tostring(L, -1)); experimentalSubGroupTitles.append(subGroupTitle); lua_pop(L, 1); lua_rawgeti(L, -1, 2); float min = lua_tonumber(L, -1); experimentalMin.append(min); lua_pop(L, 1); lua_rawgeti(L, -1, 3); float max = lua_tonumber(L, -1); experimentalMax.append(max); lua_pop(L, 1); if (luaL_getn(L, -1) > 3) { lua_rawgeti(L, -1, 4); float max = lua_tonumber(L, -1); experimentalPrecision.append(max); lua_pop(L, 1); } else experimentalPrecision.append(0); } lua_pop(L, 1); } } lua_pop(L, 1); lua_pushstring(L, "customizationStringNames"); lua_gettable(L, -2); if (lua_istable(L, -1) == 1) { int n = luaL_getn(L, -1); for (int i = 1; i <= n; ++i) { lua_rawgeti(L, -1, i); QString stringName(lua_tostring(L, -1)); customizationStringNames.append(stringName); lua_pop(L, 1); } } lua_pop(L, 1); lua_pushstring(L, "customizationValues"); lua_gettable(L, -2); if (lua_istable(L, -1) == 1) { int n = luaL_getn(L, -1); for (int i = 1; i <= n; ++i) { lua_rawgeti(L, -1, i); if (lua_istable(L, -1) == 1) { int c = luaL_getn(L, -1); for (int j = 1; j <= c; ++j) { lua_rawgeti(L, -1, j); if (j == 1) { quint8 min = lua_tonumber(L, -1); customizationValueMin.append(min); } else if (j == c) { quint8 max = lua_tonumber(L, -1); customizationValueMax.append(max); } lua_pop(L, 1); } } lua_pop(L, 1); } } lua_pop(L, 1); lua_pushstring(L, "skillMods"); lua_gettable(L, -2); if (lua_istable(L, -1) == 1) { int n = luaL_getn(L, -1); for (int i = 1; i <= n; ++i) { lua_rawgeti(L, -1, i); if (lua_istable(L, -1) == 1) { int c = luaL_getn(L, -1); for (int j = 1; j <= c; ++j) { lua_rawgeti(L, -1, j); if (j == 1) { QString skillName = lua_tostring(L, -1); skillModsNames.append(skillName); } else if (j == 2) { quint8 value = lua_tonumber(L, -1); skillModsValues.append(value); } lua_pop(L, 1); } } lua_pop(L, 1); } } lua_pop(L, 1); }