本文整理汇总了C++中CTexture::getPatch方法的典型用法代码示例。如果您正苦于以下问题:C++ CTexture::getPatch方法的具体用法?C++ CTexture::getPatch怎么用?C++ CTexture::getPatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTexture
的用法示例。
在下文中一共展示了CTexture::getPatch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeTexture
/* TextureXPanel::removeTexture
* Removes any selected textures
*******************************************************************/
void TextureXPanel::removeTexture()
{
// Get selected textures
vector<long> selection = list_textures->getSelection();
// Begin recording undo level
undo_manager->beginRecord("Remove Texture(s)");
// Go through selection backwards
for (int a = selection.size() - 1; a >= 0; a--)
{
// Remove texture from patch table entries
CTexture* tex = texturex.getTexture(selection[a]);
for (unsigned p = 0; p < tex->nPatches(); p++)
tx_editor->patchTable().patch(tex->getPatch(p)->getName()).removeTextureUsage(tex->getName());
// Record undo step
undo_manager->recordUndoStep(new TextureCreateDeleteUS(this, tex, false));
// Remove texture from list
texturex.removeTexture(selection[a]);
}
// End recording undo level
undo_manager->endRecord(true);
// Clear selection & refresh
list_textures->clearSelection();
list_textures->updateList();
texture_editor->clearTexture();
// Update variables
modified = true;
}
示例2: openTEXTUREX
/* TextureXPanel::openTEXTUREX
* Loads a TEXTUREx or TEXTURES format texture list into the editor
*******************************************************************/
bool TextureXPanel::openTEXTUREX(ArchiveEntry* entry)
{
// Open texture list (check format)
if (entry->getType()->getFormat() == "texturex")
{
// TEXTURE1/2 format
if (!texturex.readTEXTUREXData(entry, tx_editor->patchTable()))
return false;
// Create default texture editor
texture_editor = new TextureEditorPanel(this, tx_editor);
// Update patch table usage info
for (size_t a = 0; a < texturex.nTextures(); a++)
{
CTexture* tex = texturex.getTexture(a);
// Go through texture's patches
for (size_t p = 0; p < tex->nPatches(); p++)
tx_editor->patchTable().patch(tex->getPatch(p)->getName()).used_in.push_back(tex->getName());
}
}
else
{
// TEXTURES format
if (!texturex.readTEXTURESData(entry))
return false;
// Create extended texture editor
texture_editor = new ZTextureEditorPanel(this, tx_editor);
// Add 'type' column
list_textures->InsertColumn(2, "Type");
}
tx_entry = entry;
// Add texture editor area
GetSizer()->Add(texture_editor, 1, wxEXPAND|wxALL, 4);
texture_editor->setupLayout();
// Update format label
label_tx_format->SetLabel("Format: " + texturex.getTextureXFormatString());
// Update texture list
list_textures->updateList();
return true;
}
示例3: paste
/* 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;
}
示例4: writeTEXTUREXData
//.........这里部分代码省略.........
// Check for WorldPanning flag
if (tex->world_panning)
txdef.flags |= TX_WORLDPANNING;
// Write texture definition
SAFEFUNC(txdata.write(&txdef, 22));
break;
}
case TXF_NAMELESS:
{
// Create nameless texture definition
nltdef_t txdef;
txdef.flags = 0;
txdef.scale[0] = (tex->getScaleX()*8);
txdef.scale[1] = (tex->getScaleY()*8);
txdef.width = tex->getWidth();
txdef.height = tex->getHeight();
txdef.columndir[0] = 0;
txdef.columndir[1] = 0;
txdef.patchcount = tex->nPatches();
// Write texture definition
SAFEFUNC(txdata.write(&txdef, 8));
break;
}
case TXF_STRIFE11:
{
// Create strife format texture definition
stdef_t txdef;
memset(txdef.name, 0, 8); // Set texture name to all 0's (to ensure compatibility with XWE)
strncpy(txdef.name, CHR(tex->getName().Upper()), tex->getName().Len());
txdef.flags = 0;
txdef.scale[0] = (tex->getScaleX()*8);
txdef.scale[1] = (tex->getScaleY()*8);
txdef.width = tex->getWidth();
txdef.height = tex->getHeight();
txdef.patchcount = tex->nPatches();
// Check for WorldPanning flag
if (tex->world_panning)
txdef.flags |= TX_WORLDPANNING;
// Write texture definition
SAFEFUNC(txdata.write(&txdef, 18));
break;
}
default: return false;
}
// Write patch references
for (size_t k = 0; k < tex->nPatches(); ++k) {
// Get patch to write
CTPatch* patch = tex->getPatch(k);
// Create patch definition
tx_patch_t pdef;
pdef.left = patch->xOffset();
pdef.top = patch->yOffset();
// Check for 'invalid' patch
if (patch->getName().StartsWith("INVPATCH")) {
// Get raw patch index from name
string number = patch->getName();
number.Replace("INVPATCH", "");
long index;
number.ToLong(&index);
pdef.patch = index;
}
else
pdef.patch = patch_table.patchIndex(patch->getName()); // Note this will be -1 if the patch doesn't exist in the patch table. This should never happen with the texture editor, though.
// Write common data
SAFEFUNC(txdata.write(&pdef, 6));
// In non-Strife formats, there's some added rubbish
if (txformat != TXF_STRIFE11) {
foo = 0;
SAFEFUNC(txdata.write(&foo, 4));
}
}
}
// Write offsets
SAFEFUNC(txdata.seek(4, SEEK_SET));
SAFEFUNC(txdata.write(offsets, 4*numtextures));
// Write data to the TEXTUREx entry
texturex->importMemChunk(txdata);
// Update entry type
EntryType::detectEntryType(texturex);
// Clean up
delete[] offsets;
return true;
}