Rename TCO and BB to clip and pattern in save files (#6309)
... and clarify how PatternTrack cloning works - pattern -> midiclip - automationpattern -> automationclip - *tco -> *clip - bb* -> pattern* - bbtrackcontainer -> patternstore
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include "ProjectVersion.h"
|
||||
#include "SongEditor.h"
|
||||
#include "TextFloat.h"
|
||||
#include "Track.h"
|
||||
#include "PathUtil.h"
|
||||
|
||||
#include "lmmsversion.h"
|
||||
@@ -54,7 +55,7 @@ static void findIds(const QDomElement& elem, QList<jo_id_t>& idList);
|
||||
|
||||
// QMap with the DOM elements that access file resources
|
||||
const DataFile::ResourcesMap DataFile::ELEMENTS_WITH_RESOURCES = {
|
||||
{ "sampletco", {"src"} },
|
||||
{ "sampleclip", {"src"} },
|
||||
{ "audiofileprocessor", {"src"} },
|
||||
};
|
||||
|
||||
@@ -71,7 +72,7 @@ const std::vector<DataFile::UpgradeMethod> DataFile::UPGRADE_METHODS = {
|
||||
&DataFile::upgrade_1_3_0 , &DataFile::upgrade_noHiddenClipNames,
|
||||
&DataFile::upgrade_automationNodes , &DataFile::upgrade_extendedNoteRange,
|
||||
&DataFile::upgrade_defaultTripleOscillatorHQ,
|
||||
&DataFile::upgrade_mixerRename
|
||||
&DataFile::upgrade_mixerRename , &DataFile::upgrade_bbTcoRename,
|
||||
};
|
||||
|
||||
// Vector of all versions that have upgrade routines.
|
||||
@@ -95,7 +96,7 @@ DataFile::typeDescStruct
|
||||
{ DataFile::ClipboardData, "clipboard-data" },
|
||||
{ DataFile::JournalData, "journaldata" },
|
||||
{ DataFile::EffectSettings, "effectsettings" },
|
||||
{ DataFile::MidiClip, "pattern" }
|
||||
{ DataFile::MidiClip, "midiclip" }
|
||||
} ;
|
||||
|
||||
|
||||
@@ -1790,6 +1791,40 @@ void DataFile::upgrade_mixerRename()
|
||||
}
|
||||
|
||||
|
||||
// Rename BB to pattern and TCO to clip
|
||||
void DataFile::upgrade_bbTcoRename()
|
||||
{
|
||||
std::vector<std::pair<const char *, const char *>> names {
|
||||
{"automationpattern", "automationclip"},
|
||||
{"bbtco", "patternclip"},
|
||||
{"pattern", "midiclip"},
|
||||
{"sampletco", "sampleclip"},
|
||||
{"bbtrack", "patterntrack"},
|
||||
{"bbtrackcontainer", "patternstore"},
|
||||
};
|
||||
// Replace names of XML tags
|
||||
for (auto name : names)
|
||||
{
|
||||
QDomNodeList elements = elementsByTagName(name.first);
|
||||
for (int i = 0; !elements.item(i).isNull(); ++i)
|
||||
{
|
||||
elements.item(i).toElement().setTagName(name.second);
|
||||
}
|
||||
}
|
||||
// Replace "Beat/Bassline" with "Pattern" in track names
|
||||
QDomNodeList elements = elementsByTagName("track");
|
||||
for (int i = 0; !elements.item(i).isNull(); ++i)
|
||||
{
|
||||
auto e = elements.item(i).toElement();
|
||||
static_assert(Track::PatternTrack == 1, "Must be type=1 for backwards compatibility");
|
||||
if (e.attribute("type").toInt() == Track::PatternTrack)
|
||||
{
|
||||
e.setAttribute("name", e.attribute("name").replace("Beat/Bassline", "Pattern"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DataFile::upgrade()
|
||||
{
|
||||
// Runs all necessary upgrade methods
|
||||
|
||||
@@ -1112,7 +1112,7 @@ void Song::loadProject( const QString & fileName )
|
||||
++m_nLoadingTrack;
|
||||
if (nd.toElement().attribute("type").toInt() == Track::PatternTrack)
|
||||
{
|
||||
n += nd.toElement().elementsByTagName("bbtrack").at(0) // TODO rename to patterntrack
|
||||
n += nd.toElement().elementsByTagName("patterntrack").at(0)
|
||||
.toElement().firstChildElement().childNodes().count();
|
||||
}
|
||||
nd=nd.nextSibling();
|
||||
|
||||
@@ -161,8 +161,9 @@ Track * Track::create( const QDomElement & element, TrackContainer * tc )
|
||||
*/
|
||||
Track* Track::clone()
|
||||
{
|
||||
// Save track to temporary XML and load it to create a new identical track
|
||||
QDomDocument doc;
|
||||
QDomElement parent = doc.createElement("clone");
|
||||
QDomElement parent = doc.createElement("clonedtrack");
|
||||
saveState(doc, parent);
|
||||
Track* t = create(parent.firstChild().toElement(), m_trackContainer);
|
||||
|
||||
|
||||
@@ -149,14 +149,15 @@ void PatternTrack::saveTrackSpecificSettings(QDomDocument& doc, QDomElement& _th
|
||||
/* _this.setAttribute( "current", s_infoMap[this] ==
|
||||
engine::getPatternEditor()->currentPattern() );*/
|
||||
if( s_infoMap[this] == 0 &&
|
||||
_this.parentNode().parentNode().nodeName() != "clone" &&
|
||||
_this.parentNode().parentNode().nodeName() != "clonedtrack" &&
|
||||
_this.parentNode().parentNode().nodeName() != "journaldata" )
|
||||
{
|
||||
Engine::patternStore()->saveState(doc, _this);
|
||||
}
|
||||
if( _this.parentNode().parentNode().nodeName() == "clone" )
|
||||
// If we are creating drag-n-drop data for Track::clone() only save pattern ID, not pattern content
|
||||
if (_this.parentNode().parentNode().nodeName() == "clonedtrack")
|
||||
{
|
||||
_this.setAttribute( "clonebbt", s_infoMap[this] ); // TODO rename bb to pattern
|
||||
_this.setAttribute("sourcepattern", s_infoMap[this]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,9 +171,11 @@ void PatternTrack::loadTrackSpecificSettings(const QDomElement& _this)
|
||||
m_trackLabel->setPixmapFile( _this.attribute( "icon" ) );
|
||||
}*/
|
||||
|
||||
if( _this.hasAttribute( "clonebbt" ) ) // TODO rename bb to pattern
|
||||
// If data was created by Track::clone(), do not add any tracks to the pattern(-editor)
|
||||
// instead create a new copy of the clip on each track
|
||||
if (_this.hasAttribute("sourcepattern"))
|
||||
{
|
||||
const int src = _this.attribute( "clonebbt" ).toInt(); // TODO rename bb to pattern
|
||||
const int src = _this.attribute("sourcepattern").toInt();
|
||||
const int dst = s_infoMap[this];
|
||||
TrackContainer::TrackList tl =
|
||||
Engine::patternStore()->tracks();
|
||||
|
||||
Reference in New Issue
Block a user