Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d241fd1b5e | |||
| ad2a536efe | |||
| 50f6e30f71 | |||
| efbc200ba7 | |||
| eba2da8400 | |||
| 1558e6b18f | |||
| 3686bb4f9f | |||
| c0a23544f1 | |||
| 5035f39364 | |||
| 83bbe12a87 | |||
| 1e2408fd0a | |||
| f8214b6b6c | |||
| 6605c1ca12 | |||
| 5d9749a920 | |||
| ede7d2b23d | |||
| 2d7349cafb | |||
| da942631f0 | |||
| 48ebec985b | |||
| 9679966f37 |
@@ -0,0 +1,71 @@
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*-coa.*' # Asc-1.1.6-coa.2, 9.1.40-coa.3, etc.
|
||||
- 'v*' # v0.3.0 for repos without an upstream version
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: linux-amd64
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # build_zip uses git archive HEAD; full history is fine
|
||||
|
||||
- name: Build per-addon zip(s)
|
||||
run: bash tools/build_zip.sh
|
||||
|
||||
- name: Publish release (Gitea API direct; no action dependency)
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
API: ${{ github.server_url }}/api/v1
|
||||
# Gitea attachment ceiling is 200 MiB (see roles/gitea config).
|
||||
# Skip anything larger so one oversized asset doesn't fail the job.
|
||||
MAX_BYTES: 209715200
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Create the release (or reuse if it already exists for this tag).
|
||||
RID=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
|
||||
"$API/repos/$REPO/releases/tags/$TAG" 2>/dev/null \
|
||||
| jq -r '.id // empty')
|
||||
if [ -z "$RID" ]; then
|
||||
RID=$(curl -sf -X POST -H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
"$API/repos/$REPO/releases" \
|
||||
-d "$(jq -nc --arg t "$TAG" '{tag_name:$t,name:$t,draft:false,prerelease:false}')" \
|
||||
| jq -r '.id')
|
||||
fi
|
||||
echo "release id: $RID"
|
||||
# Upload every dist/*.zip. Per-asset failures don't fail the job —
|
||||
# we want partial releases to still publish rather than block the
|
||||
# whole pipeline on one big file.
|
||||
failed=0
|
||||
uploaded=0
|
||||
for f in dist/*.zip; do
|
||||
name=$(basename "$f")
|
||||
size=$(stat -c '%s' "$f")
|
||||
if [ "$size" -gt "$MAX_BYTES" ]; then
|
||||
echo "::warning::skip $name (${size} B > ${MAX_BYTES} B Gitea limit; host on CDN instead)"
|
||||
failed=$((failed+1))
|
||||
continue
|
||||
fi
|
||||
echo "uploading $name ($(numfmt --to=iec "$size"))"
|
||||
if curl -sf -X POST -H "Authorization: token $GITEA_TOKEN" \
|
||||
-F "attachment=@$f" \
|
||||
"$API/repos/$REPO/releases/$RID/assets?name=$name" \
|
||||
| jq -r '" -> " + .browser_download_url'; then
|
||||
uploaded=$((uploaded+1))
|
||||
else
|
||||
echo "::warning::upload failed for $name"
|
||||
failed=$((failed+1))
|
||||
fi
|
||||
done
|
||||
echo "release published: $uploaded uploaded, $failed skipped/failed"
|
||||
# Only fail the job if NO assets uploaded — a release with zero
|
||||
# attachments isn't useful to anyone.
|
||||
[ "$uploaded" -gt 0 ]
|
||||
@@ -1,77 +0,0 @@
|
||||
name: "Bug Report"
|
||||
description: Create a report to help us improve this addon
|
||||
labels: '🐛 Bug'
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Please search for existing issues before creating a new one.
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Description
|
||||
description: What did you expect to happen and what happened instead?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: flavor
|
||||
attributes:
|
||||
label: Realm
|
||||
description: What realm did this occur on?
|
||||
options:
|
||||
- Area 52 (Default)
|
||||
- Seasonal
|
||||
- Grizzly Hills
|
||||
- Rexxar
|
||||
- Other
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: testing
|
||||
attributes:
|
||||
label: Tested with only this addon
|
||||
description: Did you try having just this addon as the only enabled addon and everything else disabled?
|
||||
options:
|
||||
- label: "Yes"
|
||||
- label: "No"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Lua Error
|
||||
description: |
|
||||
Do you have an error log of what happened? If you don't see any errors, make sure that error reporting is enabled (`/console scriptErrors 1`)
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Reproduction Steps
|
||||
description: Please list out the steps to reproduce your bug.
|
||||
placeholder: |
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: Last Good Version
|
||||
description: |
|
||||
Was it working in a previous version? If yes, which update did it stop working? If you don't know, when was the last date you were aware it was working
|
||||
placeholder: "MM/DD/YYYY"
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Screenshots
|
||||
description: If applicable, add screenshots to help explain your problem.
|
||||
placeholder: Click here to attach your screenshots via the editor button in the top right.
|
||||
validations:
|
||||
required: false
|
||||
@@ -1 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -1,28 +0,0 @@
|
||||
# Description
|
||||
|
||||
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
|
||||
<!-- A #issueNumber will be sufficient. -->
|
||||
Fixes #(issue)
|
||||
|
||||
## Type of change
|
||||
|
||||
Please delete options that are not relevant.
|
||||
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
|
||||
## How Has This Been Tested
|
||||
|
||||
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
|
||||
|
||||
- [ ] Test A
|
||||
- [ ] Test B
|
||||
|
||||
## Checklist
|
||||
<!-- These can be checked off after the pull request is submitted, in case you want discussion before they are completely ready -->
|
||||
|
||||
- [ ] I have performed a self-review of my own code
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
|
||||
<!-- Is there any additional work that needs to be done? If so, add it to the above list -->
|
||||
@@ -5,3 +5,4 @@
|
||||
.lua/*
|
||||
.vscode
|
||||
.idea
|
||||
dist/
|
||||
|
||||
@@ -3760,14 +3760,17 @@ local function loadFilterOptions()
|
||||
add = {
|
||||
order = 0,
|
||||
type = "input",
|
||||
name = L["Aura name"],
|
||||
name = L["Aura name or spell ID"],
|
||||
desc = L["Enter an exact aura name, or a numeric spell ID for precise matching (CoA's client exposes aura spell IDs)."],
|
||||
--dialogControl = "Aura_EditBox",
|
||||
hidden = false,
|
||||
set = function(info, value)
|
||||
local filterType = info[#(info) - 3]
|
||||
local filter = filterMap[info[#(info) - 2]]
|
||||
|
||||
ShadowUF.db.profile.filters[filterType][filter][value] = true
|
||||
-- A purely-numeric entry is stored as a number so it matches the
|
||||
-- spellId returned by UnitAura; anything else stays a name string.
|
||||
ShadowUF.db.profile.filters[filterType][filter][tonumber(value) or value] = true
|
||||
|
||||
reloadUnitAuras()
|
||||
rebuildFilters()
|
||||
@@ -3846,7 +3849,15 @@ local function loadFilterOptions()
|
||||
-- on the other hand we can't set width to "normal" so tricking it
|
||||
width = "",
|
||||
fontSize = "medium",
|
||||
name = function(info) return spellMap[info[#(info)]] end,
|
||||
name = function(info)
|
||||
local entry = spellMap[info[#(info)]]
|
||||
-- Numeric entries are spell IDs; show "Name (ID)" when the client can resolve it.
|
||||
if( type(entry) == "number" ) then
|
||||
local spellName = GetSpellInfo(entry)
|
||||
return spellName and string.format("%s (%d)", spellName, entry) or tostring(entry)
|
||||
end
|
||||
return entry
|
||||
end,
|
||||
}
|
||||
|
||||
local spellRow = {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
-- as well as associate it with a slash command.
|
||||
-- @class file
|
||||
-- @name AceConfig-3.0
|
||||
-- @release $Id: AceConfig-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $
|
||||
-- @release $Id$
|
||||
|
||||
--[[
|
||||
AceConfig-3.0
|
||||
@@ -12,21 +12,22 @@ Very light wrapper library that combines all the AceConfig subcomponents into on
|
||||
|
||||
]]
|
||||
|
||||
local MAJOR, MINOR = "AceConfig-3.0", 2
|
||||
local cfgreg = LibStub("AceConfigRegistry-3.0")
|
||||
local cfgcmd = LibStub("AceConfigCmd-3.0")
|
||||
|
||||
local MAJOR, MINOR = "AceConfig-3.0", 3
|
||||
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not AceConfig then return end
|
||||
|
||||
local cfgreg = LibStub("AceConfigRegistry-3.0")
|
||||
local cfgcmd = LibStub("AceConfigCmd-3.0")
|
||||
local cfgdlg = LibStub("AceConfigDialog-3.0")
|
||||
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0")
|
||||
--TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
|
||||
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
|
||||
|
||||
-- Lua APIs
|
||||
local pcall, error, type, pairs = pcall, error, type, pairs
|
||||
|
||||
-- -------------------------------------------------------------------
|
||||
-- :RegisterOptionsTable(appName, options, slashcmd, persist)
|
||||
-- :RegisterOptionsTable(appName, options, slashcmd)
|
||||
--
|
||||
-- - appName - (string) application name
|
||||
-- - options - table or function ref, see AceConfigRegistry
|
||||
@@ -36,7 +37,7 @@ local pcall, error, type, pairs = pcall, error, type, pairs
|
||||
-- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
|
||||
-- @paramsig appName, options [, slashcmd]
|
||||
-- @param appName The application name for the config table.
|
||||
-- @param options The option table (or a function to generate one on demand)
|
||||
-- @param options The option table (or a function to generate one on demand). http://www.wowace.com/addons/ace3/pages/ace-config-3-0-options-tables/
|
||||
-- @param slashcmd A slash command to register for the option table, or a table of slash commands.
|
||||
-- @usage
|
||||
-- local AceConfig = LibStub("AceConfig-3.0")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- AceConfigCmd-3.0 handles access to an options table through the "command line" interface via the ChatFrames.
|
||||
-- @class file
|
||||
-- @name AceConfigCmd-3.0
|
||||
-- @release $Id: AceConfigCmd-3.0.lua 904 2009-12-13 11:56:37Z nevcairiel $
|
||||
-- @release $Id$
|
||||
|
||||
--[[
|
||||
AceConfigCmd-3.0
|
||||
@@ -14,8 +14,9 @@ REQUIRES: AceConsole-3.0 for command registration (loaded on demand)
|
||||
|
||||
-- TODO: plugin args
|
||||
|
||||
local cfgreg = LibStub("AceConfigRegistry-3.0")
|
||||
|
||||
local MAJOR, MINOR = "AceConfigCmd-3.0", 12
|
||||
local MAJOR, MINOR = "AceConfigCmd-3.0", 14
|
||||
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not AceConfigCmd then return end
|
||||
@@ -23,7 +24,6 @@ if not AceConfigCmd then return end
|
||||
AceConfigCmd.commands = AceConfigCmd.commands or {}
|
||||
local commands = AceConfigCmd.commands
|
||||
|
||||
local cfgreg = LibStub("AceConfigRegistry-3.0")
|
||||
local AceConsole -- LoD
|
||||
local AceConsoleName = "AceConsole-3.0"
|
||||
|
||||
@@ -37,17 +37,10 @@ local error, assert = error, assert
|
||||
-- WoW APIs
|
||||
local _G = _G
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: LibStub, SELECTED_CHAT_FRAME, DEFAULT_CHAT_FRAME
|
||||
|
||||
|
||||
local L = setmetatable({}, { -- TODO: replace with proper locale
|
||||
__index = function(self,k) return k end
|
||||
})
|
||||
|
||||
|
||||
|
||||
local function print(msg)
|
||||
(SELECTED_CHAT_FRAME or DEFAULT_CHAT_FRAME):AddMessage(msg)
|
||||
end
|
||||
@@ -401,7 +394,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
||||
return
|
||||
end
|
||||
|
||||
local str = strsub(info.input,inputpos);
|
||||
local strInput = strsub(info.input,inputpos);
|
||||
|
||||
if tab.type=="execute" then
|
||||
------------ execute --------------------------------------------
|
||||
@@ -414,21 +407,21 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
||||
|
||||
local res = true
|
||||
if tab.pattern then
|
||||
if not(type(tab.pattern)=="string") then err(info, inputpos, "'pattern' - expected a string") end
|
||||
if not strmatch(str, tab.pattern) then
|
||||
usererr(info, inputpos, "'"..str.."' - " .. L["invalid input"])
|
||||
if type(tab.pattern)~="string" then err(info, inputpos, "'pattern' - expected a string") end
|
||||
if not strmatch(strInput, tab.pattern) then
|
||||
usererr(info, inputpos, "'"..strInput.."' - " .. L["invalid input"])
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
do_final(info, inputpos, tab, "set", str)
|
||||
do_final(info, inputpos, tab, "set", strInput)
|
||||
|
||||
|
||||
|
||||
elseif tab.type=="toggle" then
|
||||
------------ toggle --------------------------------------------
|
||||
local b
|
||||
local str = strtrim(strlower(str))
|
||||
local str = strtrim(strlower(strInput))
|
||||
if str=="" then
|
||||
b = callmethod(info, inputpos, tab, "get")
|
||||
|
||||
@@ -465,9 +458,9 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
||||
|
||||
elseif tab.type=="range" then
|
||||
------------ range --------------------------------------------
|
||||
local val = tonumber(str)
|
||||
local val = tonumber(strInput)
|
||||
if not val then
|
||||
usererr(info, inputpos, "'"..str.."' - "..L["expected number"])
|
||||
usererr(info, inputpos, "'"..strInput.."' - "..L["expected number"])
|
||||
return
|
||||
end
|
||||
if type(info.step)=="number" then
|
||||
@@ -487,7 +480,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
||||
|
||||
elseif tab.type=="select" then
|
||||
------------ select ------------------------------------
|
||||
local str = strtrim(strlower(str))
|
||||
local str = strtrim(strlower(strInput))
|
||||
|
||||
local values = tab.values
|
||||
if type(values) == "function" or type(values) == "string" then
|
||||
@@ -528,7 +521,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
||||
|
||||
elseif tab.type=="multiselect" then
|
||||
------------ multiselect -------------------------------------------
|
||||
local str = strtrim(strlower(str))
|
||||
local str = strtrim(strlower(strInput))
|
||||
|
||||
local values = tab.values
|
||||
if type(values) == "function" or type(values) == "string" then
|
||||
@@ -565,7 +558,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
||||
|
||||
--check that the opt is valid
|
||||
local ok
|
||||
for k,v in pairs(values) do
|
||||
for k in pairs(values) do
|
||||
if strlower(k)==opt then
|
||||
opt = k -- overwrite with key (in case of case mismatches)
|
||||
ok = true
|
||||
@@ -634,7 +627,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
||||
|
||||
elseif tab.type=="color" then
|
||||
------------ color --------------------------------------------
|
||||
local str = strtrim(strlower(str))
|
||||
local str = strtrim(strlower(strInput))
|
||||
if str == "" then
|
||||
--TODO: Show current value
|
||||
return
|
||||
@@ -642,7 +635,14 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
||||
|
||||
local r, g, b, a
|
||||
|
||||
if tab.hasAlpha then
|
||||
local hasAlpha = tab.hasAlpha
|
||||
if type(hasAlpha) == "function" or type(hasAlpha) == "string" then
|
||||
info.hasAlpha = hasAlpha
|
||||
hasAlpha = callmethod(info, inputpos, tab, 'hasAlpha')
|
||||
info.hasAlpha = nil
|
||||
end
|
||||
|
||||
if hasAlpha then
|
||||
if str:len() == 8 and str:find("^%x*$") then
|
||||
--parse a hex string
|
||||
r,g,b,a = tonumber(str:sub(1, 2), 16) / 255, tonumber(str:sub(3, 4), 16) / 255, tonumber(str:sub(5, 6), 16) / 255, tonumber(str:sub(7, 8), 16) / 255
|
||||
@@ -699,7 +699,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
||||
|
||||
elseif tab.type=="keybinding" then
|
||||
------------ keybinding --------------------------------------------
|
||||
local str = strtrim(strlower(str))
|
||||
local str = strtrim(strlower(strInput))
|
||||
if str == "" then
|
||||
--TODO: Show current value
|
||||
return
|
||||
|
||||
+417
-255
File diff suppressed because it is too large
Load Diff
+43
-16
@@ -8,16 +8,16 @@
|
||||
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName".
|
||||
-- @class file
|
||||
-- @name AceConfigRegistry-3.0
|
||||
-- @release $Id: AceConfigRegistry-3.0.lua 921 2010-05-09 15:49:14Z nevcairiel $
|
||||
local MAJOR, MINOR = "AceConfigRegistry-3.0", 12
|
||||
-- @release $Id$
|
||||
local CallbackHandler = LibStub("CallbackHandler-1.0")
|
||||
|
||||
local MAJOR, MINOR = "AceConfigRegistry-3.0", 22
|
||||
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not AceConfigRegistry then return end
|
||||
|
||||
AceConfigRegistry.tables = AceConfigRegistry.tables or {}
|
||||
|
||||
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
|
||||
|
||||
if not AceConfigRegistry.callbacks then
|
||||
AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
|
||||
end
|
||||
@@ -57,8 +57,8 @@ local istable={["table"]=true, _="table"}
|
||||
local ismethodtable={["table"]=true,["string"]=true,["function"]=true, _="methodname, funcref or table"}
|
||||
local optstring={["nil"]=true,["string"]=true, _="string"}
|
||||
local optstringfunc={["nil"]=true,["string"]=true,["function"]=true, _="string or funcref"}
|
||||
local optstringnumberfunc={["nil"]=true,["string"]=true,["number"]=true,["function"]=true, _="string, number or funcref"}
|
||||
local optnumber={["nil"]=true,["number"]=true, _="number"}
|
||||
local optmethod={["nil"]=true,["string"]=true,["function"]=true, _="methodname or funcref"}
|
||||
local optmethodfalse={["nil"]=true,["string"]=true,["function"]=true,["boolean"]={[false]=true}, _="methodname, funcref or false"}
|
||||
local optmethodnumber={["nil"]=true,["string"]=true,["function"]=true,["number"]=true, _="methodname, funcref or number"}
|
||||
local optmethodtable={["nil"]=true,["string"]=true,["function"]=true,["table"]=true, _="methodname, funcref or table"}
|
||||
@@ -66,6 +66,7 @@ local optmethodbool={["nil"]=true,["string"]=true,["function"]=true,["boolean"]=
|
||||
local opttable={["nil"]=true,["table"]=true, _="table"}
|
||||
local optbool={["nil"]=true,["boolean"]=true, _="boolean"}
|
||||
local optboolnumber={["nil"]=true,["boolean"]=true,["number"]=true, _="boolean or number"}
|
||||
local optstringnumber={["nil"]=true,["string"]=true,["number"]=true, _="string or number"}
|
||||
|
||||
local basekeys={
|
||||
type=isstring,
|
||||
@@ -82,24 +83,33 @@ local basekeys={
|
||||
dialogHidden=optmethodbool,
|
||||
dropdownHidden=optmethodbool,
|
||||
cmdHidden=optmethodbool,
|
||||
icon=optstringfunc,
|
||||
tooltipHyperlink=optstringfunc,
|
||||
icon=optstringnumberfunc,
|
||||
iconCoords=optmethodtable,
|
||||
handler=opttable,
|
||||
get=optmethodfalse,
|
||||
set=optmethodfalse,
|
||||
func=optmethodfalse,
|
||||
arg={["*"]=true},
|
||||
width=optstring,
|
||||
width=optstringnumber,
|
||||
relWidth=optnumber,
|
||||
}
|
||||
|
||||
local typedkeys={
|
||||
header={},
|
||||
header={
|
||||
control=optstring,
|
||||
dialogControl=optstring,
|
||||
dropdownControl=optstring,
|
||||
},
|
||||
description={
|
||||
image=optstringfunc,
|
||||
image=optstringnumberfunc,
|
||||
imageCoords=optmethodtable,
|
||||
imageHeight=optnumber,
|
||||
imageWidth=optnumber,
|
||||
fontSize=optstringfunc,
|
||||
control=optstring,
|
||||
dialogControl=optstring,
|
||||
dropdownControl=optstring,
|
||||
},
|
||||
group={
|
||||
args=istable,
|
||||
@@ -112,10 +122,13 @@ local typedkeys={
|
||||
childGroups=optstring,
|
||||
},
|
||||
execute={
|
||||
image=optstringfunc,
|
||||
image=optstringnumberfunc,
|
||||
imageCoords=optmethodtable,
|
||||
imageHeight=optnumber,
|
||||
imageWidth=optnumber,
|
||||
control=optstring,
|
||||
dialogControl=optstring,
|
||||
dropdownControl=optstring,
|
||||
},
|
||||
input={
|
||||
pattern=optstring,
|
||||
@@ -127,8 +140,11 @@ local typedkeys={
|
||||
},
|
||||
toggle={
|
||||
tristate=optbool,
|
||||
image=optstringfunc,
|
||||
image=optstringnumberfunc,
|
||||
imageCoords=optmethodtable,
|
||||
control=optstring,
|
||||
dialogControl=optstring,
|
||||
dropdownControl=optstring,
|
||||
},
|
||||
tristate={
|
||||
},
|
||||
@@ -140,9 +156,13 @@ local typedkeys={
|
||||
step=optnumber,
|
||||
bigStep=optnumber,
|
||||
isPercent=optbool,
|
||||
control=optstring,
|
||||
dialogControl=optstring,
|
||||
dropdownControl=optstring,
|
||||
},
|
||||
select={
|
||||
values=ismethodtable,
|
||||
sorting=optmethodtable,
|
||||
style={
|
||||
["nil"]=true,
|
||||
["string"]={dropdown=true,radio=true},
|
||||
@@ -151,6 +171,7 @@ local typedkeys={
|
||||
control=optstring,
|
||||
dialogControl=optstring,
|
||||
dropdownControl=optstring,
|
||||
itemControl=optstring,
|
||||
},
|
||||
multiselect={
|
||||
values=ismethodtable,
|
||||
@@ -161,10 +182,15 @@ local typedkeys={
|
||||
dropdownControl=optstring,
|
||||
},
|
||||
color={
|
||||
hasAlpha=optbool,
|
||||
hasAlpha=optmethodbool,
|
||||
control=optstring,
|
||||
dialogControl=optstring,
|
||||
dropdownControl=optstring,
|
||||
},
|
||||
keybinding={
|
||||
-- TODO
|
||||
control=optstring,
|
||||
dialogControl=optstring,
|
||||
dropdownControl=optstring,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -287,7 +313,8 @@ end
|
||||
-- @param appName The application name as given to `:RegisterOptionsTable()`
|
||||
-- @param options The options table, OR a function reference that generates it on demand. \\
|
||||
-- See the top of the page for info on arguments passed to such functions.
|
||||
function AceConfigRegistry:RegisterOptionsTable(appName, options)
|
||||
-- @param skipValidation Skip options table validation (primarily useful for extremely huge options, with a noticeable slowdown)
|
||||
function AceConfigRegistry:RegisterOptionsTable(appName, options, skipValidation)
|
||||
if type(options)=="table" then
|
||||
if options.type~="group" then -- quick sanity checker
|
||||
error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2)
|
||||
@@ -295,7 +322,7 @@ function AceConfigRegistry:RegisterOptionsTable(appName, options)
|
||||
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
|
||||
errlvl=(errlvl or 0)+1
|
||||
validateGetterArgs(uiType, uiName, errlvl)
|
||||
if not AceConfigRegistry.validated[uiType][appName] then
|
||||
if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
|
||||
AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
|
||||
AceConfigRegistry.validated[uiType][appName] = true
|
||||
end
|
||||
@@ -306,7 +333,7 @@ function AceConfigRegistry:RegisterOptionsTable(appName, options)
|
||||
errlvl=(errlvl or 0)+1
|
||||
validateGetterArgs(uiType, uiName, errlvl)
|
||||
local tab = assert(options(uiType, uiName, appName))
|
||||
if not AceConfigRegistry.validated[uiType][appName] then
|
||||
if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
|
||||
AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
|
||||
AceConfigRegistry.validated[uiType][appName] = true
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles.
|
||||
-- @class file
|
||||
-- @name AceDBOptions-3.0
|
||||
-- @release $Id: AceDBOptions-3.0.lua 938 2010-06-13 07:21:38Z nevcairiel $
|
||||
local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 12
|
||||
local AceDBOptions, oldminor = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR)
|
||||
-- @release $Id$
|
||||
local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 15
|
||||
local AceDBOptions = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR)
|
||||
|
||||
if not AceDBOptions then return end -- No upgrade needed
|
||||
|
||||
@@ -13,10 +13,6 @@ local pairs, next = pairs, next
|
||||
-- WoW APIs
|
||||
local UnitClass = UnitClass
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: NORMAL_FONT_COLOR_CODE, FONT_COLOR_CODE_CLOSE
|
||||
|
||||
AceDBOptions.optionTables = AceDBOptions.optionTables or {}
|
||||
AceDBOptions.handlers = AceDBOptions.handlers or {}
|
||||
|
||||
@@ -25,168 +21,208 @@ AceDBOptions.handlers = AceDBOptions.handlers or {}
|
||||
]]
|
||||
|
||||
local L = {
|
||||
default = "Default",
|
||||
intro = "You can change the active database profile, so you can have different settings for every character.",
|
||||
reset_desc = "Reset the current profile back to its default values, in case your configuration is broken, or you simply want to start over.",
|
||||
reset = "Reset Profile",
|
||||
reset_sub = "Reset the current profile to the default",
|
||||
choose = "Existing Profiles",
|
||||
choose_desc = "You can either create a new profile by entering a name in the editbox, or choose one of the already existing profiles.",
|
||||
choose_sub = "Select one of your currently available profiles.",
|
||||
copy = "Copy From",
|
||||
copy_desc = "Copy the settings from one existing profile into the currently active profile.",
|
||||
current = "Current Profile:",
|
||||
default = "Default",
|
||||
delete = "Delete a Profile",
|
||||
delete_confirm = "Are you sure you want to delete the selected profile?",
|
||||
delete_desc = "Delete existing and unused profiles from the database to save space, and cleanup the SavedVariables file.",
|
||||
delete_sub = "Deletes a profile from the database.",
|
||||
intro = "You can change the active database profile, so you can have different settings for every character.",
|
||||
new = "New",
|
||||
new_sub = "Create a new empty profile.",
|
||||
choose = "Existing Profiles",
|
||||
choose_sub = "Select one of your currently available profiles.",
|
||||
copy_desc = "Copy the settings from one existing profile into the currently active profile.",
|
||||
copy = "Copy From",
|
||||
delete_desc = "Delete existing and unused profiles from the database to save space, and cleanup the SavedVariables file.",
|
||||
delete = "Delete a Profile",
|
||||
delete_sub = "Deletes a profile from the database.",
|
||||
delete_confirm = "Are you sure you want to delete the selected profile?",
|
||||
profiles = "Profiles",
|
||||
profiles_sub = "Manage Profiles",
|
||||
current = "Current Profile:",
|
||||
reset = "Reset Profile",
|
||||
reset_desc = "Reset the current profile back to its default values, in case your configuration is broken, or you simply want to start over.",
|
||||
reset_sub = "Reset the current profile to the default",
|
||||
}
|
||||
|
||||
local LOCALE = GetLocale()
|
||||
if LOCALE == "deDE" then
|
||||
L["choose"] = "Vorhandene Profile"
|
||||
L["choose_desc"] = "Du kannst ein neues Profil erstellen, indem du einen neuen Namen in der Eingabebox 'Neu' eingibst, oder wähle eines der vorhandenen Profile aus."
|
||||
L["choose_sub"] = "Wählt ein bereits vorhandenes Profil aus."
|
||||
L["copy"] = "Kopieren von..."
|
||||
L["copy_desc"] = "Kopiere die Einstellungen von einem vorhandenen Profil in das aktive Profil."
|
||||
L["current"] = "Aktuelles Profil:"
|
||||
L["default"] = "Standard"
|
||||
L["intro"] = "Hier kannst du das aktive Datenbankprofile \195\164ndern, damit du verschiedene Einstellungen f\195\188r jeden Charakter erstellen kannst, wodurch eine sehr flexible Konfiguration m\195\182glich wird."
|
||||
L["reset_desc"] = "Setzt das momentane Profil auf Standardwerte zur\195\188ck, f\195\188r den Fall das mit der Konfiguration etwas schief lief oder weil du einfach neu starten willst."
|
||||
L["reset"] = "Profil zur\195\188cksetzen"
|
||||
L["reset_sub"] = "Das aktuelle Profil auf Standard zur\195\188cksetzen."
|
||||
L["choose_desc"] = "Du kannst ein neues Profil erstellen, indem du einen neuen Namen in der Eingabebox 'Neu' eingibst, oder w\195\164hle eines der vorhandenen Profile aus."
|
||||
L["delete"] = "Profil löschen"
|
||||
L["delete_confirm"] = "Willst du das ausgewählte Profil wirklich löschen?"
|
||||
L["delete_desc"] = "Lösche vorhandene oder unbenutzte Profile aus der Datenbank, um Platz zu sparen und die SavedVariables-Datei 'sauber' zu halten."
|
||||
L["delete_sub"] = "Löscht ein Profil aus der Datenbank."
|
||||
L["intro"] = "Hier kannst du das aktive Datenbankprofil ändern, damit du verschiedene Einstellungen für jeden Charakter erstellen kannst, wodurch eine sehr flexible Konfiguration möglich wird."
|
||||
L["new"] = "Neu"
|
||||
L["new_sub"] = "Ein neues Profil erstellen."
|
||||
L["choose"] = "Vorhandene Profile"
|
||||
L["choose_sub"] = "W\195\164hlt ein bereits vorhandenes Profil aus."
|
||||
L["copy_desc"] = "Kopiere die Einstellungen von einem vorhandenen Profil in das aktive Profil."
|
||||
L["copy"] = "Kopieren von..."
|
||||
L["delete_desc"] = "L\195\182sche vorhandene oder unbenutzte Profile aus der Datenbank um Platz zu sparen und um die SavedVariables Datei 'sauber' zu halten."
|
||||
L["delete"] = "Profil l\195\182schen"
|
||||
L["delete_sub"] = "L\195\182scht ein Profil aus der Datenbank."
|
||||
L["delete_confirm"] = "Willst du das ausgew\195\164hlte Profil wirklich l\195\182schen?"
|
||||
L["profiles"] = "Profile"
|
||||
L["profiles_sub"] = "Profile verwalten"
|
||||
--L["current"] = "Current Profile:"
|
||||
L["reset"] = "Profil zurücksetzen"
|
||||
L["reset_desc"] = "Setzt das momentane Profil auf Standardwerte zurück, für den Fall, dass mit der Konfiguration etwas schief lief oder weil du einfach neu starten willst."
|
||||
L["reset_sub"] = "Das aktuelle Profil auf Standard zurücksetzen."
|
||||
elseif LOCALE == "frFR" then
|
||||
L["default"] = "D\195\169faut"
|
||||
L["intro"] = "Vous pouvez changer le profil actuel afin d'avoir des param\195\168tres diff\195\169rents pour chaque personnage, permettant ainsi d'avoir une configuration tr\195\168s flexible."
|
||||
L["reset_desc"] = "R\195\169initialise le profil actuel au cas o\195\185 votre configuration est corrompue ou si vous voulez tout simplement faire table rase."
|
||||
L["reset"] = "R\195\169initialiser le profil"
|
||||
L["reset_sub"] = "R\195\169initialise le profil actuel avec les param\195\168tres par d\195\169faut."
|
||||
L["choose_desc"] = "Vous pouvez cr\195\169er un nouveau profil en entrant un nouveau nom dans la bo\195\174te de saisie, ou en choississant un des profils d\195\169j\195\160 existants."
|
||||
L["new"] = "Nouveau"
|
||||
L["new_sub"] = "Cr\195\169\195\169e un nouveau profil vierge."
|
||||
L["choose"] = "Profils existants"
|
||||
L["choose_sub"] = "Permet de choisir un des profils d\195\169j\195\160 disponibles."
|
||||
L["copy_desc"] = "Copie les param\195\168tres d'un profil d\195\169j\195\160 existant dans le profil actuellement actif."
|
||||
L["copy"] = "Copier \195\160 partir de"
|
||||
L["delete_desc"] = "Supprime les profils existants inutilis\195\169s de la base de donn\195\169es afin de gagner de la place et de nettoyer le fichier SavedVariables."
|
||||
L["choose_desc"] = "Vous pouvez créer un nouveau profil en entrant un nouveau nom dans la boîte de saisie, ou en choississant un des profils déjà existants."
|
||||
L["choose_sub"] = "Permet de choisir un des profils déjà disponibles."
|
||||
L["copy"] = "Copier à partir de"
|
||||
L["copy_desc"] = "Copie les paramètres d'un profil déjà existant dans le profil actuellement actif."
|
||||
L["current"] = "Profil actuel :"
|
||||
L["default"] = "Défaut"
|
||||
L["delete"] = "Supprimer un profil"
|
||||
L["delete_sub"] = "Supprime un profil de la base de donn\195\169es."
|
||||
L["delete_confirm"] = "Etes-vous s\195\187r de vouloir supprimer le profil s\195\169lectionn\195\169 ?"
|
||||
L["delete_confirm"] = "Etes-vous sûr de vouloir supprimer le profil sélectionné ?"
|
||||
L["delete_desc"] = "Supprime les profils existants inutilisés de la base de données afin de gagner de la place et de nettoyer le fichier SavedVariables."
|
||||
L["delete_sub"] = "Supprime un profil de la base de données."
|
||||
L["intro"] = "Vous pouvez changer le profil actuel afin d'avoir des paramètres différents pour chaque personnage, permettant ainsi d'avoir une configuration très flexible."
|
||||
L["new"] = "Nouveau"
|
||||
L["new_sub"] = "Créée un nouveau profil vierge."
|
||||
L["profiles"] = "Profils"
|
||||
L["profiles_sub"] = "Gestion des profils"
|
||||
--L["current"] = "Current Profile:"
|
||||
L["reset"] = "Réinitialiser le profil"
|
||||
L["reset_desc"] = "Réinitialise le profil actuel au cas où votre configuration est corrompue ou si vous voulez tout simplement faire table rase."
|
||||
L["reset_sub"] = "Réinitialise le profil actuel avec les paramètres par défaut."
|
||||
elseif LOCALE == "koKR" then
|
||||
L["choose"] = "기존 프로필"
|
||||
L["choose_desc"] = "편집 상자에 이름을 입력하여 새로운 프로필을 만들거나 이미 존재하는 프로필 중 하나를 선택할 수 있습니다."
|
||||
L["choose_sub"] = "현재 이용할 수 있는 프로필 중 하나를 선택합니다."
|
||||
L["copy"] = "복사해 올 프로필"
|
||||
L["copy_desc"] = "기존 프로필의 설정을 현재 활성화된 프로필로 복사합니다."
|
||||
L["current"] = "현재 프로필:"
|
||||
L["default"] = "기본값"
|
||||
L["intro"] = "모든 캐릭터의 다양한 설정과 사용중인 데이터베이스 프로필, 어느것이던지 매우 다루기 쉽게 바꿀수 있습니다."
|
||||
L["reset_desc"] = "단순히 다시 새롭게 구성을 원하는 경우, 현재 프로필을 기본값으로 초기화 합니다."
|
||||
L["reset"] = "프로필 초기화"
|
||||
L["reset_sub"] = "현재의 프로필을 기본값으로 초기화 합니다"
|
||||
L["choose_desc"] = "새로운 이름을 입력하거나, 이미 있는 프로필중 하나를 선택하여 새로운 프로필을 만들 수 있습니다."
|
||||
L["new"] = "새로운 프로필"
|
||||
L["new_sub"] = "새로운 프로필을 만듭니다."
|
||||
L["choose"] = "프로필 선택"
|
||||
L["choose_sub"] = "당신이 현재 이용할수 있는 프로필을 선택합니다."
|
||||
L["copy_desc"] = "현재 사용중인 프로필에, 선택한 프로필의 설정을 복사합니다."
|
||||
L["copy"] = "복사"
|
||||
L["delete_desc"] = "데이터베이스에 사용중이거나 저장된 프로파일 삭제로 SavedVariables 파일의 정리와 공간 절약이 됩니다."
|
||||
L["delete"] = "프로필 삭제"
|
||||
L["delete_sub"] = "데이터베이스의 프로필을 삭제합니다."
|
||||
L["delete_confirm"] = "정말로 선택한 프로필의 삭제를 원하십니까?"
|
||||
L["delete_confirm"] = "선택한 프로필을 삭제하시겠습니까?"
|
||||
L["delete_desc"] = "데이터베이스에서 기존 프로필과 사용하지 않는 프로필을 삭제하여 공간을 절약하고 SavedVariables 파일을 정리합니다."
|
||||
L["delete_sub"] = "데이터베이스에서 프로필을 삭제합니다."
|
||||
L["intro"] = "활성 데이터베이스 프로필을 변경할 수 있으며, 모든 캐릭터마다 서로 다른 설정을 지정할 수 있습니다."
|
||||
L["new"] = "새로운 프로필"
|
||||
L["new_sub"] = "비어 있는 프로필을 새로 만듭니다."
|
||||
L["profiles"] = "프로필"
|
||||
L["profiles_sub"] = "프로필 설정"
|
||||
--L["current"] = "Current Profile:"
|
||||
L["profiles_sub"] = "프로필 관리"
|
||||
L["reset"] = "프로필 재설정"
|
||||
L["reset_desc"] = "구성이 손상되었거나 처음부터 다시 시작하고 싶은 경우 현재 프로필을 기본값으로 재설정하세요."
|
||||
L["reset_sub"] = "현재 프로필을 기본값으로 재설정합니다"
|
||||
elseif LOCALE == "esES" or LOCALE == "esMX" then
|
||||
L["default"] = "Por defecto"
|
||||
L["intro"] = "Puedes cambiar el perfil activo de tal manera que cada personaje tenga diferentes configuraciones."
|
||||
L["reset_desc"] = "Reinicia el perfil actual a los valores por defectos, en caso de que se haya estropeado la configuración o quieras volver a empezar de nuevo."
|
||||
L["reset"] = "Reiniciar Perfil"
|
||||
L["reset_sub"] = "Reinicar el perfil actual al de por defecto"
|
||||
L["choose"] = "Perfiles existentes"
|
||||
L["choose_desc"] = "Puedes crear un nuevo perfil introduciendo un nombre en el recuadro o puedes seleccionar un perfil de los ya existentes."
|
||||
L["choose_sub"] = "Selecciona uno de los perfiles disponibles."
|
||||
L["copy"] = "Copiar de"
|
||||
L["copy_desc"] = "Copia los ajustes de un perfil existente al perfil actual."
|
||||
L["current"] = "Perfil actual:"
|
||||
L["default"] = "Por defecto"
|
||||
L["delete"] = "Borrar un Perfil"
|
||||
L["delete_confirm"] = "¿Estas seguro que quieres borrar el perfil seleccionado?"
|
||||
L["delete_desc"] = "Borra los perfiles existentes y sin uso de la base de datos para ganar espacio y limpiar el archivo SavedVariables."
|
||||
L["delete_sub"] = "Borra un perfil de la base de datos."
|
||||
L["intro"] = "Puedes cambiar el perfil activo de tal manera que cada personaje tenga diferentes configuraciones."
|
||||
L["new"] = "Nuevo"
|
||||
L["new_sub"] = "Crear un nuevo perfil vacio."
|
||||
L["choose"] = "Perfiles existentes"
|
||||
L["choose_sub"] = "Selecciona uno de los perfiles disponibles."
|
||||
L["copy_desc"] = "Copia los ajustes de un perfil existente al perfil actual."
|
||||
L["copy"] = "Copiar de"
|
||||
L["delete_desc"] = "Borra los perfiles existentes y sin uso de la base de datos para ganar espacio y limpiar el archivo SavedVariables."
|
||||
L["delete"] = "Borrar un Perfil"
|
||||
L["delete_sub"] = "Borra un perfil de la base de datos."
|
||||
L["delete_confirm"] = "¿Estas seguro que quieres borrar el perfil seleccionado?"
|
||||
L["profiles"] = "Perfiles"
|
||||
L["profiles_sub"] = "Manejar Perfiles"
|
||||
--L["current"] = "Current Profile:"
|
||||
L["reset"] = "Reiniciar Perfil"
|
||||
L["reset_desc"] = "Reinicia el perfil actual a los valores por defectos, en caso de que se haya estropeado la configuración o quieras volver a empezar de nuevo."
|
||||
L["reset_sub"] = "Reinicar el perfil actual al de por defecto"
|
||||
elseif LOCALE == "zhTW" then
|
||||
L["choose"] = "現有的設定檔"
|
||||
L["choose_desc"] = "您可以在文字方塊內輸入名字以建立新的設定檔,或是選擇一個現有的設定檔使用。"
|
||||
L["choose_sub"] = "從當前可用的設定檔裡面選擇一個。"
|
||||
L["copy"] = "複製自"
|
||||
L["copy_desc"] = "從一個現有的設定檔,將設定複製到現在使用中的設定檔。"
|
||||
L["current"] = "目前設定檔:"
|
||||
L["default"] = "預設"
|
||||
L["intro"] = "你可以選擇一個活動的資料設定檔,這樣你的每個角色就可以擁有不同的設定值,可以給你的插件設定帶來極大的靈活性。"
|
||||
L["reset_desc"] = "將當前的設定檔恢復到它的預設值,用於你的設定檔損壞,或者你只是想重來的情況。"
|
||||
L["reset"] = "重置設定檔"
|
||||
L["reset_sub"] = "將當前的設定檔恢復為預設值"
|
||||
L["choose_desc"] = "你可以通過在文本框內輸入一個名字創立一個新的設定檔,也可以選擇一個已經存在的設定檔。"
|
||||
L["delete"] = "刪除一個設定檔"
|
||||
L["delete_confirm"] = "確定要刪除所選擇的設定檔嗎?"
|
||||
L["delete_desc"] = "從資料庫裡刪除不再使用的設定檔,以節省空間,並且清理 SavedVariables 檔案。"
|
||||
L["delete_sub"] = "從資料庫裡刪除一個設定檔。"
|
||||
L["intro"] = "您可以從資料庫中選擇一個設定檔來使用,如此就可以讓每個角色使用不同的設定。"
|
||||
L["new"] = "新建"
|
||||
L["new_sub"] = "新建一個空的設定檔。"
|
||||
L["choose"] = "現有的設定檔"
|
||||
L["choose_sub"] = "從當前可用的設定檔裏面選擇一個。"
|
||||
L["copy_desc"] = "從當前某個已保存的設定檔複製到當前正使用的設定檔。"
|
||||
L["copy"] = "複製自"
|
||||
L["delete_desc"] = "從資料庫裏刪除不再使用的設定檔,以節省空間,並且清理SavedVariables檔。"
|
||||
L["delete"] = "刪除一個設定檔"
|
||||
L["delete_sub"] = "從資料庫裏刪除一個設定檔。"
|
||||
L["delete_confirm"] = "你確定要刪除所選擇的設定檔嗎?"
|
||||
L["profiles"] = "設定檔"
|
||||
L["profiles_sub"] = "管理設定檔"
|
||||
--L["current"] = "Current Profile:"
|
||||
L["reset"] = "重置設定檔"
|
||||
L["reset_desc"] = "將現用的設定檔重置為預設值;用於設定檔損壞,或者單純想要重來的情況。"
|
||||
L["reset_sub"] = "將目前的設定檔重置為預設值"
|
||||
elseif LOCALE == "zhCN" then
|
||||
L["default"] = "默认"
|
||||
L["intro"] = "你可以选择一个活动的数据配置文件,这样你的每个角色就可以拥有不同的设置值,可以给你的插件配置带来极大的灵活性。"
|
||||
L["reset_desc"] = "将当前的配置文件恢复到它的默认值,用于你的配置文件损坏,或者你只是想重来的情况。"
|
||||
L["reset"] = "重置配置文件"
|
||||
L["reset_sub"] = "将当前的配置文件恢复为默认值"
|
||||
L["choose"] = "现有的配置文件"
|
||||
L["choose_desc"] = "你可以通过在文本框内输入一个名字创立一个新的配置文件,也可以选择一个已经存在的配置文件。"
|
||||
L["choose_sub"] = "从当前可用的配置文件里面选择一个。"
|
||||
L["copy"] = "复制自"
|
||||
L["copy_desc"] = "从当前某个已保存的配置文件复制到当前正使用的配置文件。"
|
||||
L["current"] = "当前配置文件:"
|
||||
L["default"] = "默认"
|
||||
L["delete"] = "删除一个配置文件"
|
||||
L["delete_confirm"] = "你确定要删除所选择的配置文件么?"
|
||||
L["delete_desc"] = "从数据库里删除不再使用的配置文件,以节省空间,并且清理SavedVariables文件。"
|
||||
L["delete_sub"] = "从数据库里删除一个配置文件。"
|
||||
L["intro"] = "你可以选择一个活动的数据配置文件,这样你的每个角色就可以拥有不同的设置值,可以给你的插件配置带来极大的灵活性。"
|
||||
L["new"] = "新建"
|
||||
L["new_sub"] = "新建一个空的配置文件。"
|
||||
L["choose"] = "现有的配置文件"
|
||||
L["choose_sub"] = "从当前可用的配置文件里面选择一个。"
|
||||
L["copy_desc"] = "从当前某个已保存的配置文件复制到当前正使用的配置文件。"
|
||||
L["copy"] = "复制自"
|
||||
L["delete_desc"] = "从数据库里删除不再使用的配置文件,以节省空间,并且清理SavedVariables文件。"
|
||||
L["delete"] = "删除一个配置文件"
|
||||
L["delete_sub"] = "从数据库里删除一个配置文件。"
|
||||
L["delete_confirm"] = "你确定要删除所选择的配置文件么?"
|
||||
L["profiles"] = "配置文件"
|
||||
L["profiles_sub"] = "管理配置文件"
|
||||
--L["current"] = "Current Profile:"
|
||||
L["reset"] = "重置配置文件"
|
||||
L["reset_desc"] = "将当前的配置文件恢复到它的默认值,用于你的配置文件损坏,或者你只是想重来的情况。"
|
||||
L["reset_sub"] = "将当前的配置文件恢复为默认值"
|
||||
elseif LOCALE == "ruRU" then
|
||||
L["default"] = "По умолчанию"
|
||||
L["intro"] = "Изменяя активный профиль, вы можете задать различные настройки модификаций для каждого персонажа."
|
||||
L["reset_desc"] = "Если ваша конфигурации испорчена или если вы хотите настроить всё заново - сбросьте текущий профиль на стандартные значения."
|
||||
L["reset"] = "Сброс профиля"
|
||||
L["reset_sub"] = "Сброс текущего профиля на стандартный"
|
||||
L["choose_desc"] = "Вы можете создать новый профиль, введя название в поле ввода, или выбрать один из уже существующих профилей."
|
||||
L["new"] = "Новый"
|
||||
L["new_sub"] = "Создать новый чистый профиль"
|
||||
L["choose"] = "Существующие профили"
|
||||
L["choose_sub"] = "Выбор одиного из уже доступных профилей"
|
||||
L["copy_desc"] = "Скопировать настройки из выбранного профиля в активный."
|
||||
L["choose_desc"] = "Вы можете создать новый профиль, введя название в поле ввода, или выбрать один из уже существующих профилей."
|
||||
L["choose_sub"] = "Выбор одного из уже доступных профилей."
|
||||
L["copy"] = "Скопировать из"
|
||||
L["delete_desc"] = "Удалить существующий и неиспользуемый профиль из БД для сохранения места, и очистить SavedVariables файл."
|
||||
L["copy_desc"] = "Копирование настроек из выбранного профиля в активный."
|
||||
L["current"] = "Текущий профиль:"
|
||||
L["default"] = "По умолчанию"
|
||||
L["delete"] = "Удалить профиль"
|
||||
L["delete_sub"] = "Удаление профиля из БД"
|
||||
L["delete_confirm"] = "Вы уверены, что вы хотите удалить выбранный профиль?"
|
||||
L["delete_confirm"] = "Вы уверены, что хотите удалить выбранный профиль?"
|
||||
L["delete_desc"] = "Удаление существующего и неиспользуемого профиля из базы данных для сохранения места, и очистка файла SavedVariables."
|
||||
L["delete_sub"] = "Удаление профиля из базы данных."
|
||||
L["intro"] = "Изменяя активный профиль, Вы можете задать разные настройки для каждого персонажа."
|
||||
L["new"] = "Новый"
|
||||
L["new_sub"] = "Создание нового чистого профиля."
|
||||
L["profiles"] = "Профили"
|
||||
L["profiles_sub"] = "Управление профилями"
|
||||
--L["current"] = "Current Profile:"
|
||||
L["reset"] = "Сбросить профиль"
|
||||
L["reset_desc"] = "Сброс текущего профиля к стандартным настройкам, если Ваша конфигурация испорчена или Вы хотите настроить все заново."
|
||||
L["reset_sub"] = "Сброс текущего профиля на стандартный"
|
||||
elseif LOCALE == "itIT" then
|
||||
L["choose"] = "Profili Esistenti"
|
||||
L["choose_desc"] = "Puoi creare un nuovo profilo digitando il nome della casella di testo, oppure scegliendone uno tra i profili già esistenti."
|
||||
L["choose_sub"] = "Seleziona uno dei profili attualmente disponibili."
|
||||
L["copy"] = "Copia Da"
|
||||
L["copy_desc"] = "Copia le impostazioni da un profilo esistente nel profilo attivo in questo momento."
|
||||
L["current"] = "Profilo Attivo:"
|
||||
L["default"] = "Predefinito"
|
||||
L["delete"] = "Cancella un Profilo"
|
||||
L["delete_confirm"] = "Sei sicuro di voler cancellare il profilo selezionato?"
|
||||
L["delete_desc"] = "Cancella i profili non utilizzati dal database per risparmiare spazio e mantenere puliti i file di configurazione SavedVariables."
|
||||
L["delete_sub"] = "Cancella un profilo dal Database."
|
||||
L["intro"] = "Puoi cambiare il profilo attivo, in modo da usare impostazioni diverse per ogni personaggio."
|
||||
L["new"] = "Nuovo"
|
||||
L["new_sub"] = "Crea un nuovo profilo vuoto."
|
||||
L["profiles"] = "Profili"
|
||||
L["profiles_sub"] = "Gestisci Profili"
|
||||
L["reset"] = "Reimposta Profilo"
|
||||
L["reset_desc"] = "Riporta il tuo profilo attivo alle sue impostazioni predefinite, nel caso in cui la tua configurazione si sia corrotta, o semplicemente tu voglia re-inizializzarla."
|
||||
L["reset_sub"] = "Reimposta il profilo ai suoi valori predefiniti."
|
||||
elseif LOCALE == "ptBR" then
|
||||
L["choose"] = "Perfis Existentes"
|
||||
L["choose_desc"] = "Você pode tanto criar um perfil novo tanto digitando um nome na caixa de texto, quanto escolher um dos perfis já existentes."
|
||||
L["choose_sub"] = "Selecione um de seus perfis atualmente disponíveis."
|
||||
L["copy"] = "Copiar De"
|
||||
L["copy_desc"] = "Copia as definições de um perfil existente no perfil atualmente ativo."
|
||||
L["current"] = "Perfil Autal:"
|
||||
L["default"] = "Padrão"
|
||||
L["delete"] = "Remover um Perfil"
|
||||
L["delete_confirm"] = "Tem certeza que deseja remover o perfil selecionado?"
|
||||
L["delete_desc"] = "Remove perfis existentes e inutilizados do banco de dados para economizar espaço, e limpar o arquivo SavedVariables."
|
||||
L["delete_sub"] = "Remove um perfil do banco de dados."
|
||||
L["intro"] = "Você pode alterar o perfil do banco de dados ativo, para que possa ter definições diferentes para cada personagem."
|
||||
L["new"] = "Novo"
|
||||
L["new_sub"] = "Cria um novo perfil vazio."
|
||||
L["profiles"] = "Perfis"
|
||||
L["profiles_sub"] = "Gerenciar Perfis"
|
||||
L["reset"] = "Resetar Perfil"
|
||||
L["reset_desc"] = "Reseta o perfil atual para os valores padrões, no caso de sua configuração estar quebrada, ou simplesmente se deseja começar novamente."
|
||||
L["reset_sub"] = "Resetar o perfil atual ao padrão"
|
||||
end
|
||||
|
||||
local defaultProfiles
|
||||
|
||||
@@ -24,33 +24,28 @@
|
||||
-- f:AddChild(btn)
|
||||
-- @class file
|
||||
-- @name AceGUI-3.0
|
||||
-- @release $Id: AceGUI-3.0.lua 924 2010-05-13 15:12:20Z nevcairiel $
|
||||
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 33
|
||||
-- @release $Id$
|
||||
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 41
|
||||
local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR)
|
||||
|
||||
if not AceGUI then return end -- No upgrade needed
|
||||
|
||||
-- Lua APIs
|
||||
local tconcat, tremove, tinsert = table.concat, table.remove, table.insert
|
||||
local tinsert, wipe = table.insert, table.wipe
|
||||
local select, pairs, next, type = select, pairs, next, type
|
||||
local error, assert, loadstring = error, assert, loadstring
|
||||
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
|
||||
local math_max = math.max
|
||||
local error, assert = error, assert
|
||||
local setmetatable, rawget = setmetatable, rawget
|
||||
local math_max, math_min, math_ceil = math.max, math.min, math.ceil
|
||||
|
||||
-- WoW APIs
|
||||
local UIParent = UIParent
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: geterrorhandler, LibStub
|
||||
|
||||
--local con = LibStub("AceConsole-3.0",true)
|
||||
|
||||
AceGUI.WidgetRegistry = AceGUI.WidgetRegistry or {}
|
||||
AceGUI.LayoutRegistry = AceGUI.LayoutRegistry or {}
|
||||
AceGUI.WidgetBase = AceGUI.WidgetBase or {}
|
||||
AceGUI.WidgetContainerBase = AceGUI.WidgetContainerBase or {}
|
||||
AceGUI.WidgetVersions = AceGUI.WidgetVersions or {}
|
||||
AceGUI.tooltip = AceGUI.tooltip or CreateFrame("GameTooltip", "AceGUITooltip", UIParent, "GameTooltipTemplate")
|
||||
|
||||
-- local upvalues
|
||||
local WidgetRegistry = AceGUI.WidgetRegistry
|
||||
@@ -66,39 +61,10 @@ local function errorhandler(err)
|
||||
return geterrorhandler()(err)
|
||||
end
|
||||
|
||||
local function CreateDispatcher(argCount)
|
||||
local code = [[
|
||||
local xpcall, eh = ...
|
||||
local method, ARGS
|
||||
local function call() return method(ARGS) end
|
||||
|
||||
local function dispatch(func, ...)
|
||||
method = func
|
||||
if not method then return end
|
||||
ARGS = ...
|
||||
return xpcall(call, eh)
|
||||
end
|
||||
|
||||
return dispatch
|
||||
]]
|
||||
|
||||
local ARGS = {}
|
||||
for i = 1, argCount do ARGS[i] = "arg"..i end
|
||||
code = code:gsub("ARGS", tconcat(ARGS, ", "))
|
||||
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
|
||||
end
|
||||
|
||||
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
|
||||
local dispatcher = CreateDispatcher(argCount)
|
||||
rawset(self, argCount, dispatcher)
|
||||
return dispatcher
|
||||
end})
|
||||
Dispatchers[0] = function(func)
|
||||
return xpcall(func, errorhandler)
|
||||
end
|
||||
|
||||
local function safecall(func, ...)
|
||||
return Dispatchers[select("#", ...)](func, ...)
|
||||
if func then
|
||||
return xpcall(func, errorhandler, ...)
|
||||
end
|
||||
end
|
||||
|
||||
-- Recycling functions
|
||||
@@ -122,38 +88,38 @@ do
|
||||
AceGUI.objPools = AceGUI.objPools or {}
|
||||
local objPools = AceGUI.objPools
|
||||
--Returns a new instance, if none are available either returns a new table or calls the given contructor
|
||||
function newWidget(type)
|
||||
if not WidgetRegistry[type] then
|
||||
function newWidget(widgetType)
|
||||
if not WidgetRegistry[widgetType] then
|
||||
error("Attempt to instantiate unknown widget type", 2)
|
||||
end
|
||||
|
||||
if not objPools[type] then
|
||||
objPools[type] = {}
|
||||
if not objPools[widgetType] then
|
||||
objPools[widgetType] = {}
|
||||
end
|
||||
|
||||
local newObj = next(objPools[type])
|
||||
local newObj = next(objPools[widgetType])
|
||||
if not newObj then
|
||||
newObj = WidgetRegistry[type]()
|
||||
newObj.AceGUIWidgetVersion = WidgetVersions[type]
|
||||
newObj = WidgetRegistry[widgetType]()
|
||||
newObj.AceGUIWidgetVersion = WidgetVersions[widgetType]
|
||||
else
|
||||
objPools[type][newObj] = nil
|
||||
objPools[widgetType][newObj] = nil
|
||||
-- if the widget is older then the latest, don't even try to reuse it
|
||||
-- just forget about it, and grab a new one.
|
||||
if not newObj.AceGUIWidgetVersion or newObj.AceGUIWidgetVersion < WidgetVersions[type] then
|
||||
return newWidget(type)
|
||||
if not newObj.AceGUIWidgetVersion or newObj.AceGUIWidgetVersion < WidgetVersions[widgetType] then
|
||||
return newWidget(widgetType)
|
||||
end
|
||||
end
|
||||
return newObj
|
||||
end
|
||||
-- Releases an instance to the Pool
|
||||
function delWidget(obj,type)
|
||||
if not objPools[type] then
|
||||
objPools[type] = {}
|
||||
function delWidget(obj,widgetType)
|
||||
if not objPools[widgetType] then
|
||||
objPools[widgetType] = {}
|
||||
end
|
||||
if objPools[type][obj] then
|
||||
if objPools[widgetType][obj] then
|
||||
error("Attempt to Release Widget that is already released", 2)
|
||||
end
|
||||
objPools[type][obj] = true
|
||||
objPools[widgetType][obj] = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -169,9 +135,9 @@ end
|
||||
-- OnAcquire function on it, before returning.
|
||||
-- @param type The type of the widget.
|
||||
-- @return The newly created widget.
|
||||
function AceGUI:Create(type)
|
||||
if WidgetRegistry[type] then
|
||||
local widget = newWidget(type)
|
||||
function AceGUI:Create(widgetType)
|
||||
if WidgetRegistry[widgetType] then
|
||||
local widget = newWidget(widgetType)
|
||||
|
||||
if rawget(widget, "Acquire") then
|
||||
widget.OnAcquire = widget.Acquire
|
||||
@@ -189,7 +155,7 @@ function AceGUI:Create(type)
|
||||
if widget.OnAcquire then
|
||||
widget:OnAcquire()
|
||||
else
|
||||
error(("Widget type %s doesn't supply an OnAcquire Function"):format(type))
|
||||
error(("Widget type %s doesn't supply an OnAcquire Function"):format(widgetType))
|
||||
end
|
||||
-- Set the default Layout ("List")
|
||||
safecall(widget.SetLayout, widget, "List")
|
||||
@@ -204,7 +170,10 @@ end
|
||||
-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well.
|
||||
-- @param widget The widget to release
|
||||
function AceGUI:Release(widget)
|
||||
if widget.isQueuedForRelease then return end
|
||||
widget.isQueuedForRelease = true
|
||||
safecall(widget.PauseLayout, widget)
|
||||
widget.frame:Hide()
|
||||
widget:Fire("OnRelease")
|
||||
safecall(widget.ReleaseChildren, widget)
|
||||
|
||||
@@ -233,9 +202,26 @@ function AceGUI:Release(widget)
|
||||
widget.content.width = nil
|
||||
widget.content.height = nil
|
||||
end
|
||||
widget.isQueuedForRelease = nil
|
||||
delWidget(widget, widget.type)
|
||||
end
|
||||
|
||||
--- Check if a widget is currently in the process of being released
|
||||
-- This function check if this widget, or any of its parents (in which case it'll be released shortly as well)
|
||||
-- are currently being released. This allows addon to handle any callbacks accordingly.
|
||||
-- @param widget The widget to check
|
||||
function AceGUI:IsReleasing(widget)
|
||||
if widget.isQueuedForRelease then
|
||||
return true
|
||||
end
|
||||
|
||||
if widget.parent and widget.parent.AceGUIWidgetVersion then
|
||||
return AceGUI:IsReleasing(widget.parent)
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-----------
|
||||
-- Focus --
|
||||
-----------
|
||||
@@ -362,6 +348,10 @@ do
|
||||
AceGUI:Release(self)
|
||||
end
|
||||
|
||||
WidgetBase.IsReleasing = function(self)
|
||||
return AceGUI:IsReleasing(self)
|
||||
end
|
||||
|
||||
WidgetBase.SetPoint = function(self, ...)
|
||||
return self.frame:SetPoint(...)
|
||||
end
|
||||
@@ -593,25 +583,25 @@ AceGUI.counts = AceGUI.counts or {}
|
||||
-- This is used by widgets that require a named frame, e.g. when a Blizzard
|
||||
-- Template requires it.
|
||||
-- @param type The widget type
|
||||
function AceGUI:GetNextWidgetNum(type)
|
||||
if not self.counts[type] then
|
||||
self.counts[type] = 0
|
||||
function AceGUI:GetNextWidgetNum(widgetType)
|
||||
if not self.counts[widgetType] then
|
||||
self.counts[widgetType] = 0
|
||||
end
|
||||
self.counts[type] = self.counts[type] + 1
|
||||
return self.counts[type]
|
||||
self.counts[widgetType] = self.counts[widgetType] + 1
|
||||
return self.counts[widgetType]
|
||||
end
|
||||
|
||||
--- Return the number of created widgets for this type.
|
||||
-- In contrast to GetNextWidgetNum, the number is not incremented.
|
||||
-- @param type The widget type
|
||||
function AceGUI:GetWidgetCount(type)
|
||||
return self.counts[type] or 0
|
||||
-- @param widgetType The widget type
|
||||
function AceGUI:GetWidgetCount(widgetType)
|
||||
return self.counts[widgetType] or 0
|
||||
end
|
||||
|
||||
--- Return the version of the currently registered widget type.
|
||||
-- @param type The widget type
|
||||
function AceGUI:GetWidgetVersion(type)
|
||||
return WidgetVersions[type]
|
||||
-- @param widgetType The widget type
|
||||
function AceGUI:GetWidgetVersion(widgetType)
|
||||
return WidgetVersions[widgetType]
|
||||
end
|
||||
|
||||
-------------
|
||||
@@ -667,14 +657,23 @@ AceGUI:RegisterLayout("Fill",
|
||||
if children[1] then
|
||||
children[1]:SetWidth(content:GetWidth() or 0)
|
||||
children[1]:SetHeight(content:GetHeight() or 0)
|
||||
children[1].frame:ClearAllPoints()
|
||||
children[1].frame:SetAllPoints(content)
|
||||
children[1].frame:Show()
|
||||
safecall(content.obj.LayoutFinished, content.obj, nil, children[1].frame:GetHeight())
|
||||
end
|
||||
end)
|
||||
|
||||
local layoutrecursionblock = nil
|
||||
local function safelayoutcall(object, func, ...)
|
||||
layoutrecursionblock = true
|
||||
object[func](object, ...)
|
||||
layoutrecursionblock = nil
|
||||
end
|
||||
|
||||
AceGUI:RegisterLayout("Flow",
|
||||
function(content, children)
|
||||
if layoutrecursionblock then return end
|
||||
--used height so far
|
||||
local height = 0
|
||||
--width used in the current row
|
||||
@@ -682,14 +681,12 @@ AceGUI:RegisterLayout("Flow",
|
||||
--height of the current row
|
||||
local rowheight = 0
|
||||
local rowoffset = 0
|
||||
local lastrowoffset
|
||||
|
||||
local width = content.width or content:GetWidth() or 0
|
||||
|
||||
--control at the start of the row
|
||||
local rowstart
|
||||
local rowstartoffset
|
||||
local lastrowstart
|
||||
local isfullheight
|
||||
|
||||
local frameoffset
|
||||
@@ -762,12 +759,11 @@ AceGUI:RegisterLayout("Flow",
|
||||
end
|
||||
|
||||
if child.width == "fill" then
|
||||
child:SetWidth(width)
|
||||
safelayoutcall(child, "SetWidth", width)
|
||||
frame:SetPoint("RIGHT", content)
|
||||
|
||||
usedwidth = 0
|
||||
rowstart = frame
|
||||
rowstartoffset = frameoffset
|
||||
|
||||
if child.DoLayout then
|
||||
child:DoLayout()
|
||||
@@ -776,7 +772,7 @@ AceGUI:RegisterLayout("Flow",
|
||||
rowoffset = child.alignoffset or (rowheight / 2)
|
||||
rowstartoffset = rowoffset
|
||||
elseif child.width == "relative" then
|
||||
child:SetWidth(width * child.relWidth)
|
||||
safelayoutcall(child, "SetWidth", width * child.relWidth)
|
||||
|
||||
if child.DoLayout then
|
||||
child:DoLayout()
|
||||
@@ -803,3 +799,222 @@ AceGUI:RegisterLayout("Flow",
|
||||
height = height + rowheight + 3
|
||||
safecall(content.obj.LayoutFinished, content.obj, nil, height)
|
||||
end)
|
||||
|
||||
-- Get alignment method and value. Possible alignment methods are a callback, a number, "start", "middle", "end", "fill" or "TOPLEFT", "BOTTOMRIGHT" etc.
|
||||
local GetCellAlign = function (dir, tableObj, colObj, cellObj, cell, child)
|
||||
local fn = cellObj and (cellObj["align" .. dir] or cellObj.align)
|
||||
or colObj and (colObj["align" .. dir] or colObj.align)
|
||||
or tableObj["align" .. dir] or tableObj.align
|
||||
or "CENTERLEFT"
|
||||
local val
|
||||
child, cell = child or 0, cell or 0
|
||||
|
||||
if type(fn) == "string" then
|
||||
fn = fn:lower()
|
||||
fn = dir == "V" and (fn:sub(1, 3) == "top" and "start" or fn:sub(1, 6) == "bottom" and "end" or fn:sub(1, 6) == "center" and "middle")
|
||||
or dir == "H" and (fn:sub(-4) == "left" and "start" or fn:sub(-5) == "right" and "end" or fn:sub(-6) == "center" and "middle")
|
||||
or fn
|
||||
val = (fn == "start" or fn == "fill") and 0 or fn == "end" and cell - child or (cell - child) / 2
|
||||
elseif type(fn) == "function" then
|
||||
val = fn(child or 0, cell, dir)
|
||||
else
|
||||
val = fn
|
||||
end
|
||||
|
||||
return fn, math_max(0, math_min(val, cell))
|
||||
end
|
||||
|
||||
-- Get width or height for multiple cells combined
|
||||
local GetCellDimension = function (dir, laneDim, from, to, space)
|
||||
local dim = 0
|
||||
for cell=from,to do
|
||||
dim = dim + (laneDim[cell] or 0)
|
||||
end
|
||||
return dim + math_max(0, to - from) * (space or 0)
|
||||
end
|
||||
|
||||
--[[ Options
|
||||
============
|
||||
Container:
|
||||
- columns ({col, col, ...}): Column settings. "col" can be a number (<= 0: content width, <1: rel. width, <10: weight, >=10: abs. width) or a table with column setting.
|
||||
- space, spaceH, spaceV: Overall, horizontal and vertical spacing between cells.
|
||||
- align, alignH, alignV: Overall, horizontal and vertical cell alignment. See GetCellAlign() for possible values.
|
||||
Columns:
|
||||
- width: Fixed column width (nil or <=0: content width, <1: rel. width, >=1: abs. width).
|
||||
- min or 1: Min width for content based width
|
||||
- max or 2: Max width for content based width
|
||||
- weight: Flexible column width. The leftover width after accounting for fixed-width columns is distributed to weighted columns according to their weights.
|
||||
- align, alignH, alignV: Overwrites the container setting for alignment.
|
||||
Cell:
|
||||
- colspan: Makes a cell span multiple columns.
|
||||
- rowspan: Makes a cell span multiple rows.
|
||||
- align, alignH, alignV: Overwrites the container and column setting for alignment.
|
||||
]]
|
||||
AceGUI:RegisterLayout("Table",
|
||||
function (content, children)
|
||||
local obj = content.obj
|
||||
obj:PauseLayout()
|
||||
|
||||
local tableObj = obj:GetUserData("table")
|
||||
local cols = tableObj.columns
|
||||
local spaceH = tableObj.spaceH or tableObj.space or 0
|
||||
local spaceV = tableObj.spaceV or tableObj.space or 0
|
||||
local totalH = (content:GetWidth() or content.width or 0) - spaceH * (#cols - 1)
|
||||
|
||||
-- We need to reuse these because layout events can come in very frequently
|
||||
local layoutCache = obj:GetUserData("layoutCache")
|
||||
if not layoutCache then
|
||||
layoutCache = {{}, {}, {}, {}, {}, {}}
|
||||
obj:SetUserData("layoutCache", layoutCache)
|
||||
end
|
||||
local t, laneH, laneV, rowspans, rowStart, colStart = unpack(layoutCache)
|
||||
|
||||
-- Create the grid
|
||||
local n, slotFound = 0
|
||||
for i,child in ipairs(children) do
|
||||
if child:IsShown() then
|
||||
repeat
|
||||
n = n + 1
|
||||
local col = (n - 1) % #cols + 1
|
||||
local row = math_ceil(n / #cols)
|
||||
local rowspan = rowspans[col]
|
||||
local cell = rowspan and rowspan.child or child
|
||||
local cellObj = cell:GetUserData("cell")
|
||||
slotFound = not rowspan
|
||||
|
||||
-- Rowspan
|
||||
if not rowspan and cellObj and cellObj.rowspan then
|
||||
rowspan = {child = child, from = row, to = row + cellObj.rowspan - 1}
|
||||
rowspans[col] = rowspan
|
||||
end
|
||||
if rowspan and i == #children then
|
||||
rowspan.to = row
|
||||
end
|
||||
|
||||
-- Colspan
|
||||
local colspan = math_max(0, math_min((cellObj and cellObj.colspan or 1) - 1, #cols - col))
|
||||
n = n + colspan
|
||||
|
||||
-- Place the cell
|
||||
if not rowspan or rowspan.to == row then
|
||||
t[n] = cell
|
||||
rowStart[cell] = rowspan and rowspan.from or row
|
||||
colStart[cell] = col
|
||||
|
||||
if rowspan then
|
||||
rowspans[col] = nil
|
||||
end
|
||||
end
|
||||
until slotFound
|
||||
end
|
||||
end
|
||||
|
||||
local rows = math_ceil(n / #cols)
|
||||
|
||||
-- Determine fixed size cols and collect weights
|
||||
local extantH, totalWeight = totalH, 0
|
||||
for col,colObj in ipairs(cols) do
|
||||
laneH[col] = 0
|
||||
|
||||
if type(colObj) == "number" then
|
||||
colObj = {[colObj >= 1 and colObj < 10 and "weight" or "width"] = colObj}
|
||||
cols[col] = colObj
|
||||
end
|
||||
|
||||
if colObj.weight then
|
||||
-- Weight
|
||||
totalWeight = totalWeight + (colObj.weight or 1)
|
||||
else
|
||||
if not colObj.width or colObj.width <= 0 then
|
||||
-- Content width
|
||||
for row=1,rows do
|
||||
local child = t[(row - 1) * #cols + col]
|
||||
if child then
|
||||
local f = child.frame
|
||||
f:ClearAllPoints()
|
||||
local childH = f:GetWidth() or 0
|
||||
|
||||
laneH[col] = math_max(laneH[col], childH - GetCellDimension("H", laneH, colStart[child], col - 1, spaceH))
|
||||
end
|
||||
end
|
||||
|
||||
laneH[col] = math_max(colObj.min or colObj[1] or 0, math_min(laneH[col], colObj.max or colObj[2] or laneH[col]))
|
||||
else
|
||||
-- Rel./Abs. width
|
||||
laneH[col] = colObj.width < 1 and colObj.width * totalH or colObj.width
|
||||
end
|
||||
extantH = math_max(0, extantH - laneH[col])
|
||||
end
|
||||
end
|
||||
|
||||
-- Determine sizes based on weight
|
||||
local scale = totalWeight > 0 and extantH / totalWeight or 0
|
||||
for col,colObj in pairs(cols) do
|
||||
if colObj.weight then
|
||||
laneH[col] = scale * colObj.weight
|
||||
end
|
||||
end
|
||||
|
||||
-- Arrange children
|
||||
for row=1,rows do
|
||||
local rowV = 0
|
||||
|
||||
-- Horizontal placement and sizing
|
||||
for col=1,#cols do
|
||||
local child = t[(row - 1) * #cols + col]
|
||||
if child then
|
||||
local colObj = cols[colStart[child]]
|
||||
local cellObj = child:GetUserData("cell")
|
||||
local offsetH = GetCellDimension("H", laneH, 1, colStart[child] - 1, spaceH) + (colStart[child] == 1 and 0 or spaceH)
|
||||
local cellH = GetCellDimension("H", laneH, colStart[child], col, spaceH)
|
||||
|
||||
local f = child.frame
|
||||
f:ClearAllPoints()
|
||||
local childH = f:GetWidth() or 0
|
||||
|
||||
local alignFn, align = GetCellAlign("H", tableObj, colObj, cellObj, cellH, childH)
|
||||
f:SetPoint("LEFT", content, offsetH + align, 0)
|
||||
if child:IsFullWidth() or alignFn == "fill" or childH > cellH then
|
||||
f:SetPoint("RIGHT", content, "LEFT", offsetH + align + cellH, 0)
|
||||
end
|
||||
|
||||
if child.DoLayout then
|
||||
child:DoLayout()
|
||||
end
|
||||
|
||||
rowV = math_max(rowV, (f:GetHeight() or 0) - GetCellDimension("V", laneV, rowStart[child], row - 1, spaceV))
|
||||
end
|
||||
end
|
||||
|
||||
laneV[row] = rowV
|
||||
|
||||
-- Vertical placement and sizing
|
||||
for col=1,#cols do
|
||||
local child = t[(row - 1) * #cols + col]
|
||||
if child then
|
||||
local colObj = cols[colStart[child]]
|
||||
local cellObj = child:GetUserData("cell")
|
||||
local offsetV = GetCellDimension("V", laneV, 1, rowStart[child] - 1, spaceV) + (rowStart[child] == 1 and 0 or spaceV)
|
||||
local cellV = GetCellDimension("V", laneV, rowStart[child], row, spaceV)
|
||||
|
||||
local f = child.frame
|
||||
local childV = f:GetHeight() or 0
|
||||
|
||||
local alignFn, align = GetCellAlign("V", tableObj, colObj, cellObj, cellV, childV)
|
||||
if child:IsFullHeight() or alignFn == "fill" then
|
||||
f:SetHeight(cellV)
|
||||
end
|
||||
f:SetPoint("TOP", content, 0, -(offsetV + align))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Calculate total height
|
||||
local totalV = GetCellDimension("V", laneV, 1, #laneV, spaceV)
|
||||
|
||||
-- Cleanup
|
||||
for _,v in pairs(layoutCache) do wipe(v) end
|
||||
|
||||
safecall(obj.LayoutFinished, obj, nil, totalV)
|
||||
obj:ResumeLayout()
|
||||
end)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
BlizOptionsGroup Container
|
||||
Simple container widget for the integration of AceGUI into the Blizzard Interface Options
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "BlizOptionsGroup", 20
|
||||
local Type, Version = "BlizOptionsGroup", 26
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
@@ -36,8 +36,12 @@ local function cancel(frame)
|
||||
frame.obj:Fire("cancel")
|
||||
end
|
||||
|
||||
local function defaults(frame)
|
||||
frame.obj:Fire("defaults")
|
||||
local function default(frame)
|
||||
frame.obj:Fire("default")
|
||||
end
|
||||
|
||||
local function refresh(frame)
|
||||
frame.obj:Fire("refresh")
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -95,13 +99,23 @@ local methods = {
|
||||
Constructor
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame")
|
||||
-- CoA-compat: InterfaceOptionsFramePanelContainer is a global from the stock 3.3.5
|
||||
-- Interface Options frame; on the CoA reworked FrameXML it can be nil at the time
|
||||
-- AceGUI widgets are constructed. Fall back to UIParent so CreateFrame doesn't blow up.
|
||||
local _parent = InterfaceOptionsFramePanelContainer or UIParent
|
||||
local frame = CreateFrame("Frame", nil, _parent)
|
||||
frame:Hide()
|
||||
|
||||
-- support functions for the Blizzard Interface Options
|
||||
frame.okay = okay
|
||||
frame.cancel = cancel
|
||||
frame.defaults = defaults
|
||||
frame.default = default
|
||||
frame.refresh = refresh
|
||||
|
||||
-- 10.0 support function aliases (cancel has been removed)
|
||||
frame.OnCommit = okay
|
||||
frame.OnDefault = default
|
||||
frame.OnRefresh = refresh
|
||||
|
||||
frame:SetScript("OnHide", OnHide)
|
||||
frame:SetScript("OnShow", OnShow)
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
--[[-----------------------------------------------------------------------------
|
||||
DropdownGroup Container
|
||||
Container controlled by a dropdown on the top.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "DropdownGroup", 22
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
-- Lua APIs
|
||||
local assert, pairs, type = assert, pairs, type
|
||||
@@ -6,83 +12,61 @@ local assert, pairs, type = assert, pairs, type
|
||||
-- WoW APIs
|
||||
local CreateFrame = CreateFrame
|
||||
|
||||
--[[
|
||||
Selection Group controls all have an interface to select a group for thier contents
|
||||
None of them will auto size to thier contents, and should usually be used with a scrollframe
|
||||
unless you know that the controls will fit inside
|
||||
]]
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function SelectedGroup(self, event, value)
|
||||
local group = self.parentgroup
|
||||
local status = group.status or group.localstatus
|
||||
status.selected = value
|
||||
self.parentgroup:Fire("OnGroupSelected", value)
|
||||
end
|
||||
|
||||
--------------------------
|
||||
-- Dropdown Group --
|
||||
--------------------------
|
||||
--[[
|
||||
Events :
|
||||
OnGroupSelected
|
||||
|
||||
]]
|
||||
do
|
||||
local Type = "DropdownGroup"
|
||||
local Version = 13
|
||||
|
||||
local function OnAcquire(self)
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Methods
|
||||
-------------------------------------------------------------------------------]]
|
||||
local methods = {
|
||||
["OnAcquire"] = function(self)
|
||||
self.dropdown:SetText("")
|
||||
self:SetDropdownWidth(200)
|
||||
self:SetTitle("")
|
||||
end
|
||||
end,
|
||||
|
||||
local function OnRelease(self)
|
||||
self.frame:ClearAllPoints()
|
||||
self.frame:Hide()
|
||||
["OnRelease"] = function(self)
|
||||
self.dropdown.list = nil
|
||||
self.status = nil
|
||||
for k in pairs(self.localstatus) do
|
||||
self.localstatus[k] = nil
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
local PaneBackdrop = {
|
||||
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||
tile = true, tileSize = 16, edgeSize = 16,
|
||||
insets = { left = 3, right = 3, top = 5, bottom = 3 }
|
||||
}
|
||||
|
||||
local function SetTitle(self,title)
|
||||
["SetTitle"] = function(self, title)
|
||||
self.titletext:SetText(title)
|
||||
self.dropdown.frame:ClearAllPoints()
|
||||
if title and title ~= "" then
|
||||
self.dropdown.frame:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -2, 0)
|
||||
self.dropdown.frame:SetPoint("TOPRIGHT", -2, 0)
|
||||
else
|
||||
self.dropdown.frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", -1, 0)
|
||||
self.dropdown.frame:SetPoint("TOPLEFT", -1, 0)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
["SetGroupList"] = function(self,list,order)
|
||||
self.dropdown:SetList(list,order)
|
||||
end,
|
||||
|
||||
local function SelectedGroup(self,event,value)
|
||||
local group = self.parentgroup
|
||||
local status = group.status or group.localstatus
|
||||
status.selected = value
|
||||
self.parentgroup:Fire("OnGroupSelected", value)
|
||||
end
|
||||
|
||||
local function SetGroupList(self,list)
|
||||
self.dropdown:SetList(list)
|
||||
end
|
||||
|
||||
-- called to set an external table to store status in
|
||||
local function SetStatusTable(self, status)
|
||||
["SetStatusTable"] = function(self, status)
|
||||
assert(type(status) == "table")
|
||||
self.status = status
|
||||
end
|
||||
end,
|
||||
|
||||
local function SetGroup(self,group)
|
||||
["SetGroup"] = function(self,group)
|
||||
self.dropdown:SetValue(group)
|
||||
local status = self.status or self.localstatus
|
||||
status.selected = group
|
||||
self:Fire("OnGroupSelected", group)
|
||||
end
|
||||
end,
|
||||
|
||||
local function OnWidthSet(self, width)
|
||||
["OnWidthSet"] = function(self, width)
|
||||
local content = self.content
|
||||
local contentwidth = width - 26
|
||||
if contentwidth < 0 then
|
||||
@@ -90,10 +74,9 @@ do
|
||||
end
|
||||
content:SetWidth(contentwidth)
|
||||
content.width = contentwidth
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
local function OnHeightSet(self, height)
|
||||
["OnHeightSet"] = function(self, height)
|
||||
local content = self.content
|
||||
local contentheight = height - 63
|
||||
if contentheight < 0 then
|
||||
@@ -101,78 +84,74 @@ do
|
||||
end
|
||||
content:SetHeight(contentheight)
|
||||
content.height = contentheight
|
||||
end
|
||||
end,
|
||||
|
||||
local function LayoutFinished(self, width, height)
|
||||
["LayoutFinished"] = function(self, width, height)
|
||||
self:SetHeight((height or 0) + 63)
|
||||
end
|
||||
end,
|
||||
|
||||
local function SetDropdownWidth(self, width)
|
||||
["SetDropdownWidth"] = function(self, width)
|
||||
self.dropdown:SetWidth(width)
|
||||
end
|
||||
}
|
||||
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame")
|
||||
local self = {}
|
||||
self.type = Type
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Constructor
|
||||
-------------------------------------------------------------------------------]]
|
||||
local PaneBackdrop = {
|
||||
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||
tile = true, tileSize = 16, edgeSize = 16,
|
||||
insets = { left = 3, right = 3, top = 5, bottom = 3 }
|
||||
}
|
||||
|
||||
self.OnRelease = OnRelease
|
||||
self.OnAcquire = OnAcquire
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:SetHeight(100)
|
||||
frame:SetWidth(100)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
|
||||
self.SetTitle = SetTitle
|
||||
self.SetGroupList = SetGroupList
|
||||
self.SetGroup = SetGroup
|
||||
self.SetStatusTable = SetStatusTable
|
||||
self.SetDropdownWidth = SetDropdownWidth
|
||||
self.OnWidthSet = OnWidthSet
|
||||
self.OnHeightSet = OnHeightSet
|
||||
self.LayoutFinished = LayoutFinished
|
||||
local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||
titletext:SetPoint("TOPLEFT", 4, -5)
|
||||
titletext:SetPoint("TOPRIGHT", -4, -5)
|
||||
titletext:SetJustifyH("LEFT")
|
||||
titletext:SetHeight(18)
|
||||
|
||||
self.localstatus = {}
|
||||
local dropdown = AceGUI:Create("Dropdown")
|
||||
dropdown.frame:SetParent(frame)
|
||||
dropdown.frame:SetFrameLevel(dropdown.frame:GetFrameLevel() + 2)
|
||||
dropdown:SetCallback("OnValueChanged", SelectedGroup)
|
||||
dropdown.frame:SetPoint("TOPLEFT", -1, 0)
|
||||
dropdown.frame:Show()
|
||||
dropdown:SetLabel("")
|
||||
|
||||
self.frame = frame
|
||||
frame.obj = self
|
||||
local border = CreateFrame("Frame", nil, frame, "BackdropTemplate")
|
||||
border:SetPoint("TOPLEFT", 0, -26)
|
||||
border:SetPoint("BOTTOMRIGHT", 0, 3)
|
||||
border:SetBackdrop(PaneBackdrop)
|
||||
border:SetBackdropColor(0.1,0.1,0.1,0.5)
|
||||
border:SetBackdropBorderColor(0.4,0.4,0.4)
|
||||
|
||||
frame:SetHeight(100)
|
||||
frame:SetWidth(100)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame", nil, border)
|
||||
content:SetPoint("TOPLEFT", 10, -10)
|
||||
content:SetPoint("BOTTOMRIGHT", -10, 10)
|
||||
|
||||
local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||
titletext:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -5)
|
||||
titletext:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -4, -5)
|
||||
titletext:SetJustifyH("LEFT")
|
||||
titletext:SetHeight(18)
|
||||
self.titletext = titletext
|
||||
|
||||
local dropdown = AceGUI:Create("Dropdown")
|
||||
self.dropdown = dropdown
|
||||
dropdown.frame:SetParent(frame)
|
||||
dropdown.frame:SetFrameLevel(dropdown.frame:GetFrameLevel() + 2)
|
||||
dropdown.parentgroup = self
|
||||
dropdown:SetCallback("OnValueChanged",SelectedGroup)
|
||||
dropdown.frame:SetPoint("TOPLEFT",frame,"TOPLEFT", -1, 0)
|
||||
dropdown.frame:Show()
|
||||
dropdown:SetLabel("")
|
||||
|
||||
local border = CreateFrame("Frame",nil,frame)
|
||||
self.border = border
|
||||
border:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-26)
|
||||
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,3)
|
||||
|
||||
border:SetBackdrop(PaneBackdrop)
|
||||
border:SetBackdropColor(0.1,0.1,0.1,0.5)
|
||||
border:SetBackdropBorderColor(0.4,0.4,0.4)
|
||||
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame",nil,border)
|
||||
self.content = content
|
||||
content.obj = self
|
||||
content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10)
|
||||
content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10)
|
||||
|
||||
AceGUI:RegisterAsContainer(self)
|
||||
return self
|
||||
local widget = {
|
||||
frame = frame,
|
||||
localstatus = {},
|
||||
titletext = titletext,
|
||||
dropdown = dropdown,
|
||||
border = border,
|
||||
content = content,
|
||||
type = Type
|
||||
}
|
||||
for method, func in pairs(methods) do
|
||||
widget[method] = func
|
||||
end
|
||||
dropdown.parentgroup = widget
|
||||
|
||||
AceGUI:RegisterWidgetType(Type,Constructor,Version)
|
||||
return AceGUI:RegisterAsContainer(widget)
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type, Constructor, Version)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Frame Container
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "Frame", 20
|
||||
local Type, Version = "Frame", 30
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
@@ -13,18 +13,18 @@ local wipe = table.wipe
|
||||
local PlaySound = PlaySound
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: CLOSE
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Button_OnClick(frame)
|
||||
PlaySound("gsTitleOptionExit")
|
||||
PlaySound(799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
|
||||
frame.obj:Hide()
|
||||
end
|
||||
|
||||
local function Frame_OnShow(frame)
|
||||
frame.obj:Fire("OnShow")
|
||||
end
|
||||
|
||||
local function Frame_OnClose(frame)
|
||||
frame.obj:Fire("OnClose")
|
||||
end
|
||||
@@ -64,6 +64,14 @@ local function SizerE_OnMouseDown(frame)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function StatusBar_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnterStatusBar")
|
||||
end
|
||||
|
||||
local function StatusBar_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeaveStatusBar")
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Methods
|
||||
-------------------------------------------------------------------------------]]
|
||||
@@ -71,10 +79,12 @@ local methods = {
|
||||
["OnAcquire"] = function(self)
|
||||
self.frame:SetParent(UIParent)
|
||||
self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
self.frame:SetFrameLevel(100) -- Lots of room to draw under it
|
||||
self:SetTitle()
|
||||
self:SetStatusText()
|
||||
self:ApplyStatus()
|
||||
self:Show()
|
||||
self:EnableResize(true)
|
||||
end,
|
||||
|
||||
["OnRelease"] = function(self)
|
||||
@@ -104,6 +114,7 @@ local methods = {
|
||||
|
||||
["SetTitle"] = function(self, title)
|
||||
self.titletext:SetText(title)
|
||||
self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10)
|
||||
end,
|
||||
|
||||
["SetStatusText"] = function(self, text)
|
||||
@@ -118,6 +129,13 @@ local methods = {
|
||||
self.frame:Show()
|
||||
end,
|
||||
|
||||
["EnableResize"] = function(self, state)
|
||||
local func = state and "Show" or "Hide"
|
||||
self.sizer_se[func](self.sizer_se)
|
||||
self.sizer_s[func](self.sizer_s)
|
||||
self.sizer_e[func](self.sizer_e)
|
||||
end,
|
||||
|
||||
-- called to set an external table to store status in
|
||||
["SetStatusTable"] = function(self, status)
|
||||
assert(type(status) == "table")
|
||||
@@ -158,17 +176,23 @@ local PaneBackdrop = {
|
||||
}
|
||||
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame", nil, UIParent)
|
||||
local frame = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
|
||||
frame:Hide()
|
||||
|
||||
frame:EnableMouse(true)
|
||||
frame:SetMovable(true)
|
||||
frame:SetResizable(true)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
frame:SetFrameLevel(100) -- Lots of room to draw under it
|
||||
frame:SetBackdrop(FrameBackdrop)
|
||||
frame:SetBackdropColor(0, 0, 0, 1)
|
||||
frame:SetMinResize(400, 200)
|
||||
if frame.SetResizeBounds then -- WoW 10.0
|
||||
frame:SetResizeBounds(400, 200)
|
||||
else
|
||||
frame:SetMinResize(400, 200)
|
||||
end
|
||||
frame:SetToplevel(true)
|
||||
frame:SetScript("OnShow", Frame_OnShow)
|
||||
frame:SetScript("OnHide", Frame_OnClose)
|
||||
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
|
||||
|
||||
@@ -179,13 +203,15 @@ local function Constructor()
|
||||
closebutton:SetWidth(100)
|
||||
closebutton:SetText(CLOSE)
|
||||
|
||||
local statusbg = CreateFrame("Frame", nil, frame)
|
||||
local statusbg = CreateFrame("Button", nil, frame, "BackdropTemplate")
|
||||
statusbg:SetPoint("BOTTOMLEFT", 15, 15)
|
||||
statusbg:SetPoint("BOTTOMRIGHT", -132, 15)
|
||||
statusbg:SetHeight(24)
|
||||
statusbg:SetBackdrop(PaneBackdrop)
|
||||
statusbg:SetBackdropColor(0.1,0.1,0.1)
|
||||
statusbg:SetBackdropBorderColor(0.4,0.4,0.4)
|
||||
statusbg:SetScript("OnEnter", StatusBar_OnEnter)
|
||||
statusbg:SetScript("OnLeave", StatusBar_OnLeave)
|
||||
|
||||
local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||
statustext:SetPoint("TOPLEFT", 7, -2)
|
||||
@@ -245,7 +271,7 @@ local function Constructor()
|
||||
line2:SetHeight(8)
|
||||
line2:SetPoint("BOTTOMRIGHT", -8, 8)
|
||||
line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
|
||||
local x = 0.1 * 8/17
|
||||
x = 0.1 * 8/17
|
||||
line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
|
||||
|
||||
local sizer_s = CreateFrame("Frame", nil, frame)
|
||||
@@ -273,6 +299,10 @@ local function Constructor()
|
||||
localstatus = {},
|
||||
titletext = titletext,
|
||||
statustext = statustext,
|
||||
titlebg = titlebg,
|
||||
sizer_se = sizer_se,
|
||||
sizer_s = sizer_s,
|
||||
sizer_e = sizer_e,
|
||||
content = content,
|
||||
frame = frame,
|
||||
type = Type
|
||||
@@ -280,7 +310,7 @@ local function Constructor()
|
||||
for method, func in pairs(methods) do
|
||||
widget[method] = func
|
||||
end
|
||||
closebutton.obj = widget
|
||||
closebutton.obj, statusbg.obj = widget, widget
|
||||
|
||||
return AceGUI:RegisterAsContainer(widget)
|
||||
end
|
||||
|
||||
@@ -1,72 +1,40 @@
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
--[[-----------------------------------------------------------------------------
|
||||
InlineGroup Container
|
||||
Simple container widget that creates a visible "box" with an optional title.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "InlineGroup", 22
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
-- Lua APIs
|
||||
local pairs = pairs
|
||||
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-------------
|
||||
-- Widgets --
|
||||
-------------
|
||||
--[[
|
||||
Widgets must provide the following functions
|
||||
Acquire() - Called when the object is aquired, should set everything to a default hidden state
|
||||
Release() - Called when the object is Released, should remove any anchors and hide the Widget
|
||||
|
||||
And the following members
|
||||
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
|
||||
type - the type of the object, same as the name given to :RegisterWidget()
|
||||
|
||||
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
|
||||
It will be cleared automatically when a widget is released
|
||||
Placing values directly into a widget object should be avoided
|
||||
|
||||
If the Widget can act as a container for other Widgets the following
|
||||
content - frame or derivitive that children will be anchored to
|
||||
|
||||
The Widget can supply the following Optional Members
|
||||
|
||||
|
||||
]]
|
||||
|
||||
--------------------------
|
||||
-- Inline Group --
|
||||
--------------------------
|
||||
--[[
|
||||
This is a simple grouping container, no selection
|
||||
It will resize automatically to the height of the controls added to it
|
||||
]]
|
||||
|
||||
do
|
||||
local Type = "InlineGroup"
|
||||
local Version = 6
|
||||
|
||||
local function OnAcquire(self)
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Methods
|
||||
-------------------------------------------------------------------------------]]
|
||||
local methods = {
|
||||
["OnAcquire"] = function(self)
|
||||
self:SetWidth(300)
|
||||
self:SetHeight(100)
|
||||
end
|
||||
self:SetTitle("")
|
||||
end,
|
||||
|
||||
local function OnRelease(self)
|
||||
self.frame:ClearAllPoints()
|
||||
self.frame:Hide()
|
||||
end
|
||||
-- ["OnRelease"] = nil,
|
||||
|
||||
local PaneBackdrop = {
|
||||
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||
tile = true, tileSize = 16, edgeSize = 16,
|
||||
insets = { left = 3, right = 3, top = 5, bottom = 3 }
|
||||
}
|
||||
|
||||
local function SetTitle(self,title)
|
||||
["SetTitle"] = function(self,title)
|
||||
self.titletext:SetText(title)
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
local function LayoutFinished(self, width, height)
|
||||
["LayoutFinished"] = function(self, width, height)
|
||||
if self.noAutoHeight then return end
|
||||
self:SetHeight((height or 0) + 40)
|
||||
end
|
||||
end,
|
||||
|
||||
local function OnWidthSet(self, width)
|
||||
["OnWidthSet"] = function(self, width)
|
||||
local content = self.content
|
||||
local contentwidth = width - 20
|
||||
if contentwidth < 0 then
|
||||
@@ -74,10 +42,9 @@ do
|
||||
end
|
||||
content:SetWidth(contentwidth)
|
||||
content.width = contentwidth
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
local function OnHeightSet(self, height)
|
||||
["OnHeightSet"] = function(self, height)
|
||||
local content = self.content
|
||||
local contentheight = height - 20
|
||||
if contentheight < 0 then
|
||||
@@ -86,53 +53,51 @@ do
|
||||
content:SetHeight(contentheight)
|
||||
content.height = contentheight
|
||||
end
|
||||
}
|
||||
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame",nil,UIParent)
|
||||
local self = {}
|
||||
self.type = Type
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Constructor
|
||||
-------------------------------------------------------------------------------]]
|
||||
local PaneBackdrop = {
|
||||
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||
tile = true, tileSize = 16, edgeSize = 16,
|
||||
insets = { left = 3, right = 3, top = 5, bottom = 3 }
|
||||
}
|
||||
|
||||
self.OnRelease = OnRelease
|
||||
self.OnAcquire = OnAcquire
|
||||
self.SetTitle = SetTitle
|
||||
self.frame = frame
|
||||
self.LayoutFinished = LayoutFinished
|
||||
self.OnWidthSet = OnWidthSet
|
||||
self.OnHeightSet = OnHeightSet
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame", nil, UIParent)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
|
||||
frame.obj = self
|
||||
local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||
titletext:SetPoint("TOPLEFT", 14, 0)
|
||||
titletext:SetPoint("TOPRIGHT", -14, 0)
|
||||
titletext:SetJustifyH("LEFT")
|
||||
titletext:SetHeight(18)
|
||||
|
||||
frame:SetHeight(100)
|
||||
frame:SetWidth(100)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
local border = CreateFrame("Frame", nil, frame, "BackdropTemplate")
|
||||
border:SetPoint("TOPLEFT", 0, -17)
|
||||
border:SetPoint("BOTTOMRIGHT", -1, 3)
|
||||
border:SetBackdrop(PaneBackdrop)
|
||||
border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
|
||||
border:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||
|
||||
local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
|
||||
titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0)
|
||||
titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0)
|
||||
titletext:SetJustifyH("LEFT")
|
||||
titletext:SetHeight(18)
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame", nil, border)
|
||||
content:SetPoint("TOPLEFT", 10, -10)
|
||||
content:SetPoint("BOTTOMRIGHT", -10, 10)
|
||||
|
||||
self.titletext = titletext
|
||||
|
||||
local border = CreateFrame("Frame",nil,frame)
|
||||
self.border = border
|
||||
border:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-17)
|
||||
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-1,3)
|
||||
|
||||
border:SetBackdrop(PaneBackdrop)
|
||||
border:SetBackdropColor(0.1,0.1,0.1,0.5)
|
||||
border:SetBackdropBorderColor(0.4,0.4,0.4)
|
||||
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame",nil,border)
|
||||
self.content = content
|
||||
content.obj = self
|
||||
content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10)
|
||||
content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10)
|
||||
|
||||
AceGUI:RegisterAsContainer(self)
|
||||
return self
|
||||
local widget = {
|
||||
frame = frame,
|
||||
content = content,
|
||||
titletext = titletext,
|
||||
type = Type
|
||||
}
|
||||
for method, func in pairs(methods) do
|
||||
widget[method] = func
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type,Constructor,Version)
|
||||
return AceGUI:RegisterAsContainer(widget)
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type, Constructor, Version)
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
--[[-----------------------------------------------------------------------------
|
||||
ScrollFrame Container
|
||||
Plain container that scrolls its content and doesn't grow in height.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "ScrollFrame", 26
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
-- Lua APIs
|
||||
local pairs, assert, type = pairs, assert, type
|
||||
@@ -7,59 +13,50 @@ local min, max, floor = math.min, math.max, math.floor
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function FixScrollOnUpdate(frame)
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
frame.obj:FixScroll()
|
||||
end
|
||||
|
||||
-------------
|
||||
-- Widgets --
|
||||
-------------
|
||||
--[[
|
||||
Widgets must provide the following functions
|
||||
Acquire() - Called when the object is aquired, should set everything to a default hidden state
|
||||
Release() - Called when the object is Released, should remove any anchors and hide the Widget
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function ScrollFrame_OnMouseWheel(frame, value)
|
||||
frame.obj:MoveScroll(value)
|
||||
end
|
||||
|
||||
And the following members
|
||||
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
|
||||
type - the type of the object, same as the name given to :RegisterWidget()
|
||||
local function ScrollFrame_OnSizeChanged(frame)
|
||||
frame:SetScript("OnUpdate", FixScrollOnUpdate)
|
||||
end
|
||||
|
||||
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
|
||||
It will be cleared automatically when a widget is released
|
||||
Placing values directly into a widget object should be avoided
|
||||
local function ScrollBar_OnScrollValueChanged(frame, value)
|
||||
frame.obj:SetScroll(value)
|
||||
end
|
||||
|
||||
If the Widget can act as a container for other Widgets the following
|
||||
content - frame or derivitive that children will be anchored to
|
||||
|
||||
The Widget can supply the following Optional Members
|
||||
|
||||
|
||||
]]
|
||||
|
||||
--------------------------
|
||||
-- Scroll Frame --
|
||||
--------------------------
|
||||
do
|
||||
local Type = "ScrollFrame"
|
||||
local Version = 9
|
||||
|
||||
local function OnAcquire(self)
|
||||
|
||||
end
|
||||
|
||||
local function OnRelease(self)
|
||||
self.frame:ClearAllPoints()
|
||||
self.frame:Hide()
|
||||
self.status = nil
|
||||
-- do SetScroll after niling status, but before clearing localstatus
|
||||
-- so the scroll value isnt populated back into status, but not kept in localstatus either
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Methods
|
||||
-------------------------------------------------------------------------------]]
|
||||
local methods = {
|
||||
["OnAcquire"] = function(self)
|
||||
self:SetScroll(0)
|
||||
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
|
||||
end,
|
||||
|
||||
["OnRelease"] = function(self)
|
||||
self.status = nil
|
||||
for k in pairs(self.localstatus) do
|
||||
self.localstatus[k] = nil
|
||||
end
|
||||
self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0)
|
||||
self.scrollframe:SetPoint("BOTTOMRIGHT")
|
||||
self.scrollbar:Hide()
|
||||
self.scrollBarShown = nil
|
||||
self.content.height, self.content.width = nil, nil
|
||||
end
|
||||
self.content.height, self.content.width, self.content.original_width = nil, nil, nil
|
||||
end,
|
||||
|
||||
local function SetScroll(self, value)
|
||||
["SetScroll"] = function(self, value)
|
||||
local status = self.status or self.localstatus
|
||||
local viewheight = self.scrollframe:GetHeight()
|
||||
local height = self.content:GetHeight()
|
||||
@@ -71,20 +68,17 @@ do
|
||||
offset = floor((height - viewheight) / 1000.0 * value)
|
||||
end
|
||||
self.content:ClearAllPoints()
|
||||
self.content:SetPoint("TOPLEFT", self.scrollframe, "TOPLEFT", 0, offset)
|
||||
self.content:SetPoint("TOPRIGHT", self.scrollframe, "TOPRIGHT", 0, offset)
|
||||
self.content:SetPoint("TOPLEFT", 0, offset)
|
||||
self.content:SetPoint("TOPRIGHT", 0, offset)
|
||||
status.offset = offset
|
||||
status.scrollvalue = value
|
||||
end
|
||||
end,
|
||||
|
||||
local function MoveScroll(self, value)
|
||||
["MoveScroll"] = function(self, value)
|
||||
local status = self.status or self.localstatus
|
||||
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
|
||||
|
||||
if height > viewheight then
|
||||
self.scrollbar:Hide()
|
||||
else
|
||||
self.scrollbar:Show()
|
||||
if self.scrollBarShown then
|
||||
local diff = height - viewheight
|
||||
local delta = 1
|
||||
if value < 0 then
|
||||
@@ -92,29 +86,35 @@ do
|
||||
end
|
||||
self.scrollbar:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
local function FixScroll(self)
|
||||
["FixScroll"] = function(self)
|
||||
if self.updateLock then return end
|
||||
self.updateLock = true
|
||||
local status = self.status or self.localstatus
|
||||
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
|
||||
local offset = status.offset or 0
|
||||
local curvalue = self.scrollbar:GetValue()
|
||||
if viewheight < height then
|
||||
-- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys
|
||||
-- No-one is going to miss 2 pixels at the bottom of the frame, anyhow!
|
||||
if viewheight < height + 2 then
|
||||
if self.scrollBarShown then
|
||||
self.scrollBarShown = nil
|
||||
self.scrollbar:Hide()
|
||||
self.scrollbar:SetValue(0)
|
||||
self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0)
|
||||
self.scrollframe:SetPoint("BOTTOMRIGHT")
|
||||
if self.content.original_width then
|
||||
self.content.width = self.content.original_width
|
||||
end
|
||||
self:DoLayout()
|
||||
end
|
||||
else
|
||||
if not self.scrollBarShown then
|
||||
self.scrollBarShown = true
|
||||
self.scrollbar:Show()
|
||||
self.scrollframe:SetPoint("BOTTOMRIGHT", self.frame,"BOTTOMRIGHT",-20,0)
|
||||
self.scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
|
||||
if self.content.original_width then
|
||||
self.content.width = self.content.original_width - 20
|
||||
end
|
||||
self:DoLayout()
|
||||
end
|
||||
local value = (offset / (viewheight - height) * 1000)
|
||||
@@ -123,119 +123,93 @@ do
|
||||
self:SetScroll(value)
|
||||
if value < 1000 then
|
||||
self.content:ClearAllPoints()
|
||||
self.content:SetPoint("TOPLEFT", self.scrollframe, "TOPLEFT", 0, offset)
|
||||
self.content:SetPoint("TOPRIGHT", self.scrollframe, "TOPRIGHT", 0, offset)
|
||||
self.content:SetPoint("TOPLEFT", 0, offset)
|
||||
self.content:SetPoint("TOPRIGHT", 0, offset)
|
||||
status.offset = offset
|
||||
end
|
||||
end
|
||||
self.updateLock = nil
|
||||
end
|
||||
end,
|
||||
|
||||
local function OnMouseWheel(this, value)
|
||||
this.obj:MoveScroll(value)
|
||||
end
|
||||
|
||||
local function OnScrollValueChanged(this, value)
|
||||
this.obj:SetScroll(value)
|
||||
end
|
||||
|
||||
local function FixScrollOnUpdate(this)
|
||||
this:SetScript("OnUpdate", nil)
|
||||
this.obj:FixScroll()
|
||||
end
|
||||
|
||||
local function OnSizeChanged(this)
|
||||
this:SetScript("OnUpdate", FixScrollOnUpdate)
|
||||
end
|
||||
|
||||
local function LayoutFinished(self, width, height)
|
||||
["LayoutFinished"] = function(self, width, height)
|
||||
self.content:SetHeight(height or 0 + 20)
|
||||
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
|
||||
end
|
||||
|
||||
-- called to set an external table to store status in
|
||||
local function SetStatusTable(self, status)
|
||||
-- update the scrollframe
|
||||
self:FixScroll()
|
||||
|
||||
-- schedule another update when everything has "settled"
|
||||
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
|
||||
end,
|
||||
|
||||
["SetStatusTable"] = function(self, status)
|
||||
assert(type(status) == "table")
|
||||
self.status = status
|
||||
if not status.scrollvalue then
|
||||
status.scrollvalue = 0
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
local function OnWidthSet(self, width)
|
||||
["OnWidthSet"] = function(self, width)
|
||||
local content = self.content
|
||||
content.width = width
|
||||
end
|
||||
content.width = width - (self.scrollBarShown and 20 or 0)
|
||||
content.original_width = width
|
||||
end,
|
||||
|
||||
|
||||
local function OnHeightSet(self, height)
|
||||
["OnHeightSet"] = function(self, height)
|
||||
local content = self.content
|
||||
content.height = height
|
||||
end
|
||||
}
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Constructor
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame", nil, UIParent)
|
||||
local num = AceGUI:GetNextWidgetNum(Type)
|
||||
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame", nil, UIParent)
|
||||
local self = {}
|
||||
self.type = Type
|
||||
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
|
||||
scrollframe:SetPoint("TOPLEFT")
|
||||
scrollframe:SetPoint("BOTTOMRIGHT")
|
||||
scrollframe:EnableMouseWheel(true)
|
||||
scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
|
||||
scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
|
||||
|
||||
self.OnRelease = OnRelease
|
||||
self.OnAcquire = OnAcquire
|
||||
local scrollbar = CreateFrame("Slider", ("AceConfigDialogScrollFrame%dScrollBar"):format(num), scrollframe, "UIPanelScrollBarTemplate")
|
||||
scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
|
||||
scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
|
||||
scrollbar:SetMinMaxValues(0, 1000)
|
||||
scrollbar:SetValueStep(1)
|
||||
scrollbar:SetValue(0)
|
||||
scrollbar:SetWidth(16)
|
||||
scrollbar:Hide()
|
||||
-- set the script as the last step, so it doesn't fire yet
|
||||
scrollbar:SetScript("OnValueChanged", ScrollBar_OnScrollValueChanged)
|
||||
|
||||
self.MoveScroll = MoveScroll
|
||||
self.FixScroll = FixScroll
|
||||
self.SetScroll = SetScroll
|
||||
self.LayoutFinished = LayoutFinished
|
||||
self.SetStatusTable = SetStatusTable
|
||||
self.OnWidthSet = OnWidthSet
|
||||
self.OnHeightSet = OnHeightSet
|
||||
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
|
||||
scrollbg:SetAllPoints(scrollbar)
|
||||
scrollbg:SetColorTexture(0, 0, 0, 0.4)
|
||||
|
||||
self.localstatus = {}
|
||||
self.frame = frame
|
||||
frame.obj = self
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame", nil, scrollframe)
|
||||
content:SetPoint("TOPLEFT")
|
||||
content:SetPoint("TOPRIGHT")
|
||||
content:SetHeight(400)
|
||||
scrollframe:SetScrollChild(content)
|
||||
|
||||
--Container Support
|
||||
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
|
||||
scrollframe.obj = self
|
||||
scrollframe:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)
|
||||
scrollframe:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 0)
|
||||
scrollframe:EnableMouseWheel(true)
|
||||
scrollframe:SetScript("OnMouseWheel", OnMouseWheel)
|
||||
scrollframe:SetScript("OnSizeChanged", OnSizeChanged)
|
||||
self.scrollframe = scrollframe
|
||||
|
||||
local content = CreateFrame("Frame", nil, scrollframe)
|
||||
content.obj = self
|
||||
content:SetPoint("TOPLEFT", scrollframe, "TOPLEFT", 0, 0)
|
||||
content:SetPoint("TOPRIGHT", scrollframe, "TOPRIGHT", 0, 0)
|
||||
content:SetHeight(400)
|
||||
self.content = content
|
||||
scrollframe:SetScrollChild(content)
|
||||
|
||||
local num = AceGUI:GetNextWidgetNum(Type)
|
||||
local name = ("AceConfigDialogScrollFrame%dScrollBar"):format(num)
|
||||
local scrollbar = CreateFrame("Slider", name, scrollframe, "UIPanelScrollBarTemplate")
|
||||
scrollbar.obj = self
|
||||
scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
|
||||
scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
|
||||
scrollbar:SetScript("OnValueChanged", OnScrollValueChanged)
|
||||
scrollbar:SetMinMaxValues(0, 1000)
|
||||
scrollbar:SetValueStep(1)
|
||||
scrollbar:SetValue(0)
|
||||
scrollbar:SetWidth(16)
|
||||
scrollbar:Hide()
|
||||
self.scrollbar = scrollbar
|
||||
|
||||
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
|
||||
scrollbg:SetAllPoints(scrollbar)
|
||||
scrollbg:SetTexture(0, 0, 0, 0.4)
|
||||
|
||||
self.localstatus.scrollvalue = 0
|
||||
|
||||
--self:FixScroll()
|
||||
AceGUI:RegisterAsContainer(self)
|
||||
--AceGUI:RegisterAsWidget(self)
|
||||
return self
|
||||
local widget = {
|
||||
localstatus = { scrollvalue = 0 },
|
||||
scrollframe = scrollframe,
|
||||
scrollbar = scrollbar,
|
||||
content = content,
|
||||
frame = frame,
|
||||
type = Type
|
||||
}
|
||||
for method, func in pairs(methods) do
|
||||
widget[method] = func
|
||||
end
|
||||
scrollframe.obj, scrollbar.obj = widget, widget
|
||||
|
||||
AceGUI:RegisterWidgetType(Type,Constructor,Version)
|
||||
return AceGUI:RegisterAsContainer(widget)
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type, Constructor, Version)
|
||||
|
||||
@@ -1,99 +1,69 @@
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
--[[-----------------------------------------------------------------------------
|
||||
SimpleGroup Container
|
||||
Simple container widget that just groups widgets.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "SimpleGroup", 20
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
-- Lua APIs
|
||||
local pairs = pairs
|
||||
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-------------
|
||||
-- Widgets --
|
||||
-------------
|
||||
--[[
|
||||
Widgets must provide the following functions
|
||||
Acquire() - Called when the object is aquired, should set everything to a default hidden state
|
||||
Release() - Called when the object is Released, should remove any anchors and hide the Widget
|
||||
|
||||
And the following members
|
||||
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
|
||||
type - the type of the object, same as the name given to :RegisterWidget()
|
||||
|
||||
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
|
||||
It will be cleared automatically when a widget is released
|
||||
Placing values directly into a widget object should be avoided
|
||||
|
||||
If the Widget can act as a container for other Widgets the following
|
||||
content - frame or derivitive that children will be anchored to
|
||||
|
||||
The Widget can supply the following Optional Members
|
||||
|
||||
|
||||
]]
|
||||
|
||||
--------------------------
|
||||
-- Simple Group --
|
||||
--------------------------
|
||||
--[[
|
||||
This is a simple grouping container, no selection, no borders
|
||||
It will resize automatically to the height of the controls added to it
|
||||
]]
|
||||
|
||||
do
|
||||
local Type = "SimpleGroup"
|
||||
local Version = 5
|
||||
|
||||
local function OnAcquire(self)
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Methods
|
||||
-------------------------------------------------------------------------------]]
|
||||
local methods = {
|
||||
["OnAcquire"] = function(self)
|
||||
self:SetWidth(300)
|
||||
self:SetHeight(100)
|
||||
end
|
||||
end,
|
||||
|
||||
local function OnRelease(self)
|
||||
self.frame:ClearAllPoints()
|
||||
self.frame:Hide()
|
||||
end
|
||||
-- ["OnRelease"] = nil,
|
||||
|
||||
local function LayoutFinished(self, width, height)
|
||||
["LayoutFinished"] = function(self, width, height)
|
||||
if self.noAutoHeight then return end
|
||||
self:SetHeight(height or 0)
|
||||
end
|
||||
end,
|
||||
|
||||
local function OnWidthSet(self, width)
|
||||
["OnWidthSet"] = function(self, width)
|
||||
local content = self.content
|
||||
content:SetWidth(width)
|
||||
content.width = width
|
||||
end
|
||||
end,
|
||||
|
||||
local function OnHeightSet(self, height)
|
||||
["OnHeightSet"] = function(self, height)
|
||||
local content = self.content
|
||||
content:SetHeight(height)
|
||||
content.height = height
|
||||
end
|
||||
}
|
||||
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame",nil,UIParent)
|
||||
local self = {}
|
||||
self.type = Type
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Constructor
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame", nil, UIParent)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
|
||||
self.OnRelease = OnRelease
|
||||
self.OnAcquire = OnAcquire
|
||||
self.frame = frame
|
||||
self.LayoutFinished = LayoutFinished
|
||||
self.OnWidthSet = OnWidthSet
|
||||
self.OnHeightSet = OnHeightSet
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame", nil, frame)
|
||||
content:SetPoint("TOPLEFT")
|
||||
content:SetPoint("BOTTOMRIGHT")
|
||||
|
||||
frame.obj = self
|
||||
|
||||
frame:SetHeight(100)
|
||||
frame:SetWidth(100)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame",nil,frame)
|
||||
self.content = content
|
||||
content.obj = self
|
||||
content:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
|
||||
content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
|
||||
|
||||
AceGUI:RegisterAsContainer(self)
|
||||
return self
|
||||
local widget = {
|
||||
frame = frame,
|
||||
content = content,
|
||||
type = Type
|
||||
}
|
||||
for method, func in pairs(methods) do
|
||||
widget[method] = func
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type,Constructor,Version)
|
||||
return AceGUI:RegisterAsContainer(widget)
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type, Constructor, Version)
|
||||
|
||||
@@ -1,63 +1,229 @@
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
--[[-----------------------------------------------------------------------------
|
||||
TabGroup Container
|
||||
Container that uses tabs on top to switch between groups.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "TabGroup", 38
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
-- Lua APIs
|
||||
local pairs, ipairs, assert, type = pairs, ipairs, assert, type
|
||||
local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, table.wipe
|
||||
|
||||
-- WoW APIs
|
||||
local PlaySound = PlaySound
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
local _G = _G
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: PanelTemplates_TabResize, PanelTemplates_SetDisabledTabState, PanelTemplates_SelectTab, PanelTemplates_DeselectTab
|
||||
-- local upvalue storage used by BuildTabs
|
||||
local widths = {}
|
||||
local rowwidths = {}
|
||||
local rowends = {}
|
||||
|
||||
-------------
|
||||
-- Widgets --
|
||||
-------------
|
||||
--[[
|
||||
Widgets must provide the following functions
|
||||
Acquire() - Called when the object is aquired, should set everything to a default hidden state
|
||||
Release() - Called when the object is Released, should remove any anchors and hide the Widget
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
|
||||
And the following members
|
||||
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
|
||||
type - the type of the object, same as the name given to :RegisterWidget()
|
||||
local function PanelTemplates_TabResize(tab, padding, absoluteSize, minWidth, maxWidth, absoluteTextSize)
|
||||
local tabName = tab:GetName();
|
||||
|
||||
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
|
||||
It will be cleared automatically when a widget is released
|
||||
Placing values directly into a widget object should be avoided
|
||||
|
||||
If the Widget can act as a container for other Widgets the following
|
||||
content - frame or derivitive that children will be anchored to
|
||||
|
||||
The Widget can supply the following Optional Members
|
||||
|
||||
|
||||
]]
|
||||
|
||||
--------------------------
|
||||
-- Tab Group --
|
||||
--------------------------
|
||||
|
||||
do
|
||||
local Type = "TabGroup"
|
||||
local Version = 25
|
||||
|
||||
local PaneBackdrop = {
|
||||
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||
tile = true, tileSize = 16, edgeSize = 16,
|
||||
insets = { left = 3, right = 3, top = 5, bottom = 3 }
|
||||
}
|
||||
|
||||
local function OnAcquire(self)
|
||||
local buttonMiddle = tab.Middle or tab.middleTexture or _G[tabName.."Middle"];
|
||||
local buttonMiddleDisabled = tab.MiddleDisabled or (tabName and _G[tabName.."MiddleDisabled"]);
|
||||
local left = tab.Left or tab.leftTexture or _G[tabName.."Left"];
|
||||
local sideWidths = 2 * left:GetWidth();
|
||||
local tabText = tab.Text or _G[tab:GetName().."Text"];
|
||||
local highlightTexture = tab.HighlightTexture or (tabName and _G[tabName.."HighlightTexture"]);
|
||||
|
||||
local width, tabWidth;
|
||||
local textWidth;
|
||||
if ( absoluteTextSize ) then
|
||||
textWidth = absoluteTextSize;
|
||||
else
|
||||
tabText:SetWidth(0);
|
||||
textWidth = tabText:GetWidth();
|
||||
end
|
||||
-- If there's an absolute size specified then use it
|
||||
if ( absoluteSize ) then
|
||||
if ( absoluteSize < sideWidths) then
|
||||
width = 1;
|
||||
tabWidth = sideWidths
|
||||
else
|
||||
width = absoluteSize - sideWidths;
|
||||
tabWidth = absoluteSize
|
||||
end
|
||||
tabText:SetWidth(width);
|
||||
else
|
||||
-- Otherwise try to use padding
|
||||
if ( padding ) then
|
||||
width = textWidth + padding;
|
||||
else
|
||||
width = textWidth + 24;
|
||||
end
|
||||
-- If greater than the maxWidth then cap it
|
||||
if ( maxWidth and width > maxWidth ) then
|
||||
if ( padding ) then
|
||||
width = maxWidth + padding;
|
||||
else
|
||||
width = maxWidth + 24;
|
||||
end
|
||||
tabText:SetWidth(width);
|
||||
else
|
||||
tabText:SetWidth(0);
|
||||
end
|
||||
if (minWidth and width < minWidth) then
|
||||
width = minWidth;
|
||||
end
|
||||
tabWidth = width + sideWidths;
|
||||
end
|
||||
|
||||
local function OnRelease(self)
|
||||
self.frame:ClearAllPoints()
|
||||
self.frame:Hide()
|
||||
if ( buttonMiddle ) then
|
||||
buttonMiddle:SetWidth(width);
|
||||
end
|
||||
if ( buttonMiddleDisabled ) then
|
||||
buttonMiddleDisabled:SetWidth(width);
|
||||
end
|
||||
|
||||
tab:SetWidth(tabWidth);
|
||||
|
||||
if ( highlightTexture ) then
|
||||
highlightTexture:SetWidth(tabWidth);
|
||||
end
|
||||
end
|
||||
|
||||
local function PanelTemplates_DeselectTab(tab)
|
||||
local name = tab:GetName();
|
||||
|
||||
local left = tab.Left or _G[name.."Left"];
|
||||
local middle = tab.Middle or _G[name.."Middle"];
|
||||
local right = tab.Right or _G[name.."Right"];
|
||||
left:Show();
|
||||
middle:Show();
|
||||
right:Show();
|
||||
--tab:UnlockHighlight();
|
||||
tab:Enable();
|
||||
local text = tab.Text or _G[name.."Text"];
|
||||
text:SetPoint("CENTER", tab, "CENTER", (tab.deselectedTextX or 0), (tab.deselectedTextY or 2));
|
||||
|
||||
local leftDisabled = tab.LeftDisabled or _G[name.."LeftDisabled"];
|
||||
local middleDisabled = tab.MiddleDisabled or _G[name.."MiddleDisabled"];
|
||||
local rightDisabled = tab.RightDisabled or _G[name.."RightDisabled"];
|
||||
leftDisabled:Hide();
|
||||
middleDisabled:Hide();
|
||||
rightDisabled:Hide();
|
||||
end
|
||||
|
||||
local function PanelTemplates_SelectTab(tab)
|
||||
local name = tab:GetName();
|
||||
|
||||
local left = tab.Left or _G[name.."Left"];
|
||||
local middle = tab.Middle or _G[name.."Middle"];
|
||||
local right = tab.Right or _G[name.."Right"];
|
||||
left:Hide();
|
||||
middle:Hide();
|
||||
right:Hide();
|
||||
--tab:LockHighlight();
|
||||
tab:Disable();
|
||||
tab:SetDisabledFontObject(GameFontHighlightSmall);
|
||||
local text = tab.Text or _G[name.."Text"];
|
||||
text:SetPoint("CENTER", tab, "CENTER", (tab.selectedTextX or 0), (tab.selectedTextY or -3));
|
||||
|
||||
local leftDisabled = tab.LeftDisabled or _G[name.."LeftDisabled"];
|
||||
local middleDisabled = tab.MiddleDisabled or _G[name.."MiddleDisabled"];
|
||||
local rightDisabled = tab.RightDisabled or _G[name.."RightDisabled"];
|
||||
leftDisabled:Show();
|
||||
middleDisabled:Show();
|
||||
rightDisabled:Show();
|
||||
|
||||
if GameTooltip:IsOwned(tab) then
|
||||
GameTooltip:Hide();
|
||||
end
|
||||
end
|
||||
|
||||
local function PanelTemplates_SetDisabledTabState(tab)
|
||||
local name = tab:GetName();
|
||||
local left = tab.Left or _G[name.."Left"];
|
||||
local middle = tab.Middle or _G[name.."Middle"];
|
||||
local right = tab.Right or _G[name.."Right"];
|
||||
left:Show();
|
||||
middle:Show();
|
||||
right:Show();
|
||||
--tab:UnlockHighlight();
|
||||
tab:Disable();
|
||||
tab.text = tab:GetText();
|
||||
-- Gray out text
|
||||
tab:SetDisabledFontObject(GameFontDisableSmall);
|
||||
local leftDisabled = tab.LeftDisabled or _G[name.."LeftDisabled"];
|
||||
local middleDisabled = tab.MiddleDisabled or _G[name.."MiddleDisabled"];
|
||||
local rightDisabled = tab.RightDisabled or _G[name.."RightDisabled"];
|
||||
leftDisabled:Hide();
|
||||
middleDisabled:Hide();
|
||||
rightDisabled:Hide();
|
||||
end
|
||||
|
||||
local function UpdateTabLook(frame)
|
||||
if frame.disabled then
|
||||
PanelTemplates_SetDisabledTabState(frame)
|
||||
elseif frame.selected then
|
||||
PanelTemplates_SelectTab(frame)
|
||||
else
|
||||
PanelTemplates_DeselectTab(frame)
|
||||
end
|
||||
end
|
||||
|
||||
local function Tab_SetText(frame, text)
|
||||
frame:_SetText(text)
|
||||
local width = frame.obj.frame.width or frame.obj.frame:GetWidth() or 0
|
||||
PanelTemplates_TabResize(frame, 0, nil, nil, width, frame:GetFontString():GetStringWidth())
|
||||
end
|
||||
|
||||
local function Tab_SetSelected(frame, selected)
|
||||
frame.selected = selected
|
||||
UpdateTabLook(frame)
|
||||
end
|
||||
|
||||
local function Tab_SetDisabled(frame, disabled)
|
||||
frame.disabled = disabled
|
||||
UpdateTabLook(frame)
|
||||
end
|
||||
|
||||
local function BuildTabsOnUpdate(frame)
|
||||
local self = frame.obj
|
||||
self:BuildTabs()
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Tab_OnClick(frame)
|
||||
if not (frame.selected or frame.disabled) then
|
||||
PlaySound(841) -- SOUNDKIT.IG_CHARACTER_INFO_TAB
|
||||
frame.obj:SelectTab(frame.value)
|
||||
end
|
||||
end
|
||||
|
||||
local function Tab_OnEnter(frame)
|
||||
local self = frame.obj
|
||||
self:Fire("OnTabEnter", self.tabs[frame.id].value, frame)
|
||||
end
|
||||
|
||||
local function Tab_OnLeave(frame)
|
||||
local self = frame.obj
|
||||
self:Fire("OnTabLeave", self.tabs[frame.id].value, frame)
|
||||
end
|
||||
|
||||
local function Tab_OnShow(frame)
|
||||
_G[frame:GetName().."HighlightTexture"]:SetWidth(frame:GetTextWidth() + 30)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Methods
|
||||
-------------------------------------------------------------------------------]]
|
||||
local methods = {
|
||||
["OnAcquire"] = function(self)
|
||||
self:SetTitle()
|
||||
end,
|
||||
|
||||
["OnRelease"] = function(self)
|
||||
self.status = nil
|
||||
for k in pairs(self.localstatus) do
|
||||
self.localstatus[k] = nil
|
||||
@@ -66,70 +232,75 @@ do
|
||||
for _, tab in pairs(self.tabs) do
|
||||
tab:Hide()
|
||||
end
|
||||
self:SetTitle()
|
||||
end
|
||||
end,
|
||||
|
||||
local function Tab_SetText(self, text)
|
||||
self:_SetText(text)
|
||||
local width = self.obj.frame.width or self.obj.frame:GetWidth() or 0
|
||||
PanelTemplates_TabResize(self, 0, nil, width)
|
||||
end
|
||||
["CreateTab"] = function(self, id)
|
||||
local tabname = ("AceGUITabGroup%dTab%d"):format(self.num, id)
|
||||
local tab = CreateFrame("Button", tabname, self.border)
|
||||
tab:SetSize(115, 24)
|
||||
tab.deselectedTextY = -3
|
||||
tab.selectedTextY = -2
|
||||
|
||||
local function UpdateTabLook(self)
|
||||
if self.disabled then
|
||||
PanelTemplates_SetDisabledTabState(self)
|
||||
elseif self.selected then
|
||||
PanelTemplates_SelectTab(self)
|
||||
else
|
||||
PanelTemplates_DeselectTab(self)
|
||||
end
|
||||
end
|
||||
tab.LeftDisabled = tab:CreateTexture(tabname .. "LeftDisabled", "BORDER")
|
||||
tab.LeftDisabled:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
|
||||
tab.LeftDisabled:SetSize(20, 24)
|
||||
tab.LeftDisabled:SetPoint("BOTTOMLEFT", 0, -3)
|
||||
tab.LeftDisabled:SetTexCoord(0, 0.15625, 0, 1.0)
|
||||
|
||||
local function Tab_SetSelected(self, selected)
|
||||
self.selected = selected
|
||||
UpdateTabLook(self)
|
||||
end
|
||||
tab.MiddleDisabled = tab:CreateTexture(tabname .. "MiddleDisabled", "BORDER")
|
||||
tab.MiddleDisabled:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
|
||||
tab.MiddleDisabled:SetSize(88, 24)
|
||||
tab.MiddleDisabled:SetPoint("LEFT", tab.LeftDisabled, "RIGHT")
|
||||
tab.MiddleDisabled:SetTexCoord(0.15625, 0.84375, 0, 1.0)
|
||||
|
||||
local function Tab_OnClick(self)
|
||||
if not (self.selected or self.disabled) then
|
||||
PlaySound("igCharacterInfoTab")
|
||||
self.obj:SelectTab(self.value)
|
||||
end
|
||||
end
|
||||
tab.RightDisabled = tab:CreateTexture(tabname .. "RightDisabled", "BORDER")
|
||||
tab.RightDisabled:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
|
||||
tab.RightDisabled:SetSize(20, 24)
|
||||
tab.RightDisabled:SetPoint("LEFT", tab.MiddleDisabled, "RIGHT")
|
||||
tab.RightDisabled:SetTexCoord(0.84375, 1.0, 0, 1.0)
|
||||
|
||||
local function Tab_SetDisabled(self, disabled)
|
||||
self.disabled = disabled
|
||||
UpdateTabLook(self)
|
||||
end
|
||||
tab.Left = tab:CreateTexture(tabname .. "Left", "BORDER")
|
||||
tab.Left:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
|
||||
tab.Left:SetSize(20, 24)
|
||||
tab.Left:SetPoint("TOPLEFT")
|
||||
tab.Left:SetTexCoord(0, 0.15625, 0, 1.0)
|
||||
|
||||
local function Tab_OnEnter(this)
|
||||
local self = this.obj
|
||||
self:Fire("OnTabEnter", self.tabs[this.id].value, this)
|
||||
end
|
||||
tab.Middle = tab:CreateTexture(tabname .. "Middle", "BORDER")
|
||||
tab.Middle:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
|
||||
tab.Middle:SetSize(88, 24)
|
||||
tab.Middle:SetPoint("LEFT", tab.Left, "RIGHT")
|
||||
tab.Middle:SetTexCoord(0.15625, 0.84375, 0, 1.0)
|
||||
|
||||
local function Tab_OnLeave(this)
|
||||
local self = this.obj
|
||||
self:Fire("OnTabLeave", self.tabs[this.id].value, this)
|
||||
end
|
||||
tab.Right = tab:CreateTexture(tabname .. "Right", "BORDER")
|
||||
tab.Right:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
|
||||
tab.Right:SetSize(20, 24)
|
||||
tab.Right:SetPoint("LEFT", tab.Middle, "RIGHT")
|
||||
tab.Right:SetTexCoord(0.84375, 1.0, 0, 1.0)
|
||||
|
||||
local function Tab_OnShow(this)
|
||||
_G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30)
|
||||
end
|
||||
tab.Text = tab:CreateFontString(tabname .. "Text")
|
||||
tab:SetFontString(tab.Text)
|
||||
|
||||
tab:SetNormalFontObject(GameFontNormalSmall)
|
||||
tab:SetHighlightFontObject(GameFontHighlightSmall)
|
||||
tab:SetDisabledFontObject(GameFontHighlightSmall)
|
||||
tab:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight", "ADD")
|
||||
tab.HighlightTexture = tab:GetHighlightTexture()
|
||||
tab.HighlightTexture:ClearAllPoints()
|
||||
tab.HighlightTexture:SetPoint("LEFT", tab, "LEFT", 10, -4)
|
||||
tab.HighlightTexture:SetPoint("RIGHT", tab, "RIGHT", -10, -4)
|
||||
_G[tabname .. "HighlightTexture"] = tab.HighlightTexture
|
||||
|
||||
local function CreateTab(self, id)
|
||||
local tabname = "AceGUITabGroup"..self.num.."Tab"..id
|
||||
local tab = CreateFrame("Button",tabname,self.border,"OptionsFrameTabButtonTemplate")
|
||||
tab.obj = self
|
||||
tab.id = id
|
||||
|
||||
tab.text = _G[tabname .. "Text"]
|
||||
tab.text = tab.Text -- compat
|
||||
tab.text:ClearAllPoints()
|
||||
tab.text:SetPoint("LEFT", tab, "LEFT", 14, -3)
|
||||
tab.text:SetPoint("RIGHT", tab, "RIGHT", -12, -3)
|
||||
tab.text:SetPoint("LEFT", 14, -3)
|
||||
tab.text:SetPoint("RIGHT", -12, -3)
|
||||
|
||||
tab:SetScript("OnClick",Tab_OnClick)
|
||||
tab:SetScript("OnEnter",Tab_OnEnter)
|
||||
tab:SetScript("OnLeave",Tab_OnLeave)
|
||||
tab:SetScript("OnClick", Tab_OnClick)
|
||||
tab:SetScript("OnEnter", Tab_OnEnter)
|
||||
tab:SetScript("OnLeave", Tab_OnLeave)
|
||||
tab:SetScript("OnShow", Tab_OnShow)
|
||||
|
||||
tab._SetText = tab.SetText
|
||||
@@ -138,9 +309,9 @@ do
|
||||
tab.SetDisabled = Tab_SetDisabled
|
||||
|
||||
return tab
|
||||
end
|
||||
end,
|
||||
|
||||
local function SetTitle(self, text)
|
||||
["SetTitle"] = function(self, text)
|
||||
self.titletext:SetText(text or "")
|
||||
if text and text ~= "" then
|
||||
self.alignoffset = 25
|
||||
@@ -148,17 +319,15 @@ do
|
||||
self.alignoffset = 18
|
||||
end
|
||||
self:BuildTabs()
|
||||
end
|
||||
end,
|
||||
|
||||
-- called to set an external table to store status in
|
||||
local function SetStatusTable(self, status)
|
||||
["SetStatusTable"] = function(self, status)
|
||||
assert(type(status) == "table")
|
||||
self.status = status
|
||||
end
|
||||
end,
|
||||
|
||||
local function SelectTab(self, value)
|
||||
["SelectTab"] = function(self, value)
|
||||
local status = self.status or self.localstatus
|
||||
|
||||
local found
|
||||
for i, v in ipairs(self.tabs) do
|
||||
if v.value == value then
|
||||
@@ -172,20 +341,16 @@ do
|
||||
if found then
|
||||
self:Fire("OnGroupSelected",value)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
local function SetTabs(self, tabs)
|
||||
["SetTabs"] = function(self, tabs)
|
||||
self.tablist = tabs
|
||||
self:BuildTabs()
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
local widths = {}
|
||||
local rowwidths = {}
|
||||
local rowends = {}
|
||||
local function BuildTabs(self)
|
||||
["BuildTabs"] = function(self)
|
||||
local hastitle = (self.titletext:GetText() and self.titletext:GetText() ~= "")
|
||||
local status = self.status or self.localstatus
|
||||
local tablist = self.tablist
|
||||
local tabs = self.tabs
|
||||
|
||||
@@ -193,15 +358,9 @@ do
|
||||
|
||||
local width = self.frame.width or self.frame:GetWidth() or 0
|
||||
|
||||
for i = #widths, 1, -1 do
|
||||
widths[i] = nil
|
||||
end
|
||||
for i = #rowwidths, 1, -1 do
|
||||
rowwidths[i] = nil
|
||||
end
|
||||
for i = #rowends, 1, -1 do
|
||||
rowends[i] = nil
|
||||
end
|
||||
wipe(widths)
|
||||
wipe(rowwidths)
|
||||
wipe(rowends)
|
||||
|
||||
--Place Text into tabs and get thier initial width
|
||||
for i, v in ipairs(tablist) do
|
||||
@@ -274,27 +433,24 @@ do
|
||||
|
||||
-- equal padding for each tab to fill the available width,
|
||||
-- if the used space is above 75% already
|
||||
-- the 18 pixel is the typical width of a scrollbar, so we can have a tab group inside a scrolling frame,
|
||||
-- and not have the tabs jump around funny when switching between tabs that need scrolling and those that don't
|
||||
local padding = 0
|
||||
if not (numrows == 1 and rowwidths[1] < width*0.75) then
|
||||
if not (numrows == 1 and rowwidths[1] < width*0.75 - 18) then
|
||||
padding = (width - rowwidths[row]) / (endtab - starttab+1)
|
||||
end
|
||||
|
||||
for i = starttab, endtab do
|
||||
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width)
|
||||
PanelTemplates_TabResize(tabs[i], padding + 4, nil, nil, width, tabs[i]:GetFontString():GetStringWidth())
|
||||
end
|
||||
starttab = endtab + 1
|
||||
end
|
||||
|
||||
self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)
|
||||
self.border:SetPoint("TOPLEFT",self.frame,"TOPLEFT",1,-self.borderoffset)
|
||||
end
|
||||
self.border:SetPoint("TOPLEFT", 1, -self.borderoffset)
|
||||
end,
|
||||
|
||||
local function BuildTabsOnUpdate(this)
|
||||
BuildTabs(this.obj)
|
||||
this:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
local function OnWidthSet(self, width)
|
||||
["OnWidthSet"] = function(self, width)
|
||||
local content = self.content
|
||||
local contentwidth = width - 60
|
||||
if contentwidth < 0 then
|
||||
@@ -302,12 +458,11 @@ do
|
||||
end
|
||||
content:SetWidth(contentwidth)
|
||||
content.width = contentwidth
|
||||
BuildTabs(self)
|
||||
self:BuildTabs(self)
|
||||
self.frame:SetScript("OnUpdate", BuildTabsOnUpdate)
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
local function OnHeightSet(self, height)
|
||||
["OnHeightSet"] = function(self, height)
|
||||
local content = self.content
|
||||
local contentheight = height - (self.borderoffset + 23)
|
||||
if contentheight < 0 then
|
||||
@@ -315,75 +470,66 @@ do
|
||||
end
|
||||
content:SetHeight(contentheight)
|
||||
content.height = contentheight
|
||||
end
|
||||
end,
|
||||
|
||||
local function LayoutFinished(self, width, height)
|
||||
["LayoutFinished"] = function(self, width, height)
|
||||
if self.noAutoHeight then return end
|
||||
self:SetHeight((height or 0) + (self.borderoffset + 23))
|
||||
end
|
||||
}
|
||||
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame",nil,UIParent)
|
||||
local self = {}
|
||||
self.type = Type
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Constructor
|
||||
-------------------------------------------------------------------------------]]
|
||||
local PaneBackdrop = {
|
||||
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||
tile = true, tileSize = 16, edgeSize = 16,
|
||||
insets = { left = 3, right = 3, top = 5, bottom = 3 }
|
||||
}
|
||||
|
||||
self.num = AceGUI:GetNextWidgetNum(Type)
|
||||
local function Constructor()
|
||||
local num = AceGUI:GetNextWidgetNum(Type)
|
||||
local frame = CreateFrame("Frame",nil,UIParent)
|
||||
frame:SetHeight(100)
|
||||
frame:SetWidth(100)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
|
||||
self.localstatus = {}
|
||||
local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
|
||||
titletext:SetPoint("TOPLEFT", 14, 0)
|
||||
titletext:SetPoint("TOPRIGHT", -14, 0)
|
||||
titletext:SetJustifyH("LEFT")
|
||||
titletext:SetHeight(18)
|
||||
titletext:SetText("")
|
||||
|
||||
self.OnRelease = OnRelease
|
||||
self.OnAcquire = OnAcquire
|
||||
self.SetTitle = SetTitle
|
||||
self.CreateTab = CreateTab
|
||||
self.SelectTab = SelectTab
|
||||
self.BuildTabs = BuildTabs
|
||||
self.SetStatusTable = SetStatusTable
|
||||
self.SetTabs = SetTabs
|
||||
self.LayoutFinished = LayoutFinished
|
||||
self.frame = frame
|
||||
local border = CreateFrame("Frame", nil, frame, "BackdropTemplate")
|
||||
border:SetPoint("TOPLEFT", 1, -27)
|
||||
border:SetPoint("BOTTOMRIGHT", -1, 3)
|
||||
border:SetBackdrop(PaneBackdrop)
|
||||
border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
|
||||
border:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||
|
||||
self.OnWidthSet = OnWidthSet
|
||||
self.OnHeightSet = OnHeightSet
|
||||
local content = CreateFrame("Frame", nil, border)
|
||||
content:SetPoint("TOPLEFT", 10, -7)
|
||||
content:SetPoint("BOTTOMRIGHT", -10, 7)
|
||||
|
||||
frame.obj = self
|
||||
|
||||
frame:SetHeight(100)
|
||||
frame:SetWidth(100)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
|
||||
self.alignoffset = 18
|
||||
|
||||
local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
|
||||
titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0)
|
||||
titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0)
|
||||
titletext:SetJustifyH("LEFT")
|
||||
titletext:SetHeight(18)
|
||||
titletext:SetText("")
|
||||
|
||||
self.titletext = titletext
|
||||
|
||||
local border = CreateFrame("Frame",nil,frame)
|
||||
self.border = border
|
||||
self.borderoffset = 27
|
||||
border:SetPoint("TOPLEFT",frame,"TOPLEFT",1,-27)
|
||||
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-1,3)
|
||||
|
||||
border:SetBackdrop(PaneBackdrop)
|
||||
border:SetBackdropColor(0.1,0.1,0.1,0.5)
|
||||
border:SetBackdropBorderColor(0.4,0.4,0.4)
|
||||
|
||||
self.tabs = {}
|
||||
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame",nil,border)
|
||||
self.content = content
|
||||
content.obj = self
|
||||
content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-7)
|
||||
content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,7)
|
||||
|
||||
AceGUI:RegisterAsContainer(self)
|
||||
return self
|
||||
local widget = {
|
||||
num = num,
|
||||
frame = frame,
|
||||
localstatus = {},
|
||||
alignoffset = 18,
|
||||
titletext = titletext,
|
||||
border = border,
|
||||
borderoffset = 27,
|
||||
tabs = {},
|
||||
content = content,
|
||||
type = Type
|
||||
}
|
||||
for method, func in pairs(methods) do
|
||||
widget[method] = func
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type,Constructor,Version)
|
||||
return AceGUI:RegisterAsContainer(widget)
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type, Constructor, Version)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,10 +7,6 @@ local pairs, assert, type = pairs, assert, type
|
||||
local PlaySound = PlaySound
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: GameFontNormal
|
||||
|
||||
----------------
|
||||
-- Main Frame --
|
||||
----------------
|
||||
@@ -21,14 +17,18 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
]]
|
||||
do
|
||||
local Type = "Window"
|
||||
local Version = 4
|
||||
local Version = 8
|
||||
|
||||
local function frameOnShow(this)
|
||||
this.obj:Fire("OnShow")
|
||||
end
|
||||
|
||||
local function frameOnClose(this)
|
||||
this.obj:Fire("OnClose")
|
||||
end
|
||||
|
||||
local function closeOnClick(this)
|
||||
PlaySound("gsTitleOptionExit")
|
||||
PlaySound(799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
|
||||
this.obj:Hide()
|
||||
end
|
||||
|
||||
@@ -180,72 +180,77 @@ do
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
frame:SetScript("OnMouseDown", frameOnMouseDown)
|
||||
|
||||
frame:SetScript("OnShow",frameOnShow)
|
||||
frame:SetScript("OnHide",frameOnClose)
|
||||
frame:SetMinResize(240,240)
|
||||
if frame.SetResizeBounds then -- WoW 10.0
|
||||
frame:SetResizeBounds(240,240)
|
||||
else
|
||||
frame:SetMinResize(240,240)
|
||||
end
|
||||
frame:SetToplevel(true)
|
||||
|
||||
local titlebg = frame:CreateTexture(nil, "BACKGROUND")
|
||||
titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]])
|
||||
titlebg:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Title-Background")
|
||||
titlebg:SetPoint("TOPLEFT", 9, -6)
|
||||
titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24)
|
||||
|
||||
local dialogbg = frame:CreateTexture(nil, "BACKGROUND")
|
||||
dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]])
|
||||
dialogbg:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
|
||||
dialogbg:SetPoint("TOPLEFT", 8, -24)
|
||||
dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
|
||||
dialogbg:SetVertexColor(0, 0, 0, .75)
|
||||
|
||||
local topleft = frame:CreateTexture(nil, "BORDER")
|
||||
topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
topleft:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
|
||||
topleft:SetWidth(64)
|
||||
topleft:SetHeight(64)
|
||||
topleft:SetPoint("TOPLEFT")
|
||||
topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
|
||||
|
||||
local topright = frame:CreateTexture(nil, "BORDER")
|
||||
topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
topright:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
|
||||
topright:SetWidth(64)
|
||||
topright:SetHeight(64)
|
||||
topright:SetPoint("TOPRIGHT")
|
||||
topright:SetTexCoord(0.625, 0.75, 0, 1)
|
||||
|
||||
local top = frame:CreateTexture(nil, "BORDER")
|
||||
top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
top:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
|
||||
top:SetHeight(64)
|
||||
top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
|
||||
top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
|
||||
top:SetTexCoord(0.25, 0.369140625, 0, 1)
|
||||
|
||||
local bottomleft = frame:CreateTexture(nil, "BORDER")
|
||||
bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
bottomleft:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
|
||||
bottomleft:SetWidth(64)
|
||||
bottomleft:SetHeight(64)
|
||||
bottomleft:SetPoint("BOTTOMLEFT")
|
||||
bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
|
||||
|
||||
local bottomright = frame:CreateTexture(nil, "BORDER")
|
||||
bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
bottomright:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
|
||||
bottomright:SetWidth(64)
|
||||
bottomright:SetHeight(64)
|
||||
bottomright:SetPoint("BOTTOMRIGHT")
|
||||
bottomright:SetTexCoord(0.875, 1, 0, 1)
|
||||
|
||||
local bottom = frame:CreateTexture(nil, "BORDER")
|
||||
bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
bottom:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
|
||||
bottom:SetHeight(64)
|
||||
bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
|
||||
bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
|
||||
bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
|
||||
|
||||
local left = frame:CreateTexture(nil, "BORDER")
|
||||
left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
left:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
|
||||
left:SetWidth(64)
|
||||
left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
|
||||
left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
|
||||
left:SetTexCoord(0.001953125, 0.125, 0, 1)
|
||||
|
||||
local right = frame:CreateTexture(nil, "BORDER")
|
||||
right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
right:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
|
||||
right:SetWidth(64)
|
||||
right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
|
||||
right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
|
||||
@@ -295,7 +300,7 @@ do
|
||||
line2:SetHeight(8)
|
||||
line2:SetPoint("BOTTOMRIGHT", -8, 8)
|
||||
line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
|
||||
local x = 0.1 * 8/17
|
||||
x = 0.1 * 8/17
|
||||
line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
|
||||
|
||||
local sizer_s = CreateFrame("Frame",nil,frame)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Button Widget
|
||||
Graphical Button.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "Button", 20
|
||||
local Type, Version = "Button", 24
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
@@ -17,9 +17,9 @@ local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Button_OnClick(frame, ...)
|
||||
PlaySound("igMainMenuOption")
|
||||
frame.obj:Fire("OnClick", ...)
|
||||
AceGUI:ClearFocus()
|
||||
PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
|
||||
frame.obj:Fire("OnClick", ...)
|
||||
end
|
||||
|
||||
local function Control_OnEnter(frame)
|
||||
@@ -39,6 +39,7 @@ local methods = {
|
||||
self:SetHeight(24)
|
||||
self:SetWidth(200)
|
||||
self:SetDisabled(false)
|
||||
self:SetAutoWidth(false)
|
||||
self:SetText()
|
||||
end,
|
||||
|
||||
@@ -46,6 +47,16 @@ local methods = {
|
||||
|
||||
["SetText"] = function(self, text)
|
||||
self.text:SetText(text)
|
||||
if self.autoWidth then
|
||||
self:SetWidth(self.text:GetStringWidth() + 30)
|
||||
end
|
||||
end,
|
||||
|
||||
["SetAutoWidth"] = function(self, autoWidth)
|
||||
self.autoWidth = autoWidth
|
||||
if self.autoWidth then
|
||||
self:SetWidth(self.text:GetStringWidth() + 30)
|
||||
end
|
||||
end,
|
||||
|
||||
["SetDisabled"] = function(self, disabled)
|
||||
@@ -63,7 +74,7 @@ Constructor
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Constructor()
|
||||
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
|
||||
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2")
|
||||
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
|
||||
frame:Hide()
|
||||
|
||||
frame:EnableMouse(true)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Checkbox Widget
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "CheckBox", 21
|
||||
local Type, Version = "CheckBox", 26
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
@@ -12,10 +12,6 @@ local select, pairs = select, pairs
|
||||
local PlaySound = PlaySound
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: SetDesaturation, GameFontHighlight
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
@@ -26,7 +22,7 @@ local function AlignImage(self)
|
||||
self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
|
||||
self.text:SetPoint("RIGHT")
|
||||
else
|
||||
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
|
||||
self.text:SetPoint("LEFT", self.image, "RIGHT", 1, 0)
|
||||
self.text:SetPoint("RIGHT")
|
||||
end
|
||||
end
|
||||
@@ -60,9 +56,9 @@ local function CheckBox_OnMouseUp(frame)
|
||||
self:ToggleChecked()
|
||||
|
||||
if self.checked then
|
||||
PlaySound("igMainMenuOptionCheckBoxOn")
|
||||
PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
|
||||
else -- for both nil and false (tristate)
|
||||
PlaySound("igMainMenuOptionCheckBoxOff")
|
||||
PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
|
||||
end
|
||||
|
||||
self:Fire("OnValueChanged", self.checked)
|
||||
@@ -91,7 +87,7 @@ local methods = {
|
||||
if self.desc then
|
||||
self.desc:SetWidth(width - 30)
|
||||
if self.desc:GetText() and self.desc:GetText() ~= "" then
|
||||
self:SetHeight(28 + self.desc:GetHeight())
|
||||
self:SetHeight(28 + self.desc:GetStringHeight())
|
||||
end
|
||||
end
|
||||
end,
|
||||
@@ -102,6 +98,9 @@ local methods = {
|
||||
self.frame:Disable()
|
||||
self.text:SetTextColor(0.5, 0.5, 0.5)
|
||||
SetDesaturation(self.check, true)
|
||||
if self.desc then
|
||||
self.desc:SetTextColor(0.5, 0.5, 0.5)
|
||||
end
|
||||
else
|
||||
self.frame:Enable()
|
||||
self.text:SetTextColor(1, 1, 1)
|
||||
@@ -110,23 +109,26 @@ local methods = {
|
||||
else
|
||||
SetDesaturation(self.check, false)
|
||||
end
|
||||
if self.desc then
|
||||
self.desc:SetTextColor(1, 1, 1)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
["SetValue"] = function(self,value)
|
||||
["SetValue"] = function(self, value)
|
||||
local check = self.check
|
||||
self.checked = value
|
||||
if value then
|
||||
SetDesaturation(self.check, false)
|
||||
self.check:Show()
|
||||
SetDesaturation(check, false)
|
||||
check:Show()
|
||||
else
|
||||
--Nil is the unknown tristate value
|
||||
if self.tristate and value == nil then
|
||||
SetDesaturation(self.check, true)
|
||||
self.check:Show()
|
||||
SetDesaturation(check, true)
|
||||
check:Show()
|
||||
else
|
||||
SetDesaturation(self.check, false)
|
||||
self.check:Hide()
|
||||
SetDesaturation(check, false)
|
||||
check:Hide()
|
||||
end
|
||||
end
|
||||
self:SetDisabled(self.disabled)
|
||||
@@ -193,18 +195,19 @@ local methods = {
|
||||
["SetDescription"] = function(self, desc)
|
||||
if desc then
|
||||
if not self.desc then
|
||||
local desc = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
|
||||
desc:ClearAllPoints()
|
||||
desc:SetPoint("TOPLEFT", self.checkbg, "TOPRIGHT", 5, -21)
|
||||
desc:SetWidth(self.frame.width - 30)
|
||||
desc:SetJustifyH("LEFT")
|
||||
desc:SetJustifyV("TOP")
|
||||
self.desc = desc
|
||||
local f = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
|
||||
f:ClearAllPoints()
|
||||
f:SetPoint("TOPLEFT", self.checkbg, "TOPRIGHT", 5, -21)
|
||||
f:SetWidth(self.frame.width - 30)
|
||||
f:SetPoint("RIGHT", self.frame, "RIGHT", -30, 0)
|
||||
f:SetJustifyH("LEFT")
|
||||
f:SetJustifyV("TOP")
|
||||
self.desc = f
|
||||
end
|
||||
self.desc:Show()
|
||||
--self.text:SetFontObject(GameFontNormal)
|
||||
self.desc:SetText(desc)
|
||||
self:SetHeight(28 + self.desc:GetHeight())
|
||||
self:SetHeight(28 + self.desc:GetStringHeight())
|
||||
else
|
||||
if self.desc then
|
||||
self.desc:SetText("")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--[[-----------------------------------------------------------------------------
|
||||
ColorPicker Widget
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "ColorPicker", 20
|
||||
local Type, Version = "ColorPicker", 28
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
@@ -11,17 +11,24 @@ local pairs = pairs
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: ShowUIPanel, HideUIPanel, ColorPickerFrame, OpacitySliderFrame
|
||||
-- Unfortunately we have no way to realistically detect if a client uses inverted alpha
|
||||
-- as no API will tell you. Wrath uses the old colorpicker, era uses the new one, both are inverted
|
||||
local INVERTED_ALPHA = (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE)
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function ColorCallback(self, r, g, b, a, isAlpha)
|
||||
if INVERTED_ALPHA and a then
|
||||
a = 1 - a
|
||||
end
|
||||
if not self.HasAlpha then
|
||||
a = 1
|
||||
end
|
||||
-- no change, skip update
|
||||
if r == self.r and g == self.g and b == self.b and a == self.a then
|
||||
return
|
||||
end
|
||||
self:SetColor(r, g, b, a)
|
||||
if ColorPickerFrame:IsVisible() then
|
||||
--colorpicker is still open
|
||||
@@ -47,35 +54,70 @@ local function Control_OnLeave(frame)
|
||||
end
|
||||
|
||||
local function ColorSwatch_OnClick(frame)
|
||||
HideUIPanel(ColorPickerFrame)
|
||||
ColorPickerFrame:Hide()
|
||||
local self = frame.obj
|
||||
if not self.disabled then
|
||||
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10)
|
||||
ColorPickerFrame:SetClampedToScreen(true)
|
||||
|
||||
ColorPickerFrame.func = function()
|
||||
local r, g, b = ColorPickerFrame:GetColorRGB()
|
||||
local a = 1 - OpacitySliderFrame:GetValue()
|
||||
ColorCallback(self, r, g, b, a)
|
||||
if ColorPickerFrame.SetupColorPickerAndShow then -- 10.2.5 color picker overhaul
|
||||
local r2, g2, b2, a2 = self.r, self.g, self.b, (self.a or 1)
|
||||
if INVERTED_ALPHA then
|
||||
a2 = 1 - a2
|
||||
end
|
||||
|
||||
local info = {
|
||||
swatchFunc = function()
|
||||
local r, g, b = ColorPickerFrame:GetColorRGB()
|
||||
local a = ColorPickerFrame:GetColorAlpha()
|
||||
ColorCallback(self, r, g, b, a)
|
||||
end,
|
||||
|
||||
hasOpacity = self.HasAlpha,
|
||||
opacityFunc = function()
|
||||
local r, g, b = ColorPickerFrame:GetColorRGB()
|
||||
local a = ColorPickerFrame:GetColorAlpha()
|
||||
ColorCallback(self, r, g, b, a, true)
|
||||
end,
|
||||
opacity = a2,
|
||||
|
||||
cancelFunc = function()
|
||||
ColorCallback(self, r2, g2, b2, a2, true)
|
||||
end,
|
||||
|
||||
r = r2,
|
||||
g = g2,
|
||||
b = b2,
|
||||
}
|
||||
|
||||
ColorPickerFrame:SetupColorPickerAndShow(info)
|
||||
else
|
||||
ColorPickerFrame.func = function()
|
||||
local r, g, b = ColorPickerFrame:GetColorRGB()
|
||||
local a = OpacitySliderFrame:GetValue()
|
||||
ColorCallback(self, r, g, b, a)
|
||||
end
|
||||
|
||||
ColorPickerFrame.hasOpacity = self.HasAlpha
|
||||
ColorPickerFrame.opacityFunc = function()
|
||||
local r, g, b = ColorPickerFrame:GetColorRGB()
|
||||
local a = OpacitySliderFrame:GetValue()
|
||||
ColorCallback(self, r, g, b, a, true)
|
||||
end
|
||||
|
||||
local r, g, b, a = self.r, self.g, self.b, 1 - (self.a or 1)
|
||||
if self.HasAlpha then
|
||||
ColorPickerFrame.opacity = a
|
||||
end
|
||||
ColorPickerFrame:SetColorRGB(r, g, b)
|
||||
|
||||
ColorPickerFrame.cancelFunc = function()
|
||||
ColorCallback(self, r, g, b, a, true)
|
||||
end
|
||||
|
||||
ColorPickerFrame:Show()
|
||||
end
|
||||
|
||||
ColorPickerFrame.hasOpacity = self.HasAlpha
|
||||
ColorPickerFrame.opacityFunc = function()
|
||||
local r, g, b = ColorPickerFrame:GetColorRGB()
|
||||
local a = 1 - OpacitySliderFrame:GetValue()
|
||||
ColorCallback(self, r, g, b, a, true)
|
||||
end
|
||||
|
||||
local r, g, b, a = self.r, self.g, self.b, self.a
|
||||
if self.HasAlpha then
|
||||
ColorPickerFrame.opacity = 1 - (a or 0)
|
||||
end
|
||||
ColorPickerFrame:SetColorRGB(r, g, b)
|
||||
|
||||
ColorPickerFrame.cancelFunc = function()
|
||||
ColorCallback(self, r, g, b, a, true)
|
||||
end
|
||||
|
||||
ShowUIPanel(ColorPickerFrame)
|
||||
end
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
@@ -142,13 +184,15 @@ local function Constructor()
|
||||
colorSwatch:SetPoint("LEFT")
|
||||
|
||||
local texture = frame:CreateTexture(nil, "BACKGROUND")
|
||||
colorSwatch.background = texture
|
||||
texture:SetWidth(16)
|
||||
texture:SetHeight(16)
|
||||
texture:SetTexture(1, 1, 1)
|
||||
texture:SetColorTexture(1, 1, 1)
|
||||
texture:SetPoint("CENTER", colorSwatch)
|
||||
texture:Show()
|
||||
|
||||
local checkers = frame:CreateTexture(nil, "BACKGROUND")
|
||||
colorSwatch.checkers = checkers
|
||||
checkers:SetWidth(14)
|
||||
checkers:SetHeight(14)
|
||||
checkers:SetTexture("Tileset\\Generic\\Checkers")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
--[[ $Id: AceGUIWidget-DropDown-Items.lua 916 2010-03-15 12:24:36Z nevcairiel $ ]]--
|
||||
--[[ $Id$ ]]--
|
||||
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
|
||||
@@ -41,7 +41,7 @@ local ItemBase = {
|
||||
-- NOTE: The ItemBase version is added to each item's version number
|
||||
-- to ensure proper updates on ItemBase changes.
|
||||
-- Use at least 1000er steps.
|
||||
version = 1000,
|
||||
version = 2000,
|
||||
counter = 0,
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ function ItemBase.Create(type)
|
||||
highlight:Hide()
|
||||
self.highlight = highlight
|
||||
|
||||
local check = frame:CreateTexture("OVERLAY")
|
||||
local check = frame:CreateTexture(nil, "OVERLAY")
|
||||
check:SetWidth(16)
|
||||
check:SetHeight(16)
|
||||
check:SetPoint("LEFT",frame,"LEFT",3,-1)
|
||||
@@ -186,7 +186,7 @@ function ItemBase.Create(type)
|
||||
check:Hide()
|
||||
self.check = check
|
||||
|
||||
local sub = frame:CreateTexture("OVERLAY")
|
||||
local sub = frame:CreateTexture(nil, "OVERLAY")
|
||||
sub:SetWidth(16)
|
||||
sub:SetHeight(16)
|
||||
sub:SetPoint("RIGHT",frame,"RIGHT",-3,-1)
|
||||
@@ -215,6 +215,12 @@ function ItemBase.Create(type)
|
||||
return self
|
||||
end
|
||||
|
||||
-- Register a dummy LibStub library to retrieve the ItemBase, so other addons can use it.
|
||||
local IBLib = LibStub:NewLibrary("AceGUI-3.0-DropDown-ItemBase", ItemBase.version)
|
||||
if IBLib then
|
||||
IBLib.GetItemBase = function() return ItemBase end
|
||||
end
|
||||
|
||||
--[[
|
||||
Template for items:
|
||||
|
||||
@@ -317,7 +323,7 @@ end
|
||||
-- Does not close the pullout on click.
|
||||
do
|
||||
local widgetType = "Dropdown-Item-Toggle"
|
||||
local widgetVersion = 3
|
||||
local widgetVersion = 4
|
||||
|
||||
local function UpdateToggle(self)
|
||||
if self.value then
|
||||
@@ -337,9 +343,9 @@ do
|
||||
if self.disabled then return end
|
||||
self.value = not self.value
|
||||
if self.value then
|
||||
PlaySound("igMainMenuOptionCheckBoxOn")
|
||||
PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
|
||||
else
|
||||
PlaySound("igMainMenuOptionCheckBoxOff")
|
||||
PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
|
||||
end
|
||||
UpdateToggle(self)
|
||||
self:Fire("OnValueChanged", self.value)
|
||||
@@ -434,7 +440,7 @@ end
|
||||
-- A single line to separate items
|
||||
do
|
||||
local widgetType = "Dropdown-Item-Separator"
|
||||
local widgetVersion = 1
|
||||
local widgetVersion = 2
|
||||
|
||||
-- exported, override
|
||||
local function SetDisabled(self, disabled)
|
||||
@@ -449,7 +455,7 @@ do
|
||||
|
||||
local line = self.frame:CreateTexture(nil, "OVERLAY")
|
||||
line:SetHeight(1)
|
||||
line:SetTexture(.5, .5, .5)
|
||||
line:SetColorTexture(.5, .5, .5)
|
||||
line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
|
||||
line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--[[ $Id: AceGUIWidget-DropDown.lua 916 2010-03-15 12:24:36Z nevcairiel $ ]]--
|
||||
--[[ $Id$ ]]--
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
|
||||
-- Lua APIs
|
||||
local min, max, floor = math.min, math.max, math.floor
|
||||
local select, pairs, ipairs = select, pairs, ipairs
|
||||
local select, pairs, ipairs, type, tostring = select, pairs, ipairs, type, tostring
|
||||
local tsort = table.sort
|
||||
|
||||
-- WoW APIs
|
||||
@@ -11,10 +11,6 @@ local PlaySound = PlaySound
|
||||
local UIParent, CreateFrame = UIParent, CreateFrame
|
||||
local _G = _G
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: CLOSE
|
||||
|
||||
local function fixlevels(parent,...)
|
||||
local i = 1
|
||||
local child = select(i, ...)
|
||||
@@ -39,7 +35,7 @@ end
|
||||
|
||||
do
|
||||
local widgetType = "Dropdown-Pullout"
|
||||
local widgetVersion = 3
|
||||
local widgetVersion = 5
|
||||
|
||||
--[[ Static data ]]--
|
||||
|
||||
@@ -193,12 +189,7 @@ do
|
||||
|
||||
local height = 8
|
||||
for i, item in pairs(items) do
|
||||
if i == 1 then
|
||||
item:SetPoint("TOP", itemFrame, "TOP", 0, -2)
|
||||
else
|
||||
item:SetPoint("TOP", items[i-1].frame, "BOTTOM", 0, 1)
|
||||
end
|
||||
|
||||
item:SetPoint("TOP", itemFrame, "TOP", 0, -2 + (i - 1) * -16)
|
||||
item:Show()
|
||||
|
||||
height = height + 16
|
||||
@@ -258,7 +249,7 @@ do
|
||||
|
||||
local function Constructor()
|
||||
local count = AceGUI:GetNextWidgetNum(widgetType)
|
||||
local frame = CreateFrame("Frame", "AceGUI30Pullout"..count, UIParent)
|
||||
local frame = CreateFrame("Frame", "AceGUI30Pullout"..count, UIParent, "BackdropTemplate")
|
||||
local self = {}
|
||||
self.count = count
|
||||
self.type = widgetType
|
||||
@@ -309,7 +300,7 @@ do
|
||||
scrollFrame.obj = self
|
||||
itemFrame.obj = self
|
||||
|
||||
local slider = CreateFrame("Slider", "AceGUI30PulloutScrollbar"..count, scrollFrame)
|
||||
local slider = CreateFrame("Slider", "AceGUI30PulloutScrollbar"..count, scrollFrame, "BackdropTemplate")
|
||||
slider:SetOrientation("VERTICAL")
|
||||
slider:SetHitRectInsets(0, 0, -10, 0)
|
||||
slider:SetBackdrop(sliderBackdrop)
|
||||
@@ -356,17 +347,19 @@ end
|
||||
|
||||
do
|
||||
local widgetType = "Dropdown"
|
||||
local widgetVersion = 22
|
||||
local widgetVersion = 36
|
||||
|
||||
--[[ Static data ]]--
|
||||
|
||||
--[[ UI event handler ]]--
|
||||
|
||||
local function Control_OnEnter(this)
|
||||
this.obj.button:LockHighlight()
|
||||
this.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave(this)
|
||||
this.obj.button:UnlockHighlight()
|
||||
this.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
@@ -379,14 +372,13 @@ do
|
||||
|
||||
local function Dropdown_TogglePullout(this)
|
||||
local self = this.obj
|
||||
PlaySound("igMainMenuOptionCheckBoxOn") -- missleading name, but the Blizzard code uses this sound
|
||||
if self.open then
|
||||
self.open = nil
|
||||
self.pullout:Close()
|
||||
AceGUI:ClearFocus()
|
||||
else
|
||||
self.open = true
|
||||
self.pullout:SetWidth(self.frame:GetWidth())
|
||||
self.pullout:SetWidth(self.pulloutWidth or self.frame:GetWidth())
|
||||
self.pullout:Open("TOPLEFT", self.frame, "BOTTOMLEFT", 0, self.label:IsShown() and -2 or 0)
|
||||
AceGUI:SetFocus(self)
|
||||
end
|
||||
@@ -403,6 +395,7 @@ do
|
||||
end
|
||||
|
||||
self.open = true
|
||||
self:Fire("OnOpened")
|
||||
end
|
||||
|
||||
local function OnPulloutClose(this)
|
||||
@@ -460,6 +453,9 @@ do
|
||||
|
||||
self:SetHeight(44)
|
||||
self:SetWidth(200)
|
||||
self:SetLabel()
|
||||
self:SetPulloutWidth(nil)
|
||||
self.list = {}
|
||||
end
|
||||
|
||||
-- exported, AceGUI callback
|
||||
@@ -471,7 +467,6 @@ do
|
||||
self.pullout = nil
|
||||
|
||||
self:SetText("")
|
||||
self:SetLabel("")
|
||||
self:SetDisabled(false)
|
||||
self:SetMultiselect(false)
|
||||
|
||||
@@ -490,9 +485,11 @@ do
|
||||
if disabled then
|
||||
self.text:SetTextColor(0.5,0.5,0.5)
|
||||
self.button:Disable()
|
||||
self.button_cover:Disable()
|
||||
self.label:SetTextColor(0.5,0.5,0.5)
|
||||
else
|
||||
self.button:Enable()
|
||||
self.button_cover:Enable()
|
||||
self.label:SetTextColor(1,.82,0)
|
||||
self.text:SetTextColor(1,1,1)
|
||||
end
|
||||
@@ -515,21 +512,21 @@ do
|
||||
if text and text ~= "" then
|
||||
self.label:SetText(text)
|
||||
self.label:Show()
|
||||
self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,-18)
|
||||
self.frame:SetHeight(44)
|
||||
self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,-14)
|
||||
self:SetHeight(40)
|
||||
self.alignoffset = 26
|
||||
else
|
||||
self.label:SetText("")
|
||||
self.label:Hide()
|
||||
self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,0)
|
||||
self.frame:SetHeight(26)
|
||||
self:SetHeight(26)
|
||||
self.alignoffset = 12
|
||||
end
|
||||
end
|
||||
|
||||
-- exported
|
||||
local function SetValue(self, value)
|
||||
if self.list then
|
||||
self:SetText(self.list[value] or "")
|
||||
end
|
||||
self:SetText(self.list[value] or "")
|
||||
self.value = value
|
||||
end
|
||||
|
||||
@@ -560,8 +557,12 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local function AddListItem(self, value, text)
|
||||
local item = AceGUI:Create("Dropdown-Item-Toggle")
|
||||
local function AddListItem(self, value, text, itemType)
|
||||
if not itemType then itemType = "Dropdown-Item-Toggle" end
|
||||
local exists = AceGUI:GetWidgetVersion(itemType)
|
||||
if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end
|
||||
|
||||
local item = AceGUI:Create(itemType)
|
||||
item:SetText(text)
|
||||
item.userdata.obj = self
|
||||
item.userdata.value = value
|
||||
@@ -580,20 +581,34 @@ do
|
||||
|
||||
-- exported
|
||||
local sortlist = {}
|
||||
local function SetList(self, list)
|
||||
self.list = list
|
||||
local function sortTbl(x,y)
|
||||
local num1, num2 = tonumber(x), tonumber(y)
|
||||
if num1 and num2 then -- numeric comparison, either two numbers or numeric strings
|
||||
return num1 < num2
|
||||
else -- compare everything else tostring'ed
|
||||
return tostring(x) < tostring(y)
|
||||
end
|
||||
end
|
||||
local function SetList(self, list, order, itemType)
|
||||
self.list = list or {}
|
||||
self.pullout:Clear()
|
||||
self.hasClose = nil
|
||||
if not list then return end
|
||||
|
||||
for v in pairs(list) do
|
||||
sortlist[#sortlist + 1] = v
|
||||
end
|
||||
tsort(sortlist)
|
||||
if type(order) ~= "table" then
|
||||
for v in pairs(list) do
|
||||
sortlist[#sortlist + 1] = v
|
||||
end
|
||||
tsort(sortlist, sortTbl)
|
||||
|
||||
for i, value in pairs(sortlist) do
|
||||
AddListItem(self, value, list[value])
|
||||
sortlist[i] = nil
|
||||
for i, key in ipairs(sortlist) do
|
||||
AddListItem(self, key, list[key], itemType)
|
||||
sortlist[i] = nil
|
||||
end
|
||||
else
|
||||
for i, key in ipairs(order) do
|
||||
AddListItem(self, key, list[key], itemType)
|
||||
end
|
||||
end
|
||||
if self.multiselect then
|
||||
ShowMultiText(self)
|
||||
@@ -602,11 +617,9 @@ do
|
||||
end
|
||||
|
||||
-- exported
|
||||
local function AddItem(self, value, text)
|
||||
if self.list then
|
||||
self.list[value] = text
|
||||
AddListItem(self, value, text)
|
||||
end
|
||||
local function AddItem(self, value, text, itemType)
|
||||
self.list[value] = text
|
||||
AddListItem(self, value, text, itemType)
|
||||
end
|
||||
|
||||
-- exported
|
||||
@@ -623,6 +636,10 @@ do
|
||||
return self.multiselect
|
||||
end
|
||||
|
||||
local function SetPulloutWidth(self, width)
|
||||
self.pulloutWidth = width
|
||||
end
|
||||
|
||||
--[[ Constructor ]]--
|
||||
|
||||
local function Constructor()
|
||||
@@ -654,11 +671,10 @@ do
|
||||
self.GetMultiselect = GetMultiselect
|
||||
self.SetItemValue = SetItemValue
|
||||
self.SetItemDisabled = SetItemDisabled
|
||||
self.SetPulloutWidth = SetPulloutWidth
|
||||
|
||||
self.alignoffset = 31
|
||||
self.alignoffset = 26
|
||||
|
||||
frame:SetHeight(44)
|
||||
frame:SetWidth(200)
|
||||
frame:SetScript("OnHide",Dropdown_OnHide)
|
||||
|
||||
dropdown:ClearAllPoints()
|
||||
@@ -684,6 +700,15 @@ do
|
||||
button:SetScript("OnLeave",Control_OnLeave)
|
||||
button:SetScript("OnClick",Dropdown_TogglePullout)
|
||||
|
||||
local button_cover = CreateFrame("BUTTON",nil,self.frame)
|
||||
self.button_cover = button_cover
|
||||
button_cover.obj = self
|
||||
button_cover:SetPoint("TOPLEFT",self.frame,"BOTTOMLEFT",0,25)
|
||||
button_cover:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT")
|
||||
button_cover:SetScript("OnEnter",Control_OnEnter)
|
||||
button_cover:SetScript("OnLeave",Control_OnLeave)
|
||||
button_cover:SetScript("OnClick",Dropdown_TogglePullout)
|
||||
|
||||
local text = _G[dropdown:GetName() .. "Text"]
|
||||
self.text = text
|
||||
text.obj = self
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--[[-----------------------------------------------------------------------------
|
||||
EditBox Widget
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "EditBox", 20
|
||||
local Type, Version = "EditBox", 29
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
@@ -10,20 +10,20 @@ local tostring, pairs = tostring, pairs
|
||||
|
||||
-- WoW APIs
|
||||
local PlaySound = PlaySound
|
||||
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName
|
||||
local GetCursorInfo, ClearCursor = GetCursorInfo, ClearCursor
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
local _G = _G
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
if not AceGUIEditBoxInsertLink then
|
||||
-- upgradeable hook
|
||||
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
|
||||
if ChatFrameUtil and ChatFrameUtil.InsertLink then
|
||||
hooksecurefunc(ChatFrameUtil, "InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
|
||||
elseif ChatEdit_InsertLink then
|
||||
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
|
||||
end
|
||||
end
|
||||
|
||||
function _G.AceGUIEditBoxInsertLink(text)
|
||||
@@ -59,6 +59,11 @@ local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
local function Frame_OnShowFocus(frame)
|
||||
frame.obj.editbox:SetFocus()
|
||||
frame:SetScript("OnShow", nil)
|
||||
end
|
||||
|
||||
local function EditBox_OnEscapePressed(frame)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
@@ -68,29 +73,33 @@ local function EditBox_OnEnterPressed(frame)
|
||||
local value = frame:GetText()
|
||||
local cancel = self:Fire("OnEnterPressed", value)
|
||||
if not cancel then
|
||||
PlaySound("igMainMenuOptionCheckBoxOn")
|
||||
PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
|
||||
HideButton(self)
|
||||
end
|
||||
end
|
||||
|
||||
local function EditBox_OnReceiveDrag(frame)
|
||||
local self = frame.obj
|
||||
local type, id, info = GetCursorInfo()
|
||||
local type, id, info, extra = GetCursorInfo()
|
||||
local name
|
||||
if type == "item" then
|
||||
self:SetText(info)
|
||||
self:Fire("OnEnterPressed", info)
|
||||
ClearCursor()
|
||||
name = info
|
||||
elseif type == "spell" then
|
||||
local name, rank = GetSpellName(id, info)
|
||||
if rank and rank:match("%d") then
|
||||
name = name.."("..rank..")"
|
||||
if C_Spell and C_Spell.GetSpellName then
|
||||
name = C_Spell.GetSpellName(extra)
|
||||
else
|
||||
name = GetSpellInfo(id, info)
|
||||
end
|
||||
elseif type == "macro" then
|
||||
name = GetMacroInfo(id)
|
||||
end
|
||||
if name then
|
||||
self:SetText(name)
|
||||
self:Fire("OnEnterPressed", name)
|
||||
ClearCursor()
|
||||
HideButton(self)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
HideButton(self)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function EditBox_OnTextChanged(frame)
|
||||
@@ -103,6 +112,10 @@ local function EditBox_OnTextChanged(frame)
|
||||
end
|
||||
end
|
||||
|
||||
local function EditBox_OnFocusGained(frame)
|
||||
AceGUI:SetFocus(frame.obj)
|
||||
end
|
||||
|
||||
local function Button_OnClick(frame)
|
||||
local editbox = frame.obj.editbox
|
||||
editbox:ClearFocus()
|
||||
@@ -120,9 +133,12 @@ local methods = {
|
||||
self:SetLabel()
|
||||
self:SetText()
|
||||
self:DisableButton(false)
|
||||
self:SetMaxLetters(0)
|
||||
end,
|
||||
|
||||
-- ["OnRelease"] = nil,
|
||||
["OnRelease"] = function(self)
|
||||
self:ClearFocus()
|
||||
end,
|
||||
|
||||
["SetDisabled"] = function(self, disabled)
|
||||
self.disabled = disabled
|
||||
@@ -145,6 +161,10 @@ local methods = {
|
||||
HideButton(self)
|
||||
end,
|
||||
|
||||
["GetText"] = function(self, text)
|
||||
return self.editbox:GetText()
|
||||
end,
|
||||
|
||||
["SetLabel"] = function(self, text)
|
||||
if text and text ~= "" then
|
||||
self.label:SetText(text)
|
||||
@@ -163,6 +183,29 @@ local methods = {
|
||||
|
||||
["DisableButton"] = function(self, disabled)
|
||||
self.disablebutton = disabled
|
||||
if disabled then
|
||||
HideButton(self)
|
||||
end
|
||||
end,
|
||||
|
||||
["SetMaxLetters"] = function (self, num)
|
||||
self.editbox:SetMaxLetters(num or 0)
|
||||
end,
|
||||
|
||||
["ClearFocus"] = function(self)
|
||||
self.editbox:ClearFocus()
|
||||
self.frame:SetScript("OnShow", nil)
|
||||
end,
|
||||
|
||||
["SetFocus"] = function(self)
|
||||
self.editbox:SetFocus()
|
||||
if not self.frame:IsShown() then
|
||||
self.frame:SetScript("OnShow", Frame_OnShowFocus)
|
||||
end
|
||||
end,
|
||||
|
||||
["HighlightText"] = function(self, from, to)
|
||||
self.editbox:HighlightText(from, to)
|
||||
end
|
||||
}
|
||||
|
||||
@@ -184,6 +227,7 @@ local function Constructor()
|
||||
editbox:SetScript("OnTextChanged", EditBox_OnTextChanged)
|
||||
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
|
||||
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
|
||||
editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
|
||||
editbox:SetTextInsets(0, 0, 3, 3)
|
||||
editbox:SetMaxLetters(256)
|
||||
editbox:SetPoint("BOTTOMLEFT", 6, 0)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Icon Widget
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "Icon", 20
|
||||
local Type, Version = "Icon", 21
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
-- Lua APIs
|
||||
local select, pairs = select, pairs
|
||||
local select, pairs, print = select, pairs, print
|
||||
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
@@ -87,7 +87,7 @@ local methods = {
|
||||
else
|
||||
self.frame:Enable()
|
||||
self.label:SetTextColor(1, 1, 1)
|
||||
self.image:SetVertexColor(1, 1, 1)
|
||||
self.image:SetVertexColor(1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -131,12 +131,8 @@ local function Constructor()
|
||||
for method, func in pairs(methods) do
|
||||
widget[method] = func
|
||||
end
|
||||
-- SetText is deprecated, but keep it around for a while. (say, to WoW 4.0)
|
||||
if (select(4, GetBuildInfo()) < 40000) then
|
||||
widget.SetText = widget.SetLabel
|
||||
else
|
||||
widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end
|
||||
end
|
||||
|
||||
widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end
|
||||
|
||||
return AceGUI:RegisterAsWidget(widget)
|
||||
end
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
--[[-----------------------------------------------------------------------------
|
||||
InteractiveLabel Widget
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "InteractiveLabel", 20
|
||||
local Type, Version = "InteractiveLabel", 21
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
-- Lua APIs
|
||||
local select, pairs = select, pairs
|
||||
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: GameFontHighlightSmall
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Keybinding Widget
|
||||
Set Keybindings in the Config UI.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "Keybinding", 21
|
||||
local Type, Version = "Keybinding", 27
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
@@ -13,10 +13,6 @@ local pairs = pairs
|
||||
local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: NOT_BOUND
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
@@ -34,11 +30,15 @@ local function Keybinding_OnClick(frame, button)
|
||||
local self = frame.obj
|
||||
if self.waitingForKey then
|
||||
frame:EnableKeyboard(false)
|
||||
frame:EnableMouseWheel(false)
|
||||
frame:EnableGamePadButton(false)
|
||||
self.msgframe:Hide()
|
||||
frame:UnlockHighlight()
|
||||
self.waitingForKey = nil
|
||||
else
|
||||
frame:EnableKeyboard(true)
|
||||
frame:EnableMouseWheel(true)
|
||||
frame:EnableGamePadButton(true)
|
||||
self.msgframe:Show()
|
||||
frame:LockHighlight()
|
||||
self.waitingForKey = true
|
||||
@@ -73,6 +73,8 @@ local function Keybinding_OnKeyDown(frame, key)
|
||||
end
|
||||
|
||||
frame:EnableKeyboard(false)
|
||||
frame:EnableMouseWheel(false)
|
||||
frame:EnableGamePadButton(false)
|
||||
self.msgframe:Hide()
|
||||
frame:UnlockHighlight()
|
||||
self.waitingForKey = nil
|
||||
@@ -97,6 +99,16 @@ local function Keybinding_OnMouseDown(frame, button)
|
||||
Keybinding_OnKeyDown(frame, button)
|
||||
end
|
||||
|
||||
local function Keybinding_OnMouseWheel(frame, direction)
|
||||
local button
|
||||
if direction >= 0 then
|
||||
button = "MOUSEWHEELUP"
|
||||
else
|
||||
button = "MOUSEWHEELDOWN"
|
||||
end
|
||||
Keybinding_OnKeyDown(frame, button)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Methods
|
||||
-------------------------------------------------------------------------------]]
|
||||
@@ -108,6 +120,9 @@ local methods = {
|
||||
self.waitingForKey = nil
|
||||
self.msgframe:Hide()
|
||||
self:SetDisabled(false)
|
||||
self.button:EnableKeyboard(false)
|
||||
self.button:EnableMouseWheel(false)
|
||||
self.button:EnableGamePadButton(false)
|
||||
end,
|
||||
|
||||
-- ["OnRelease"] = nil,
|
||||
@@ -173,18 +188,23 @@ local function Constructor()
|
||||
local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type)
|
||||
|
||||
local frame = CreateFrame("Frame", nil, UIParent)
|
||||
local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate2")
|
||||
local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate")
|
||||
|
||||
button:EnableMouse(true)
|
||||
button:EnableMouseWheel(false)
|
||||
button:RegisterForClicks("AnyDown")
|
||||
button:SetScript("OnEnter", Control_OnEnter)
|
||||
button:SetScript("OnLeave", Control_OnLeave)
|
||||
button:SetScript("OnClick", Keybinding_OnClick)
|
||||
button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
|
||||
button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
|
||||
button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
|
||||
pcall(button.SetScript, button, "OnGamePadButtonDown", Keybinding_OnKeyDown)
|
||||
button:SetPoint("BOTTOMLEFT")
|
||||
button:SetPoint("BOTTOMRIGHT")
|
||||
button:SetHeight(24)
|
||||
button:EnableKeyboard(false)
|
||||
button:EnableGamePadButton(false)
|
||||
|
||||
local text = button:GetFontString()
|
||||
text:SetPoint("LEFT", 7, 0)
|
||||
@@ -196,12 +216,13 @@ local function Constructor()
|
||||
label:SetJustifyH("CENTER")
|
||||
label:SetHeight(18)
|
||||
|
||||
local msgframe = CreateFrame("Frame", nil, UIParent)
|
||||
local msgframe = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
|
||||
msgframe:SetHeight(30)
|
||||
msgframe:SetBackdrop(ControlBackdrop)
|
||||
msgframe:SetBackdropColor(0,0,0)
|
||||
msgframe:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
msgframe:SetFrameLevel(1000)
|
||||
msgframe:SetToplevel(true)
|
||||
|
||||
local msg = msgframe:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||
msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel.")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Label Widget
|
||||
Displays text and optionally an icon.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "Label", 21
|
||||
local Type, Version = "Label", 28
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
@@ -12,10 +12,6 @@ local max, select, pairs = math.max, select, pairs
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: GameFontHighlightSmall
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
@@ -39,19 +35,28 @@ local function UpdateImageAnchor(self)
|
||||
label:SetPoint("TOP", image, "BOTTOM")
|
||||
label:SetPoint("LEFT")
|
||||
label:SetWidth(width)
|
||||
height = image:GetHeight() + label:GetHeight()
|
||||
height = image:GetHeight() + label:GetStringHeight()
|
||||
else
|
||||
-- image on the left
|
||||
image:SetPoint("TOPLEFT")
|
||||
label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0)
|
||||
if image:GetHeight() > label:GetStringHeight() then
|
||||
label:SetPoint("LEFT", image, "RIGHT", 4, 0)
|
||||
else
|
||||
label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0)
|
||||
end
|
||||
label:SetWidth(width - imagewidth - 4)
|
||||
height = max(image:GetHeight(), label:GetHeight())
|
||||
height = max(image:GetHeight(), label:GetStringHeight())
|
||||
end
|
||||
else
|
||||
-- no image shown
|
||||
label:SetPoint("TOPLEFT")
|
||||
label:SetWidth(width)
|
||||
height = label:GetHeight()
|
||||
height = label:GetStringHeight()
|
||||
end
|
||||
|
||||
-- avoid zero-height labels, since they can used as spacers
|
||||
if not height or height == 0 then
|
||||
height = 1
|
||||
end
|
||||
|
||||
self.resizing = true
|
||||
@@ -74,6 +79,8 @@ local methods = {
|
||||
self:SetImageSize(16, 16)
|
||||
self:SetColor()
|
||||
self:SetFontObject()
|
||||
self:SetJustifyH("LEFT")
|
||||
self:SetJustifyV("TOP")
|
||||
|
||||
-- reset the flag
|
||||
self.resizing = nil
|
||||
@@ -118,11 +125,16 @@ local methods = {
|
||||
end,
|
||||
|
||||
["SetFont"] = function(self, font, height, flags)
|
||||
self.label:SetFont(font, height, flags)
|
||||
if not self.fontObject then
|
||||
self.fontObject = CreateFont("AceGUI30LabelFont" .. AceGUI:GetNextWidgetNum(Type))
|
||||
end
|
||||
self.fontObject:SetFont(font, height, flags)
|
||||
self:SetFontObject(self.fontObject)
|
||||
end,
|
||||
|
||||
["SetFontObject"] = function(self, font)
|
||||
self:SetFont((font or GameFontHighlightSmall):GetFont())
|
||||
self.label:SetFontObject(font or GameFontHighlightSmall)
|
||||
UpdateImageAnchor(self)
|
||||
end,
|
||||
|
||||
["SetImageSize"] = function(self, width, height)
|
||||
@@ -130,6 +142,14 @@ local methods = {
|
||||
self.image:SetHeight(height)
|
||||
UpdateImageAnchor(self)
|
||||
end,
|
||||
|
||||
["SetJustifyH"] = function(self, justifyH)
|
||||
self.label:SetJustifyH(justifyH)
|
||||
end,
|
||||
|
||||
["SetJustifyV"] = function(self, justifyV)
|
||||
self.label:SetJustifyV(justifyV)
|
||||
end,
|
||||
}
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -140,9 +160,6 @@ local function Constructor()
|
||||
frame:Hide()
|
||||
|
||||
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall")
|
||||
label:SetJustifyH("LEFT")
|
||||
label:SetJustifyV("TOP")
|
||||
|
||||
local image = frame:CreateTexture(nil, "BACKGROUND")
|
||||
|
||||
-- create widget
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
local Type, Version = "MultiLineEditBox", 20
|
||||
local Type, Version = "MultiLineEditBox", 33
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
@@ -6,13 +6,51 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
local pairs = pairs
|
||||
|
||||
-- WoW APIs
|
||||
local GetCursorInfo, GetSpellName, ClearCursor = GetCursorInfo, GetSpellName, ClearCursor
|
||||
local GetCursorInfo, ClearCursor = GetCursorInfo, ClearCursor
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
local _G = _G
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: ACCEPT, ChatFontNormal
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
|
||||
if not AceGUIMultiLineEditBoxInsertLink then
|
||||
-- upgradeable hook
|
||||
if ChatFrameUtil and ChatFrameUtil.InsertLink then
|
||||
hooksecurefunc(ChatFrameUtil, "InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end)
|
||||
elseif ChatEdit_InsertLink then
|
||||
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end)
|
||||
end
|
||||
end
|
||||
|
||||
function _G.AceGUIMultiLineEditBoxInsertLink(text)
|
||||
for i = 1, AceGUI:GetWidgetCount(Type) do
|
||||
local editbox = _G[("MultiLineEditBox%uEdit"):format(i)]
|
||||
if editbox and editbox:IsVisible() and editbox:HasFocus() then
|
||||
editbox:Insert(text)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function Layout(self)
|
||||
self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight)
|
||||
|
||||
if self.labelHeight == 0 then
|
||||
self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23)
|
||||
else
|
||||
self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19)
|
||||
end
|
||||
|
||||
if self.disablebutton then
|
||||
self.scrollBar:SetPoint("BOTTOM", self.frame, "BOTTOM", 0, 21)
|
||||
self.scrollBG:SetPoint("BOTTOMLEFT", 0, 4)
|
||||
else
|
||||
self.scrollBar:SetPoint("BOTTOM", self.button, "TOP", 0, 18)
|
||||
self.scrollBG:SetPoint("BOTTOMLEFT", self.button, "TOPLEFT")
|
||||
end
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
@@ -40,6 +78,7 @@ end
|
||||
|
||||
local function OnEditFocusLost(self) -- EditBox
|
||||
self:HighlightText(0, 0)
|
||||
self.obj:Fire("OnEditFocusLost")
|
||||
end
|
||||
|
||||
local function OnEnter(self) -- EditBox / ScrollFrame
|
||||
@@ -65,11 +104,12 @@ local function OnMouseUp(self)
|
||||
end
|
||||
|
||||
local function OnReceiveDrag(self) -- EditBox / ScrollFrame
|
||||
local type, id, info = GetCursorInfo()
|
||||
local type, id, info, extra = GetCursorInfo()
|
||||
if type == "spell" then
|
||||
info, id = GetSpellName(id, info)
|
||||
if id and id:match("%d") then
|
||||
info = info .. "(" .. id .. ")"
|
||||
if C_Spell and C_Spell.GetSpellName then
|
||||
info = C_Spell.GetSpellName(extra)
|
||||
else
|
||||
info = GetSpellInfo(id, info)
|
||||
end
|
||||
elseif type ~= "item" then
|
||||
return
|
||||
@@ -109,25 +149,40 @@ local function OnVerticalScroll(self, offset)
|
||||
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight())
|
||||
end
|
||||
|
||||
local function OnScrollRangeChanged(self, xrange, yrange)
|
||||
if yrange == 0 then
|
||||
self.obj.editBox:SetHitRectInsets(0, 0, 0, 0)
|
||||
else
|
||||
OnVerticalScroll(self, self:GetVerticalScroll())
|
||||
end
|
||||
end
|
||||
|
||||
local function OnShowFocus(frame)
|
||||
frame.obj.editBox:SetFocus()
|
||||
frame:SetScript("OnShow", nil)
|
||||
end
|
||||
|
||||
local function OnEditFocusGained(frame)
|
||||
AceGUI:SetFocus(frame.obj)
|
||||
frame.obj:Fire("OnEditFocusGained")
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Methods
|
||||
-------------------------------------------------------------------------------]]
|
||||
local methods = {
|
||||
["GetText"] = function(self)
|
||||
return self.editBox:GetText()
|
||||
end,
|
||||
|
||||
["OnAcquire"] = function(self)
|
||||
self.editBox:SetText("")
|
||||
self:SetDisabled(false)
|
||||
self:SetWidth(200)
|
||||
self:DisableButton(false)
|
||||
self:SetNumLines()
|
||||
self.entered = nil
|
||||
self:SetMaxLetters(0)
|
||||
end,
|
||||
|
||||
["OnRelease"] = function(self)
|
||||
self.frame:ClearAllPoints()
|
||||
self.frame:Hide()
|
||||
self:ClearFocus()
|
||||
end,
|
||||
|
||||
["SetDisabled"] = function(self, disabled)
|
||||
@@ -152,28 +207,68 @@ local methods = {
|
||||
self.label:SetText(text)
|
||||
if self.labelHeight ~= 10 then
|
||||
self.labelHeight = 10
|
||||
self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19)
|
||||
self:SetHeight(self.frame.height + 10)
|
||||
self.label:Show()
|
||||
end
|
||||
elseif self.labelHeight ~= 0 then
|
||||
self.labelHeight = 0
|
||||
self.label:Hide()
|
||||
self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23)
|
||||
self:SetHeight(self.frame.height - 10)
|
||||
end
|
||||
Layout(self)
|
||||
end,
|
||||
|
||||
["SetNumLines"] = function(self, value)
|
||||
if not value or value < 4 then
|
||||
value = 4
|
||||
end
|
||||
self:SetHeight(value * 14 + 41 + self.labelHeight)
|
||||
self.numlines = value
|
||||
Layout(self)
|
||||
end,
|
||||
|
||||
["SetText"] = function(self, text)
|
||||
self.editBox:SetText(text)
|
||||
end
|
||||
end,
|
||||
|
||||
["GetText"] = function(self)
|
||||
return self.editBox:GetText()
|
||||
end,
|
||||
|
||||
["SetMaxLetters"] = function (self, num)
|
||||
self.editBox:SetMaxLetters(num or 0)
|
||||
end,
|
||||
|
||||
["DisableButton"] = function(self, disabled)
|
||||
self.disablebutton = disabled
|
||||
if disabled then
|
||||
self.button:Hide()
|
||||
else
|
||||
self.button:Show()
|
||||
end
|
||||
Layout(self)
|
||||
end,
|
||||
|
||||
["ClearFocus"] = function(self)
|
||||
self.editBox:ClearFocus()
|
||||
self.frame:SetScript("OnShow", nil)
|
||||
end,
|
||||
|
||||
["SetFocus"] = function(self)
|
||||
self.editBox:SetFocus()
|
||||
if not self.frame:IsShown() then
|
||||
self.frame:SetScript("OnShow", OnShowFocus)
|
||||
end
|
||||
end,
|
||||
|
||||
["HighlightText"] = function(self, from, to)
|
||||
self.editBox:HighlightText(from, to)
|
||||
end,
|
||||
|
||||
["GetCursorPosition"] = function(self)
|
||||
return self.editBox:GetCursorPosition()
|
||||
end,
|
||||
|
||||
["SetCursorPosition"] = function(self, ...)
|
||||
return self.editBox:SetCursorPosition(...)
|
||||
end,
|
||||
}
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -198,8 +293,8 @@ local function Constructor()
|
||||
label:SetText(ACCEPT)
|
||||
label:SetHeight(10)
|
||||
|
||||
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate2")
|
||||
button:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, 4)
|
||||
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate")
|
||||
button:SetPoint("BOTTOMLEFT", 0, 4)
|
||||
button:SetHeight(22)
|
||||
button:SetWidth(label:GetStringWidth() + 24)
|
||||
button:SetText(ACCEPT)
|
||||
@@ -212,7 +307,7 @@ local function Constructor()
|
||||
text:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -5, 1)
|
||||
text:SetJustifyV("MIDDLE")
|
||||
|
||||
local scrollBG = CreateFrame("Frame", nil, frame)
|
||||
local scrollBG = CreateFrame("Frame", nil, frame, "BackdropTemplate")
|
||||
scrollBG:SetBackdrop(backdrop)
|
||||
scrollBG:SetBackdropColor(0, 0, 0)
|
||||
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||
@@ -236,8 +331,9 @@ local function Constructor()
|
||||
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
|
||||
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
|
||||
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
|
||||
scrollFrame:HookScript("OnScrollRangeChanged", OnScrollRangeChanged)
|
||||
|
||||
local editBox = CreateFrame("EditBox", nil, scrollFrame)
|
||||
local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame)
|
||||
editBox:SetAllPoints()
|
||||
editBox:SetFontObject(ChatFontNormal)
|
||||
editBox:SetMultiLine(true)
|
||||
@@ -253,6 +349,8 @@ local function Constructor()
|
||||
editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
|
||||
editBox:SetScript("OnTextChanged", OnTextChanged)
|
||||
editBox:SetScript("OnTextSet", OnTextSet)
|
||||
editBox:SetScript("OnEditFocusGained", OnEditFocusGained)
|
||||
|
||||
|
||||
scrollFrame:SetScrollChild(editBox)
|
||||
|
||||
@@ -262,7 +360,9 @@ local function Constructor()
|
||||
frame = frame,
|
||||
label = label,
|
||||
labelHeight = 10,
|
||||
numlines = 4,
|
||||
scrollBar = scrollBar,
|
||||
scrollBG = scrollBG,
|
||||
scrollFrame = scrollFrame,
|
||||
type = Type
|
||||
}
|
||||
@@ -271,8 +371,7 @@ local function Constructor()
|
||||
end
|
||||
button.obj, editBox.obj, scrollFrame.obj = widget, widget, widget
|
||||
|
||||
AceGUI:RegisterAsWidget(widget)
|
||||
return widget
|
||||
return AceGUI:RegisterAsWidget(widget)
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type, Constructor, Version)
|
||||
|
||||
@@ -2,22 +2,18 @@
|
||||
Slider Widget
|
||||
Graphical Slider, like, for Range values.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "Slider", 20
|
||||
local Type, Version = "Slider", 24
|
||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
-- Lua APIs
|
||||
local min, max, floor = math.min, math.max, math.floor
|
||||
local tonumber = tonumber
|
||||
local tonumber, pairs = tonumber, pairs
|
||||
|
||||
-- WoW APIs
|
||||
local PlaySound = PlaySound
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: GameFontHighlightSmall
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
@@ -31,13 +27,13 @@ local function UpdateText(self)
|
||||
end
|
||||
|
||||
local function UpdateLabels(self)
|
||||
local min, max = (self.min or 0), (self.max or 100)
|
||||
local min_value, max_value = (self.min or 0), (self.max or 100)
|
||||
if self.ispercent then
|
||||
self.lowtext:SetFormattedText("%s%%", (min * 100))
|
||||
self.hightext:SetFormattedText("%s%%", (max * 100))
|
||||
self.lowtext:SetFormattedText("%s%%", (min_value * 100))
|
||||
self.hightext:SetFormattedText("%s%%", (max_value * 100))
|
||||
else
|
||||
self.lowtext:SetText(min)
|
||||
self.hightext:SetText(max)
|
||||
self.lowtext:SetText(min_value)
|
||||
self.hightext:SetText(max_value)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,10 +53,13 @@ local function Frame_OnMouseDown(frame)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function Slider_OnValueChanged(frame)
|
||||
local function Slider_OnValueChanged(frame, newvalue)
|
||||
local self = frame.obj
|
||||
if not frame.setup then
|
||||
local newvalue = frame:GetValue()
|
||||
if self.step and self.step > 0 then
|
||||
local min_value = self.min or 0
|
||||
newvalue = floor((newvalue - min_value) / self.step + 0.5) * self.step + min_value
|
||||
end
|
||||
if newvalue ~= self.value and not self.disabled then
|
||||
self.value = newvalue
|
||||
self:Fire("OnValueChanged", newvalue)
|
||||
@@ -104,7 +103,7 @@ local function EditBox_OnEnterPressed(frame)
|
||||
end
|
||||
|
||||
if value then
|
||||
PlaySound("igMainMenuOptionCheckBoxOn")
|
||||
PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
|
||||
self.slider:SetValue(value)
|
||||
self:Fire("OnMouseUp", value)
|
||||
end
|
||||
@@ -172,13 +171,13 @@ local methods = {
|
||||
self.label:SetText(text)
|
||||
end,
|
||||
|
||||
["SetSliderValues"] = function(self, min, max, step)
|
||||
["SetSliderValues"] = function(self, min_value, max_value, step)
|
||||
local frame = self.slider
|
||||
frame.setup = true
|
||||
self.min = min
|
||||
self.max = max
|
||||
self.min = min_value
|
||||
self.max = max_value
|
||||
self.step = step
|
||||
frame:SetMinMaxValues(min or 0,max or 100)
|
||||
frame:SetMinMaxValues(min_value or 0,max_value or 100)
|
||||
UpdateLabels(self)
|
||||
frame:SetValueStep(step or 1)
|
||||
if self.value then
|
||||
@@ -222,7 +221,7 @@ local function Constructor()
|
||||
label:SetJustifyH("CENTER")
|
||||
label:SetHeight(15)
|
||||
|
||||
local slider = CreateFrame("Slider", nil, frame)
|
||||
local slider = CreateFrame("Slider", nil, frame, "BackdropTemplate")
|
||||
slider:SetOrientation("HORIZONTAL")
|
||||
slider:SetHeight(15)
|
||||
slider:SetHitRectInsets(0, 0, -10, 0)
|
||||
@@ -244,7 +243,7 @@ local function Constructor()
|
||||
local hightext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
|
||||
hightext:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", -2, 3)
|
||||
|
||||
local editbox = CreateFrame("EditBox", nil, frame)
|
||||
local editbox = CreateFrame("EditBox", nil, frame, "BackdropTemplate")
|
||||
editbox:SetAutoFocus(false)
|
||||
editbox:SetFontObject(GameFontHighlightSmall)
|
||||
editbox:SetPoint("TOP", slider, "BOTTOM")
|
||||
@@ -274,6 +273,7 @@ local function Constructor()
|
||||
widget[method] = func
|
||||
end
|
||||
slider.obj, editbox.obj = widget, widget
|
||||
C_Timer.After(0.3, function() editbox:SetText(" ") UpdateText(widget) end) -- Workaround for font loading issue, making the editboxes blank until the text is changed
|
||||
|
||||
return AceGUI:RegisterAsWidget(widget)
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
## Title: Shadowed Unit Frames
|
||||
## Notes: An apple a day keeps the raptor away, or so they say
|
||||
## Author: Shadowed
|
||||
## Version: v3.3.0
|
||||
## Version: v3.3.0-coa.2
|
||||
## SavedVariables: ShadowedUFDB
|
||||
## OptionalDeps: Ace3, LibSharedMedia-3.0, LibHealComm-4.0, AceGUI-3.0-SharedMediaWidgets
|
||||
## X-Curse-Packaged-Version: v3.2.12
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
-- * **race** Race-specific data. All of the players characters of the same race share this database.
|
||||
-- * **faction** Faction-specific data. All of the players characters of the same faction share this database.
|
||||
-- * **factionrealm** Faction and realm specific data. All of the players characters on the same realm and of the same faction share this database.
|
||||
-- * **locale** Locale specific data, based on the locale of the players game client.
|
||||
-- * **global** Global Data. All characters on the same account share this database.
|
||||
-- * **profile** Profile-specific data. All characters using the same profile share this database. The user can control which profile should be used.
|
||||
--
|
||||
@@ -39,23 +40,19 @@
|
||||
-- end
|
||||
-- @class file
|
||||
-- @name AceDB-3.0.lua
|
||||
-- @release $Id: AceDB-3.0.lua 940 2010-06-19 08:01:47Z nevcairiel $
|
||||
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 21
|
||||
local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR)
|
||||
-- @release $Id$
|
||||
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 33
|
||||
local AceDB = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR)
|
||||
|
||||
if not AceDB then return end -- No upgrade needed
|
||||
|
||||
-- Lua APIs
|
||||
local type, pairs, next, error = type, pairs, next, error
|
||||
local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
|
||||
local setmetatable, rawset, rawget = setmetatable, rawset, rawget
|
||||
|
||||
-- WoW APIs
|
||||
local _G = _G
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: LibStub
|
||||
|
||||
AceDB.db_registry = AceDB.db_registry or {}
|
||||
AceDB.frame = AceDB.frame or CreateFrame("Frame")
|
||||
|
||||
@@ -97,11 +94,11 @@ local function copyDefaults(dest, src)
|
||||
-- This is a metatable used for table defaults
|
||||
local mt = {
|
||||
-- This handles the lookup and creation of new subtables
|
||||
__index = function(t,k)
|
||||
if k == nil then return nil end
|
||||
__index = function(t,k2)
|
||||
if k2 == nil then return nil end
|
||||
local tbl = {}
|
||||
copyDefaults(tbl, v)
|
||||
rawset(t, k, tbl)
|
||||
rawset(t, k2, tbl)
|
||||
return tbl
|
||||
end,
|
||||
}
|
||||
@@ -114,7 +111,15 @@ local function copyDefaults(dest, src)
|
||||
end
|
||||
else
|
||||
-- Values are not tables, so this is just a simple return
|
||||
local mt = {__index = function(t,k) return k~=nil and v or nil end}
|
||||
-- (PR #10 backport: the old `k2~=nil and v or nil` short-circuits to
|
||||
-- nil whenever the default `v` itself is falsy — so `["*"] = false`
|
||||
-- defaults silently became nil. Make the read explicit instead.)
|
||||
local mt = {
|
||||
__index = function(t,k2)
|
||||
if k2 == nil then return nil end
|
||||
return v
|
||||
end,
|
||||
}
|
||||
setmetatable(dest, mt)
|
||||
end
|
||||
elseif type(v) == "table" then
|
||||
@@ -260,6 +265,12 @@ local _, classKey = UnitClass("player")
|
||||
local _, raceKey = UnitRace("player")
|
||||
local factionKey = UnitFactionGroup("player")
|
||||
local factionrealmKey = factionKey .. " - " .. realmKey
|
||||
local localeKey = GetLocale():lower()
|
||||
|
||||
local regionTable = { "US", "KR", "EU", "TW", "CN" }
|
||||
local regionKey = regionTable[GetCurrentRegion()] or GetCurrentRegionName() or "TR"
|
||||
local factionrealmregionKey = factionrealmKey .. " - " .. regionKey
|
||||
|
||||
-- Actual database initialization function
|
||||
local function initdb(sv, defaults, defaultProfile, olddb, parent)
|
||||
-- Generate the database keys for each section
|
||||
@@ -295,7 +306,9 @@ local function initdb(sv, defaults, defaultProfile, olddb, parent)
|
||||
["race"] = raceKey,
|
||||
["faction"] = factionKey,
|
||||
["factionrealm"] = factionrealmKey,
|
||||
["factionrealmregion"] = factionrealmregionKey,
|
||||
["profile"] = profileKey,
|
||||
["locale"] = localeKey,
|
||||
["global"] = true,
|
||||
["profiles"] = true,
|
||||
}
|
||||
@@ -355,7 +368,7 @@ local function logoutHandler(frame, event)
|
||||
|
||||
-- cleanup sections that are empty without defaults
|
||||
local sv = rawget(db, "sv")
|
||||
for section in pairs(db.keys) do
|
||||
for section in pairs(rawget(db, "keys")) do
|
||||
if rawget(sv, section) then
|
||||
-- global is special, all other sections have sub-entrys
|
||||
-- also don't delete empty profiles on main dbs, only on namespaces
|
||||
@@ -372,6 +385,26 @@ local function logoutHandler(frame, event)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- second pass after everything else is cleaned up to remove empty namespaces
|
||||
-- can't be run in-loop above since there is no guaranteed order
|
||||
for db in pairs(AceDB.db_registry) do
|
||||
local sv = rawget(db, "sv")
|
||||
local namespaces = rawget(sv, "namespaces")
|
||||
if namespaces then
|
||||
for name in pairs(namespaces) do
|
||||
-- cleanout empty profiles table, if still present
|
||||
if namespaces[name].profiles and not next(namespaces[name].profiles) then
|
||||
namespaces[name].profiles = nil
|
||||
end
|
||||
|
||||
-- remove entire namespace, if needed
|
||||
if not next(namespaces[name]) then
|
||||
namespaces[name] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -388,7 +421,7 @@ AceDB.frame:SetScript("OnEvent", logoutHandler)
|
||||
-- @param defaults A table of defaults for this database
|
||||
function DBObjectLib:RegisterDefaults(defaults)
|
||||
if defaults and type(defaults) ~= "table" then
|
||||
error("Usage: AceDBObject:RegisterDefaults(defaults): 'defaults' - table or nil expected.", 2)
|
||||
error(("Usage: AceDBObject:RegisterDefaults(defaults): 'defaults' - table or nil expected, got %q."):format(type(defaults)), 2)
|
||||
end
|
||||
|
||||
validateDefaults(defaults, self.keys)
|
||||
@@ -420,7 +453,7 @@ end
|
||||
-- @param name The name of the profile to set as the current profile
|
||||
function DBObjectLib:SetProfile(name)
|
||||
if type(name) ~= "string" then
|
||||
error("Usage: AceDBObject:SetProfile(name): 'name' - string expected.", 2)
|
||||
error(("Usage: AceDBObject:SetProfile(name): 'name' - string expected, got %q."):format(type(name)), 2)
|
||||
end
|
||||
|
||||
-- changing to the same profile, dont do anything
|
||||
@@ -462,7 +495,7 @@ end
|
||||
-- @param tbl A table to store the profile names in (optional)
|
||||
function DBObjectLib:GetProfiles(tbl)
|
||||
if tbl and type(tbl) ~= "table" then
|
||||
error("Usage: AceDBObject:GetProfiles(tbl): 'tbl' - table or nil expected.", 2)
|
||||
error(("Usage: AceDBObject:GetProfiles(tbl): 'tbl' - table or nil expected, got %q."):format(type(tbl)), 2)
|
||||
end
|
||||
|
||||
-- Clear the container table
|
||||
@@ -500,15 +533,15 @@ end
|
||||
-- @param silent If true, do not raise an error when the profile does not exist
|
||||
function DBObjectLib:DeleteProfile(name, silent)
|
||||
if type(name) ~= "string" then
|
||||
error("Usage: AceDBObject:DeleteProfile(name): 'name' - string expected.", 2)
|
||||
error(("Usage: AceDBObject:DeleteProfile(name): 'name' - string expected, got %q."):format(type(name)), 2)
|
||||
end
|
||||
|
||||
if self.keys.profile == name then
|
||||
error("Cannot delete the active profile in an AceDBObject.", 2)
|
||||
error(("Cannot delete the active profile (%q) in an AceDBObject."):format(name), 2)
|
||||
end
|
||||
|
||||
if not rawget(self.profiles, name) and not silent then
|
||||
error("Cannot delete profile '" .. name .. "'. It does not exist.", 2)
|
||||
error(("Cannot delete profile %q as it does not exist."):format(name), 2)
|
||||
end
|
||||
|
||||
self.profiles[name] = nil
|
||||
@@ -520,6 +553,26 @@ function DBObjectLib:DeleteProfile(name, silent)
|
||||
end
|
||||
end
|
||||
|
||||
-- remove from unloaded namespaces
|
||||
if self.sv.namespaces then
|
||||
for nsname, data in pairs(self.sv.namespaces) do
|
||||
if self.children and self.children[nsname] then
|
||||
-- already a mapped namespace
|
||||
elseif data.profiles then
|
||||
data.profiles[name] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- switch all characters that use this profile back to the default
|
||||
if self.sv.profileKeys then
|
||||
for key, profile in pairs(self.sv.profileKeys) do
|
||||
if profile == name then
|
||||
self.sv.profileKeys[key] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Callback: OnProfileDeleted, database, profileKey
|
||||
self.callbacks:Fire("OnProfileDeleted", self, name)
|
||||
end
|
||||
@@ -530,15 +583,15 @@ end
|
||||
-- @param silent If true, do not raise an error when the profile does not exist
|
||||
function DBObjectLib:CopyProfile(name, silent)
|
||||
if type(name) ~= "string" then
|
||||
error("Usage: AceDBObject:CopyProfile(name): 'name' - string expected.", 2)
|
||||
error(("Usage: AceDBObject:CopyProfile(name): 'name' - string expected, got %q."):format(type(name)), 2)
|
||||
end
|
||||
|
||||
if name == self.keys.profile then
|
||||
error("Cannot have the same source and destination profiles.", 2)
|
||||
error(("Cannot have the same source and destination profiles (%q)."):format(name), 2)
|
||||
end
|
||||
|
||||
if not rawget(self.profiles, name) and not silent then
|
||||
error("Cannot copy profile '" .. name .. "'. It does not exist.", 2)
|
||||
error(("Cannot copy profile %q as it does not exist."):format(name), 2)
|
||||
end
|
||||
|
||||
-- Reset the profile before copying
|
||||
@@ -556,6 +609,20 @@ function DBObjectLib:CopyProfile(name, silent)
|
||||
end
|
||||
end
|
||||
|
||||
-- copy unloaded namespaces
|
||||
if self.sv.namespaces then
|
||||
for nsname, data in pairs(self.sv.namespaces) do
|
||||
if self.children and self.children[nsname] then
|
||||
-- already a mapped namespace
|
||||
elseif data.profiles then
|
||||
-- reset the current profile
|
||||
data.profiles[self.keys.profile] = {}
|
||||
-- copy data
|
||||
copyTable(data.profiles[name], data.profiles[self.keys.profile])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Callback: OnProfileCopied, database, sourceProfileKey
|
||||
self.callbacks:Fire("OnProfileCopied", self, name)
|
||||
end
|
||||
@@ -582,6 +649,18 @@ function DBObjectLib:ResetProfile(noChildren, noCallbacks)
|
||||
end
|
||||
end
|
||||
|
||||
-- reset unloaded namespaces
|
||||
if self.sv.namespaces and not noChildren then
|
||||
for nsname, data in pairs(self.sv.namespaces) do
|
||||
if self.children and self.children[nsname] then
|
||||
-- already a mapped namespace
|
||||
elseif data.profiles then
|
||||
-- reset the current profile
|
||||
data.profiles[self.keys.profile] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Callback: OnProfileReset, database
|
||||
if not noCallbacks then
|
||||
self.callbacks:Fire("OnProfileReset", self)
|
||||
@@ -592,8 +671,8 @@ end
|
||||
-- profile.
|
||||
-- @param defaultProfile The profile name to use as the default
|
||||
function DBObjectLib:ResetDB(defaultProfile)
|
||||
if defaultProfile and type(defaultProfile) ~= "string" then
|
||||
error("Usage: AceDBObject:ResetDB(defaultProfile): 'defaultProfile' - string or nil expected.", 2)
|
||||
if defaultProfile and type(defaultProfile) ~= "string" and defaultProfile ~= true then
|
||||
error(("Usage: AceDBObject:ResetDB(defaultProfile): 'defaultProfile' - string or true expected, got %q."):format(type(defaultProfile)), 2)
|
||||
end
|
||||
|
||||
local sv = self.sv
|
||||
@@ -601,8 +680,6 @@ function DBObjectLib:ResetDB(defaultProfile)
|
||||
sv[k] = nil
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
|
||||
initdb(sv, self.defaults, defaultProfile, self)
|
||||
|
||||
-- fix the child namespaces
|
||||
@@ -629,13 +706,13 @@ end
|
||||
-- @param defaults A table of values to use as defaults
|
||||
function DBObjectLib:RegisterNamespace(name, defaults)
|
||||
if type(name) ~= "string" then
|
||||
error("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - string expected.", 2)
|
||||
error(("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - string expected, got %q."):format(type(name)), 2)
|
||||
end
|
||||
if defaults and type(defaults) ~= "table" then
|
||||
error("Usage: AceDBObject:RegisterNamespace(name, defaults): 'defaults' - table or nil expected.", 2)
|
||||
error(("Usage: AceDBObject:RegisterNamespace(name, defaults): 'defaults' - table or nil expected, got %q."):format(type(defaults)), 2)
|
||||
end
|
||||
if self.children and self.children[name] then
|
||||
error ("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - a namespace with that name already exists.", 2)
|
||||
error(("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - a namespace called %q already exists."):format(name), 2)
|
||||
end
|
||||
|
||||
local sv = self.sv
|
||||
@@ -659,10 +736,10 @@ end
|
||||
-- @return the namespace object if found
|
||||
function DBObjectLib:GetNamespace(name, silent)
|
||||
if type(name) ~= "string" then
|
||||
error("Usage: AceDBObject:GetNamespace(name): 'name' - string expected.", 2)
|
||||
error(("Usage: AceDBObject:GetNamespace(name): 'name' - string expected, got %q."):format(type(name)), 2)
|
||||
end
|
||||
if not silent and not (self.children and self.children[name]) then
|
||||
error ("Usage: AceDBObject:GetNamespace(name): 'name' - namespace does not exist.", 2)
|
||||
error(("Usage: AceDBObject:GetNamespace(name): 'name' - namespace %q does not exist."):format(name), 2)
|
||||
end
|
||||
if not self.children then self.children = {} end
|
||||
return self.children[name]
|
||||
@@ -701,15 +778,15 @@ function AceDB:New(tbl, defaults, defaultProfile)
|
||||
end
|
||||
|
||||
if type(tbl) ~= "table" then
|
||||
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'tbl' - table expected.", 2)
|
||||
error(("Usage: AceDB:New(tbl, defaults, defaultProfile): 'tbl' - table expected, got %q."):format(type(tbl)), 2)
|
||||
end
|
||||
|
||||
if defaults and type(defaults) ~= "table" then
|
||||
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaults' - table expected.", 2)
|
||||
error(("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaults' - table expected, got %q."):format(type(defaults)), 2)
|
||||
end
|
||||
|
||||
if defaultProfile and type(defaultProfile) ~= "string" and defaultProfile ~= true then
|
||||
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string or true expected.", 2)
|
||||
error(("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string or true expected, got %q."):format(type(defaultProfile)), 2)
|
||||
end
|
||||
|
||||
return initdb(tbl, defaults, defaultProfile)
|
||||
|
||||
+24
-61
@@ -1,61 +1,26 @@
|
||||
--[[ $Id: CallbackHandler-1.0.lua 9 2009-09-17 10:38:10Z mikk $ ]]
|
||||
local MAJOR, MINOR = "CallbackHandler-1.0", 5
|
||||
--[[ $Id: CallbackHandler-1.0.lua 25 2022-12-12 15:02:36Z nevcairiel $ ]]
|
||||
local MAJOR, MINOR = "CallbackHandler-1.0", 8
|
||||
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not CallbackHandler then return end -- No upgrade needed
|
||||
|
||||
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
|
||||
|
||||
local type = type
|
||||
local pcall = pcall
|
||||
local pairs = pairs
|
||||
local assert = assert
|
||||
local concat = table.concat
|
||||
local loadstring = loadstring
|
||||
local next = next
|
||||
local select = select
|
||||
local type = type
|
||||
local xpcall = xpcall
|
||||
-- Lua APIs
|
||||
local securecallfunction, error = securecallfunction, error
|
||||
local setmetatable, rawget = setmetatable, rawget
|
||||
local next, select, pairs, type, tostring = next, select, pairs, type, tostring
|
||||
|
||||
local function errorhandler(err)
|
||||
return geterrorhandler()(err)
|
||||
|
||||
local function Dispatch(handlers, ...)
|
||||
local index, method = next(handlers)
|
||||
if not method then return end
|
||||
repeat
|
||||
securecallfunction(method, ...)
|
||||
index, method = next(handlers, index)
|
||||
until not method
|
||||
end
|
||||
|
||||
local function CreateDispatcher(argCount)
|
||||
local code = [[
|
||||
local next, xpcall, eh = ...
|
||||
|
||||
local method, ARGS
|
||||
local function call() method(ARGS) end
|
||||
|
||||
local function dispatch(handlers, ...)
|
||||
local index
|
||||
index, method = next(handlers)
|
||||
if not method then return end
|
||||
local OLD_ARGS = ARGS
|
||||
ARGS = ...
|
||||
repeat
|
||||
xpcall(call, eh)
|
||||
index, method = next(handlers, index)
|
||||
until not method
|
||||
ARGS = OLD_ARGS
|
||||
end
|
||||
|
||||
return dispatch
|
||||
]]
|
||||
|
||||
local ARGS, OLD_ARGS = {}, {}
|
||||
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
|
||||
code = code:gsub("OLD_ARGS", concat(OLD_ARGS, ", ")):gsub("ARGS", concat(ARGS, ", "))
|
||||
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
|
||||
end
|
||||
|
||||
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
|
||||
local dispatcher = CreateDispatcher(argCount)
|
||||
rawset(self, argCount, dispatcher)
|
||||
return dispatcher
|
||||
end})
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
-- CallbackHandler:New
|
||||
--
|
||||
@@ -64,9 +29,7 @@ end})
|
||||
-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
|
||||
-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
|
||||
|
||||
function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, OnUsed, OnUnused)
|
||||
-- TODO: Remove this after beta has gone out
|
||||
assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused")
|
||||
function CallbackHandler.New(_self, target, RegisterName, UnregisterName, UnregisterAllName)
|
||||
|
||||
RegisterName = RegisterName or "RegisterCallback"
|
||||
UnregisterName = UnregisterName or "UnregisterCallback"
|
||||
@@ -88,19 +51,19 @@ function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAll
|
||||
local oldrecurse = registry.recurse
|
||||
registry.recurse = oldrecurse + 1
|
||||
|
||||
Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
|
||||
Dispatch(events[eventname], eventname, ...)
|
||||
|
||||
registry.recurse = oldrecurse
|
||||
|
||||
if registry.insertQueue and oldrecurse==0 then
|
||||
-- Something in one of our callbacks wanted to register more callbacks; they got queued
|
||||
for eventname,callbacks in pairs(registry.insertQueue) do
|
||||
local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
|
||||
for self,func in pairs(callbacks) do
|
||||
events[eventname][self] = func
|
||||
for event,callbacks in pairs(registry.insertQueue) do
|
||||
local first = not rawget(events, event) or not next(events[event]) -- test for empty before. not test for one member after. that one member may have been overwritten.
|
||||
for object,func in pairs(callbacks) do
|
||||
events[event][object] = func
|
||||
-- fire OnUsed callback?
|
||||
if first and registry.OnUsed then
|
||||
registry.OnUsed(registry, target, eventname)
|
||||
registry.OnUsed(registry, target, event)
|
||||
first = nil
|
||||
end
|
||||
end
|
||||
@@ -146,9 +109,9 @@ function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAll
|
||||
regfunc = function(...) self[method](self,...) end
|
||||
end
|
||||
else
|
||||
-- function ref with self=object or self="addonId"
|
||||
if type(self)~="table" and type(self)~="string" then
|
||||
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2)
|
||||
-- function ref with self=object or self="addonId" or self=thread
|
||||
if type(self)~="table" and type(self)~="string" and type(self)~="thread" then
|
||||
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2)
|
||||
end
|
||||
|
||||
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
|
||||
|
||||
@@ -10,7 +10,7 @@ if not LibStub or LibStub.minor < LIBSTUB_MINOR then
|
||||
|
||||
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.")
|
||||
minor = assert(tonumber(string.match(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
|
||||
|
||||
-239
@@ -1,239 +0,0 @@
|
||||
--[[ $Id: CallbackHandler-1.0.lua 60548 2008-02-07 11:04:06Z nevcairiel $ ]]
|
||||
local MAJOR, MINOR = "CallbackHandler-1.0", 3
|
||||
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not CallbackHandler then return end -- No upgrade needed
|
||||
|
||||
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
|
||||
|
||||
local type = type
|
||||
local pcall = pcall
|
||||
local pairs = pairs
|
||||
local assert = assert
|
||||
local concat = table.concat
|
||||
local loadstring = loadstring
|
||||
local next = next
|
||||
local select = select
|
||||
local type = type
|
||||
local xpcall = xpcall
|
||||
|
||||
local function errorhandler(err)
|
||||
return geterrorhandler()(err)
|
||||
end
|
||||
|
||||
local function CreateDispatcher(argCount)
|
||||
local code = [[
|
||||
local next, xpcall, eh = ...
|
||||
|
||||
local method, ARGS
|
||||
local function call() method(ARGS) end
|
||||
|
||||
local function dispatch(handlers, ...)
|
||||
local index
|
||||
index, method = next(handlers)
|
||||
if not method then return end
|
||||
local OLD_ARGS = ARGS
|
||||
ARGS = ...
|
||||
repeat
|
||||
xpcall(call, eh)
|
||||
index, method = next(handlers, index)
|
||||
until not method
|
||||
ARGS = OLD_ARGS
|
||||
end
|
||||
|
||||
return dispatch
|
||||
]]
|
||||
|
||||
local ARGS, OLD_ARGS = {}, {}
|
||||
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
|
||||
code = code:gsub("OLD_ARGS", concat(OLD_ARGS, ", ")):gsub("ARGS", concat(ARGS, ", "))
|
||||
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
|
||||
end
|
||||
|
||||
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
|
||||
local dispatcher = CreateDispatcher(argCount)
|
||||
rawset(self, argCount, dispatcher)
|
||||
return dispatcher
|
||||
end})
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
-- CallbackHandler:New
|
||||
--
|
||||
-- target - target object to embed public APIs in
|
||||
-- RegisterName - name of the callback registration API, default "RegisterCallback"
|
||||
-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
|
||||
-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
|
||||
|
||||
function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, OnUsed, OnUnused)
|
||||
-- TODO: Remove this after beta has gone out
|
||||
assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused")
|
||||
|
||||
RegisterName = RegisterName or "RegisterCallback"
|
||||
UnregisterName = UnregisterName or "UnregisterCallback"
|
||||
if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
|
||||
UnregisterAllName = "UnregisterAllCallbacks"
|
||||
end
|
||||
|
||||
-- we declare all objects and exported APIs inside this closure to quickly gain access
|
||||
-- to e.g. function names, the "target" parameter, etc
|
||||
|
||||
|
||||
-- Create the registry object
|
||||
local events = setmetatable({}, meta)
|
||||
local registry = { recurse=0, events=events }
|
||||
|
||||
-- registry:Fire() - fires the given event/message into the registry
|
||||
function registry:Fire(eventname, ...)
|
||||
if not rawget(events, eventname) or not next(events[eventname]) then return end
|
||||
local oldrecurse = registry.recurse
|
||||
registry.recurse = oldrecurse + 1
|
||||
|
||||
Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
|
||||
|
||||
registry.recurse = oldrecurse
|
||||
|
||||
if registry.insertQueue and oldrecurse==0 then
|
||||
-- Something in one of our callbacks wanted to register more callbacks; they got queued
|
||||
for eventname,callbacks in pairs(registry.insertQueue) do
|
||||
local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
|
||||
for self,func in pairs(callbacks) do
|
||||
events[eventname][self] = func
|
||||
-- fire OnUsed callback?
|
||||
if first and registry.OnUsed then
|
||||
registry.OnUsed(registry, target, eventname)
|
||||
first = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
registry.insertQueue = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Registration of a callback, handles:
|
||||
-- self["method"], leads to self["method"](self, ...)
|
||||
-- self with function ref, leads to functionref(...)
|
||||
-- "addonId" (instead of self) with function ref, leads to functionref(...)
|
||||
-- all with an optional arg, which, if present, gets passed as first argument (after self if present)
|
||||
target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]])
|
||||
if type(eventname) ~= "string" then
|
||||
error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
|
||||
end
|
||||
|
||||
method = method or eventname
|
||||
|
||||
local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
|
||||
|
||||
if type(method) ~= "string" and type(method) ~= "function" then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
|
||||
end
|
||||
|
||||
local regfunc
|
||||
|
||||
if type(method) == "string" then
|
||||
-- self["method"] calling style
|
||||
if type(self) ~= "table" then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
|
||||
elseif self==target then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
|
||||
elseif type(self[method]) ~= "function" then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
|
||||
end
|
||||
|
||||
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
|
||||
local arg=select(1,...)
|
||||
regfunc = function(...) self[method](self,arg,...) end
|
||||
else
|
||||
regfunc = function(...) self[method](self,...) end
|
||||
end
|
||||
else
|
||||
-- function ref with self=object or self="addonId"
|
||||
if type(self)~="table" and type(self)~="string" then
|
||||
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2)
|
||||
end
|
||||
|
||||
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
|
||||
local arg=select(1,...)
|
||||
regfunc = function(...) method(arg,...) end
|
||||
else
|
||||
regfunc = method
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if events[eventname][self] or registry.recurse<1 then
|
||||
-- if registry.recurse<1 then
|
||||
-- we're overwriting an existing entry, or not currently recursing. just set it.
|
||||
events[eventname][self] = regfunc
|
||||
-- fire OnUsed callback?
|
||||
if registry.OnUsed and first then
|
||||
registry.OnUsed(registry, target, eventname)
|
||||
end
|
||||
else
|
||||
-- we're currently processing a callback in this registry, so delay the registration of this new entry!
|
||||
-- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
|
||||
registry.insertQueue = registry.insertQueue or setmetatable({},meta)
|
||||
registry.insertQueue[eventname][self] = regfunc
|
||||
end
|
||||
end
|
||||
|
||||
-- Unregister a callback
|
||||
target[UnregisterName] = function(self, eventname)
|
||||
if not self or self==target then
|
||||
error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
|
||||
end
|
||||
if type(eventname) ~= "string" then
|
||||
error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
|
||||
end
|
||||
if rawget(events, eventname) and events[eventname][self] then
|
||||
events[eventname][self] = nil
|
||||
-- Fire OnUnused callback?
|
||||
if registry.OnUnused and not next(events[eventname]) then
|
||||
registry.OnUnused(registry, target, eventname)
|
||||
end
|
||||
end
|
||||
if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
|
||||
registry.insertQueue[eventname][self] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- OPTIONAL: Unregister all callbacks for given selfs/addonIds
|
||||
if UnregisterAllName then
|
||||
target[UnregisterAllName] = function(...)
|
||||
if select("#",...)<1 then
|
||||
error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
|
||||
end
|
||||
if select("#",...)==1 and ...==target then
|
||||
error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
|
||||
end
|
||||
|
||||
|
||||
for i=1,select("#",...) do
|
||||
local self = select(i,...)
|
||||
if registry.insertQueue then
|
||||
for eventname, callbacks in pairs(registry.insertQueue) do
|
||||
if callbacks[self] then
|
||||
callbacks[self] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
for eventname, callbacks in pairs(events) do
|
||||
if callbacks[self] then
|
||||
callbacks[self] = nil
|
||||
-- Fire OnUnused callback?
|
||||
if registry.OnUnused and not next(callbacks) then
|
||||
registry.OnUnused(registry, target, eventname)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return registry
|
||||
end
|
||||
|
||||
|
||||
-- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
|
||||
-- try to upgrade old implicit embeds since the system is selfcontained and
|
||||
-- relies on closures to work.
|
||||
|
||||
+62
-30
@@ -1,6 +1,6 @@
|
||||
--[[
|
||||
--[[
|
||||
Name: LibSharedMedia-3.0
|
||||
Revision: $Revision: 53 $
|
||||
Revision: $Revision: 62 $
|
||||
Author: Elkano (elkano@gmx.de)
|
||||
Inspired By: SurfaceLib by Haste/Otravi (troeks@gmail.com)
|
||||
Website: http://www.wowace.com/projects/libsharedmedia-3-0/
|
||||
@@ -9,7 +9,7 @@ Dependencies: LibStub, CallbackHandler-1.0
|
||||
License: LGPL v2.1
|
||||
]]
|
||||
|
||||
local MAJOR, MINOR = "LibSharedMedia-3.0", 90000 + tonumber(("$Revision: 53 $"):match("(%d+)"))
|
||||
local MAJOR, MINOR = "LibSharedMedia-3.0", 3030002 -- 3.3.5 / increase manually on changes
|
||||
local lib = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not lib then return end
|
||||
@@ -20,8 +20,6 @@ local pairs = _G.pairs
|
||||
local type = _G.type
|
||||
|
||||
local band = _G.bit.band
|
||||
|
||||
local table_insert = _G.table.insert
|
||||
local table_sort = _G.table.sort
|
||||
|
||||
local locale = GetLocale()
|
||||
@@ -59,21 +57,31 @@ lib.MediaType.SOUND = "sound" -- sound files
|
||||
-- populate lib with default Blizzard data
|
||||
-- BACKGROUND
|
||||
if not lib.MediaTable.background then lib.MediaTable.background = {} end
|
||||
lib.MediaTable.background["Blizzard Dialog Background"] = [[Interface\DialogFrame\UI-DialogBox-Background]]
|
||||
lib.MediaTable.background["Blizzard Low Health"] = [[Interface\FullScreenTextures\LowHealth]]
|
||||
lib.MediaTable.background["Blizzard Out of Control"] = [[Interface\FullScreenTextures\OutOfControl]]
|
||||
lib.MediaTable.background["Blizzard Parchment"] = [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]]
|
||||
lib.MediaTable.background["Blizzard Parchment 2"] = [[Interface\AchievementFrame\UI-Achievement-Parchment]]
|
||||
lib.MediaTable.background["Blizzard Tabard Background"] = [[Interface\TabardFrame\TabardFrameBackground]]
|
||||
lib.MediaTable.background["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Background]]
|
||||
lib.MediaTable.background["Solid"] = [[Interface\Buttons\WHITE8X8]]
|
||||
lib.MediaTable.background["None"] = [[]]
|
||||
lib.MediaTable.background["Blizzard Dialog Background"] = [[Interface\DialogFrame\UI-DialogBox-Background]]
|
||||
lib.MediaTable.background["Blizzard Dialog Background Dark"] = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]]
|
||||
lib.MediaTable.background["Blizzard Dialog Background Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]
|
||||
lib.MediaTable.background["Blizzard Low Health"] = [[Interface\FullScreenTextures\LowHealth]]
|
||||
lib.MediaTable.background["Blizzard Marble"] = [[Interface\FrameGeneral\UI-Background-Marble]]
|
||||
lib.MediaTable.background["Blizzard Out of Control"] = [[Interface\FullScreenTextures\OutOfControl]]
|
||||
lib.MediaTable.background["Blizzard Parchment"] = [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]]
|
||||
lib.MediaTable.background["Blizzard Parchment 2"] = [[Interface\AchievementFrame\UI-GuildAchievement-Parchment-Horizontal]]
|
||||
lib.MediaTable.background["Blizzard Rock"] = [[Interface\FrameGeneral\UI-Background-Rock]]
|
||||
lib.MediaTable.background["Blizzard Tabard Background"] = [[Interface\TabardFrame\TabardFrameBackground]]
|
||||
lib.MediaTable.background["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Background]]
|
||||
lib.MediaTable.background["Solid"] = [[Interface\Buttons\WHITE8X8]]
|
||||
lib.DefaultMedia.background = "None"
|
||||
|
||||
-- BORDER
|
||||
if not lib.MediaTable.border then lib.MediaTable.border = {} end
|
||||
lib.MediaTable.border["None"] = [[Interface\None]]
|
||||
lib.MediaTable.border["None"] = [[]]
|
||||
lib.MediaTable.border["Blizzard Achievement Wood"] = [[Interface\AchievementFrame\UI-Achievement-WoodBorder]]
|
||||
lib.MediaTable.border["Blizzard Chat Bubble"] = [[Interface\Tooltips\ChatBubble-Backdrop]]
|
||||
lib.MediaTable.border["Blizzard Dialog"] = [[Interface\DialogFrame\UI-DialogBox-Border]]
|
||||
lib.MediaTable.border["Blizzard Dialog Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Border]]
|
||||
lib.MediaTable.border["Blizzard Party"] = [[Interface\CHARACTERFRAME\UI-Party-Border]]
|
||||
lib.MediaTable.border["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Border]]
|
||||
lib.DefaultMedia.border = "None"
|
||||
|
||||
-- FONT
|
||||
if not lib.MediaTable.font then lib.MediaTable.font = {} end
|
||||
@@ -91,9 +99,9 @@ if locale == "koKR" then
|
||||
elseif locale == "zhCN" then
|
||||
LOCALE_MASK = lib.LOCALE_BIT_zhCN
|
||||
--
|
||||
SML_MT_font["伤害数字"] = [[Fonts\ZYKai_C.ttf]]
|
||||
SML_MT_font["默认"] = [[Fonts\ZYKai_T.ttf]]
|
||||
SML_MT_font["聊天"] = [[Fonts\ZYHei.ttf]]
|
||||
SML_MT_font["伤害数字"] = [[Fonts\ARKai_C.ttf]]
|
||||
SML_MT_font["默认"] = [[Fonts\ARKai_T.ttf]]
|
||||
SML_MT_font["聊天"] = [[Fonts\ARHei.ttf]]
|
||||
--
|
||||
lib.DefaultMedia["font"] = "默认" -- someone from zhCN please adjust if needed
|
||||
--
|
||||
@@ -110,11 +118,17 @@ elseif locale == "zhTW" then
|
||||
elseif locale == "ruRU" then
|
||||
LOCALE_MASK = lib.LOCALE_BIT_ruRU
|
||||
--
|
||||
SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
|
||||
SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]]
|
||||
SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS.TTF]]
|
||||
SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
|
||||
SML_MT_font["Skurri"] = [[Fonts\SKURRI.TTF]]
|
||||
SML_MT_font["2002"] = [[Fonts\2002.TTF]]
|
||||
SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]]
|
||||
SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]]
|
||||
SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]]
|
||||
SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]]
|
||||
SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
|
||||
SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT___CYR.TTF]]
|
||||
SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]]
|
||||
SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]]
|
||||
SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
|
||||
SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]]
|
||||
--
|
||||
lib.DefaultMedia.font = "Friz Quadrata TT"
|
||||
--
|
||||
@@ -122,10 +136,17 @@ else
|
||||
LOCALE_MASK = lib.LOCALE_BIT_western
|
||||
locale_is_western = true
|
||||
--
|
||||
SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
|
||||
SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]]
|
||||
SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS.TTF]]
|
||||
SML_MT_font["Skurri"] = [[Fonts\SKURRI.TTF]]
|
||||
SML_MT_font["2002"] = [[Fonts\2002.TTF]]
|
||||
SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]]
|
||||
SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]]
|
||||
SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]]
|
||||
SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]]
|
||||
SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
|
||||
SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]]
|
||||
SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]]
|
||||
SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]]
|
||||
SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
|
||||
SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]]
|
||||
--
|
||||
lib.DefaultMedia.font = "Friz Quadrata TT"
|
||||
--
|
||||
@@ -134,11 +155,13 @@ end
|
||||
-- STATUSBAR
|
||||
if not lib.MediaTable.statusbar then lib.MediaTable.statusbar = {} end
|
||||
lib.MediaTable.statusbar["Blizzard"] = [[Interface\TargetingFrame\UI-StatusBar]]
|
||||
lib.MediaTable.statusbar["Blizzard Character Skills Bar"] = [[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]]
|
||||
lib.MediaTable.statusbar["Solid"] = [[Interface\Buttons\WHITE8X8]]
|
||||
lib.DefaultMedia.statusbar = "Blizzard"
|
||||
|
||||
-- SOUND
|
||||
if not lib.MediaTable.sound then lib.MediaTable.sound = {} end
|
||||
lib.MediaTable.sound["None"] = [[Interface\Quiet.mp3]] -- Relies on the fact that PlaySound[File] doesn't error on non-existing input.
|
||||
lib.MediaTable.sound["None"] = [[Interface\Quiet.ogg]] -- Relies on the fact that PlaySound[File] doesn't error on these values.
|
||||
lib.DefaultMedia.sound = "None"
|
||||
|
||||
local function rebuildMediaList(mediatype)
|
||||
@@ -162,8 +185,18 @@ function lib:Register(mediatype, key, data, langmask)
|
||||
if type(key) ~= "string" then
|
||||
error(MAJOR..":Register(mediatype, key, data, langmask) - key must be string, got "..type(key))
|
||||
end
|
||||
if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then return false end
|
||||
mediatype = mediatype:lower()
|
||||
if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then
|
||||
-- ignore fonts that aren't flagged as supporting local glyphs on non-western clients
|
||||
return false
|
||||
end
|
||||
if mediatype == lib.MediaType.SOUND and type(data) == "string" then
|
||||
local path = data:lower()
|
||||
if not path:find(".ogg", nil, true) and not path:find(".mp3", nil, true) and not path:find(".wav", nil, true) then
|
||||
-- Only wav, ogg and mp3 are valid sounds.
|
||||
return false
|
||||
end
|
||||
end
|
||||
if not mediaTable[mediatype] then mediaTable[mediatype] = {} end
|
||||
local mtable = mediaTable[mediatype]
|
||||
if mtable[key] then return false end
|
||||
@@ -178,8 +211,7 @@ function lib:Fetch(mediatype, key, noDefault)
|
||||
local mtt = mediaTable[mediatype]
|
||||
local overridekey = overrideMedia[mediatype]
|
||||
local result = mtt and ((overridekey and mtt[overridekey] or mtt[key]) or (not noDefault and defaultMedia[mediatype] and mtt[defaultMedia[mediatype]])) or nil
|
||||
|
||||
return result
|
||||
return result ~= "" and result or nil
|
||||
end
|
||||
|
||||
function lib:IsValid(mediatype, key)
|
||||
@@ -1,20 +0,0 @@
|
||||
## Interface: 30000
|
||||
## X-Curse-Packaged-Version: 2
|
||||
## X-Curse-Project-Name: LibSharedMedia-3.0
|
||||
## X-Curse-Project-ID: libsharedmedia-3-0
|
||||
## X-Curse-Repository-ID: wow/libsharedmedia-3-0/mainline
|
||||
|
||||
## Title: Lib: SharedMedia-3.0
|
||||
## Notes: Shared handling of media data (fonts, sounds, textures, ...) between addons.
|
||||
## Author: Elkano
|
||||
## Version: 3.0-59
|
||||
## X-Website: http://www.wowace.com/projects/libsharedmedia-3-0/
|
||||
## X-Category: Library
|
||||
|
||||
## X-Revision: 59
|
||||
## X-Date: 2009-03-06T10:12:34Z
|
||||
|
||||
LibStub\LibStub.lua
|
||||
CallbackHandler-1.0\CallbackHandler-1.0.lua
|
||||
|
||||
LibSharedMedia-3.0\lib.xml
|
||||
@@ -1,4 +0,0 @@
|
||||
<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="LibSharedMedia-3.0.lua" />
|
||||
</Ui>
|
||||
@@ -1,30 +0,0 @@
|
||||
-- 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]
|
||||
|
||||
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
|
||||
LibStub = LibStub or {libs = {}, minors = {} }
|
||||
_G[LIBSTUB_MAJOR] = LibStub
|
||||
LibStub.minor = LIBSTUB_MINOR
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
function LibStub:IterateLibraries() return pairs(self.libs) end
|
||||
setmetatable(LibStub, { __call = LibStub.GetLibrary })
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
<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">
|
||||
<Include file="LibSharedMedia-3.0\lib.xml" />
|
||||
</Ui>
|
||||
@@ -48,6 +48,8 @@ L["Ascending"] = "Ascending"
|
||||
L["Aura border style"] = "Aura border style"
|
||||
L["Aura filters"] = "Aura filters"
|
||||
L["Aura name"] = "Aura name"
|
||||
L["Aura name or spell ID"] = "Aura name or spell ID"
|
||||
L["Enter an exact aura name, or a numeric spell ID for precise matching (CoA's client exposes aura spell IDs)."] = "Enter an exact aura name, or a numeric spell ID for precise matching (CoA's client exposes aura spell IDs)."
|
||||
L["Auras"] = "Auras"
|
||||
L["Aura types to filter"] = "Aura types to filter"
|
||||
L["B"] = "B"
|
||||
|
||||
@@ -1,6 +1,47 @@
|
||||
local Auras = {}
|
||||
local stealableColor = {r = 1, g = 1, b = 1}
|
||||
local playerUnits = {player = true, vehicle = true, pet = true}
|
||||
|
||||
-- CoA: UnitAura "HARMFUL|RAID" only honours vanilla class dispels; custom classes
|
||||
-- need a manual type check. playerCoaDispels is nil until first checked, false if
|
||||
-- the player is not a dispelling CoA class, or a {type=true} set if they are.
|
||||
local playerCoaDispels
|
||||
-- Class tokens: MONK = Templar, PROPHET = Venomancer, WILDWALKER = Primalist
|
||||
-- (CoA in-game display names differ from internal class tokens).
|
||||
local COA_CLASS_DISPELS = {
|
||||
["CHRONOMANCER"] = { Magic = true, Curse = true, Disease = true, Poison = true },
|
||||
["MONK"] = { Magic = true, Disease = true, Poison = true }, -- Templar (Rebuke)
|
||||
["PROPHET"] = { Poison = true }, -- Venomancer (Antivenom)
|
||||
["PYROMANCER"] = { Disease = true, Poison = true },
|
||||
["RANGER"] = { Disease = true, Poison = true },
|
||||
["CULTIST"] = { Curse = true },
|
||||
["SONOFARUGAL"] = { Curse = true },
|
||||
["SPIRITMAGE"] = { Magic = true },
|
||||
["STARCALLER"] = { Magic = true },
|
||||
["WITCHHUNTER"] = { Curse = true },
|
||||
["SUNCLERIC"] = { Magic = true, Disease = true, Poison = true }, -- Sanctify
|
||||
["WILDWALKER"] = { Disease = true, Poison = true }, -- Primalist (Soothing Touch — DBC says Magic, gameplay is Poison/Disease)
|
||||
["WITCHDOCTOR"] = { Curse = true, Disease = true, Poison = true }, -- Hexbreak (806240, single-target Curse) + Cleansing Idol (504840, AoE Disease/Poison)
|
||||
["TINKER"] = { Disease = true, Poison = true }, -- Nanobot Cleanser
|
||||
}
|
||||
local function getCoaDispels()
|
||||
if playerCoaDispels ~= nil then return playerCoaDispels end
|
||||
-- Trust the COA_CLASS_DISPELS table directly: it only contains custom-class
|
||||
-- tokens, so any token-match implies the player IS a dispelling custom
|
||||
-- class. Avoids C_Player.IsCustomClass timing/availability issues (the
|
||||
-- API isn't reliable for every class on every login — Witchdoctor in
|
||||
-- particular was getting cached as false on raid frames).
|
||||
local _, token = UnitClass("player")
|
||||
if not token or token == "" then
|
||||
-- UnitClass not ready yet (very early init); don't cache — retry on
|
||||
-- the next scan so we pick it up once in-world.
|
||||
return nil
|
||||
end
|
||||
playerCoaDispels = COA_CLASS_DISPELS[token] or false
|
||||
return playerCoaDispels
|
||||
end
|
||||
-- Expose for other modules (highlight.lua) so the dispel set stays single-source.
|
||||
ShadowUF.GetCoaDispels = getCoaDispels
|
||||
local mainHand, offHand = {time = 0}, {time = 0}
|
||||
local tempEnchantScan
|
||||
ShadowUF:RegisterModule(Auras, "auras", ShadowUF.L["Auras"])
|
||||
@@ -479,14 +520,23 @@ end
|
||||
local function scan(parent, frame, type, config, filter)
|
||||
if( frame.totalAuras >= frame.maxAuras or not config.enabled ) then return end
|
||||
|
||||
-- CoA: |RAID is not honoured for custom classes; override with manual type check.
|
||||
local coaFilter
|
||||
if filter == "HARMFUL|RAID" then
|
||||
coaFilter = getCoaDispels()
|
||||
if coaFilter then filter = "HARMFUL" end
|
||||
end
|
||||
|
||||
local isFriendly = UnitIsFriend(frame.parent.unit, "player")
|
||||
local index = 0
|
||||
while( true ) do
|
||||
index = index + 1
|
||||
local name, rank, texture, count, auraType, duration, endTime, caster, isStealable = UnitAura(frame.parent.unit, index, filter)
|
||||
-- CoA's 3.3.5 client returns spellId as the 11th value (stock 3.3.5a stops at 10),
|
||||
-- which lets the whitelist/blacklist match by ID as well as by name.
|
||||
local name, rank, texture, count, auraType, duration, endTime, caster, isStealable, _, spellId = UnitAura(frame.parent.unit, index, filter)
|
||||
if( not name ) then break end
|
||||
|
||||
if( ( not config.player or playerUnits[caster] ) and ( not parent.whitelist[type] and not parent.blacklist[type] or parent.whitelist[type] and parent.whitelist[name] or parent.blacklist[type] and not parent.blacklist[name] ) ) then
|
||||
if( ( not coaFilter or (auraType and coaFilter[auraType]) ) and ( not config.player or playerUnits[caster] ) and ( not parent.whitelist[type] and not parent.blacklist[type] or parent.whitelist[type] and ( parent.whitelist[name] or parent.whitelist[spellId] ) or parent.blacklist[type] and not ( parent.blacklist[name] or parent.blacklist[spellId] ) ) ) then
|
||||
-- Create any buttons we need
|
||||
frame.totalAuras = frame.totalAuras + 1
|
||||
if( #(frame.buttons) < frame.totalAuras ) then
|
||||
|
||||
@@ -150,6 +150,29 @@ end
|
||||
|
||||
function Highlight:UpdateAura(frame)
|
||||
-- In theory, we don't need aura scanning because the first debuff returned is always one we can cure... in theory
|
||||
frame.highlight.hasDebuff = UnitIsFriend(frame.unit, "player") and select(5, UnitDebuff(frame.unit, 1, "RAID")) or nil
|
||||
if not UnitIsFriend(frame.unit, "player") then
|
||||
frame.highlight.hasDebuff = nil
|
||||
return self:Update(frame)
|
||||
end
|
||||
|
||||
-- CoA: "RAID" filter doesn't know about custom dispel classes (Witchdoctor, Templar, …);
|
||||
-- if the player is one of those, scan all debuffs and match against our dispel set.
|
||||
local coaDispels = ShadowUF.GetCoaDispels and ShadowUF.GetCoaDispels()
|
||||
if coaDispels then
|
||||
local hit
|
||||
local i = 1
|
||||
while true do
|
||||
local name, _, _, _, dispelType = UnitDebuff(frame.unit, i)
|
||||
if not name then break end
|
||||
if dispelType and coaDispels[dispelType] then
|
||||
hit = dispelType
|
||||
break
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
frame.highlight.hasDebuff = hit
|
||||
else
|
||||
frame.highlight.hasDebuff = select(5, UnitDebuff(frame.unit, 1, "RAID")) or nil
|
||||
end
|
||||
self:Update(frame)
|
||||
end
|
||||
|
||||
@@ -70,10 +70,12 @@ function Portrait:Update(frame, event)
|
||||
-- Use class thingy
|
||||
if( type == "class" ) then
|
||||
local classToken = select(2, UnitClass(frame.unitOwner))
|
||||
if( classToken ) then
|
||||
local coords = classToken and CLASS_ICON_TCOORDS[classToken]
|
||||
if( coords ) then
|
||||
frame.portrait:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes")
|
||||
frame.portrait:SetTexCoord(CLASS_ICON_TCOORDS[classToken][1], CLASS_ICON_TCOORDS[classToken][2], CLASS_ICON_TCOORDS[classToken][3], CLASS_ICON_TCOORDS[classToken][4])
|
||||
frame.portrait:SetTexCoord(coords[1], coords[2], coords[3], coords[4])
|
||||
else
|
||||
-- CoA custom classes (Witchdoctor/Templar/…) have no CLASS_ICON_TCOORDS entry; blank instead of crash
|
||||
frame.portrait:SetTexture("")
|
||||
end
|
||||
-- Use 2D character image
|
||||
|
||||
@@ -2,12 +2,32 @@ local Totems = {}
|
||||
local totemColors = {}
|
||||
local MAX_TOTEMS = MAX_TOTEMS
|
||||
|
||||
-- CoA: per-class slot count override (different from shaman's 4).
|
||||
local COA_CLASS_TOTEMS = {
|
||||
WITCHDOCTOR = 3,
|
||||
}
|
||||
|
||||
-- Death Knights untalented ghouls are guardians and are considered totems........... so set it up for them
|
||||
if( select(2, UnitClass("player")) == "DEATHKNIGHT" ) then
|
||||
local playerClass = select(2, UnitClass("player"))
|
||||
if( playerClass == "DEATHKNIGHT" ) then
|
||||
MAX_TOTEMS = 1
|
||||
ShadowUF:RegisterModule(Totems, "totemBar", ShadowUF.L["Guardian bar"], true, "DEATHKNIGHT")
|
||||
else
|
||||
ShadowUF:RegisterModule(Totems, "totemBar", ShadowUF.L["Totem bar"], true, "SHAMAN")
|
||||
-- CoA: SHAMAN is the vanilla totem class, but CoA custom classes (Witchdoctor, …) also use the
|
||||
-- multi-cast totem bar. Detect via MAX_TOTEMS > 1 (set by FrameXML for totem classes) or the
|
||||
-- HasMultiCastActionBar API (Bartender uses the same probe). Register with class=nil so the
|
||||
-- module is available to any CoA totem class, not just SHAMAN.
|
||||
local hasTotems = (MAX_TOTEMS and MAX_TOTEMS > 1)
|
||||
or (type(HasMultiCastActionBar) == "function" and HasMultiCastActionBar())
|
||||
or playerClass == "SHAMAN"
|
||||
if COA_CLASS_TOTEMS[playerClass] then
|
||||
MAX_TOTEMS = COA_CLASS_TOTEMS[playerClass]
|
||||
end
|
||||
if( hasTotems ) then
|
||||
ShadowUF:RegisterModule(Totems, "totemBar", ShadowUF.L["Totem bar"], true)
|
||||
else
|
||||
ShadowUF:RegisterModule(Totems, "totemBar", ShadowUF.L["Totem bar"], true, "SHAMAN")
|
||||
end
|
||||
end
|
||||
|
||||
function Totems:OnEnable(frame)
|
||||
@@ -17,11 +37,27 @@ function Totems:OnEnable(frame)
|
||||
|
||||
for id=1, MAX_TOTEMS do
|
||||
local totem = ShadowUF.Units:CreateBar(frame)
|
||||
totem:SetFrameLevel(1)
|
||||
-- Sit above the parent unit button (RegisterForClicks "AnyUp" + frame.menu)
|
||||
-- so right-clicks land on the totem strip instead of opening the unit popup.
|
||||
totem:SetFrameLevel((frame.topFrameLevel or 5) + 5)
|
||||
totem:SetMinMaxValues(0, 1)
|
||||
totem:SetValue(0)
|
||||
totem.id = MAX_TOTEMS == 1 and 1 or TOTEM_PRIORITIES[id]
|
||||
|
||||
-- Right-click dismisses the totem in this slot. EnableMouse on the strip
|
||||
-- absorbs clicks here (loses click-to-target on the totem bar only).
|
||||
totem:EnableMouse(true)
|
||||
totem:SetScript("OnMouseUp", function(self, button)
|
||||
if button == "RightButton" and self.have then
|
||||
DestroyTotem(self.id)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Seconds-remaining text, centred on the bar; updated by totemMonitor.
|
||||
totem.timeText = totem:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||
totem.timeText:SetPoint("CENTER", totem, "CENTER", 0, 0)
|
||||
totem.timeText:SetText("")
|
||||
|
||||
if( id > 1 ) then
|
||||
totem:SetPoint("TOPLEFT", frame.totemBar.totems[id - 1], "TOPRIGHT", 1, 0)
|
||||
else
|
||||
@@ -74,10 +110,23 @@ end
|
||||
|
||||
local function totemMonitor(self, elapsed)
|
||||
local time = GetTime()
|
||||
self:SetValue(self.endTime - time)
|
||||
local remaining = self.endTime - time
|
||||
self:SetValue(remaining)
|
||||
|
||||
if self.timeText then
|
||||
local intSec = remaining > 0 and math.floor(remaining) or 0
|
||||
if intSec ~= self.lastIntSec then
|
||||
self.lastIntSec = intSec
|
||||
self.timeText:SetText(intSec > 0 and intSec or "")
|
||||
end
|
||||
end
|
||||
|
||||
if( time >= self.endTime ) then
|
||||
self:SetValue(0)
|
||||
if self.timeText then
|
||||
self.timeText:SetText("")
|
||||
self.lastIntSec = nil
|
||||
end
|
||||
self:SetScript("OnUpdate", nil)
|
||||
end
|
||||
end
|
||||
@@ -101,6 +150,10 @@ function Totems:Update(frame)
|
||||
indicator:SetScript("OnUpdate", nil)
|
||||
indicator:SetMinMaxValues(0, 1)
|
||||
indicator:SetValue(0)
|
||||
if indicator.timeText then
|
||||
indicator.timeText:SetText("")
|
||||
indicator.lastIntSec = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -753,7 +753,15 @@ function Units:SetHeaderAttributes(frame, type)
|
||||
frame:SetAttribute("groupFilter", filter or "1,2,3,4,5,6,7,8")
|
||||
|
||||
if( config.groupBy == "CLASS" ) then
|
||||
frame:SetAttribute("groupingOrder", "DEATHKNIGHT,DRUID,HUNTER,MAGE,PALADIN,PRIEST,ROGUE,SHAMAN,WARLOCK,WARRIOR")
|
||||
-- CoA: build groupingOrder dynamically from RAID_CLASS_COLORS so all 21 CoA custom
|
||||
-- classes (populated via CUSTOM_CLASS_COLORS) are included. Hardcoding the 10
|
||||
-- vanilla classes silently drops Witchdoctor/Templar/… into an unsorted tail.
|
||||
local orderedClasses = {}
|
||||
for classToken in pairs(RAID_CLASS_COLORS) do
|
||||
table.insert(orderedClasses, classToken)
|
||||
end
|
||||
table.sort(orderedClasses)
|
||||
frame:SetAttribute("groupingOrder", table.concat(orderedClasses, ","))
|
||||
frame:SetAttribute("groupBy", "CLASS")
|
||||
else
|
||||
frame:SetAttribute("groupingOrder", "1,2,3,4,5,6,7,8")
|
||||
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build per-addon zip artefacts from HEAD via git-archive.
|
||||
#
|
||||
# - Discovers top-level addon folders (Foo/Foo.toc).
|
||||
# - Re-creates dist/ each run.
|
||||
# - Always archives HEAD, so the working tree state is irrelevant.
|
||||
# - If more than one addon folder is present, also emits <repo>-all.zip
|
||||
# with every addon folder side-by-side at the zip root.
|
||||
# - When run inside Gitea Actions the working tree lives under a
|
||||
# per-job dir like /var/lib/act_runner/work/.../hostexecutor, so the
|
||||
# repo name comes from $GITHUB_REPOSITORY (set by the runner) and
|
||||
# only falls back to the toplevel basename for local invocations.
|
||||
set -euo pipefail
|
||||
|
||||
root=$(git rev-parse --show-toplevel)
|
||||
cd "$root"
|
||||
|
||||
# Gitea Actions sets GITHUB_REPOSITORY=owner/repo. The basename of
|
||||
# `git rev-parse --show-toplevel` inside the runner is the worker dir
|
||||
# (e.g. `hostexecutor`), which would name the bundle wrong.
|
||||
if [ -n "${GITHUB_REPOSITORY:-}" ]; then
|
||||
repo_name="${GITHUB_REPOSITORY##*/}"
|
||||
else
|
||||
repo_name=$(basename "$root")
|
||||
fi
|
||||
dist="$root/dist"
|
||||
|
||||
# Find Foo/Foo.toc pairs at depth 1; ignore libs nested deeper.
|
||||
addons=()
|
||||
while IFS= read -r toc; do
|
||||
dir=$(dirname "$toc")
|
||||
folder=$(basename "$dir")
|
||||
base=$(basename "$toc" .toc)
|
||||
# Accept Foo.toc and Foo_Wrath.toc style flavour variants; folder must match
|
||||
# at least one toc basename prefix (Foo).
|
||||
case "$base" in
|
||||
"$folder"|"$folder"_*) addons+=("$folder") ;;
|
||||
esac
|
||||
done < <(command find . -mindepth 2 -maxdepth 2 -type f -name '*.toc' | sed 's|^\./||' | sort)
|
||||
|
||||
# Dedupe (a folder with Foo.toc + Foo_Wrath.toc shows up twice).
|
||||
if [ ${#addons[@]} -gt 0 ]; then
|
||||
mapfile -t addons < <(printf '%s\n' "${addons[@]}" | awk '!seen[$0]++')
|
||||
fi
|
||||
|
||||
if [ ${#addons[@]} -eq 0 ]; then
|
||||
echo "no addon folders found (looking for */Foo.toc with matching folder name)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "$dist"
|
||||
mkdir -p "$dist"
|
||||
|
||||
for folder in "${addons[@]}"; do
|
||||
out="$dist/$folder.zip"
|
||||
# No --prefix: the folder already sits at the repo root, so git-archive
|
||||
# emits entries as <folder>/... which is exactly what
|
||||
# Interface/AddOns/ expects after extraction.
|
||||
git archive HEAD --format=zip -o "$out" -- "$folder"
|
||||
echo "built dist/$folder.zip"
|
||||
done
|
||||
|
||||
# Combined bundle only makes sense when there are multiple addons.
|
||||
if [ ${#addons[@]} -gt 1 ]; then
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
git archive HEAD --format=tar -- "${addons[@]}" | tar -x -C "$tmp"
|
||||
out="$dist/$repo_name-all.zip"
|
||||
( cd "$tmp" && zip -qr "$out" "${addons[@]}" )
|
||||
echo "built dist/$repo_name-all.zip"
|
||||
fi
|
||||
Reference in New Issue
Block a user