forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesync.lua
More file actions
70 lines (56 loc) · 2.69 KB
/
desync.lua
File metadata and controls
70 lines (56 loc) · 2.69 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
--*****************************************************************************
--* File: lua/modules/ui/dialogs/desync.lua
--* Author: Chris Blackwell
--* Summary: handles multiplayer desyncs
--*
--* Copyright © 2005 Gas Powered Games, Inc. All rights reserved.
--*****************************************************************************
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 doesntCare = false
function UpdateDialog(beatNumber, strings)
WARN("Desync at beat " .. beatNumber .. " tick " .. GetGameTimeSeconds())
if doesntCare or dialog then
return
end
local dialogContent = Group(GetFrame(0))
LayoutHelpers.SetDimensions(dialogContent, 400, 320)
dialog = Popup(GetFrame(0), dialogContent)
local title = UIUtil.CreateText(dialogContent, "<LOC desync_0000>Desync Detected", 14, UIUtil.titleFont)
LayoutHelpers.AtTopIn(title, dialogContent, 5)
LayoutHelpers.AtHorizontalCenterIn(title, dialogContent)
local infoText = TextArea(dialogContent, 390, 80)
infoText:SetText(LOC("<LOC desync_0003>"))
LayoutHelpers.Below(infoText, title)
LayoutHelpers.AtLeftIn(infoText, dialogContent, 5)
local subtitle = UIUtil.CreateText(dialogContent, "<LOC desync_0004>Diagnostic Info", 14, UIUtil.titleFont)
LayoutHelpers.Below(subtitle, infoText, 5)
LayoutHelpers.AtHorizontalCenterIn(subtitle, dialogContent)
dialog.diagnosticBox = TextArea(dialogContent, 390, 130)
dialog.diagnosticBox:SetFont(UIUtil.bodyFont, 10)
LayoutHelpers.Below(dialog.diagnosticBox, subtitle, 5)
LayoutHelpers.AtHorizontalCenterIn(dialog.diagnosticBox, dialogContent)
local dontCare = UIUtil.CreateCheckbox(dialogContent, '/CHECKBOX/', "<LOC desync_0002>Don't tell me any more", true, 11)
LayoutHelpers.AtBottomIn(dontCare, dialogContent, 15)
LayoutHelpers.AtLeftIn(dontCare, dialogContent, 5)
local okBtn = UIUtil.CreateButtonWithDropshadow(dialogContent, '/BUTTON/medium/', "<LOC _Ok>")
LayoutHelpers.AtHorizontalCenterIn(okBtn, dialogContent)
LayoutHelpers.AtBottomIn(okBtn, dialogContent, 5)
okBtn.OnClick = function(self, modifiers)
dialog:Close()
end
dialog.OnClosed = function(self)
dialog = false
doesntCare = dontCare:IsChecked()
end
for k, v in strings do
if v then
dialog.diagnosticBox:AppendLine(v)
end
end
dialog.diagnosticBox:AppendLine(LOC("<LOC desync_0001>Beat# ") .. tostring(beatNumber))
end