parent
6d9ee85559
commit
88ffb47e4c
6 changed files with 40 additions and 9 deletions
|
@ -141,6 +141,8 @@ Binding an id to 0 is equivalent to unbinding it.
|
|||
//! succeeded.
|
||||
bool rebind(const std::string &srcId, const std::string &dstId);
|
||||
|
||||
bool renumber(const std::string &srcId, const TFrameId &fid);
|
||||
|
||||
//! Unbinds all known identifiers, resetting the image manager to its empty
|
||||
//! state.
|
||||
void clear();
|
||||
|
@ -286,6 +288,8 @@ protected:
|
|||
std::vector<TFrameId>,
|
||||
std::vector<std::string>, bool){};
|
||||
|
||||
virtual void setFid(const TFrameId &fid){};
|
||||
|
||||
//! Clears the builder's cached data.
|
||||
virtual void invalidate() {
|
||||
m_info = TImageInfo();
|
||||
|
|
|
@ -450,8 +450,8 @@ public:
|
|||
for (int i = 0; i < n; i++) {
|
||||
std::map<TXshCell, TXshCell>::const_iterator it =
|
||||
table.find(cells[i]);
|
||||
if (it != table.end())
|
||||
cells[i] = it->second, changed = it->first != it->second;
|
||||
if (it != table.end() && it->first != it->second)
|
||||
cells[i] = it->second, changed = true;
|
||||
}
|
||||
if (changed) xsh->setCells(r0, c, n, &cells[0]);
|
||||
}
|
||||
|
|
|
@ -231,6 +231,8 @@ void ImageLoader::buildAllIconsAndPutInCache(TXshSimpleLevel *level,
|
|||
}
|
||||
}
|
||||
|
||||
void ImageLoader::setFid(const TFrameId &fid) { m_fid = fid; }
|
||||
|
||||
//***************************************************************************************
|
||||
// ImageRasterizer implementation
|
||||
//***************************************************************************************
|
||||
|
|
|
@ -59,6 +59,10 @@ public:
|
|||
std::vector<std::string> iconIds,
|
||||
bool cacheImagesAsWell) override;
|
||||
|
||||
/* Exposed to allow Fid to be updated due to a renumber operation
|
||||
*/
|
||||
void setFid(const TFrameId &fid);
|
||||
|
||||
protected:
|
||||
bool getInfo(TImageInfo &info, int imFlags, void *extData) override;
|
||||
TImageP build(int imFlags, void *extData) override;
|
||||
|
|
|
@ -246,11 +246,24 @@ bool ImageManager::rebind(const std::string &srcId, const std::string &dstId) {
|
|||
m_imp->m_builders.erase(st);
|
||||
m_imp->m_builders[dstId] = builder;
|
||||
|
||||
m_imp->m_builders[dstId]->m_cached = true;
|
||||
m_imp->m_builders[dstId]->m_modified = true;
|
||||
|
||||
TImageCache::instance()->remap(dstId, srcId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImageManager::renumber(const std::string &srcId, const TFrameId &fid) {
|
||||
std::map<std::string, ImageBuilderP>::iterator st =
|
||||
m_imp->m_builders.find(srcId);
|
||||
if (st == m_imp->m_builders.end()) return false;
|
||||
|
||||
m_imp->m_builders[srcId]->setFid(fid);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ImageManager::clear() {
|
||||
|
|
|
@ -1964,11 +1964,20 @@ void TXshSimpleLevel::renumber(const std::vector<TFrameId> &fids) {
|
|||
std::map<TFrameId, TFrameId>::iterator jt;
|
||||
|
||||
{
|
||||
for (i = 0, jt = table.begin(); jt != table.end(); ++jt, ++i)
|
||||
im->rebind(getImageId(jt->first), "^" + std::to_string(i));
|
||||
for (i = 0, jt = table.begin(); jt != table.end(); ++jt, ++i) {
|
||||
std::string Id = getImageId(jt->first);
|
||||
im->rebind(Id, "^" + std::to_string(i));
|
||||
TImageCache::instance()->remap("^icon:" + std::to_string(i),
|
||||
"icon:" + Id);
|
||||
}
|
||||
|
||||
for (i = 0, jt = table.begin(); jt != table.end(); ++jt, ++i)
|
||||
im->rebind("^" + std::to_string(i), getImageId(jt->second));
|
||||
for (i = 0, jt = table.begin(); jt != table.end(); ++jt, ++i) {
|
||||
std::string Id = getImageId(jt->second);
|
||||
im->rebind("^" + std::to_string(i), Id);
|
||||
TImageCache::instance()->remap("icon:" + Id,
|
||||
"^icon:" + std::to_string(i));
|
||||
im->renumber(Id, jt->second);
|
||||
}
|
||||
}
|
||||
|
||||
if (getType() == PLI_XSHLEVEL) {
|
||||
|
@ -2178,9 +2187,8 @@ TFilePath TXshSimpleLevel::getExistingHookFile(
|
|||
}
|
||||
|
||||
assert(h >= 0);
|
||||
return (h < 0) ? TFilePath()
|
||||
: decodedLevelPath.getParentDir() +
|
||||
TFilePath(hookFiles[h].toStdWString());
|
||||
return (h < 0) ? TFilePath() : decodedLevelPath.getParentDir() +
|
||||
TFilePath(hookFiles[h].toStdWString());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue