forked from jordanmchavez/kdm-tts
-
Notifications
You must be signed in to change notification settings - Fork 5
/
GlobalUi.ttslua
61 lines (52 loc) · 2.2 KB
/
GlobalUi.ttslua
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
local Hunt = require("Kdm/Hunt")
local Campaign = require("Kdm/Campaign")
local Showdown = require("Kdm/Showdown")
local Timeline = require("Kdm/Timeline")
local Ui = require("Kdm/Ui")
---------------------------------------------------------------------------------------------------
local GlobalUi = {}
---------------------------------------------------------------------------------------------------
function GlobalUi.Init()
local ui = Ui.Get2d()
local buttons = {
{ name = "Campaign", module = Campaign, image = "CampaignButton" },
{ name = "Hunt", module = Hunt, image = "HuntButton" },
{ name = "Showdown", module = Showdown, image = "ShowdownButton" },
{ name = "Timeline", module = Timeline, image = "TimelineButton" },
}
GlobalUi.buttons = {}
for i, button in ipairs(buttons) do
GlobalUi.buttons[button.name] = ui:Button({ id = button.name, rectAlignment = "UpperLeft", x = 70, y = -10 - (i - 1) * 40, width = 100, height = 30, image = button.image, onClick = function()
if button.module.IsUiOpen() then
button.module.HideUi()
else
for _, other in ipairs(buttons) do
if other.name != button.name then
other.module.HideUi()
end
end
button.module.ShowUi()
end
end })
end
GlobalUi.open = true
GlobalUi.collapseExpandButton = ui:Button({ id = "CollapseExpand", rectAlignment = "UpperLeft", x = 180, y = -10, width = 30, height = 30, image = "CollapseButton", onClick = function()
if GlobalUi.open then
GlobalUi.open = false
GlobalUi.collapseExpandButton:SetImage("ExpandButton")
for _, button in pairs(GlobalUi.buttons) do
button:Hide()
end
else
GlobalUi.open = true
GlobalUi.collapseExpandButton:SetImage("CollapseButton")
for _, button in pairs(GlobalUi.buttons) do
button:Show()
end
end
end })
end
---------------------------------------------------------------------------------------------------
return {
Init = GlobalUi.Init,
}