ModulesManagementWidget::ModulesManagementWidget(ModulesManagement *nmodulesMgmt, QWidget *parent) : QWidget(parent) { ui = new(std::nothrow) Ui::ModulesManagementWidget(); if (ui == NULL) { qFatal("Cannot allocate memory for Ui::ModulesManagementWidget X{"); } modulesMgmt = nmodulesMgmt; moduleTitle = modulesMgmt->getLangName(); ui->setupUi(this); ui->infoLabel->setText(modulesMgmt->getInfos()); connect(modulesMgmt,SIGNAL(modulesUpdated()), this, SLOT(loadModules())); connect(modulesMgmt,SIGNAL(pathsUpdated()), this, SLOT(loadPaths())); connect(ui->modulesListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onModuleSelected(QListWidgetItem*))); connect(ui->loadPushButton, SIGNAL(clicked()), this, SLOT(onManualClicked())); loadPaths(); loadModules(); qDebug() << this << "created"; }
bool ResourceManager::LoadResources() { if (!loadPaths()) { LOGERROR("could not load Textures locations"); return false; } LOG("Beginning To Load Textures"); sf::Texture tmpTexture; int locationsCount = static_cast<int>(texturesLocations.size()); int requiredTexturesCount = (int)Textures::Texture::TexturesCount; LOG("Stored Locations Count = " + std::to_string(locationsCount)); LOG("Required Textures Count = " + std::to_string(requiredTexturesCount)); if (locationsCount != requiredTexturesCount) { LOGERROR("Texture Locations Variable count does not match the textures count"); return false; } for (auto itr = texturesLocations.begin(); itr != texturesLocations.end(); itr++) { if (!tmpTexture.loadFromFile(itr->second)) { LOGERROR("could not find texture : " + itr->second); return false; } LOG("Loaded Texture : " + itr->second); tmpTexture.setRepeated(false); tmpTexture.setSmooth(true); textures[itr->first] = std::move(tmpTexture); } return true; }
Items::Items() { loadPaths(item_paths, sprite_paths); //Pushes back empty sf::sprite/image pointers to vector //Loads files from item_paths (see loadPaths()) and sets sprites in item vector to load images for (unsigned int x=0; x<item_paths.size(); x++) { item_imgs.push_back(new sf::Image); items.push_back(new sf::Sprite); item_imgs[x]->LoadFromFile(item_paths[x]); items[x]->SetImage(*item_imgs[x]); } //Pushes back empty sf::image pointers to sf::image vector containing sprite images //Loads sprite images from the sprite paths for (unsigned int x=0; x<sprite_paths.size(); x++) { sprite_items.push_back(new sf::Image); sprite_spr.push_back(new sf::Sprite); sprite_items[x]->LoadFromFile(sprite_paths[x]); sprite_spr[x]->SetImage(*sprite_items[x]); std::cout << "Size: " << sprite_spr.size() << std::endl; } //slots.push_back(std::vector<sf::Sprite*>()); //Allocate space in 2d vector for sprites for (unsigned int x=0; x<8; x++) { slots.push_back(std::vector<sf::Sprite*>()); for (unsigned int y=0; y<10; y++) { slots[x].push_back(new sf::Sprite); } } for (unsigned int x=0; x<sprite_spr.size(); x++) { thumbspr[items[x]]=sprite_spr[x]; } //Push back sprite pointers for each left slot and initalize with coords for (unsigned int x=0; x<5; x++) { left_slots[x]=new sf::Sprite; } left_slots_initialize(left_slots); //Load and set inventory img inv_img.LoadFromFile("inventory/inventory.png"); inventory.SetImage(inv_img); //Load and set gold mouse over inventory img mouse_over_img.LoadFromFile("inventory/mouse_over.png"); mouse_over.SetImage(mouse_over_img); thumb_id_initialize(items,item_paths,thumb_id); ITEM_SIZE=32; }
//int CMapFileFilterXML::loadXMLData(QString filename) int CMapFileFilterXML::loadXMLData(const QByteArray & buffer) { // TODO_jp : Make sure Zone ID and level ID max value is set corretly QDomDocument doc ("map"); if (!doc.setContent( buffer)) { kDebug() << "Unable to open the map file, not a valid xml document"; // file.close(); return -1; } for (CMapPluginBase *plugin = m_mapManager->getPluginList()->first(); plugin!=0; plugin = m_mapManager->getPluginList()->next()) { plugin->loadAboutToStart(); } QDomElement docElem = doc.documentElement(); // Check that this version of the file can be loaded QDomElement e = readChildElement(&docElem,"Version"); if (!e.isNull()) { QString major = e.attribute("Major",""); QString minor = e.attribute("Minor",""); if (major != "1" || minor != "0") { //TODO_jp : Output error message kDebug() << "This version can't be loaded"; return -4; } } else { //TODO_jp : Output error message kDebug() << "Unable to find version"; return -2; } // Find Root Zone QDomElement rootZoneNode = readChildElement(&docElem,"Zone"); if (rootZoneNode.isNull()) { //TODO_jp : Output error message kDebug() << "Unable to find root zone"; return -2; } // Load Root Zone int errorZone =loadZone(&rootZoneNode,NULL); if (errorZone!=0) { return errorZone; } // Find Paths QDomElement pathsNode = readChildElement(&docElem,"Paths"); if (pathsNode.isNull()) { //TODO_jp : Output error message kDebug() << "Unable to find paths"; return -2; } // Load Paths int errorPath = loadPaths(&pathsNode); if (errorPath!=0) { return errorPath; } // Find Links QDomElement linksNode = readChildElement(&docElem,"Links"); if (pathsNode.isNull()) { //TODO_jp : Output error message kDebug() << "Unable to find links"; return -2; } int errorLinks = loadLinks(&linksNode); if (errorLinks!=0) { return errorLinks; } // Return no error return 0; }