FreeImage & FreeImage::operator=( const FreeImage & image ) { this -> fileName = image.fileName; #ifdef WIN32 this -> fileNameW = image.fileNameW; #endif this -> size = size; this -> invertY = image.invertY; this -> loadingType = image.loadingType; this -> BPP = image.BPP; this -> loadingFormat = image.loadingFormat; this -> resampleFilter = image.resampleFilter; if ( image.isLoaded() ) { lock(); this -> freeImage = FreeImage_Clone( image.freeImage ); setLoaded( true ); unlock(); } else { this -> freeImage = image.freeImage; //Probably NULL setLoaded( false ); } if ( this -> freeImage ) this -> stride = FreeImage_GetPitch( this -> freeImage ); else this -> stride = 0; return *this; }
void Card::setAll(const char* allch) { String all = allch; int indexof = all.find(delim); if (indexof > -1) { setQuantity(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(delim); setText(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(delim); setThumb(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(delim); setFront(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(delim); setBack(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(delim); setId(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(delim); setRate(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(delim); setValue(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(delim); setNote(all.substr(0,indexof++).c_str()); all=all.substr(indexof); setLoaded(true); if ((getText().length() <= 0)||(getQuantity().length() <= 0)) { setQuantity(""); setText(""); setLoaded(false); } } else { setQuantity(""); setText(""); setThumb(""); setFront(""); setBack(""); setId(""); setRate(""); setValue(""); setNote(""); setLoaded(false); } }
// @mfunc Load the persisted representation of this // <c OMStrongObjectReference>. void OMStrongObjectReference::load(void) { TRACE("OMStrongObjectReference::load"); PRECONDITION("Not already loaded", !isLoaded()); PRECONDITION("Valid container property", _property != 0); // open the sub-storage // OMStorable* containingObject = _property->propertySet()->container(); OMStoredObject* store = containingObject->store(); ASSERT("Valid store", store != 0); OMStoredObject* subStorage = store->open(_name); // restore referenced object from the sub-storage // OMStorable* object = subStorage->restoreObject(*this); ASSERT("Object properly restored", object != 0); // place a pointer to the newly restored object in this element // setValue(object); setLoaded(); // notify the client that the object has just been restored // ASSERT("Valid containing property", _property != 0); OMFile* file = _property->propertySet()->container()->file(); ASSERT("Valid file", file != 0); _pointer->onRestore(file->clientOnSaveContext()); POSTCONDITION("Property properly loaded", isLoaded()); }
// @mfunc Set the value of this <c OMStrongObjectReference>. // The value is a pointer to the referenced <c OMStorable>. // @parm A pointer to the new <c OMStorable>. // @rdesc A pointer to previous <c OMStorable>, if any. OMStorable* OMStrongObjectReference::setValue(const OMStorable* value) { TRACE("OMStrongObjectReference::setValue"); PRECONDITION("Valid container property", _property != 0); // Detach the old object // OMStorable* oldObject = _pointer; if (oldObject != 0) { oldObject->detach(); } // Set the element to contain the new object // _pointer = const_cast<OMStorable*>(value); OMStorable* newObject = _pointer; // Attach the new object // if (newObject != 0) { OMStorable* container = _property->propertySet()->container(); newObject->attach(container, _name); } setLoaded(); POSTCONDITION("Element properly set", _pointer == newObject); return oldObject; }
/* ArchiveEntry::importMem * Imports a chunk of memory into the entry, resizing it and clearing * any currently existing data. * Returns false if data pointer is invalid, true otherwise *******************************************************************/ bool ArchiveEntry::importMem(const void* data, uint32_t size) { // Check parameters if (!data) return false; // Check if locked if (locked) { Global::error = "Entry is locked"; return false; } // Clear any current data clearData(); // Copy data into the entry this->data.importMem((const uint8_t*)data, size); // Update attributes this->size = size; setLoaded(); setType(EntryType::unknownType()); setState(1); return true; }
void FreeImage::loadFromDatas( unsigned char * datas, const Math::Vec2<Size> & size, Format format, bool datasInvertY ) { unload(); lock(); setLoading( true ); _updateFormat( format ); this -> size = size; this -> invertY = datasInvertY; this -> loadingType = LoadingType::EMPTY; this -> fileName.clear(); //we have no reason to keep a filepath now. #ifdef WIN32 this -> fileNameW.clear(); //we have no reason to keep a filepath now. #endif // WIN32 #ifdef WIN32 if ( format == Format::RGB || format == Format::RGBA ) { //because FreeImage do not care of MASK and use BGR on Windows size_t numPixels = this -> size.x * this -> size.y; size_t offsetPerPixel = ( this -> BPP / 8 ); unsigned char * newDatas = new unsigned char[offsetPerPixel * numPixels]; auto otherIt = datas; auto thisIt = newDatas; if ( format == Format::RGB ) { for ( size_t i = 0; i < numPixels; i++ ) { thisIt[0] = otherIt[2]; thisIt[1] = otherIt[1]; thisIt[2] = otherIt[0]; otherIt += offsetPerPixel; thisIt += offsetPerPixel; } } else if ( format == Format::RGBA ) { for ( size_t i = 0; i < numPixels; i++ ) { thisIt[0] = otherIt[2]; thisIt[1] = otherIt[1]; thisIt[2] = otherIt[0]; thisIt[3] = otherIt[3]; otherIt += offsetPerPixel; thisIt += offsetPerPixel; } } this -> freeImage = FreeImage_ConvertFromRawBits( newDatas, this -> size.x, this -> size.y, this -> size.x * ( this -> BPP / 8 ), this -> BPP, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, this -> invertY ); delete[] newDatas; } else { this -> freeImage = FreeImage_ConvertFromRawBits( datas, this -> size.x, this -> size.y, this -> size.x * ( this -> BPP / 8 ), this -> BPP, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, this -> invertY ); } #else this -> freeImage = FreeImage_ConvertFromRawBits( datas, this -> size.x, this -> size.y, this -> size.x * ( this -> BPP / 8 ), this -> BPP, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, this -> invertY ); #endif this -> stride = FreeImage_GetPitch( this -> freeImage ); setLoading( false ); setLoaded( true ); unlock(); }
//============================================================================== AztecDVBR_Matrix::~AztecDVBR_Matrix(){ if (isAllocated()) { delete [] Amat_->val; delete [] Amat_->bindx; delete [] Amat_->rpntr; delete [] Amat_->bpntr; delete [] Amat_->indx; delete [] remoteInds_; delete [] remoteBlockSizes_; setAllocated(false); } if (isLoaded()) { free(Amat_->cpntr); free(external_); free(extern_index_); free(update_index_); free(data_org_); delete [] orderingUpdate_; setLoaded(false); } delete [] nnzPerRow_; localNNZ_ = 0; AZ_matrix_destroy(&Amat_); Amat_ = NULL; }
void Texture::finalize() { if(mImage == NULL || mImage->getData() == NULL || !mImage->loaded()) { Console::Print(Console::Error, "Failed to load texture: Image wasn't loaded."); return; } //Cleanup the GL texture if any was loaded unload(); //Generate and bind a new texture glGenTextures(1, &mTexture); glBindTexture(GL_TEXTURE_2D, mTexture); //bind(); //DEBUGPRINT("Finalizing OpenGL texture %u", mTexture); GLenum glpixelformat = 0; switch(mImage->getPixelFormat()) { case Image::PixelFormat_RGB: { glpixelformat = GL_RGB; //DEBUGPRINT("Image pixelformat is: RGB", 0); } break; case Image::PixelFormat_RGBA: { glpixelformat = GL_RGBA; //DEBUGPRINT("Image pixelformat is: RGBA", 0); } break; default: { Console::Print(Console::Error, "Failed to load texture: Unknown pixel format given."); return; } } mWidth = (float) mImage->getWidth(); mHeight = (float) mImage->getHeight(); DEBUGPRINT("Texture size is %f %f", mWidth, mHeight); glPixelStorei (GL_UNPACK_ALIGNMENT, 1); //gluBuild2DMipmaps(GL_TEXTURE_2D, 4, textureLoader.getWidth(), textureLoader.getHeight(), glpixelformat, GL_UNSIGNED_BYTE, buffer.get()); glTexImage2D(GL_TEXTURE_2D, 0, glpixelformat, mImage->getWidth(), mImage->getHeight(), 0, glpixelformat, GL_UNSIGNED_BYTE, mImage->getData()->get()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); //Remove our reference to this image so it can be unloaded when no longer in use. mImage = EMPTY_IMAGE; //Mark this texture as loaded so the sprite can render. setLoaded(); }
bool tryLoading() { if (load()) { setLoaded(true); return true; } else return false; }
void RaceScene::destroy() { if (m_initialized) { delete m_logic; m_logic = NULL; delete m_graphics; m_graphics = NULL; setLoaded(false); m_initialized = false; } }
// @mfunc Detach this <c OMStrongObjectReference>. void OMStrongObjectReference::detach(void) { TRACE("OMStrongObjectReference::detach"); if (_pointer != 0) { _pointer->detach(); } // So that an attempt to access an unloaded object that has been // detached results in a void reference (there is an inaccessible // persisted representation of the object). // setLoaded(); }
// @mfunc Close this <c OMStrongObjectReference>. void OMStrongObjectReference::close(void) { TRACE("OMStrongObjectReference::close"); if (_pointer != 0) { _pointer->close(); } // So that an attempt to access an unloaded object after the file // has been closed results in a void reference (there is an // inaccessible persisted representation of the object). // setLoaded(); }
void IndexPage::loadPage(BufferManager* manager) { Buffer* buffer = manager->getBuffer(bufferIndex()); buffer->seek(bufferPos()); __int32 bsize = buffer->readInt(); char* data = buffer->readChars(); MemoryStream* helperStream = new MemoryStream(data, bsize); helperStream->seek(0); helperStream->readInt(); // BUCKET_MAX_ELEMENTS size = helperStream->readInt(); IndexPage* tempPointer = NULL; for (int x = 0; x < BUCKET_MAX_ELEMENTS; x++) { Index* index = retrieveIndexElement(helperStream); elements[x] = index; tempPointer = retrievePointer(helperStream); pointers[x] = tempPointer; if (tempPointer != NULL) { tempPointer->parentElement = this; } } // Recovers the last pointer tempPointer = retrievePointer(helperStream); pointers[BUCKET_MAX_ELEMENTS] = tempPointer; if (tempPointer != NULL) { tempPointer->parentElement = this; } // Recovers siblings leftSibling = retrievePointer(helperStream); rightSibling = retrievePointer(helperStream); setLoaded(true); /* for (int x = 0; x <= BUCKET_MAX_ELEMENTS; x++) { IndexPage* temp = page->pointers[x]; if ((temp != NULL) && (temp->bufferIndex() > -1)) { loadPage(temp); } } */ delete helperStream; }
/* ArchiveEntry::unloadData * 'Unloads' entry data from memory *******************************************************************/ void ArchiveEntry::unloadData() { // Check there is any data to be 'unloaded' if (!data.hasData() || !data_loaded) return; // Only unload if the data wasn't modified if (getState() > 0) return; // Delete any data data.clear(); // Update variables etc setLoaded(false); }
//----------------------------------------------------------------------------- // loadFromFile() //----------------------------------------------------------------------------- BOOL LLMuteList::loadFromFile(const std::string& filename) { if(!filename.size()) { llwarns << "Mute List Filename is Empty!" << llendl; return FALSE; } LLFILE* fp = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ if (!fp) { llwarns << "Couldn't open mute list " << filename << llendl; return FALSE; } // *NOTE: Changing the size of these buffers will require changes // in the scanf below. char id_buffer[MAX_STRING]; /*Flawfinder: ignore*/ char name_buffer[MAX_STRING]; /*Flawfinder: ignore*/ char buffer[MAX_STRING]; /*Flawfinder: ignore*/ while (!feof(fp) && fgets(buffer, MAX_STRING, fp)) { id_buffer[0] = '\0'; name_buffer[0] = '\0'; S32 type = 0; U32 flags = 0; sscanf( /* Flawfinder: ignore */ buffer, " %d %254s %254[^|]| %u\n", &type, id_buffer, name_buffer, &flags); LLUUID id = LLUUID(id_buffer); LLMute mute(id, std::string(name_buffer), (LLMute::EType)type, flags); if (mute.mID.isNull() || mute.mType == LLMute::BY_NAME) { mLegacyMutes.insert(mute.mName); } else { mMutes.insert(mute); } } fclose(fp); setLoaded(); return TRUE; }
//============================================================================== void AztecDVBR_Matrix::loadComplete() { // // This is where we call the Aztec function AZ_transform, which calculates // communication parameters and re-orders the equations for use as a // global distributed matrix. // MPI_Comm thisComm = amap_->getCommunicator(); // Sync processors. MPI_Barrier(thisComm); #ifndef FEI_SER int thisProc = 0; MPI_Comm_rank(thisComm, &thisProc); #endif AZ_transform(amap_->getProcConfig(), &external_, Amat_->bindx, Amat_->val, amap_->getBlockUpdate(), &update_index_, &extern_index_, &data_org_, N_update_, Amat_->indx, Amat_->bpntr, Amat_->rpntr, &(Amat_->cpntr), AZ_VBR_MATRIX); data_org_[AZ_internal_use] = 1; Amat_->data_org = data_org_; //On return from AZ_transform, the array update_index_ contains a mapping //to the local re-ordering of the indices of the update_ array. Now we will //fill the orderingUpdate array with the reverse of that mapping. i.e., a //record of how to get back to the original ordering of the update indices. orderingUpdate_ = new int[N_update_]; for(int ii=0; ii<N_update_; ii++) orderingUpdate_[update_index_[ii]] = ii; // Sync processors. #ifndef FEI_SER MPI_Barrier(thisComm); #endif setLoaded(true); return; }
bool ObjectBuilderAsset::load() { ASSERT(getLoaded() == false, "Attempt to load already loaded asset!"); ASSERT(getPath() != NULL, "Attempt to load an asset with no path!"); if (!getLoaded() && getPath()) { LoaderSystem* loaderSystem = getSystem<LoaderSystem>(); if (loaderSystem) { ObjectHandle<ObjectBuilder> builder = loaderSystem->load(getPath()); if (builder) { setBuilder(builder); setLoaded(true); } } } return getLoaded(); }
/* ArchiveEntry::importFileStream * Imports [len] data from [file] *******************************************************************/ bool ArchiveEntry::importFileStream(wxFile& file, uint32_t len) { // Check if locked if (locked) { Global::error = "Entry is locked"; return false; } // Import data from the file stream if (data.importFileStream(file, len)) { // Update attributes this->size = data.getSize(); setLoaded(); setType(EntryType::unknownType()); setState(1); return true; } return false; }
TEST_F(ConfigTests, test_plugin_reconfigure) { auto& rf = RegistryFactory::get(); // Add a configuration plugin (could be any plugin) that will react to // config updates. rf.registry("config_parser") ->add("placebo", std::make_shared<PlaceboConfigParserPlugin>()); // Create a config that has been loaded. setLoaded(); get().update({{"data", "{}"}}); // Get the placebo. auto placebo = std::static_pointer_cast<PlaceboConfigParserPlugin>( rf.plugin("config_parser", "placebo")); EXPECT_EQ(placebo->configures, 1U); // Updating with the same content does not reconfigure parsers. get().update({{"data", "{}"}}); EXPECT_EQ(placebo->configures, 1U); // Updating with different content will reconfigure. get().update({{"data", "{\"options\":{}}"}}); EXPECT_EQ(placebo->configures, 2U); get().update({{"data", "{\"options\":{}}"}}); EXPECT_EQ(placebo->configures, 2U); // Updating with a new source will reconfigure. get().update({{"data", "{\"options\":{}}"}, {"data1", "{}"}}); EXPECT_EQ(placebo->configures, 3U); // Updating and not including a source is handled by the config plugin. // The config will expect the other source to update asynchronously and does // not consider the missing key as a delete request. get().update({{"data", "{\"options\":{}}"}}); EXPECT_EQ(placebo->configures, 3U); rf.registry("config_parser")->remove("placebo"); }
// ----------------------------------------------------------------------------- // Reads pod format data from a MemChunk // Returns true if successful, false otherwise // ----------------------------------------------------------------------------- bool PodArchive::open(MemChunk& mc) { // Check data was given if (!mc.hasData()) return false; // Read no. of files mc.seek(0, 0); uint32_t num_files; mc.read(&num_files, 4); // Read id mc.read(id_, 80); // Read directory vector<FileEntry> files(num_files); mc.read(files.data(), num_files * sizeof(FileEntry)); // Stop announcements (don't want to be announcing modification due to entries being added etc) setMuted(true); // Create entries UI::setSplashProgressMessage("Reading pod archive data"); for (unsigned a = 0; a < num_files; a++) { // Get the entry name as a wxFileName (so we can break it up) wxFileName fn(files[a].name); // Create entry auto new_entry = std::make_shared<ArchiveEntry>(fn.GetFullName(), files[a].size); new_entry->exProp("Offset") = files[a].offset; new_entry->setLoaded(false); // Add entry and directory to directory tree string path = fn.GetPath(false); auto ndir = createDir(path); ndir->addEntry(new_entry); new_entry->setState(ArchiveEntry::State::Unmodified); LOG_MESSAGE(5, "File size: %d, offset: %d, name: %s", files[a].size, files[a].offset, files[a].name); } // Detect entry types vector<ArchiveEntry*> all_entries; putEntryTreeAsList(all_entries); UI::setSplashProgressMessage("Detecting entry types"); for (unsigned a = 0; a < all_entries.size(); a++) { // Skip dir/marker if (all_entries[a]->size() == 0 || all_entries[a]->type() == EntryType::folderType()) { all_entries[a]->setState(ArchiveEntry::State::Unmodified); continue; } // Update splash window progress UI::setSplashProgress((float)a / (float)all_entries.size()); // Read data MemChunk edata; mc.exportMemChunk(edata, all_entries[a]->exProp("Offset").intValue(), all_entries[a]->size()); all_entries[a]->importMemChunk(edata); // Detect entry type EntryType::detectEntryType(all_entries[a]); // Unload entry data if needed if (!archive_load_data) all_entries[a]->unloadData(); // Set entry to unchanged all_entries[a]->setState(ArchiveEntry::State::Unmodified); LOG_MESSAGE(5, "entry %s size %d", CHR(all_entries[a]->name()), all_entries[a]->size()); } // Setup variables setMuted(false); setModified(false); announce("opened"); UI::setSplashProgressMessage(""); return true; }
BOOL LLMuteList::remove(const LLMute& mute, U32 flags) { BOOL found = FALSE; // First, remove from main list. mute_set_t::iterator it = mMutes.find(mute); if (it != mMutes.end()) { LLMute localmute = *it; bool remove = true; if(flags) { // If the user passed mute flags, we may only want to turn some flags on. localmute.mFlags |= flags; if(localmute.mFlags == LLMute::flagAll) { // Every currently available mute property has been masked out. // Remove the mute entry entirely. } else { // Only some of the properties are masked out. Update the entry. remove = false; } } else { // The caller didn't pass any flags -- just remove the mute entry entirely. } // Always remove the entry from the set -- it will be re-added with new flags if necessary. mMutes.erase(it); if(remove) { // The entry was actually removed. Notify the server. updateRemove(localmute); llinfos << "Unmuting " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << llendl; } else { // Flags were updated, the mute entry needs to be retransmitted to the server and re-added to the list. mMutes.insert(localmute); updateAdd(localmute); llinfos << "Updating mute entry " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << llendl; } // Must be after erase. setLoaded(); // why is this here? -MG } // Clean up any legacy mutes string_set_t::iterator legacy_it = mLegacyMutes.find(mute.mName); if (legacy_it != mLegacyMutes.end()) { // Database representation of legacy mute is UUID null. LLMute mute(LLUUID::null, *legacy_it, LLMute::BY_NAME); updateRemove(mute); mLegacyMutes.erase(legacy_it); // Must be after erase. setLoaded(); // why is this here? -MG } return found; }
// ----------------------------------------------------------------------------- // Reads wad format data from a MemChunk // Returns true if successful, false otherwise // ----------------------------------------------------------------------------- bool Wad2Archive::open(MemChunk& mc) { // Check data was given if (!mc.hasData()) return false; // Read wad header uint32_t num_lumps = 0; uint32_t dir_offset = 0; char wad_type[4] = ""; mc.seek(0, SEEK_SET); mc.read(&wad_type, 4); // Wad type mc.read(&num_lumps, 4); // No. of lumps in wad mc.read(&dir_offset, 4); // Offset to directory // Byteswap values for big endian if needed num_lumps = wxINT32_SWAP_ON_BE(num_lumps); dir_offset = wxINT32_SWAP_ON_BE(dir_offset); // Check the header if (wad_type[0] != 'W' || wad_type[1] != 'A' || wad_type[2] != 'D' || (wad_type[3] != '2' && wad_type[3] != '3')) { Log::error("Wad2Archive::open: Invalid header"); Global::error = "Invalid wad2 header"; return false; } if (wad_type[3] == '3') wad3_ = true; // Stop announcements (don't want to be announcing modification due to entries being added etc) setMuted(true); // Read the directory mc.seek(dir_offset, SEEK_SET); UI::setSplashProgressMessage("Reading wad archive data"); for (uint32_t d = 0; d < num_lumps; d++) { // Update splash window progress UI::setSplashProgress(((float)d / (float)num_lumps)); // Read lump info Wad2Entry info; mc.read(&info, 32); // Byteswap values for big endian if needed info.offset = wxINT32_SWAP_ON_BE(info.offset); info.size = wxINT32_SWAP_ON_BE(info.size); info.dsize = wxINT32_SWAP_ON_BE(info.dsize); // If the lump data goes past the end of the file, // the wadfile is invalid if ((unsigned)(info.offset + info.dsize) > mc.size()) { Log::error("Wad2Archive::open: Wad2 archive is invalid or corrupt"); Global::error = "Archive is invalid and/or corrupt"; setMuted(false); return false; } // Create & setup lump auto nlump = std::make_shared<ArchiveEntry>(wxString::FromAscii(info.name, 16), info.dsize); nlump->setLoaded(false); nlump->exProp("Offset") = (int)info.offset; nlump->exProp("W2Type") = info.type; nlump->exProp("W2Size") = (int)info.size; nlump->exProp("W2Comp") = !!(info.cmprs); nlump->setState(ArchiveEntry::State::Unmodified); // Add to entry list rootDir()->addEntry(nlump); } // Detect all entry types MemChunk edata; UI::setSplashProgressMessage("Detecting entry types"); for (size_t a = 0; a < numEntries(); a++) { // Update splash window progress UI::setSplashProgress((((float)a / (float)num_lumps))); // Get entry auto entry = entryAt(a); // Read entry data if it isn't zero-sized if (entry->size() > 0) { // Read the entry data mc.exportMemChunk(edata, (int)entry->exProp("Offset"), entry->size()); entry->importMemChunk(edata); } // Detect entry type EntryType::detectEntryType(entry); // Unload entry data if needed if (!archive_load_data) entry->unloadData(); // Set entry to unchanged entry->setState(ArchiveEntry::State::Unmodified); } // Detect maps (will detect map entry types) UI::setSplashProgressMessage("Detecting maps"); detectMaps(); // Setup variables setMuted(false); setModified(false); announce("opened"); UI::setSplashProgressMessage(""); return true; }
void LoadingOverlay::customActionAfterActivate() { //Make sure we display the correct percentage setLoaded(mLoadedValue, mLoadedMessage); }
//------------------------------------------------------------------------------ void Resource::unload() { setLoaded(false); }
//------------------------------------------------------------------------------ void Resource::load() { setLoaded(true); }
// ----------------------------------------------------------------------------- // Reads grp format data from a MemChunk // Returns true if successful, false otherwise // ----------------------------------------------------------------------------- bool GrpArchive::open(MemChunk& mc) { // Check data was given if (!mc.hasData()) return false; // Read grp header uint32_t num_lumps = 0; char ken_magic[13] = ""; mc.seek(0, SEEK_SET); mc.read(ken_magic, 12); // "KenSilverman" mc.read(&num_lumps, 4); // No. of lumps in grp // Byteswap values for big endian if needed num_lumps = wxINT32_SWAP_ON_BE(num_lumps); // Null-terminate the magic header ken_magic[12] = 0; // Check the header if (!(S_CMP(wxString::FromAscii(ken_magic), "KenSilverman"))) { Log::error(S_FMT("GrpArchive::openFile: File %s has invalid header", filename_)); Global::error = "Invalid grp header"; return false; } // Stop announcements (don't want to be announcing modification due to entries being added etc) setMuted(true); // The header takes as much space as a directory entry uint32_t entryoffset = 16 * (1 + num_lumps); // Read the directory UI::setSplashProgressMessage("Reading grp archive data"); for (uint32_t d = 0; d < num_lumps; d++) { // Update splash window progress UI::setSplashProgress(((float)d / (float)num_lumps)); // Read lump info char name[13] = ""; uint32_t offset = entryoffset; uint32_t size = 0; mc.read(name, 12); // Name mc.read(&size, 4); // Size name[12] = '\0'; // Byteswap values for big endian if needed size = wxINT32_SWAP_ON_BE(size); // Increase offset of next entry by this entry's size entryoffset += size; // If the lump data goes past the end of the file, // the grpfile is invalid if (offset + size > mc.size()) { Log::error("GrpArchive::open: grp archive is invalid or corrupt"); Global::error = "Archive is invalid and/or corrupt"; setMuted(false); return false; } // Create & setup lump auto nlump = std::make_shared<ArchiveEntry>(wxString::FromAscii(name), size); nlump->setLoaded(false); nlump->exProp("Offset") = (int)offset; nlump->setState(ArchiveEntry::State::Unmodified); // Add to entry list rootDir()->addEntry(nlump); } // Detect all entry types MemChunk edata; UI::setSplashProgressMessage("Detecting entry types"); for (size_t a = 0; a < numEntries(); a++) { // Update splash window progress UI::setSplashProgress((((float)a / (float)num_lumps))); // Get entry auto entry = entryAt(a); // Read entry data if it isn't zero-sized if (entry->size() > 0) { // Read the entry data mc.exportMemChunk(edata, getEntryOffset(entry), entry->size()); entry->importMemChunk(edata); } // Detect entry type EntryType::detectEntryType(entry); // Unload entry data if needed if (!archive_load_data) entry->unloadData(); // Set entry to unchanged entry->setState(ArchiveEntry::State::Unmodified); } // Setup variables setMuted(false); setModified(false); announce("opened"); UI::setSplashProgressMessage(""); return true; }
void Shader::load(const char *path) { std::string pathStr = path; FileInput vertexShaderFile; FileInput fragmentShaderFile; if( !vertexShaderFile.open(pathStr + ".vert") || !fragmentShaderFile.open(pathStr + ".frag") ) { Console::Print(Console::Error, "Could not load vertex shader %s.", path); return; } DEBUGPRINT("Reading shader sources",0); //Read the shader sources from file vertexShaderFile.read(mVertexShaderSrc); fragmentShaderFile.read(mFragmentShaderSrc); //DEBUGPRINT("Vertex shader %s", mVertexShaderSrc.c_str()); //Compile the shaders DEBUGPRINT("Compiling Vertex Shader %s.vert", path); GLuint vertexshader = loadShader(mVertexShaderSrc, GL_VERTEX_SHADER); if(vertexshader == 0) { Console::Print(Console::Error, "Could not compile vertex shader."); return; } DEBUGPRINT("Compiling Fragment Shader %s.frag", path); GLuint fragmentshader = loadShader(mFragmentShaderSrc, GL_FRAGMENT_SHADER); if(vertexshader == 0) { Console::Print(Console::Error, "Could not compile fragment shader."); return; } //Link the shaders together into a program. DEBUGPRINT("Linking program %s", path); mProgram = linkProgram(vertexshader, fragmentshader); if (mProgram == 0) { Console::Print(Console::Error, "Error linking program."); glDeleteShader(vertexshader); glDeleteShader(fragmentshader); return; } DEBUGPRINT("Program linked: %i", mProgram); //Decrease the reference count on our shader objects so they get //deleted when the program is deleted. glDeleteShader(vertexshader); glDeleteShader(fragmentshader); //Set up the uniform locations for the matrices in this shader mProjectionMatrixHandle = glGetUniformLocation(mProgram, SHADER_PROJECTION_MATRIX_NAME); mModelMatrixHandle = glGetUniformLocation(mProgram, SHADER_MODEL_MATRIX_NAME); mViewMatrixHandle = glGetUniformLocation(mProgram, SHADER_VIEW_MATRIX_NAME); mTexture0Handle = glGetUniformLocation(mProgram, SHADER_TEXTURE0_NAME); mColor = glGetUniformLocation(mProgram, SHADER_COLOR_NAME); DEBUGPRINT("Found %s at: %i", SHADER_PROJECTION_MATRIX_NAME, mProjectionMatrixHandle); DEBUGPRINT("Found %s at: %i", SHADER_MODEL_MATRIX_NAME, mModelMatrixHandle); DEBUGPRINT("Found %s at: %i", SHADER_VIEW_MATRIX_NAME, mViewMatrixHandle); DEBUGPRINT("Found Texture0 at: %i", mTexture0Handle); DEBUGPRINT("Found Color at: %i", mColor); //Bind our shader use(); //Set the default color glm::vec4 defaultcolor = glm::vec4(COLOR_DEFAULT); setColor(defaultcolor); //TODO: We should probably check if any of these are -1. If so, the shader is unusable. //Mark this shader as loaded so binding this shader works. setLoaded(); }
void ObjectBuilderAsset::unload() { setBuilder(NULL); setLoaded(false); }
void Feed::setAll(const char* allch) { if (strlen(allch) <= 0) { allch = ""; } String all = allch; int indexof = all.find(","); if (indexof > -1) { setUsername(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setEncrypt(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setUnsuccessful(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setReplaceWhiteSpaces(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setReplaceSpecialCharacters(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setCredits(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setEmail(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setHandle(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setTouch(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setSeconds(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setRegistered(all.substr(0,indexof++).c_str()); all=all.substr(indexof); indexof = all.find(","); setNoteSeconds(all.substr(0,indexof++).c_str()); all=all.substr(indexof); setLoaded(true); if ((getUsername().length() <= 0)||(getEncrypt().length() <= 0)) { setUsername(""); setEncrypt(""); setLoaded(false); } } else { setLoaded(false); setUsername(""); setEncrypt(""); setUnsuccessful(""); setReplaceWhiteSpaces(""); setReplaceSpecialCharacters(""); setCredits(""); setEmail(""); setHandle(""); setTouch("false"); setRegistered("0"); setNoteLoaded(false); setNoteSeconds(""); } }
// ----------------------------------------------------------------------------- // Reads lfd format data from a MemChunk // Returns true if successful, false otherwise // ----------------------------------------------------------------------------- bool LfdArchive::open(MemChunk& mc) { // Check data was given if (!mc.hasData()) return false; // Check size if (mc.size() < 16) return false; // Check magic header if (mc[0] != 'R' || mc[1] != 'M' || mc[2] != 'A' || mc[3] != 'P') return false; // Get directory length uint32_t dir_len = 0; mc.seek(12, SEEK_SET); mc.read(&dir_len, 4); dir_len = wxINT32_SWAP_ON_BE(dir_len); // Check size if ((unsigned)mc.size() < (dir_len) || dir_len % 16) return false; // Guess number of lumps uint32_t num_lumps = dir_len / 16; // Stop announcements (don't want to be announcing modification due to entries being added etc) setMuted(true); // Read each entry UI::setSplashProgressMessage("Reading lfd archive data"); size_t offset = dir_len + 16; size_t size = mc.size(); for (uint32_t d = 0; offset < size; d++) { // Update splash window progress UI::setSplashProgress(((float)d / (float)num_lumps)); // Read lump info uint32_t length = 0; char type[5] = ""; char name[9] = ""; mc.read(type, 4); // Type mc.read(name, 8); // Name mc.read(&length, 4); // Size name[8] = '\0'; type[4] = 0; // Move past the header offset += 16; // Byteswap values for big endian if needed length = wxINT32_SWAP_ON_BE(length); // If the lump data goes past the end of the file, // the gobfile is invalid if (offset + length > size) { LOG_MESSAGE(1, "LfdArchive::open: lfd archive is invalid or corrupt"); Global::error = "Archive is invalid and/or corrupt"; setMuted(false); return false; } // Create & setup lump wxFileName fn(name); fn.SetExt(type); auto nlump = std::make_shared<ArchiveEntry>(fn.GetFullName(), length); nlump->setLoaded(false); nlump->exProp("Offset") = (int)offset; nlump->setState(ArchiveEntry::State::Unmodified); // Add to entry list rootDir()->addEntry(nlump); // Move to next entry offset += length; mc.seek(offset, SEEK_SET); } if (num_lumps != numEntries()) LOG_MESSAGE(1, "Warning: computed %i lumps, but actually %i entries", num_lumps, numEntries()); // Detect all entry types MemChunk edata; UI::setSplashProgressMessage("Detecting entry types"); for (size_t a = 0; a < numEntries(); a++) { // Update splash window progress UI::setSplashProgress((((float)a / (float)num_lumps))); // Get entry auto entry = entryAt(a); // Read entry data if it isn't zero-sized if (entry->size() > 0) { // Read the entry data mc.exportMemChunk(edata, getEntryOffset(entry), entry->size()); entry->importMemChunk(edata); } // Detect entry type EntryType::detectEntryType(entry); // Unload entry data if needed if (!archive_load_data) entry->unloadData(); // Set entry to unchanged entry->setState(ArchiveEntry::State::Unmodified); } // Setup variables setMuted(false); setModified(false); announce("opened"); UI::setSplashProgressMessage(""); return true; }