forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteamkill.lua
More file actions
76 lines (62 loc) · 3.03 KB
/
teamkill.lua
File metadata and controls
76 lines (62 loc) · 3.03 KB
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
--*****************************************************************************
--* File: lua/ui/dialogs/teamkill.lua
--* Author: Quark036
--* Summary: pops up to warn of a teamkill and ask if it should be reported
--*****************************************************************************
local UIUtil = import('/lua/ui/uiutil.lua')
local LayoutHelpers = import('/lua/maui/layouthelpers.lua')
local Group = import('/lua/maui/group.lua').Group
local Popup = import('/lua/ui/controls/popups/popup.lua').Popup
local TextArea = import('/lua/ui/controls/textarea.lua').TextArea
local dialog = false
local shouldReport = false
local waitingTimeBeforeReport = 10;
function CreateDialog(teamkill)
if dialog then
return
end
local dialogContent = Group(GetFrame(0))
LayoutHelpers.SetDimensions(dialogContent, 360, 180)
dialog = Popup(GetFrame(0), dialogContent)
local title = UIUtil.CreateText(dialogContent, "<LOC teamkill_0001>Teamkill Detected", 14, UIUtil.titleFont)
LayoutHelpers.AtTopIn(title, dialogContent, 10)
LayoutHelpers.AtHorizontalCenterIn(title, dialogContent)
local infoText = TextArea(dialogContent, 340, 100)
infoText:SetText(LOC("<LOC teamkill_0002>You have been killed by friendly fire. The deliberate killing of teammates is against FAF rules. If you feel your death was deliberate or unsportsmanlike, press the button below to report it."))
LayoutHelpers.Below(infoText, title)
LayoutHelpers.AtLeftIn(infoText, dialogContent, 10)
local forgiveBtn = UIUtil.CreateButtonWithDropshadow(dialogContent, '/BUTTON/medium/', "<LOC teamkill_0004>Forgive")
LayoutHelpers.AtBottomIn(forgiveBtn, dialogContent, 10)
LayoutHelpers.AtLeftIn(forgiveBtn, dialogContent, 10)
forgiveBtn.OnClick = function(self, modifiers)
KillThread(dialog.countdownThread)
dialog:Close()
end
local reportBtn = UIUtil.CreateButtonWithDropshadow(dialogContent, '/BUTTON/medium/', "<LOC teamkill_0003>Report")
LayoutHelpers.AtBottomIn(reportBtn, dialogContent, 10)
LayoutHelpers.AtRightIn(reportBtn, dialogContent, 10)
UIUtil.setEnabled(reportBtn, false)
reportBtn.OnClick = function(self, modifiers)
GpgNetSend('TeamkillReport', teamkill.time, teamkill.victim.id, teamkill.victim.name, teamkill.instigator.id, teamkill.instigator.name)
WARN("TEAMKILL WAS REPORTED")
dialog:Close()
end
dialog.OnClosed = function(self)
dialog = false
end
dialog.OnEscapePressed = function(self)
end
dialog.OnShadowClicked = function(self)
end
dialog.countdownThread = ForkThread(WaitBeforeEnablingReportButton, reportBtn)
end
function WaitBeforeEnablingReportButton(reportBtn)
local waitedTime = 0;
while waitedTime < waitingTimeBeforeReport do
reportBtn.label:SetText(LOC("<LOC teamkill_0003>Report").."["..(waitingTimeBeforeReport-waitedTime).."]")
WaitSeconds(1)
waitedTime = waitedTime + 1
end
reportBtn.label:SetText(LOC("<LOC teamkill_0003>Report"))
UIUtil.setEnabled(reportBtn, true)
end