-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathATOM.lua
executable file
·164 lines (136 loc) · 5.5 KB
/
ATOM.lua
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
local addonName, ATOM = ...
ATOM = LibStub('AceAddon-3.0'):NewAddon(ATOM, addonName, 'AceEvent-3.0', 'AceConsole-3.0', 'AceTimer-3.0')
ATOM:SetDefaultModuleLibraries('AceEvent-3.0', 'AceConsole-3.0', 'AceTimer-3.0')
_G['ATOM'] = ATOM;
function ATOM:OnInitialize()
self.db = LibStub('AceDB-3.0'):New('AtomDB')
end
function ATOM:OnEnable()
self:RegisterChatCommand('atom', 'SlashCommand')
end
function ATOM:Wait(delay, func)
ATOM:ScheduleTimer(func or delay, func and delay or 0.5)
end
function ATOM:SlashCommand(msg)
local cmd, offset = self:GetArgs(msg)
local args = msg:sub(offset)
if cmd == 'clear' then
self:GetModule('Chat'):Clear()
elseif cmd == 'count' then
self:CreateItemCountFrame(args)
elseif cmd == 'countdown' then
C_PartyInfo.DoCountdown(tonumber(args) * 60)
elseif cmd == 'destroy' then
self:GetModule('Bags'):DestroyItems(args == 'true')
elseif cmd == 'dialogui' then
DialogueUI_ShowSettingsFrame()
elseif cmd == 'mark' then
self:GetModule('Macros'):MarkTarget(args ~= '' and args or nil)
elseif cmd == 'mount' then
self:GetModule('Mounts'):Mount(args)
elseif cmd == 'move' then
SetCVar('autoInteract', GetCVar('autoInteract') ~= '1' and '1' or '0')
elseif cmd == 'powerleveling' then
self:GetModule('BattlePets'):GetActivePowerlevelingBattlePetTrainer()
elseif cmd == 'quest' then
self:GetModule('Quest'):QuestCompleted(args)
elseif cmd == 'scoreboard' then
WorldStateScoreFrame:Show()
elseif cmd == 'solves' then
self:TolvirSolves()
elseif cmd == 'screenshot' then
Screenshot()
elseif cmd == 'target' then
self:GetModule('Macros'):UpdateTargetMacro(args)
elseif cmd == 'underlight' then
self:GetModule('Bags'):ReactivateUnderlightAngler()
elseif cmd == 'view' then
self:GetModule('System'):SetView(args ~= '' and tonumber(args) or false)
elseif cmd == 'volume' then
self:GetModule('System'):SetVolume(args ~= '' and tonumber(args) or false)
elseif cmd == 'wago' then
self:GetModule('Wago'):ShowWindow()
elseif cmd == 'way' then
self:SetUserWaypoint(args)
end
end
function ATOM:TolvirSolves()
local solves = 0
for i = 1, GetNumArtifactsByRace(14) do
solves = solves + select(10, GetArtifactInfoByRace(14, i))
end
local change = floor(1000 * (1 - (0.995 ^ solves))) / 10
ATOM:Print('Tol\'vir: %s solves, (%s%% chance to have found the scepter by now.)', solves, change)
end
function ATOM:SetUserWaypoint(cmd)
local x, y = self:GetArgs(cmd, 2)
x = tonumber(x:match('^%s*(.-),?%s*$')) * 100 / 10000
y = tonumber(y) * 100 / 10000
local currentMapAreaID = C_Map.GetBestMapForUnit('player')
C_Map.SetUserWaypoint(UiMapPoint.CreateFromCoordinates(currentMapAreaID, x, y))
C_SuperTrack.SetSuperTrackedUserWaypoint(true)
end
function ATOM:ShortenNameplateUnitName(unitId, unitFrame, envTable)
local function abbriviateName(fullName, maxLength)
local nameParts = { strsplit(' ', fullName) }
for i = #nameParts, 1, -1 do
-- dont abbreviate last names or words less than 5 characters
if not (i == #nameParts or nameParts[i]:len() < 5) then
nameParts[i] = nameParts[i]:sub(1, 1) .. '.'
end
-- stop abbriviating if the parts fit within the length of the
-- original truncated unitName that was set for the nameplate
if table.concat(nameParts, ' '):len() < maxLength then
break
end
end
return table.concat(nameParts, ' ')
end
local unitName = unitFrame.healthBar.unitName:GetText() or ''
local maxLength = unitName:len()
local plateFrame = C_NamePlate.GetNamePlateForUnit(unitId)
local fullName = plateFrame and plateFrame.namePlateUnitName or unitName
if fullName ~= unitName then
-- ignore everything after the first comma
fullName = select(1, strsplit(',', fullName))
unitFrame.healthBar.unitName:SetText(abbriviateName(fullName, maxLength))
end
end
--[[
function (self, unitId, unitFrame, envTable)
local unitName = unitFrame.healthBar.unitName:GetText()
local plateFrame = C_NamePlate.GetNamePlateForUnit(unitId)
if plateFrame and plateFrame.namePlateUnitName ~= unitName then
unitName = plateFrame.namePlateUnitName:gsub('(%S+) ', function (t) return t:sub(1, 1) .. '. ' end)
unitFrame.healthBar.unitName:SetText(unitName)
end
end
]]
function ATOM:CreateItemCountFrame(name)
local frame = CreateFrame('Button', nil, UIParent)
frame:SetClampedToScreen(true)
frame:SetPoint('CENTER')
frame:SetWidth(64)
frame:SetHeight(64)
frame:EnableMouse(true)
frame:SetMovable(true)
frame:RegisterForDrag('RightButton')
frame:RegisterEvent('CHAT_MSG_LOOT');
frame:SetScript('OnDragStop', function(self)
self:StopMovingOrSizing()
end)
frame:SetScript('OnDragStart', function(self)
self:StartMoving()
end)
local icon = frame:CreateTexture('OVERLAY')
-- icon:SetTexCoord(0.08,0.92,0.08,0.92)
icon:SetTexture(GetItemIcon(name))
icon:SetAllPoints()
local text = frame:CreateFontString('OVERLAY', nil, 'GameFontHighlightLarge')
text:SetFont('Interface\\AddOns\\ATOM\\Fonts\\Lato-Bold.ttf', 23)
text:SetPoint('BOTTOM', frame, 'BOTTOM', 0, 4)
text:SetText(GetItemCount(name))
frame:SetScript('OnEvent', function(self, event)
text:SetText(GetItemCount(name))
end);
end