本文整理汇总了C++中ArchiveTreeNode类的典型用法代码示例。如果您正苦于以下问题:C++ ArchiveTreeNode类的具体用法?C++ ArchiveTreeNode怎么用?C++ ArchiveTreeNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArchiveTreeNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ArchiveEntry
/* ArchiveTreeNode::merge
* Merges [node] with this node. Entries within [node] are added
* at [position] within this node. Returns false if [node] is invalid,
* true otherwise
*******************************************************************/
bool ArchiveTreeNode::merge(ArchiveTreeNode* node, unsigned position, int state)
{
// Check node was given to merge
if (!node)
return false;
// Merge entries
for (unsigned a = 0; a < node->numEntries(); a++)
{
if (node->getEntry(a))
{
string name = Misc::lumpNameToFileName(node->getEntry(a)->getName());
node->getEntry(a)->setName(name);
}
ArchiveEntry* nentry = new ArchiveEntry(*(node->getEntry(a)));
addEntry(nentry, position);
nentry->setState(state);
if (position < entries.size())
position++;
}
// Merge subdirectories
for (unsigned a = 0; a < node->nChildren(); a++)
{
ArchiveTreeNode* child = (ArchiveTreeNode*)STreeNode::addChild(node->getChild(a)->getName());
child->merge((ArchiveTreeNode*)node->getChild(a));
child->getDirEntry()->setState(state);
}
return true;
}
示例2: getDir
/* Archive::removeDir
* Deletes the directory matching [path], starting from [base]. If
* [base] is NULL, the root directory is used. Returns false if
* the directory does not exist, true otherwise
*******************************************************************/
bool Archive::removeDir(string path, ArchiveTreeNode* base)
{
// Abort if read only
if (read_only)
return false;
// Get the dir to remove
ArchiveTreeNode* dir = getDir(path, base);
// Check it exists (and that it isn't the root dir)
if (!dir || dir == getRoot())
return false;
// Record undo step
if (UndoRedo::currentlyRecording())
UndoRedo::currentManager()->recordUndoStep(new DirCreateDeleteUS(false, dir));
// Remove the directory from its parent
if (dir->getParent())
dir->getParent()->removeChild(dir);
// Delete the directory
delete dir;
// Set the archive state to modified
setModified(true);
return true;
}
示例3: fn
/* Archive::importDir
* Imports all files (including subdirectories) from [directory] into
* the archive
*******************************************************************/
bool Archive::importDir(string directory)
{
// Get a list of all files in the directory
wxArrayString files;
wxDir::GetAllFiles(directory, &files);
// Go through files
for (unsigned a = 0; a < files.size(); a++)
{
string name = files[a];
name.Replace(directory, "", false); // Remove directory from entry name
// Split filename into dir+name
wxFileName fn(name);
string ename = fn.GetFullName();
string edir = fn.GetPath();
// Remove beginning \ or / from dir
if (edir.StartsWith("\\") || edir.StartsWith("/"))
edir.Remove(0, 1);
// Add the entry
ArchiveTreeNode* dir = createDir(edir);
ArchiveEntry* entry = addNewEntry(ename, dir->numEntries()+1, dir);
// Load data
entry->importFile(files[a]);
// Set unmodified
entry->setState(0);
dir->getDirEntry()->setState(0);
}
return true;
}
示例4: importEditorImages
void importEditorImages(MapTexHashMap& map, ArchiveTreeNode* dir, string path)
{
SImage image;
// Go through entries
for (unsigned a = 0; a < dir->numEntries(); a++)
{
ArchiveEntry* entry = dir->getEntry(a);
// Load entry to image
if (image.open(entry->getMCData()))
{
// Create texture in hashmap
string name = path + entry->getName(true);
//wxLogMessage("Loading editor texture %s", CHR(name));
map_tex_t& mtex = map[name];
mtex.texture = new GLTexture(false);
mtex.texture->setFilter(GLTexture::MIPMAP);
mtex.texture->loadImage(&image);
}
}
// Go through subdirs
for (unsigned a = 0; a < dir->nChildren(); a++)
{
ArchiveTreeNode* subdir = (ArchiveTreeNode*)dir->getChild(a);
importEditorImages(map, subdir, path + subdir->getName() + "/");
}
}
示例5: loadLanguages
// ----------------------------------------------------------------------------
// TextLanguage::loadLanguages
//
// Loads all text language definitions from slade.pk3
// ----------------------------------------------------------------------------
bool TextLanguage::loadLanguages()
{
// Get slade resource archive
Archive* res_archive = App::archiveManager().programResourceArchive();
// Read language definitions from resource archive
if (res_archive)
{
// Get 'config/languages' directly
ArchiveTreeNode* dir = res_archive->getDir("config/languages");
if (dir)
{
// Read all entries in this dir
for (unsigned a = 0; a < dir->numEntries(); a++)
readLanguageDefinition(dir->entryAt(a)->getMCData(), dir->entryAt(a)->getName());
}
else
Log::warning(
1,
"Warning: 'config/languages' not found in slade.pk3, no builtin text language definitions loaded"
);
}
return true;
}
示例6: swapNames
void swapNames()
{
ArchiveTreeNode* dir = archive->getDir(path);
archive->renameDir(dir, old_name);
old_name = new_name;
new_name = dir->getName();
path = dir->getPath();
}
示例7: doSwap
bool doSwap()
{
// Get parent dir
ArchiveTreeNode* dir = archive->getDir(path);
if (dir)
return dir->swapEntries(index1, index2);
return false;
}
示例8: deleteEntry
bool deleteEntry()
{
// Get parent dir
ArchiveTreeNode* dir = archive->getDir(path);
if (dir)
return archive->removeEntry(dir->getEntry(index));
else
return false;
}
示例9: getConfigurationNames
/* ColourConfiguration::getConfigurationNames
* Adds all available colour configuration names to [names]
*******************************************************************/
void ColourConfiguration::getConfigurationNames(vector<string>& names)
{
// TODO: search custom folder
// Search resource pk3
Archive* res = theArchiveManager->programResourceArchive();
ArchiveTreeNode* dir = res->getDir("config/colours");
for (unsigned a = 0; a < dir->numEntries(); a++)
names.push_back(dir->getEntry(a)->getName(true));
}
示例10: removeEntry
/* Archive::removeEntry
* Removes [entry] from the archive. If [delete_entry] is true, the
* entry will also be deleted. Returns true if the removal succeeded
*******************************************************************/
bool Archive::removeEntry(ArchiveEntry* entry, bool delete_entry)
{
// Abort if read only
if (read_only)
return false;
// Check entry
if (!checkEntry(entry))
return false;
// Check if entry is locked
if (entry->isLocked())
return false;
// Get its directory
ArchiveTreeNode* dir = entry->getParentDir();
// Error if entry has no parent directory
if (!dir)
return false;
// Create undo step
if (UndoRedo::currentlyRecording())
UndoRedo::currentManager()->recordUndoStep(new EntryCreateDeleteUS(false, entry));
// Get the entry index
int index = dir->entryIndex(entry);
// Announce (before actually removing in case entry is still needed)
MemChunk mc;
wxUIntPtr ptr = wxPtrToUInt(entry);
mc.write(&index, sizeof(int));
mc.write(&ptr, sizeof(wxUIntPtr));
announce("entry_removing", mc);
// Remove it from its directory
bool ok = dir->removeEntry(index);
// If it was removed ok
if (ok)
{
// Announce removed
announce("entry_removed", mc);
// Delete if necessary
if (delete_entry)
delete entry;
// Update variables etc
setModified(true);
}
return ok;
}
示例11: swapEntries
/* Archive::swapEntries
* Swaps [entry1] and [entry2]. Returns false if either entry is
* invalid or if both entries are not in the same directory, true
* otherwise
*******************************************************************/
bool Archive::swapEntries(ArchiveEntry* entry1, ArchiveEntry* entry2)
{
// Abort if read only
if (read_only)
return false;
// Check both entries
if (!checkEntry(entry1) || !checkEntry(entry2))
return false;
// Check neither entry is locked
if (entry1->isLocked() || entry2->isLocked())
return false;
// Get their directory
ArchiveTreeNode* dir = entry1->getParentDir();
// Error if no dir
if (!dir)
return false;
// Check they are both in the same directory
if (entry2->getParentDir() != dir)
{
wxLogMessage("Error: Can't swap two entries in different directories");
return false;
}
// Get entry indices
int i1 = dir->entryIndex(entry1);
int i2 = dir->entryIndex(entry2);
// Check indices
if (i1 < 0 || i2 < 0)
return false;
// Create undo step
if (UndoRedo::currentlyRecording())
UndoRedo::currentManager()->recordUndoStep(new EntrySwapUS(dir, i1, i2));
// Swap entries
dir->swapEntries(i1, i2);
// Announce the swap
announce("entries_swapped");
// Set modified
setModified(true);
// Return success
return true;
}
示例12: doRedo
bool doRedo()
{
// Get entry parent dir
ArchiveTreeNode* dir = archive->getDir(entry_path);
if (dir)
{
// Rename entry
ArchiveEntry* entry = dir->getEntry(entry_index);
return archive->renameEntry(entry, new_name);
}
return false;
}
示例13: getEntry
// ----------------------------------------------------------------------------
// ArchiveEntryList::getItemText
//
// Called when the widget requests the text for [item] at [column]
// ----------------------------------------------------------------------------
string ArchiveEntryList::getItemText(long item, long column, long index) const
{
// Get entry
ArchiveEntry* entry = getEntry(index, false);
// Check entry
if (!entry)
return "INVALID INDEX";
// Determine what column we want
int col = columnType(column);
if (col == 0)
return entry->getName(); // Name column
else if (col == 1)
{
// Size column
if (entry->getType() == EntryType::folderType())
{
// Entry is a folder, return the number of entries+subdirectories in it
ArchiveTreeNode* dir = nullptr;
// Get selected directory
if (entry == entry_dir_back)
dir = (ArchiveTreeNode*)current_dir->getParent(); // If it's the 'back directory', get the current dir's parent
else
dir = archive->getDir(entry->getName(), current_dir);
// If it's null, return error
if (!dir)
return "INVALID DIRECTORY";
// Return the number of items in the directory
return S_FMT("%d entries", dir->numEntries() + dir->nChildren());
}
else
return entry->getSizeString(); // Not a folder, just return the normal size string
}
else if (col == 2)
return entry->getTypeString(); // Type column
else if (col == 3)
{
// Index column
if (entry->getType() == EntryType::folderType())
return "";
else
return S_FMT("%d", entry->getParentDir()->entryIndex(entry));
}
else
return "INVALID COLUMN"; // Invalid column
}
示例14: readConfiguration
/* ColourConfiguration::readConfiguration
* Reads saved colour configuration [name]
*******************************************************************/
bool ColourConfiguration::readConfiguration(string name)
{
// TODO: search custom folder
// Search resource pk3
Archive* res = theArchiveManager->programResourceArchive();
ArchiveTreeNode* dir = res->getDir("config/colours");
for (unsigned a = 0; a < dir->numEntries(); a++)
{
if (S_CMPNOCASE(dir->getEntry(a)->getName(true), name))
return readConfiguration(dir->getEntry(a)->getMCData());
}
return false;
}
示例15: ArchiveTreeNode
/* ArchiveTreeNode::clone
* Returns a clone of this node
*******************************************************************/
ArchiveTreeNode* ArchiveTreeNode::clone()
{
// Create copy
ArchiveTreeNode* copy = new ArchiveTreeNode();
copy->setName(dir_entry->getName());
// Copy entries
for (unsigned a = 0; a < entries.size(); a++)
copy->addEntry(new ArchiveEntry(*(entries[a])));
// Copy subdirectories
for (unsigned a = 0; a < children.size(); a++)
copy->addChild(((ArchiveTreeNode*)children[a])->clone());
return copy;
}