TextureModificationUS(TextureXPanel* tx_panel, CTexture* texture) : tx_panel(tx_panel) { tex_copy = new CTexture(); tex_copy->copyTexture(texture); tex_copy->setState(texture->getState()); index = tx_panel->txList().textureIndex(tex_copy->getName()); }
/* TextureXPanel::paste * Pastes any textures on the clipboard after the last selected * texture *******************************************************************/ void TextureXPanel::paste() { // Check there is anything on the clipboard if (theClipboard->nItems() == 0) return; // Get last selected index int selected = list_textures->getLastSelected(); if (selected == -1) selected = texturex.nTextures() - 1; // Add to end of the list if nothing selected // Begin recording undo level undo_manager->beginRecord("Paste Texture(s)"); // Go through clipboard items for (unsigned a = 0; a < theClipboard->nItems(); a++) { // Skip if not a texture clipboard item if (theClipboard->getItem(a)->getType() != CLIPBOARD_COMPOSITE_TEXTURE) continue; // Get texture item TextureClipboardItem* item = (TextureClipboardItem*)(theClipboard->getItem(a)); // Add new texture after last selected item CTexture* ntex = new CTexture((texturex.getFormat() == TXF_TEXTURES)); ntex->copyTexture(item->getTexture(), true); ntex->setState(2); texturex.addTexture(ntex, ++selected); // Record undo step undo_manager->recordUndoStep(new TextureCreateDeleteUS(this, ntex, true)); // Deal with patches for (unsigned p = 0; p < ntex->nPatches(); p++) { CTPatch* patch = ntex->getPatch(p); // Update patch table if necessary if (texturex.getFormat() != TXF_TEXTURES) tx_editor->patchTable().addPatch(patch->getName()); // Get the entry for this patch ArchiveEntry* entry = patch->getPatchEntry(tx_editor->getArchive()); // If the entry wasn't found in any open archive, try copying it from the clipboard // (the user may have closed the archive the original patch was in) if (!entry) { entry = item->getPatchEntry(patch->getName()); // Copy the copied patch entry over to this archive if (entry) tx_editor->getArchive()->addEntry(entry, "patches", true); } // If the entry exists in the base resource archive or this archive, do nothing else if (entry->getParent() == theArchiveManager->baseResourceArchive() || entry->getParent() == tx_editor->getArchive()) continue; // Otherwise, copy the entry over to this archive else tx_editor->getArchive()->addEntry(entry, "patches", true); } } // End recording undo level undo_manager->endRecord(true); // Refresh list_textures->updateList(); // Update variables modified = true; }