From: <rel...@us...> - 2011-01-02 16:10:56
|
Revision: 780 http://modplug.svn.sourceforge.net/modplug/?rev=780&view=rev Author: relabsoluness Date: 2011-01-02 16:10:49 +0000 (Sun, 02 Jan 2011) Log Message: ----------- [Fix] Sample Editor: Changing zoom level should now preserve better the view position. [Fix] Build: VC03 build was broken. [Ref] Some cleanup(mostly regarding compiler warnings). Modified Paths: -------------- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_smp.h trunk/OpenMPT/mptrack/misc_util.cpp trunk/OpenMPT/mptrack/misc_util.h trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/SNDDEV.H trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/unlha/UNLHA32.H Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-01-02 16:10:49 UTC (rev 780) @@ -36,7 +36,7 @@ } -void CCustEdit::SetKey(UINT inMod, CString c) +void CCustEdit::SetKey(UINT /*inMod*/, CString /*c*/) { /* mod = inMod; @@ -354,7 +354,7 @@ void COptionsKeyboard::OnCategorySelChanged() //------------------------------------------- { - CommandID nCmd = (CommandID)m_lbnCommandKeys.GetItemData( m_lbnCommandKeys.GetCurSel() ); + //CommandID nCmd = (CommandID)m_lbnCommandKeys.GetItemData( m_lbnCommandKeys.GetCurSel() ); int nCat = m_cmbCategory.GetItemData( m_cmbCategory.GetCurSel() ); //Fill Command list @@ -372,7 +372,7 @@ m_lbnCommandKeys.SetItemData(m_lbnCommandKeys.AddString(plocalCmdSet->GetCommandText(com)), com); if (commandCategories[nCat].separatorAt(com)) - m_lbnCommandKeys.SetItemData(m_lbnCommandKeys.AddString("------------------------------------------------------"), -1); + m_lbnCommandKeys.SetItemData(m_lbnCommandKeys.AddString("------------------------------------------------------"), DWORD_PTR(-1)); } } m_lbnCommandKeys.SetCurSel(0); @@ -657,7 +657,7 @@ if(files.abort) return; m_sFullPathName = files.first_file.c_str(); - plocalCmdSet->SaveFile(m_sFullPathName, m_bDebugSave.GetCheck()); + plocalCmdSet->SaveFile(m_sFullPathName, m_bDebugSave.GetCheck() != BST_UNCHECKED); //TentativeSetToDefaultFile(m_sFullPathName); } Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.h =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.h 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.h 2011-01-02 16:10:49 UTC (rev 780) @@ -33,7 +33,7 @@ commands.Copy(copy.commands); separators.Copy(copy.separators); } - bool separatorAt(UINT c) + bool separatorAt(int c) { for (int p=0; p<separators.GetSize(); p++) { Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-01-02 16:10:49 UTC (rev 780) @@ -760,7 +760,20 @@ SendMessageToActiveViews(WM_MOD_ACTIVATEVIEW, IDD_CONTROL_INSTRUMENTS, nIns); } +void CModDoc::AddLogEvent(LogEventType eventType, LPCTSTR pszFuncName, LPCTSTR pszFormat, ...) +{ + CString strMsg; + va_list args; + va_start(args, pszFormat); + strMsg.FormatV(pszFormat, args); + va_end(args); + m_logEvents << Util::GetDateTimeStr() + << _T("Event type: ") << eventType << std::endl + << _T("Function: ") << pszFuncName << std::endl + << _T("Message: ") << strMsg << std::endl << std::endl; +} + BOOL CModDoc::AddToLog(LPCSTR lpszLog) //------------------------------------ { Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/mptrack/Moddoc.h 2011-01-02 16:10:49 UTC (rev 780) @@ -147,13 +147,19 @@ bool octaveLink; // apply octaveModifier }; +enum LogEventType +{ + LogEventUnexpectedError +}; + //============================= class CModDoc: public CDocument //============================= { protected: LPSTR m_lpszLog; + std::basic_ostringstream<TCHAR> m_logEvents; // Log for general progress and error events. CSoundFile m_SndFile; BOOL m_bPaused; @@ -197,6 +203,10 @@ LPCSTR GetLog() const { return m_lpszLog; } BOOL ClearLog(); UINT ShowLog(LPCSTR lpszTitle=NULL, CWnd *parent=NULL); + + // Logging for general progress and error events. + void AddLogEvent(LogEventType eventType, LPCTSTR pszFuncName, LPCTSTR pszFormat, ...); + void ViewPattern(UINT nPat, UINT nOrd); void ViewSample(UINT nSmp); void ViewInstrument(UINT nIns); Modified: trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp 2011-01-02 16:10:49 UTC (rev 780) @@ -39,7 +39,7 @@ void CMoveFXSlotDialog::OnOK() //---------------------------- { - m_nToSlot = m_CbnEmptySlots.GetItemData(m_CbnEmptySlots.GetCurSel()); + m_nToSlot = static_cast<PLUGINDEX>(m_CbnEmptySlots.GetItemData(m_CbnEmptySlots.GetCurSel())); CDialog::OnOK(); } Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2011-01-02 16:10:49 UTC (rev 780) @@ -135,7 +135,7 @@ } -void CViewSample::UpdateScrollSize() +void CViewSample::UpdateScrollSize(const UINT nZoomOld) //---------------------------------- { CModDoc *pModDoc = GetDocument(); @@ -182,7 +182,19 @@ sizePage.cx = sizeLine.cx * 4; sizePage.cy = sizeLine.cy; SetScrollSizes(MM_TEXT, m_sizeTotal, sizePage, sizeLine); - m_nScrollPos = GetScrollPos(SB_HORZ) << m_nScrollFactor; + + if (nZoomOld != m_nZoom) // After zoom change, keep the view position. + { + const UINT nOldPos = ScrollPosToSamplePos(nZoomOld); + const float fPosFraction = (dwLen > 0) ? static_cast<float>(nOldPos) / dwLen : 0; + m_nScrollPos = 0; + m_nScrollPos = SampleToScreen(nOldPos); + SetScrollPos(SB_HORZ, static_cast<int>(fPosFraction * GetScrollLimit(SB_HORZ))); + } + else + { + m_nScrollPos = GetScrollPos(SB_HORZ) << m_nScrollFactor; + } } } @@ -220,8 +232,9 @@ if (nZoom > MAX_ZOOM) return FALSE; + const UINT nZoomOld = m_nZoom; m_nZoom = nZoom; - UpdateScrollSize(); + UpdateScrollSize(nZoomOld); InvalidateRect(NULL, FALSE); return TRUE; } @@ -749,8 +762,9 @@ CSoundFile *pSndFile; HGDIOBJ oldpen; HDC hdc; - UINT nSmpScrollPos = (m_nZoom) ? (m_nScrollPos << (m_nZoom - 1)) : 0; + UINT nSmpScrollPos = ScrollPosToSamplePos(); + if ((!pModDoc) || (!pDC)) return; hdc = pDC->m_hDC; oldpen = ::SelectObject(hdc, CMainFrame::penBlack); Modified: trunk/OpenMPT/mptrack/View_smp.h =================================================================== --- trunk/OpenMPT/mptrack/View_smp.h 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/mptrack/View_smp.h 2011-01-02 16:10:49 UTC (rev 780) @@ -31,7 +31,8 @@ DECLARE_SERIAL(CViewSample) public: - void UpdateScrollSize(); + void UpdateScrollSize() {UpdateScrollSize(m_nZoom);} + void UpdateScrollSize(const UINT nZoomOld); BOOL SetCurrentSample(SAMPLEINDEX nSmp); BOOL SetZoom(UINT nZoom); LONG SampleToScreen(LONG n) const; @@ -65,6 +66,9 @@ // if smaller than the smallest zoom, returns value >= MAX_ZOOM + 1. UINT GetAutoZoomLevel(const MODSAMPLE& smp); + UINT ScrollPosToSamplePos() const {return ScrollPosToSamplePos(m_nZoom);} + UINT ScrollPosToSamplePos(UINT nZoom) const {return (nZoom > 0) ? (m_nScrollPos << (nZoom - 1)) : 0;} + public: //{{AFX_VIRTUAL(CViewSample) virtual void OnDraw(CDC *); Modified: trunk/OpenMPT/mptrack/misc_util.cpp =================================================================== --- trunk/OpenMPT/mptrack/misc_util.cpp 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/mptrack/misc_util.cpp 2011-01-02 16:10:49 UTC (rev 780) @@ -1,5 +1,6 @@ #include "stdafx.h" #include "misc_util.h" +#include <ctime> /* * Loads resource. @@ -51,3 +52,11 @@ return sMsg; } + +std::basic_string<TCHAR> Util::GetDateTimeStr() +{ + time_t t; + std::time(&t); + return _tctime(&t); +} + Modified: trunk/OpenMPT/mptrack/misc_util.h =================================================================== --- trunk/OpenMPT/mptrack/misc_util.h 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/mptrack/misc_util.h 2011-01-02 16:10:49 UTC (rev 780) @@ -53,6 +53,7 @@ { #if _HAS_TR1 static_assert(std::tr1::is_pointer<T>::value == false, "Won't memset pointers."); + static_assert(std::tr1::is_pod<T>::value == true, "Won't memset non-pods."); #endif memset(&a, 0, sizeof(T)); } @@ -224,6 +225,9 @@ // Returns maximum value of given integer type. template <class T> inline T MaxValueOfType(const T&) {static_assert(std::numeric_limits<T>::is_integer == true, "Only interger types are allowed."); return (std::numeric_limits<T>::max)();} + + // Returns string containing date and time ended with newline. + std::basic_string<TCHAR> GetDateTimeStr(); }; #endif Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2011-01-02 16:10:49 UTC (rev 780) @@ -349,10 +349,11 @@ #pragma pack() -bool CSoundFile::ReadAMS2(LPCBYTE lpStream, DWORD dwMemLength) +bool CSoundFile::ReadAMS2(LPCBYTE /*lpStream*/, DWORD /*dwMemLength*/) //------------------------------------------------------------ { return false; +#if 0 const AMS2FILEHEADER *pfh = (AMS2FILEHEADER *)lpStream; AMS2SONGHEADER *psh; DWORD dwMemPos; @@ -590,6 +591,7 @@ dwMemPos += ReadSample(&Samples[iSmp], flags, (LPSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos); } return true; +#endif } Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-01-02 16:10:49 UTC (rev 780) @@ -1269,6 +1269,7 @@ for(size_t n = start; n < num; n++) { tm loadDate; + MemsetZero(loadDate); uint32 openTime; if(n < num - 1) @@ -1281,7 +1282,14 @@ { // Current ("new") timestamp const time_t creationTime = pModDoc->GetCreationTime(); - localtime_s(&loadDate, &creationTime); + //localtime_s(&loadDate, &creationTime); + const tm* const p = localtime(&creationTime); + if (p != nullptr) + loadDate = *p; + else if (pSndFile->GetModDocPtr() != nullptr) + pSndFile->GetModDocPtr()->AddLogEvent(LogEventUnexpectedError, + __FUNCTION__, + _T("localtime() returned nullptr.")); openTime = (uint32)((double)difftime(time(nullptr), creationTime) * 18.2f); } Modified: trunk/OpenMPT/soundlib/SNDDEV.H =================================================================== --- trunk/OpenMPT/soundlib/SNDDEV.H 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/soundlib/SNDDEV.H 2011-01-02 16:10:49 UTC (rev 780) @@ -79,7 +79,7 @@ virtual BOOL IsOpen() = 0; virtual UINT GetCurrentLatency() = 0; virtual void SilenceAudioBuffer(ISoundSource *pSource, ULONG nMaxLatency, DWORD dwUser=0) = 0; - virtual UINT GetCurrentSampleRate(UINT nDevice) { return 0; } + virtual UINT GetCurrentSampleRate(UINT nDevice) { UNREFERENCED_PARAMETER(nDevice); return 0; } }; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-01-02 16:10:49 UTC (rev 780) @@ -439,13 +439,14 @@ CTuningCollection* CSoundFile::s_pTuningsSharedLocal(0); uint8 CSoundFile::s_DefaultPlugVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; - +#pragma warning(disable : 4355) // "'this' : used in base member initializer list" CSoundFile::CSoundFile() : Patterns(*this), Order(*this), m_PlaybackEventer(*this), m_pModSpecs(&ModSpecs::itEx), m_MIDIMapper(*this) +#pragma warning(default : 4355) // "'this' : used in base member initializer list" //---------------------- { m_nType = MOD_TYPE_NONE; @@ -1532,7 +1533,7 @@ //added to position i. If index of some current channel is missing from the //newOrder-vector, then the channel gets removed. - CHANNELINDEX nRemainingChannels = newOrder.size(); + const CHANNELINDEX nRemainingChannels = static_cast<CHANNELINDEX>(newOrder.size()); if(nRemainingChannels > GetModSpecifications().channelsMax || nRemainingChannels < GetModSpecifications().channelsMin) { @@ -2587,10 +2588,9 @@ transp++; ftune -= 128; } - if (transp > 127) transp = 127; - if (transp < -127) transp = -127; - psmp->RelativeTone = transp; - psmp->nFineTune = ftune; + Limit(transp, -127, 127); + psmp->RelativeTone = static_cast<int8>(transp); + psmp->nFineTune = static_cast<int8>(ftune); } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-01-02 16:10:49 UTC (rev 780) @@ -25,7 +25,7 @@ #include <aeffect.h> // VST #else typedef int32 VstInt32; -typedef int32 VstIntPtr; +typedef intptr_t VstIntPtr; #endif class CTuningBase; @@ -660,6 +660,7 @@ inline bool TypeIsXM_MOD() const { return (m_nType & (MOD_TYPE_XM | MOD_TYPE_MOD)) != 0; } inline bool TypeIsMOD_S3M() const { return (m_nType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) != 0; } CModDoc* GetpModDoc() const { return m_pModDoc; } + CModDoc* GetModDocPtr() const { return m_pModDoc; } void SetMasterVolume(UINT vol, bool adjustAGC = false); UINT GetMasterVolume() const { return m_nMasterVolume; } Modified: trunk/OpenMPT/unlha/UNLHA32.H =================================================================== --- trunk/OpenMPT/unlha/UNLHA32.H 2010-12-31 20:58:02 UTC (rev 779) +++ trunk/OpenMPT/unlha/UNLHA32.H 2011-01-02 16:10:49 UTC (rev 780) @@ -81,7 +81,7 @@ protected: void setup_get(char *p) { get_ptr = p; } int get_byte() { return (*get_ptr++ & 0xff); } - unsigned short get_word() { int b0, b1; b0 = get_byte(); b1 = get_byte(); return (b1 << 8) + b0; } + unsigned short get_word() { int b0, b1; b0 = get_byte(); b1 = get_byte(); return static_cast<unsigned short>((b1 << 8) + b0); } long get_longword() { long b0, b1, b2, b3; b0 = get_byte(); b1 = get_byte(); b2 = get_byte(); b3 = get_byte(); return (b3 << 24) + (b2 << 16) + (b1 << 8) + b0; } BOOL get_header(DWORD &fp, LzHeader *hdr); VOID make_crctable(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |