-
Notifications
You must be signed in to change notification settings - Fork 5
/
introtexthelper.cpp
80 lines (66 loc) · 1.9 KB
/
introtexthelper.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
74
75
76
77
78
79
80
#include "prism/introtexthelper.h"
#include "prism/mugenanimationhandler.h"
struct IntroText
{
int mID;
MugenAnimationHandlerElement* mAnimationElement;
Vector2DI mSFX;
MugenSounds* mSounds;
int mDurationLeft;
int hasPlayedSound;
};
static struct {
int mNextID;
std::map<int, IntroText> mList;
} gPrismIntroTextHelper;
static void loadIntroTextHelper(void*)
{
gPrismIntroTextHelper.mNextID = 0;
gPrismIntroTextHelper.mList.clear();
}
static void unloadIntroTextHelper(void*)
{
for(auto& e : gPrismIntroTextHelper.mList)
{
removeMugenAnimation(e.second.mAnimationElement);
}
gPrismIntroTextHelper.mList.clear();
}
static int updateIntroText(void*, IntroText& e)
{
if (!e.hasPlayedSound) {
tryPlayMugenSound(e.mSounds, e.mSFX.x, e.mSFX.y);
e.hasPlayedSound = 1;
}
e.mDurationLeft--;
if(e.mDurationLeft <= 0) {
removeMugenAnimation(e.mAnimationElement);
return 1;
}
return 0;
}
static void updateIntroTextHelper(void*)
{
stl_int_map_remove_predicate(gPrismIntroTextHelper.mList, updateIntroText);
}
ActorBlueprint getPrismIntroTextHandler()
{
return makeActorBlueprint(loadIntroTextHelper, unloadIntroTextHelper, updateIntroTextHelper);
}
int addPrismIntroText(const Position& tPosition, int tAnimation, const Vector2DI& tSFX, int tDuration, MugenSpriteFile* tSprites, MugenAnimations* tAnimations, MugenSounds* tSounds)
{
int id = gPrismIntroTextHelper.mNextID++;
IntroText e;
e.mID = id;
e.mAnimationElement = addMugenAnimation(getMugenAnimation(tAnimations, tAnimation), tSprites, tPosition);
e.mSFX = tSFX;
e.mSounds = tSounds;
e.mDurationLeft = tDuration;
e.hasPlayedSound = 0;
gPrismIntroTextHelper.mList[id] = e;
return id;
}
int hasPrismIntroTextFinished(int tID)
{
return (gPrismIntroTextHelper.mList.find(tID) == gPrismIntroTextHelper.mList.end());
}