This repository was archived by the owner on Nov 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1Version-Utils.lua
More file actions
94 lines (82 loc) · 2.52 KB
/
1Version-Utils.lua
File metadata and controls
94 lines (82 loc) · 2.52 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
------------------------------------------------------------------------------------------------
-- 1Version ver. @project-version@
-- Authored by Chrono Syz -- Entity-US / Wildstar
-- Build @project-hash@
-- Copyright (c) Chronosis. All rights reserved
--
-- https://github.com/chronosis/1Version
------------------------------------------------------------------------------------------------
-- 1Version-Utils.lua
------------------------------------------------------------------------------------------------
require "Window"
require "Item"
require "GameLib"
local OneVersion = Apollo.GetAddon("1Version")
local Info = Apollo.GetAddonInfo("1Version")
local Utils = Apollo.GetPackage("SimpleUtils-1.0").tPackage
-----------------------------------------------------------------------------------------------
-- Wrappers for debug functionality
-----------------------------------------------------------------------------------------------
function OneVersion:ToggleDebug()
if self.settings.user.debug then
self:PrintDB("Debug turned off")
self.settings.user.debug = false
else
self.settings.user.debug = true
self:PrintDB("Debug turned on")
end
end
function OneVersion:BuildVersionString(major, minor, patch, suffix)
-- This is a stupid fix to get around the LUA zero-index stupidity
local sfx = (suffix or 0)
if sfx == 0 then
sfx = tostring(sfx)
end
local strVer = string.format("%d.%d.%d%s", major, minor, patch, OneVersion.CodeEnumAddonSuffixMap[sfx])
return strVer
end
function OneVersion:GetPlayerName()
local player = GameLib.GetPlayerUnit()
local playerName = ""
if player ~= nil then
playerName = player:GetName()
end
if playerName ~= nil then
return playerName
end
return ""
end
function OneVersion:BuildSortableTable(t)
local u = {}
for k,v in pairs(t) do table.insert(u, v) end
return u
end
function OneVersion.BoolBit(b)
if type(b) == "boolean" then
if b then
return 1
end
end
return 0
end
function OneVersion.AddonSort(a,b)
local a_bool = OneVersion.BoolBit(not a.upgrade)
local b_bool = OneVersion.BoolBit(not b.upgrade)
local a_str = tostring(a_bool) .. a.label
local b_str = tostring(b_bool) .. b.label
return a_str < b_str
end
function OneVersion:PrintParty(str)
Utils:pprint("[OneVersion]: " .. str)
end
function OneVersion:PrintDB(str)
if self.settings.user.debug then
Utils:debug("[OneVersion]: " .. str)
end
end
function OneVersion:DestroyWindowList(list)
for key,value in pairs(list) do
list[key]:Destroy()
end
list = {}
end