summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2SoundPlayer.h
blob: 667ac13a4fd2774fd5901435462fc0b8ccece391 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include "common.h"

enum PLAYMODE {
	PlayMode_0,
	PlayMode_1,
	PlayMode_2,
	PlayMode_3
};

enum SOUNDPRIORITY {
	SoundPriority_0,
	SoundPriority_1
};

enum {
	SoundMask_10 = 0x10,
    SoundMask_20 = 0x20,
};

enum {
	SoundFlags_10 = 0x10,
    SoundFlags_20 = 0x20,
	SoundFlags_10000 = 0x10000
};

class AFX_CLASS_EXPORT T2SoundObjItem {
public:
    T2SoundObjItem();
    ~T2SoundObjItem();

    enum {
        FileSource = 1,
        ResSource = 2
    };

    CString mName;
    SOUNDPRIORITY mPriority;
    LPDIRECTSOUNDBUFFER mDSBuffers[4];
    DWORD mPlayedAt[4];
    int mSourceKind;
    CString mPath;
    unsigned int mResID;
    HINSTANCE mModuleHandle;
};

class AFX_CLASS_EXPORT T2SoundObjItemList : public CList<T2SoundObjItem *, T2SoundObjItem *> {
public:
    T2SoundObjItemList();
    virtual ~T2SoundObjItemList();
};

class AFX_CLASS_EXPORT T2SoundPlayer : public CWnd {
	DECLARE_MESSAGE_MAP()

public:
	T2SoundPlayer(CWnd* inParentWnd, IDirectSound* inDirectSound);
	virtual ~T2SoundPlayer();
	void AddSound(const CString& inName, SOUNDPRIORITY inPriority, const CString& inPath);
	void AddSound(const CString& inName, SOUNDPRIORITY inPriority, unsigned int inResID, HINSTANCE inModule);
	void DeleteSound(const CString& inName);
	void DeleteSoundAll();
	void Play(const CString& inName, unsigned int inMask, unsigned int inFlags, POINT* inPt, PLAYMODE inPlayMode, int inVolume);
	void Stop(const CString& inName);
	void StopAll();
	void SetVolume(const CString& inName, int inVolume);
	void SetSoundOn(BOOL inSoundOn);
	void FadeOut();
	void FadeIn();
	void PlayCDTrack(int inTrack, BOOL inFlag);
	void StopCD();
	unsigned int GetSEMask() const { return mSEMask; }
	void SetSEMask(unsigned int inMask) { mSEMask = inMask; }
	BOOL IsSoundOn() const { return mIsSoundOn; }

protected:
	LRESULT OnMCINotify(WPARAM wParam, LPARAM lParam);

private:
	BOOL LoadSound(T2SoundObjItem* inItem, const CString& inName, CWave& inWave, BOOL inReloadFlag);

	IDirectSound *mDirectSound;
	T2SoundObjItemList *mItemList;
	int mCurrentCDTrack;
	unsigned int mSEMask;
	BOOL mIsSoundOn;
	BOOL mIsFadeOut;
};