ESO Lua File v100012

ingame/trialaccount/trialaccount.lua

[◄ back to folders ]
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
--Splash Dialog
---------------
local TrialAccountSplashDialog = ZO_Object:Subclass()
function TrialAccountSplashDialog:New(...)
    local trialDialog = ZO_Object.New(self)
    trialDialog:Initialize(...)
    return trialDialog
end
function TrialAccountSplashDialog:Initialize(control)
    self.control = control
    self.dialogPane = control:GetNamedChild("Pane")
    self.dialogScrollChild = self.dialogPane:GetNamedChild("ScrollChild")
    self.dialogDescription = self.dialogPane:GetNamedChild("Description")
    self.dialogInfo = 
    {
        customControl = control,
        title = {},
        noChoiceCallback =  function(dialog)
                                dialog.data.owner:RemoveSplash(dialog.data.accountTypeId, dialog.data.version)
                            end,
        buttons =
        {
            [1] =
            {
                control = control:GetNamedChild("Cancel"),
                text = SI_DIALOG_EXIT,
                keybind = "DIALOG_NEGATIVE",
                clickSound = SOUNDS.DIALOG_ACCEPT,
                callback =  function(dialog)
                                dialog.data.owner:RemoveSplash(dialog.data.accountTypeId, dialog.data.version)
                            end,
            },
        }
    }
    ZO_Dialogs_RegisterCustomDialog("TRIAL_ACCOUNT_SPLASH", self.dialogInfo)
    local function OnAddOnLoaded(event, name)
        if name == "ZO_Ingame" then
            local defaults = 
            {
                seen = {},
            }
            self.sv = ZO_SavedVars:New("ZO_Ingame_SavedVariables", 1, "TrialAccount", defaults)
            self:CheckLoadSplash(false)
            self.control:UnregisterForEvent(EVENT_ADD_ON_LOADED)
        end
    end
    control:RegisterForEvent(EVENT_ADD_ON_LOADED, OnAddOnLoaded)
end
function TrialAccountSplashDialog:CheckLoadSplash(force)
    local accountTypeId, title, description, version = GetTrialInfo();
    if accountTypeId ~= 0 then
        if not self.sv.seen[accountTypeId] or self.sv.seen[accountTypeId] < version or force then
            self.dialogInfo.title.text = title
            self.dialogDescription:SetText(description)
            local descriptionWidth, descriptionHeight = self.dialogDescription:GetTextDimensions()
            local contentHeight = descriptionHeight + 6
            self.dialogPane:SetHeight(contentHeight)
            self.dialogScrollChild:SetHeight(contentHeight)
            ZO_Dialogs_ShowDialog("TRIAL_ACCOUNT_SPLASH", { accountTypeId = accountTypeId, version = version, owner = self })
        end
    end
end
function TrialAccountSplashDialog:RemoveSplash(accountTypeId, version)
    ZO_Dialogs_ReleaseDialog("TRIAL_ACCOUNT_SPLASH")
    self.sv.seen[accountTypeId] = version
end
    TRIAL_ACCOUNT_SPLASH_DIALOG = TrialAccountSplashDialog:New(control)
end