From: <sag...@us...> - 2011-09-03 18:52:32
|
Revision: 1012 http://modplug.svn.sourceforge.net/modplug/?rev=1012&view=rev Author: saga-games Date: 2011-09-03 18:52:21 +0000 (Sat, 03 Sep 2011) Log Message: ----------- [Ref] Moved some code that is common between tracker and player library to ./common/ [Ref] Unified calls to ::MessageBox / AfxMessageBox into Reporting::Notification Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/DefaultVstEditor.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/EffectVis.cpp trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/PSRatioCalc.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/Stdafx.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/UpdateCheck.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/dlg_misc.h trunk/OpenMPT/mptrack/fxp.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/mptrack.vcproj trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/mptrack/serialization_utils.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Loaders.h trunk/OpenMPT/soundlib/Message.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Snd_rvb.cpp trunk/OpenMPT/soundlib/Snddev.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/mod_specifications.cpp trunk/OpenMPT/soundlib/modcommand.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/tuningbase.h trunk/OpenMPT/ungzip/ungzip.h Added Paths: ----------- trunk/OpenMPT/common/ trunk/OpenMPT/common/Reporting.cpp trunk/OpenMPT/common/Reporting.h trunk/OpenMPT/common/StringFixer.h trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/typedefs.h Removed Paths: ------------- trunk/OpenMPT/mptrack/misc_util.cpp trunk/OpenMPT/mptrack/misc_util.h trunk/OpenMPT/mptrack/typedefs.h trunk/OpenMPT/soundlib/StringFixer.h Property changes on: trunk/OpenMPT/common ___________________________________________________________________ Added: tsvn:logminsize + 10 Added: bugtraq:number + true Added: trunk/OpenMPT/common/Reporting.cpp =================================================================== --- trunk/OpenMPT/common/Reporting.cpp (rev 0) +++ trunk/OpenMPT/common/Reporting.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,21 @@ +#include "Stdafx.h" +#include "Reporting.h" +#include "../mptrack/Mainfrm.h" + +UINT Reporting::Notification(CString text, UINT flags /* = MB_OK*/, HWND parent /* = NULL*/) +//------------------------------------------------------------------------------------------ +{ + return ::MessageBox(parent, text, MAINFRAME_TITLE, flags); +}; + + +UINT Reporting::Notification(CString text, CString caption, UINT flags /* = MB_OK*/, HWND parent /* = NULL*/) +//----------------------------------------------------------------------------------------------------------- +{ + if(parent == NULL && CMainFrame::GetMainFrame() != nullptr) + { + parent = CMainFrame::GetMainFrame()->m_hWnd; + } + + return ::MessageBox(parent, text, caption, flags); +}; Added: trunk/OpenMPT/common/Reporting.h =================================================================== --- trunk/OpenMPT/common/Reporting.h (rev 0) +++ trunk/OpenMPT/common/Reporting.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,17 @@ +#pragma once +#ifndef REPORTING_H +#define REPORTING_H + +//============= +class Reporting +//============= +{ + +public: + + static UINT Notification(CString text, UINT flags = MB_OK, HWND parent = NULL); + static UINT Notification(CString text, CString caption, UINT flags = MB_OK, HWND parent = NULL); + +}; + +#endif // REPORTING_H Added: trunk/OpenMPT/common/StringFixer.h =================================================================== --- trunk/OpenMPT/common/StringFixer.h (rev 0) +++ trunk/OpenMPT/common/StringFixer.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,124 @@ +/* + * StringFixer.h + * ------------- + * Purpose: Various functions for "fixing" char array strings for writing to or + * reading from module files, or for securing char arrays in general. + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + + +#ifndef STRINGFIXER_H +#define STRINGFIXER_H +#pragma once + + +namespace StringFixer +{ + + // Sets last character to null in given char array. + // Size of the array must be known at compile time. + template <size_t size> + void SetNullTerminator(char (&buffer)[size]) + //------------------------------------------ + { + STATIC_ASSERT(size > 0); + buffer[size-1] = 0; + } + + + // Convert a 0-terminated string to a space-padded string + template <size_t size> + void NullToSpaceString(char (&buffer)[size]) + //------------------------------------------ + { + STATIC_ASSERT(size > 0); + size_t pos = size; + while (pos-- > 0) + if (buffer[pos] == 0) + buffer[pos] = 32; + buffer[size - 1] = 0; + } + + + // Convert a space-padded string to a 0-terminated string + template <size_t size> + void SpaceToNullString(char (&buffer)[size]) + //------------------------------------------ + { + STATIC_ASSERT(size > 0); + // First, remove any Nulls + NullToSpaceString(buffer); + size_t pos = size; + while (pos-- > 0) + { + if (buffer[pos] == 32) + buffer[pos] = 0; + else if(buffer[pos] != 0) + break; + } + buffer[size - 1] = 0; + } + + + // Remove any chars after the first null char + template <size_t size> + void FixNullString(char (&buffer)[size]) + //-------------------------------------- + { + STATIC_ASSERT(size > 0); + SetNullTerminator(buffer); + size_t pos = 0; + // Find the first null char. + while(buffer[pos] != '\0' && pos < size) + { + pos++; + } + // Remove everything after the null char. + while(pos < size) + { + buffer[pos++] = '\0'; + } + } + + + // Convert a space-padded string to a 0-terminated string. STATIC VERSION! (use this if the maximum string length is known) + // Additional template parameter to specifify the max length of the final string, + // not including null char (useful for e.g. mod loaders) + template <size_t length, size_t size> + void SpaceToNullStringFixed(char (&buffer)[size]) + //------------------------------------------------ + { + STATIC_ASSERT(size > 0); + STATIC_ASSERT(length < size); + // Remove Nulls in string + SpaceToNullString(buffer); + // Overwrite trailing chars + for(size_t pos = length; pos < size; pos++) + { + buffer[pos] = 0; + } + } + + + // Convert a space-padded string to a 0-terminated string. DYNAMIC VERSION! + // Additional function parameter to specifify the max length of the final string, + // not including null char (useful for e.g. mod loaders) + template <size_t size> + void SpaceToNullStringFixed(char (&buffer)[size], size_t length) + //-------------------------------------------------------------- + { + STATIC_ASSERT(size > 0); + ASSERT(length < size); + // Remove Nulls in string + SpaceToNullString(buffer); + // Overwrite trailing chars + for(size_t pos = length; pos < size; pos++) + { + buffer[pos] = 0; + } + } + +}; + +#endif // STRINGFIXER_H Added: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp (rev 0) +++ trunk/OpenMPT/common/misc_util.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,75 @@ +#include "stdafx.h" +#include "misc_util.h" +#include <ctime> + +/* + * Loads resource. + * [in] lpName and lpType: parameters passed to FindResource(). + * [out] pData: Pointer to loaded resource data, nullptr if load not successful. + * [out] nSize: Size of the data in bytes, zero if load not succesfull. + * [out] hglob: HGLOBAL returned by LoadResource-function. + * Return: pData. + */ +LPCCH LoadResource(LPCTSTR lpName, LPCTSTR lpType, LPCCH& pData, size_t& nSize, HGLOBAL& hglob) +//--------------------------------------------------------------------------------------------- +{ + pData = nullptr; + nSize = 0; + hglob = nullptr; + HINSTANCE hInstance = AfxGetInstanceHandle(); + HRSRC hrsrc = FindResource(hInstance, lpName, lpType); + if (hrsrc != NULL) + { + hglob = LoadResource(hInstance, hrsrc); + if (hglob != NULL) + { + pData = reinterpret_cast<const char*>(LockResource(hglob)); + nSize = SizeofResource(hInstance, hrsrc); + } + } + return pData; +} + + +// Returns WinAPI error message corresponding to error code returned by GetLastError(). +CString GetErrorMessage(DWORD nErrorCode) +//--------------------------------------- +{ + LPVOID lpMsgBuf; + + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + nErrorCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, + NULL ); + + CString msg = (LPTSTR)lpMsgBuf; + LocalFree(lpMsgBuf); + + return msg; +} + + +std::basic_string<TCHAR> Util::sdTime::GetDateTimeStr() +{ + time_t t; + std::time(&t); + return _tctime(&t); +} + +time_t Util::sdTime::MakeGmTime(tm& timeUtc) +{ +#if (_MSC_VER < MSVC_VER_2005) + // VC++ 2003 doesn't have _mkgmtime + // This does not seem to work properly with DST time zones sometimes - if that's of any concern for you, please upgrade your compiler :) + TIME_ZONE_INFORMATION tzi; + GetTimeZoneInformation(&tzi); + const time_t timeUtcTimeT = mktime(&timeUtc) - tzi.Bias * 60; +#else + const time_t timeUtcTimeT = _mkgmtime(&timeUtc); +#endif + return timeUtcTimeT; +} + Added: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h (rev 0) +++ trunk/OpenMPT/common/misc_util.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,316 @@ +#ifndef MISC_UTIL_H +#define MISC_UTIL_H +#pragma once + +#include <sstream> +#include <string> +#include <limits> +#include "typedefs.h" +#if _HAS_TR1 + #include <type_traits> +#endif +#include <io.h> // for _taccess + +//Convert object(typically number) to string +template<class T> +inline std::string Stringify(const T& x) +//-------------------------------------- +{ + std::ostringstream o; + if(!(o << x)) return "FAILURE"; + else return o.str(); +} + +//Convert string to number. +template<class T> +inline T ConvertStrTo(LPCSTR psz) +//------------------------------- +{ + #if _HAS_TR1 + static_assert(std::tr1::is_const<T>::value == false && std::tr1::is_volatile<T>::value == false, "Const and volatile types are not handled correctly."); + #endif + if(std::numeric_limits<T>::is_integer) + return static_cast<T>(atoi(psz)); + else + return static_cast<T>(atof(psz)); +} + +template<> inline uint32 ConvertStrTo(LPCSTR psz) {return strtoul(psz, nullptr, 10);} +template<> inline int64 ConvertStrTo(LPCSTR psz) {return _strtoi64(psz, nullptr, 10);} +template<> inline uint64 ConvertStrTo(LPCSTR psz) {return _strtoui64(psz, nullptr, 10);} + + +// Memset given object to zero. +template <class T> +inline void MemsetZero(T &a) +//-------------------------- +{ +#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)); +} + + +// Copy given object to other location. +template <class T> +inline void MemCopy(T &destination, T &source) +//-------------------------------------------- +{ +#if _HAS_TR1 + static_assert(std::tr1::is_pointer<T>::value == false, "Won't copy pointers."); + static_assert(std::tr1::is_pod<T>::value == true, "Won't copy non-pods."); +#endif + memcpy(&destination, &source, sizeof(T)); +} + +template <class T> +inline void MemCopy(T &destination, const T &source) +//-------------------------------------------------- +{ +#if _HAS_TR1 + static_assert(std::tr1::is_pointer<T>::value == false, "Won't copy pointers."); + static_assert(std::tr1::is_pod<T>::value == true, "Won't copy non-pods."); +#endif + memcpy(&destination, &source, sizeof(T)); +} + + +// Limits 'val' to given range. If 'val' is less than 'lowerLimit', 'val' is set to value 'lowerLimit'. +// Similarly if 'val' is greater than 'upperLimit', 'val' is set to value 'upperLimit'. +// If 'lowerLimit' > 'upperLimit', 'val' won't be modified. +template<class T, class C> +inline void Limit(T& val, const C lowerLimit, const C upperLimit) +//--------------------------------------------------------------- +{ + if(lowerLimit > upperLimit) return; + if(val < lowerLimit) val = lowerLimit; + else if(val > upperLimit) val = upperLimit; +} + + +// Like Limit, but returns value +template<class T, class C> +inline T Clamp(T val, const C lowerLimit, const C upperLimit) +//----------------------------------------------------------- +{ + if(lowerLimit > upperLimit) return val; + if(val < lowerLimit) return lowerLimit; + else if(val > upperLimit) return upperLimit; + else return val; +} + + +// Like Limit, but with upperlimit only. +template<class T, class C> +inline void LimitMax(T& val, const C upperLimit) +//---------------------------------------------- +{ + if(val > upperLimit) + val = upperLimit; +} + + +// Like Limit, but returns value +#ifndef CLAMP +#define CLAMP(number, low, high) min(high, max(low, number)) +#endif + + +LPCCH LoadResource(LPCTSTR lpName, LPCTSTR lpType, LPCCH& pData, size_t& nSize, HGLOBAL& hglob); +CString GetErrorMessage(DWORD nErrorCode); + +namespace utilImpl +{ + template <bool bMemcpy> + struct ArrayCopyImpl {}; + + template <> + struct ArrayCopyImpl<true> + { + template <class T> + static void Do(T* pDst, const T* pSrc, const size_t n) {memcpy(pDst, pSrc, sizeof(T) * n);} + }; + + template <> + struct ArrayCopyImpl<false> + { + template <class T> + static void Do(T* pDst, const T* pSrc, const size_t n) {std::copy(pSrc, pSrc + n, pDst);} + }; +} // namespace utilImpl + + +// Copies n elements from array pSrc to array pDst. +// If the source and destination arrays overlap, behaviour is undefined. +template <class T> +void ArrayCopy(T* pDst, const T* pSrc, const size_t n) +//---------------------------------------------------- +{ + utilImpl::ArrayCopyImpl<std::tr1::has_trivial_assign<T>::value>::Do(pDst, pSrc, n); +} + + +// Sanitize a filename (remove special chars) +template <size_t size> +void SanitizeFilename(char (&buffer)[size]) +//----------------------------------------- +{ + STATIC_ASSERT(size > 0); + for(size_t i = 0; i < size; i++) + { + if( buffer[i] == '\\' || + buffer[i] == '\"' || + buffer[i] == '/' || + buffer[i] == ':' || + buffer[i] == '?' || + buffer[i] == '<' || + buffer[i] == '>' || + buffer[i] == '*') + { + for(size_t j = i + 1; j < size; j++) + { + buffer[j - 1] = buffer[j]; + } + buffer[size - 1] = 0; + } + } +} + + +// Greatest Common Divisor. +template <class T> +T gcd(T a, T b) +//------------- +{ + if(a < 0) + a = -a; + if(b < 0) + b = -b; + do + { + if(a == 0) + return b; + b %= a; + if(b == 0) + return a; + a %= b; + } +} + + +// Convert a variable-length MIDI integer <value> to a normal integer <result>. +// Function returns how many bytes have been read. +template <class TIn, class TOut> +size_t ConvertMIDI2Int(TOut &result, TIn value) +//--------------------------------------------- +{ + return ConvertMIDI2Int(result, (uint8 *)(&value), sizeof(TIn)); +} + + +// Convert a variable-length MIDI integer held in the byte buffer <value> to a normal integer <result>. +// maxLength bytes are read from the byte buffer at max. +// Function returns how many bytes have been read. +// TODO This should report overflow errors if TOut is too small! +template <class TOut> +size_t ConvertMIDI2Int(TOut &result, uint8 *value, size_t maxLength) +//------------------------------------------------------------------ +{ + static_assert(std::numeric_limits<TOut>::is_integer == true, "Output type is a not an integer"); + + if(maxLength <= 0) + { + result = 0; + return 0; + } + size_t bytesUsed = 0; + result = 0; + uint8 b; + do + { + b = *value; + result <<= 7; + result |= (b & 0x7F); + value++; + } while (++bytesUsed < maxLength && (b & 0x80) != 0); + return bytesUsed; +} + + +// Convert an integer <value> to a variable-length MIDI integer, held in the byte buffer <result>. +// maxLength bytes are written to the byte buffer at max. +// Function returns how many bytes have been written. +template <class TIn> +size_t ConvertInt2MIDI(uint8 *result, size_t maxLength, TIn value) +//---------------------------------------------------------------- +{ + static_assert(std::numeric_limits<TIn>::is_integer == true, "Input type is a not an integer"); + + if(maxLength <= 0) + { + *result = 0; + return 0; + } + size_t bytesUsed = 0; + do + { + *result = (value & 0x7F); + value >>= 7; + if(value != 0) + { + *result |= 0x80; + } + result++; + } while (++bytesUsed < maxLength && value != 0) + return bytesUsed; +} + + +namespace Util +{ + // Like std::max, but avoids conflict with max-macro. + template <class T> inline const T& Max(const T& a, const T& b) {return (std::max)(a, b);} + + // Like std::min, but avoids conflict with min-macro. + template <class T> inline const T& Min(const T& a, const T& b) {return (std::min)(a, b);} + + // 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 integer types are allowed."); return (std::numeric_limits<T>::max)();} + + /// Returns value rounded to nearest integer. + inline double Round(const double& val) {return std::floor(val + 0.5);} + + /// Rounds given double value to nearest integer value of type T. + template <class T> inline T Round(const double& val) + { + static_assert(std::numeric_limits<T>::is_integer == true, "Type is a not an integer"); + static_assert(sizeof(T) <= 4, "Revise the implementation for integers > 32-bits."); + const double valRounded = Round(val); + ASSERT(valRounded >= (std::numeric_limits<T>::min)() && valRounded <= (std::numeric_limits<T>::max)()); + const T intval = static_cast<T>(valRounded); + return intval; + } + + +}; + +namespace Util { namespace sdTime +{ + // Returns string containing date and time ended with newline. + std::basic_string<TCHAR> GetDateTimeStr(); + + time_t MakeGmTime(tm& timeUtc); + +}}; // namespace Util::sdTime + +namespace Util { namespace sdOs +{ + /// Checks whether file or folder exists and whether it has the given mode. + enum FileMode {FileModeExists = 0, FileModeRead = 4, FileModeWrite = 2, FileModeReadWrite = 6}; + inline bool IsPathFileAvailable(LPCTSTR pszFilePath, FileMode fm) {return (_taccess(pszFilePath, fm) == 0);} + +} } // namespace Util::sdOs + +#endif Added: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h (rev 0) +++ trunk/OpenMPT/common/typedefs.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,70 @@ +#ifndef TYPEDEFS_H +#define TYPEDEFS_H + +#define nullptr 0 + +// CountOf macro computes the number of elements in a statically-allocated array. +#if _MSC_VER >= 1400 + #define CountOf(x) _countof(x) +#else + #define CountOf(x) (sizeof(x)/sizeof(x[0])) +#endif + +#define ARRAYELEMCOUNT(x) CountOf(x) + +//Compile time assert. +#define STATIC_ASSERT(expr) C_ASSERT(expr) +#define static_assert(expr, msg) C_ASSERT(expr) + + +typedef __int8 int8; +typedef __int16 int16; +typedef __int32 int32; +typedef __int64 int64; + +typedef unsigned __int8 uint8; +typedef unsigned __int16 uint16; +typedef unsigned __int32 uint32; +typedef unsigned __int64 uint64; + +const int8 int8_min = -127-1; +const int16 int16_min = -32767-1; +const int32 int32_min = -2147483647-1; +const int64 int64_min = -9223372036854775807-1; + +const int8 int8_max = 127; +const int16 int16_max = 32767; +const int32 int32_max = 2147483647; +const int64 int64_max = 9223372036854775807; + +const uint8 uint8_max = 255; +const uint16 uint16_max = 65535; +const uint32 uint32_max = 4294967295; +const uint64 uint64_max = 18446744073709551615; + +typedef float float32; + + +#if !_HAS_TR1 + namespace std + { + namespace tr1 + { + template <class T> struct has_trivial_assign {static const bool value = false;}; + + #define SPECIALIZE_TRIVIAL_ASSIGN(type) template <> struct has_trivial_assign<type> {static const bool value = true;} + SPECIALIZE_TRIVIAL_ASSIGN(int8); + SPECIALIZE_TRIVIAL_ASSIGN(uint8); + SPECIALIZE_TRIVIAL_ASSIGN(int16); + SPECIALIZE_TRIVIAL_ASSIGN(uint16); + SPECIALIZE_TRIVIAL_ASSIGN(int32); + SPECIALIZE_TRIVIAL_ASSIGN(uint32); + SPECIALIZE_TRIVIAL_ASSIGN(int64); + SPECIALIZE_TRIVIAL_ASSIGN(uint64); + #undef SPECIALIZE_TRIVIAL_ASSIGN + }; + }; +#endif + + +#endif Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -9,7 +9,7 @@ #include "fxp.h" #include "dlg_misc.h" #include "AbstractVstEditor.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #ifndef NO_VST @@ -29,10 +29,10 @@ ON_COMMAND(ID_VSTPRESETBACKWARDJUMP,OnVSTPresetBackwardJump) ON_COMMAND(ID_VSTPRESETFORWARDJUMP, OnVSTPresetForwardJump) ON_COMMAND(ID_PLUGINTOINSTRUMENT, OnCreateInstrument) - ON_COMMAND_RANGE(ID_PRESET_SET, ID_PRESET_SET+MAX_PLUGPRESETS, OnSetPreset) + ON_COMMAND_RANGE(ID_PRESET_SET, ID_PRESET_SET + MAX_PLUGPRESETS, OnSetPreset) ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys - ON_COMMAND_RANGE(ID_PLUGSELECT, ID_PLUGSELECT+MAX_MIXPLUGINS, OnToggleEditor) //rewbs.patPlugName - ON_COMMAND_RANGE(ID_SELECTINST, ID_SELECTINST+MAX_INSTRUMENTS, OnSetInputInstrument) //rewbs.patPlugName + ON_COMMAND_RANGE(ID_PLUGSELECT, ID_PLUGSELECT + MAX_MIXPLUGINS, OnToggleEditor) //rewbs.patPlugName + ON_COMMAND_RANGE(ID_SELECTINST, ID_SELECTINST + MAX_INSTRUMENTS, OnSetInputInstrument) //rewbs.patPlugName ON_COMMAND_RANGE(ID_LEARN_MACRO_FROM_PLUGGUI, ID_LEARN_MACRO_FROM_PLUGGUI + NUM_MACROS, PrepareToLearnMacro) END_MESSAGE_MAP() @@ -111,7 +111,7 @@ m_pVstPlugin->GetModDoc()->SetModified(); } else { - ::AfxMessageBox("Error loading preset. Are you sure it is for this plugin?"); + Reporting::Notification("Error loading preset. Are you sure it is for this plugin?"); } } @@ -129,7 +129,7 @@ //TODO: exception handling if (!(m_pVstPlugin->SaveProgram(files.first_file.c_str()))) - ::AfxMessageBox("Error saving preset."); + Reporting::Notification("Error saving preset."); } @@ -138,7 +138,7 @@ { if (m_pVstPlugin) { - if (::AfxMessageBox("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", MB_YESNO|MB_ICONEXCLAMATION) == IDYES) + if (Reporting::Notification("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", MB_YESNO | MB_ICONEXCLAMATION) == IDYES) m_pVstPlugin->RandomizeParams(); UpdateParamDisplays(); } @@ -355,7 +355,7 @@ return false; if(!m_pVstPlugin->isInstrument() || pModDoc->GetSoundFile()->GetModSpecifications().instrumentsMax == 0 || - AfxMessageBox(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), MB_YESNO | MB_ICONQUESTION) == IDNO) + Reporting::Notification(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), MB_YESNO | MB_ICONQUESTION) == IDNO) { return false; } else Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -85,7 +85,7 @@ } else { m_bEnabled = false; - AfxMessageBox("Warning: Autosave failed and has been disabled. Please:\n- Review your autosave paths\n- Check available diskspace & filesystem access rights\n- If you are using the ITP format, ensure all instruments exist as independant .iti files"); + Reporting::Notification("Warning: Autosave failed and has been disabled. Please:\n- Review your autosave paths\n- Check available diskspace & filesystem access rights\n- If you are using the ITP format, ensure all instruments exist as independant .iti files"); success = false; } } @@ -475,8 +475,9 @@ } bool pathIsOK = !_access(path, 0); - if (!pathIsOK && IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) && !IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR)) { - ::AfxMessageBox("Error: backup path does not exist.", MB_OK|MB_ICONEXCLAMATION); + if (!pathIsOK && IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) && !IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR)) + { + Reporting::Notification("Error: backup path does not exist.", MB_OK | MB_ICONEXCLAMATION); ::SetFocus(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_PATH)); return 0; } Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -546,7 +546,7 @@ { //We don't remove an instrument's unused samples in an ITP. wsprintf(s, "OpenMPT detected %d sample%s referenced by an instrument,\n" "but not used in the song. Do you want to remove them?", nExt, (nExt == 1) ? "" : "s"); - if (::MessageBox(NULL, s, "Sample Cleanup", MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Notification(s, "Sample Cleanup", MB_YESNO | MB_ICONQUESTION) == IDYES) { CriticalSection cs; for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->GetNumSamples(); nSmp++) @@ -588,7 +588,7 @@ CHAR s[512]; wsprintf(s, "%d sample%s unused data after the loop end point,\n" "Do you want to optimize %s and remove this unused data?", nLoopOpt, (nLoopOpt == 1) ? " has" : "s have", (nLoopOpt == 1) ? "it" : "them"); - if (::MessageBox(NULL, s, "Sample Optimization", MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Notification(s, "Sample Optimization", MB_YESNO | MB_ICONQUESTION) == IDYES) { for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->m_nSamples; nSmp++) { @@ -712,13 +712,13 @@ char removeSamples = -1; if ( !((pSndFile->GetType() == MOD_TYPE_IT) && (pSndFile->m_dwSongFlags & SONG_ITPROJECT))) //never remove an instrument's samples in ITP. { - if(::MessageBox(NULL, "Remove samples associated with an instrument if they are unused?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES) + if(Reporting::Notification("Remove samples associated with an instrument if they are unused?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES) { removeSamples = 1; } } else { - ::MessageBox(NULL, "This is an IT project file, so no samples associated with an used instrument will be removed.", "Removing unused instruments", MB_OK | MB_ICONINFORMATION); + Reporting::Notification("This is an IT project file, so no samples associated with an used instrument will be removed.", "Removing unused instruments", MB_OK | MB_ICONINFORMATION); } BeginWaitCursor(); @@ -746,7 +746,7 @@ } EndWaitCursor(); if ((bReorg) && (pSndFile->m_nInstruments > 1) - && (::MessageBox(NULL, "Do you want to reorganize the remaining instruments?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES)) + && (Reporting::Notification("Do you want to reorganize the remaining instruments?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES)) { BeginWaitCursor(); CriticalSection cs; @@ -870,7 +870,7 @@ if(pSndFile == nullptr) return false; //jojo.compocleanup - if(::MessageBox(NULL, TEXT("WARNING: OpenMPT will convert the module to IT format and reset all song, sample and instrument attributes to default values. Continue?"), TEXT("Resetting variables"), MB_YESNO | MB_ICONWARNING) == IDNO) + if(Reporting::Notification(TEXT("WARNING: OpenMPT will convert the module to IT format and reset all song, sample and instrument attributes to default values. Continue?"), TEXT("Resetting variables"), MB_YESNO | MB_ICONWARNING) == IDNO) return false; // Stop play. Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -1,8 +1,9 @@ //rewbs.customKeys #include "stdafx.h" -#include ".\commandset.h" +#include "commandset.h" #include "resource.h" +#include "../common/Reporting.h" #include <stdio.h> #include <stdlib.h> #include <fstream> @@ -43,7 +44,7 @@ { //CHAR s[64]; //wsprintf(s, "pointer = %lX",plocalCmdSet); - //::MessageBox(NULL, "about to remove all", NULL, MB_OK|MB_ICONEXCLAMATION); //disabled by rewbs + //Reporting::Notification("about to remove all", NULL, MB_OK|MB_ICONEXCLAMATION); //disabled by rewbs //commands.RemoveAll(); } @@ -1479,7 +1480,7 @@ while(iStrm.getline(s, sizeof(s))) { - //::MessageBox(NULL, s, "", MB_ICONEXCLAMATION|MB_OK); + //Reporting::Notification(s, MB_ICONEXCLAMATION|MB_OK); curLine = s; @@ -1583,7 +1584,7 @@ CString err; err.Format("The following problems have been encountered while trying to load the key binding file %s:\n", szFilename); err += errText; - ::MessageBox(NULL, err, "", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(err, MB_ICONEXCLAMATION | MB_OK); } if(fileVersion < KEYMAP_VERSION) UpgradeKeymap(pTempCS, fileVersion); @@ -1601,7 +1602,7 @@ { CString strMsg; AfxFormatString1(strMsg, IDS_CANT_OPEN_KEYBINDING_FILE, fileName); - AfxMessageBox(strMsg, MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(strMsg, MB_ICONEXCLAMATION | MB_OK); return false; } else Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -7,7 +7,7 @@ #include "ctrl_gen.h" #include "view_gen.h" #include "math.h" -#include "misc_util.h" +#include "../common/misc_util.h" // -> CODE#0015 // -> DESC="channels management dlg" Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -8,8 +8,8 @@ #include "view_ins.h" #include "dlg_misc.h" #include "tuningDialog.h" -#include "misc_util.h" -#include "../soundlib/StringFixer.h" +#include "../common/misc_util.h" +#include "../common/StringFixer.h" #include "SelectPluginDialog.h" #pragma warning(disable:4244) //conversion from 'type1' to 'type2', possible loss of data Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -8,7 +8,7 @@ #include "ctrl_pat.h" #include "view_pat.h" #include "ChannelManagerDlg.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" ////////////////////////////////////////////////////////////// @@ -1128,7 +1128,7 @@ // If this macro is not the default IT macro, display a warning. if(!m_pModDoc->IsMacroDefaultSetupUsed()) { - if(AfxMessageBox(_T("You have chosen not to embed MIDI macros. However, the current macro configuration differs from the default macro configuration that is assumed when loading a file that has no macros embedded. This can result in data loss and broken playback.\nWould you like to embed MIDI macros now?"), MB_YESNO) == IDYES) + if(Reporting::Notification(_T("You have chosen not to embed MIDI macros. However, the current macro configuration differs from the default macro configuration that is assumed when loading a file that has no macros embedded. This can result in data loss and broken playback.\nWould you like to embed MIDI macros now?"), MB_YESNO) == IDYES) { m_pSndFile->m_dwSongFlags |= SONG_EMBEDMIDICFG; m_pModDoc->SetModified(); Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -1399,7 +1399,7 @@ CString strParam; strParam.Format(TEXT("%u: %s"), rSf.Order.GetCurrentSequenceIndex(), (LPCTSTR)rSf.Order.m_sName); CString str; AfxFormatString1(str, IDS_CONFIRM_SEQUENCE_DELETE, strParam); - if (AfxMessageBox(str, MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Notification(str, MB_YESNO | MB_ICONQUESTION) == IDYES) rSf.Order.RemoveSequence(); else { Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -16,7 +16,7 @@ #include "smbPitchShift.cpp" #pragma warning(default:4244) //"conversion from 'type1' to 'type2', possible loss of data" #include "modsmp_ctrl.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include <Shlwapi.h> #ifdef _DEBUG @@ -1826,7 +1826,7 @@ default: wsprintf(str, _T("Unknown Error...")); break; } - AfxMessageBox(str, MB_ICONERROR); + Reporting::Notification(str, MB_ICONERROR); return; } @@ -1897,7 +1897,7 @@ { CString str; str.Format(TEXT(GetStrI18N("Current samplerate, %u Hz, is not in the supported samplerate range 8000 Hz - 48000 Hz. Continue?")), nSampleRate); - if(AfxMessageBox(str, MB_ICONQUESTION|MB_YESNO) != IDYES) + if(Reporting::Notification(str, MB_ICONQUESTION|MB_YESNO) != IDYES) return -1; } Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -42,14 +42,15 @@ //-------------------------------------------------------------------------------- { CSliderCtrl* pScrolledSlider = reinterpret_cast<CSliderCtrl*>(pScrollBar); - if ((pScrolledSlider == &m_slParam) && (nSBCode != SB_ENDSCROLL) ) { + if ((pScrolledSlider == &m_slParam) && (nSBCode != SB_ENDSCROLL)) + { OnParamSliderChanged(); } CAbstractVstEditor::OnVScroll(nSBCode, nPos, pScrollBar); } BOOL CDefaultVstEditor::OpenEditor(CWnd *parent) -//--------------------------------------- +//---------------------------------------------- { Create(IDD_DEFAULTPLUGINEDITOR, parent); SetTitle(); @@ -59,12 +60,14 @@ ShowWindow(SW_SHOW); // Fill param listbox - if (m_pVstPlugin) { + if (m_pVstPlugin) + { char s[128]; long nParams = m_pVstPlugin->GetNumParameters(); m_lbParameters.SetRedraw(FALSE); //disable lisbox refreshes during fill to avoid flicker m_lbParameters.ResetContent(); - for (long i=0; i<nParams; i++) { + for (long i=0; i<nParams; i++) + { CHAR sname[64]; m_pVstPlugin->GetParamName(i, sname, sizeof(sname)); wsprintf(s, "%02X: %s", i|0x80, sname); Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -8,7 +8,7 @@ #include "EffectVis.h" //rewbs.fxvis #include "ChannelManagerDlg.h" #include "../soundlib/tuningbase.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include <string> using std::string; @@ -610,7 +610,7 @@ { UINT nSkip = m_nMidRow - yofs; UINT nPrevPat = m_nPattern; - BOOL bPrevPatFound = FALSE; + bool bPrevPatFound = false; // Display previous pattern if (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_SHOWPREVIOUS) @@ -625,14 +625,14 @@ if(startOrder < pSndFile->Order.size() && pSndFile->Order[startOrder] == m_nPattern) { nPrevPat = pSndFile->Order[prevOrder]; - bPrevPatFound = TRUE; + bPrevPatFound = true; } } } if ((bPrevPatFound) && (nPrevPat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[nPrevPat])) { UINT nPrevRows = pSndFile->Patterns[nPrevPat].GetNumRows(); - UINT n = (nSkip < nPrevRows) ? nSkip : nPrevRows; + UINT n = min(nSkip, nPrevRows); ypaint += (nSkip-n)*m_szCell.cy; rect.SetRect(0, m_szHeader.cy, nColumnWidth * ncols + m_szHeader.cx, ypaint - 1); @@ -664,7 +664,7 @@ if ((nVisRows > 0) && (m_nMidRow)) { UINT nNextPat = m_nPattern; - BOOL bNextPatFound = FALSE; + bool bNextPatFound = false; const ORDERINDEX startOrder= static_cast<ORDERINDEX>(SendCtrlMessage(CTRLMSG_GETCURRENTORDER)); ORDERINDEX nNextOrder; nNextOrder = pSndFile->Order.GetNextOrderIgnoringSkips(startOrder); @@ -675,12 +675,12 @@ if ((nNextOrder < ordCount) && (pSndFile->Order[startOrder] == m_nPattern)) { nNextPat = pSndFile->Order[nNextOrder]; - bNextPatFound = TRUE; + bNextPatFound = true; } if ((bNextPatFound) && (nNextPat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[nNextPat])) { UINT nNextRows = pSndFile->Patterns[nNextPat].GetNumRows(); - UINT n = ((UINT)nVisRows < nNextRows) ? nVisRows : nNextRows; + UINT n = min((UINT)nVisRows, nNextRows); m_Dib.SetBlendMode(0x80); DrawPatternData(hdc, pSndFile, nNextPat, FALSE, FALSE, @@ -1322,6 +1322,7 @@ void CViewPattern::OnSize(UINT nType, int cx, int cy) //--------------------------------------------------- { + // TODO: Switching between modules (when MDI childs are maximized) first calls this with the windowed size, then with the maximized size, which makes the scrollbars move. Eww! CScrollView::OnSize(nType, cx, cy); if (((nType == SIZE_RESTORED) || (nType == SIZE_MAXIMIZED)) && (cx > 0) && (cy > 0)) { Modified: trunk/OpenMPT/mptrack/EffectVis.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectVis.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/EffectVis.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -686,7 +686,7 @@ MakeChange(m_nDragItem, point.y); } else if ((m_dwStatus & FXVSTATUS_LDRAGGING)) - { + { // Interpolate if we detect that rows have been skipped but the left mouse button was not released. // This ensures we produce a smooth curve even when we are not notified of mouse movements at a high frequency (e.g. if CPU usage is high) if ((m_nLastDrawnRow>(int)m_startRow) && ((int)row != m_nLastDrawnRow) && ((int)row != m_nLastDrawnRow+1) && ((int)row != m_nLastDrawnRow-1)) @@ -728,7 +728,7 @@ if (IsPcNote(row)) { paramValue = ScreenYToPCParam(point.y); - wsprintf(effectName, "%s", "Param Control"); //TODO - show smooth & plug+param + wsprintf(effectName, "%s", "Param Control"); // TODO - show smooth & plug+param } else { @@ -765,14 +765,16 @@ void CEffectVis::OnEditUndo() +//--------------------------- { - CHAR s[64]; - wsprintf(s, "Undo Through!"); - ::MessageBox(NULL, s, NULL, MB_OK|MB_ICONEXCLAMATION); + CHAR s[64]; + strcpy(s, "Undo Through!"); + Reporting::Notification(s, MB_OK | MB_ICONEXCLAMATION); } + BOOL CEffectVis::OnInitDialog() -//-------------------------------- +//----------------------------- { CModControlDlg::OnInitDialog(); if (m_pModDoc->GetModType() == MOD_TYPE_MPT && IsPcNote(m_startRow)) @@ -828,13 +830,15 @@ } void CEffectVis::MakeChange(int row, long y) +//------------------------------------------ { MODCOMMAND *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (!pcmd) { + if (!pcmd) + { return; } - int offset = row*m_pSndFile->m_nChannels + m_nChan; + int offset = row * m_pSndFile->GetNumChannels() + m_nChan; switch (m_nAction) { @@ -871,7 +875,8 @@ break; case kAction_Preserve: - if (GetCommand(row) || IsPcNote(row)) { + if (GetCommand(row) || IsPcNote(row)) + { // Only set param if we have an effect type or if this is a PC note. // Never change the effect type. SetParamFromY(row, y); Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -137,7 +137,7 @@ } } - ::MessageBox(window, errorMessage, "OpenMPT Crash", MB_ICONERROR); + Reporting::Notification(errorMessage, "OpenMPT Crash", MB_ICONERROR, window); // Let Windows handle the exception... return EXCEPTION_CONTINUE_SEARCH; Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Globals.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -203,7 +203,7 @@ CModControlView::CModControlView() //-------------------------------- { - memset(m_Pages, 0, sizeof(m_Pages)); + MemsetZero(m_Pages); m_nActiveDlg = -1; m_nInstrumentChanged = -1; m_hWndView = NULL; Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -531,7 +531,7 @@ if (cmd<0 || m_nCurKeyChoice<0 || m_nCurKeyChoice>=ih->GetKeyListSize(cmd)) { CString error = "Nothing to restore for this slot."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; } @@ -552,7 +552,7 @@ if (m_nCurHotKey<0 || m_nCurKeyChoice<0 || m_nCurKeyChoice>=plocalCmdSet->GetKeyListSize(cmd)) { CString error = "No key currently set for this slot."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; } @@ -573,7 +573,7 @@ if (cmd<0) { CString error = "Invalid slot."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; } @@ -589,13 +589,13 @@ if (!kc.code) { CString error = "You need to say to which key you'd like to map this command."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; } if (!kc.event) { /* CString error = "You need to select at least one key event type (up, down or hold)."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; */ kc.event = kKeyEventDown; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -2193,7 +2193,7 @@ AfxFormatString1(str, IDS_FILE_EXISTS_BUT_IS_NOT_READABLE, (LPCTSTR)sPath); else AfxFormatString1(str, IDS_FILE_DOES_NOT_EXIST, (LPCTSTR)sPath); - AfxMessageBox(str); + Reporting::Notification(str); } } else Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -121,10 +121,10 @@ if((m_SndFile.GetNumInstruments() || nResizedPatterns) && (nNewType & (MOD_TYPE_MOD|MOD_TYPE_S3M))) { - if(::MessageBox(NULL, - "This operation will convert all instruments to samples,\n" - "and resize all patterns to 64 rows.\n" - "Do you want to continue?", "Warning", MB_YESNO | MB_ICONQUESTION) != IDYES) return false; + if(Reporting::Notification( + "This operation will convert all instruments to samples,\n" + "and resize all patterns to 64 rows.\n" + "Do you want to continue?", "Warning", MB_YESNO | MB_ICONQUESTION) != IDYES) return false; BeginWaitCursor(); CriticalSection cs; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -15,7 +15,7 @@ #include "version.h" #include "modsmp_ctrl.h" #include "CleanupSong.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include <shlwapi.h> extern WORD S3MFineTuneTable[16]; @@ -232,7 +232,7 @@ { CString sTemp; sTemp.Format("File: %s\nLast saved with: %s, current version is %s\n\n%s", lpszPathName, (LPCTSTR)MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), MptVersion::str, GetLog()); - AfxMessageBox(sTemp, MB_ICONINFORMATION); + Reporting::Notification(sTemp, MB_ICONINFORMATION); ClearLog(); } @@ -423,7 +423,7 @@ wsprintf(s, "Warning: this song was last saved with a more recent version of OpenMPT.\r\nSong saved with: v%s. Current version: v%s.\r\n", (LPCTSTR)MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), MptVersion::str); - ::AfxMessageBox(s); + Reporting::Notification(s); } SetModifiedFlag(FALSE); // (bModified); @@ -481,7 +481,7 @@ } else { if(type == MOD_TYPE_IT && m_SndFile.m_dwSongFlags & SONG_ITPROJECT) - AfxMessageBox(_T("ITP projects need to have a path set for each instrument..."), MB_ICONERROR | MB_OK); + Reporting::Notification(_T("ITP projects need to have a path set for each instrument..."), MB_ICONERROR | MB_OK); else ErrorBox(IDS_ERR_SAVESONG, CMainFrame::GetMainFrame()); } @@ -508,7 +508,8 @@ } } - if(unsavedInstrument && ::MessageBox(NULL,"Do you want to save modified instruments?",NULL,MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES){ + if(unsavedInstrument && Reporting::Notification("Do you want to save modified instruments?", MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES) + { for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++) { @@ -853,7 +854,7 @@ CShowLogDlg dlg(parent); return dlg.ShowLog(m_lpszLog, lpszTitle); #else - return ::MessageBox((parent) ? parent->m_hWnd : NULL, m_lpszLog, lpszTitle, MB_OK|MB_ICONINFORMATION); + return Reporting::Notification(m_lpszLog, lpszTitle, MB_OK | MB_ICONINFORMATION, (parent) ? parent->m_hWnd : nullptr); #endif } return IDCANCEL; @@ -1801,24 +1802,24 @@ { case MOD_TYPE_MOD: pattern = FileFilterMOD; - if( AfxMessageBox(GetStrI18N(TEXT( + if(Reporting::Notification(GetStrI18N(TEXT( "Compared to regular MOD save, compatibility export adjusts the beginning of oneshot samples " "in order to make the file compatible with ProTracker and other Amiga-based trackers. " "Note that this feature does not remove effects \"invented\" by other PC-based trackers (f.e. panning commands)." - "\n\n Proceed?")), MB_ICONINFORMATION|MB_YESNO) != IDYES + "\n\n Proceed?")), MB_ICONINFORMATION | MB_YESNO) != IDYES ) return; break; case MOD_TYPE_IT: pattern = FileFilterIT; - ::MessageBox(NULL,"Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.",MB_ICONINFORMATION | MB_OK); + Reporting::Notification("Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.", MB_ICONINFORMATION | MB_OK); break; case MOD_TYPE_XM: pattern = FileFilterXM; - ::MessageBox(NULL,"Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.",MB_ICONINFORMATION | MB_OK); + Reporting::Notification("Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.", MB_ICONINFORMATION | MB_OK); break; default: - ::MessageBox(NULL,"Compatibility export is currently only available for MOD, XM and IT modules.", "Can't do compatibility export.",MB_ICONINFORMATION | MB_OK); + Reporting::Notification("Compatibility export is currently only available for MOD, XM and IT modules.", "Can't do compatibility export.", MB_ICONINFORMATION | MB_OK); return; } ext = m_SndFile.GetModSpecifications().fileExtension; @@ -3811,13 +3812,13 @@ { CString message; message.Format("Param %d beyond controllable range.", paramToUse); - ::MessageBox(NULL,message, "Macro not assigned for this param",MB_ICONINFORMATION | MB_OK); + Reporting::Notification(message, "Macro not assigned for this param", MB_ICONINFORMATION | MB_OK); return; } CString message; message.Format("Param %d can now be controlled with macro %X", paramToUse, macroToSet); - ::MessageBox(NULL, message, "Macro assigned for this param",MB_ICONINFORMATION | MB_OK); + Reporting::Notification(message, "Macro assigned for this param", MB_ICONINFORMATION | MB_OK); return; } @@ -3986,7 +3987,7 @@ { CString sErrMsg; AfxFormatString1(sErrMsg, IDS_UNABLE_TO_CREATE_USER_TEMPLATE_FOLDER, pszTemplateFolder); - AfxMessageBox(sErrMsg); + Reporting::Notification(sErrMsg); return; } } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Moddoc.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -10,7 +10,7 @@ #endif // _MSC_VER >= 1000 #include "sndfile.h" -#include "misc_util.h" +#include "../common/misc_util.h" #include "Undo.h" #include <time.h> Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -8,7 +8,7 @@ #include "dlg_misc.h" #include "dlsbank.h" #include "modsmp_ctrl.h" -#include "misc_util.h" +#include "../common/misc_util.h" #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" @@ -43,7 +43,7 @@ { CString error; error.Format("Error: Max number of channels for this file type is %d", maxChans); - ::AfxMessageBox(error, MB_OK|MB_ICONEXCLAMATION); + Reporting::Notification(error, MB_OK | MB_ICONEXCLAMATION); return false; } Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -288,7 +288,7 @@ else { m_PreAmpNoteShowed = true; - AfxMessageBox(str_preampChangeNote, MB_ICONINFORMATION); + Reporting::Notification(str_preampChangeNote, MB_ICONINFORMATION); SetPreAmpSliderPosition(); } } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -18,7 +18,7 @@ #include <afxadv.h> #include <shlwapi.h> #include "UpdateCheck.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include "ExceptionHandler.h" // rewbs.memLeak @@ -97,7 +97,7 @@ { CString str; str.Format(GetStrI18N(_TEXT("Unable to open \"%s\": file does not exist.")), path); - AfxMessageBox(str); + Reporting::Notification(str); } else //Case: Valid path but opening fails. { @@ -109,7 +109,7 @@ "recommended to close some documents as otherwise crash is likely" "(currently there %s %d document%s open).")), path, (nOdc == 1) ? "is" : "are", nOdc, (nOdc == 1) ? "" : "s"); - AfxMessageBox(str); + Reporting::Notification(str); } } } @@ -2177,7 +2177,7 @@ if(nonFoundPlugs.GetLength() > 0) { nonFoundPlugs.Insert(0, "Problems were encountered with plugins:\n"); - MessageBox(NULL, nonFoundPlugs, "", MB_OK); + Reporting::Notification(nonFoundPlugs); } return FALSE; } Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Mptrack.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -16,6 +16,7 @@ #include "../soundlib/Sndfile.h" #include "ACMConvert.h" #include <windows.h> +#include "../common/Reporting.h" class CModDoc; class CVstPluginManager; Modified: trunk/OpenMPT/mptrack/PSRatioCalc.cpp =================================================================== --- trunk/OpenMPT/mptrack/PSRatioCalc.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/PSRatioCalc.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -162,7 +162,7 @@ { if (m_dRatio<50.0 || m_dRatio>200.0) { - ::MessageBox(NULL, "Error: ratio must be between 50% and 200%.", + Reporting::Notification("Error: ratio must be between 50% and 200%.", "Error", MB_ICONERROR | MB_OK); return; } Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -711,7 +711,7 @@ || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) || (m_nChannel >= pSndFile->m_nChannels) || (!pSndFile->Patterns[m_nPattern])) return; - MODCOMMAND *m = pSndFile->Patterns[m_nPattern]+m_nRow*pSndFile->m_nChannels+m_nChannel; + MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); if ((m->note != note) || (m->instr != instr)) { if(!m_bModified) // let's create just one undo step. @@ -740,7 +740,7 @@ || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) || (m_nChannel >= pSndFile->m_nChannels) || (!pSndFile->Patterns[m_nPattern])) return; - MODCOMMAND *m = pSndFile->Patterns[m_nPattern]+m_nRow*pSndFile->m_nChannels+m_nChannel; + MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); if ((m->volcmd != volcmd) || (m->vol != vol)) { if(!m_bModified) // let's create just one undo step. @@ -768,7 +768,7 @@ || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) || (m_nChannel >= pSndFile->m_nChannels) || (!pSndFile->Patterns[m_nPattern])) return; - MODCOMMAND *m = pSndFile->Patterns[m_nPattern]+m_nRow*pSndFile->m_nChannels+m_nChannel; + MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" Modified: trunk/OpenMPT/mptrack/Stdafx.h =================================================================== --- trunk/OpenMPT/mptrack/Stdafx.h 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Stdafx.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -94,7 +94,7 @@ void Log(LPCSTR format,...); -#include "typedefs.h" +#include "../common/typedefs.h" //To mark string that should be translated in case of multilingual version. #define GetStrI18N(x) (x) Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -19,9 +19,9 @@ #include "UpdateCheck.h" #include "Mpdlgs.h" #include "AutoSaver.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include "TrackerSettings.h" -#include "misc_util.h" +#include "../common/misc_util.h" const TCHAR *TrackerSettings::m_szDirectoryToSettingsName[NUM_DIRS] = { _T("Songs_Directory"), _T("Samples_Directory"), _T("Instruments_Directory"), _T("Plugins_Directory"), _T("Plugin_Presets_Directory"), _T("Export_Directory"), _T(""), _T("") }; @@ -412,6 +412,11 @@ GetPrivateProfileStruct("Effects", "EQ_User2", &CEQSetupDlg::gUserPresets[1], sizeof(EQPRESET), iniFile); GetPrivateProfileStruct("Effects", "EQ_User3", &CEQSetupDlg::gUserPresets[2], sizeof(EQPRESET), iniFile); GetPrivateProfileStruct("Effects", "EQ_User4", &CEQSetupDlg::gUserPresets[3], sizeof(EQPRESET), iniFile); + StringFixer::SetNullTerminator(m_EqSettings.szName); + StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[0].szName); + StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[1].szName); + StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[2].szName); + StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[3].szName); // Auto saver settings @@ -458,7 +463,7 @@ if (pEqSettings->Gains[i] > 32) pEqSettings->Gains[i] = 16; if ((pEqSettings->Freqs[i] < 100) || (pEqSettings->Freqs[i] > 10000)) pEqSettings->Freqs[i] = CEQSetupDlg::gEQPresets[0].Freqs[i]; } - pEqSettings->szName[sizeof(pEqSettings->szName)-1] = 0; + StringFixer::SetNullTerminator(pEqSettings->szName); } Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -3,8 +3,8 @@ #include "TuningDialog.h" #include "MainFrm.h" #include <algorithm> -#include "misc_util.h" -#include ".\tuningdialog.h" +#include "../common/misc_util.h" +#include "tuningdialog.h" const CTuningDialog::TUNINGTREEITEM CTuningDialog::s_notFoundItemTuning = TUNINGTREEITEM(); const HTREEITEM CTuningDialog::s_notFoundItemTree = NULL; @@ -458,7 +458,7 @@ TUNINGTYPE newType = GetTuningTypeFromStr(strNewType); if(!m_pActiveTuning->IsOfType(newType)) { - if(MessageBox("This action may change the ratio values; continue?", 0, MB_YESNO) == IDYES) + if(Reporting::Notification("This action may change the ratio values; continue?", MB_YESNO) == IDYES) { m_ModifiedTCs[GetpTuningCollection(m_pActiveTuning)] = true; @@ ... [truncated message content] |