From: <sag...@us...> - 2012-02-07 00:16:32
|
Revision: 1174 http://modplug.svn.sourceforge.net/modplug/?rev=1174&view=rev Author: saga-games Date: 2012-02-07 00:16:25 +0000 (Tue, 07 Feb 2012) Log Message: ----------- [New] Added "Close All" short cut + menu item (tx Wayfinder). [Mod] Even when a module is not playing, the estimated tempo is now updated after a speed change in the GUI [Mod] Changed maximum width of pattern display to allow for wider displays than 4096 pixels (http://bugs.openmpt.org/view.php?id=215). [Ref] Moved samples per tick calculation around to fix the point above. [Mod] OpenMPT: Version is now 1.20.00.66 Modified Paths: -------------- trunk/OpenMPT/mptrack/CloseMainDialog.cpp trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/CloseMainDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2012-02-07 00:16:25 UTC (rev 1174) @@ -51,20 +51,15 @@ CheckDlgButton(IDC_CHECK1, BST_CHECKED); - CDocTemplate *pDocTmpl = theApp.GetModDocTemplate(); - if(pDocTmpl) + vector<CModDoc *> documents = theApp.GetOpenDocuments(); + for(vector<CModDoc *>::iterator doc = documents.begin(); doc != documents.end(); doc++) { - POSITION pos = pDocTmpl->GetFirstDocPosition(); - CDocument *pDoc; - while((pos != NULL) && ((pDoc = pDocTmpl->GetNextDoc(pos)) != NULL)) + CModDoc *pModDoc = *doc; + if(pModDoc->IsModified()) { - CModDoc *pModDoc = (CModDoc *)pDoc; - if(pModDoc->IsModified()) - { - int item = m_List.AddString(FormatTitle(pModDoc, true)); - m_List.SetItemDataPtr(item, pModDoc); - m_List.SetSel(item, TRUE); - } + int item = m_List.AddString(FormatTitle(pModDoc, true)); + m_List.SetItemDataPtr(item, pModDoc); + m_List.SetSel(item, TRUE); } } Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2012-02-07 00:16:25 UTC (rev 1174) @@ -607,6 +607,7 @@ DefineKeyCommand(kcIncreaseSpacing, 1861, _T("Increase Row Spacing")); DefineKeyCommand(kcDecreaseSpacing, 1862, _T("Decrease Row Spacing")); DefineKeyCommand(kcSampleAutotune, 1863, _T("Tune Sample to given Note")); + DefineKeyCommand(kcFileCloseAll, 1864, _T("File/Close All")); // Add new key commands here. #ifdef _DEBUG Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/CommandSet.h 2012-02-07 00:16:25 UTC (rev 1174) @@ -54,6 +54,7 @@ kcFileNew=kcGlobalStart, kcFileOpen, kcFileClose, + kcFileCloseAll, kcFileSave, kcFileSaveAs, kcFileSaveTemplate, Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2012-02-07 00:16:25 UTC (rev 1174) @@ -410,11 +410,12 @@ { case FILENEW: s="&New\t"; c = kcFileNew; break; case ID_FILE_OPEN: s="&Open...\t"; c = kcFileOpen; break; - case ID_FILE_OPENTEMPLATE: return "Open Template\t"; + case ID_FILE_OPENTEMPLATE: return "Open &Template\t"; case ID_FILE_CLOSE: s="&Close\t"; c = kcFileClose; break; + case ID_FILE_CLOSEALL: s="C&lose All\t"; c = kcFileCloseAll; break; case ID_FILE_SAVE: s="&Save\t"; c = kcFileSave; break; case ID_FILE_SAVE_AS: s="Save &As...\t"; c = kcFileSaveAs; break; - case ID_FILE_SAVEASTEMPLATE:s="Save as &Template\t"; c = kcFileSaveTemplate; break; + case ID_FILE_SAVEASTEMPLATE:s="Sa&ve as Template\t"; c = kcFileSaveTemplate; break; case ID_FILE_SAVEASWAVE: s="Export as &Wave...\t"; c = kcFileSaveAsWave; break; case ID_FILE_SAVEASMP3: s="Export as M&P3...\t"; c = kcFileSaveAsMP3; break; case ID_FILE_SAVEMIDI: s="Export as M&IDI...\t"; c = kcFileSaveMidi; break; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2012-02-07 00:16:25 UTC (rev 1174) @@ -2377,6 +2377,7 @@ case kcViewEditHistory: OnViewEditHistory(); break; case kcNextDocument: MDINext(); break; case kcPrevDocument: MDIPrev(); break; + case kcFileCloseAll: theApp.OnFileCloseAll(); break; //D'oh!! moddoc isn't a CWnd so we have to handle its messages and pass them on. @@ -2463,6 +2464,7 @@ pSndFile = GetActiveDoc()->GetSoundFile(); if (pSndFile) { + pSndFile->RecalculateSamplesPerTick(); return pSndFile->GetCurrentBPM(); } return 0; Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2012-02-07 00:16:25 UTC (rev 1174) @@ -20,6 +20,7 @@ #include "UpdateCheck.h" #include "../common/StringFixer.h" #include "ExceptionHandler.h" +#include "CloseMainDialog.h" // rewbs.memLeak #define _CRTDBG_MAP_ALLOC @@ -203,6 +204,48 @@ } +void CTrackApp::OnFileCloseAll() +//------------------------------ +{ + if(!(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_NOCLOSEDIALOG)) + { + // Show modified documents window + CloseMainDialog dlg; + if(dlg.DoModal() != IDOK) + { + return; + } + } + + vector<CModDoc *> documents = theApp.GetOpenDocuments(); + for(vector<CModDoc *>::iterator doc = documents.begin(); doc != documents.end(); doc++) + { + (*doc)->SafeFileClose(); + } +} + + +// Retrieve a list of all open modules. +vector<CModDoc *> CTrackApp::GetOpenDocuments() +//--------------------------------------------- +{ + vector<CModDoc *> documents; + + CDocTemplate *pDocTmpl = theApp.GetModDocTemplate(); + if(pDocTmpl) + { + POSITION pos = pDocTmpl->GetFirstDocPosition(); + CDocument *pDoc; + while((pos != NULL) && ((pDoc = pDocTmpl->GetNextDoc(pos)) != NULL)) + { + documents.push_back(dynamic_cast<CModDoc *>(pDoc)); + } + } + + return documents; +} + + ///////////////////////////////////////////////////////////////////////////// // Common Tables @@ -563,6 +606,7 @@ // -! NEW_FEATURE#0023 ON_COMMAND(ID_NEW_MPT, OnFileNewMPT) ON_COMMAND(ID_FILE_OPEN, OnFileOpen) + ON_COMMAND(ID_FILE_CLOSEALL, OnFileCloseAll) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_HELP_INDEX, CWinApp::OnHelpIndex) ON_COMMAND(ID_HELP_FINDER, CWinApp::OnHelpFinder) @@ -1528,12 +1572,12 @@ const char* const pArrCredit = { "OpenMPT / ModPlug Tracker|" - "Copyright \xA9 2004-2011 Contributors|" + "Copyright \xA9 2004-2012 Contributors|" "Copyright \xA9 1997-2003 Olivier Lapicque (ol...@mo...)|" "|" "Contributors:|" + "Johannes Schultz (2008-2012)|" "Ahti Lepp\xE4nen (2005-2011)|" - "Johannes Schultz (2008-2011)|" "Robin Fernandes (2004-2007)|" "Sergiy Pylypenko (2007)|" "Eric Chavanon (2004-2005)|" Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/Mptrack.h 2012-02-07 00:16:25 UTC (rev 1174) @@ -168,6 +168,8 @@ static FileDlgResult ShowOpenSaveFileDialog(const bool load, const std::string defaultExtension, const std::string defaultFilename, const std::string extFilter, const std::string workingDirectory = "", const bool allowMultiSelect = false, int *filterIndex = nullptr); + vector<CModDoc *>GetOpenDocuments(); + public: CDocTemplate *GetModDocTemplate() const { return m_pModTemplate; } CVstPluginManager *GetPluginManager() const { return m_pPluginManager; } @@ -233,6 +235,8 @@ afx_msg void OnFileOpen(); afx_msg void OnAppAbout(); afx_msg void OnHelpSearch(); + + afx_msg void OnFileCloseAll(); //}}AFX_MSG DECLARE_MESSAGE_MAP() @@ -282,16 +286,17 @@ ////////////////////////////////////////////////////////////////// // More Bitmap Helpers -#define FASTBMP_XSHIFT 12 // 4K pixels +//#define FASTBMP_XSHIFT 12 // 4K pixels +#define FASTBMP_XSHIFT 13 // 8K pixels #define FASTBMP_MAXWIDTH (1 << FASTBMP_XSHIFT) #define FASTBMP_MAXHEIGHT 16 -typedef struct MODPLUGFASTDIB +struct MODPLUGFASTDIB { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[256]; BYTE DibBits[FASTBMP_MAXWIDTH*FASTBMP_MAXHEIGHT]; -} MODPLUGFASTDIB, *LPMODPLUGFASTDIB; +}; //=============== class CFastBitmap Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/mptrack.rc 2012-02-07 00:16:25 UTC (rev 1174) @@ -2035,6 +2035,7 @@ MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN MENUITEM "Open template", 65535 MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM "C&lose All", ID_FILE_CLOSEALL MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE MENUITEM "Save &As...", ID_FILE_SAVE_AS MENUITEM "Save as Template...", ID_FILE_SAVEASTEMPLATE Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/resource.h 2012-02-07 00:16:25 UTC (rev 1174) @@ -1204,13 +1204,14 @@ #define ID_HELP_EXAMPLEMODULES 44459 #define ID_FILE_SAVEASTEMPLATE 44460 #define ID_ORDERLIST_INSERT_SEPARATOR 44461 -#define ID_FXCOMMANDS_BASE 44462 +#define ID_FXCOMMANDS_BASE 44462 // From here: Command range [ID_FXCOMMANDS_BASE, ID_FXCOMMANDS_BASE + 10] #define ID_PLUGINEDITOR_SLIDERS_BASE 44500 // From here: Command range [ID_PLUGINEDITOR_SLIDERS_BASE, ID_PLUGINEDITOR_SLIDERS_BASE + NUM_PLUGINEDITOR_PARAMETERS] #define ID_PLUGINEDITOR_EDIT_BASE 44550 // From here: Command range [ID_PLUGINEDITOR_EDIT_BASE, ID_PLUGINEDITOR_EDIT_BASE + NUM_PLUGINEDITOR_PARAMETERS] #define ID_HELP_SHOWSETTINGSFOLDER 44600 +#define ID_FILE_CLOSEALL 44601 // Next default values for new objects // @@ -1218,7 +1219,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 535 -#define _APS_NEXT_COMMAND_VALUE 44601 +#define _APS_NEXT_COMMAND_VALUE 44602 #define _APS_NEXT_CONTROL_VALUE 2448 #define _APS_NEXT_SYMED_VALUE 901 #endif Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/mptrack/version.h 2012-02-07 00:16:25 UTC (rev 1174) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 65 +#define VER_MINORMINOR 66 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of @@ -35,7 +35,7 @@ const char* const str = MPT_VERSION_STR; // Returns numerical version value from given version string. - static VersionNum ToNum(const char* const s) + static VersionNum ToNum(const char *const s) { int v1, v2, v3, v4; sscanf(s, "%x.%x.%x.%x", &v1, &v2, &v3, &v4); Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2012-02-07 00:16:25 UTC (rev 1174) @@ -742,15 +742,7 @@ InitializeVisitedRows(true); - switch(m_nTempoMode) - { - case tempo_mode_alternative: - m_nSamplesPerTick = gdwMixingFreq / m_nMusicTempo; break; - case tempo_mode_modern: - m_nSamplesPerTick = gdwMixingFreq * (60/m_nMusicTempo / (m_nMusicSpeed * m_nCurrentRowsPerBeat)); break; - case tempo_mode_classic: default: - m_nSamplesPerTick = (gdwMixingFreq * 5 * m_nTempoFactor) / (m_nMusicTempo << 8); - } + RecalculateSamplesPerTick(); if ((m_nRestartPos >= Order.size()) || (Order[m_nRestartPos] >= Patterns.Size())) m_nRestartPos = 0; @@ -1007,8 +999,8 @@ return pos + m_nRow; } -double CSoundFile::GetCurrentBPM() const -//--------------------------------------- +double CSoundFile::GetCurrentBPM() const +//-------------------------------------- { double bpm; @@ -2290,6 +2282,7 @@ DWORD CSoundFile::TransposeToFrequency(int transp, int ftune) //----------------------------------------------------------- { + // return (unsigned int) (8363.0 * pow(2, (transp * 128.0 + ftune) / 1536.0)); const float _fbase = 8363; const float _factor = 1.0f/(12.0f*128.0f); int result; @@ -2325,6 +2318,8 @@ int CSoundFile::FrequencyToTranspose(DWORD freq) //---------------------------------------------- { + // return (int) (1536.0 * (log(freq / 8363.0) / log(2))); + const float _f1_8363 = 1.0f / 8363.0f; const float _factor = 128 * 12; LONG result; @@ -2348,7 +2343,7 @@ int f2t = FrequencyToTranspose(psmp->nC5Speed); int transp = f2t >> 7; int ftune = f2t & 0x7F; //0x7F == 111 1111 - if (ftune > 80) // XXX I'm pretty sure this is supposed to be 0x80. + if (ftune > 80) // XXX Why is this 80? { transp++; ftune -= 128; @@ -2772,6 +2767,24 @@ } +// Calculate the length of a tick, depending on the tempo mode. +void CSoundFile::RecalculateSamplesPerTick() +//------------------------------------------ +{ + switch(m_nTempoMode) + { + case tempo_mode_alternative: + m_nSamplesPerTick = gdwMixingFreq / m_nMusicTempo; + break; + case tempo_mode_modern: + m_nSamplesPerTick = gdwMixingFreq * (60/m_nMusicTempo / (m_nMusicSpeed * m_nCurrentRowsPerBeat)); + break; + case tempo_mode_classic: default: + m_nSamplesPerTick = (gdwMixingFreq * 5 * m_nTempoFactor) / (m_nMusicTempo << 8); + } +} + + // Get the duration of a row in milliseconds, based on the current rows per beat and given speed and tempo settings. double CSoundFile::GetRowDuration(UINT speed, UINT tempo) const //------------------------------------------------------------- Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2012-02-07 00:11:38 UTC (rev 1173) +++ trunk/OpenMPT/soundlib/Sndfile.h 2012-02-07 00:16:25 UTC (rev 1174) @@ -732,6 +732,7 @@ //Returns song length in seconds. DWORD GetSongTime() { return static_cast<DWORD>((m_nTempoMode == tempo_mode_alternative) ? GetLength(eNoAdjust).duration + 1.0 : GetLength(eNoAdjust).duration + 0.5); } + void RecalculateSamplesPerTick(); double GetRowDuration(UINT speed, UINT tempo) const; // A repeat count value of -1 means infinite loop @@ -844,7 +845,6 @@ static BOOL SetWaveConfig(UINT nRate,UINT nBits,UINT nChannels,BOOL bMMX=FALSE); static BOOL SetDspEffects(BOOL bSurround,BOOL bReverb,BOOL xbass,BOOL dolbynr=FALSE,BOOL bEQ=FALSE); static BOOL SetResamplingMode(UINT nMode); // SRCMODE_XXXX - static BOOL IsStereo() { return (gnChannels > 1) ? TRUE : FALSE; } static DWORD GetSampleRate() { return gdwMixingFreq; } static DWORD GetBitsPerSample() { return gnBitsPerSample; } static DWORD InitSysInfo(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |