-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathBuildSetService.lua
More file actions
41 lines (34 loc) · 1.29 KB
/
BuildSetService.lua
File metadata and controls
41 lines (34 loc) · 1.29 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
-- Path of Building
--
-- Module: BuildSetService
-- Build set service for managing loadouts.
-- Utility functions
local m_max = math.max
local BuildSetServiceClass = newClass("BuildSetService", function(self, buildMode)
self.buildMode = buildMode
end)
function BuildSetServiceClass:NewLoadout(name)
self.buildMode:NewLoadout(name, function()
self.buildMode:SyncLoadouts()
self.buildMode.modFlag = true
self.buildMode.controls.buildLoadouts:SetSel(1)
end)
end
function BuildSetServiceClass:CopyLoadout(specId, itemSetId, skillSetId, configSetId, newName)
local newSpec = self.buildMode:CopyLoadout(specId, itemSetId, skillSetId, configSetId, newName)
self.buildMode:SyncLoadouts()
self.buildMode.modFlag = true
self.buildMode.controls.buildLoadouts:SetSel(newSpec.id + 1)
end
function BuildSetServiceClass:RenameLoadout(oldName, newName)
self.buildMode:RenameLoadout(oldName, newName, function()
self.buildMode:SyncLoadouts()
self.buildMode.modFlag = true
end)
end
function BuildSetServiceClass:DeleteLoadout(index, list, spec)
local nextLoadoutIndex = index <= self.buildMode.treeTab.activeSpec and m_max(1, index - 1) or
self.buildMode.treeTab.activeSpec
local nextLoadout = list[nextLoadoutIndex]
self.buildMode:DeleteLoadout(spec.title or "Default", nextLoadout.title or "Default")
end