-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPopup.angelscript
89 lines (77 loc) · 1.76 KB
/
Popup.angelscript
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
89
const vector2 DEFAULT_EXIT_BUTTON_POS(0.92f,0.88f);
class Popup : UILayer
{
private string m_lastLayer;
private string m_popupSprite;
private UILayerManager@ m_layerManager;
private bool m_hasPausedGame;
bool tapScreenToClose;
Popup(const string &in spritePath, const string &in closeButton, const string &in lastLayer,
UILayerManager@ layerManager, const vector2 &in exitButtonPos)
{
super();
@m_layerManager = @layerManager;
m_popupSprite = spritePath;
const vector2 screenSize(GetScreenSize());
addSprite("ETHFramework/sprites/eth_framework_square.png", ARGB(150,0,0,0), V2_ZERO, screenSize, V2_ZERO);
if (m_popupSprite != "")
addSprite(m_popupSprite, COLOR_WHITE, screenSize * 0.5f, V2_HALF);
m_lastLayer = lastLayer;
addButton("close", closeButton, exitButtonPos, V2_HALF);
if (!g_timeManager.isPaused())
{
g_timeManager.pause();
m_hasPausedGame = true;
}
else
{
m_hasPausedGame = false;
}
tapScreenToClose = false;
}
void close()
{
setButtonPressed("close", true);
}
private bool hasReceivedCloseCommand()
{
if (tapScreenToClose)
{
if (GetInputHandle().GetTouchState(0) == KS_HIT)
return true;
}
if (isButtonPressed("close"))
return true;
if (GetInputHandle().GetKeyState(K_BACK) == KS_HIT)
return true;
return false;
}
void update()
{
UILayer::update();
if (hasReceivedCloseCommand())
{
dismissSprites();
dismissButtons();
setButtonPressed("close", false);
}
if (isEverythingDismissed())
{
if (m_layerManager !is null)
{
m_layerManager.setCurrentLayer(m_lastLayer);
@m_layerManager = null;
}
if (m_hasPausedGame)
g_timeManager.resume();
}
}
string getName() const
{
return "Popup";
}
bool isAlwaysActive() const
{
return true;
}
}