From: <sag...@us...> - 2009-10-07 17:12:54
|
Revision: 390 http://modplug.svn.sourceforge.net/modplug/?rev=390&view=rev Author: saga-games Date: 2009-10-07 17:12:37 +0000 (Wed, 07 Oct 2009) Log Message: ----------- [Imp] Treeview: Should behave correctly when number of sequences changed from 1 or to 1. [Mod] Mod Creation: When clicking on the "new" buton, the newly created module will be of the same type as the currently active document. Should probably be an option. Modified Paths: -------------- trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2009-10-06 12:44:31 UTC (rev 389) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2009-10-07 17:12:37 UTC (rev 390) @@ -773,6 +773,10 @@ } } } + if(m_SndFile.Order.GetLengthTailTrimmed() > specs.ordersMax) + { + AddToLog("WARNING: Order list has been trimmed!"); + } m_SndFile.Order.resize(specs.ordersMax); } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2009-10-06 12:44:31 UTC (rev 389) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2009-10-07 17:12:37 UTC (rev 390) @@ -1265,7 +1265,46 @@ void CTrackApp::OnFileNew() //------------------------- { - if (m_bInitialized) OnFileNewIT(); + if (!m_bInitialized) return; + + // Default module type + MODTYPE nNewType = MOD_TYPE_IT; + bool bIsProject = false; + + // Get active document to make the new module of the same type + CModDoc *pModDoc = CMainFrame::GetMainFrame()->GetActiveDoc(); + if(pModDoc != nullptr) + { + CSoundFile *pSndFile = pModDoc->GetSoundFile(); + if(pSndFile != nullptr) + { + nNewType = pSndFile->GetBestSaveFormat(); + bIsProject = ((pSndFile->m_dwSongFlags & SONG_ITPROJECT) != 0) ? true: false; + } + } + + switch(nNewType) + { + case MOD_TYPE_MOD: + OnFileNewMOD(); + break; + case MOD_TYPE_S3M: + OnFileNewS3M(); + break; + case MOD_TYPE_XM: + OnFileNewXM(); + break; + case MOD_TYPE_IT: + if(bIsProject) + OnFileNewITProject(); + else + OnFileNewIT(); + break; + case MOD_TYPE_MPT: + default: + OnFileNewMPT(); + break; + } } Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2009-10-06 12:44:31 UTC (rev 389) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2009-10-07 17:12:37 UTC (rev 390) @@ -688,6 +688,25 @@ if ((pInfo->hOrders) && (hintFlagPart != HINT_INSNAMES) && (hintFlagPart != HINT_SMPNAMES)) { const DWORD nPat = (lHint >> HINT_SHIFT_PAT); + + // only one seq remaining: update parent item || previously only one sequence + if((pInfo->tiSequences.size() > 1 && pSndFile->Order.GetNumSequences() == 1) || (pInfo->tiSequences.size() == 1 && pSndFile->Order.GetNumSequences() > 1)) + { + if(pInfo->tiOrders.size() != pSndFile->Order.GetNumSequences()) + { + for(size_t nSeq = 0; nSeq < pInfo->tiOrders.size(); nSeq++) + { + for(size_t nOrd = 0; nOrd < pInfo->tiOrders[nSeq].size(); nOrd++) if (pInfo->tiOrders[nSeq][nOrd]) + { + DeleteItem(pInfo->tiOrders[nSeq][nOrd]); pInfo->tiOrders[nSeq][nOrd] = NULL; + } + DeleteItem(pInfo->tiSequences[nSeq]); pInfo->tiSequences[nSeq] = NULL; + } + pInfo->tiOrders.resize(pSndFile->Order.GetNumSequences()); + pInfo->tiSequences.resize(pSndFile->Order.GetNumSequences(), NULL); + } + } + // If there are too many sequences, delete them. for(size_t nSeq = pSndFile->Order.GetNumSequences(); nSeq < pInfo->tiSequences.size(); nSeq++) if (pInfo->tiSequences[nSeq]) { @@ -703,23 +722,6 @@ pInfo->tiOrders.resize(pSndFile->Order.GetNumSequences()); } - // TODO what to do when seq count changed from 2 to 1 or from 1 to 2? - - /* // number of sequences changed: wipe tree first (is this necessary?) - if(pInfo->tiOrders.size() != pSndFile->Order.GetNumSequences()) - { - for(size_t nSeq = 0; nSeq < pInfo->tiOrders.size(); nSeq++) - { - for(size_t nOrd = 0; nOrd < pInfo->tiOrders[nSeq].size(); nOrd++) if (pInfo->tiOrders[nSeq][nOrd]) - { - DeleteItem(pInfo->tiOrders[nSeq][nOrd]); pInfo->tiOrders[nSeq][nOrd] = NULL; - } - DeleteItem(pInfo->tiSequences[nSeq]); pInfo->tiSequences[nSeq] = NULL; - } - pInfo->tiOrders.resize(pSndFile->Order.GetNumSequences()); - pInfo->tiSequences.resize(pSndFile->Order.GetNumSequences(), NULL); - }*/ - HTREEITEM hAncestorNode = pInfo->hOrders; // go through all sequences Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2009-10-06 12:44:31 UTC (rev 389) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2009-10-07 17:12:37 UTC (rev 390) @@ -1359,8 +1359,8 @@ //end rewbs.playSongFromCursor -UINT CSoundFile::GetBestSaveFormat() const -//---------------------------------------- +MODTYPE CSoundFile::GetBestSaveFormat() const +//------------------------------------------- { if ((!m_nSamples) || (!m_nChannels)) return MOD_TYPE_NONE; if (!m_nType) return MOD_TYPE_NONE; @@ -1376,8 +1376,8 @@ } -UINT CSoundFile::GetSaveFormats() const -//------------------------------------- +MODTYPE CSoundFile::GetSaveFormats() const +//---------------------------------------- { UINT n = 0; if ((!m_nSamples) || (!m_nChannels) || (m_nType == MOD_TYPE_NONE)) return 0; @@ -2650,7 +2650,7 @@ CHAR szName[MAX_PATTERNNAME] = ""; if (nPat >= Patterns.Size()) return FALSE; if (lpszName) lstrcpyn(szName, lpszName, MAX_PATTERNNAME); - szName[MAX_PATTERNNAME-1] = 0; + SpaceToNullString(szName); //szName[MAX_PATTERNNAME-1] = 0; if (!m_lpszPatternNames) m_nPatternNames = 0; if (nPat >= m_nPatternNames) { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2009-10-06 12:44:31 UTC (rev 389) +++ trunk/OpenMPT/soundlib/Sndfile.h 2009-10-07 17:12:37 UTC (rev 390) @@ -730,8 +730,8 @@ #endif // MODPLUG_NO_FILESAVE // MOD Convert function - UINT GetBestSaveFormat() const; - UINT GetSaveFormats() const; + MODTYPE GetBestSaveFormat() const; + MODTYPE GetSaveFormats() const; void ConvertModCommand(MODCOMMAND *) const; void S3MConvert(MODCOMMAND *m, BOOL bIT) const; void S3MSaveConvert(UINT *pcmd, UINT *pprm, BOOL bIT, BOOL bCompatibilityExport = false) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |