/trunk
if not isHeader or (isHeader and hasRep) then |
id = 'rep_' .. factionname |
t = LookupFaction(factionname, true) |
if not t.gain then t.gain = 0 end |
if t.rawValue and t.rawValue ~= barValue then |
t.gain = barValue - t.rawValue |
end |
t.rawValue = barValue |
t.state = standingId |
t.value = barValue - barMin |
t.max = barMax - barMin |
if t.gain ~= 0 then t:Notify(true) end |
end |
end |
PXP.Menu.Resort() |
if not PXP.events["COMBAT_TEXT_UPDATE"] then PXP.events["COMBAT_TEXT_UPDATE"] = {} end |
PXP.events["COMBAT_TEXT_UPDATE"]['faction'] = function(event, type, faction, gain, ...) |
-- We no longer update faction this way, we just do a Notify and let UPDATE_FACTION sort it all out. |
if type ~= 'FACTION' then return end |
local m = LookupFaction(faction) |
if m and gain > 0 then m:Notify() end |
end |
local m = PXP.ModifyFactionRep(faction, gain) |
m:Notify() |
end |
if not PXP.events["UPDATE_FACTION"] then PXP.events["UPDATE_FACTION"] = {} end |
PXP.events["UPDATE_FACTION"]['faction'] = function(...) PXP.ReloadFactionData() end |
if self.modes then |
for k, v in pairs(self.modes) do |
if v.next then |
if not first or k.id < first then first = k end |
if not last or k.id > last then last = k end |
if k.id < mode.id and (n.prev == nil or k.id > n.prev) then n.prev = k end |
if k.id > modeId and (n.next == nil or k.id < n.next) then n.next = k end |
if not first or k.id < first.id then first = k end |
if not last or k.id > last.id then last = k end |
if k.id < mode.id and (n.prev == nil or k.id > n.prev.id) then n.prev = k end |
if k.id > mode.id and (n.next == nil or k.id < n.next.id) then n.next = k end |
end |
end |
end |
return true |
end |
function PXP.Bar.Delete(self) |
if self.parent then |
self.parent:Remove(self) |
end |
self.baseFrame:Hide() |
self.baseFrame:SetScript("OnEnter", nil) |
self.baseFrame:SetScript("OnLeave", nil) |
self.baseFrame:SetScript("OnMouseDown", nil) |
self.baseFrame:SetScript("OnMouseUp", nil) |
self.baseFrame:SetScript("OnUpdate", nil) |
self.parent = nil |
self.next = nil |
self.prev = nil |
self.baseFrame = nil |
self.overlayFrame = nil |
end |
-- Remove a mode from our interest list, and make another mode active. |
function PXP.Bar.RemoveMode(self, mode, isInherit) |
assert(mode) |
if not mode.virtual then |
self.modes[n.prev].next = n.next |
self.modes[n.next].prev = n.prev |
if self.currentMode == modeId then |
if n.next ~= modeId then |
if self.currentMode == mode then |
if n.next ~= mode then |
self:SetMode(n.next) |
else |
self:SetMode(nil) |
end |
end |
end |
self.modes[modeId] = nil |
self.modes[mode] = nil |
end |
mode.watchers.primary[self] = nil |
end |
end |
-- Toggle automatic mode switching |
function PXP.Bar.SetautoUpdate(self, v) |
if v then v = true else v = nil end |
self.autoUpdate = v |
local modeId, mode |
return v |
end |
-- Maximum bar value.. Minimum is always 0. |
function PXP.Bar.SetMax(self, v) |
function PXP.Menu.ActionDeleteBar(self, bar) |
CloseDropDownMenus() |
bar.parent:Remove(bar) |
bar:Delete() |
--bar.parent:Remove(bar) |
end |
function PXP.Menu.ActionCreateBar(self, base, clone) |
local rootMenu = {} |
if bar.currentMode then |
assert(PXP.modes[bar.currentMode]) |
table.insert(rootMenu, {text = PXP.modes[bar.currentMode].name, isTitle = true}) |
table.insert(rootMenu, {text = bar.currentMode.name, isTitle = true}) |
else |
table.insert(rootMenu, {text = TR.NOT_CONFIGURED, isTitle = true}) |
end |
table.insert(rootMenu, MenuSep) |
table.insert(rootMenu, { |
text = TR.AUTOUPDATE, |
tooltipText = TR.AUTOUPDATE_TT, |
text = TR.EDITMODE, |
tooltipText = TR.EDITMODE_TT, |
func = function(...) bar.parent:SetForceVisible(not bar.parent.forceVisible) end, |
checked = bar.parent.forceVisible, |
}) |
table.insert(rootMenu, { |
text = TR.AUTOUPDATE, |
tooltipText = TR.AUTOUPDATE_TT, |
func = function(...) CloseDropDownMenus(); bar.autoSwitchModes = not bar.autoSwitchModes end, |
checked = bar.autoSwitchModes, |
func = function(...) CloseDropDownMenus(); bar.autoUpdate = not bar.autoUpdate end, |
checked = bar.autoUpdate, |
}) |
EasyMenu(rootMenu, PXP.Menu.Frame, UIParent, x/scale, y/scale, "MENU", 10) |
max= 1, |
type = nil, |
name = 'NAME ME', |
watchers = { primary={}, secondary={} }, |
state = 0, |
} |
function PXP.Mode.Notify(self) |
function PXP.Mode.Notify(self, primaryOnly) |
local handledPrimary = nil |
for bar, _ in pairs(self.watchers.primary) do |
bar:Update() |
end |
if handledPrimary then return true end |
if handledPrimary or primaryOnly then return true end |
local oldestbar = nil |
-- No bar currently set to this mode would handle it. |
function PXP.LoadProfile(profile) |
assert(PXP.globalData.profiles[profile], "Profile not found") |
for group, _ in pairs(PXP.groups) do group:Delete() end |
for _, group in pairs(PXP.groups) do group:Delete() end |
PXP.groups = {} |
PXP.profileName = profile |
PXP.profile = PXP.globalData.profiles[profile] |
local p = PXP.profile |
for modename, initproc in pairs(PXP.profileLoadCallbacks) do initproc() end |
local group, bar |
for _, groupSettings in pairs(PXP.profile.groups) do |
group = PXP.Group:New() |
table.insert(PXP.groups, group) |
group:SetOrigin(groupSettings.originX, groupSettings.originY) |
group.width = groupSettings.width |
group.height = groupSettings.height |
end |
end |
end |
for modename, initproc in pairs(PXP.profileLoadCallbacks) do initproc() end |
end |
function PXP.SaveProfile(profile) |
p.groups = {} |
local groupSettings, barSettings |
local bar |
for group, _ in pairs(PXP.groups) do |
groupSettings = {} |
local bar, group |
for _, group in pairs(PXP.groups) do |
groupSettings = { bars = {} } |
table.insert(p.groups, groupSettings) |
groupSettings.originX , groupSettings.originY = group:GetOrigin() |
end |
barSettings.modes = {} |
for modeId, modeData in pairs(bar.modes) do |
if modeData.explicit then |
table.insert(barSettings.modes, modeId) |
for mode, data in pairs(bar.modes) do |
if data.explicit then |
table.insert(barSettings.modes, mode.id) |
if not PXP.globalData.modeCache[modeId] then |
PXP.globalData.modeCache[modeId] = { |
name = PXP.modes[modeId].name, |
type = PXP.modes[modeId].type, |
} |
end |
if not PXP.globalData.modeCache[mode.id] then PXP.globalData.modeCache[mode.id] = { name = mode.name, type = mode.type } end |
end |
end |
bar = bar.next |
PXP.events["PLAYER_LOGIN"]['core'] = function(...) |
PXP.Initialize() |
end |
if not PXP.events["PLAYER_LOGOUT"] then PXP.events["PLAYER_LOGOUT"] = {} end |
PXP.events["PLAYER_LOGOUT"]['core'] = function(...) |
PXP.SaveProfile() |
end |
return obj |
end |
function PXP.Group.Delete(self) |
obj.StopMovingOrSizing() |
obj.frame:Hide() |
for bar, _ in pairs(self.bars) do bar:Delete() end |
end |
function PXP.Group.SetOrigin(self, x, y) |
assert(x and y) |
self.frame:ClearAllPoints() |
## SavedVariables: ProgressionGlobalData |
## SavedVariablesPerCharacter: ProgressionCharacterData |
## Dependencies: |
## Version: 30000.1 |
## Version: 30000.2 |
## OptionalDeps: |
## X-Embeds: |
## X-Category: |
else |
t.value = curXP |
t.max = maxXP |
if t.state == PXP.STATE_NOPET then |
t.gain = 0 |
else |
t.gain = gain or PXP.GetGain(oldxp, oldmax, oldlevel, t.value, t.level) |
end |
if t.level < UnitLevel("player") then |
t.state = PXP.STATE_NORMAL |
else |
t.state = PXP.STATE_CAPPED |
end |
if gain == nil then gain = PXP.GetGain(oldxp, oldmax, oldlevel, t.value, t.level) end |
t.gain = gain |
end |
t:Notify() |
end |
if not PXP.events["UNIT_PET_EXPERIENCE"] then PXP.events["UNIT_PET_EXPERIENCE"] = {} end |
PXP.events["UNIT_PET_EXPERIENCE"]['petxp'] =UpdatePetXP |
if not PXP.events["UNIT_PET"] then PXP.events["UNIT_PET"] = {} end |
PXP.events["UNIT_PET"]['petxp'] =UpdatePetXP |
PXP.Menu.Resort() |