Testing LibQTip to create simple tooltip.
This commit is contained in:
parent
1d6326fa5f
commit
efc27e8f94
12 changed files with 1644 additions and 41 deletions
106
ChoreTracker.lua
106
ChoreTracker.lua
|
@ -1,9 +1,10 @@
|
|||
ChoreTracker = LibStub('AceAddon-3.0'):NewAddon('ChoreTracker','AceConsole-3.0','AceEvent-3.0')
|
||||
local LibQTip = LibStub('LibQTip-1.0')
|
||||
local core = ChoreTracker
|
||||
|
||||
local trackedInstances = {
|
||||
['Baradin Hold'] = true,
|
||||
['Firelands'] = true,
|
||||
['Baradin Hold'] = 'BH',
|
||||
['Firelands'] = 'FL',
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,8 +15,67 @@ local defaults = {
|
|||
}
|
||||
}
|
||||
|
||||
function core:OnInitialize()
|
||||
local function anchor_OnEnter(self)
|
||||
self.db = LibStub('AceDB-3.0'):New('ChoreTrackerDB',defaults,'Default')
|
||||
local columnCount = 2
|
||||
for instance,abbreviation in pairs(trackedInstances) do
|
||||
columnCount = columnCount + 1
|
||||
end
|
||||
|
||||
self.tooltip = LibQTip:Acquire('ChoreTrackerTooltip',columnCount,'LEFT','CENTER','RIGHT')
|
||||
|
||||
--create the tooltip header
|
||||
self.tooltip:AddHeader('')
|
||||
local valorPointColumn = self.tooltip:AddColumn('LEFT')
|
||||
self.tooltip:SetCell(1,1,'Chore')
|
||||
self.tooltip:SetCell(1,2,'VP')
|
||||
local nextColumn = 3
|
||||
for instance,abbreviation in pairs(trackedInstances) do
|
||||
self.tooltip:SetCell(1,nextColumn,abbreviation,nil,'LEFT')
|
||||
nextColumn = nextColumn + 1
|
||||
end
|
||||
--go through all stored raiders
|
||||
for character,instancesTable in pairs(self.db.global.lockouts) do
|
||||
local characterLine = self.tooltip:AddLine('')
|
||||
self.tooltip:SetCell(characterLine,1,character,nil,'LEFT')
|
||||
self.tooltip:SetCell(characterLine,2,self.db.global.valorPoints[character],nil,'LEFT')
|
||||
|
||||
local nextColumn = 3
|
||||
for instance,abbreviation in pairs(trackedInstances) do
|
||||
if self.db.global.lockouts[character][instance] ~= nil then
|
||||
self.tooltip:SetCell(characterLine,nextColumn,self.db.global.lockouts[character][instance].defeatedBosses,nil,'LEFT')
|
||||
else
|
||||
self.tooltip:SetCell(characterLine,nextColumn,'0',nil,'LEFT')
|
||||
end
|
||||
nextColumn = nextColumn + 1
|
||||
end
|
||||
end
|
||||
|
||||
self.tooltip:SmartAnchorTo(self)
|
||||
self.tooltip:Show()
|
||||
end
|
||||
|
||||
local function anchor_OnLeave(self)
|
||||
LibQTip:Release(self.tooltip)
|
||||
self.tooltip = nil
|
||||
end
|
||||
|
||||
function core:OnInitialize()
|
||||
self.db = LibStub('AceDB-3.0'):New('ChoreTrackerDB',defaults,'Default')
|
||||
|
||||
local ChoresDisplay = CreateFrame('Frame','ChoreTrackerFrame',UIParent)
|
||||
ChoresDisplay:SetPoint('CENTER')
|
||||
ChoresDisplay.background = ChoresDisplay:CreateTexture(nil,'BACKGROUND')
|
||||
ChoresDisplay.background:SetAllPoints(true)
|
||||
ChoresDisplay.background:SetTexture(1,0.5,0,0.5)
|
||||
ChoresDisplay:SetHeight(50)
|
||||
ChoresDisplay:SetWidth(50)
|
||||
ChoresDisplay:Show()
|
||||
|
||||
self.ChoresDisplay = ChoresDisplay
|
||||
|
||||
ChoresDisplay:SetScript('OnEnter', anchor_OnEnter)
|
||||
ChoresDisplay:SetScript('OnLeave', anchor_OnLeave)
|
||||
end
|
||||
|
||||
function core:OnEnable()
|
||||
|
@ -30,43 +90,7 @@ function core:OnEnable()
|
|||
end
|
||||
|
||||
function core:ViewChores()
|
||||
local ChoresDisplay = CreateFrame('Frame','ChoreTrackerFrame',UIParent)
|
||||
ChoresDisplay:SetPoint('CENTER')
|
||||
ChoresDisplay:EnableMouse(true)
|
||||
ChoresDisplay:SetMovable(true)
|
||||
ChoresDisplay:RegisterForDrag('LeftButton')
|
||||
|
||||
ChoresDisplay:SetScript('OnDragStart',ChoresDisplay.StartMoving)
|
||||
ChoresDisplay:SetScript('OnDragStop',ChoresDisplay.StopMovingOrSizing)
|
||||
ChoresDisplay:SetScript('OnHide',ChoresDisplay.StopMovingOrSizing)
|
||||
|
||||
ChoresDisplay.background = ChoresDisplay:CreateTexture(nil,'BACKGROUND')
|
||||
ChoresDisplay.background:SetAllPoints(true)
|
||||
ChoresDisplay.background:SetTexture(1,0.5,0,0.5)
|
||||
|
||||
ChoresDisplay.lines = {}
|
||||
local lineCount = 1
|
||||
for k,v in pairs(self.db.global.valorPoints) do
|
||||
local line = ChoresDisplay:CreateFontString(nil,'OVERLAY','GameFontNormal')
|
||||
ChoresDisplay.lines[lineCount] = line
|
||||
|
||||
if lineCount > 1 then
|
||||
line:SetPoint('TOPLEFT',ChoresDisplay.lines[lineCount - 1],'BOTTOMLEFT',0,0)
|
||||
line:SetPoint('TOPRIGHT',ChoresDisplay.lines[lineCount - 1],'BOTTOMRIGHT',0,0)
|
||||
else
|
||||
line:SetPoint('TOPLEFT',ChoresDisplay,'TOPLEFT',5,-5)
|
||||
line:SetPoint('TOPRIGHT',ChoresDisplay,'TOPRIGHT',5,-5)
|
||||
end
|
||||
|
||||
line:SetFormattedText("%s - %d",k,v)
|
||||
lineCount = lineCount + 1
|
||||
end
|
||||
|
||||
local height = select(2,GameFontNormal:GetFont())
|
||||
ChoresDisplay:SetHeight(height * lineCount)
|
||||
ChoresDisplay:SetWidth(300)
|
||||
|
||||
ChoresDisplay:Show()
|
||||
|
||||
end
|
||||
|
||||
function core:UpdateChores()
|
||||
|
@ -88,7 +112,7 @@ function core:UpdateChores()
|
|||
for i = 1, savedInstances do
|
||||
local instanceName,_,instanceReset,_,_,_,_,_,_,_,_,defeatedBosses = GetSavedInstanceInfo(i)
|
||||
|
||||
if trackedInstances[instanceName] == true then
|
||||
if trackedInstances[instanceName] ~= nil then
|
||||
if instanceReset > 0 then
|
||||
self.db.global.lockouts[name][instanceName] = {}
|
||||
self.db.global.lockouts[name][instanceName].defeatedBosses = defeatedBosses
|
||||
|
|
13
Libs/LibQTip-1.0/Changelog-LibQTip-1.0-r152-release.txt
Normal file
13
Libs/LibQTip-1.0/Changelog-LibQTip-1.0-r152-release.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
------------------------------------------------------------------------
|
||||
r152 | torhal | 2011-04-27 08:11:19 +0000 (Wed, 27 Apr 2011) | 1 line
|
||||
Changed paths:
|
||||
A /tags/r152-release (from /trunk:151)
|
||||
|
||||
Tagging as r152-release
|
||||
------------------------------------------------------------------------
|
||||
r151 | torhal | 2011-04-27 08:09:30 +0000 (Wed, 27 Apr 2011) | 1 line
|
||||
Changed paths:
|
||||
M /trunk/LibQTip-1.0.toc
|
||||
|
||||
Updated ToC version for WoW 4.1
|
||||
------------------------------------------------------------------------
|
29
Libs/LibQTip-1.0/LICENSE.txt
Normal file
29
Libs/LibQTip-1.0/LICENSE.txt
Normal file
|
@ -0,0 +1,29 @@
|
|||
Copyright (c) 2008, LibQTip Development Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Redistribution of a stand alone version is strictly prohibited without
|
||||
prior written authorization from the Lead of the LibQTip Development Team.
|
||||
* Neither the name of the LibQTip Development Team nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1329
Libs/LibQTip-1.0/LibQTip-1.0.lua
Normal file
1329
Libs/LibQTip-1.0/LibQTip-1.0.lua
Normal file
File diff suppressed because it is too large
Load diff
17
Libs/LibQTip-1.0/LibQTip-1.0.toc
Normal file
17
Libs/LibQTip-1.0/LibQTip-1.0.toc
Normal file
|
@ -0,0 +1,17 @@
|
|||
## Interface: 40100
|
||||
## Title: Lib: QTip-1.0
|
||||
## Notes: Library providing multi-column tooltips.
|
||||
## Author: Torhal, Adirelle, Elkano, Tristanian
|
||||
## Version: r152-release
|
||||
## LoadOnDemand: 1
|
||||
## X-Date: 2011-04-27T08:09:30Z
|
||||
## X-Credits: Kaelten (input on initial design)
|
||||
## X-Category: Library, Tooltip
|
||||
## X-License: Ace3 BSD-like license
|
||||
## X-Curse-Packaged-Version: r152-release
|
||||
## X-Curse-Project-Name: LibQTip-1.0
|
||||
## X-Curse-Project-ID: libqtip-1-0
|
||||
## X-Curse-Repository-ID: wow/libqtip-1-0/mainline
|
||||
|
||||
LibStub\LibStub.lua
|
||||
lib.xml
|
51
Libs/LibQTip-1.0/LibStub/LibStub.lua
Normal file
51
Libs/LibQTip-1.0/LibStub/LibStub.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
-- $Id: LibStub.lua 76 2007-09-03 01:50:17Z mikk $
|
||||
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
|
||||
-- LibStub is hereby placed in the Public Domain
|
||||
-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
|
||||
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
|
||||
local LibStub = _G[LIBSTUB_MAJOR]
|
||||
|
||||
-- Check to see is this version of the stub is obsolete
|
||||
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
|
||||
LibStub = LibStub or {libs = {}, minors = {} }
|
||||
_G[LIBSTUB_MAJOR] = LibStub
|
||||
LibStub.minor = LIBSTUB_MINOR
|
||||
|
||||
-- LibStub:NewLibrary(major, minor)
|
||||
-- major (string) - the major version of the library
|
||||
-- minor (string or number ) - the minor version of the library
|
||||
--
|
||||
-- returns nil if a newer or same version of the lib is already present
|
||||
-- returns empty library object or old library object if upgrade is needed
|
||||
function LibStub:NewLibrary(major, minor)
|
||||
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
|
||||
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
|
||||
|
||||
local oldminor = self.minors[major]
|
||||
if oldminor and oldminor >= minor then return nil end
|
||||
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
|
||||
return self.libs[major], oldminor
|
||||
end
|
||||
|
||||
-- LibStub:GetLibrary(major, [silent])
|
||||
-- major (string) - the major version of the library
|
||||
-- silent (boolean) - if true, library is optional, silently return nil if its not found
|
||||
--
|
||||
-- throws an error if the library can not be found (except silent is set)
|
||||
-- returns the library object if found
|
||||
function LibStub:GetLibrary(major, silent)
|
||||
if not self.libs[major] and not silent then
|
||||
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
|
||||
end
|
||||
return self.libs[major], self.minors[major]
|
||||
end
|
||||
|
||||
-- LibStub:IterateLibraries()
|
||||
--
|
||||
-- Returns an iterator for the currently registered libraries
|
||||
function LibStub:IterateLibraries()
|
||||
return pairs(self.libs)
|
||||
end
|
||||
|
||||
setmetatable(LibStub, { __call = LibStub.GetLibrary })
|
||||
end
|
13
Libs/LibQTip-1.0/LibStub/LibStub.toc
Normal file
13
Libs/LibQTip-1.0/LibStub/LibStub.toc
Normal file
|
@ -0,0 +1,13 @@
|
|||
## Interface: 40000
|
||||
## Title: Lib: LibStub
|
||||
## Notes: Universal Library Stub
|
||||
## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
|
||||
## X-Website: http://jira.wowace.com/browse/LS
|
||||
## X-Category: Library
|
||||
## X-License: Public Domain
|
||||
## X-Curse-Packaged-Version: 1.0.1
|
||||
## X-Curse-Project-Name: LibStub
|
||||
## X-Curse-Project-ID: libstub
|
||||
## X-Curse-Repository-ID: wow/libstub/mainline
|
||||
|
||||
LibStub.lua
|
41
Libs/LibQTip-1.0/LibStub/tests/test.lua
Normal file
41
Libs/LibQTip-1.0/LibStub/tests/test.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
|
||||
assert(lib) -- should return the library table
|
||||
assert(not oldMinor) -- should not return the old minor, since it didn't exist
|
||||
|
||||
-- the following is to create data and then be able to check if the same data exists after the fact
|
||||
function lib:MyMethod()
|
||||
end
|
||||
local MyMethod = lib.MyMethod
|
||||
lib.MyTable = {}
|
||||
local MyTable = lib.MyTable
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
|
||||
assert(not newLib) -- should not return since out of date
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
|
||||
assert(not newLib) -- should not return since out of date
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
|
||||
assert(newLib) -- library table
|
||||
assert(rawequal(newLib, lib)) -- should be the same reference as the previous
|
||||
assert(newOldMinor == 1) -- should return the minor version of the previous version
|
||||
|
||||
assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
|
||||
assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
|
||||
assert(newLib) -- library table
|
||||
assert(newOldMinor == 2) -- previous version was 2
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
|
||||
assert(newLib)
|
||||
assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
|
||||
assert(newLib)
|
||||
assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
|
27
Libs/LibQTip-1.0/LibStub/tests/test2.lua
Normal file
27
Libs/LibQTip-1.0/LibStub/tests/test2.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
for major, library in LibStub:IterateLibraries() do
|
||||
-- check that MyLib doesn't exist yet, by iterating through all the libraries
|
||||
assert(major ~= "MyLib")
|
||||
end
|
||||
|
||||
assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
|
||||
assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
|
||||
local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
|
||||
assert(lib) -- check it exists
|
||||
assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
|
||||
|
||||
assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
|
||||
|
||||
local count=0
|
||||
for major, library in LibStub:IterateLibraries() do
|
||||
-- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
|
||||
if major == "MyLib" then -- we found it!
|
||||
count = count +1
|
||||
assert(rawequal(library, lib)) -- verify that the references are equal
|
||||
end
|
||||
end
|
||||
assert(count == 1) -- verify that we actually found it, and only once
|
14
Libs/LibQTip-1.0/LibStub/tests/test3.lua
Normal file
14
Libs/LibQTip-1.0/LibStub/tests/test3.lua
Normal file
|
@ -0,0 +1,14 @@
|
|||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
local proxy = newproxy() -- non-string
|
||||
|
||||
assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
|
||||
local success, ret = pcall(LibStub.GetLibrary, proxy, true)
|
||||
assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
|
||||
|
||||
assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
|
||||
|
||||
assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
|
41
Libs/LibQTip-1.0/LibStub/tests/test4.lua
Normal file
41
Libs/LibQTip-1.0/LibStub/tests/test4.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
|
||||
-- Pretend like loaded libstub is old and doesn't have :IterateLibraries
|
||||
assert(LibStub.minor)
|
||||
LibStub.minor = LibStub.minor - 0.0001
|
||||
LibStub.IterateLibraries = nil
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(type(LibStub.IterateLibraries)=="function")
|
||||
|
||||
|
||||
-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
|
||||
LibStub.IterateLibraries = 123
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
|
||||
LibStub.minor = LibStub.minor + 0.0001
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
-- Again with a huge number
|
||||
LibStub.minor = LibStub.minor + 1234567890
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
print("OK")
|
4
Libs/LibQTip-1.0/lib.xml
Normal file
4
Libs/LibQTip-1.0/lib.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="LibQTip-1.0.lua"/>
|
||||
</Ui>
|
Loading…
Reference in a new issue