123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- #pragma once
- #include "openmpt/all/BuildSettings.hpp"
- #include "openmpt/base/FlagSet.hpp"
- #include "../soundlib/Snd_defs.h"
- OPENMPT_NAMESPACE_BEGIN
- enum HintCategory
- {
- HINTCAT_GLOBAL = 0,
- HINTCAT_GENERAL = 0,
- HINTCAT_PATTERNS = 1,
- HINTCAT_SAMPLES = 2,
- HINTCAT_INSTRUMENTS = 3,
- HINTCAT_SEQUENCE = 4,
- HINTCAT_PLUGINS = 5,
- HINTCAT_COMMENTS = 6,
- NUM_HINTCATS
- };
- enum HintType
- {
-
- HINT_NONE = 0x00,
- HINT_MODTYPE = 0x01,
- HINT_MPTOPTIONS = 0x02,
- HINT_UNDO = 0x04,
- HINT_ALLGLOBAL = HINT_MODTYPE | HINT_MPTOPTIONS | HINT_UNDO,
-
-
- HINT_MODGENERAL = 0x10,
- HINT_MODCHANNELS = 0x20,
- HINT_TUNINGS = 0x40,
-
- HINT_PATTERNDATA = 0x10,
- HINT_PATTERNROW = 0x20,
- HINT_PATNAMES = 0x40,
-
- HINT_SAMPLEINFO = 0x10,
- HINT_SAMPLEDATA = 0x20,
- HINT_SMPNAMES = 0x40,
-
- HINT_INSTRUMENT = 0x10,
- HINT_ENVELOPE = 0x20,
- HINT_INSNAMES = 0x40,
-
- HINT_MODSEQUENCE = 0x10,
- HINT_SEQNAMES = 0x20,
- HINT_RESTARTPOS = 0x40,
-
- HINT_MIXPLUGINS = 0x10,
- HINT_PLUGINNAMES = 0x20,
- HINT_PLUGINPARAM = 0x40,
-
- HINT_MODCOMMENTS = 0x10,
- };
- DECLARE_FLAGSET(HintType)
- struct UpdateHint
- {
- protected:
- using store_t = uint32;
- union
- {
- struct
- {
- store_t type : 7;
- store_t category : 3;
- store_t item : 22;
- };
- store_t rawData;
- };
-
- UpdateHint(HintCategory category_, store_t item_ = 0) : type(HINT_NONE), category(category_), item(item_)
- {
- static_assert(sizeof(UpdateHint) == sizeof(store_t), "Internal UpdateHint size inconsistency");
- static_assert(sizeof(UpdateHint) <= sizeof(LPARAM), "Update hints are currently tunnelled through LPARAMs in MFC");
- MPT_ASSERT(static_cast<HintCategory>(category) == category_);
- MPT_ASSERT(UpdateHint::item == item);
- }
- template<typename T>
- MPT_FORCEINLINE T GetData() const { return static_cast<T>(item); }
- public:
- UpdateHint() : type(HINT_NONE), category(HINTCAT_GLOBAL), item(0) { }
- template<typename T>
- MPT_FORCEINLINE UpdateHint &SetData(T i) { item = i; MPT_ASSERT(item == i); return *this; }
- MPT_FORCEINLINE HintCategory GetCategory() const { return static_cast<HintCategory>(category); }
- MPT_FORCEINLINE FlagSet<HintType> GetType() const { return FlagSet<HintType>(static_cast<FlagSet<HintType>::store_type>(type)); }
-
- static MPT_FORCEINLINE UpdateHint FromLPARAM(LPARAM rawData) { UpdateHint hint; hint.rawData = static_cast<store_t>(rawData); return hint; }
- MPT_FORCEINLINE LPARAM AsLPARAM() const { return rawData; }
-
- template<typename T>
- MPT_FORCEINLINE T ToType() const
- {
- T hint = static_cast<const T &>(*this);
- if(T::classCategory != static_cast<HintCategory>(category))
- {
- hint.type &= HINT_ALLGLOBAL;
- hint.item = 0;
- }
- return hint;
- }
-
- MPT_FORCEINLINE UpdateHint &ModType() { type |= HINT_MODTYPE; return *this; }
- MPT_FORCEINLINE UpdateHint &MPTOptions() { type |= HINT_MPTOPTIONS; return *this; }
- MPT_FORCEINLINE UpdateHint &Undo() { type |= HINT_UNDO; return *this; }
- };
- struct GeneralHint : public UpdateHint
- {
- static constexpr HintCategory classCategory = HINTCAT_GENERAL;
- GeneralHint() : UpdateHint(classCategory, 0) { }
- GeneralHint(CHANNELINDEX channel) : UpdateHint(classCategory, 1 + channel) { }
- MPT_FORCEINLINE GeneralHint &General() { type |= HINT_MODGENERAL; return *this; }
- MPT_FORCEINLINE GeneralHint &Channels() { type |= HINT_MODCHANNELS; return *this; }
- MPT_FORCEINLINE GeneralHint &Tunings() { type |= HINT_TUNINGS; return *this; }
- MPT_FORCEINLINE CHANNELINDEX GetChannel() const { return item ? static_cast<CHANNELINDEX>(item - 1) : CHANNELINDEX_INVALID; }
- };
- struct PatternHint : public UpdateHint
- {
- static constexpr HintCategory classCategory = HINTCAT_PATTERNS;
- PatternHint(PATTERNINDEX item = 0) : UpdateHint(classCategory, item) { }
- MPT_FORCEINLINE PatternHint &Data() { type |= HINT_PATTERNDATA; return *this; }
- MPT_FORCEINLINE PatternHint &Names() { type |= HINT_PATNAMES; return *this; }
- PATTERNINDEX GetPattern() const { return GetData<PATTERNINDEX>(); }
- };
- struct RowHint : public UpdateHint
- {
- static constexpr HintCategory classCategory = HINTCAT_PATTERNS;
- RowHint(ROWINDEX item = 0) : UpdateHint(classCategory, item) { type = HINT_PATTERNROW; }
- MPT_FORCEINLINE ROWINDEX GetRow() const { return GetData<ROWINDEX>(); }
- };
- struct SampleHint : public UpdateHint
- {
- static constexpr HintCategory classCategory = HINTCAT_SAMPLES;
- SampleHint(SAMPLEINDEX item = 0) : UpdateHint(classCategory, item) { }
- MPT_FORCEINLINE SampleHint &Info() { type |= HINT_SAMPLEINFO; return *this; }
- MPT_FORCEINLINE SampleHint &Data() { type |= HINT_SAMPLEDATA; return *this; }
- MPT_FORCEINLINE SampleHint &Names() { type |= HINT_SMPNAMES; return *this; }
- MPT_FORCEINLINE SAMPLEINDEX GetSample() const { return GetData<SAMPLEINDEX>(); }
- };
- struct InstrumentHint : public UpdateHint
- {
- static constexpr HintCategory classCategory = HINTCAT_INSTRUMENTS;
- InstrumentHint(INSTRUMENTINDEX item = 0) : UpdateHint(classCategory, item) { }
- MPT_FORCEINLINE InstrumentHint &Info() { type |= HINT_INSTRUMENT; return *this; }
- MPT_FORCEINLINE InstrumentHint &Envelope() { type |= HINT_ENVELOPE; return *this; }
- MPT_FORCEINLINE InstrumentHint &Names() { type |= HINT_INSNAMES; return *this; }
- MPT_FORCEINLINE INSTRUMENTINDEX GetInstrument() const { return GetData<INSTRUMENTINDEX>(); }
- };
- struct SequenceHint : public UpdateHint
- {
- static constexpr HintCategory classCategory = HINTCAT_SEQUENCE;
- SequenceHint(SEQUENCEINDEX item = 0) : UpdateHint(classCategory, item) { }
- MPT_FORCEINLINE SequenceHint &Data() { type |= HINT_MODSEQUENCE; return *this; }
- MPT_FORCEINLINE SequenceHint &Names() { type |= HINT_SEQNAMES; return *this; }
- MPT_FORCEINLINE SequenceHint &RestartPos() { type |= HINT_RESTARTPOS; return *this; }
- MPT_FORCEINLINE SEQUENCEINDEX GetSequence() const { return GetData<SEQUENCEINDEX>(); }
- };
- struct PluginHint : public UpdateHint
- {
- static constexpr HintCategory classCategory = HINTCAT_PLUGINS;
- PluginHint(PLUGINDEX item = 0) : UpdateHint(classCategory, item) { }
- MPT_FORCEINLINE PluginHint &Info() { type |= HINT_MIXPLUGINS; return *this; }
- MPT_FORCEINLINE PluginHint &Names() { type |= HINT_PLUGINNAMES; return *this; }
- MPT_FORCEINLINE PluginHint &Parameter() { type |= HINT_PLUGINPARAM; return *this; }
- MPT_FORCEINLINE PLUGINDEX GetPlugin() const { return GetData<PLUGINDEX>(); }
- };
- struct CommentHint : public UpdateHint
- {
- static constexpr HintCategory classCategory = HINTCAT_COMMENTS;
- CommentHint() : UpdateHint(classCategory) { type = HINT_MODCOMMENTS; }
- };
- OPENMPT_NAMESPACE_END
|