-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sound.cpp
73 lines (47 loc) · 1.08 KB
/
Sound.cpp
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
#include "Include\Sound.hpp"
Sound::Sound() : count(0){}
Sound::~Sound()
{
if (count != 0){
for (auto& sh : this->sh) DeleteSoundMem(sh);
}
}
int Sound::Load(const TCHAR * FNAME, std::string key, int BufferNum, int UnionHandle)
{
this->key.push_back(key);
sh.push_back(LoadSoundMem(FNAME, BufferNum, UnionHandle));
count++;
return 0;
}
int Sound::PlayMem(std::string key, int PlayType, int TopPositionFlag)
{
if (count == 0) return -1;
const int& Hdl = GetHandle(key);
if (Hdl == -1) return Hdl;
return PlaySoundMem(Hdl, PlayType, TopPositionFlag);
}
void Sound::List()
{
if (count == 0) return;
int c = 0;
printfDx("Soundキーリスト:\n");
for(auto key : this->key)
{
std::string list = key + "\n";
printfDx(list.c_str());
c++;
}
printfDx("合計%dファイル", c);
}
int Sound::GetHandle(std::string key)
{
for (int i = 0; i != this->key.size(); ++i)
{
if (this->key[i] != key) continue;
return this->sh[i];
}
std::string warning = key + "というキーが見当たりません。";
MessageBox(NULL, warning.c_str(), "NOT FOUND", MB_OK);
return -1;
}
// EOF