16 Commits

Author SHA1 Message Date
florian.berthold efbc200ba7 fix(dispels): drop C_Player.IsCustomClass gate from getCoaDispels
release / release (push) Successful in 4s
Witchdoctor (and likely other CoA classes intermittently) never got the
"On curable debuff" border highlight on raid/party frames: the
C_Player.IsCustomClass() check in getCoaDispels could return false at
scan time and cache playerCoaDispels = false, after which the highlight
manual-scan path was never entered and the fallback RAID filter (which
doesn't know about COA dispel spells) silently returned nothing.

COA_CLASS_DISPELS only contains custom-class tokens (CHRONOMANCER,
WITCHDOCTOR, MONK = Templar, PROPHET = Venomancer, etc.) so any token
match already implies the player is a dispelling custom class — the
IsCustomClass call is redundant. Trust the table directly. Vanilla
classes whose tokens aren't in the table still get false → RAID filter
path, unchanged.

Bump v3.3.0-coa.2.
2026-05-27 22:55:04 +02:00
florian.berthold eba2da8400 ci: respect GITHUB_REPOSITORY + tolerate per-asset upload failures
release / release (push) Successful in 2s
2026-05-25 12:16:55 +02:00
florian.berthold 1558e6b18f ci: add Gitea Actions release workflow (per-addon git-archive zip)
release / release (push) Successful in 3s
2026-05-25 12:01:40 +02:00
florian.berthold 3686bb4f9f fix(totems): raise frame level so right-click reaches the totem strip
Parent unit button registers AnyUp clicks and opens the unit popup via
frame.menu — and was z-above the totem (which sat at frame level 1),
so right-clicks fell through to the popup instead of dismissing the
totem. Lift the totem to topFrameLevel + 5 so it wins the click.
2026-05-25 11:57:54 +02:00
florian.berthold c0a23544f1 feat(totems): right-click dismiss, Witchdoctor 3-slot cap, seconds counter
- Right-click on a populated totem slot calls DestroyTotem(slot).
  EnableMouse on the strip absorbs clicks (loses click-to-target on
  the totem-bar pixels only; health/power bar still targets normally).
- COA_CLASS_TOTEMS table overrides MAX_TOTEMS per class. WITCHDOCTOR
  capped to 3 so the 4th unused slot no longer renders. Easy to extend
  for any future custom totem classes.
- Integer-seconds countdown text centred on each slot. totemMonitor
  only repaints the FontString when the integer changes so OnUpdate
  stays cheap. Cleared on expiry / dismiss.
2026-05-25 11:51:11 +02:00
florian.berthold 5035f39364 fix(highlight): manual debuff scan for CoA dispel classes
UnitDebuff(unit, 1, "RAID") ignores CoA custom classes, so on a
Witchdoctor/Templar/etc. hasDebuff was always nil and the unit-frame
border highlight never lit up on curable Poison/Disease/Magic/Curse.

Fix mirrors the auras.lua shim: if ShadowUF.GetCoaDispels() returns a
dispel set, scan UnitDebuff entries manually and match by dispelType.
Expose getCoaDispels on the ShadowUF namespace so highlight.lua can
reuse the single source of truth (COA_CLASS_DISPELS lives in auras.lua).
2026-05-25 11:51:03 +02:00
florian.berthold 83bbe12a87 feat(dispels): include 4 more CoA classes in raid-frame dispel filter
COA_CLASS_DISPELS was missing Sun Cleric, Primalist (WILDWALKER token),
Witchdoctor, and Tinker — so members of those classes saw no dispel
highlighting on raid frames despite being able to cleanse. Sourced
dispel types from coa-decursive's DCR_init.lua spell map (Sanctify,
Soothing Touch, Cleansing Idol, Nanobot Cleanser), which is verified
against gameplay rather than DBC misc_value.

Also adds inline display-name comments for MONK / PROPHET / WILDWALKER
since the in-game class names don't match the internal tokens.
2026-05-25 11:23:42 +02:00
florian.berthold 1e2408fd0a chore: remove .github/ (upstream templates, not relevant on Gitea) 2026-05-25 11:02:51 +02:00
florian.berthold f8214b6b6c fix(libs): pick up coa-ace3 9583952 (AceDB falsy-defaults PR #10 backport)
Re-sync after coa-ace3 9583952 backported WoWUIDev/Ace3 PR #10 which fixes
the AceDB-3.0 simple-value defaults metatable: previously falsy defaults
like ["*"] = false read back as nil because of `k2~=nil and v or nil`
short-circuiting. Now they round-trip correctly.
2026-05-24 19:31:45 +02:00
florian.berthold 6605c1ca12 fix(libs): pick up coa-ace3 3ec2009 (BlizOptionsGroup + Settings.* CoA-compat)
Re-sync after coa-ace3 3ec2009 added two CoA-compat patches:
  - AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua: parent
    falls back to UIParent when InterfaceOptionsFramePanelContainer is nil
  - AceConfig-3.0/AceConfigDialog-3.0: Settings.* block guarded with
    fallback to InterfaceOptions_AddCategory on WotLK-era clients

Without these, every addon registering a Blizzard Interface Options
panel via AceConfigDialog errors on load on the CoA client.
2026-05-24 17:41:32 +02:00
florian.berthold 5d9749a920 fix: include CoA custom classes in portrait/totems/raid-grouping
portrait.lua: guard CLASS_ICON_TCOORDS[classToken] lookup. CoA custom
classes (Witchdoctor, Templar, …) have no entry in the vanilla
CLASS_ICON_TCOORDS table, so the old SetTexCoord call crashed with a
nil-index whenever a custom-class unit was shown. Cache the lookup
into a local and fall through to blank texture on miss.

totems.lua: file-level class gate registered the totem bar only for
SHAMAN (and a 1-slot DK guardian variant), locking out Witchdoctor and
any future CoA totem class. Probe MAX_TOTEMS > 1 / HasMultiCastActionBar
(Bartender's pattern) and register without a class filter when the
player has the multi-cast totem bar, so any CoA totem class picks it up.

units.lua: raid-header groupingOrder was the hardcoded 10-class vanilla
string, which dumped the 11 CoA custom classes into an unsorted tail
when GROUP BY CLASS was active. Build the order dynamically from
RAID_CLASS_COLORS (CoA populates this with all 21 classes via the
CUSTOM_CLASS_COLORS mechanism) at the call site.
2026-05-24 17:39:05 +02:00
florian.berthold ede7d2b23d chore(libs): sync shared LibStub-registered libs to canonical highest
Bumps in this fork:
  - LibSharedMedia-3.0

Brings these libs in line with the highest version any Exiles fork currently
bundles, so LibStub resolution is predictable regardless of load order.
2026-05-24 17:07:54 +02:00
florian.berthold 2d7349cafb fix(libs): pick up coa-ace3 d422ad3 (FileDataID → string paths)
Re-sync after coa-ace3 d422ad3 which converted 42 numeric FileDataIDs in
Set*Texture() calls back to string paths. Upstream Ace3 uses FDIDs which
silently fail on WoW 3.3.5 / CoA, rendering color swatches, checkboxes
and window chrome as solid-red placeholders.
2026-05-23 14:03:46 +02:00
florian.berthold da942631f0 chore(libs): sync Ace3 to coa-ace3 (WoWUIDev master @ 52e5f2c)
Bring every embedded Ace3 / CallbackHandler / LibStub copy in line with the
canonical Exiles/coa-ace3 bundle so LibStub resolution is predictable across
all Exiles forks regardless of which addons are enabled.

Libraries updated in this fork:
  AceConfig-3.0          3  (2 → 3)
  AceConfigCmd-3.0       14  (12 → 14)
  AceConfigDialog-3.0    92  (48 → 92)
  AceConfigRegistry-3.0  22  (12 → 22)
  AceDB-3.0              33  (21 → 33)
  AceDBOptions-3.0       15  (12 → 15)
  AceGUI-3.0             41  (33 → 41)
  CallbackHandler-1.0    8  (5 → 8)
  LibStub                2
2026-05-23 13:42:19 +02:00
florian.berthold 48ebec985b coa: fix CoA dispel detection timing in SUF aura scan
Previous approach baked playerCoaDispels into group.coaRaidFilter during
OnLayoutApplied, which can fire before PLAYER_LOGIN when C_Player isn't
ready yet — Venomancer and other CoA classes got cached as false and
never re-evaluated.

Fix: move all CoA logic into scan() itself so it runs on every
PLAYER_ENTERING_WORLD update. getCoaDispels() no longer caches when
C_Player is unavailable (returns nil without storing), so the first
successful in-world call populates it correctly.

updateGroup() is restored to its original form — no group.coaRaidFilter.
scan() intercepts filter=="HARMFUL|RAID", calls getCoaDispels(), and if
a dispel set is found strips |RAID and applies the per-type check inline.
2026-05-17 10:52:50 +02:00
florian.berthold 9679966f37 coa: fix "Show curable only" debuff filter for CoA custom classes
UnitAura "HARMFUL|RAID" only honours vanilla class dispel knowledge in
the 3.3.5 client — CoA custom classes (Chronomancer, Monk/Templar,
Prophet/Venomancer, etc.) were silently filtered to zero debuffs.

Fix: in updateGroup(), detect CoA dispellers via C_Player:IsCustomClass()
and store their per-class dispel set on group.coaRaidFilter instead of
appending |RAID.  scan() skips debuffs whose auraType is not in that
set, preserving contiguous button layout with no gaps.

Class → dispel types (sourced from coa-decursive):
  CHRONOMANCER  Magic/Curse/Disease/Poison (Roll Back 804490)
  MONK          Magic/Disease/Poison (Rebuke 525051)
  PROPHET       Poison (Antivenom 800905; curse-dispel doesn't fire)
  PYROMANCER    Disease/Poison
  RANGER        Disease/Poison
  CULTIST       Curse
  SONOFARUGAL   Curse
  SPIRITMAGE    Magic
  STARCALLER    Magic
  WITCHHUNTER   Curse
2026-05-17 06:08:34 +02:00
58 changed files with 12482 additions and 11800 deletions
+71
View File
@@ -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 ]
-77
View File
@@ -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
View File
@@ -1 +0,0 @@
blank_issues_enabled: false
-20
View File
@@ -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.
-28
View File
@@ -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 -->
+2 -1
View File
@@ -4,4 +4,5 @@
.install .install
.lua/* .lua/*
.vscode .vscode
.idea .idea
dist/
@@ -1,57 +1,58 @@
--- AceConfig-3.0 wrapper library. --- AceConfig-3.0 wrapper library.
-- Provides an API to register an options table with the config registry, -- Provides an API to register an options table with the config registry,
-- as well as associate it with a slash command. -- as well as associate it with a slash command.
-- @class file -- @class file
-- @name AceConfig-3.0 -- @name AceConfig-3.0
-- @release $Id: AceConfig-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $ -- @release $Id$
--[[ --[[
AceConfig-3.0 AceConfig-3.0
Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole. Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
]] ]]
local MAJOR, MINOR = "AceConfig-3.0", 2 local cfgreg = LibStub("AceConfigRegistry-3.0")
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR) local cfgcmd = LibStub("AceConfigCmd-3.0")
if not AceConfig then return end local MAJOR, MINOR = "AceConfig-3.0", 3
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
local cfgreg = LibStub("AceConfigRegistry-3.0")
local cfgcmd = LibStub("AceConfigCmd-3.0") if not AceConfig then return end
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 -- 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 -- - appName - (string) application name
-- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command -- - options - table or function ref, see AceConfigRegistry
-- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command
--- Register a option table with the AceConfig registry.
-- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly. --- Register a option table with the AceConfig registry.
-- @paramsig appName, options [, slashcmd] -- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
-- @param appName The application name for the config table. -- @paramsig appName, options [, slashcmd]
-- @param options The option table (or a function to generate one on demand) -- @param appName The application name for the config table.
-- @param slashcmd A slash command to register for the option table, or a table of slash commands. -- @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/
-- @usage -- @param slashcmd A slash command to register for the option table, or a table of slash commands.
-- local AceConfig = LibStub("AceConfig-3.0") -- @usage
-- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"}) -- local AceConfig = LibStub("AceConfig-3.0")
function AceConfig:RegisterOptionsTable(appName, options, slashcmd) -- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options) function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
if not ok then error(msg, 2) end local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
if not ok then error(msg, 2) end
if slashcmd then
if type(slashcmd) == "table" then if slashcmd then
for _,cmd in pairs(slashcmd) do if type(slashcmd) == "table" then
cfgcmd:CreateChatCommand(cmd, appName) for _,cmd in pairs(slashcmd) do
end cfgcmd:CreateChatCommand(cmd, appName)
else end
cfgcmd:CreateChatCommand(slashcmd, appName) else
end cfgcmd:CreateChatCommand(slashcmd, appName)
end end
end end
end
@@ -1,8 +1,8 @@
<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/ <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"> ..\FrameXML\UI.xsd">
<Include file="AceConfigRegistry-3.0\AceConfigRegistry-3.0.xml"/> <Include file="AceConfigRegistry-3.0\AceConfigRegistry-3.0.xml"/>
<Include file="AceConfigCmd-3.0\AceConfigCmd-3.0.xml"/> <Include file="AceConfigCmd-3.0\AceConfigCmd-3.0.xml"/>
<Include file="AceConfigDialog-3.0\AceConfigDialog-3.0.xml"/> <Include file="AceConfigDialog-3.0\AceConfigDialog-3.0.xml"/>
<!--<Include file="AceConfigDropdown-3.0\AceConfigDropdown-3.0.xml"/>--> <!--<Include file="AceConfigDropdown-3.0\AceConfigDropdown-3.0.xml"/>-->
<Script file="AceConfig-3.0.lua"/> <Script file="AceConfig-3.0.lua"/>
</Ui> </Ui>
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ <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"> ..\FrameXML\UI.xsd">
<Script file="AceConfigCmd-3.0.lua"/> <Script file="AceConfigCmd-3.0.lua"/>
</Ui> </Ui>
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ <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"> ..\FrameXML\UI.xsd">
<Script file="AceConfigDialog-3.0.lua"/> <Script file="AceConfigDialog-3.0.lua"/>
</Ui> </Ui>
@@ -1,346 +1,373 @@
--- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules.\\ --- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules.\\
-- Options tables can be registered as raw tables, OR as function refs that return a table.\\ -- Options tables can be registered as raw tables, OR as function refs that return a table.\\
-- Such functions receive three arguments: "uiType", "uiName", "appName". \\ -- Such functions receive three arguments: "uiType", "uiName", "appName". \\
-- * Valid **uiTypes**: "cmd", "dropdown", "dialog". This is verified by the library at call time. \\ -- * Valid **uiTypes**: "cmd", "dropdown", "dialog". This is verified by the library at call time. \\
-- * The **uiName** field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\ -- * The **uiName** field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\
-- * The **appName** field is the options table name as given at registration time \\ -- * The **appName** field is the options table name as given at registration time \\
-- --
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName". -- :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 -- @class file
-- @name AceConfigRegistry-3.0 -- @name AceConfigRegistry-3.0
-- @release $Id: AceConfigRegistry-3.0.lua 921 2010-05-09 15:49:14Z nevcairiel $ -- @release $Id$
local MAJOR, MINOR = "AceConfigRegistry-3.0", 12 local CallbackHandler = LibStub("CallbackHandler-1.0")
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
local MAJOR, MINOR = "AceConfigRegistry-3.0", 22
if not AceConfigRegistry then return end local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
AceConfigRegistry.tables = AceConfigRegistry.tables or {} if not AceConfigRegistry then return end
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0") AceConfigRegistry.tables = AceConfigRegistry.tables or {}
if not AceConfigRegistry.callbacks then if not AceConfigRegistry.callbacks then
AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry) AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
end end
-- Lua APIs -- Lua APIs
local tinsert, tconcat = table.insert, table.concat local tinsert, tconcat = table.insert, table.concat
local strfind, strmatch = string.find, string.match local strfind, strmatch = string.find, string.match
local type, tostring, select, pairs = type, tostring, select, pairs local type, tostring, select, pairs = type, tostring, select, pairs
local error, assert = error, assert local error, assert = error, assert
----------------------------------------------------------------------- -----------------------------------------------------------------------
-- Validating options table consistency: -- Validating options table consistency:
AceConfigRegistry.validated = { AceConfigRegistry.validated = {
-- list of options table names ran through :ValidateOptionsTable automatically. -- list of options table names ran through :ValidateOptionsTable automatically.
-- CLEARED ON PURPOSE, since newer versions may have newer validators -- CLEARED ON PURPOSE, since newer versions may have newer validators
cmd = {}, cmd = {},
dropdown = {}, dropdown = {},
dialog = {}, dialog = {},
} }
local function err(msg, errlvl, ...) local function err(msg, errlvl, ...)
local t = {} local t = {}
for i=select("#",...),1,-1 do for i=select("#",...),1,-1 do
tinsert(t, (select(i, ...))) tinsert(t, (select(i, ...)))
end end
error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2) error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
end end
local isstring={["string"]=true, _="string"} local isstring={["string"]=true, _="string"}
local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"} local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"}
local istable={["table"]=true, _="table"} local istable={["table"]=true, _="table"}
local ismethodtable={["table"]=true,["string"]=true,["function"]=true, _="methodname, funcref or table"} local ismethodtable={["table"]=true,["string"]=true,["function"]=true, _="methodname, funcref or table"}
local optstring={["nil"]=true,["string"]=true, _="string"} local optstring={["nil"]=true,["string"]=true, _="string"}
local optstringfunc={["nil"]=true,["string"]=true,["function"]=true, _="string or funcref"} local optstringfunc={["nil"]=true,["string"]=true,["function"]=true, _="string or funcref"}
local optnumber={["nil"]=true,["number"]=true, _="number"} local optstringnumberfunc={["nil"]=true,["string"]=true,["number"]=true,["function"]=true, _="string, number or funcref"}
local optmethod={["nil"]=true,["string"]=true,["function"]=true, _="methodname or funcref"} local optnumber={["nil"]=true,["number"]=true, _="number"}
local optmethodfalse={["nil"]=true,["string"]=true,["function"]=true,["boolean"]={[false]=true}, _="methodname, funcref or false"} 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 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"} local optmethodtable={["nil"]=true,["string"]=true,["function"]=true,["table"]=true, _="methodname, funcref or table"}
local optmethodbool={["nil"]=true,["string"]=true,["function"]=true,["boolean"]=true, _="methodname, funcref or boolean"} local optmethodbool={["nil"]=true,["string"]=true,["function"]=true,["boolean"]=true, _="methodname, funcref or boolean"}
local opttable={["nil"]=true,["table"]=true, _="table"} local opttable={["nil"]=true,["table"]=true, _="table"}
local optbool={["nil"]=true,["boolean"]=true, _="boolean"} local optbool={["nil"]=true,["boolean"]=true, _="boolean"}
local optboolnumber={["nil"]=true,["boolean"]=true,["number"]=true, _="boolean or number"} 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, local basekeys={
name=isstringfunc, type=isstring,
desc=optstringfunc, name=isstringfunc,
descStyle=optstring, desc=optstringfunc,
order=optmethodnumber, descStyle=optstring,
validate=optmethodfalse, order=optmethodnumber,
confirm=optmethodbool, validate=optmethodfalse,
confirmText=optstring, confirm=optmethodbool,
disabled=optmethodbool, confirmText=optstring,
hidden=optmethodbool, disabled=optmethodbool,
guiHidden=optmethodbool, hidden=optmethodbool,
dialogHidden=optmethodbool, guiHidden=optmethodbool,
dropdownHidden=optmethodbool, dialogHidden=optmethodbool,
cmdHidden=optmethodbool, dropdownHidden=optmethodbool,
icon=optstringfunc, cmdHidden=optmethodbool,
iconCoords=optmethodtable, tooltipHyperlink=optstringfunc,
handler=opttable, icon=optstringnumberfunc,
get=optmethodfalse, iconCoords=optmethodtable,
set=optmethodfalse, handler=opttable,
func=optmethodfalse, get=optmethodfalse,
arg={["*"]=true}, set=optmethodfalse,
width=optstring, func=optmethodfalse,
} arg={["*"]=true},
width=optstringnumber,
local typedkeys={ relWidth=optnumber,
header={}, }
description={
image=optstringfunc, local typedkeys={
imageCoords=optmethodtable, header={
imageHeight=optnumber, control=optstring,
imageWidth=optnumber, dialogControl=optstring,
fontSize=optstringfunc, dropdownControl=optstring,
}, },
group={ description={
args=istable, image=optstringnumberfunc,
plugins=opttable, imageCoords=optmethodtable,
inline=optbool, imageHeight=optnumber,
cmdInline=optbool, imageWidth=optnumber,
guiInline=optbool, fontSize=optstringfunc,
dropdownInline=optbool, control=optstring,
dialogInline=optbool, dialogControl=optstring,
childGroups=optstring, dropdownControl=optstring,
}, },
execute={ group={
image=optstringfunc, args=istable,
imageCoords=optmethodtable, plugins=opttable,
imageHeight=optnumber, inline=optbool,
imageWidth=optnumber, cmdInline=optbool,
}, guiInline=optbool,
input={ dropdownInline=optbool,
pattern=optstring, dialogInline=optbool,
usage=optstring, childGroups=optstring,
control=optstring, },
dialogControl=optstring, execute={
dropdownControl=optstring, image=optstringnumberfunc,
multiline=optboolnumber, imageCoords=optmethodtable,
}, imageHeight=optnumber,
toggle={ imageWidth=optnumber,
tristate=optbool, control=optstring,
image=optstringfunc, dialogControl=optstring,
imageCoords=optmethodtable, dropdownControl=optstring,
}, },
tristate={ input={
}, pattern=optstring,
range={ usage=optstring,
min=optnumber, control=optstring,
softMin=optnumber, dialogControl=optstring,
max=optnumber, dropdownControl=optstring,
softMax=optnumber, multiline=optboolnumber,
step=optnumber, },
bigStep=optnumber, toggle={
isPercent=optbool, tristate=optbool,
}, image=optstringnumberfunc,
select={ imageCoords=optmethodtable,
values=ismethodtable, control=optstring,
style={ dialogControl=optstring,
["nil"]=true, dropdownControl=optstring,
["string"]={dropdown=true,radio=true}, },
_="string: 'dropdown' or 'radio'" tristate={
}, },
control=optstring, range={
dialogControl=optstring, min=optnumber,
dropdownControl=optstring, softMin=optnumber,
}, max=optnumber,
multiselect={ softMax=optnumber,
values=ismethodtable, step=optnumber,
style=optstring, bigStep=optnumber,
tristate=optbool, isPercent=optbool,
control=optstring, control=optstring,
dialogControl=optstring, dialogControl=optstring,
dropdownControl=optstring, dropdownControl=optstring,
}, },
color={ select={
hasAlpha=optbool, values=ismethodtable,
}, sorting=optmethodtable,
keybinding={ style={
-- TODO ["nil"]=true,
}, ["string"]={dropdown=true,radio=true},
} _="string: 'dropdown' or 'radio'"
},
local function validateKey(k,errlvl,...) control=optstring,
errlvl=(errlvl or 0)+1 dialogControl=optstring,
if type(k)~="string" then dropdownControl=optstring,
err("["..tostring(k).."] - key is not a string", errlvl,...) itemControl=optstring,
end },
if strfind(k, "[%c\127]") then multiselect={
err("["..tostring(k).."] - key name contained control characters", errlvl,...) values=ismethodtable,
end style=optstring,
end tristate=optbool,
control=optstring,
local function validateVal(v, oktypes, errlvl,...) dialogControl=optstring,
errlvl=(errlvl or 0)+1 dropdownControl=optstring,
local isok=oktypes[type(v)] or oktypes["*"] },
color={
if not isok then hasAlpha=optmethodbool,
err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,...) control=optstring,
end dialogControl=optstring,
if type(isok)=="table" then -- isok was a table containing specific values to be tested for! dropdownControl=optstring,
if not isok[v] then },
err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl,...) keybinding={
end control=optstring,
end dialogControl=optstring,
end dropdownControl=optstring,
},
local function validate(options,errlvl,...) }
errlvl=(errlvl or 0)+1
-- basic consistency local function validateKey(k,errlvl,...)
if type(options)~="table" then errlvl=(errlvl or 0)+1
err(": expected a table, got a "..type(options), errlvl,...) if type(k)~="string" then
end err("["..tostring(k).."] - key is not a string", errlvl,...)
if type(options.type)~="string" then end
err(".type: expected a string, got a "..type(options.type), errlvl,...) if strfind(k, "[%c\127]") then
end err("["..tostring(k).."] - key name contained control characters", errlvl,...)
end
-- get type and 'typedkeys' member end
local tk = typedkeys[options.type]
if not tk then local function validateVal(v, oktypes, errlvl,...)
err(".type: unknown type '"..options.type.."'", errlvl,...) errlvl=(errlvl or 0)+1
end local isok=oktypes[type(v)] or oktypes["*"]
-- make sure that all options[] are known parameters if not isok then
for k,v in pairs(options) do err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,...)
if not (tk[k] or basekeys[k]) then end
err(": unknown parameter", errlvl,tostring(k),...) if type(isok)=="table" then -- isok was a table containing specific values to be tested for!
end if not isok[v] then
end err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl,...)
end
-- verify that required params are there, and that everything is the right type end
for k,oktypes in pairs(basekeys) do end
validateVal(options[k], oktypes, errlvl,k,...)
end local function validate(options,errlvl,...)
for k,oktypes in pairs(tk) do errlvl=(errlvl or 0)+1
validateVal(options[k], oktypes, errlvl,k,...) -- basic consistency
end if type(options)~="table" then
err(": expected a table, got a "..type(options), errlvl,...)
-- extra logic for groups end
if options.type=="group" then if type(options.type)~="string" then
for k,v in pairs(options.args) do err(".type: expected a string, got a "..type(options.type), errlvl,...)
validateKey(k,errlvl,"args",...) end
validate(v, errlvl,k,"args",...)
end -- get type and 'typedkeys' member
if options.plugins then local tk = typedkeys[options.type]
for plugname,plugin in pairs(options.plugins) do if not tk then
if type(plugin)~="table" then err(".type: unknown type '"..options.type.."'", errlvl,...)
err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname),"plugins",...) end
end
for k,v in pairs(plugin) do -- make sure that all options[] are known parameters
validateKey(k,errlvl,tostring(plugname),"plugins",...) for k,v in pairs(options) do
validate(v, errlvl,k,tostring(plugname),"plugins",...) if not (tk[k] or basekeys[k]) then
end err(": unknown parameter", errlvl,tostring(k),...)
end end
end end
end
end -- verify that required params are there, and that everything is the right type
for k,oktypes in pairs(basekeys) do
validateVal(options[k], oktypes, errlvl,k,...)
--- Validates basic structure and integrity of an options table \\ end
-- Does NOT verify that get/set etc actually exist, since they can be defined at any depth for k,oktypes in pairs(tk) do
-- @param options The table to be validated validateVal(options[k], oktypes, errlvl,k,...)
-- @param name The name of the table to be validated (shown in any error message) end
-- @param errlvl (optional number) error level offset, default 0 (=errors point to the function calling :ValidateOptionsTable)
function AceConfigRegistry:ValidateOptionsTable(options,name,errlvl) -- extra logic for groups
errlvl=(errlvl or 0)+1 if options.type=="group" then
name = name or "Optionstable" for k,v in pairs(options.args) do
if not options.name then validateKey(k,errlvl,"args",...)
options.name=name -- bit of a hack, the root level doesn't really need a .name :-/ validate(v, errlvl,k,"args",...)
end end
validate(options,errlvl,name) if options.plugins then
end for plugname,plugin in pairs(options.plugins) do
if type(plugin)~="table" then
--- Fires a "ConfigTableChange" callback for those listening in on it, allowing config GUIs to refresh. err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname),"plugins",...)
-- You should call this function if your options table changed from any outside event, like a game event end
-- or a timer. for k,v in pairs(plugin) do
-- @param appName The application name as given to `:RegisterOptionsTable()` validateKey(k,errlvl,tostring(plugname),"plugins",...)
function AceConfigRegistry:NotifyChange(appName) validate(v, errlvl,k,tostring(plugname),"plugins",...)
if not AceConfigRegistry.tables[appName] then return end end
AceConfigRegistry.callbacks:Fire("ConfigTableChange", appName) end
end end
end
-- ------------------------------------------------------------------- end
-- Registering and retreiving options tables:
--- Validates basic structure and integrity of an options table \\
-- validateGetterArgs: helper function for :GetOptionsTable (or, rather, the getter functions returned by it) -- Does NOT verify that get/set etc actually exist, since they can be defined at any depth
-- @param options The table to be validated
local function validateGetterArgs(uiType, uiName, errlvl) -- @param name The name of the table to be validated (shown in any error message)
errlvl=(errlvl or 0)+2 -- @param errlvl (optional number) error level offset, default 0 (=errors point to the function calling :ValidateOptionsTable)
if uiType~="cmd" and uiType~="dropdown" and uiType~="dialog" then function AceConfigRegistry:ValidateOptionsTable(options,name,errlvl)
error(MAJOR..": Requesting options table: 'uiType' - invalid configuration UI type, expected 'cmd', 'dropdown' or 'dialog'", errlvl) errlvl=(errlvl or 0)+1
end name = name or "Optionstable"
if not strmatch(uiName, "[A-Za-z]%-[0-9]") then -- Expecting e.g. "MyLib-1.2" if not options.name then
error(MAJOR..": Requesting options table: 'uiName' - badly formatted or missing version number. Expected e.g. 'MyLib-1.2'", errlvl) options.name=name -- bit of a hack, the root level doesn't really need a .name :-/
end end
end validate(options,errlvl,name)
end
--- Register an options table with the config registry.
-- @param appName The application name as given to `:RegisterOptionsTable()` --- Fires a "ConfigTableChange" callback for those listening in on it, allowing config GUIs to refresh.
-- @param options The options table, OR a function reference that generates it on demand. \\ -- You should call this function if your options table changed from any outside event, like a game event
-- See the top of the page for info on arguments passed to such functions. -- or a timer.
function AceConfigRegistry:RegisterOptionsTable(appName, options) -- @param appName The application name as given to `:RegisterOptionsTable()`
if type(options)=="table" then function AceConfigRegistry:NotifyChange(appName)
if options.type~="group" then -- quick sanity checker if not AceConfigRegistry.tables[appName] then return end
error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2) AceConfigRegistry.callbacks:Fire("ConfigTableChange", appName)
end end
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
errlvl=(errlvl or 0)+1 -- -------------------------------------------------------------------
validateGetterArgs(uiType, uiName, errlvl) -- Registering and retreiving options tables:
if not AceConfigRegistry.validated[uiType][appName] then
AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
AceConfigRegistry.validated[uiType][appName] = true -- validateGetterArgs: helper function for :GetOptionsTable (or, rather, the getter functions returned by it)
end
return options local function validateGetterArgs(uiType, uiName, errlvl)
end errlvl=(errlvl or 0)+2
elseif type(options)=="function" then if uiType~="cmd" and uiType~="dropdown" and uiType~="dialog" then
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl) error(MAJOR..": Requesting options table: 'uiType' - invalid configuration UI type, expected 'cmd', 'dropdown' or 'dialog'", errlvl)
errlvl=(errlvl or 0)+1 end
validateGetterArgs(uiType, uiName, errlvl) if not strmatch(uiName, "[A-Za-z]%-[0-9]") then -- Expecting e.g. "MyLib-1.2"
local tab = assert(options(uiType, uiName, appName)) error(MAJOR..": Requesting options table: 'uiName' - badly formatted or missing version number. Expected e.g. 'MyLib-1.2'", errlvl)
if not AceConfigRegistry.validated[uiType][appName] then end
AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable end
AceConfigRegistry.validated[uiType][appName] = true
end --- Register an options table with the config registry.
return tab -- @param appName The application name as given to `:RegisterOptionsTable()`
end -- @param options The options table, OR a function reference that generates it on demand. \\
else -- See the top of the page for info on arguments passed to such functions.
error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - expected table or function reference", 2) -- @param skipValidation Skip options table validation (primarily useful for extremely huge options, with a noticeable slowdown)
end function AceConfigRegistry:RegisterOptionsTable(appName, options, skipValidation)
end if type(options)=="table" then
if options.type~="group" then -- quick sanity checker
--- Returns an iterator of ["appName"]=funcref pairs error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2)
function AceConfigRegistry:IterateOptionsTables() end
return pairs(AceConfigRegistry.tables) AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
end errlvl=(errlvl or 0)+1
validateGetterArgs(uiType, uiName, errlvl)
if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
AceConfigRegistry.validated[uiType][appName] = true
--- Query the registry for a specific options table. end
-- If only appName is given, a function is returned which you return options
-- can call with (uiType,uiName) to get the table.\\ end
-- If uiType&uiName are given, the table is returned. elseif type(options)=="function" then
-- @param appName The application name as given to `:RegisterOptionsTable()` AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
-- @param uiType The type of UI to get the table for, one of "cmd", "dropdown", "dialog" errlvl=(errlvl or 0)+1
-- @param uiName The name of the library/addon querying for the table, e.g. "MyLib-1.0" validateGetterArgs(uiType, uiName, errlvl)
function AceConfigRegistry:GetOptionsTable(appName, uiType, uiName) local tab = assert(options(uiType, uiName, appName))
local f = AceConfigRegistry.tables[appName] if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
if not f then AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
return nil AceConfigRegistry.validated[uiType][appName] = true
end end
return tab
if uiType then end
return f(uiType,uiName,1) -- get the table for us else
else error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - expected table or function reference", 2)
return f -- return the function end
end end
end
--- Returns an iterator of ["appName"]=funcref pairs
function AceConfigRegistry:IterateOptionsTables()
return pairs(AceConfigRegistry.tables)
end
--- Query the registry for a specific options table.
-- If only appName is given, a function is returned which you
-- can call with (uiType,uiName) to get the table.\\
-- If uiType&uiName are given, the table is returned.
-- @param appName The application name as given to `:RegisterOptionsTable()`
-- @param uiType The type of UI to get the table for, one of "cmd", "dropdown", "dialog"
-- @param uiName The name of the library/addon querying for the table, e.g. "MyLib-1.0"
function AceConfigRegistry:GetOptionsTable(appName, uiType, uiName)
local f = AceConfigRegistry.tables[appName]
if not f then
return nil
end
if uiType then
return f(uiType,uiName,1) -- get the table for us
else
return f -- return the function
end
end
@@ -1,4 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ <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"> ..\FrameXML\UI.xsd">
<Script file="AceConfigRegistry-3.0.lua"/> <Script file="AceConfigRegistry-3.0.lua"/>
</Ui> </Ui>
@@ -1,420 +1,456 @@
--- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles. --- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles.
-- @class file -- @class file
-- @name AceDBOptions-3.0 -- @name AceDBOptions-3.0
-- @release $Id: AceDBOptions-3.0.lua 938 2010-06-13 07:21:38Z nevcairiel $ -- @release $Id$
local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 12 local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 15
local AceDBOptions, oldminor = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR) local AceDBOptions = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR)
if not AceDBOptions then return end -- No upgrade needed if not AceDBOptions then return end -- No upgrade needed
-- Lua APIs -- Lua APIs
local pairs, next = pairs, next local pairs, next = pairs, next
-- WoW APIs -- WoW APIs
local UnitClass = UnitClass local UnitClass = UnitClass
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded AceDBOptions.optionTables = AceDBOptions.optionTables or {}
-- List them here for Mikk's FindGlobals script AceDBOptions.handlers = AceDBOptions.handlers or {}
-- GLOBALS: NORMAL_FONT_COLOR_CODE, FONT_COLOR_CODE_CLOSE
--[[
AceDBOptions.optionTables = AceDBOptions.optionTables or {} Localization of AceDBOptions-3.0
AceDBOptions.handlers = AceDBOptions.handlers or {} ]]
--[[ local L = {
Localization of AceDBOptions-3.0 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.",
local L = { copy = "Copy From",
default = "Default", copy_desc = "Copy the settings from one existing profile into the currently active profile.",
intro = "You can change the active database profile, so you can have different settings for every character.", current = "Current 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.", default = "Default",
reset = "Reset Profile", delete = "Delete a Profile",
reset_sub = "Reset the current profile to the default", delete_confirm = "Are you sure you want to delete the selected profile?",
choose_desc = "You can either create a new profile by entering a name in the editbox, or choose one of the already existing profiles.", delete_desc = "Delete existing and unused profiles from the database to save space, and cleanup the SavedVariables file.",
new = "New", delete_sub = "Deletes a profile from the database.",
new_sub = "Create a new empty profile.", intro = "You can change the active database profile, so you can have different settings for every character.",
choose = "Existing Profiles", new = "New",
choose_sub = "Select one of your currently available profiles.", new_sub = "Create a new empty profile.",
copy_desc = "Copy the settings from one existing profile into the currently active profile.", profiles = "Profiles",
copy = "Copy From", profiles_sub = "Manage Profiles",
delete_desc = "Delete existing and unused profiles from the database to save space, and cleanup the SavedVariables file.", reset = "Reset Profile",
delete = "Delete a 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.",
delete_sub = "Deletes a profile from the database.", reset_sub = "Reset the current profile to the default",
delete_confirm = "Are you sure you want to delete the selected profile?", }
profiles = "Profiles",
profiles_sub = "Manage Profiles", local LOCALE = GetLocale()
current = "Current Profile:", 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."
local LOCALE = GetLocale() L["choose_sub"] = "Wählt ein bereits vorhandenes Profil aus."
if LOCALE == "deDE" then L["copy"] = "Kopieren von..."
L["default"] = "Standard" L["copy_desc"] = "Kopiere die Einstellungen von einem vorhandenen Profil in das aktive Profil."
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["current"] = "Aktuelles Profil:"
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["default"] = "Standard"
L["reset"] = "Profil zur\195\188cksetzen" L["delete"] = "Profil löschen"
L["reset_sub"] = "Das aktuelle Profil auf Standard zur\195\188cksetzen." L["delete_confirm"] = "Willst du das ausgewählte Profil wirklich löschen?"
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_desc"] = "Lösche vorhandene oder unbenutzte Profile aus der Datenbank, um Platz zu sparen und die SavedVariables-Datei 'sauber' zu halten."
L["new"] = "Neu" L["delete_sub"] = "Löscht ein Profil aus der Datenbank."
L["new_sub"] = "Ein neues Profil erstellen." 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["choose"] = "Vorhandene Profile" L["new"] = "Neu"
L["choose_sub"] = "W\195\164hlt ein bereits vorhandenes Profil aus." L["new_sub"] = "Ein neues Profil erstellen."
L["copy_desc"] = "Kopiere die Einstellungen von einem vorhandenen Profil in das aktive Profil." L["profiles"] = "Profile"
L["copy"] = "Kopieren von..." L["profiles_sub"] = "Profile verwalten"
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["reset"] = "Profil zurücksetzen"
L["delete"] = "Profil l\195\182schen" 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["delete_sub"] = "L\195\182scht ein Profil aus der Datenbank." L["reset_sub"] = "Das aktuelle Profil auf Standard zurücksetzen."
L["delete_confirm"] = "Willst du das ausgew\195\164hlte Profil wirklich l\195\182schen?" elseif LOCALE == "frFR" then
L["profiles"] = "Profile" L["choose"] = "Profils existants"
L["profiles_sub"] = "Profile verwalten" 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["current"] = "Current Profile:" L["choose_sub"] = "Permet de choisir un des profils déjà disponibles."
elseif LOCALE == "frFR" then L["copy"] = "Copier à partir de"
L["default"] = "D\195\169faut" L["copy_desc"] = "Copie les paramètres d'un profil déjà existant dans le profil actuellement actif."
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["current"] = "Profil actuel :"
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["default"] = "Défaut"
L["reset"] = "R\195\169initialiser le profil" L["delete"] = "Supprimer un profil"
L["reset_sub"] = "R\195\169initialise le profil actuel avec les param\195\168tres par d\195\169faut." L["delete_confirm"] = "Etes-vous sûr de vouloir supprimer le profil sélectionné ?"
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["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["new"] = "Nouveau" L["delete_sub"] = "Supprime un profil de la base de données."
L["new_sub"] = "Cr\195\169\195\169e un nouveau profil vierge." 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["choose"] = "Profils existants" L["new"] = "Nouveau"
L["choose_sub"] = "Permet de choisir un des profils d\195\169j\195\160 disponibles." L["new_sub"] = "Créée un nouveau profil vierge."
L["copy_desc"] = "Copie les param\195\168tres d'un profil d\195\169j\195\160 existant dans le profil actuellement actif." L["profiles"] = "Profils"
L["copy"] = "Copier \195\160 partir de" L["profiles_sub"] = "Gestion des profils"
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["reset"] = "Réinitialiser le profil"
L["delete"] = "Supprimer un 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["delete_sub"] = "Supprime un profil de la base de donn\195\169es." L["reset_sub"] = "Réinitialise le profil actuel avec les paramètres par défaut."
L["delete_confirm"] = "Etes-vous s\195\187r de vouloir supprimer le profil s\195\169lectionn\195\169 ?" elseif LOCALE == "koKR" then
L["profiles"] = "Profils" L["choose"] = "기존 프로필"
L["profiles_sub"] = "Gestion des profils" L["choose_desc"] = "편집 상자에 이름을 입력하여 새로운 프로필을 만들거나 이미 존재하는 프로필 중 하나를 선택할 수 있습니다."
--L["current"] = "Current Profile:" L["choose_sub"] = "현재 이용할 수 있는 프로필 중 하나를 선택합니다."
elseif LOCALE == "koKR" then L["copy"] = "복사해 올 프로필"
L["default"] = "본값" L["copy_desc"] = "존 프로필의 설정을 현재 활성화된 프로필로 복사합니다."
L["intro"] = "모든 캐릭터의 다양한 설정과 사용중인 데이터베이스 프로필, 어느것이던지 매우 다루기 쉽게 바꿀수 있습니다." L["current"] = "현재 프로필:"
L["reset_desc"] = "단순히 다시 새롭게 구성을 원하는 경우, 현재 프로필을 기본값으로 초기화 합니다." L["default"] = "기본값"
L["reset"] = "프로필 초기화" L["delete"] = "프로필 삭제"
L["reset_sub"] = "현재의 프로필을 기본값으로 초기화 합니다" L["delete_confirm"] = "선택한 프로필을 삭제하시겠습니까?"
L["choose_desc"] = "새로운 이름을 입력하거나, 이미 있는 프로필중 하나를 선택하여 새로운 프로필을 만들 수 있습니다." L["delete_desc"] = "데이터베이스에서 기존 프로필과 사용하지 않는 프로필을 삭제하여 공간을 절약하고 SavedVariables 파일을 정리합니다."
L["new"] = "새로운 프로필" L["delete_sub"] = "데이터베이스에서 프로필을 삭제합니다."
L["new_sub"] = "새로운 프로필을 만듭니다." L["intro"] = "활성 데이터베이스 프로필을 변경할 수 있으며, 모든 캐릭터마다 서로 다른 설정을 지정할 수 있습니다."
L["choose"] = "프로필 선택" L["new"] = "새로운 프로필"
L["choose_sub"] = "당신이 현재 이용할수 있는 프로필을 선택합니다." L["new_sub"] = "비어 있는 프로필을 새로 만듭니다."
L["copy_desc"] = "현재 사용중인 프로필에, 선택한 프로필의 설정을 복사합니다." L["profiles"] = "프로필"
L["copy"] = "복사" L["profiles_sub"] = "프로필 관리"
L["delete_desc"] = "데이터베이스에 사용중이거나 저장된 프로파일 삭제로 SavedVariables 파일의 정리와 공간 절약이 됩니다." L["reset"] = "프로필 재설정"
L["delete"] = "프로필 삭제" L["reset_desc"] = "구성이 손상되었거나 처음부터 다시 시작하고 싶은 경우 현재 프로필을 기본값으로 재설정하세요."
L["delete_sub"] = "데이터베이스의 프로필을 삭제합니다." L["reset_sub"] = "현재 프로필을 기본값으로 재설정합니다"
L["delete_confirm"] = "정말로 선택한 프로필의 삭제를 원하십니까?" elseif LOCALE == "esES" or LOCALE == "esMX" then
L["profiles"] = "프로필" L["choose"] = "Perfiles existentes"
L["profiles_sub"] = "프로필 설정" L["choose_desc"] = "Puedes crear un nuevo perfil introduciendo un nombre en el recuadro o puedes seleccionar un perfil de los ya existentes."
--L["current"] = "Current Profile:" L["choose_sub"] = "Selecciona uno de los perfiles disponibles."
elseif LOCALE == "esES" or LOCALE == "esMX" then L["copy"] = "Copiar de"
L["default"] = "Por defecto" L["copy_desc"] = "Copia los ajustes de un perfil existente al perfil actual."
L["intro"] = "Puedes cambiar el perfil activo de tal manera que cada personaje tenga diferentes configuraciones." L["current"] = "Perfil actual:"
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["default"] = "Por defecto"
L["reset"] = "Reiniciar Perfil" L["delete"] = "Borrar un Perfil"
L["reset_sub"] = "Reinicar el perfil actual al de por defecto" L["delete_confirm"] = "¿Estas seguro que quieres borrar el perfil seleccionado?"
L["choose_desc"] = "Puedes crear un nuevo perfil introduciendo un nombre en el recuadro o puedes seleccionar un perfil de los ya existentes." L["delete_desc"] = "Borra los perfiles existentes y sin uso de la base de datos para ganar espacio y limpiar el archivo SavedVariables."
L["new"] = "Nuevo" L["delete_sub"] = "Borra un perfil de la base de datos."
L["new_sub"] = "Crear un nuevo perfil vacio." L["intro"] = "Puedes cambiar el perfil activo de tal manera que cada personaje tenga diferentes configuraciones."
L["choose"] = "Perfiles existentes" L["new"] = "Nuevo"
L["choose_sub"] = "Selecciona uno de los perfiles disponibles." L["new_sub"] = "Crear un nuevo perfil vacio."
L["copy_desc"] = "Copia los ajustes de un perfil existente al perfil actual." L["profiles"] = "Perfiles"
L["copy"] = "Copiar de" L["profiles_sub"] = "Manejar Perfiles"
L["delete_desc"] = "Borra los perfiles existentes y sin uso de la base de datos para ganar espacio y limpiar el archivo SavedVariables." L["reset"] = "Reiniciar Perfil"
L["delete"] = "Borrar un 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["delete_sub"] = "Borra un perfil de la base de datos." L["reset_sub"] = "Reinicar el perfil actual al de por defecto"
L["delete_confirm"] = "¿Estas seguro que quieres borrar el perfil seleccionado?" elseif LOCALE == "zhTW" then
L["profiles"] = "Perfiles" L["choose"] = "現有的設定檔"
L["profiles_sub"] = "Manejar Perfiles" L["choose_desc"] = "您可以在文字方塊內輸入名字以建立新的設定檔,或是選擇一個現有的設定檔使用。"
--L["current"] = "Current Profile:" L["choose_sub"] = "從當前可用的設定檔裡面選擇一個。"
elseif LOCALE == "zhTW" then L["copy"] = "複製自"
L["default"] = "預設" L["copy_desc"] = "從一個現有的設定檔,將設定複製到現在使用中的設定檔。"
L["intro"] = "你可以選擇一個活動的資料設定檔,這樣你的每個角色就可以擁有不同的設定值,可以給你的插件設定帶來極大的靈活性。" L["current"] = "目前設定檔:"
L["reset_desc"] = "將當前的設定檔恢復到它的預設值,用於你的設定檔損壞,或者你只是想重來的情況。" L["default"] = "預設"
L["reset"] = "重置設定檔" L["delete"] = "刪除一個設定檔"
L["reset_sub"] = "將當前的設定檔恢復為預設值" L["delete_confirm"] = "確定要刪除所選擇的設定檔嗎?"
L["choose_desc"] = "你可以通過在文本框內輸入一個名字創立一個新的設定檔,也可以選擇一個已經存在的設定檔" L["delete_desc"] = "從資料庫裡刪除不再使用的設定檔,以節省空間,並且清理 SavedVariables 檔案"
L["new"] = "新建" L["delete_sub"] = "從資料庫裡刪除一個設定檔。"
L["new_sub"] = "新建一個空的設定" L["intro"] = "您可以從資料庫中選擇一個設定檔來使用,如此就可以讓每個角色使用不同的設定。"
L["choose"] = "現有的設定檔" L["new"] = "新建"
L["choose_sub"] = "從當前可用的設定檔裏面選擇一個" L["new_sub"] = "新建一個空的設定檔"
L["copy_desc"] = "從當前某個已保存的設定檔複製到當前正使用的設定檔。" L["profiles"] = "設定檔"
L["copy"] = "複製自" L["profiles_sub"] = "管理設定檔"
L["delete_desc"] = "從資料庫裏刪除不再使用的設定檔,以節省空間,並且清理SavedVariables檔。" L["reset"] = "重置設定檔"
L["delete"] = "刪除一個設定檔" L["reset_desc"] = "將現用的設定檔重置為預設值;用於設定檔損壞,或者單純想要重來的情況。"
L["delete_sub"] = "從資料庫裏刪除一個設定檔。" L["reset_sub"] = "將目前的設定檔重置為預設值"
L["delete_confirm"] = "你確定要刪除所選擇的設定檔嗎?" elseif LOCALE == "zhCN" then
L["profiles"] = "設定檔" L["choose"] = "现有的配置文件"
L["profiles_sub"] = "管理設定檔" L["choose_desc"] = "你可以通过在文本框内输入一个名字创立一个新的配置文件,也可以选择一个已经存在的配置文件。"
--L["current"] = "Current Profile:" L["choose_sub"] = "从当前可用的配置文件里面选择一个。"
elseif LOCALE == "zhCN" then L["copy"] = "复制自"
L["default"] = "默认" L["copy_desc"] = "从当前某个已保存的配置文件复制到当前正使用的配置文件。"
L["intro"] = "你可以选择一个活动的数据配置文件,这样你的每个角色就可以拥有不同的设置值,可以给你的插件配置带来极大的灵活性。" L["current"] = "当前配置文件:"
L["reset_desc"] = "将当前的配置文件恢复到它的默认值,用于你的配置文件损坏,或者你只是想重来的情况。" L["default"] = "默认"
L["reset"] = "重置配置文件" L["delete"] = "删除一个配置文件"
L["reset_sub"] = "将当前的配置文件恢复为默认值" L["delete_confirm"] = "你确定要删除所选择的配置文件么?"
L["choose_desc"] = "你可以通过在文本框内输入一个名字创立一个新的配置文件,也可以选择一个已经存在的配置文件。" L["delete_desc"] = "从数据库里删除不再使用的配置文件,以节省空间,并且清理SavedVariables文件。"
L["new"] = "新建" L["delete_sub"] = "从数据库里删除一个配置文件。"
L["new_sub"] = "新建一个空的配置文件" L["intro"] = "你可以选择一个活动的数据配置文件,这样你的每个角色就可以拥有不同的设置值,可以给你的插件配置带来极大的灵活性"
L["choose"] = "现有的配置文件" L["new"] = "新建"
L["choose_sub"] = "从当前可用的配置文件里面选择一个" L["new_sub"] = "新建一个空的配置文件"
L["copy_desc"] = "从当前某个已保存的配置文件复制到当前正使用的配置文件。" L["profiles"] = "配置文件"
L["copy"] = "复制自" L["profiles_sub"] = "管理配置文件"
L["delete_desc"] = "从数据库里删除不再使用的配置文件,以节省空间,并且清理SavedVariables文件。" L["reset"] = "重置配置文件"
L["delete"] = "删除一个配置文件" L["reset_desc"] = "将当前的配置文件恢复到它的默认值,用于你的配置文件损坏,或者你只是想重来的情况。"
L["delete_sub"] = "从数据库里删除一个配置文件。" L["reset_sub"] = "将当前的配置文件恢复为默认值"
L["delete_confirm"] = "你确定要删除所选择的配置文件么?" elseif LOCALE == "ruRU" then
L["profiles"] = "配置文件" L["choose"] = "Существующие профили"
L["profiles_sub"] = "管理配置文件" L["choose_desc"] = "Вы можете создать новый профиль, введя название в поле ввода, или выбрать один из уже существующих профилей."
--L["current"] = "Current Profile:" L["choose_sub"] = "Выбор одного из уже доступных профилей."
elseif LOCALE == "ruRU" then L["copy"] = "Скопировать из"
L["default"] = "По умолчанию" L["copy_desc"] = "Копирование настроек из выбранного профиля в активный."
L["intro"] = "Изменяя активный профиль, вы можете задать различные настройки модификаций для каждого персонажа." L["current"] = "Текущий профиль:"
L["reset_desc"] = "Если ваша конфигурации испорчена или если вы хотите настроить всё заново - сбросьте текущий профиль на стандартные значения." L["default"] = "По умолчанию"
L["reset"] = "Сброс профиля" L["delete"] = "Удалить профиль"
L["reset_sub"] = "Сброс текущего профиля на стандартный" L["delete_confirm"] = "Вы уверены, что хотите удалить выбранный профиль?"
L["choose_desc"] = "Вы можете создать новый профиль, введя название в поле ввода, или выбрать один из уже существующих профилей." L["delete_desc"] = "Удаление существующего и неиспользуемого профиля из базы данных для сохранения места, и очистка файла SavedVariables."
L["new"] = "Новый" L["delete_sub"] = "Удаление профиля из базы данных."
L["new_sub"] = "Создать новый чистый профиль" L["intro"] = "Изменяя активный профиль, Вы можете задать разные настройки для каждого персонажа."
L["choose"] = "Существующие профили" L["new"] = "Новый"
L["choose_sub"] = "Выбор одиного из уже доступных профилей" L["new_sub"] = "Создание нового чистого профиля."
L["copy_desc"] = "Скопировать настройки из выбранного профиля в активный." L["profiles"] = "Профили"
L["copy"] = "Скопировать из" L["profiles_sub"] = "Управление профилями"
L["delete_desc"] = "Удалить существующий и неиспользуемый профиль из БД для сохранения места, и очистить SavedVariables файл." L["reset"] = "Сбросить профиль"
L["delete"] = "Удалить профиль" L["reset_desc"] = "Сброс текущего профиля к стандартным настройкам, если Ваша конфигурация испорчена или Вы хотите настроить все заново."
L["delete_sub"] = "Удаление профиля из БД" L["reset_sub"] = "Сброс текущего профиля на стандартный"
L["delete_confirm"] = "Вы уверены, что вы хотите удалить выбранный профиль?" elseif LOCALE == "itIT" then
L["profiles"] = "Профили" L["choose"] = "Profili Esistenti"
L["profiles_sub"] = "Управление профилями" L["choose_desc"] = "Puoi creare un nuovo profilo digitando il nome della casella di testo, oppure scegliendone uno tra i profili già esistenti."
--L["current"] = "Current Profile:" L["choose_sub"] = "Seleziona uno dei profili attualmente disponibili."
end L["copy"] = "Copia Da"
L["copy_desc"] = "Copia le impostazioni da un profilo esistente nel profilo attivo in questo momento."
local defaultProfiles L["current"] = "Profilo Attivo:"
local tmpprofiles = {} L["default"] = "Predefinito"
L["delete"] = "Cancella un Profilo"
-- Get a list of available profiles for the specified database. L["delete_confirm"] = "Sei sicuro di voler cancellare il profilo selezionato?"
-- You can specify which profiles to include/exclude in the list using the two boolean parameters listed below. L["delete_desc"] = "Cancella i profili non utilizzati dal database per risparmiare spazio e mantenere puliti i file di configurazione SavedVariables."
-- @param db The db object to retrieve the profiles from L["delete_sub"] = "Cancella un profilo dal Database."
-- @param common If true, getProfileList will add the default profiles to the return list, even if they have not been created yet L["intro"] = "Puoi cambiare il profilo attivo, in modo da usare impostazioni diverse per ogni personaggio."
-- @param nocurrent If true, then getProfileList will not display the current profile in the list L["new"] = "Nuovo"
-- @return Hashtable of all profiles with the internal name as keys and the display name as value. L["new_sub"] = "Crea un nuovo profilo vuoto."
local function getProfileList(db, common, nocurrent) L["profiles"] = "Profili"
local profiles = {} L["profiles_sub"] = "Gestisci Profili"
L["reset"] = "Reimposta Profilo"
-- copy existing profiles into the table 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."
local currentProfile = db:GetCurrentProfile() L["reset_sub"] = "Reimposta il profilo ai suoi valori predefiniti."
for i,v in pairs(db:GetProfiles(tmpprofiles)) do elseif LOCALE == "ptBR" then
if not (nocurrent and v == currentProfile) then L["choose"] = "Perfis Existentes"
profiles[v] = v 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."
end L["choose_sub"] = "Selecione um de seus perfis atualmente disponíveis."
end L["copy"] = "Copiar De"
L["copy_desc"] = "Copia as definições de um perfil existente no perfil atualmente ativo."
-- add our default profiles to choose from ( or rename existing profiles) L["current"] = "Perfil Autal:"
for k,v in pairs(defaultProfiles) do L["default"] = "Padrão"
if (common or profiles[k]) and not (nocurrent and k == currentProfile) then L["delete"] = "Remover um Perfil"
profiles[k] = v L["delete_confirm"] = "Tem certeza que deseja remover o perfil selecionado?"
end L["delete_desc"] = "Remove perfis existentes e inutilizados do banco de dados para economizar espaço, e limpar o arquivo SavedVariables."
end 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."
return profiles L["new"] = "Novo"
end L["new_sub"] = "Cria um novo perfil vazio."
L["profiles"] = "Perfis"
--[[ L["profiles_sub"] = "Gerenciar Perfis"
OptionsHandlerPrototype L["reset"] = "Resetar Perfil"
prototype class for handling the options in a sane way 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"
local OptionsHandlerPrototype = {} end
--[[ Reset the profile ]] local defaultProfiles
function OptionsHandlerPrototype:Reset() local tmpprofiles = {}
self.db:ResetProfile()
end -- Get a list of available profiles for the specified database.
-- You can specify which profiles to include/exclude in the list using the two boolean parameters listed below.
--[[ Set the profile to value ]] -- @param db The db object to retrieve the profiles from
function OptionsHandlerPrototype:SetProfile(info, value) -- @param common If true, getProfileList will add the default profiles to the return list, even if they have not been created yet
self.db:SetProfile(value) -- @param nocurrent If true, then getProfileList will not display the current profile in the list
end -- @return Hashtable of all profiles with the internal name as keys and the display name as value.
local function getProfileList(db, common, nocurrent)
--[[ returns the currently active profile ]] local profiles = {}
function OptionsHandlerPrototype:GetCurrentProfile()
return self.db:GetCurrentProfile() -- copy existing profiles into the table
end local currentProfile = db:GetCurrentProfile()
for i,v in pairs(db:GetProfiles(tmpprofiles)) do
--[[ if not (nocurrent and v == currentProfile) then
List all active profiles profiles[v] = v
you can control the output with the .arg variable end
currently four modes are supported end
(empty) - return all available profiles -- add our default profiles to choose from ( or rename existing profiles)
"nocurrent" - returns all available profiles except the currently active profile for k,v in pairs(defaultProfiles) do
"common" - returns all avaialble profiles + some commonly used profiles ("char - realm", "realm", "class", "Default") if (common or profiles[k]) and not (nocurrent and k == currentProfile) then
"both" - common except the active profile profiles[k] = v
]] end
function OptionsHandlerPrototype:ListProfiles(info) end
local arg = info.arg
local profiles return profiles
if arg == "common" and not self.noDefaultProfiles then end
profiles = getProfileList(self.db, true, nil)
elseif arg == "nocurrent" then --[[
profiles = getProfileList(self.db, nil, true) OptionsHandlerPrototype
elseif arg == "both" then -- currently not used prototype class for handling the options in a sane way
profiles = getProfileList(self.db, (not self.noDefaultProfiles) and true, true) ]]
else local OptionsHandlerPrototype = {}
profiles = getProfileList(self.db)
end --[[ Reset the profile ]]
function OptionsHandlerPrototype:Reset()
return profiles self.db:ResetProfile()
end end
function OptionsHandlerPrototype:HasNoProfiles(info) --[[ Set the profile to value ]]
local profiles = self:ListProfiles(info) function OptionsHandlerPrototype:SetProfile(info, value)
return ((not next(profiles)) and true or false) self.db:SetProfile(value)
end end
--[[ Copy a profile ]] --[[ returns the currently active profile ]]
function OptionsHandlerPrototype:CopyProfile(info, value) function OptionsHandlerPrototype:GetCurrentProfile()
self.db:CopyProfile(value) return self.db:GetCurrentProfile()
end end
--[[ Delete a profile from the db ]] --[[
function OptionsHandlerPrototype:DeleteProfile(info, value) List all active profiles
self.db:DeleteProfile(value) you can control the output with the .arg variable
end currently four modes are supported
--[[ fill defaultProfiles with some generic values ]] (empty) - return all available profiles
local function generateDefaultProfiles(db) "nocurrent" - returns all available profiles except the currently active profile
defaultProfiles = { "common" - returns all avaialble profiles + some commonly used profiles ("char - realm", "realm", "class", "Default")
["Default"] = L["default"], "both" - common except the active profile
[db.keys.char] = db.keys.char, ]]
[db.keys.realm] = db.keys.realm, function OptionsHandlerPrototype:ListProfiles(info)
[db.keys.class] = UnitClass("player") local arg = info.arg
} local profiles
end if arg == "common" and not self.noDefaultProfiles then
profiles = getProfileList(self.db, true, nil)
--[[ create and return a handler object for the db, or upgrade it if it already existed ]] elseif arg == "nocurrent" then
local function getOptionsHandler(db, noDefaultProfiles) profiles = getProfileList(self.db, nil, true)
if not defaultProfiles then elseif arg == "both" then -- currently not used
generateDefaultProfiles(db) profiles = getProfileList(self.db, (not self.noDefaultProfiles) and true, true)
end else
profiles = getProfileList(self.db)
local handler = AceDBOptions.handlers[db] or { db = db, noDefaultProfiles = noDefaultProfiles } end
for k,v in pairs(OptionsHandlerPrototype) do return profiles
handler[k] = v end
end
function OptionsHandlerPrototype:HasNoProfiles(info)
AceDBOptions.handlers[db] = handler local profiles = self:ListProfiles(info)
return handler return ((not next(profiles)) and true or false)
end end
--[[ --[[ Copy a profile ]]
the real options table function OptionsHandlerPrototype:CopyProfile(info, value)
]] self.db:CopyProfile(value)
local optionsTable = { end
desc = {
order = 1, --[[ Delete a profile from the db ]]
type = "description", function OptionsHandlerPrototype:DeleteProfile(info, value)
name = L["intro"] .. "\n", self.db:DeleteProfile(value)
}, end
descreset = {
order = 9, --[[ fill defaultProfiles with some generic values ]]
type = "description", local function generateDefaultProfiles(db)
name = L["reset_desc"], defaultProfiles = {
}, ["Default"] = L["default"],
reset = { [db.keys.char] = db.keys.char,
order = 10, [db.keys.realm] = db.keys.realm,
type = "execute", [db.keys.class] = UnitClass("player")
name = L["reset"], }
desc = L["reset_sub"], end
func = "Reset",
}, --[[ create and return a handler object for the db, or upgrade it if it already existed ]]
current = { local function getOptionsHandler(db, noDefaultProfiles)
order = 11, if not defaultProfiles then
type = "description", generateDefaultProfiles(db)
name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end, end
width = "default",
}, local handler = AceDBOptions.handlers[db] or { db = db, noDefaultProfiles = noDefaultProfiles }
choosedesc = {
order = 20, for k,v in pairs(OptionsHandlerPrototype) do
type = "description", handler[k] = v
name = "\n" .. L["choose_desc"], end
},
new = { AceDBOptions.handlers[db] = handler
name = L["new"], return handler
desc = L["new_sub"], end
type = "input",
order = 30, --[[
get = false, the real options table
set = "SetProfile", ]]
}, local optionsTable = {
choose = { desc = {
name = L["choose"], order = 1,
desc = L["choose_sub"], type = "description",
type = "select", name = L["intro"] .. "\n",
order = 40, },
get = "GetCurrentProfile", descreset = {
set = "SetProfile", order = 9,
values = "ListProfiles", type = "description",
arg = "common", name = L["reset_desc"],
}, },
copydesc = { reset = {
order = 50, order = 10,
type = "description", type = "execute",
name = "\n" .. L["copy_desc"], name = L["reset"],
}, desc = L["reset_sub"],
copyfrom = { func = "Reset",
order = 60, },
type = "select", current = {
name = L["copy"], order = 11,
desc = L["copy_desc"], type = "description",
get = false, name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end,
set = "CopyProfile", width = "default",
values = "ListProfiles", },
disabled = "HasNoProfiles", choosedesc = {
arg = "nocurrent", order = 20,
}, type = "description",
deldesc = { name = "\n" .. L["choose_desc"],
order = 70, },
type = "description", new = {
name = "\n" .. L["delete_desc"], name = L["new"],
}, desc = L["new_sub"],
delete = { type = "input",
order = 80, order = 30,
type = "select", get = false,
name = L["delete"], set = "SetProfile",
desc = L["delete_sub"], },
get = false, choose = {
set = "DeleteProfile", name = L["choose"],
values = "ListProfiles", desc = L["choose_sub"],
disabled = "HasNoProfiles", type = "select",
arg = "nocurrent", order = 40,
confirm = true, get = "GetCurrentProfile",
confirmText = L["delete_confirm"], set = "SetProfile",
}, values = "ListProfiles",
} arg = "common",
},
--- Get/Create a option table that you can use in your addon to control the profiles of AceDB-3.0. copydesc = {
-- @param db The database object to create the options table for. order = 50,
-- @return The options table to be used in AceConfig-3.0 type = "description",
-- @usage name = "\n" .. L["copy_desc"],
-- -- Assuming `options` is your top-level options table and `self.db` is your database: },
-- options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) copyfrom = {
function AceDBOptions:GetOptionsTable(db, noDefaultProfiles) order = 60,
local tbl = AceDBOptions.optionTables[db] or { type = "select",
type = "group", name = L["copy"],
name = L["profiles"], desc = L["copy_desc"],
desc = L["profiles_sub"], get = false,
} set = "CopyProfile",
values = "ListProfiles",
tbl.handler = getOptionsHandler(db, noDefaultProfiles) disabled = "HasNoProfiles",
tbl.args = optionsTable arg = "nocurrent",
},
AceDBOptions.optionTables[db] = tbl deldesc = {
return tbl order = 70,
end type = "description",
name = "\n" .. L["delete_desc"],
-- upgrade existing tables },
for db,tbl in pairs(AceDBOptions.optionTables) do delete = {
tbl.handler = getOptionsHandler(db) order = 80,
tbl.args = optionsTable type = "select",
end name = L["delete"],
desc = L["delete_sub"],
get = false,
set = "DeleteProfile",
values = "ListProfiles",
disabled = "HasNoProfiles",
arg = "nocurrent",
confirm = true,
confirmText = L["delete_confirm"],
},
}
--- Get/Create a option table that you can use in your addon to control the profiles of AceDB-3.0.
-- @param db The database object to create the options table for.
-- @return The options table to be used in AceConfig-3.0
-- @usage
-- -- Assuming `options` is your top-level options table and `self.db` is your database:
-- options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
function AceDBOptions:GetOptionsTable(db, noDefaultProfiles)
local tbl = AceDBOptions.optionTables[db] or {
type = "group",
name = L["profiles"],
desc = L["profiles_sub"],
}
tbl.handler = getOptionsHandler(db, noDefaultProfiles)
tbl.args = optionsTable
AceDBOptions.optionTables[db] = tbl
return tbl
end
-- upgrade existing tables
for db,tbl in pairs(AceDBOptions.optionTables) do
tbl.handler = getOptionsHandler(db)
tbl.args = optionsTable
end
@@ -1,4 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ <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"> ..\FrameXML\UI.xsd">
<Script file="AceDBOptions-3.0.lua"/> <Script file="AceDBOptions-3.0.lua"/>
</Ui> </Ui>
File diff suppressed because it is too large Load Diff
@@ -1,28 +1,28 @@
<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/ <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"> ..\FrameXML\UI.xsd">
<Script file="AceGUI-3.0.lua"/> <Script file="AceGUI-3.0.lua"/>
<!-- Container --> <!-- Container -->
<Script file="widgets\AceGUIContainer-BlizOptionsGroup.lua"/> <Script file="widgets\AceGUIContainer-BlizOptionsGroup.lua"/>
<Script file="widgets\AceGUIContainer-DropDownGroup.lua"/> <Script file="widgets\AceGUIContainer-DropDownGroup.lua"/>
<Script file="widgets\AceGUIContainer-Frame.lua"/> <Script file="widgets\AceGUIContainer-Frame.lua"/>
<Script file="widgets\AceGUIContainer-InlineGroup.lua"/> <Script file="widgets\AceGUIContainer-InlineGroup.lua"/>
<Script file="widgets\AceGUIContainer-ScrollFrame.lua"/> <Script file="widgets\AceGUIContainer-ScrollFrame.lua"/>
<Script file="widgets\AceGUIContainer-SimpleGroup.lua"/> <Script file="widgets\AceGUIContainer-SimpleGroup.lua"/>
<Script file="widgets\AceGUIContainer-TabGroup.lua"/> <Script file="widgets\AceGUIContainer-TabGroup.lua"/>
<Script file="widgets\AceGUIContainer-TreeGroup.lua"/> <Script file="widgets\AceGUIContainer-TreeGroup.lua"/>
<Script file="widgets\AceGUIContainer-Window.lua"/> <Script file="widgets\AceGUIContainer-Window.lua"/>
<!-- Widgets --> <!-- Widgets -->
<Script file="widgets\AceGUIWidget-Button.lua"/> <Script file="widgets\AceGUIWidget-Button.lua"/>
<Script file="widgets\AceGUIWidget-CheckBox.lua"/> <Script file="widgets\AceGUIWidget-CheckBox.lua"/>
<Script file="widgets\AceGUIWidget-ColorPicker.lua"/> <Script file="widgets\AceGUIWidget-ColorPicker.lua"/>
<Script file="widgets\AceGUIWidget-DropDown.lua"/> <Script file="widgets\AceGUIWidget-DropDown.lua"/>
<Script file="widgets\AceGUIWidget-DropDown-Items.lua"/> <Script file="widgets\AceGUIWidget-DropDown-Items.lua"/>
<Script file="widgets\AceGUIWidget-EditBox.lua"/> <Script file="widgets\AceGUIWidget-EditBox.lua"/>
<Script file="widgets\AceGUIWidget-Heading.lua"/> <Script file="widgets\AceGUIWidget-Heading.lua"/>
<Script file="widgets\AceGUIWidget-Icon.lua"/> <Script file="widgets\AceGUIWidget-Icon.lua"/>
<Script file="widgets\AceGUIWidget-InteractiveLabel.lua"/> <Script file="widgets\AceGUIWidget-InteractiveLabel.lua"/>
<Script file="widgets\AceGUIWidget-Keybinding.lua"/> <Script file="widgets\AceGUIWidget-Keybinding.lua"/>
<Script file="widgets\AceGUIWidget-Label.lua"/> <Script file="widgets\AceGUIWidget-Label.lua"/>
<Script file="widgets\AceGUIWidget-MultiLineEditBox.lua"/> <Script file="widgets\AceGUIWidget-MultiLineEditBox.lua"/>
<Script file="widgets\AceGUIWidget-Slider.lua"/> <Script file="widgets\AceGUIWidget-Slider.lua"/>
</Ui> </Ui>
@@ -1,133 +1,147 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
BlizOptionsGroup Container BlizOptionsGroup Container
Simple container widget for the integration of AceGUI into the Blizzard Interface Options 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) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local pairs = pairs local pairs = pairs
-- WoW APIs -- WoW APIs
local CreateFrame = CreateFrame local CreateFrame = CreateFrame
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Scripts Scripts
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local function OnShow(frame) local function OnShow(frame)
frame.obj:Fire("OnShow") frame.obj:Fire("OnShow")
end end
local function OnHide(frame) local function OnHide(frame)
frame.obj:Fire("OnHide") frame.obj:Fire("OnHide")
end end
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Support functions Support functions
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local function okay(frame) local function okay(frame)
frame.obj:Fire("okay") frame.obj:Fire("okay")
end end
local function cancel(frame) local function cancel(frame)
frame.obj:Fire("cancel") frame.obj:Fire("cancel")
end end
local function defaults(frame) local function default(frame)
frame.obj:Fire("defaults") frame.obj:Fire("default")
end end
--[[----------------------------------------------------------------------------- local function refresh(frame)
Methods frame.obj:Fire("refresh")
-------------------------------------------------------------------------------]] end
local methods = { --[[-----------------------------------------------------------------------------
["OnAcquire"] = function(self) Methods
self:SetName() -------------------------------------------------------------------------------]]
self:SetTitle()
end, local methods = {
["OnAcquire"] = function(self)
-- ["OnRelease"] = nil, self:SetName()
self:SetTitle()
["OnWidthSet"] = function(self, width) end,
local content = self.content
local contentwidth = width - 63 -- ["OnRelease"] = nil,
if contentwidth < 0 then
contentwidth = 0 ["OnWidthSet"] = function(self, width)
end local content = self.content
content:SetWidth(contentwidth) local contentwidth = width - 63
content.width = contentwidth if contentwidth < 0 then
end, contentwidth = 0
end
["OnHeightSet"] = function(self, height) content:SetWidth(contentwidth)
local content = self.content content.width = contentwidth
local contentheight = height - 26 end,
if contentheight < 0 then
contentheight = 0 ["OnHeightSet"] = function(self, height)
end local content = self.content
content:SetHeight(contentheight) local contentheight = height - 26
content.height = contentheight if contentheight < 0 then
end, contentheight = 0
end
["SetName"] = function(self, name, parent) content:SetHeight(contentheight)
self.frame.name = name content.height = contentheight
self.frame.parent = parent end,
end,
["SetName"] = function(self, name, parent)
["SetTitle"] = function(self, title) self.frame.name = name
local content = self.content self.frame.parent = parent
content:ClearAllPoints() end,
if not title or title == "" then
content:SetPoint("TOPLEFT", 10, -10) ["SetTitle"] = function(self, title)
self.label:SetText("") local content = self.content
else content:ClearAllPoints()
content:SetPoint("TOPLEFT", 10, -40) if not title or title == "" then
self.label:SetText(title) content:SetPoint("TOPLEFT", 10, -10)
end self.label:SetText("")
content:SetPoint("BOTTOMRIGHT", -10, 10) else
end content:SetPoint("TOPLEFT", 10, -40)
} self.label:SetText(title)
end
--[[----------------------------------------------------------------------------- content:SetPoint("BOTTOMRIGHT", -10, 10)
Constructor end
-------------------------------------------------------------------------------]] }
local function Constructor()
local frame = CreateFrame("Frame") --[[-----------------------------------------------------------------------------
frame:Hide() Constructor
-------------------------------------------------------------------------------]]
-- support functions for the Blizzard Interface Options local function Constructor()
frame.okay = okay -- CoA-compat: InterfaceOptionsFramePanelContainer is a global from the stock 3.3.5
frame.cancel = cancel -- Interface Options frame; on the CoA reworked FrameXML it can be nil at the time
frame.defaults = defaults -- AceGUI widgets are constructed. Fall back to UIParent so CreateFrame doesn't blow up.
local _parent = InterfaceOptionsFramePanelContainer or UIParent
frame:SetScript("OnHide", OnHide) local frame = CreateFrame("Frame", nil, _parent)
frame:SetScript("OnShow", OnShow) frame:Hide()
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") -- support functions for the Blizzard Interface Options
label:SetPoint("TOPLEFT", 10, -15) frame.okay = okay
label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45) frame.cancel = cancel
label:SetJustifyH("LEFT") frame.default = default
label:SetJustifyV("TOP") frame.refresh = refresh
--Container Support -- 10.0 support function aliases (cancel has been removed)
local content = CreateFrame("Frame", nil, frame) frame.OnCommit = okay
content:SetPoint("TOPLEFT", 10, -10) frame.OnDefault = default
content:SetPoint("BOTTOMRIGHT", -10, 10) frame.OnRefresh = refresh
local widget = { frame:SetScript("OnHide", OnHide)
label = label, frame:SetScript("OnShow", OnShow)
frame = frame,
content = content, local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
type = Type label:SetPoint("TOPLEFT", 10, -15)
} label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
for method, func in pairs(methods) do label:SetJustifyH("LEFT")
widget[method] = func label:SetJustifyV("TOP")
end
--Container Support
return AceGUI:RegisterAsContainer(widget) local content = CreateFrame("Frame", nil, frame)
end content:SetPoint("TOPLEFT", 10, -10)
content:SetPoint("BOTTOMRIGHT", -10, 10)
AceGUI:RegisterWidgetType(Type, Constructor, Version)
local widget = {
label = label,
frame = frame,
content = content,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsContainer(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,178 +1,157 @@
local AceGUI = LibStub("AceGUI-3.0") --[[-----------------------------------------------------------------------------
DropdownGroup Container
-- Lua APIs Container controlled by a dropdown on the top.
local assert, pairs, type = assert, pairs, type -------------------------------------------------------------------------------]]
local Type, Version = "DropdownGroup", 22
-- WoW APIs local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
local CreateFrame = CreateFrame if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
--[[ -- Lua APIs
Selection Group controls all have an interface to select a group for thier contents local assert, pairs, type = assert, pairs, type
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 -- WoW APIs
]] local CreateFrame = CreateFrame
-------------------------- --[[-----------------------------------------------------------------------------
-- Dropdown Group -- Scripts
-------------------------- -------------------------------------------------------------------------------]]
--[[ local function SelectedGroup(self, event, value)
Events : local group = self.parentgroup
OnGroupSelected local status = group.status or group.localstatus
status.selected = value
]] self.parentgroup:Fire("OnGroupSelected", value)
do end
local Type = "DropdownGroup"
local Version = 13 --[[-----------------------------------------------------------------------------
Methods
local function OnAcquire(self) -------------------------------------------------------------------------------]]
self.dropdown:SetText("") local methods = {
self:SetDropdownWidth(200) ["OnAcquire"] = function(self)
self:SetTitle("") self.dropdown:SetText("")
end self:SetDropdownWidth(200)
self:SetTitle("")
local function OnRelease(self) end,
self.frame:ClearAllPoints()
self.frame:Hide() ["OnRelease"] = function(self)
self.dropdown.list = nil self.dropdown.list = nil
self.status = nil self.status = nil
for k in pairs(self.localstatus) do for k in pairs(self.localstatus) do
self.localstatus[k] = nil self.localstatus[k] = nil
end end
end end,
local PaneBackdrop = { ["SetTitle"] = function(self, title)
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", self.titletext:SetText(title)
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", self.dropdown.frame:ClearAllPoints()
tile = true, tileSize = 16, edgeSize = 16, if title and title ~= "" then
insets = { left = 3, right = 3, top = 5, bottom = 3 } self.dropdown.frame:SetPoint("TOPRIGHT", -2, 0)
} else
self.dropdown.frame:SetPoint("TOPLEFT", -1, 0)
local function SetTitle(self,title) end
self.titletext:SetText(title) end,
self.dropdown.frame:ClearAllPoints()
if title and title ~= "" then ["SetGroupList"] = function(self,list,order)
self.dropdown.frame:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -2, 0) self.dropdown:SetList(list,order)
else end,
self.dropdown.frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", -1, 0)
end ["SetStatusTable"] = function(self, status)
end assert(type(status) == "table")
self.status = status
end,
local function SelectedGroup(self,event,value)
local group = self.parentgroup ["SetGroup"] = function(self,group)
local status = group.status or group.localstatus self.dropdown:SetValue(group)
status.selected = value local status = self.status or self.localstatus
self.parentgroup:Fire("OnGroupSelected", value) status.selected = group
end self:Fire("OnGroupSelected", group)
end,
local function SetGroupList(self,list)
self.dropdown:SetList(list) ["OnWidthSet"] = function(self, width)
end local content = self.content
local contentwidth = width - 26
-- called to set an external table to store status in if contentwidth < 0 then
local function SetStatusTable(self, status) contentwidth = 0
assert(type(status) == "table") end
self.status = status content:SetWidth(contentwidth)
end content.width = contentwidth
end,
local function SetGroup(self,group)
self.dropdown:SetValue(group) ["OnHeightSet"] = function(self, height)
local status = self.status or self.localstatus local content = self.content
status.selected = group local contentheight = height - 63
self:Fire("OnGroupSelected", group) if contentheight < 0 then
end contentheight = 0
end
local function OnWidthSet(self, width) content:SetHeight(contentheight)
local content = self.content content.height = contentheight
local contentwidth = width - 26 end,
if contentwidth < 0 then
contentwidth = 0 ["LayoutFinished"] = function(self, width, height)
end self:SetHeight((height or 0) + 63)
content:SetWidth(contentwidth) end,
content.width = contentwidth
end ["SetDropdownWidth"] = function(self, width)
self.dropdown:SetWidth(width)
end
local function OnHeightSet(self, height) }
local content = self.content
local contentheight = height - 63 --[[-----------------------------------------------------------------------------
if contentheight < 0 then Constructor
contentheight = 0 -------------------------------------------------------------------------------]]
end local PaneBackdrop = {
content:SetHeight(contentheight) bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
content.height = contentheight edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
end tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 3, right = 3, top = 5, bottom = 3 }
local function LayoutFinished(self, width, height) }
self:SetHeight((height or 0) + 63)
end local function Constructor()
local frame = CreateFrame("Frame")
local function SetDropdownWidth(self, width) frame:SetHeight(100)
self.dropdown:SetWidth(width) frame:SetWidth(100)
end frame:SetFrameStrata("FULLSCREEN_DIALOG")
local function Constructor() local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
local frame = CreateFrame("Frame") titletext:SetPoint("TOPLEFT", 4, -5)
local self = {} titletext:SetPoint("TOPRIGHT", -4, -5)
self.type = Type titletext:SetJustifyH("LEFT")
titletext:SetHeight(18)
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire local dropdown = AceGUI:Create("Dropdown")
dropdown.frame:SetParent(frame)
self.SetTitle = SetTitle dropdown.frame:SetFrameLevel(dropdown.frame:GetFrameLevel() + 2)
self.SetGroupList = SetGroupList dropdown:SetCallback("OnValueChanged", SelectedGroup)
self.SetGroup = SetGroup dropdown.frame:SetPoint("TOPLEFT", -1, 0)
self.SetStatusTable = SetStatusTable dropdown.frame:Show()
self.SetDropdownWidth = SetDropdownWidth dropdown:SetLabel("")
self.OnWidthSet = OnWidthSet
self.OnHeightSet = OnHeightSet local border = CreateFrame("Frame", nil, frame, "BackdropTemplate")
self.LayoutFinished = LayoutFinished border:SetPoint("TOPLEFT", 0, -26)
border:SetPoint("BOTTOMRIGHT", 0, 3)
self.localstatus = {} border:SetBackdrop(PaneBackdrop)
border:SetBackdropColor(0.1,0.1,0.1,0.5)
self.frame = frame border:SetBackdropBorderColor(0.4,0.4,0.4)
frame.obj = self
--Container Support
frame:SetHeight(100) local content = CreateFrame("Frame", nil, border)
frame:SetWidth(100) content:SetPoint("TOPLEFT", 10, -10)
frame:SetFrameStrata("FULLSCREEN_DIALOG") content:SetPoint("BOTTOMRIGHT", -10, 10)
local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") local widget = {
titletext:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -5) frame = frame,
titletext:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -4, -5) localstatus = {},
titletext:SetJustifyH("LEFT") titletext = titletext,
titletext:SetHeight(18) dropdown = dropdown,
self.titletext = titletext border = border,
content = content,
local dropdown = AceGUI:Create("Dropdown") type = Type
self.dropdown = dropdown }
dropdown.frame:SetParent(frame) for method, func in pairs(methods) do
dropdown.frame:SetFrameLevel(dropdown.frame:GetFrameLevel() + 2) widget[method] = func
dropdown.parentgroup = self end
dropdown:SetCallback("OnValueChanged",SelectedGroup) dropdown.parentgroup = widget
dropdown.frame:SetPoint("TOPLEFT",frame,"TOPLEFT", -1, 0)
dropdown.frame:Show() return AceGUI:RegisterAsContainer(widget)
dropdown:SetLabel("") end
local border = CreateFrame("Frame",nil,frame) AceGUI:RegisterWidgetType(Type, Constructor, Version)
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
end
AceGUI:RegisterWidgetType(Type,Constructor,Version)
end
@@ -1,288 +1,318 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Frame Container Frame Container
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local Type, Version = "Frame", 20 local Type, Version = "Frame", 30
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local pairs, assert, type = pairs, assert, type local pairs, assert, type = pairs, assert, type
local wipe = table.wipe local wipe = table.wipe
-- WoW APIs -- WoW APIs
local PlaySound = PlaySound local PlaySound = PlaySound
local CreateFrame, UIParent = CreateFrame, UIParent 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 Scripts
-- GLOBALS: CLOSE -------------------------------------------------------------------------------]]
local function Button_OnClick(frame)
--[[----------------------------------------------------------------------------- PlaySound(799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
Scripts frame.obj:Hide()
-------------------------------------------------------------------------------]] end
local function Button_OnClick(frame)
PlaySound("gsTitleOptionExit") local function Frame_OnShow(frame)
frame.obj:Hide() frame.obj:Fire("OnShow")
end end
local function Frame_OnClose(frame) local function Frame_OnClose(frame)
frame.obj:Fire("OnClose") frame.obj:Fire("OnClose")
end end
local function Frame_OnMouseDown(frame) local function Frame_OnMouseDown(frame)
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local function Title_OnMouseDown(frame) local function Title_OnMouseDown(frame)
frame:GetParent():StartMoving() frame:GetParent():StartMoving()
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local function MoverSizer_OnMouseUp(mover) local function MoverSizer_OnMouseUp(mover)
local frame = mover:GetParent() local frame = mover:GetParent()
frame:StopMovingOrSizing() frame:StopMovingOrSizing()
local self = frame.obj local self = frame.obj
local status = self.status or self.localstatus local status = self.status or self.localstatus
status.width = frame:GetWidth() status.width = frame:GetWidth()
status.height = frame:GetHeight() status.height = frame:GetHeight()
status.top = frame:GetTop() status.top = frame:GetTop()
status.left = frame:GetLeft() status.left = frame:GetLeft()
end end
local function SizerSE_OnMouseDown(frame) local function SizerSE_OnMouseDown(frame)
frame:GetParent():StartSizing("BOTTOMRIGHT") frame:GetParent():StartSizing("BOTTOMRIGHT")
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local function SizerS_OnMouseDown(frame) local function SizerS_OnMouseDown(frame)
frame:GetParent():StartSizing("BOTTOM") frame:GetParent():StartSizing("BOTTOM")
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local function SizerE_OnMouseDown(frame) local function SizerE_OnMouseDown(frame)
frame:GetParent():StartSizing("RIGHT") frame:GetParent():StartSizing("RIGHT")
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
--[[----------------------------------------------------------------------------- local function StatusBar_OnEnter(frame)
Methods frame.obj:Fire("OnEnterStatusBar")
-------------------------------------------------------------------------------]] end
local methods = {
["OnAcquire"] = function(self) local function StatusBar_OnLeave(frame)
self.frame:SetParent(UIParent) frame.obj:Fire("OnLeaveStatusBar")
self.frame:SetFrameStrata("FULLSCREEN_DIALOG") end
self:SetTitle()
self:SetStatusText() --[[-----------------------------------------------------------------------------
self:ApplyStatus() Methods
self:Show() -------------------------------------------------------------------------------]]
end, local methods = {
["OnAcquire"] = function(self)
["OnRelease"] = function(self) self.frame:SetParent(UIParent)
self.status = nil self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
wipe(self.localstatus) self.frame:SetFrameLevel(100) -- Lots of room to draw under it
end, self:SetTitle()
self:SetStatusText()
["OnWidthSet"] = function(self, width) self:ApplyStatus()
local content = self.content self:Show()
local contentwidth = width - 34 self:EnableResize(true)
if contentwidth < 0 then end,
contentwidth = 0
end ["OnRelease"] = function(self)
content:SetWidth(contentwidth) self.status = nil
content.width = contentwidth wipe(self.localstatus)
end, end,
["OnHeightSet"] = function(self, height) ["OnWidthSet"] = function(self, width)
local content = self.content local content = self.content
local contentheight = height - 57 local contentwidth = width - 34
if contentheight < 0 then if contentwidth < 0 then
contentheight = 0 contentwidth = 0
end end
content:SetHeight(contentheight) content:SetWidth(contentwidth)
content.height = contentheight content.width = contentwidth
end, end,
["SetTitle"] = function(self, title) ["OnHeightSet"] = function(self, height)
self.titletext:SetText(title) local content = self.content
end, local contentheight = height - 57
if contentheight < 0 then
["SetStatusText"] = function(self, text) contentheight = 0
self.statustext:SetText(text) end
end, content:SetHeight(contentheight)
content.height = contentheight
["Hide"] = function(self) end,
self.frame:Hide()
end, ["SetTitle"] = function(self, title)
self.titletext:SetText(title)
["Show"] = function(self) self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10)
self.frame:Show() end,
end,
["SetStatusText"] = function(self, text)
-- called to set an external table to store status in self.statustext:SetText(text)
["SetStatusTable"] = function(self, status) end,
assert(type(status) == "table")
self.status = status ["Hide"] = function(self)
self:ApplyStatus() self.frame:Hide()
end, end,
["ApplyStatus"] = function(self) ["Show"] = function(self)
local status = self.status or self.localstatus self.frame:Show()
local frame = self.frame end,
self:SetWidth(status.width or 700)
self:SetHeight(status.height or 500) ["EnableResize"] = function(self, state)
frame:ClearAllPoints() local func = state and "Show" or "Hide"
if status.top and status.left then self.sizer_se[func](self.sizer_se)
frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top) self.sizer_s[func](self.sizer_s)
frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0) self.sizer_e[func](self.sizer_e)
else end,
frame:SetPoint("CENTER")
end -- called to set an external table to store status in
end ["SetStatusTable"] = function(self, status)
} assert(type(status) == "table")
self.status = status
--[[----------------------------------------------------------------------------- self:ApplyStatus()
Constructor end,
-------------------------------------------------------------------------------]]
local FrameBackdrop = { ["ApplyStatus"] = function(self)
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", local status = self.status or self.localstatus
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", local frame = self.frame
tile = true, tileSize = 32, edgeSize = 32, self:SetWidth(status.width or 700)
insets = { left = 8, right = 8, top = 8, bottom = 8 } self:SetHeight(status.height or 500)
} frame:ClearAllPoints()
if status.top and status.left then
local PaneBackdrop = { frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", else
tile = true, tileSize = 16, edgeSize = 16, frame:SetPoint("CENTER")
insets = { left = 3, right = 3, top = 5, bottom = 3 } end
} end
}
local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent) --[[-----------------------------------------------------------------------------
frame:Hide() Constructor
-------------------------------------------------------------------------------]]
frame:EnableMouse(true) local FrameBackdrop = {
frame:SetMovable(true) bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
frame:SetResizable(true) edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
frame:SetFrameStrata("FULLSCREEN_DIALOG") tile = true, tileSize = 32, edgeSize = 32,
frame:SetBackdrop(FrameBackdrop) insets = { left = 8, right = 8, top = 8, bottom = 8 }
frame:SetBackdropColor(0, 0, 0, 1) }
frame:SetMinResize(400, 200)
frame:SetToplevel(true) local PaneBackdrop = {
frame:SetScript("OnHide", Frame_OnClose) bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
frame:SetScript("OnMouseDown", Frame_OnMouseDown) edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
local closebutton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate") insets = { left = 3, right = 3, top = 5, bottom = 3 }
closebutton:SetScript("OnClick", Button_OnClick) }
closebutton:SetPoint("BOTTOMRIGHT", -27, 17)
closebutton:SetHeight(20) local function Constructor()
closebutton:SetWidth(100) local frame = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
closebutton:SetText(CLOSE) frame:Hide()
local statusbg = CreateFrame("Frame", nil, frame) frame:EnableMouse(true)
statusbg:SetPoint("BOTTOMLEFT", 15, 15) frame:SetMovable(true)
statusbg:SetPoint("BOTTOMRIGHT", -132, 15) frame:SetResizable(true)
statusbg:SetHeight(24) frame:SetFrameStrata("FULLSCREEN_DIALOG")
statusbg:SetBackdrop(PaneBackdrop) frame:SetFrameLevel(100) -- Lots of room to draw under it
statusbg:SetBackdropColor(0.1,0.1,0.1) frame:SetBackdrop(FrameBackdrop)
statusbg:SetBackdropBorderColor(0.4,0.4,0.4) frame:SetBackdropColor(0, 0, 0, 1)
if frame.SetResizeBounds then -- WoW 10.0
local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal") frame:SetResizeBounds(400, 200)
statustext:SetPoint("TOPLEFT", 7, -2) else
statustext:SetPoint("BOTTOMRIGHT", -7, 2) frame:SetMinResize(400, 200)
statustext:SetHeight(20) end
statustext:SetJustifyH("LEFT") frame:SetToplevel(true)
statustext:SetText("") frame:SetScript("OnShow", Frame_OnShow)
frame:SetScript("OnHide", Frame_OnClose)
local titlebg = frame:CreateTexture(nil, "OVERLAY") frame:SetScript("OnMouseDown", Frame_OnMouseDown)
titlebg:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
titlebg:SetTexCoord(0.31, 0.67, 0, 0.63) local closebutton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
titlebg:SetPoint("TOP", 0, 12) closebutton:SetScript("OnClick", Button_OnClick)
titlebg:SetWidth(100) closebutton:SetPoint("BOTTOMRIGHT", -27, 17)
titlebg:SetHeight(40) closebutton:SetHeight(20)
closebutton:SetWidth(100)
local title = CreateFrame("Frame", nil, frame) closebutton:SetText(CLOSE)
title:EnableMouse(true)
title:SetScript("OnMouseDown", Title_OnMouseDown) local statusbg = CreateFrame("Button", nil, frame, "BackdropTemplate")
title:SetScript("OnMouseUp", MoverSizer_OnMouseUp) statusbg:SetPoint("BOTTOMLEFT", 15, 15)
title:SetAllPoints(titlebg) statusbg:SetPoint("BOTTOMRIGHT", -132, 15)
statusbg:SetHeight(24)
local titletext = title:CreateFontString(nil, "OVERLAY", "GameFontNormal") statusbg:SetBackdrop(PaneBackdrop)
titletext:SetPoint("TOP", titlebg, "TOP", 0, -14) statusbg:SetBackdropColor(0.1,0.1,0.1)
statusbg:SetBackdropBorderColor(0.4,0.4,0.4)
local titlebg_l = frame:CreateTexture(nil, "OVERLAY") statusbg:SetScript("OnEnter", StatusBar_OnEnter)
titlebg_l:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") statusbg:SetScript("OnLeave", StatusBar_OnLeave)
titlebg_l:SetTexCoord(0.21, 0.31, 0, 0.63)
titlebg_l:SetPoint("RIGHT", titlebg, "LEFT") local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal")
titlebg_l:SetWidth(30) statustext:SetPoint("TOPLEFT", 7, -2)
titlebg_l:SetHeight(40) statustext:SetPoint("BOTTOMRIGHT", -7, 2)
statustext:SetHeight(20)
local titlebg_r = frame:CreateTexture(nil, "OVERLAY") statustext:SetJustifyH("LEFT")
titlebg_r:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") statustext:SetText("")
titlebg_r:SetTexCoord(0.67, 0.77, 0, 0.63)
titlebg_r:SetPoint("LEFT", titlebg, "RIGHT") local titlebg = frame:CreateTexture(nil, "OVERLAY")
titlebg_r:SetWidth(30) titlebg:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
titlebg_r:SetHeight(40) titlebg:SetTexCoord(0.31, 0.67, 0, 0.63)
titlebg:SetPoint("TOP", 0, 12)
local sizer_se = CreateFrame("Frame", nil, frame) titlebg:SetWidth(100)
sizer_se:SetPoint("BOTTOMRIGHT") titlebg:SetHeight(40)
sizer_se:SetWidth(25)
sizer_se:SetHeight(25) local title = CreateFrame("Frame", nil, frame)
sizer_se:EnableMouse() title:EnableMouse(true)
sizer_se:SetScript("OnMouseDown",SizerSE_OnMouseDown) title:SetScript("OnMouseDown", Title_OnMouseDown)
sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp) title:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
title:SetAllPoints(titlebg)
local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
line1:SetWidth(14) local titletext = title:CreateFontString(nil, "OVERLAY", "GameFontNormal")
line1:SetHeight(14) titletext:SetPoint("TOP", titlebg, "TOP", 0, -14)
line1:SetPoint("BOTTOMRIGHT", -8, 8)
line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") local titlebg_l = frame:CreateTexture(nil, "OVERLAY")
local x = 0.1 * 14/17 titlebg_l:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) titlebg_l:SetTexCoord(0.21, 0.31, 0, 0.63)
titlebg_l:SetPoint("RIGHT", titlebg, "LEFT")
local line2 = sizer_se:CreateTexture(nil, "BACKGROUND") titlebg_l:SetWidth(30)
line2:SetWidth(8) titlebg_l:SetHeight(40)
line2:SetHeight(8)
line2:SetPoint("BOTTOMRIGHT", -8, 8) local titlebg_r = frame:CreateTexture(nil, "OVERLAY")
line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") titlebg_r:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
local x = 0.1 * 8/17 titlebg_r:SetTexCoord(0.67, 0.77, 0, 0.63)
line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) titlebg_r:SetPoint("LEFT", titlebg, "RIGHT")
titlebg_r:SetWidth(30)
local sizer_s = CreateFrame("Frame", nil, frame) titlebg_r:SetHeight(40)
sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
sizer_s:SetPoint("BOTTOMLEFT") local sizer_se = CreateFrame("Frame", nil, frame)
sizer_s:SetHeight(25) sizer_se:SetPoint("BOTTOMRIGHT")
sizer_s:EnableMouse(true) sizer_se:SetWidth(25)
sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown) sizer_se:SetHeight(25)
sizer_s:SetScript("OnMouseUp", MoverSizer_OnMouseUp) sizer_se:EnableMouse()
sizer_se:SetScript("OnMouseDown",SizerSE_OnMouseDown)
local sizer_e = CreateFrame("Frame", nil, frame) sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
sizer_e:SetPoint("TOPRIGHT") local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
sizer_e:SetWidth(25) line1:SetWidth(14)
sizer_e:EnableMouse(true) line1:SetHeight(14)
sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown) line1:SetPoint("BOTTOMRIGHT", -8, 8)
sizer_e:SetScript("OnMouseUp", MoverSizer_OnMouseUp) line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
local x = 0.1 * 14/17
--Container Support line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
local content = CreateFrame("Frame", nil, frame)
content:SetPoint("TOPLEFT", 17, -27) local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
content:SetPoint("BOTTOMRIGHT", -17, 40) line2:SetWidth(8)
line2:SetHeight(8)
local widget = { line2:SetPoint("BOTTOMRIGHT", -8, 8)
localstatus = {}, line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
titletext = titletext, x = 0.1 * 8/17
statustext = statustext, line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
content = content,
frame = frame, local sizer_s = CreateFrame("Frame", nil, frame)
type = Type sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
} sizer_s:SetPoint("BOTTOMLEFT")
for method, func in pairs(methods) do sizer_s:SetHeight(25)
widget[method] = func sizer_s:EnableMouse(true)
end sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
closebutton.obj = widget sizer_s:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
return AceGUI:RegisterAsContainer(widget) local sizer_e = CreateFrame("Frame", nil, frame)
end sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
sizer_e:SetPoint("TOPRIGHT")
AceGUI:RegisterWidgetType(Type, Constructor, Version) sizer_e:SetWidth(25)
sizer_e:EnableMouse(true)
sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
sizer_e:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
--Container Support
local content = CreateFrame("Frame", nil, frame)
content:SetPoint("TOPLEFT", 17, -27)
content:SetPoint("BOTTOMRIGHT", -17, 40)
local widget = {
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
}
for method, func in pairs(methods) do
widget[method] = func
end
closebutton.obj, statusbg.obj = widget, widget
return AceGUI:RegisterAsContainer(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,138 +1,103 @@
local AceGUI = LibStub("AceGUI-3.0") --[[-----------------------------------------------------------------------------
InlineGroup Container
-- WoW APIs Simple container widget that creates a visible "box" with an optional title.
local CreateFrame, UIParent = CreateFrame, UIParent -------------------------------------------------------------------------------]]
local Type, Version = "InlineGroup", 22
------------- local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
-- Widgets -- if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-------------
--[[ -- Lua APIs
Widgets must provide the following functions local pairs = pairs
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 -- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
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() Methods
-------------------------------------------------------------------------------]]
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet local methods = {
It will be cleared automatically when a widget is released ["OnAcquire"] = function(self)
Placing values directly into a widget object should be avoided self:SetWidth(300)
self:SetHeight(100)
If the Widget can act as a container for other Widgets the following self:SetTitle("")
content - frame or derivitive that children will be anchored to end,
The Widget can supply the following Optional Members -- ["OnRelease"] = nil,
["SetTitle"] = function(self,title)
]] self.titletext:SetText(title)
end,
--------------------------
-- Inline Group --
-------------------------- ["LayoutFinished"] = function(self, width, height)
--[[ if self.noAutoHeight then return end
This is a simple grouping container, no selection self:SetHeight((height or 0) + 40)
It will resize automatically to the height of the controls added to it end,
]]
["OnWidthSet"] = function(self, width)
do local content = self.content
local Type = "InlineGroup" local contentwidth = width - 20
local Version = 6 if contentwidth < 0 then
contentwidth = 0
local function OnAcquire(self) end
self:SetWidth(300) content:SetWidth(contentwidth)
self:SetHeight(100) content.width = contentwidth
end end,
local function OnRelease(self) ["OnHeightSet"] = function(self, height)
self.frame:ClearAllPoints() local content = self.content
self.frame:Hide() local contentheight = height - 20
end if contentheight < 0 then
contentheight = 0
local PaneBackdrop = { end
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", content:SetHeight(contentheight)
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", content.height = contentheight
tile = true, tileSize = 16, edgeSize = 16, end
insets = { left = 3, right = 3, top = 5, bottom = 3 } }
}
--[[-----------------------------------------------------------------------------
local function SetTitle(self,title) Constructor
self.titletext:SetText(title) -------------------------------------------------------------------------------]]
end local PaneBackdrop = {
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
local function LayoutFinished(self, width, height) tile = true, tileSize = 16, edgeSize = 16,
if self.noAutoHeight then return end insets = { left = 3, right = 3, top = 5, bottom = 3 }
self:SetHeight((height or 0) + 40) }
end
local function Constructor()
local function OnWidthSet(self, width) local frame = CreateFrame("Frame", nil, UIParent)
local content = self.content frame:SetFrameStrata("FULLSCREEN_DIALOG")
local contentwidth = width - 20
if contentwidth < 0 then local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
contentwidth = 0 titletext:SetPoint("TOPLEFT", 14, 0)
end titletext:SetPoint("TOPRIGHT", -14, 0)
content:SetWidth(contentwidth) titletext:SetJustifyH("LEFT")
content.width = contentwidth titletext:SetHeight(18)
end
local border = CreateFrame("Frame", nil, frame, "BackdropTemplate")
border:SetPoint("TOPLEFT", 0, -17)
local function OnHeightSet(self, height) border:SetPoint("BOTTOMRIGHT", -1, 3)
local content = self.content border:SetBackdrop(PaneBackdrop)
local contentheight = height - 20 border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
if contentheight < 0 then border:SetBackdropBorderColor(0.4, 0.4, 0.4)
contentheight = 0
end --Container Support
content:SetHeight(contentheight) local content = CreateFrame("Frame", nil, border)
content.height = contentheight content:SetPoint("TOPLEFT", 10, -10)
end content:SetPoint("BOTTOMRIGHT", -10, 10)
local function Constructor() local widget = {
local frame = CreateFrame("Frame",nil,UIParent) frame = frame,
local self = {} content = content,
self.type = Type titletext = titletext,
type = Type
self.OnRelease = OnRelease }
self.OnAcquire = OnAcquire for method, func in pairs(methods) do
self.SetTitle = SetTitle widget[method] = func
self.frame = frame end
self.LayoutFinished = LayoutFinished
self.OnWidthSet = OnWidthSet return AceGUI:RegisterAsContainer(widget)
self.OnHeightSet = OnHeightSet end
frame.obj = self AceGUI:RegisterWidgetType(Type, Constructor, Version)
frame:SetHeight(100)
frame:SetWidth(100)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
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)
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
end
AceGUI:RegisterWidgetType(Type,Constructor,Version)
end
@@ -1,241 +1,215 @@
local AceGUI = LibStub("AceGUI-3.0") --[[-----------------------------------------------------------------------------
ScrollFrame Container
-- Lua APIs Plain container that scrolls its content and doesn't grow in height.
local pairs, assert, type = pairs, assert, type -------------------------------------------------------------------------------]]
local min, max, floor = math.min, math.max, math.floor local Type, Version = "ScrollFrame", 26
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
-- WoW APIs if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local CreateFrame, UIParent = CreateFrame, UIParent
-- Lua APIs
local pairs, assert, type = pairs, assert, type
------------- local min, max, floor = math.min, math.max, math.floor
-- Widgets --
------------- -- WoW APIs
--[[ local CreateFrame, UIParent = CreateFrame, UIParent
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 local function FixScrollOnUpdate(frame)
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes frame:SetScript("OnUpdate", nil)
type - the type of the object, same as the name given to :RegisterWidget() frame.obj:FixScroll()
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 Scripts
-------------------------------------------------------------------------------]]
If the Widget can act as a container for other Widgets the following local function ScrollFrame_OnMouseWheel(frame, value)
content - frame or derivitive that children will be anchored to frame.obj:MoveScroll(value)
end
The Widget can supply the following Optional Members
local function ScrollFrame_OnSizeChanged(frame)
frame:SetScript("OnUpdate", FixScrollOnUpdate)
]] end
-------------------------- local function ScrollBar_OnScrollValueChanged(frame, value)
-- Scroll Frame -- frame.obj:SetScroll(value)
-------------------------- end
do
local Type = "ScrollFrame" --[[-----------------------------------------------------------------------------
local Version = 9 Methods
-------------------------------------------------------------------------------]]
local function OnAcquire(self) local methods = {
["OnAcquire"] = function(self)
end self:SetScroll(0)
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
local function OnRelease(self) end,
self.frame:ClearAllPoints()
self.frame:Hide() ["OnRelease"] = function(self)
self.status = nil self.status = nil
-- do SetScroll after niling status, but before clearing localstatus for k in pairs(self.localstatus) do
-- so the scroll value isnt populated back into status, but not kept in localstatus either self.localstatus[k] = nil
self:SetScroll(0) end
for k in pairs(self.localstatus) do self.scrollframe:SetPoint("BOTTOMRIGHT")
self.localstatus[k] = nil self.scrollbar:Hide()
end self.scrollBarShown = nil
self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0) self.content.height, self.content.width, self.content.original_width = nil, nil, nil
self.scrollbar:Hide() end,
self.scrollBarShown = nil
self.content.height, self.content.width = nil, nil ["SetScroll"] = function(self, value)
end local status = self.status or self.localstatus
local viewheight = self.scrollframe:GetHeight()
local function SetScroll(self, value) local height = self.content:GetHeight()
local status = self.status or self.localstatus local offset
local viewheight = self.scrollframe:GetHeight()
local height = self.content:GetHeight() if viewheight > height then
local offset offset = 0
else
if viewheight > height then offset = floor((height - viewheight) / 1000.0 * value)
offset = 0 end
else self.content:ClearAllPoints()
offset = floor((height - viewheight) / 1000.0 * value) self.content:SetPoint("TOPLEFT", 0, offset)
end self.content:SetPoint("TOPRIGHT", 0, offset)
self.content:ClearAllPoints() status.offset = offset
self.content:SetPoint("TOPLEFT", self.scrollframe, "TOPLEFT", 0, offset) status.scrollvalue = value
self.content:SetPoint("TOPRIGHT", self.scrollframe, "TOPRIGHT", 0, offset) end,
status.offset = offset
status.scrollvalue = value ["MoveScroll"] = function(self, value)
end local status = self.status or self.localstatus
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
local function MoveScroll(self, value)
local status = self.status or self.localstatus if self.scrollBarShown then
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight() local diff = height - viewheight
local delta = 1
if height > viewheight then if value < 0 then
self.scrollbar:Hide() delta = -1
else end
self.scrollbar:Show() self.scrollbar:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
local diff = height - viewheight end
local delta = 1 end,
if value < 0 then
delta = -1 ["FixScroll"] = function(self)
end if self.updateLock then return end
self.scrollbar:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000)) self.updateLock = true
end local status = self.status or self.localstatus
end local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
local offset = status.offset or 0
-- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys
local function FixScroll(self) -- No-one is going to miss 2 pixels at the bottom of the frame, anyhow!
if self.updateLock then return end if viewheight < height + 2 then
self.updateLock = true if self.scrollBarShown then
local status = self.status or self.localstatus self.scrollBarShown = nil
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight() self.scrollbar:Hide()
local offset = status.offset or 0 self.scrollbar:SetValue(0)
local curvalue = self.scrollbar:GetValue() self.scrollframe:SetPoint("BOTTOMRIGHT")
if viewheight < height then if self.content.original_width then
if self.scrollBarShown then self.content.width = self.content.original_width
self.scrollBarShown = nil end
self.scrollbar:Hide() self:DoLayout()
self.scrollbar:SetValue(0) end
self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0) else
self:DoLayout() if not self.scrollBarShown then
end self.scrollBarShown = true
else self.scrollbar:Show()
if not self.scrollBarShown then self.scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
self.scrollBarShown = true if self.content.original_width then
self.scrollbar:Show() self.content.width = self.content.original_width - 20
self.scrollframe:SetPoint("BOTTOMRIGHT", self.frame,"BOTTOMRIGHT",-20,0) end
self:DoLayout() self:DoLayout()
end end
local value = (offset / (viewheight - height) * 1000) local value = (offset / (viewheight - height) * 1000)
if value > 1000 then value = 1000 end if value > 1000 then value = 1000 end
self.scrollbar:SetValue(value) self.scrollbar:SetValue(value)
self:SetScroll(value) self:SetScroll(value)
if value < 1000 then if value < 1000 then
self.content:ClearAllPoints() self.content:ClearAllPoints()
self.content:SetPoint("TOPLEFT", self.scrollframe, "TOPLEFT", 0, offset) self.content:SetPoint("TOPLEFT", 0, offset)
self.content:SetPoint("TOPRIGHT", self.scrollframe, "TOPRIGHT", 0, offset) self.content:SetPoint("TOPRIGHT", 0, offset)
status.offset = offset status.offset = offset
end end
end end
self.updateLock = nil self.updateLock = nil
end end,
local function OnMouseWheel(this, value) ["LayoutFinished"] = function(self, width, height)
this.obj:MoveScroll(value) self.content:SetHeight(height or 0 + 20)
end
-- update the scrollframe
local function OnScrollValueChanged(this, value) self:FixScroll()
this.obj:SetScroll(value)
end -- schedule another update when everything has "settled"
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
local function FixScrollOnUpdate(this) end,
this:SetScript("OnUpdate", nil)
this.obj:FixScroll() ["SetStatusTable"] = function(self, status)
end assert(type(status) == "table")
self.status = status
local function OnSizeChanged(this) if not status.scrollvalue then
this:SetScript("OnUpdate", FixScrollOnUpdate) status.scrollvalue = 0
end end
end,
local function LayoutFinished(self, width, height)
self.content:SetHeight(height or 0 + 20) ["OnWidthSet"] = function(self, width)
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate) local content = self.content
end content.width = width - (self.scrollBarShown and 20 or 0)
content.original_width = width
-- called to set an external table to store status in end,
local function SetStatusTable(self, status)
assert(type(status) == "table") ["OnHeightSet"] = function(self, height)
self.status = status local content = self.content
if not status.scrollvalue then content.height = height
status.scrollvalue = 0 end
end }
end --[[-----------------------------------------------------------------------------
Constructor
local function OnWidthSet(self, width) -------------------------------------------------------------------------------]]
local content = self.content local function Constructor()
content.width = width local frame = CreateFrame("Frame", nil, UIParent)
end local num = AceGUI:GetNextWidgetNum(Type)
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
local function OnHeightSet(self, height) scrollframe:SetPoint("TOPLEFT")
local content = self.content scrollframe:SetPoint("BOTTOMRIGHT")
content.height = height scrollframe:EnableMouseWheel(true)
end scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent) local scrollbar = CreateFrame("Slider", ("AceConfigDialogScrollFrame%dScrollBar"):format(num), scrollframe, "UIPanelScrollBarTemplate")
local self = {} scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
self.type = Type scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
scrollbar:SetMinMaxValues(0, 1000)
self.OnRelease = OnRelease scrollbar:SetValueStep(1)
self.OnAcquire = OnAcquire scrollbar:SetValue(0)
scrollbar:SetWidth(16)
self.MoveScroll = MoveScroll scrollbar:Hide()
self.FixScroll = FixScroll -- set the script as the last step, so it doesn't fire yet
self.SetScroll = SetScroll scrollbar:SetScript("OnValueChanged", ScrollBar_OnScrollValueChanged)
self.LayoutFinished = LayoutFinished
self.SetStatusTable = SetStatusTable local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
self.OnWidthSet = OnWidthSet scrollbg:SetAllPoints(scrollbar)
self.OnHeightSet = OnHeightSet scrollbg:SetColorTexture(0, 0, 0, 0.4)
self.localstatus = {} --Container Support
self.frame = frame local content = CreateFrame("Frame", nil, scrollframe)
frame.obj = self content:SetPoint("TOPLEFT")
content:SetPoint("TOPRIGHT")
--Container Support content:SetHeight(400)
local scrollframe = CreateFrame("ScrollFrame", nil, frame) scrollframe:SetScrollChild(content)
scrollframe.obj = self
scrollframe:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0) local widget = {
scrollframe:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 0) localstatus = { scrollvalue = 0 },
scrollframe:EnableMouseWheel(true) scrollframe = scrollframe,
scrollframe:SetScript("OnMouseWheel", OnMouseWheel) scrollbar = scrollbar,
scrollframe:SetScript("OnSizeChanged", OnSizeChanged) content = content,
self.scrollframe = scrollframe frame = frame,
type = Type
local content = CreateFrame("Frame", nil, scrollframe) }
content.obj = self for method, func in pairs(methods) do
content:SetPoint("TOPLEFT", scrollframe, "TOPLEFT", 0, 0) widget[method] = func
content:SetPoint("TOPRIGHT", scrollframe, "TOPRIGHT", 0, 0) end
content:SetHeight(400) scrollframe.obj, scrollbar.obj = widget, widget
self.content = content
scrollframe:SetScrollChild(content) return AceGUI:RegisterAsContainer(widget)
end
local num = AceGUI:GetNextWidgetNum(Type)
local name = ("AceConfigDialogScrollFrame%dScrollBar"):format(num) AceGUI:RegisterWidgetType(Type, Constructor, Version)
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
end
AceGUI:RegisterWidgetType(Type,Constructor,Version)
end
@@ -1,99 +1,69 @@
local AceGUI = LibStub("AceGUI-3.0") --[[-----------------------------------------------------------------------------
SimpleGroup Container
-- WoW APIs Simple container widget that just groups widgets.
local CreateFrame, UIParent = CreateFrame, UIParent -------------------------------------------------------------------------------]]
local Type, Version = "SimpleGroup", 20
------------- local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
-- Widgets -- if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-------------
--[[ -- Lua APIs
Widgets must provide the following functions local pairs = pairs
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 -- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
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() --[[-----------------------------------------------------------------------------
Methods
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 local methods = {
Placing values directly into a widget object should be avoided ["OnAcquire"] = function(self)
self:SetWidth(300)
If the Widget can act as a container for other Widgets the following self:SetHeight(100)
content - frame or derivitive that children will be anchored to end,
The Widget can supply the following Optional Members -- ["OnRelease"] = nil,
["LayoutFinished"] = function(self, width, height)
]] if self.noAutoHeight then return end
self:SetHeight(height or 0)
-------------------------- end,
-- Simple Group --
-------------------------- ["OnWidthSet"] = function(self, width)
--[[ local content = self.content
This is a simple grouping container, no selection, no borders content:SetWidth(width)
It will resize automatically to the height of the controls added to it content.width = width
]] end,
do ["OnHeightSet"] = function(self, height)
local Type = "SimpleGroup" local content = self.content
local Version = 5 content:SetHeight(height)
content.height = height
local function OnAcquire(self) end
self:SetWidth(300) }
self:SetHeight(100)
end --[[-----------------------------------------------------------------------------
Constructor
local function OnRelease(self) -------------------------------------------------------------------------------]]
self.frame:ClearAllPoints() local function Constructor()
self.frame:Hide() local frame = CreateFrame("Frame", nil, UIParent)
end frame:SetFrameStrata("FULLSCREEN_DIALOG")
local function LayoutFinished(self, width, height) --Container Support
if self.noAutoHeight then return end local content = CreateFrame("Frame", nil, frame)
self:SetHeight(height or 0) content:SetPoint("TOPLEFT")
end content:SetPoint("BOTTOMRIGHT")
local function OnWidthSet(self, width) local widget = {
local content = self.content frame = frame,
content:SetWidth(width) content = content,
content.width = width type = Type
end }
for method, func in pairs(methods) do
local function OnHeightSet(self, height) widget[method] = func
local content = self.content end
content:SetHeight(height)
content.height = height return AceGUI:RegisterAsContainer(widget)
end end
local function Constructor() AceGUI:RegisterWidgetType(Type, Constructor, Version)
local frame = CreateFrame("Frame",nil,UIParent)
local self = {}
self.type = Type
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.frame = frame
self.LayoutFinished = LayoutFinished
self.OnWidthSet = OnWidthSet
self.OnHeightSet = OnHeightSet
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
end
AceGUI:RegisterWidgetType(Type,Constructor,Version)
end
@@ -1,389 +1,535 @@
local AceGUI = LibStub("AceGUI-3.0") --[[-----------------------------------------------------------------------------
TabGroup Container
-- Lua APIs Container that uses tabs on top to switch between groups.
local pairs, ipairs, assert, type = pairs, ipairs, assert, type -------------------------------------------------------------------------------]]
local Type, Version = "TabGroup", 38
-- WoW APIs local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
local PlaySound = PlaySound if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G -- Lua APIs
local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, table.wipe
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script -- WoW APIs
-- GLOBALS: PanelTemplates_TabResize, PanelTemplates_SetDisabledTabState, PanelTemplates_SelectTab, PanelTemplates_DeselectTab local PlaySound = PlaySound
local CreateFrame, UIParent = CreateFrame, UIParent
------------- local _G = _G
-- Widgets --
------------- -- local upvalue storage used by BuildTabs
--[[ local widths = {}
Widgets must provide the following functions local rowwidths = {}
Acquire() - Called when the object is aquired, should set everything to a default hidden state local rowends = {}
Release() - Called when the object is Released, should remove any anchors and hide the Widget
--[[-----------------------------------------------------------------------------
And the following members Support functions
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)
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet local tabName = tab:GetName();
It will be cleared automatically when a widget is released
Placing values directly into a widget object should be avoided local buttonMiddle = tab.Middle or tab.middleTexture or _G[tabName.."Middle"];
local buttonMiddleDisabled = tab.MiddleDisabled or (tabName and _G[tabName.."MiddleDisabled"]);
If the Widget can act as a container for other Widgets the following local left = tab.Left or tab.leftTexture or _G[tabName.."Left"];
content - frame or derivitive that children will be anchored to local sideWidths = 2 * left:GetWidth();
local tabText = tab.Text or _G[tab:GetName().."Text"];
The Widget can supply the following Optional Members local highlightTexture = tab.HighlightTexture or (tabName and _G[tabName.."HighlightTexture"]);
local width, tabWidth;
]] local textWidth;
if ( absoluteTextSize ) then
-------------------------- textWidth = absoluteTextSize;
-- Tab Group -- else
-------------------------- tabText:SetWidth(0);
textWidth = tabText:GetWidth();
do end
local Type = "TabGroup" -- If there's an absolute size specified then use it
local Version = 25 if ( absoluteSize ) then
if ( absoluteSize < sideWidths) then
local PaneBackdrop = { width = 1;
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", tabWidth = sideWidths
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", else
tile = true, tileSize = 16, edgeSize = 16, width = absoluteSize - sideWidths;
insets = { left = 3, right = 3, top = 5, bottom = 3 } tabWidth = absoluteSize
} end
tabText:SetWidth(width);
local function OnAcquire(self) else
-- Otherwise try to use padding
end if ( padding ) then
width = textWidth + padding;
local function OnRelease(self) else
self.frame:ClearAllPoints() width = textWidth + 24;
self.frame:Hide() end
self.status = nil -- If greater than the maxWidth then cap it
for k in pairs(self.localstatus) do if ( maxWidth and width > maxWidth ) then
self.localstatus[k] = nil if ( padding ) then
end width = maxWidth + padding;
self.tablist = nil else
for _, tab in pairs(self.tabs) do width = maxWidth + 24;
tab:Hide() end
end tabText:SetWidth(width);
self:SetTitle() else
end tabText:SetWidth(0);
end
local function Tab_SetText(self, text) if (minWidth and width < minWidth) then
self:_SetText(text) width = minWidth;
local width = self.obj.frame.width or self.obj.frame:GetWidth() or 0 end
PanelTemplates_TabResize(self, 0, nil, width) tabWidth = width + sideWidths;
end end
local function UpdateTabLook(self) if ( buttonMiddle ) then
if self.disabled then buttonMiddle:SetWidth(width);
PanelTemplates_SetDisabledTabState(self) end
elseif self.selected then if ( buttonMiddleDisabled ) then
PanelTemplates_SelectTab(self) buttonMiddleDisabled:SetWidth(width);
else end
PanelTemplates_DeselectTab(self)
end tab:SetWidth(tabWidth);
end
if ( highlightTexture ) then
local function Tab_SetSelected(self, selected) highlightTexture:SetWidth(tabWidth);
self.selected = selected end
UpdateTabLook(self) end
end
local function PanelTemplates_DeselectTab(tab)
local function Tab_OnClick(self) local name = tab:GetName();
if not (self.selected or self.disabled) then
PlaySound("igCharacterInfoTab") local left = tab.Left or _G[name.."Left"];
self.obj:SelectTab(self.value) local middle = tab.Middle or _G[name.."Middle"];
end local right = tab.Right or _G[name.."Right"];
end left:Show();
middle:Show();
local function Tab_SetDisabled(self, disabled) right:Show();
self.disabled = disabled --tab:UnlockHighlight();
UpdateTabLook(self) tab:Enable();
end local text = tab.Text or _G[name.."Text"];
text:SetPoint("CENTER", tab, "CENTER", (tab.deselectedTextX or 0), (tab.deselectedTextY or 2));
local function Tab_OnEnter(this)
local self = this.obj local leftDisabled = tab.LeftDisabled or _G[name.."LeftDisabled"];
self:Fire("OnTabEnter", self.tabs[this.id].value, this) local middleDisabled = tab.MiddleDisabled or _G[name.."MiddleDisabled"];
end local rightDisabled = tab.RightDisabled or _G[name.."RightDisabled"];
leftDisabled:Hide();
local function Tab_OnLeave(this) middleDisabled:Hide();
local self = this.obj rightDisabled:Hide();
self:Fire("OnTabLeave", self.tabs[this.id].value, this) end
end
local function PanelTemplates_SelectTab(tab)
local function Tab_OnShow(this) local name = tab:GetName();
_G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30)
end local left = tab.Left or _G[name.."Left"];
local middle = tab.Middle or _G[name.."Middle"];
local function CreateTab(self, id) local right = tab.Right or _G[name.."Right"];
local tabname = "AceGUITabGroup"..self.num.."Tab"..id left:Hide();
local tab = CreateFrame("Button",tabname,self.border,"OptionsFrameTabButtonTemplate") middle:Hide();
tab.obj = self right:Hide();
tab.id = id --tab:LockHighlight();
tab:Disable();
tab.text = _G[tabname .. "Text"] tab:SetDisabledFontObject(GameFontHighlightSmall);
tab.text:ClearAllPoints() local text = tab.Text or _G[name.."Text"];
tab.text:SetPoint("LEFT", tab, "LEFT", 14, -3) text:SetPoint("CENTER", tab, "CENTER", (tab.selectedTextX or 0), (tab.selectedTextY or -3));
tab.text:SetPoint("RIGHT", tab, "RIGHT", -12, -3)
local leftDisabled = tab.LeftDisabled or _G[name.."LeftDisabled"];
tab:SetScript("OnClick",Tab_OnClick) local middleDisabled = tab.MiddleDisabled or _G[name.."MiddleDisabled"];
tab:SetScript("OnEnter",Tab_OnEnter) local rightDisabled = tab.RightDisabled or _G[name.."RightDisabled"];
tab:SetScript("OnLeave",Tab_OnLeave) leftDisabled:Show();
tab:SetScript("OnShow", Tab_OnShow) middleDisabled:Show();
rightDisabled:Show();
tab._SetText = tab.SetText
tab.SetText = Tab_SetText if GameTooltip:IsOwned(tab) then
tab.SetSelected = Tab_SetSelected GameTooltip:Hide();
tab.SetDisabled = Tab_SetDisabled end
end
return tab
end local function PanelTemplates_SetDisabledTabState(tab)
local name = tab:GetName();
local function SetTitle(self, text) local left = tab.Left or _G[name.."Left"];
self.titletext:SetText(text or "") local middle = tab.Middle or _G[name.."Middle"];
if text and text ~= "" then local right = tab.Right or _G[name.."Right"];
self.alignoffset = 25 left:Show();
else middle:Show();
self.alignoffset = 18 right:Show();
end --tab:UnlockHighlight();
self:BuildTabs() tab:Disable();
end tab.text = tab:GetText();
-- Gray out text
-- called to set an external table to store status in tab:SetDisabledFontObject(GameFontDisableSmall);
local function SetStatusTable(self, status) local leftDisabled = tab.LeftDisabled or _G[name.."LeftDisabled"];
assert(type(status) == "table") local middleDisabled = tab.MiddleDisabled or _G[name.."MiddleDisabled"];
self.status = status local rightDisabled = tab.RightDisabled or _G[name.."RightDisabled"];
end leftDisabled:Hide();
middleDisabled:Hide();
local function SelectTab(self, value) rightDisabled:Hide();
local status = self.status or self.localstatus end
local found local function UpdateTabLook(frame)
for i, v in ipairs(self.tabs) do if frame.disabled then
if v.value == value then PanelTemplates_SetDisabledTabState(frame)
v:SetSelected(true) elseif frame.selected then
found = true PanelTemplates_SelectTab(frame)
else else
v:SetSelected(false) PanelTemplates_DeselectTab(frame)
end end
end end
status.selected = value
if found then local function Tab_SetText(frame, text)
self:Fire("OnGroupSelected",value) frame:_SetText(text)
end local width = frame.obj.frame.width or frame.obj.frame:GetWidth() or 0
end PanelTemplates_TabResize(frame, 0, nil, nil, width, frame:GetFontString():GetStringWidth())
end
local function SetTabs(self, tabs)
self.tablist = tabs local function Tab_SetSelected(frame, selected)
self:BuildTabs() frame.selected = selected
end UpdateTabLook(frame)
end
local widths = {} local function Tab_SetDisabled(frame, disabled)
local rowwidths = {} frame.disabled = disabled
local rowends = {} UpdateTabLook(frame)
local function BuildTabs(self) end
local hastitle = (self.titletext:GetText() and self.titletext:GetText() ~= "")
local status = self.status or self.localstatus local function BuildTabsOnUpdate(frame)
local tablist = self.tablist local self = frame.obj
local tabs = self.tabs self:BuildTabs()
frame:SetScript("OnUpdate", nil)
if not tablist then return end end
local width = self.frame.width or self.frame:GetWidth() or 0 --[[-----------------------------------------------------------------------------
Scripts
for i = #widths, 1, -1 do -------------------------------------------------------------------------------]]
widths[i] = nil local function Tab_OnClick(frame)
end if not (frame.selected or frame.disabled) then
for i = #rowwidths, 1, -1 do PlaySound(841) -- SOUNDKIT.IG_CHARACTER_INFO_TAB
rowwidths[i] = nil frame.obj:SelectTab(frame.value)
end end
for i = #rowends, 1, -1 do end
rowends[i] = nil
end local function Tab_OnEnter(frame)
local self = frame.obj
--Place Text into tabs and get thier initial width self:Fire("OnTabEnter", self.tabs[frame.id].value, frame)
for i, v in ipairs(tablist) do end
local tab = tabs[i]
if not tab then local function Tab_OnLeave(frame)
tab = self:CreateTab(i) local self = frame.obj
tabs[i] = tab self:Fire("OnTabLeave", self.tabs[frame.id].value, frame)
end end
tab:Show() local function Tab_OnShow(frame)
tab:SetText(v.text) _G[frame:GetName().."HighlightTexture"]:SetWidth(frame:GetTextWidth() + 30)
tab:SetDisabled(v.disabled) end
tab.value = v.value
--[[-----------------------------------------------------------------------------
widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text Methods
end -------------------------------------------------------------------------------]]
local methods = {
for i = (#tablist)+1, #tabs, 1 do ["OnAcquire"] = function(self)
tabs[i]:Hide() self:SetTitle()
end end,
--First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout ["OnRelease"] = function(self)
local numtabs = #tablist self.status = nil
local numrows = 1 for k in pairs(self.localstatus) do
local usedwidth = 0 self.localstatus[k] = nil
end
for i = 1, #tablist do self.tablist = nil
--If this is not the first tab of a row and there isn't room for it for _, tab in pairs(self.tabs) do
if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then tab:Hide()
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px end
rowends[numrows] = i - 1 end,
numrows = numrows + 1
usedwidth = 0 ["CreateTab"] = function(self, id)
end local tabname = ("AceGUITabGroup%dTab%d"):format(self.num, id)
usedwidth = usedwidth + widths[i] local tab = CreateFrame("Button", tabname, self.border)
end tab:SetSize(115, 24)
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px tab.deselectedTextY = -3
rowends[numrows] = #tablist tab.selectedTextY = -2
--Fix for single tabs being left on the last row, move a tab from the row above if applicable tab.LeftDisabled = tab:CreateTexture(tabname .. "LeftDisabled", "BORDER")
if numrows > 1 then tab.LeftDisabled:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
--if the last row has only one tab tab.LeftDisabled:SetSize(20, 24)
if rowends[numrows-1] == numtabs-1 then tab.LeftDisabled:SetPoint("BOTTOMLEFT", 0, -3)
--if there are more than 2 tabs in the 2nd last row tab.LeftDisabled:SetTexCoord(0, 0.15625, 0, 1.0)
if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then
--move 1 tab from the second last row to the last, if there is enough space tab.MiddleDisabled = tab:CreateTexture(tabname .. "MiddleDisabled", "BORDER")
if (rowwidths[numrows] + widths[numtabs-1]) <= width then tab.MiddleDisabled:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
rowends[numrows-1] = rowends[numrows-1] - 1 tab.MiddleDisabled:SetSize(88, 24)
rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1] tab.MiddleDisabled:SetPoint("LEFT", tab.LeftDisabled, "RIGHT")
rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1] tab.MiddleDisabled:SetTexCoord(0.15625, 0.84375, 0, 1.0)
end
end tab.RightDisabled = tab:CreateTexture(tabname .. "RightDisabled", "BORDER")
end tab.RightDisabled:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
end tab.RightDisabled:SetSize(20, 24)
tab.RightDisabled:SetPoint("LEFT", tab.MiddleDisabled, "RIGHT")
--anchor the rows as defined and resize tabs to fill thier row tab.RightDisabled:SetTexCoord(0.84375, 1.0, 0, 1.0)
local starttab = 1
for row, endtab in ipairs(rowends) do tab.Left = tab:CreateTexture(tabname .. "Left", "BORDER")
local first = true tab.Left:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
for tabno = starttab, endtab do tab.Left:SetSize(20, 24)
local tab = tabs[tabno] tab.Left:SetPoint("TOPLEFT")
tab:ClearAllPoints() tab.Left:SetTexCoord(0, 0.15625, 0, 1.0)
if first then
tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -(hastitle and 14 or 7)-(row-1)*20 ) tab.Middle = tab:CreateTexture(tabname .. "Middle", "BORDER")
first = false tab.Middle:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
else tab.Middle:SetSize(88, 24)
tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0) tab.Middle:SetPoint("LEFT", tab.Left, "RIGHT")
end tab.Middle:SetTexCoord(0.15625, 0.84375, 0, 1.0)
end
tab.Right = tab:CreateTexture(tabname .. "Right", "BORDER")
-- equal padding for each tab to fill the available width, tab.Right:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
-- if the used space is above 75% already tab.Right:SetSize(20, 24)
local padding = 0 tab.Right:SetPoint("LEFT", tab.Middle, "RIGHT")
if not (numrows == 1 and rowwidths[1] < width*0.75) then tab.Right:SetTexCoord(0.84375, 1.0, 0, 1.0)
padding = (width - rowwidths[row]) / (endtab - starttab+1)
end tab.Text = tab:CreateFontString(tabname .. "Text")
tab:SetFontString(tab.Text)
for i = starttab, endtab do
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width) tab:SetNormalFontObject(GameFontNormalSmall)
end tab:SetHighlightFontObject(GameFontHighlightSmall)
starttab = endtab + 1 tab:SetDisabledFontObject(GameFontHighlightSmall)
end tab:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight", "ADD")
tab.HighlightTexture = tab:GetHighlightTexture()
self.borderoffset = (hastitle and 17 or 10)+((numrows)*20) tab.HighlightTexture:ClearAllPoints()
self.border:SetPoint("TOPLEFT",self.frame,"TOPLEFT",1,-self.borderoffset) tab.HighlightTexture:SetPoint("LEFT", tab, "LEFT", 10, -4)
end tab.HighlightTexture:SetPoint("RIGHT", tab, "RIGHT", -10, -4)
_G[tabname .. "HighlightTexture"] = tab.HighlightTexture
local function BuildTabsOnUpdate(this)
BuildTabs(this.obj) tab.obj = self
this:SetScript("OnUpdate", nil) tab.id = id
end
tab.text = tab.Text -- compat
local function OnWidthSet(self, width) tab.text:ClearAllPoints()
local content = self.content tab.text:SetPoint("LEFT", 14, -3)
local contentwidth = width - 60 tab.text:SetPoint("RIGHT", -12, -3)
if contentwidth < 0 then
contentwidth = 0 tab:SetScript("OnClick", Tab_OnClick)
end tab:SetScript("OnEnter", Tab_OnEnter)
content:SetWidth(contentwidth) tab:SetScript("OnLeave", Tab_OnLeave)
content.width = contentwidth tab:SetScript("OnShow", Tab_OnShow)
BuildTabs(self)
self.frame:SetScript("OnUpdate", BuildTabsOnUpdate) tab._SetText = tab.SetText
end tab.SetText = Tab_SetText
tab.SetSelected = Tab_SetSelected
tab.SetDisabled = Tab_SetDisabled
local function OnHeightSet(self, height)
local content = self.content return tab
local contentheight = height - (self.borderoffset + 23) end,
if contentheight < 0 then
contentheight = 0 ["SetTitle"] = function(self, text)
end self.titletext:SetText(text or "")
content:SetHeight(contentheight) if text and text ~= "" then
content.height = contentheight self.alignoffset = 25
end else
self.alignoffset = 18
local function LayoutFinished(self, width, height) end
if self.noAutoHeight then return end self:BuildTabs()
self:SetHeight((height or 0) + (self.borderoffset + 23)) end,
end
["SetStatusTable"] = function(self, status)
local function Constructor() assert(type(status) == "table")
local frame = CreateFrame("Frame",nil,UIParent) self.status = status
local self = {} end,
self.type = Type
["SelectTab"] = function(self, value)
self.num = AceGUI:GetNextWidgetNum(Type) local status = self.status or self.localstatus
local found
self.localstatus = {} for i, v in ipairs(self.tabs) do
if v.value == value then
self.OnRelease = OnRelease v:SetSelected(true)
self.OnAcquire = OnAcquire found = true
self.SetTitle = SetTitle else
self.CreateTab = CreateTab v:SetSelected(false)
self.SelectTab = SelectTab end
self.BuildTabs = BuildTabs end
self.SetStatusTable = SetStatusTable status.selected = value
self.SetTabs = SetTabs if found then
self.LayoutFinished = LayoutFinished self:Fire("OnGroupSelected",value)
self.frame = frame end
end,
self.OnWidthSet = OnWidthSet
self.OnHeightSet = OnHeightSet ["SetTabs"] = function(self, tabs)
self.tablist = tabs
frame.obj = self self:BuildTabs()
end,
frame:SetHeight(100)
frame:SetWidth(100)
frame:SetFrameStrata("FULLSCREEN_DIALOG") ["BuildTabs"] = function(self)
local hastitle = (self.titletext:GetText() and self.titletext:GetText() ~= "")
self.alignoffset = 18 local tablist = self.tablist
local tabs = self.tabs
local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0) if not tablist then return end
titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0)
titletext:SetJustifyH("LEFT") local width = self.frame.width or self.frame:GetWidth() or 0
titletext:SetHeight(18)
titletext:SetText("") wipe(widths)
wipe(rowwidths)
self.titletext = titletext wipe(rowends)
local border = CreateFrame("Frame",nil,frame) --Place Text into tabs and get thier initial width
self.border = border for i, v in ipairs(tablist) do
self.borderoffset = 27 local tab = tabs[i]
border:SetPoint("TOPLEFT",frame,"TOPLEFT",1,-27) if not tab then
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-1,3) tab = self:CreateTab(i)
tabs[i] = tab
border:SetBackdrop(PaneBackdrop) end
border:SetBackdropColor(0.1,0.1,0.1,0.5)
border:SetBackdropBorderColor(0.4,0.4,0.4) tab:Show()
tab:SetText(v.text)
self.tabs = {} tab:SetDisabled(v.disabled)
tab.value = v.value
--Container Support
local content = CreateFrame("Frame",nil,border) widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
self.content = content end
content.obj = self
content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-7) for i = (#tablist)+1, #tabs, 1 do
content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,7) tabs[i]:Hide()
end
AceGUI:RegisterAsContainer(self)
return self --First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
end local numtabs = #tablist
local numrows = 1
AceGUI:RegisterWidgetType(Type,Constructor,Version) local usedwidth = 0
end
for i = 1, #tablist do
--If this is not the first tab of a row and there isn't room for it
if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
rowends[numrows] = i - 1
numrows = numrows + 1
usedwidth = 0
end
usedwidth = usedwidth + widths[i]
end
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
rowends[numrows] = #tablist
--Fix for single tabs being left on the last row, move a tab from the row above if applicable
if numrows > 1 then
--if the last row has only one tab
if rowends[numrows-1] == numtabs-1 then
--if there are more than 2 tabs in the 2nd last row
if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then
--move 1 tab from the second last row to the last, if there is enough space
if (rowwidths[numrows] + widths[numtabs-1]) <= width then
rowends[numrows-1] = rowends[numrows-1] - 1
rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1]
rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1]
end
end
end
end
--anchor the rows as defined and resize tabs to fill thier row
local starttab = 1
for row, endtab in ipairs(rowends) do
local first = true
for tabno = starttab, endtab do
local tab = tabs[tabno]
tab:ClearAllPoints()
if first then
tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -(hastitle and 14 or 7)-(row-1)*20 )
first = false
else
tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0)
end
end
-- 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 - 18) then
padding = (width - rowwidths[row]) / (endtab - starttab+1)
end
for i = starttab, endtab do
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", 1, -self.borderoffset)
end,
["OnWidthSet"] = function(self, width)
local content = self.content
local contentwidth = width - 60
if contentwidth < 0 then
contentwidth = 0
end
content:SetWidth(contentwidth)
content.width = contentwidth
self:BuildTabs(self)
self.frame:SetScript("OnUpdate", BuildTabsOnUpdate)
end,
["OnHeightSet"] = function(self, height)
local content = self.content
local contentheight = height - (self.borderoffset + 23)
if contentheight < 0 then
contentheight = 0
end
content:SetHeight(contentheight)
content.height = contentheight
end,
["LayoutFinished"] = function(self, width, height)
if self.noAutoHeight then return end
self:SetHeight((height or 0) + (self.borderoffset + 23))
end
}
--[[-----------------------------------------------------------------------------
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 }
}
local function Constructor()
local num = AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Frame",nil,UIParent)
frame:SetHeight(100)
frame:SetWidth(100)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
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("")
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)
local content = CreateFrame("Frame", nil, border)
content:SetPoint("TOPLEFT", 10, -7)
content:SetPoint("BOTTOMRIGHT", -10, 7)
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
return AceGUI:RegisterAsContainer(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
File diff suppressed because it is too large Load Diff
@@ -1,331 +1,336 @@
local AceGUI = LibStub("AceGUI-3.0") local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs -- Lua APIs
local pairs, assert, type = pairs, assert, type local pairs, assert, type = pairs, assert, type
-- WoW APIs -- WoW APIs
local PlaySound = PlaySound local PlaySound = PlaySound
local CreateFrame, UIParent = CreateFrame, UIParent 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 -- Main Frame --
-- GLOBALS: GameFontNormal ----------------
--[[
---------------- Events :
-- Main Frame -- OnClose
----------------
--[[ ]]
Events : do
OnClose local Type = "Window"
local Version = 8
]]
do local function frameOnShow(this)
local Type = "Window" this.obj:Fire("OnShow")
local Version = 4 end
local function frameOnClose(this) local function frameOnClose(this)
this.obj:Fire("OnClose") this.obj:Fire("OnClose")
end end
local function closeOnClick(this) local function closeOnClick(this)
PlaySound("gsTitleOptionExit") PlaySound(799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
this.obj:Hide() this.obj:Hide()
end end
local function frameOnMouseDown(this) local function frameOnMouseDown(this)
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local function titleOnMouseDown(this) local function titleOnMouseDown(this)
this:GetParent():StartMoving() this:GetParent():StartMoving()
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local function frameOnMouseUp(this) local function frameOnMouseUp(this)
local frame = this:GetParent() local frame = this:GetParent()
frame:StopMovingOrSizing() frame:StopMovingOrSizing()
local self = frame.obj local self = frame.obj
local status = self.status or self.localstatus local status = self.status or self.localstatus
status.width = frame:GetWidth() status.width = frame:GetWidth()
status.height = frame:GetHeight() status.height = frame:GetHeight()
status.top = frame:GetTop() status.top = frame:GetTop()
status.left = frame:GetLeft() status.left = frame:GetLeft()
end end
local function sizerseOnMouseDown(this) local function sizerseOnMouseDown(this)
this:GetParent():StartSizing("BOTTOMRIGHT") this:GetParent():StartSizing("BOTTOMRIGHT")
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local function sizersOnMouseDown(this) local function sizersOnMouseDown(this)
this:GetParent():StartSizing("BOTTOM") this:GetParent():StartSizing("BOTTOM")
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local function sizereOnMouseDown(this) local function sizereOnMouseDown(this)
this:GetParent():StartSizing("RIGHT") this:GetParent():StartSizing("RIGHT")
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local function sizerOnMouseUp(this) local function sizerOnMouseUp(this)
this:GetParent():StopMovingOrSizing() this:GetParent():StopMovingOrSizing()
end end
local function SetTitle(self,title) local function SetTitle(self,title)
self.titletext:SetText(title) self.titletext:SetText(title)
end end
local function SetStatusText(self,text) local function SetStatusText(self,text)
-- self.statustext:SetText(text) -- self.statustext:SetText(text)
end end
local function Hide(self) local function Hide(self)
self.frame:Hide() self.frame:Hide()
end end
local function Show(self) local function Show(self)
self.frame:Show() self.frame:Show()
end end
local function OnAcquire(self) local function OnAcquire(self)
self.frame:SetParent(UIParent) self.frame:SetParent(UIParent)
self.frame:SetFrameStrata("FULLSCREEN_DIALOG") self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
self:ApplyStatus() self:ApplyStatus()
self:EnableResize(true) self:EnableResize(true)
self:Show() self:Show()
end end
local function OnRelease(self) local function OnRelease(self)
self.status = nil self.status = nil
for k in pairs(self.localstatus) do for k in pairs(self.localstatus) do
self.localstatus[k] = nil self.localstatus[k] = nil
end end
end end
-- called to set an external table to store status in -- called to set an external table to store status in
local function SetStatusTable(self, status) local function SetStatusTable(self, status)
assert(type(status) == "table") assert(type(status) == "table")
self.status = status self.status = status
self:ApplyStatus() self:ApplyStatus()
end end
local function ApplyStatus(self) local function ApplyStatus(self)
local status = self.status or self.localstatus local status = self.status or self.localstatus
local frame = self.frame local frame = self.frame
self:SetWidth(status.width or 700) self:SetWidth(status.width or 700)
self:SetHeight(status.height or 500) self:SetHeight(status.height or 500)
if status.top and status.left then if status.top and status.left then
frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top) frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0) frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
else else
frame:SetPoint("CENTER",UIParent,"CENTER") frame:SetPoint("CENTER",UIParent,"CENTER")
end end
end end
local function OnWidthSet(self, width) local function OnWidthSet(self, width)
local content = self.content local content = self.content
local contentwidth = width - 34 local contentwidth = width - 34
if contentwidth < 0 then if contentwidth < 0 then
contentwidth = 0 contentwidth = 0
end end
content:SetWidth(contentwidth) content:SetWidth(contentwidth)
content.width = contentwidth content.width = contentwidth
end end
local function OnHeightSet(self, height) local function OnHeightSet(self, height)
local content = self.content local content = self.content
local contentheight = height - 57 local contentheight = height - 57
if contentheight < 0 then if contentheight < 0 then
contentheight = 0 contentheight = 0
end end
content:SetHeight(contentheight) content:SetHeight(contentheight)
content.height = contentheight content.height = contentheight
end end
local function EnableResize(self, state) local function EnableResize(self, state)
local func = state and "Show" or "Hide" local func = state and "Show" or "Hide"
self.sizer_se[func](self.sizer_se) self.sizer_se[func](self.sizer_se)
self.sizer_s[func](self.sizer_s) self.sizer_s[func](self.sizer_s)
self.sizer_e[func](self.sizer_e) self.sizer_e[func](self.sizer_e)
end end
local function Constructor() local function Constructor()
local frame = CreateFrame("Frame",nil,UIParent) local frame = CreateFrame("Frame",nil,UIParent)
local self = {} local self = {}
self.type = "Window" self.type = "Window"
self.Hide = Hide self.Hide = Hide
self.Show = Show self.Show = Show
self.SetTitle = SetTitle self.SetTitle = SetTitle
self.OnRelease = OnRelease self.OnRelease = OnRelease
self.OnAcquire = OnAcquire self.OnAcquire = OnAcquire
self.SetStatusText = SetStatusText self.SetStatusText = SetStatusText
self.SetStatusTable = SetStatusTable self.SetStatusTable = SetStatusTable
self.ApplyStatus = ApplyStatus self.ApplyStatus = ApplyStatus
self.OnWidthSet = OnWidthSet self.OnWidthSet = OnWidthSet
self.OnHeightSet = OnHeightSet self.OnHeightSet = OnHeightSet
self.EnableResize = EnableResize self.EnableResize = EnableResize
self.localstatus = {} self.localstatus = {}
self.frame = frame self.frame = frame
frame.obj = self frame.obj = self
frame:SetWidth(700) frame:SetWidth(700)
frame:SetHeight(500) frame:SetHeight(500)
frame:SetPoint("CENTER",UIParent,"CENTER",0,0) frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
frame:EnableMouse() frame:EnableMouse()
frame:SetMovable(true) frame:SetMovable(true)
frame:SetResizable(true) frame:SetResizable(true)
frame:SetFrameStrata("FULLSCREEN_DIALOG") frame:SetFrameStrata("FULLSCREEN_DIALOG")
frame:SetScript("OnMouseDown", frameOnMouseDown) frame:SetScript("OnMouseDown", frameOnMouseDown)
frame:SetScript("OnHide",frameOnClose) frame:SetScript("OnShow",frameOnShow)
frame:SetMinResize(240,240) frame:SetScript("OnHide",frameOnClose)
frame:SetToplevel(true) if frame.SetResizeBounds then -- WoW 10.0
frame:SetResizeBounds(240,240)
local titlebg = frame:CreateTexture(nil, "BACKGROUND") else
titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]]) frame:SetMinResize(240,240)
titlebg:SetPoint("TOPLEFT", 9, -6) end
titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24) frame:SetToplevel(true)
local dialogbg = frame:CreateTexture(nil, "BACKGROUND") local titlebg = frame:CreateTexture(nil, "BACKGROUND")
dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]]) titlebg:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Title-Background")
dialogbg:SetPoint("TOPLEFT", 8, -24) titlebg:SetPoint("TOPLEFT", 9, -6)
dialogbg:SetPoint("BOTTOMRIGHT", -6, 8) titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24)
dialogbg:SetVertexColor(0, 0, 0, .75)
local dialogbg = frame:CreateTexture(nil, "BACKGROUND")
local topleft = frame:CreateTexture(nil, "BORDER") dialogbg:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) dialogbg:SetPoint("TOPLEFT", 8, -24)
topleft:SetWidth(64) dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
topleft:SetHeight(64) dialogbg:SetVertexColor(0, 0, 0, .75)
topleft:SetPoint("TOPLEFT")
topleft:SetTexCoord(0.501953125, 0.625, 0, 1) local topleft = frame:CreateTexture(nil, "BORDER")
topleft:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
local topright = frame:CreateTexture(nil, "BORDER") topleft:SetWidth(64)
topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) topleft:SetHeight(64)
topright:SetWidth(64) topleft:SetPoint("TOPLEFT")
topright:SetHeight(64) topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
topright:SetPoint("TOPRIGHT")
topright:SetTexCoord(0.625, 0.75, 0, 1) local topright = frame:CreateTexture(nil, "BORDER")
topright:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
local top = frame:CreateTexture(nil, "BORDER") topright:SetWidth(64)
top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) topright:SetHeight(64)
top:SetHeight(64) topright:SetPoint("TOPRIGHT")
top:SetPoint("TOPLEFT", topleft, "TOPRIGHT") topright:SetTexCoord(0.625, 0.75, 0, 1)
top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
top:SetTexCoord(0.25, 0.369140625, 0, 1) local top = frame:CreateTexture(nil, "BORDER")
top:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
local bottomleft = frame:CreateTexture(nil, "BORDER") top:SetHeight(64)
bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
bottomleft:SetWidth(64) top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
bottomleft:SetHeight(64) top:SetTexCoord(0.25, 0.369140625, 0, 1)
bottomleft:SetPoint("BOTTOMLEFT")
bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1) local bottomleft = frame:CreateTexture(nil, "BORDER")
bottomleft:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
local bottomright = frame:CreateTexture(nil, "BORDER") bottomleft:SetWidth(64)
bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) bottomleft:SetHeight(64)
bottomright:SetWidth(64) bottomleft:SetPoint("BOTTOMLEFT")
bottomright:SetHeight(64) bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
bottomright:SetPoint("BOTTOMRIGHT")
bottomright:SetTexCoord(0.875, 1, 0, 1) local bottomright = frame:CreateTexture(nil, "BORDER")
bottomright:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
local bottom = frame:CreateTexture(nil, "BORDER") bottomright:SetWidth(64)
bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) bottomright:SetHeight(64)
bottom:SetHeight(64) bottomright:SetPoint("BOTTOMRIGHT")
bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT") bottomright:SetTexCoord(0.875, 1, 0, 1)
bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1) local bottom = frame:CreateTexture(nil, "BORDER")
bottom:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
local left = frame:CreateTexture(nil, "BORDER") bottom:SetHeight(64)
left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
left:SetWidth(64) bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT") bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
left:SetTexCoord(0.001953125, 0.125, 0, 1) local left = frame:CreateTexture(nil, "BORDER")
left:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
local right = frame:CreateTexture(nil, "BORDER") left:SetWidth(64)
right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
right:SetWidth(64) left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT") left:SetTexCoord(0.001953125, 0.125, 0, 1)
right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
right:SetTexCoord(0.1171875, 0.2421875, 0, 1) local right = frame:CreateTexture(nil, "BORDER")
right:SetTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-Border")
local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton") right:SetWidth(64)
close:SetPoint("TOPRIGHT", 2, 1) right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
close:SetScript("OnClick", closeOnClick) right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
self.closebutton = close right:SetTexCoord(0.1171875, 0.2421875, 0, 1)
close.obj = self
local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
local titletext = frame:CreateFontString(nil, "ARTWORK") close:SetPoint("TOPRIGHT", 2, 1)
titletext:SetFontObject(GameFontNormal) close:SetScript("OnClick", closeOnClick)
titletext:SetPoint("TOPLEFT", 12, -8) self.closebutton = close
titletext:SetPoint("TOPRIGHT", -32, -8) close.obj = self
self.titletext = titletext
local titletext = frame:CreateFontString(nil, "ARTWORK")
local title = CreateFrame("Button", nil, frame) titletext:SetFontObject(GameFontNormal)
title:SetPoint("TOPLEFT", titlebg) titletext:SetPoint("TOPLEFT", 12, -8)
title:SetPoint("BOTTOMRIGHT", titlebg) titletext:SetPoint("TOPRIGHT", -32, -8)
title:EnableMouse() self.titletext = titletext
title:SetScript("OnMouseDown",titleOnMouseDown)
title:SetScript("OnMouseUp", frameOnMouseUp) local title = CreateFrame("Button", nil, frame)
self.title = title title:SetPoint("TOPLEFT", titlebg)
title:SetPoint("BOTTOMRIGHT", titlebg)
local sizer_se = CreateFrame("Frame",nil,frame) title:EnableMouse()
sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) title:SetScript("OnMouseDown",titleOnMouseDown)
sizer_se:SetWidth(25) title:SetScript("OnMouseUp", frameOnMouseUp)
sizer_se:SetHeight(25) self.title = title
sizer_se:EnableMouse()
sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown) local sizer_se = CreateFrame("Frame",nil,frame)
sizer_se:SetScript("OnMouseUp", sizerOnMouseUp) sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
self.sizer_se = sizer_se sizer_se:SetWidth(25)
sizer_se:SetHeight(25)
local line1 = sizer_se:CreateTexture(nil, "BACKGROUND") sizer_se:EnableMouse()
self.line1 = line1 sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown)
line1:SetWidth(14) sizer_se:SetScript("OnMouseUp", sizerOnMouseUp)
line1:SetHeight(14) self.sizer_se = sizer_se
line1:SetPoint("BOTTOMRIGHT", -8, 8)
line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
local x = 0.1 * 14/17 self.line1 = line1
line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) line1:SetWidth(14)
line1:SetHeight(14)
local line2 = sizer_se:CreateTexture(nil, "BACKGROUND") line1:SetPoint("BOTTOMRIGHT", -8, 8)
self.line2 = line2 line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
line2:SetWidth(8) local x = 0.1 * 14/17
line2:SetHeight(8) line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
line2:SetPoint("BOTTOMRIGHT", -8, 8)
line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
local x = 0.1 * 8/17 self.line2 = line2
line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) line2:SetWidth(8)
line2:SetHeight(8)
local sizer_s = CreateFrame("Frame",nil,frame) line2:SetPoint("BOTTOMRIGHT", -8, 8)
sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0) line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) x = 0.1 * 8/17
sizer_s:SetHeight(25) line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
sizer_s:EnableMouse()
sizer_s:SetScript("OnMouseDown",sizersOnMouseDown) local sizer_s = CreateFrame("Frame",nil,frame)
sizer_s:SetScript("OnMouseUp", sizerOnMouseUp) sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0)
self.sizer_s = sizer_s sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
sizer_s:SetHeight(25)
local sizer_e = CreateFrame("Frame",nil,frame) sizer_s:EnableMouse()
sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25) sizer_s:SetScript("OnMouseDown",sizersOnMouseDown)
sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) sizer_s:SetScript("OnMouseUp", sizerOnMouseUp)
sizer_e:SetWidth(25) self.sizer_s = sizer_s
sizer_e:EnableMouse()
sizer_e:SetScript("OnMouseDown",sizereOnMouseDown) local sizer_e = CreateFrame("Frame",nil,frame)
sizer_e:SetScript("OnMouseUp", sizerOnMouseUp) sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25)
self.sizer_e = sizer_e sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
sizer_e:SetWidth(25)
--Container Support sizer_e:EnableMouse()
local content = CreateFrame("Frame",nil,frame) sizer_e:SetScript("OnMouseDown",sizereOnMouseDown)
self.content = content sizer_e:SetScript("OnMouseUp", sizerOnMouseUp)
content.obj = self self.sizer_e = sizer_e
content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32)
content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13) --Container Support
local content = CreateFrame("Frame",nil,frame)
AceGUI:RegisterAsContainer(self) self.content = content
return self content.obj = self
end content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32)
content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13)
AceGUI:RegisterWidgetType(Type,Constructor,Version)
end AceGUI:RegisterAsContainer(self)
return self
end
AceGUI:RegisterWidgetType(Type,Constructor,Version)
end
@@ -1,92 +1,103 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Button Widget Button Widget
Graphical Button. Graphical Button.
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local Type, Version = "Button", 20 local Type, Version = "Button", 24
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local pairs = pairs local pairs = pairs
-- WoW APIs -- WoW APIs
local _G = _G local _G = _G
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Scripts Scripts
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local function Button_OnClick(frame, ...) local function Button_OnClick(frame, ...)
PlaySound("igMainMenuOption") AceGUI:ClearFocus()
frame.obj:Fire("OnClick", ...) PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
AceGUI:ClearFocus() frame.obj:Fire("OnClick", ...)
end end
local function Control_OnEnter(frame) local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter") frame.obj:Fire("OnEnter")
end end
local function Control_OnLeave(frame) local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave") frame.obj:Fire("OnLeave")
end end
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Methods Methods
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local methods = { local methods = {
["OnAcquire"] = function(self) ["OnAcquire"] = function(self)
-- restore default values -- restore default values
self:SetHeight(24) self:SetHeight(24)
self:SetWidth(200) self:SetWidth(200)
self:SetDisabled(false) self:SetDisabled(false)
self:SetText() self:SetAutoWidth(false)
end, self:SetText()
end,
-- ["OnRelease"] = nil,
-- ["OnRelease"] = nil,
["SetText"] = function(self, text)
self.text:SetText(text) ["SetText"] = function(self, text)
end, self.text:SetText(text)
if self.autoWidth then
["SetDisabled"] = function(self, disabled) self:SetWidth(self.text:GetStringWidth() + 30)
self.disabled = disabled end
if disabled then end,
self.frame:Disable()
else ["SetAutoWidth"] = function(self, autoWidth)
self.frame:Enable() self.autoWidth = autoWidth
end if self.autoWidth then
end self:SetWidth(self.text:GetStringWidth() + 30)
} end
end,
--[[-----------------------------------------------------------------------------
Constructor ["SetDisabled"] = function(self, disabled)
-------------------------------------------------------------------------------]] self.disabled = disabled
local function Constructor() if disabled then
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type) self.frame:Disable()
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2") else
frame:Hide() self.frame:Enable()
end
frame:EnableMouse(true) end
frame:SetScript("OnClick", Button_OnClick) }
frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave) --[[-----------------------------------------------------------------------------
Constructor
local text = frame:GetFontString() -------------------------------------------------------------------------------]]
text:ClearAllPoints() local function Constructor()
text:SetPoint("TOPLEFT", 15, -1) local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
text:SetPoint("BOTTOMRIGHT", -15, 1) local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
text:SetJustifyV("MIDDLE") frame:Hide()
local widget = { frame:EnableMouse(true)
text = text, frame:SetScript("OnClick", Button_OnClick)
frame = frame, frame:SetScript("OnEnter", Control_OnEnter)
type = Type frame:SetScript("OnLeave", Control_OnLeave)
}
for method, func in pairs(methods) do local text = frame:GetFontString()
widget[method] = func text:ClearAllPoints()
end text:SetPoint("TOPLEFT", 15, -1)
text:SetPoint("BOTTOMRIGHT", -15, 1)
return AceGUI:RegisterAsWidget(widget) text:SetJustifyV("MIDDLE")
end
local widget = {
AceGUI:RegisterWidgetType(Type, Constructor, Version) text = text,
frame = frame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,289 +1,292 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Checkbox Widget Checkbox Widget
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local Type, Version = "CheckBox", 21 local Type, Version = "CheckBox", 26
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local select, pairs = select, pairs local select, pairs = select, pairs
-- WoW APIs -- WoW APIs
local PlaySound = PlaySound local PlaySound = PlaySound
local CreateFrame, UIParent = CreateFrame, UIParent 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 Support functions
-- GLOBALS: SetDesaturation, GameFontHighlight -------------------------------------------------------------------------------]]
local function AlignImage(self)
--[[----------------------------------------------------------------------------- local img = self.image:GetTexture()
Support functions self.text:ClearAllPoints()
-------------------------------------------------------------------------------]] if not img then
local function AlignImage(self) self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
local img = self.image:GetTexture() self.text:SetPoint("RIGHT")
self.text:ClearAllPoints() else
if not img then self.text:SetPoint("LEFT", self.image, "RIGHT", 1, 0)
self.text:SetPoint("LEFT", self.checkbg, "RIGHT") self.text:SetPoint("RIGHT")
self.text:SetPoint("RIGHT") end
else end
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
self.text:SetPoint("RIGHT") --[[-----------------------------------------------------------------------------
end Scripts
end -------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
--[[----------------------------------------------------------------------------- frame.obj:Fire("OnEnter")
Scripts end
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame) local function Control_OnLeave(frame)
frame.obj:Fire("OnEnter") frame.obj:Fire("OnLeave")
end end
local function Control_OnLeave(frame) local function CheckBox_OnMouseDown(frame)
frame.obj:Fire("OnLeave") local self = frame.obj
end if not self.disabled then
if self.image:GetTexture() then
local function CheckBox_OnMouseDown(frame) self.text:SetPoint("LEFT", self.image,"RIGHT", 2, -1)
local self = frame.obj else
if not self.disabled then self.text:SetPoint("LEFT", self.checkbg, "RIGHT", 1, -1)
if self.image:GetTexture() then end
self.text:SetPoint("LEFT", self.image,"RIGHT", 2, -1) end
else AceGUI:ClearFocus()
self.text:SetPoint("LEFT", self.checkbg, "RIGHT", 1, -1) end
end
end local function CheckBox_OnMouseUp(frame)
AceGUI:ClearFocus() local self = frame.obj
end if not self.disabled then
self:ToggleChecked()
local function CheckBox_OnMouseUp(frame)
local self = frame.obj if self.checked then
if not self.disabled then PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
self:ToggleChecked() else -- for both nil and false (tristate)
PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
if self.checked then end
PlaySound("igMainMenuOptionCheckBoxOn")
else -- for both nil and false (tristate) self:Fire("OnValueChanged", self.checked)
PlaySound("igMainMenuOptionCheckBoxOff") AlignImage(self)
end end
end
self:Fire("OnValueChanged", self.checked)
AlignImage(self) --[[-----------------------------------------------------------------------------
end Methods
end -------------------------------------------------------------------------------]]
local methods = {
--[[----------------------------------------------------------------------------- ["OnAcquire"] = function(self)
Methods self:SetType()
-------------------------------------------------------------------------------]] self:SetValue(false)
local methods = { self:SetTriState(nil)
["OnAcquire"] = function(self) -- height is calculated from the width and required space for the description
self:SetType() self:SetWidth(200)
self:SetValue(false) self:SetImage()
self:SetTriState(nil) self:SetDisabled(nil)
-- height is calculated from the width and required space for the description self:SetDescription(nil)
self:SetWidth(200) end,
self:SetImage()
self:SetDisabled(nil) -- ["OnRelease"] = nil,
self:SetDescription(nil)
end, ["OnWidthSet"] = function(self, width)
if self.desc then
-- ["OnRelease"] = nil, self.desc:SetWidth(width - 30)
if self.desc:GetText() and self.desc:GetText() ~= "" then
["OnWidthSet"] = function(self, width) self:SetHeight(28 + self.desc:GetStringHeight())
if self.desc then end
self.desc:SetWidth(width - 30) end
if self.desc:GetText() and self.desc:GetText() ~= "" then end,
self:SetHeight(28 + self.desc:GetHeight())
end ["SetDisabled"] = function(self, disabled)
end self.disabled = disabled
end, if disabled then
self.frame:Disable()
["SetDisabled"] = function(self, disabled) self.text:SetTextColor(0.5, 0.5, 0.5)
self.disabled = disabled SetDesaturation(self.check, true)
if disabled then if self.desc then
self.frame:Disable() self.desc:SetTextColor(0.5, 0.5, 0.5)
self.text:SetTextColor(0.5, 0.5, 0.5) end
SetDesaturation(self.check, true) else
else self.frame:Enable()
self.frame:Enable() self.text:SetTextColor(1, 1, 1)
self.text:SetTextColor(1, 1, 1) if self.tristate and self.checked == nil then
if self.tristate and self.checked == nil then SetDesaturation(self.check, true)
SetDesaturation(self.check, true) else
else SetDesaturation(self.check, false)
SetDesaturation(self.check, false) end
end if self.desc then
end self.desc:SetTextColor(1, 1, 1)
end, end
end
["SetValue"] = function(self,value) end,
local check = self.check
self.checked = value ["SetValue"] = function(self, value)
if value then local check = self.check
SetDesaturation(self.check, false) self.checked = value
self.check:Show() if value then
else SetDesaturation(check, false)
--Nil is the unknown tristate value check:Show()
if self.tristate and value == nil then else
SetDesaturation(self.check, true) --Nil is the unknown tristate value
self.check:Show() if self.tristate and value == nil then
else SetDesaturation(check, true)
SetDesaturation(self.check, false) check:Show()
self.check:Hide() else
end SetDesaturation(check, false)
end check:Hide()
self:SetDisabled(self.disabled) end
end, end
self:SetDisabled(self.disabled)
["GetValue"] = function(self) end,
return self.checked
end, ["GetValue"] = function(self)
return self.checked
["SetTriState"] = function(self, enabled) end,
self.tristate = enabled
self:SetValue(self:GetValue()) ["SetTriState"] = function(self, enabled)
end, self.tristate = enabled
self:SetValue(self:GetValue())
["SetType"] = function(self, type) end,
local checkbg = self.checkbg
local check = self.check ["SetType"] = function(self, type)
local highlight = self.highlight local checkbg = self.checkbg
local check = self.check
local size local highlight = self.highlight
if type == "radio" then
size = 16 local size
checkbg:SetTexture("Interface\\Buttons\\UI-RadioButton") if type == "radio" then
checkbg:SetTexCoord(0, 0.25, 0, 1) size = 16
check:SetTexture("Interface\\Buttons\\UI-RadioButton") checkbg:SetTexture("Interface\\Buttons\\UI-RadioButton")
check:SetTexCoord(0.25, 0.5, 0, 1) checkbg:SetTexCoord(0, 0.25, 0, 1)
check:SetBlendMode("ADD") check:SetTexture("Interface\\Buttons\\UI-RadioButton")
highlight:SetTexture("Interface\\Buttons\\UI-RadioButton") check:SetTexCoord(0.25, 0.5, 0, 1)
highlight:SetTexCoord(0.5, 0.75, 0, 1) check:SetBlendMode("ADD")
else highlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
size = 24 highlight:SetTexCoord(0.5, 0.75, 0, 1)
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up") else
checkbg:SetTexCoord(0, 1, 0, 1) size = 24
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
check:SetTexCoord(0, 1, 0, 1) checkbg:SetTexCoord(0, 1, 0, 1)
check:SetBlendMode("BLEND") check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight") check:SetTexCoord(0, 1, 0, 1)
highlight:SetTexCoord(0, 1, 0, 1) check:SetBlendMode("BLEND")
end highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
checkbg:SetHeight(size) highlight:SetTexCoord(0, 1, 0, 1)
checkbg:SetWidth(size) end
end, checkbg:SetHeight(size)
checkbg:SetWidth(size)
["ToggleChecked"] = function(self) end,
local value = self:GetValue()
if self.tristate then ["ToggleChecked"] = function(self)
--cycle in true, nil, false order local value = self:GetValue()
if value then if self.tristate then
self:SetValue(nil) --cycle in true, nil, false order
elseif value == nil then if value then
self:SetValue(false) self:SetValue(nil)
else elseif value == nil then
self:SetValue(true) self:SetValue(false)
end else
else self:SetValue(true)
self:SetValue(not self:GetValue()) end
end else
end, self:SetValue(not self:GetValue())
end
["SetLabel"] = function(self, label) end,
self.text:SetText(label)
end, ["SetLabel"] = function(self, label)
self.text:SetText(label)
["SetDescription"] = function(self, desc) end,
if desc then
if not self.desc then ["SetDescription"] = function(self, desc)
local desc = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") if desc then
desc:ClearAllPoints() if not self.desc then
desc:SetPoint("TOPLEFT", self.checkbg, "TOPRIGHT", 5, -21) local f = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
desc:SetWidth(self.frame.width - 30) f:ClearAllPoints()
desc:SetJustifyH("LEFT") f:SetPoint("TOPLEFT", self.checkbg, "TOPRIGHT", 5, -21)
desc:SetJustifyV("TOP") f:SetWidth(self.frame.width - 30)
self.desc = desc f:SetPoint("RIGHT", self.frame, "RIGHT", -30, 0)
end f:SetJustifyH("LEFT")
self.desc:Show() f:SetJustifyV("TOP")
--self.text:SetFontObject(GameFontNormal) self.desc = f
self.desc:SetText(desc) end
self:SetHeight(28 + self.desc:GetHeight()) self.desc:Show()
else --self.text:SetFontObject(GameFontNormal)
if self.desc then self.desc:SetText(desc)
self.desc:SetText("") self:SetHeight(28 + self.desc:GetStringHeight())
self.desc:Hide() else
end if self.desc then
--self.text:SetFontObject(GameFontHighlight) self.desc:SetText("")
self:SetHeight(24) self.desc:Hide()
end end
end, --self.text:SetFontObject(GameFontHighlight)
self:SetHeight(24)
["SetImage"] = function(self, path, ...) end
local image = self.image end,
image:SetTexture(path)
["SetImage"] = function(self, path, ...)
if image:GetTexture() then local image = self.image
local n = select("#", ...) image:SetTexture(path)
if n == 4 or n == 8 then
image:SetTexCoord(...) if image:GetTexture() then
else local n = select("#", ...)
image:SetTexCoord(0, 1, 0, 1) if n == 4 or n == 8 then
end image:SetTexCoord(...)
end else
AlignImage(self) image:SetTexCoord(0, 1, 0, 1)
end end
} end
AlignImage(self)
--[[----------------------------------------------------------------------------- end
Constructor }
-------------------------------------------------------------------------------]]
local function Constructor() --[[-----------------------------------------------------------------------------
local frame = CreateFrame("Button", nil, UIParent) Constructor
frame:Hide() -------------------------------------------------------------------------------]]
local function Constructor()
frame:EnableMouse(true) local frame = CreateFrame("Button", nil, UIParent)
frame:SetScript("OnEnter", Control_OnEnter) frame:Hide()
frame:SetScript("OnLeave", Control_OnLeave)
frame:SetScript("OnMouseDown", CheckBox_OnMouseDown) frame:EnableMouse(true)
frame:SetScript("OnMouseUp", CheckBox_OnMouseUp) frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave)
local checkbg = frame:CreateTexture(nil, "ARTWORK") frame:SetScript("OnMouseDown", CheckBox_OnMouseDown)
checkbg:SetWidth(24) frame:SetScript("OnMouseUp", CheckBox_OnMouseUp)
checkbg:SetHeight(24)
checkbg:SetPoint("TOPLEFT") local checkbg = frame:CreateTexture(nil, "ARTWORK")
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up") checkbg:SetWidth(24)
checkbg:SetHeight(24)
local check = frame:CreateTexture(nil, "OVERLAY") checkbg:SetPoint("TOPLEFT")
check:SetAllPoints(checkbg) checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
local check = frame:CreateTexture(nil, "OVERLAY")
local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") check:SetAllPoints(checkbg)
text:SetJustifyH("LEFT") check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
text:SetHeight(18)
text:SetPoint("LEFT", checkbg, "RIGHT") local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
text:SetPoint("RIGHT") text:SetJustifyH("LEFT")
text:SetHeight(18)
local highlight = frame:CreateTexture(nil, "HIGHLIGHT") text:SetPoint("LEFT", checkbg, "RIGHT")
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight") text:SetPoint("RIGHT")
highlight:SetBlendMode("ADD")
highlight:SetAllPoints(checkbg) local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
local image = frame:CreateTexture(nil, "OVERLAY") highlight:SetBlendMode("ADD")
image:SetHeight(16) highlight:SetAllPoints(checkbg)
image:SetWidth(16)
image:SetPoint("LEFT", checkbg, "RIGHT", 1, 0) local image = frame:CreateTexture(nil, "OVERLAY")
image:SetHeight(16)
local widget = { image:SetWidth(16)
checkbg = checkbg, image:SetPoint("LEFT", checkbg, "RIGHT", 1, 0)
check = check,
text = text, local widget = {
highlight = highlight, checkbg = checkbg,
image = image, check = check,
frame = frame, text = text,
type = Type highlight = highlight,
} image = image,
for method, func in pairs(methods) do frame = frame,
widget[method] = func type = Type
end }
for method, func in pairs(methods) do
return AceGUI:RegisterAsWidget(widget) widget[method] = func
end end
AceGUI:RegisterWidgetType(Type, Constructor, Version) return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,186 +1,230 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
ColorPicker Widget ColorPicker Widget
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local Type, Version = "ColorPicker", 20 local Type, Version = "ColorPicker", 28
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local pairs = pairs local pairs = pairs
-- WoW APIs -- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent local CreateFrame, UIParent = CreateFrame, UIParent
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded -- Unfortunately we have no way to realistically detect if a client uses inverted alpha
-- List them here for Mikk's FindGlobals script -- as no API will tell you. Wrath uses the old colorpicker, era uses the new one, both are inverted
-- GLOBALS: ShowUIPanel, HideUIPanel, ColorPickerFrame, OpacitySliderFrame local INVERTED_ALPHA = (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE)
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Support functions Support functions
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local function ColorCallback(self, r, g, b, a, isAlpha) local function ColorCallback(self, r, g, b, a, isAlpha)
if not self.HasAlpha then if INVERTED_ALPHA and a then
a = 1 a = 1 - a
end end
self:SetColor(r, g, b, a) if not self.HasAlpha then
if ColorPickerFrame:IsVisible() then a = 1
--colorpicker is still open end
self:Fire("OnValueChanged", r, g, b, a) -- no change, skip update
else if r == self.r and g == self.g and b == self.b and a == self.a then
--colorpicker is closed, color callback is first, ignore it, return
--alpha callback is the final call after it closes so confirm now end
if isAlpha then self:SetColor(r, g, b, a)
self:Fire("OnValueConfirmed", r, g, b, a) if ColorPickerFrame:IsVisible() then
end --colorpicker is still open
end self:Fire("OnValueChanged", r, g, b, a)
end else
--colorpicker is closed, color callback is first, ignore it,
--[[----------------------------------------------------------------------------- --alpha callback is the final call after it closes so confirm now
Scripts if isAlpha then
-------------------------------------------------------------------------------]] self:Fire("OnValueConfirmed", r, g, b, a)
local function Control_OnEnter(frame) end
frame.obj:Fire("OnEnter") end
end end
local function Control_OnLeave(frame) --[[-----------------------------------------------------------------------------
frame.obj:Fire("OnLeave") Scripts
end -------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
local function ColorSwatch_OnClick(frame) frame.obj:Fire("OnEnter")
HideUIPanel(ColorPickerFrame) end
local self = frame.obj
if not self.disabled then local function Control_OnLeave(frame)
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG") frame.obj:Fire("OnLeave")
end
ColorPickerFrame.func = function()
local r, g, b = ColorPickerFrame:GetColorRGB() local function ColorSwatch_OnClick(frame)
local a = 1 - OpacitySliderFrame:GetValue() ColorPickerFrame:Hide()
ColorCallback(self, r, g, b, a) local self = frame.obj
end if not self.disabled then
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
ColorPickerFrame.hasOpacity = self.HasAlpha ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10)
ColorPickerFrame.opacityFunc = function() ColorPickerFrame:SetClampedToScreen(true)
local r, g, b = ColorPickerFrame:GetColorRGB()
local a = 1 - OpacitySliderFrame:GetValue() if ColorPickerFrame.SetupColorPickerAndShow then -- 10.2.5 color picker overhaul
ColorCallback(self, r, g, b, a, true) local r2, g2, b2, a2 = self.r, self.g, self.b, (self.a or 1)
end if INVERTED_ALPHA then
a2 = 1 - a2
local r, g, b, a = self.r, self.g, self.b, self.a end
if self.HasAlpha then
ColorPickerFrame.opacity = 1 - (a or 0) local info = {
end swatchFunc = function()
ColorPickerFrame:SetColorRGB(r, g, b) local r, g, b = ColorPickerFrame:GetColorRGB()
local a = ColorPickerFrame:GetColorAlpha()
ColorPickerFrame.cancelFunc = function() ColorCallback(self, r, g, b, a)
ColorCallback(self, r, g, b, a, true) end,
end
hasOpacity = self.HasAlpha,
ShowUIPanel(ColorPickerFrame) opacityFunc = function()
end local r, g, b = ColorPickerFrame:GetColorRGB()
AceGUI:ClearFocus() local a = ColorPickerFrame:GetColorAlpha()
end ColorCallback(self, r, g, b, a, true)
end,
--[[----------------------------------------------------------------------------- opacity = a2,
Methods
-------------------------------------------------------------------------------]] cancelFunc = function()
local methods = { ColorCallback(self, r2, g2, b2, a2, true)
["OnAcquire"] = function(self) end,
self:SetHeight(24)
self:SetWidth(200) r = r2,
self:SetHasAlpha(false) g = g2,
self:SetColor(0, 0, 0, 1) b = b2,
self:SetDisabled(nil) }
self:SetLabel(nil)
end, ColorPickerFrame:SetupColorPickerAndShow(info)
else
-- ["OnRelease"] = nil, ColorPickerFrame.func = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
["SetLabel"] = function(self, text) local a = OpacitySliderFrame:GetValue()
self.text:SetText(text) ColorCallback(self, r, g, b, a)
end, end
["SetColor"] = function(self, r, g, b, a) ColorPickerFrame.hasOpacity = self.HasAlpha
self.r = r ColorPickerFrame.opacityFunc = function()
self.g = g local r, g, b = ColorPickerFrame:GetColorRGB()
self.b = b local a = OpacitySliderFrame:GetValue()
self.a = a or 1 ColorCallback(self, r, g, b, a, true)
self.colorSwatch:SetVertexColor(r, g, b, a) end
end,
local r, g, b, a = self.r, self.g, self.b, 1 - (self.a or 1)
["SetHasAlpha"] = function(self, HasAlpha) if self.HasAlpha then
self.HasAlpha = HasAlpha ColorPickerFrame.opacity = a
end, end
ColorPickerFrame:SetColorRGB(r, g, b)
["SetDisabled"] = function(self, disabled)
self.disabled = disabled ColorPickerFrame.cancelFunc = function()
if self.disabled then ColorCallback(self, r, g, b, a, true)
self.frame:Disable() end
self.text:SetTextColor(0.5, 0.5, 0.5)
else ColorPickerFrame:Show()
self.frame:Enable() end
self.text:SetTextColor(1, 1, 1) end
end AceGUI:ClearFocus()
end end
}
--[[-----------------------------------------------------------------------------
--[[----------------------------------------------------------------------------- Methods
Constructor -------------------------------------------------------------------------------]]
-------------------------------------------------------------------------------]] local methods = {
local function Constructor() ["OnAcquire"] = function(self)
local frame = CreateFrame("Button", nil, UIParent) self:SetHeight(24)
frame:Hide() self:SetWidth(200)
self:SetHasAlpha(false)
frame:EnableMouse(true) self:SetColor(0, 0, 0, 1)
frame:SetScript("OnEnter", Control_OnEnter) self:SetDisabled(nil)
frame:SetScript("OnLeave", Control_OnLeave) self:SetLabel(nil)
frame:SetScript("OnClick", ColorSwatch_OnClick) end,
local colorSwatch = frame:CreateTexture(nil, "OVERLAY") -- ["OnRelease"] = nil,
colorSwatch:SetWidth(19)
colorSwatch:SetHeight(19) ["SetLabel"] = function(self, text)
colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch") self.text:SetText(text)
colorSwatch:SetPoint("LEFT") end,
local texture = frame:CreateTexture(nil, "BACKGROUND") ["SetColor"] = function(self, r, g, b, a)
texture:SetWidth(16) self.r = r
texture:SetHeight(16) self.g = g
texture:SetTexture(1, 1, 1) self.b = b
texture:SetPoint("CENTER", colorSwatch) self.a = a or 1
texture:Show() self.colorSwatch:SetVertexColor(r, g, b, a)
end,
local checkers = frame:CreateTexture(nil, "BACKGROUND")
checkers:SetWidth(14) ["SetHasAlpha"] = function(self, HasAlpha)
checkers:SetHeight(14) self.HasAlpha = HasAlpha
checkers:SetTexture("Tileset\\Generic\\Checkers") end,
checkers:SetTexCoord(.25, 0, 0.5, .25)
checkers:SetDesaturated(true) ["SetDisabled"] = function(self, disabled)
checkers:SetVertexColor(1, 1, 1, 0.75) self.disabled = disabled
checkers:SetPoint("CENTER", colorSwatch) if self.disabled then
checkers:Show() self.frame:Disable()
self.text:SetTextColor(0.5, 0.5, 0.5)
local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight") else
text:SetHeight(24) self.frame:Enable()
text:SetJustifyH("LEFT") self.text:SetTextColor(1, 1, 1)
text:SetTextColor(1, 1, 1) end
text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0) end
text:SetPoint("RIGHT") }
--local highlight = frame:CreateTexture(nil, "HIGHLIGHT") --[[-----------------------------------------------------------------------------
--highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") Constructor
--highlight:SetBlendMode("ADD") -------------------------------------------------------------------------------]]
--highlight:SetAllPoints(frame) local function Constructor()
local frame = CreateFrame("Button", nil, UIParent)
local widget = { frame:Hide()
colorSwatch = colorSwatch,
text = text, frame:EnableMouse(true)
frame = frame, frame:SetScript("OnEnter", Control_OnEnter)
type = Type frame:SetScript("OnLeave", Control_OnLeave)
} frame:SetScript("OnClick", ColorSwatch_OnClick)
for method, func in pairs(methods) do
widget[method] = func local colorSwatch = frame:CreateTexture(nil, "OVERLAY")
end colorSwatch:SetWidth(19)
colorSwatch:SetHeight(19)
return AceGUI:RegisterAsWidget(widget) colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
end colorSwatch:SetPoint("LEFT")
AceGUI:RegisterWidgetType(Type, Constructor, Version) local texture = frame:CreateTexture(nil, "BACKGROUND")
colorSwatch.background = texture
texture:SetWidth(16)
texture:SetHeight(16)
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")
checkers:SetTexCoord(.25, 0, 0.5, .25)
checkers:SetDesaturated(true)
checkers:SetVertexColor(1, 1, 1, 0.75)
checkers:SetPoint("CENTER", colorSwatch)
checkers:Show()
local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight")
text:SetHeight(24)
text:SetJustifyH("LEFT")
text:SetTextColor(1, 1, 1)
text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0)
text:SetPoint("RIGHT")
--local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
--highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
--highlight:SetBlendMode("ADD")
--highlight:SetAllPoints(frame)
local widget = {
colorSwatch = colorSwatch,
text = text,
frame = frame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,465 +1,471 @@
--[[ $Id: AceGUIWidget-DropDown-Items.lua 916 2010-03-15 12:24:36Z nevcairiel $ ]]-- --[[ $Id$ ]]--
local AceGUI = LibStub("AceGUI-3.0") local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs -- Lua APIs
local select, assert = select, assert local select, assert = select, assert
-- WoW APIs -- WoW APIs
local PlaySound = PlaySound local PlaySound = PlaySound
local CreateFrame = CreateFrame local CreateFrame = CreateFrame
local function fixlevels(parent,...) local function fixlevels(parent,...)
local i = 1 local i = 1
local child = select(i, ...) local child = select(i, ...)
while child do while child do
child:SetFrameLevel(parent:GetFrameLevel()+1) child:SetFrameLevel(parent:GetFrameLevel()+1)
fixlevels(child, child:GetChildren()) fixlevels(child, child:GetChildren())
i = i + 1 i = i + 1
child = select(i, ...) child = select(i, ...)
end end
end end
local function fixstrata(strata, parent, ...) local function fixstrata(strata, parent, ...)
local i = 1 local i = 1
local child = select(i, ...) local child = select(i, ...)
parent:SetFrameStrata(strata) parent:SetFrameStrata(strata)
while child do while child do
fixstrata(strata, child, child:GetChildren()) fixstrata(strata, child, child:GetChildren())
i = i + 1 i = i + 1
child = select(i, ...) child = select(i, ...)
end end
end end
-- ItemBase is the base "class" for all dropdown items. -- ItemBase is the base "class" for all dropdown items.
-- Each item has to use ItemBase.Create(widgetType) to -- Each item has to use ItemBase.Create(widgetType) to
-- create an initial 'self' value. -- create an initial 'self' value.
-- ItemBase will add common functions and ui event handlers. -- ItemBase will add common functions and ui event handlers.
-- Be sure to keep basic usage when you override functions. -- Be sure to keep basic usage when you override functions.
local ItemBase = { local ItemBase = {
-- NOTE: The ItemBase version is added to each item's version number -- NOTE: The ItemBase version is added to each item's version number
-- to ensure proper updates on ItemBase changes. -- to ensure proper updates on ItemBase changes.
-- Use at least 1000er steps. -- Use at least 1000er steps.
version = 1000, version = 2000,
counter = 0, counter = 0,
} }
function ItemBase.Frame_OnEnter(this) function ItemBase.Frame_OnEnter(this)
local self = this.obj local self = this.obj
if self.useHighlight then if self.useHighlight then
self.highlight:Show() self.highlight:Show()
end end
self:Fire("OnEnter") self:Fire("OnEnter")
if self.specialOnEnter then if self.specialOnEnter then
self.specialOnEnter(self) self.specialOnEnter(self)
end end
end end
function ItemBase.Frame_OnLeave(this) function ItemBase.Frame_OnLeave(this)
local self = this.obj local self = this.obj
self.highlight:Hide() self.highlight:Hide()
self:Fire("OnLeave") self:Fire("OnLeave")
if self.specialOnLeave then if self.specialOnLeave then
self.specialOnLeave(self) self.specialOnLeave(self)
end end
end end
-- exported, AceGUI callback -- exported, AceGUI callback
function ItemBase.OnAcquire(self) function ItemBase.OnAcquire(self)
self.frame:SetToplevel(true) self.frame:SetToplevel(true)
self.frame:SetFrameStrata("FULLSCREEN_DIALOG") self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
end end
-- exported, AceGUI callback -- exported, AceGUI callback
function ItemBase.OnRelease(self) function ItemBase.OnRelease(self)
self:SetDisabled(false) self:SetDisabled(false)
self.pullout = nil self.pullout = nil
self.frame:SetParent(nil) self.frame:SetParent(nil)
self.frame:ClearAllPoints() self.frame:ClearAllPoints()
self.frame:Hide() self.frame:Hide()
end end
-- exported -- exported
-- NOTE: this is called by a Dropdown-Pullout. -- NOTE: this is called by a Dropdown-Pullout.
-- Do not call this method directly -- Do not call this method directly
function ItemBase.SetPullout(self, pullout) function ItemBase.SetPullout(self, pullout)
self.pullout = pullout self.pullout = pullout
self.frame:SetParent(nil) self.frame:SetParent(nil)
self.frame:SetParent(pullout.itemFrame) self.frame:SetParent(pullout.itemFrame)
self.parent = pullout.itemFrame self.parent = pullout.itemFrame
fixlevels(pullout.itemFrame, pullout.itemFrame:GetChildren()) fixlevels(pullout.itemFrame, pullout.itemFrame:GetChildren())
end end
-- exported -- exported
function ItemBase.SetText(self, text) function ItemBase.SetText(self, text)
self.text:SetText(text or "") self.text:SetText(text or "")
end end
-- exported -- exported
function ItemBase.GetText(self) function ItemBase.GetText(self)
return self.text:GetText() return self.text:GetText()
end end
-- exported -- exported
function ItemBase.SetPoint(self, ...) function ItemBase.SetPoint(self, ...)
self.frame:SetPoint(...) self.frame:SetPoint(...)
end end
-- exported -- exported
function ItemBase.Show(self) function ItemBase.Show(self)
self.frame:Show() self.frame:Show()
end end
-- exported -- exported
function ItemBase.Hide(self) function ItemBase.Hide(self)
self.frame:Hide() self.frame:Hide()
end end
-- exported -- exported
function ItemBase.SetDisabled(self, disabled) function ItemBase.SetDisabled(self, disabled)
self.disabled = disabled self.disabled = disabled
if disabled then if disabled then
self.useHighlight = false self.useHighlight = false
self.text:SetTextColor(.5, .5, .5) self.text:SetTextColor(.5, .5, .5)
else else
self.useHighlight = true self.useHighlight = true
self.text:SetTextColor(1, 1, 1) self.text:SetTextColor(1, 1, 1)
end end
end end
-- exported -- exported
-- NOTE: this is called by a Dropdown-Pullout. -- NOTE: this is called by a Dropdown-Pullout.
-- Do not call this method directly -- Do not call this method directly
function ItemBase.SetOnLeave(self, func) function ItemBase.SetOnLeave(self, func)
self.specialOnLeave = func self.specialOnLeave = func
end end
-- exported -- exported
-- NOTE: this is called by a Dropdown-Pullout. -- NOTE: this is called by a Dropdown-Pullout.
-- Do not call this method directly -- Do not call this method directly
function ItemBase.SetOnEnter(self, func) function ItemBase.SetOnEnter(self, func)
self.specialOnEnter = func self.specialOnEnter = func
end end
function ItemBase.Create(type) function ItemBase.Create(type)
-- NOTE: Most of the following code is copied from AceGUI-3.0/Dropdown widget -- NOTE: Most of the following code is copied from AceGUI-3.0/Dropdown widget
local count = AceGUI:GetNextWidgetNum(type) local count = AceGUI:GetNextWidgetNum(type)
local frame = CreateFrame("Button", "AceGUI30DropDownItem"..count) local frame = CreateFrame("Button", "AceGUI30DropDownItem"..count)
local self = {} local self = {}
self.frame = frame self.frame = frame
frame.obj = self frame.obj = self
self.type = type self.type = type
self.useHighlight = true self.useHighlight = true
frame:SetHeight(17) frame:SetHeight(17)
frame:SetFrameStrata("FULLSCREEN_DIALOG") frame:SetFrameStrata("FULLSCREEN_DIALOG")
local text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall") local text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
text:SetTextColor(1,1,1) text:SetTextColor(1,1,1)
text:SetJustifyH("LEFT") text:SetJustifyH("LEFT")
text:SetPoint("TOPLEFT",frame,"TOPLEFT",18,0) text:SetPoint("TOPLEFT",frame,"TOPLEFT",18,0)
text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-8,0) text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-8,0)
self.text = text self.text = text
local highlight = frame:CreateTexture(nil, "OVERLAY") local highlight = frame:CreateTexture(nil, "OVERLAY")
highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
highlight:SetBlendMode("ADD") highlight:SetBlendMode("ADD")
highlight:SetHeight(14) highlight:SetHeight(14)
highlight:ClearAllPoints() highlight:ClearAllPoints()
highlight:SetPoint("RIGHT",frame,"RIGHT",-3,0) highlight:SetPoint("RIGHT",frame,"RIGHT",-3,0)
highlight:SetPoint("LEFT",frame,"LEFT",5,0) highlight:SetPoint("LEFT",frame,"LEFT",5,0)
highlight:Hide() highlight:Hide()
self.highlight = highlight self.highlight = highlight
local check = frame:CreateTexture("OVERLAY") local check = frame:CreateTexture(nil, "OVERLAY")
check:SetWidth(16) check:SetWidth(16)
check:SetHeight(16) check:SetHeight(16)
check:SetPoint("LEFT",frame,"LEFT",3,-1) check:SetPoint("LEFT",frame,"LEFT",3,-1)
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
check:Hide() check:Hide()
self.check = check self.check = check
local sub = frame:CreateTexture("OVERLAY") local sub = frame:CreateTexture(nil, "OVERLAY")
sub:SetWidth(16) sub:SetWidth(16)
sub:SetHeight(16) sub:SetHeight(16)
sub:SetPoint("RIGHT",frame,"RIGHT",-3,-1) sub:SetPoint("RIGHT",frame,"RIGHT",-3,-1)
sub:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow") sub:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
sub:Hide() sub:Hide()
self.sub = sub self.sub = sub
frame:SetScript("OnEnter", ItemBase.Frame_OnEnter) frame:SetScript("OnEnter", ItemBase.Frame_OnEnter)
frame:SetScript("OnLeave", ItemBase.Frame_OnLeave) frame:SetScript("OnLeave", ItemBase.Frame_OnLeave)
self.OnAcquire = ItemBase.OnAcquire self.OnAcquire = ItemBase.OnAcquire
self.OnRelease = ItemBase.OnRelease self.OnRelease = ItemBase.OnRelease
self.SetPullout = ItemBase.SetPullout self.SetPullout = ItemBase.SetPullout
self.GetText = ItemBase.GetText self.GetText = ItemBase.GetText
self.SetText = ItemBase.SetText self.SetText = ItemBase.SetText
self.SetDisabled = ItemBase.SetDisabled self.SetDisabled = ItemBase.SetDisabled
self.SetPoint = ItemBase.SetPoint self.SetPoint = ItemBase.SetPoint
self.Show = ItemBase.Show self.Show = ItemBase.Show
self.Hide = ItemBase.Hide self.Hide = ItemBase.Hide
self.SetOnLeave = ItemBase.SetOnLeave self.SetOnLeave = ItemBase.SetOnLeave
self.SetOnEnter = ItemBase.SetOnEnter self.SetOnEnter = ItemBase.SetOnEnter
return self return self
end end
--[[ -- Register a dummy LibStub library to retrieve the ItemBase, so other addons can use it.
Template for items: local IBLib = LibStub:NewLibrary("AceGUI-3.0-DropDown-ItemBase", ItemBase.version)
if IBLib then
-- Item: IBLib.GetItemBase = function() return ItemBase end
-- end
do
local widgetType = "Dropdown-Item-" --[[
local widgetVersion = 1 Template for items:
local function Constructor() -- Item:
local self = ItemBase.Create(widgetType) --
do
AceGUI:RegisterAsWidget(self) local widgetType = "Dropdown-Item-"
return self local widgetVersion = 1
end
local function Constructor()
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version) local self = ItemBase.Create(widgetType)
end
--]] AceGUI:RegisterAsWidget(self)
return self
-- Item: Header end
-- A single text entry.
-- Special: Different text color and no highlight AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
do end
local widgetType = "Dropdown-Item-Header" --]]
local widgetVersion = 1
-- Item: Header
local function OnEnter(this) -- A single text entry.
local self = this.obj -- Special: Different text color and no highlight
self:Fire("OnEnter") do
local widgetType = "Dropdown-Item-Header"
if self.specialOnEnter then local widgetVersion = 1
self.specialOnEnter(self)
end local function OnEnter(this)
end local self = this.obj
self:Fire("OnEnter")
local function OnLeave(this)
local self = this.obj if self.specialOnEnter then
self:Fire("OnLeave") self.specialOnEnter(self)
end
if self.specialOnLeave then end
self.specialOnLeave(self)
end local function OnLeave(this)
end local self = this.obj
self:Fire("OnLeave")
-- exported, override
local function SetDisabled(self, disabled) if self.specialOnLeave then
ItemBase.SetDisabled(self, disabled) self.specialOnLeave(self)
if not disabled then end
self.text:SetTextColor(1, 1, 0) end
end
end -- exported, override
local function SetDisabled(self, disabled)
local function Constructor() ItemBase.SetDisabled(self, disabled)
local self = ItemBase.Create(widgetType) if not disabled then
self.text:SetTextColor(1, 1, 0)
self.SetDisabled = SetDisabled end
end
self.frame:SetScript("OnEnter", OnEnter)
self.frame:SetScript("OnLeave", OnLeave) local function Constructor()
local self = ItemBase.Create(widgetType)
self.text:SetTextColor(1, 1, 0)
self.SetDisabled = SetDisabled
AceGUI:RegisterAsWidget(self)
return self self.frame:SetScript("OnEnter", OnEnter)
end self.frame:SetScript("OnLeave", OnLeave)
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version) self.text:SetTextColor(1, 1, 0)
end
AceGUI:RegisterAsWidget(self)
-- Item: Execute return self
-- A simple button end
do
local widgetType = "Dropdown-Item-Execute" AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
local widgetVersion = 1 end
local function Frame_OnClick(this, button) -- Item: Execute
local self = this.obj -- A simple button
if self.disabled then return end do
self:Fire("OnClick") local widgetType = "Dropdown-Item-Execute"
if self.pullout then local widgetVersion = 1
self.pullout:Close()
end local function Frame_OnClick(this, button)
end local self = this.obj
if self.disabled then return end
local function Constructor() self:Fire("OnClick")
local self = ItemBase.Create(widgetType) if self.pullout then
self.pullout:Close()
self.frame:SetScript("OnClick", Frame_OnClick) end
end
AceGUI:RegisterAsWidget(self)
return self local function Constructor()
end local self = ItemBase.Create(widgetType)
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version) self.frame:SetScript("OnClick", Frame_OnClick)
end
AceGUI:RegisterAsWidget(self)
-- Item: Toggle return self
-- Some sort of checkbox for dropdown menus. end
-- Does not close the pullout on click.
do AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
local widgetType = "Dropdown-Item-Toggle" end
local widgetVersion = 3
-- Item: Toggle
local function UpdateToggle(self) -- Some sort of checkbox for dropdown menus.
if self.value then -- Does not close the pullout on click.
self.check:Show() do
else local widgetType = "Dropdown-Item-Toggle"
self.check:Hide() local widgetVersion = 4
end
end local function UpdateToggle(self)
if self.value then
local function OnRelease(self) self.check:Show()
ItemBase.OnRelease(self) else
self:SetValue(nil) self.check:Hide()
end end
end
local function Frame_OnClick(this, button)
local self = this.obj local function OnRelease(self)
if self.disabled then return end ItemBase.OnRelease(self)
self.value = not self.value self:SetValue(nil)
if self.value then end
PlaySound("igMainMenuOptionCheckBoxOn")
else local function Frame_OnClick(this, button)
PlaySound("igMainMenuOptionCheckBoxOff") local self = this.obj
end if self.disabled then return end
UpdateToggle(self) self.value = not self.value
self:Fire("OnValueChanged", self.value) if self.value then
end PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
else
-- exported PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
local function SetValue(self, value) end
self.value = value UpdateToggle(self)
UpdateToggle(self) self:Fire("OnValueChanged", self.value)
end end
-- exported -- exported
local function GetValue(self) local function SetValue(self, value)
return self.value self.value = value
end UpdateToggle(self)
end
local function Constructor()
local self = ItemBase.Create(widgetType) -- exported
local function GetValue(self)
self.frame:SetScript("OnClick", Frame_OnClick) return self.value
end
self.SetValue = SetValue
self.GetValue = GetValue local function Constructor()
self.OnRelease = OnRelease local self = ItemBase.Create(widgetType)
AceGUI:RegisterAsWidget(self) self.frame:SetScript("OnClick", Frame_OnClick)
return self
end self.SetValue = SetValue
self.GetValue = GetValue
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version) self.OnRelease = OnRelease
end
AceGUI:RegisterAsWidget(self)
-- Item: Menu return self
-- Shows a submenu on mouse over end
-- Does not close the pullout on click
do AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
local widgetType = "Dropdown-Item-Menu" end
local widgetVersion = 2
-- Item: Menu
local function OnEnter(this) -- Shows a submenu on mouse over
local self = this.obj -- Does not close the pullout on click
self:Fire("OnEnter") do
local widgetType = "Dropdown-Item-Menu"
if self.specialOnEnter then local widgetVersion = 2
self.specialOnEnter(self)
end local function OnEnter(this)
local self = this.obj
self.highlight:Show() self:Fire("OnEnter")
if not self.disabled and self.submenu then if self.specialOnEnter then
self.submenu:Open("TOPLEFT", self.frame, "TOPRIGHT", self.pullout:GetRightBorderWidth(), 0, self.frame:GetFrameLevel() + 100) self.specialOnEnter(self)
end end
end
self.highlight:Show()
local function OnHide(this)
local self = this.obj if not self.disabled and self.submenu then
if self.submenu then self.submenu:Open("TOPLEFT", self.frame, "TOPRIGHT", self.pullout:GetRightBorderWidth(), 0, self.frame:GetFrameLevel() + 100)
self.submenu:Close() end
end end
end
local function OnHide(this)
-- exported local self = this.obj
local function SetMenu(self, menu) if self.submenu then
assert(menu.type == "Dropdown-Pullout") self.submenu:Close()
self.submenu = menu end
end end
-- exported -- exported
local function CloseMenu(self) local function SetMenu(self, menu)
self.submenu:Close() assert(menu.type == "Dropdown-Pullout")
end self.submenu = menu
end
local function Constructor()
local self = ItemBase.Create(widgetType) -- exported
local function CloseMenu(self)
self.sub:Show() self.submenu:Close()
end
self.frame:SetScript("OnEnter", OnEnter)
self.frame:SetScript("OnHide", OnHide) local function Constructor()
local self = ItemBase.Create(widgetType)
self.SetMenu = SetMenu
self.CloseMenu = CloseMenu self.sub:Show()
AceGUI:RegisterAsWidget(self) self.frame:SetScript("OnEnter", OnEnter)
return self self.frame:SetScript("OnHide", OnHide)
end
self.SetMenu = SetMenu
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version) self.CloseMenu = CloseMenu
end
AceGUI:RegisterAsWidget(self)
-- Item: Separator return self
-- A single line to separate items end
do
local widgetType = "Dropdown-Item-Separator" AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
local widgetVersion = 1 end
-- exported, override -- Item: Separator
local function SetDisabled(self, disabled) -- A single line to separate items
ItemBase.SetDisabled(self, disabled) do
self.useHighlight = false local widgetType = "Dropdown-Item-Separator"
end local widgetVersion = 2
local function Constructor() -- exported, override
local self = ItemBase.Create(widgetType) local function SetDisabled(self, disabled)
ItemBase.SetDisabled(self, disabled)
self.SetDisabled = SetDisabled self.useHighlight = false
end
local line = self.frame:CreateTexture(nil, "OVERLAY")
line:SetHeight(1) local function Constructor()
line:SetTexture(.5, .5, .5) local self = ItemBase.Create(widgetType)
line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0) self.SetDisabled = SetDisabled
self.text:Hide() local line = self.frame:CreateTexture(nil, "OVERLAY")
line:SetHeight(1)
self.useHighlight = false line:SetColorTexture(.5, .5, .5)
line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
AceGUI:RegisterAsWidget(self) line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
return self
end self.text:Hide()
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version) self.useHighlight = false
end
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
end
File diff suppressed because it is too large Load Diff
@@ -1,223 +1,267 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
EditBox Widget EditBox Widget
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local Type, Version = "EditBox", 20 local Type, Version = "EditBox", 29
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local tostring, pairs = tostring, pairs local tostring, pairs = tostring, pairs
-- WoW APIs -- WoW APIs
local PlaySound = PlaySound local PlaySound = PlaySound
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName local GetCursorInfo, ClearCursor = GetCursorInfo, ClearCursor
local CreateFrame, UIParent = CreateFrame, UIParent local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G 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 Support functions
-- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY -------------------------------------------------------------------------------]]
if not AceGUIEditBoxInsertLink then
--[[----------------------------------------------------------------------------- -- upgradeable hook
Support functions if ChatFrameUtil and ChatFrameUtil.InsertLink then
-------------------------------------------------------------------------------]] hooksecurefunc(ChatFrameUtil, "InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
if not AceGUIEditBoxInsertLink then elseif ChatEdit_InsertLink then
-- upgradeable hook hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end) end
end end
function _G.AceGUIEditBoxInsertLink(text) function _G.AceGUIEditBoxInsertLink(text)
for i = 1, AceGUI:GetWidgetCount(Type) do for i = 1, AceGUI:GetWidgetCount(Type) do
local editbox = _G["AceGUI-3.0EditBox"..i] local editbox = _G["AceGUI-3.0EditBox"..i]
if editbox and editbox:IsVisible() and editbox:HasFocus() then if editbox and editbox:IsVisible() and editbox:HasFocus() then
editbox:Insert(text) editbox:Insert(text)
return true return true
end end
end end
end end
local function ShowButton(self) local function ShowButton(self)
if not self.disablebutton then if not self.disablebutton then
self.button:Show() self.button:Show()
self.editbox:SetTextInsets(0, 20, 3, 3) self.editbox:SetTextInsets(0, 20, 3, 3)
end end
end end
local function HideButton(self) local function HideButton(self)
self.button:Hide() self.button:Hide()
self.editbox:SetTextInsets(0, 0, 3, 3) self.editbox:SetTextInsets(0, 0, 3, 3)
end end
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Scripts Scripts
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local function Control_OnEnter(frame) local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter") frame.obj:Fire("OnEnter")
end end
local function Control_OnLeave(frame) local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave") frame.obj:Fire("OnLeave")
end end
local function EditBox_OnEscapePressed(frame) local function Frame_OnShowFocus(frame)
AceGUI:ClearFocus() frame.obj.editbox:SetFocus()
end frame:SetScript("OnShow", nil)
end
local function EditBox_OnEnterPressed(frame)
local self = frame.obj local function EditBox_OnEscapePressed(frame)
local value = frame:GetText() AceGUI:ClearFocus()
local cancel = self:Fire("OnEnterPressed", value) end
if not cancel then
PlaySound("igMainMenuOptionCheckBoxOn") local function EditBox_OnEnterPressed(frame)
HideButton(self) local self = frame.obj
end local value = frame:GetText()
end local cancel = self:Fire("OnEnterPressed", value)
if not cancel then
local function EditBox_OnReceiveDrag(frame) PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
local self = frame.obj HideButton(self)
local type, id, info = GetCursorInfo() end
if type == "item" then end
self:SetText(info)
self:Fire("OnEnterPressed", info) local function EditBox_OnReceiveDrag(frame)
ClearCursor() local self = frame.obj
elseif type == "spell" then local type, id, info, extra = GetCursorInfo()
local name, rank = GetSpellName(id, info) local name
if rank and rank:match("%d") then if type == "item" then
name = name.."("..rank..")" name = info
end elseif type == "spell" then
self:SetText(name) if C_Spell and C_Spell.GetSpellName then
self:Fire("OnEnterPressed", name) name = C_Spell.GetSpellName(extra)
ClearCursor() else
end name = GetSpellInfo(id, info)
HideButton(self) end
AceGUI:ClearFocus() elseif type == "macro" then
end name = GetMacroInfo(id)
end
local function EditBox_OnTextChanged(frame) if name then
local self = frame.obj self:SetText(name)
local value = frame:GetText() self:Fire("OnEnterPressed", name)
if tostring(value) ~= tostring(self.lasttext) then ClearCursor()
self:Fire("OnTextChanged", value) HideButton(self)
self.lasttext = value AceGUI:ClearFocus()
ShowButton(self) end
end end
end
local function EditBox_OnTextChanged(frame)
local function Button_OnClick(frame) local self = frame.obj
local editbox = frame.obj.editbox local value = frame:GetText()
editbox:ClearFocus() if tostring(value) ~= tostring(self.lasttext) then
EditBox_OnEnterPressed(editbox) self:Fire("OnTextChanged", value)
end self.lasttext = value
ShowButton(self)
--[[----------------------------------------------------------------------------- end
Methods end
-------------------------------------------------------------------------------]]
local methods = { local function EditBox_OnFocusGained(frame)
["OnAcquire"] = function(self) AceGUI:SetFocus(frame.obj)
-- height is controlled by SetLabel end
self:SetWidth(200)
self:SetDisabled(false) local function Button_OnClick(frame)
self:SetLabel() local editbox = frame.obj.editbox
self:SetText() editbox:ClearFocus()
self:DisableButton(false) EditBox_OnEnterPressed(editbox)
end, end
-- ["OnRelease"] = nil, --[[-----------------------------------------------------------------------------
Methods
["SetDisabled"] = function(self, disabled) -------------------------------------------------------------------------------]]
self.disabled = disabled local methods = {
if disabled then ["OnAcquire"] = function(self)
self.editbox:EnableMouse(false) -- height is controlled by SetLabel
self.editbox:ClearFocus() self:SetWidth(200)
self.editbox:SetTextColor(0.5,0.5,0.5) self:SetDisabled(false)
self.label:SetTextColor(0.5,0.5,0.5) self:SetLabel()
else self:SetText()
self.editbox:EnableMouse(true) self:DisableButton(false)
self.editbox:SetTextColor(1,1,1) self:SetMaxLetters(0)
self.label:SetTextColor(1,.82,0) end,
end
end, ["OnRelease"] = function(self)
self:ClearFocus()
["SetText"] = function(self, text) end,
self.lasttext = text or ""
self.editbox:SetText(text or "") ["SetDisabled"] = function(self, disabled)
self.editbox:SetCursorPosition(0) self.disabled = disabled
HideButton(self) if disabled then
end, self.editbox:EnableMouse(false)
self.editbox:ClearFocus()
["SetLabel"] = function(self, text) self.editbox:SetTextColor(0.5,0.5,0.5)
if text and text ~= "" then self.label:SetTextColor(0.5,0.5,0.5)
self.label:SetText(text) else
self.label:Show() self.editbox:EnableMouse(true)
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18) self.editbox:SetTextColor(1,1,1)
self:SetHeight(44) self.label:SetTextColor(1,.82,0)
self.alignoffset = 30 end
else end,
self.label:SetText("")
self.label:Hide() ["SetText"] = function(self, text)
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0) self.lasttext = text or ""
self:SetHeight(26) self.editbox:SetText(text or "")
self.alignoffset = 12 self.editbox:SetCursorPosition(0)
end HideButton(self)
end, end,
["DisableButton"] = function(self, disabled) ["GetText"] = function(self, text)
self.disablebutton = disabled return self.editbox:GetText()
end end,
}
["SetLabel"] = function(self, text)
--[[----------------------------------------------------------------------------- if text and text ~= "" then
Constructor self.label:SetText(text)
-------------------------------------------------------------------------------]] self.label:Show()
local function Constructor() self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18)
local num = AceGUI:GetNextWidgetNum(Type) self:SetHeight(44)
local frame = CreateFrame("Frame", nil, UIParent) self.alignoffset = 30
frame:Hide() else
self.label:SetText("")
local editbox = CreateFrame("EditBox", "AceGUI-3.0EditBox"..num, frame, "InputBoxTemplate") self.label:Hide()
editbox:SetAutoFocus(false) self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0)
editbox:SetFontObject(ChatFontNormal) self:SetHeight(26)
editbox:SetScript("OnEnter", Control_OnEnter) self.alignoffset = 12
editbox:SetScript("OnLeave", Control_OnLeave) end
editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed) end,
editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
editbox:SetScript("OnTextChanged", EditBox_OnTextChanged) ["DisableButton"] = function(self, disabled)
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) self.disablebutton = disabled
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) if disabled then
editbox:SetTextInsets(0, 0, 3, 3) HideButton(self)
editbox:SetMaxLetters(256) end
editbox:SetPoint("BOTTOMLEFT", 6, 0) end,
editbox:SetPoint("BOTTOMRIGHT")
editbox:SetHeight(19) ["SetMaxLetters"] = function (self, num)
self.editbox:SetMaxLetters(num or 0)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") end,
label:SetPoint("TOPLEFT", 0, -2)
label:SetPoint("TOPRIGHT", 0, -2) ["ClearFocus"] = function(self)
label:SetJustifyH("LEFT") self.editbox:ClearFocus()
label:SetHeight(18) self.frame:SetScript("OnShow", nil)
end,
local button = CreateFrame("Button", nil, editbox, "UIPanelButtonTemplate")
button:SetWidth(40) ["SetFocus"] = function(self)
button:SetHeight(20) self.editbox:SetFocus()
button:SetPoint("RIGHT", -2, 0) if not self.frame:IsShown() then
button:SetText(OKAY) self.frame:SetScript("OnShow", Frame_OnShowFocus)
button:SetScript("OnClick", Button_OnClick) end
button:Hide() end,
local widget = { ["HighlightText"] = function(self, from, to)
alignoffset = 30, self.editbox:HighlightText(from, to)
editbox = editbox, end
label = label, }
button = button,
frame = frame, --[[-----------------------------------------------------------------------------
type = Type Constructor
} -------------------------------------------------------------------------------]]
for method, func in pairs(methods) do local function Constructor()
widget[method] = func local num = AceGUI:GetNextWidgetNum(Type)
end local frame = CreateFrame("Frame", nil, UIParent)
editbox.obj, button.obj = widget, widget frame:Hide()
return AceGUI:RegisterAsWidget(widget) local editbox = CreateFrame("EditBox", "AceGUI-3.0EditBox"..num, frame, "InputBoxTemplate")
end editbox:SetAutoFocus(false)
editbox:SetFontObject(ChatFontNormal)
AceGUI:RegisterWidgetType(Type, Constructor, Version) editbox:SetScript("OnEnter", Control_OnEnter)
editbox:SetScript("OnLeave", Control_OnLeave)
editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
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)
editbox:SetPoint("BOTTOMRIGHT")
editbox:SetHeight(19)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
label:SetPoint("TOPLEFT", 0, -2)
label:SetPoint("TOPRIGHT", 0, -2)
label:SetJustifyH("LEFT")
label:SetHeight(18)
local button = CreateFrame("Button", nil, editbox, "UIPanelButtonTemplate")
button:SetWidth(40)
button:SetHeight(20)
button:SetPoint("RIGHT", -2, 0)
button:SetText(OKAY)
button:SetScript("OnClick", Button_OnClick)
button:Hide()
local widget = {
alignoffset = 30,
editbox = editbox,
label = label,
button = button,
frame = frame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
editbox.obj, button.obj = widget, widget
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,78 +1,78 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Heading Widget Heading Widget
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local Type, Version = "Heading", 20 local Type, Version = "Heading", 20
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local pairs = pairs local pairs = pairs
-- WoW APIs -- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent local CreateFrame, UIParent = CreateFrame, UIParent
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Methods Methods
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local methods = { local methods = {
["OnAcquire"] = function(self) ["OnAcquire"] = function(self)
self:SetText() self:SetText()
self:SetFullWidth() self:SetFullWidth()
self:SetHeight(18) self:SetHeight(18)
end, end,
-- ["OnRelease"] = nil, -- ["OnRelease"] = nil,
["SetText"] = function(self, text) ["SetText"] = function(self, text)
self.label:SetText(text or "") self.label:SetText(text or "")
if text and text ~= "" then if text and text ~= "" then
self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0) self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0)
self.right:Show() self.right:Show()
else else
self.left:SetPoint("RIGHT", -3, 0) self.left:SetPoint("RIGHT", -3, 0)
self.right:Hide() self.right:Hide()
end end
end end
} }
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Constructor Constructor
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local function Constructor() local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent) local frame = CreateFrame("Frame", nil, UIParent)
frame:Hide() frame:Hide()
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal") local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
label:SetPoint("TOP") label:SetPoint("TOP")
label:SetPoint("BOTTOM") label:SetPoint("BOTTOM")
label:SetJustifyH("CENTER") label:SetJustifyH("CENTER")
local left = frame:CreateTexture(nil, "BACKGROUND") local left = frame:CreateTexture(nil, "BACKGROUND")
left:SetHeight(8) left:SetHeight(8)
left:SetPoint("LEFT", 3, 0) left:SetPoint("LEFT", 3, 0)
left:SetPoint("RIGHT", label, "LEFT", -5, 0) left:SetPoint("RIGHT", label, "LEFT", -5, 0)
left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
left:SetTexCoord(0.81, 0.94, 0.5, 1) left:SetTexCoord(0.81, 0.94, 0.5, 1)
local right = frame:CreateTexture(nil, "BACKGROUND") local right = frame:CreateTexture(nil, "BACKGROUND")
right:SetHeight(8) right:SetHeight(8)
right:SetPoint("RIGHT", -3, 0) right:SetPoint("RIGHT", -3, 0)
right:SetPoint("LEFT", label, "RIGHT", 5, 0) right:SetPoint("LEFT", label, "RIGHT", 5, 0)
right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
right:SetTexCoord(0.81, 0.94, 0.5, 1) right:SetTexCoord(0.81, 0.94, 0.5, 1)
local widget = { local widget = {
label = label, label = label,
left = left, left = left,
right = right, right = right,
frame = frame, frame = frame,
type = Type type = Type
} }
for method, func in pairs(methods) do for method, func in pairs(methods) do
widget[method] = func widget[method] = func
end end
return AceGUI:RegisterAsWidget(widget) return AceGUI:RegisterAsWidget(widget)
end end
AceGUI:RegisterWidgetType(Type, Constructor, Version) AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,144 +1,140 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Icon Widget Icon Widget
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local Type, Version = "Icon", 20 local Type, Version = "Icon", 21
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local select, pairs = select, pairs local select, pairs, print = select, pairs, print
-- WoW APIs -- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent local CreateFrame, UIParent = CreateFrame, UIParent
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Scripts Scripts
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local function Control_OnEnter(frame) local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter") frame.obj:Fire("OnEnter")
end end
local function Control_OnLeave(frame) local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave") frame.obj:Fire("OnLeave")
end end
local function Button_OnClick(frame, button) local function Button_OnClick(frame, button)
frame.obj:Fire("OnClick", button) frame.obj:Fire("OnClick", button)
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Methods Methods
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local methods = { local methods = {
["OnAcquire"] = function(self) ["OnAcquire"] = function(self)
self:SetHeight(110) self:SetHeight(110)
self:SetWidth(110) self:SetWidth(110)
self:SetLabel() self:SetLabel()
self:SetImage(nil) self:SetImage(nil)
self:SetImageSize(64, 64) self:SetImageSize(64, 64)
self:SetDisabled(false) self:SetDisabled(false)
end, end,
-- ["OnRelease"] = nil, -- ["OnRelease"] = nil,
["SetLabel"] = function(self, text) ["SetLabel"] = function(self, text)
if text and text ~= "" then if text and text ~= "" then
self.label:Show() self.label:Show()
self.label:SetText(text) self.label:SetText(text)
self:SetHeight(self.image:GetHeight() + 25) self:SetHeight(self.image:GetHeight() + 25)
else else
self.label:Hide() self.label:Hide()
self:SetHeight(self.image:GetHeight() + 10) self:SetHeight(self.image:GetHeight() + 10)
end end
end, end,
["SetImage"] = function(self, path, ...) ["SetImage"] = function(self, path, ...)
local image = self.image local image = self.image
image:SetTexture(path) image:SetTexture(path)
if image:GetTexture() then if image:GetTexture() then
local n = select("#", ...) local n = select("#", ...)
if n == 4 or n == 8 then if n == 4 or n == 8 then
image:SetTexCoord(...) image:SetTexCoord(...)
else else
image:SetTexCoord(0, 1, 0, 1) image:SetTexCoord(0, 1, 0, 1)
end end
end end
end, end,
["SetImageSize"] = function(self, width, height) ["SetImageSize"] = function(self, width, height)
self.image:SetWidth(width) self.image:SetWidth(width)
self.image:SetHeight(height) self.image:SetHeight(height)
--self.frame:SetWidth(width + 30) --self.frame:SetWidth(width + 30)
if self.label:IsShown() then if self.label:IsShown() then
self:SetHeight(height + 25) self:SetHeight(height + 25)
else else
self:SetHeight(height + 10) self:SetHeight(height + 10)
end end
end, end,
["SetDisabled"] = function(self, disabled) ["SetDisabled"] = function(self, disabled)
self.disabled = disabled self.disabled = disabled
if disabled then if disabled then
self.frame:Disable() self.frame:Disable()
self.label:SetTextColor(0.5, 0.5, 0.5) self.label:SetTextColor(0.5, 0.5, 0.5)
self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5) self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
else else
self.frame:Enable() self.frame:Enable()
self.label:SetTextColor(1, 1, 1) self.label:SetTextColor(1, 1, 1)
self.image:SetVertexColor(1, 1, 1) self.image:SetVertexColor(1, 1, 1, 1)
end end
end end
} }
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Constructor Constructor
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local function Constructor() local function Constructor()
local frame = CreateFrame("Button", nil, UIParent) local frame = CreateFrame("Button", nil, UIParent)
frame:Hide() frame:Hide()
frame:EnableMouse(true) frame:EnableMouse(true)
frame:SetScript("OnEnter", Control_OnEnter) frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave) frame:SetScript("OnLeave", Control_OnLeave)
frame:SetScript("OnClick", Button_OnClick) frame:SetScript("OnClick", Button_OnClick)
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlight") local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlight")
label:SetPoint("BOTTOMLEFT") label:SetPoint("BOTTOMLEFT")
label:SetPoint("BOTTOMRIGHT") label:SetPoint("BOTTOMRIGHT")
label:SetJustifyH("CENTER") label:SetJustifyH("CENTER")
label:SetJustifyV("TOP") label:SetJustifyV("TOP")
label:SetHeight(18) label:SetHeight(18)
local image = frame:CreateTexture(nil, "BACKGROUND") local image = frame:CreateTexture(nil, "BACKGROUND")
image:SetWidth(64) image:SetWidth(64)
image:SetHeight(64) image:SetHeight(64)
image:SetPoint("TOP", 0, -5) image:SetPoint("TOP", 0, -5)
local highlight = frame:CreateTexture(nil, "HIGHLIGHT") local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
highlight:SetAllPoints(image) highlight:SetAllPoints(image)
highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight") highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight")
highlight:SetTexCoord(0, 1, 0.23, 0.77) highlight:SetTexCoord(0, 1, 0.23, 0.77)
highlight:SetBlendMode("ADD") highlight:SetBlendMode("ADD")
local widget = { local widget = {
label = label, label = label,
image = image, image = image,
frame = frame, frame = frame,
type = Type type = Type
} }
for method, func in pairs(methods) do for method, func in pairs(methods) do
widget[method] = func widget[method] = func
end end
-- SetText is deprecated, but keep it around for a while. (say, to WoW 4.0)
if (select(4, GetBuildInfo()) < 40000) then widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end
widget.SetText = widget.SetLabel
else return AceGUI:RegisterAsWidget(widget)
widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end end
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,101 +1,94 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
InteractiveLabel Widget InteractiveLabel Widget
-------------------------------------------------------------------------------]] -------------------------------------------------------------------------------]]
local Type, Version = "InteractiveLabel", 20 local Type, Version = "InteractiveLabel", 21
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local select, pairs = select, pairs local select, pairs = select, pairs
-- WoW APIs --[[-----------------------------------------------------------------------------
local CreateFrame, UIParent = CreateFrame, UIParent Scripts
-------------------------------------------------------------------------------]]
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded local function Control_OnEnter(frame)
-- List them here for Mikk's FindGlobals script frame.obj:Fire("OnEnter")
-- GLOBALS: GameFontHighlightSmall end
--[[----------------------------------------------------------------------------- local function Control_OnLeave(frame)
Scripts frame.obj:Fire("OnLeave")
-------------------------------------------------------------------------------]] end
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter") local function Label_OnClick(frame, button)
end frame.obj:Fire("OnClick", button)
AceGUI:ClearFocus()
local function Control_OnLeave(frame) end
frame.obj:Fire("OnLeave")
end --[[-----------------------------------------------------------------------------
Methods
local function Label_OnClick(frame, button) -------------------------------------------------------------------------------]]
frame.obj:Fire("OnClick", button) local methods = {
AceGUI:ClearFocus() ["OnAcquire"] = function(self)
end self:LabelOnAcquire()
self:SetHighlight()
--[[----------------------------------------------------------------------------- self:SetHighlightTexCoord()
Methods self:SetDisabled(false)
-------------------------------------------------------------------------------]] end,
local methods = {
["OnAcquire"] = function(self) -- ["OnRelease"] = nil,
self:LabelOnAcquire()
self:SetHighlight() ["SetHighlight"] = function(self, ...)
self:SetHighlightTexCoord() self.highlight:SetTexture(...)
self:SetDisabled(false) end,
end,
["SetHighlightTexCoord"] = function(self, ...)
-- ["OnRelease"] = nil, local c = select("#", ...)
if c == 4 or c == 8 then
["SetHighlight"] = function(self, ...) self.highlight:SetTexCoord(...)
self.highlight:SetTexture(...) else
end, self.highlight:SetTexCoord(0, 1, 0, 1)
end
["SetHighlightTexCoord"] = function(self, ...) end,
local c = select("#", ...)
if c == 4 or c == 8 then ["SetDisabled"] = function(self,disabled)
self.highlight:SetTexCoord(...) self.disabled = disabled
else if disabled then
self.highlight:SetTexCoord(0, 1, 0, 1) self.frame:EnableMouse(false)
end self.label:SetTextColor(0.5, 0.5, 0.5)
end, else
self.frame:EnableMouse(true)
["SetDisabled"] = function(self,disabled) self.label:SetTextColor(1, 1, 1)
self.disabled = disabled end
if disabled then end
self.frame:EnableMouse(false) }
self.label:SetTextColor(0.5, 0.5, 0.5)
else --[[-----------------------------------------------------------------------------
self.frame:EnableMouse(true) Constructor
self.label:SetTextColor(1, 1, 1) -------------------------------------------------------------------------------]]
end local function Constructor()
end -- create a Label type that we will hijack
} local label = AceGUI:Create("Label")
--[[----------------------------------------------------------------------------- local frame = label.frame
Constructor frame:EnableMouse(true)
-------------------------------------------------------------------------------]] frame:SetScript("OnEnter", Control_OnEnter)
local function Constructor() frame:SetScript("OnLeave", Control_OnLeave)
-- create a Label type that we will hijack frame:SetScript("OnMouseDown", Label_OnClick)
local label = AceGUI:Create("Label")
local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
local frame = label.frame highlight:SetTexture(nil)
frame:EnableMouse(true) highlight:SetAllPoints()
frame:SetScript("OnEnter", Control_OnEnter) highlight:SetBlendMode("ADD")
frame:SetScript("OnLeave", Control_OnLeave)
frame:SetScript("OnMouseDown", Label_OnClick) label.highlight = highlight
label.type = Type
local highlight = frame:CreateTexture(nil, "HIGHLIGHT") label.LabelOnAcquire = label.OnAcquire
highlight:SetTexture(nil) for method, func in pairs(methods) do
highlight:SetAllPoints() label[method] = func
highlight:SetBlendMode("ADD") end
label.highlight = highlight return label
label.type = Type end
label.LabelOnAcquire = label.OnAcquire
for method, func in pairs(methods) do AceGUI:RegisterWidgetType(Type, Constructor, Version)
label[method] = func
end
return label
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,230 +1,251 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Keybinding Widget Keybinding Widget
Set Keybindings in the Config UI. 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) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local pairs = pairs local pairs = pairs
-- WoW APIs -- WoW APIs
local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown
local CreateFrame, UIParent = CreateFrame, UIParent 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 Scripts
-- GLOBALS: NOT_BOUND -------------------------------------------------------------------------------]]
--[[----------------------------------------------------------------------------- local function Control_OnEnter(frame)
Scripts frame.obj:Fire("OnEnter")
-------------------------------------------------------------------------------]] end
local function Control_OnEnter(frame) local function Control_OnLeave(frame)
frame.obj:Fire("OnEnter") frame.obj:Fire("OnLeave")
end end
local function Control_OnLeave(frame) local function Keybinding_OnClick(frame, button)
frame.obj:Fire("OnLeave") if button == "LeftButton" or button == "RightButton" then
end local self = frame.obj
if self.waitingForKey then
local function Keybinding_OnClick(frame, button) frame:EnableKeyboard(false)
if button == "LeftButton" or button == "RightButton" then frame:EnableMouseWheel(false)
local self = frame.obj frame:EnableGamePadButton(false)
if self.waitingForKey then self.msgframe:Hide()
frame:EnableKeyboard(false) frame:UnlockHighlight()
self.msgframe:Hide() self.waitingForKey = nil
frame:UnlockHighlight() else
self.waitingForKey = nil frame:EnableKeyboard(true)
else frame:EnableMouseWheel(true)
frame:EnableKeyboard(true) frame:EnableGamePadButton(true)
self.msgframe:Show() self.msgframe:Show()
frame:LockHighlight() frame:LockHighlight()
self.waitingForKey = true self.waitingForKey = true
end end
end end
AceGUI:ClearFocus() AceGUI:ClearFocus()
end end
local ignoreKeys = { local ignoreKeys = {
["BUTTON1"] = true, ["BUTTON2"] = true, ["BUTTON1"] = true, ["BUTTON2"] = true,
["UNKNOWN"] = true, ["UNKNOWN"] = true,
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true, ["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true,
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true, ["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
} }
local function Keybinding_OnKeyDown(frame, key) local function Keybinding_OnKeyDown(frame, key)
local self = frame.obj local self = frame.obj
if self.waitingForKey then if self.waitingForKey then
local keyPressed = key local keyPressed = key
if keyPressed == "ESCAPE" then if keyPressed == "ESCAPE" then
keyPressed = "" keyPressed = ""
else else
if ignoreKeys[keyPressed] then return end if ignoreKeys[keyPressed] then return end
if IsShiftKeyDown() then if IsShiftKeyDown() then
keyPressed = "SHIFT-"..keyPressed keyPressed = "SHIFT-"..keyPressed
end end
if IsControlKeyDown() then if IsControlKeyDown() then
keyPressed = "CTRL-"..keyPressed keyPressed = "CTRL-"..keyPressed
end end
if IsAltKeyDown() then if IsAltKeyDown() then
keyPressed = "ALT-"..keyPressed keyPressed = "ALT-"..keyPressed
end end
end end
frame:EnableKeyboard(false) frame:EnableKeyboard(false)
self.msgframe:Hide() frame:EnableMouseWheel(false)
frame:UnlockHighlight() frame:EnableGamePadButton(false)
self.waitingForKey = nil self.msgframe:Hide()
frame:UnlockHighlight()
if not self.disabled then self.waitingForKey = nil
self:SetKey(keyPressed)
self:Fire("OnKeyChanged", keyPressed) if not self.disabled then
end self:SetKey(keyPressed)
end self:Fire("OnKeyChanged", keyPressed)
end end
end
local function Keybinding_OnMouseDown(frame, button) end
if button == "LeftButton" or button == "RightButton" then
return local function Keybinding_OnMouseDown(frame, button)
elseif button == "MiddleButton" then if button == "LeftButton" or button == "RightButton" then
button = "BUTTON3" return
elseif button == "Button4" then elseif button == "MiddleButton" then
button = "BUTTON4" button = "BUTTON3"
elseif button == "Button5" then elseif button == "Button4" then
button = "BUTTON5" button = "BUTTON4"
end elseif button == "Button5" then
Keybinding_OnKeyDown(frame, button) button = "BUTTON5"
end end
Keybinding_OnKeyDown(frame, button)
--[[----------------------------------------------------------------------------- end
Methods
-------------------------------------------------------------------------------]] local function Keybinding_OnMouseWheel(frame, direction)
local methods = { local button
["OnAcquire"] = function(self) if direction >= 0 then
self:SetWidth(200) button = "MOUSEWHEELUP"
self:SetLabel("") else
self:SetKey("") button = "MOUSEWHEELDOWN"
self.waitingForKey = nil end
self.msgframe:Hide() Keybinding_OnKeyDown(frame, button)
self:SetDisabled(false) end
end,
--[[-----------------------------------------------------------------------------
-- ["OnRelease"] = nil, Methods
-------------------------------------------------------------------------------]]
["SetDisabled"] = function(self, disabled) local methods = {
self.disabled = disabled ["OnAcquire"] = function(self)
if disabled then self:SetWidth(200)
self.button:Disable() self:SetLabel("")
self.label:SetTextColor(0.5,0.5,0.5) self:SetKey("")
else self.waitingForKey = nil
self.button:Enable() self.msgframe:Hide()
self.label:SetTextColor(1,1,1) self:SetDisabled(false)
end self.button:EnableKeyboard(false)
end, self.button:EnableMouseWheel(false)
self.button:EnableGamePadButton(false)
["SetKey"] = function(self, key) end,
if (key or "") == "" then
self.button:SetText(NOT_BOUND) -- ["OnRelease"] = nil,
self.button:SetNormalFontObject("GameFontNormal")
else ["SetDisabled"] = function(self, disabled)
self.button:SetText(key) self.disabled = disabled
self.button:SetNormalFontObject("GameFontHighlight") if disabled then
end self.button:Disable()
end, self.label:SetTextColor(0.5,0.5,0.5)
else
["GetKey"] = function(self) self.button:Enable()
local key = self.button:GetText() self.label:SetTextColor(1,1,1)
if key == NOT_BOUND then end
key = nil end,
end
return key ["SetKey"] = function(self, key)
end, if (key or "") == "" then
self.button:SetText(NOT_BOUND)
["SetLabel"] = function(self, label) self.button:SetNormalFontObject("GameFontNormal")
self.label:SetText(label or "") else
if (label or "") == "" then self.button:SetText(key)
self.alignoffset = nil self.button:SetNormalFontObject("GameFontHighlight")
self:SetHeight(24) end
else end,
self.alignoffset = 30
self:SetHeight(44) ["GetKey"] = function(self)
end local key = self.button:GetText()
end, if key == NOT_BOUND then
} key = nil
end
--[[----------------------------------------------------------------------------- return key
Constructor end,
-------------------------------------------------------------------------------]]
["SetLabel"] = function(self, label)
local ControlBackdrop = { self.label:SetText(label or "")
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", if (label or "") == "" then
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", self.alignoffset = nil
tile = true, tileSize = 16, edgeSize = 16, self:SetHeight(24)
insets = { left = 3, right = 3, top = 3, bottom = 3 } else
} self.alignoffset = 30
self:SetHeight(44)
local function keybindingMsgFixWidth(frame) end
frame:SetWidth(frame.msg:GetWidth() + 10) end,
frame:SetScript("OnUpdate", nil) }
end
--[[-----------------------------------------------------------------------------
local function Constructor() Constructor
local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type) -------------------------------------------------------------------------------]]
local frame = CreateFrame("Frame", nil, UIParent) local ControlBackdrop = {
local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate2") bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
button:EnableMouse(true) tile = true, tileSize = 16, edgeSize = 16,
button:RegisterForClicks("AnyDown") insets = { left = 3, right = 3, top = 3, bottom = 3 }
button:SetScript("OnEnter", Control_OnEnter) }
button:SetScript("OnLeave", Control_OnLeave)
button:SetScript("OnClick", Keybinding_OnClick) local function keybindingMsgFixWidth(frame)
button:SetScript("OnKeyDown", Keybinding_OnKeyDown) frame:SetWidth(frame.msg:GetWidth() + 10)
button:SetScript("OnMouseDown", Keybinding_OnMouseDown) frame:SetScript("OnUpdate", nil)
button:SetPoint("BOTTOMLEFT") end
button:SetPoint("BOTTOMRIGHT")
button:SetHeight(24) local function Constructor()
local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type)
local text = button:GetFontString()
text:SetPoint("LEFT", 7, 0) local frame = CreateFrame("Frame", nil, UIParent)
text:SetPoint("RIGHT", -7, 0) local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate")
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") button:EnableMouse(true)
label:SetPoint("TOPLEFT") button:EnableMouseWheel(false)
label:SetPoint("TOPRIGHT") button:RegisterForClicks("AnyDown")
label:SetJustifyH("CENTER") button:SetScript("OnEnter", Control_OnEnter)
label:SetHeight(18) button:SetScript("OnLeave", Control_OnLeave)
button:SetScript("OnClick", Keybinding_OnClick)
local msgframe = CreateFrame("Frame", nil, UIParent) button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
msgframe:SetHeight(30) button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
msgframe:SetBackdrop(ControlBackdrop) button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
msgframe:SetBackdropColor(0,0,0) button:SetScript("OnGamePadButtonDown", Keybinding_OnKeyDown)
msgframe:SetFrameStrata("FULLSCREEN_DIALOG") button:SetPoint("BOTTOMLEFT")
msgframe:SetFrameLevel(1000) button:SetPoint("BOTTOMRIGHT")
button:SetHeight(24)
local msg = msgframe:CreateFontString(nil, "OVERLAY", "GameFontNormal") button:EnableKeyboard(false)
msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel.") button:EnableGamePadButton(false)
msgframe.msg = msg
msg:SetPoint("TOPLEFT", 5, -5) local text = button:GetFontString()
msgframe:SetScript("OnUpdate", keybindingMsgFixWidth) text:SetPoint("LEFT", 7, 0)
msgframe:SetPoint("BOTTOM", button, "TOP") text:SetPoint("RIGHT", -7, 0)
msgframe:Hide()
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
local widget = { label:SetPoint("TOPLEFT")
button = button, label:SetPoint("TOPRIGHT")
label = label, label:SetJustifyH("CENTER")
msgframe = msgframe, label:SetHeight(18)
frame = frame,
alignoffset = 30, local msgframe = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
type = Type msgframe:SetHeight(30)
} msgframe:SetBackdrop(ControlBackdrop)
for method, func in pairs(methods) do msgframe:SetBackdropColor(0,0,0)
widget[method] = func msgframe:SetFrameStrata("FULLSCREEN_DIALOG")
end msgframe:SetFrameLevel(1000)
button.obj = widget msgframe:SetToplevel(true)
return AceGUI:RegisterAsWidget(widget) local msg = msgframe:CreateFontString(nil, "OVERLAY", "GameFontNormal")
end msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel.")
msgframe.msg = msg
AceGUI:RegisterWidgetType(Type, Constructor, Version) msg:SetPoint("TOPLEFT", 5, -5)
msgframe:SetScript("OnUpdate", keybindingMsgFixWidth)
msgframe:SetPoint("BOTTOM", button, "TOP")
msgframe:Hide()
local widget = {
button = button,
label = label,
msgframe = msgframe,
frame = frame,
alignoffset = 30,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
button.obj = widget
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,162 +1,179 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Label Widget Label Widget
Displays text and optionally an icon. 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) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local max, select, pairs = math.max, select, pairs local max, select, pairs = math.max, select, pairs
-- WoW APIs -- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent 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 Support functions
-- GLOBALS: GameFontHighlightSmall -------------------------------------------------------------------------------]]
--[[----------------------------------------------------------------------------- local function UpdateImageAnchor(self)
Support functions if self.resizing then return end
-------------------------------------------------------------------------------]] local frame = self.frame
local width = frame.width or frame:GetWidth() or 0
local function UpdateImageAnchor(self) local image = self.image
if self.resizing then return end local label = self.label
local frame = self.frame local height
local width = frame.width or frame:GetWidth() or 0
local image = self.image label:ClearAllPoints()
local label = self.label image:ClearAllPoints()
local height
if self.imageshown then
label:ClearAllPoints() local imagewidth = image:GetWidth()
image:ClearAllPoints() if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
-- image goes on top centered when less than 200 width for the text, or if there is no text
if self.imageshown then image:SetPoint("TOP")
local imagewidth = image:GetWidth() label:SetPoint("TOP", image, "BOTTOM")
if (width - imagewidth) < 200 or (label:GetText() or "") == "" then label:SetPoint("LEFT")
-- image goes on top centered when less than 200 width for the text, or if there is no text label:SetWidth(width)
image:SetPoint("TOP") height = image:GetHeight() + label:GetStringHeight()
label:SetPoint("TOP", image, "BOTTOM") else
label:SetPoint("LEFT") -- image on the left
label:SetWidth(width) image:SetPoint("TOPLEFT")
height = image:GetHeight() + label:GetHeight() if image:GetHeight() > label:GetStringHeight() then
else label:SetPoint("LEFT", image, "RIGHT", 4, 0)
-- image on the left else
image:SetPoint("TOPLEFT") label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0)
label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0) end
label:SetWidth(width - imagewidth - 4) label:SetWidth(width - imagewidth - 4)
height = max(image:GetHeight(), label:GetHeight()) height = max(image:GetHeight(), label:GetStringHeight())
end end
else else
-- no image shown -- no image shown
label:SetPoint("TOPLEFT") label:SetPoint("TOPLEFT")
label:SetWidth(width) label:SetWidth(width)
height = label:GetHeight() height = label:GetStringHeight()
end end
self.resizing = true -- avoid zero-height labels, since they can used as spacers
frame:SetHeight(height) if not height or height == 0 then
frame.height = height height = 1
self.resizing = nil end
end
self.resizing = true
--[[----------------------------------------------------------------------------- frame:SetHeight(height)
Methods frame.height = height
-------------------------------------------------------------------------------]] self.resizing = nil
local methods = { end
["OnAcquire"] = function(self)
-- set the flag to stop constant size updates --[[-----------------------------------------------------------------------------
self.resizing = true Methods
-- height is set dynamically by the text and image size -------------------------------------------------------------------------------]]
self:SetWidth(200) local methods = {
self:SetText() ["OnAcquire"] = function(self)
self:SetImage(nil) -- set the flag to stop constant size updates
self:SetImageSize(16, 16) self.resizing = true
self:SetColor() -- height is set dynamically by the text and image size
self:SetFontObject() self:SetWidth(200)
self:SetText()
-- reset the flag self:SetImage(nil)
self.resizing = nil self:SetImageSize(16, 16)
-- run the update explicitly self:SetColor()
UpdateImageAnchor(self) self:SetFontObject()
end, self:SetJustifyH("LEFT")
self:SetJustifyV("TOP")
-- ["OnRelease"] = nil,
-- reset the flag
["OnWidthSet"] = function(self, width) self.resizing = nil
UpdateImageAnchor(self) -- run the update explicitly
end, UpdateImageAnchor(self)
end,
["SetText"] = function(self, text)
self.label:SetText(text) -- ["OnRelease"] = nil,
UpdateImageAnchor(self)
end, ["OnWidthSet"] = function(self, width)
UpdateImageAnchor(self)
["SetColor"] = function(self, r, g, b) end,
if not (r and g and b) then
r, g, b = 1, 1, 1 ["SetText"] = function(self, text)
end self.label:SetText(text)
self.label:SetVertexColor(r, g, b) UpdateImageAnchor(self)
end, end,
["SetImage"] = function(self, path, ...) ["SetColor"] = function(self, r, g, b)
local image = self.image if not (r and g and b) then
image:SetTexture(path) r, g, b = 1, 1, 1
end
if image:GetTexture() then self.label:SetVertexColor(r, g, b)
self.imageshown = true end,
local n = select("#", ...)
if n == 4 or n == 8 then ["SetImage"] = function(self, path, ...)
image:SetTexCoord(...) local image = self.image
else image:SetTexture(path)
image:SetTexCoord(0, 1, 0, 1)
end if image:GetTexture() then
else self.imageshown = true
self.imageshown = nil local n = select("#", ...)
end if n == 4 or n == 8 then
UpdateImageAnchor(self) image:SetTexCoord(...)
end, else
image:SetTexCoord(0, 1, 0, 1)
["SetFont"] = function(self, font, height, flags) end
self.label:SetFont(font, height, flags) else
end, self.imageshown = nil
end
["SetFontObject"] = function(self, font) UpdateImageAnchor(self)
self:SetFont((font or GameFontHighlightSmall):GetFont()) end,
end,
["SetFont"] = function(self, font, height, flags)
["SetImageSize"] = function(self, width, height) if not self.fontObject then
self.image:SetWidth(width) self.fontObject = CreateFont("AceGUI30LabelFont" .. AceGUI:GetNextWidgetNum(Type))
self.image:SetHeight(height) end
UpdateImageAnchor(self) self.fontObject:SetFont(font, height, flags)
end, self:SetFontObject(self.fontObject)
} end,
--[[----------------------------------------------------------------------------- ["SetFontObject"] = function(self, font)
Constructor self.label:SetFontObject(font or GameFontHighlightSmall)
-------------------------------------------------------------------------------]] UpdateImageAnchor(self)
local function Constructor() end,
local frame = CreateFrame("Frame", nil, UIParent)
frame:Hide() ["SetImageSize"] = function(self, width, height)
self.image:SetWidth(width)
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall") self.image:SetHeight(height)
label:SetJustifyH("LEFT") UpdateImageAnchor(self)
label:SetJustifyV("TOP") end,
local image = frame:CreateTexture(nil, "BACKGROUND") ["SetJustifyH"] = function(self, justifyH)
self.label:SetJustifyH(justifyH)
-- create widget end,
local widget = {
label = label, ["SetJustifyV"] = function(self, justifyV)
image = image, self.label:SetJustifyV(justifyV)
frame = frame, end,
type = Type }
}
for method, func in pairs(methods) do --[[-----------------------------------------------------------------------------
widget[method] = func Constructor
end -------------------------------------------------------------------------------]]
local function Constructor()
return AceGUI:RegisterAsWidget(widget) local frame = CreateFrame("Frame", nil, UIParent)
end frame:Hide()
AceGUI:RegisterWidgetType(Type, Constructor, Version) local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall")
local image = frame:CreateTexture(nil, "BACKGROUND")
-- create widget
local widget = {
label = label,
image = image,
frame = frame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,278 +1,377 @@
local Type, Version = "MultiLineEditBox", 20 local Type, Version = "MultiLineEditBox", 33
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local pairs = pairs local pairs = pairs
-- WoW APIs -- WoW APIs
local GetCursorInfo, GetSpellName, ClearCursor = GetCursorInfo, GetSpellName, ClearCursor local GetCursorInfo, ClearCursor = GetCursorInfo, ClearCursor
local CreateFrame, UIParent = CreateFrame, UIParent local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G 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 Support functions
-- GLOBALS: ACCEPT, ChatFontNormal -------------------------------------------------------------------------------]]
--[[----------------------------------------------------------------------------- if not AceGUIMultiLineEditBoxInsertLink then
Scripts -- upgradeable hook
-------------------------------------------------------------------------------]] if ChatFrameUtil and ChatFrameUtil.InsertLink then
local function OnClick(self) -- Button hooksecurefunc(ChatFrameUtil, "InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end)
self = self.obj elseif ChatEdit_InsertLink then
self.editBox:ClearFocus() hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end)
if not self:Fire("OnEnterPressed", self.editBox:GetText()) then end
self.button:Disable() end
end
end function _G.AceGUIMultiLineEditBoxInsertLink(text)
for i = 1, AceGUI:GetWidgetCount(Type) do
local function OnCursorChanged(self, _, y, _, cursorHeight) -- EditBox local editbox = _G[("MultiLineEditBox%uEdit"):format(i)]
self, y = self.obj.scrollFrame, -y if editbox and editbox:IsVisible() and editbox:HasFocus() then
local offset = self:GetVerticalScroll() editbox:Insert(text)
if y < offset then return true
self:SetVerticalScroll(y) end
else end
y = y + cursorHeight - self:GetHeight() end
if y > offset then
self:SetVerticalScroll(y)
end local function Layout(self)
end self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight)
end
if self.labelHeight == 0 then
local function OnEditFocusLost(self) -- EditBox self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23)
self:HighlightText(0, 0) else
end self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19)
end
local function OnEnter(self) -- EditBox / ScrollFrame
self = self.obj if self.disablebutton then
if not self.entered then self.scrollBar:SetPoint("BOTTOM", self.frame, "BOTTOM", 0, 21)
self.entered = true self.scrollBG:SetPoint("BOTTOMLEFT", 0, 4)
self:Fire("OnEnter") else
end self.scrollBar:SetPoint("BOTTOM", self.button, "TOP", 0, 18)
end self.scrollBG:SetPoint("BOTTOMLEFT", self.button, "TOPLEFT")
end
local function OnLeave(self) -- EditBox / ScrollFrame end
self = self.obj
if self.entered then --[[-----------------------------------------------------------------------------
self.entered = nil Scripts
self:Fire("OnLeave") -------------------------------------------------------------------------------]]
end local function OnClick(self) -- Button
end self = self.obj
self.editBox:ClearFocus()
local function OnMouseUp(self) -- ScrollFrame if not self:Fire("OnEnterPressed", self.editBox:GetText()) then
self = self.obj.editBox self.button:Disable()
self:SetFocus() end
self:SetCursorPosition(self:GetNumLetters()) end
end
local function OnCursorChanged(self, _, y, _, cursorHeight) -- EditBox
local function OnReceiveDrag(self) -- EditBox / ScrollFrame self, y = self.obj.scrollFrame, -y
local type, id, info = GetCursorInfo() local offset = self:GetVerticalScroll()
if type == "spell" then if y < offset then
info, id = GetSpellName(id, info) self:SetVerticalScroll(y)
if id and id:match("%d") then else
info = info .. "(" .. id .. ")" y = y + cursorHeight - self:GetHeight()
end if y > offset then
elseif type ~= "item" then self:SetVerticalScroll(y)
return end
end end
ClearCursor() end
self = self.obj
local editBox = self.editBox local function OnEditFocusLost(self) -- EditBox
if not editBox:HasFocus() then self:HighlightText(0, 0)
editBox:SetFocus() self.obj:Fire("OnEditFocusLost")
editBox:SetCursorPosition(editBox:GetNumLetters()) end
end
editBox:Insert(info) local function OnEnter(self) -- EditBox / ScrollFrame
self.button:Enable() self = self.obj
end if not self.entered then
self.entered = true
local function OnSizeChanged(self, width, height) -- ScrollFrame self:Fire("OnEnter")
self.obj.editBox:SetWidth(width) end
end end
local function OnTextChanged(self, userInput) -- EditBox local function OnLeave(self) -- EditBox / ScrollFrame
if userInput then self = self.obj
self = self.obj if self.entered then
self:Fire("OnTextChanged", self.editBox:GetText()) self.entered = nil
self.button:Enable() self:Fire("OnLeave")
end end
end end
local function OnTextSet(self) -- EditBox local function OnMouseUp(self) -- ScrollFrame
self:HighlightText(0, 0) self = self.obj.editBox
self:SetCursorPosition(self:GetNumLetters()) self:SetFocus()
self:SetCursorPosition(0) self:SetCursorPosition(self:GetNumLetters())
self.obj.button:Disable() end
end
local function OnReceiveDrag(self) -- EditBox / ScrollFrame
local function OnVerticalScroll(self, offset) -- ScrollFrame local type, id, info, extra = GetCursorInfo()
local editBox = self.obj.editBox if type == "spell" then
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight()) if C_Spell and C_Spell.GetSpellName then
end info = C_Spell.GetSpellName(extra)
else
--[[----------------------------------------------------------------------------- info = GetSpellInfo(id, info)
Methods end
-------------------------------------------------------------------------------]] elseif type ~= "item" then
local methods = { return
["GetText"] = function(self) end
return self.editBox:GetText() ClearCursor()
end, self = self.obj
local editBox = self.editBox
["OnAcquire"] = function(self) if not editBox:HasFocus() then
self.editBox:SetText("") editBox:SetFocus()
self:SetDisabled(false) editBox:SetCursorPosition(editBox:GetNumLetters())
self:SetWidth(200) end
self:SetNumLines() editBox:Insert(info)
self.entered = nil self.button:Enable()
end, end
["OnRelease"] = function(self) local function OnSizeChanged(self, width, height) -- ScrollFrame
self.frame:ClearAllPoints() self.obj.editBox:SetWidth(width)
self.frame:Hide() end
end,
local function OnTextChanged(self, userInput) -- EditBox
["SetDisabled"] = function(self, disabled) if userInput then
local editBox = self.editBox self = self.obj
if disabled then self:Fire("OnTextChanged", self.editBox:GetText())
editBox:ClearFocus() self.button:Enable()
editBox:EnableMouse(false) end
editBox:SetTextColor(0.5, 0.5, 0.5) end
self.label:SetTextColor(0.5, 0.5, 0.5)
self.scrollFrame:EnableMouse(false) local function OnTextSet(self) -- EditBox
self.button:Disable() self:HighlightText(0, 0)
else self:SetCursorPosition(self:GetNumLetters())
editBox:EnableMouse(true) self:SetCursorPosition(0)
editBox:SetTextColor(1, 1, 1) self.obj.button:Disable()
self.label:SetTextColor(1, 0.82, 0) end
self.scrollFrame:EnableMouse(true)
end local function OnVerticalScroll(self, offset) -- ScrollFrame
end, local editBox = self.obj.editBox
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight())
["SetLabel"] = function(self, text) end
if text and text ~= "" then
self.label:SetText(text) local function OnScrollRangeChanged(self, xrange, yrange)
if self.labelHeight ~= 10 then if yrange == 0 then
self.labelHeight = 10 self.obj.editBox:SetHitRectInsets(0, 0, 0, 0)
self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19) else
self:SetHeight(self.frame.height + 10) OnVerticalScroll(self, self:GetVerticalScroll())
self.label:Show() end
end end
elseif self.labelHeight ~= 0 then
self.labelHeight = 0 local function OnShowFocus(frame)
self.label:Hide() frame.obj.editBox:SetFocus()
self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23) frame:SetScript("OnShow", nil)
self:SetHeight(self.frame.height - 10) end
end
end, local function OnEditFocusGained(frame)
AceGUI:SetFocus(frame.obj)
["SetNumLines"] = function(self, value) frame.obj:Fire("OnEditFocusGained")
if not value or value < 4 then end
value = 4
end --[[-----------------------------------------------------------------------------
self:SetHeight(value * 14 + 41 + self.labelHeight) Methods
end, -------------------------------------------------------------------------------]]
local methods = {
["SetText"] = function(self, text) ["OnAcquire"] = function(self)
self.editBox:SetText(text) self.editBox:SetText("")
end self:SetDisabled(false)
} self:SetWidth(200)
self:DisableButton(false)
--[[----------------------------------------------------------------------------- self:SetNumLines()
Constructor self.entered = nil
-------------------------------------------------------------------------------]] self:SetMaxLetters(0)
local backdrop = { end,
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16, ["OnRelease"] = function(self)
insets = { left = 4, right = 3, top = 4, bottom = 3 } self:ClearFocus()
} end,
local function Constructor() ["SetDisabled"] = function(self, disabled)
local frame = CreateFrame("Frame", nil, UIParent) local editBox = self.editBox
frame:Hide() if disabled then
editBox:ClearFocus()
local widgetNum = AceGUI:GetNextWidgetNum(Type) editBox:EnableMouse(false)
editBox:SetTextColor(0.5, 0.5, 0.5)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") self.label:SetTextColor(0.5, 0.5, 0.5)
label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, -4) self.scrollFrame:EnableMouse(false)
label:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -4) self.button:Disable()
label:SetJustifyH("LEFT") else
label:SetText(ACCEPT) editBox:EnableMouse(true)
label:SetHeight(10) editBox:SetTextColor(1, 1, 1)
self.label:SetTextColor(1, 0.82, 0)
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate2") self.scrollFrame:EnableMouse(true)
button:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, 4) end
button:SetHeight(22) end,
button:SetWidth(label:GetStringWidth() + 24)
button:SetText(ACCEPT) ["SetLabel"] = function(self, text)
button:SetScript("OnClick", OnClick) if text and text ~= "" then
button:Disable() self.label:SetText(text)
if self.labelHeight ~= 10 then
local text = button:GetFontString() self.labelHeight = 10
text:ClearAllPoints() self.label:Show()
text:SetPoint("TOPLEFT", button, "TOPLEFT", 5, -5) end
text:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -5, 1) elseif self.labelHeight ~= 0 then
text:SetJustifyV("MIDDLE") self.labelHeight = 0
self.label:Hide()
local scrollBG = CreateFrame("Frame", nil, frame) end
scrollBG:SetBackdrop(backdrop) Layout(self)
scrollBG:SetBackdropColor(0, 0, 0) end,
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
["SetNumLines"] = function(self, value)
local scrollFrame = CreateFrame("ScrollFrame", ("%s%dScrollFrame"):format(Type, widgetNum), frame, "UIPanelScrollFrameTemplate") if not value or value < 4 then
value = 4
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"] end
scrollBar:ClearAllPoints() self.numlines = value
scrollBar:SetPoint("TOP", label, "BOTTOM", 0, -19) Layout(self)
scrollBar:SetPoint("BOTTOM", button, "TOP", 0, 18) end,
scrollBar:SetPoint("RIGHT", frame, "RIGHT")
["SetText"] = function(self, text)
scrollBG:SetPoint("TOPRIGHT", scrollBar, "TOPLEFT", 0, 19) self.editBox:SetText(text)
scrollBG:SetPoint("BOTTOMLEFT", button, "TOPLEFT") end,
scrollFrame:SetPoint("TOPLEFT", scrollBG, "TOPLEFT", 5, -6) ["GetText"] = function(self)
scrollFrame:SetPoint("BOTTOMRIGHT", scrollBG, "BOTTOMRIGHT", -4, 4) return self.editBox:GetText()
scrollFrame:SetScript("OnEnter", OnEnter) end,
scrollFrame:SetScript("OnLeave", OnLeave)
scrollFrame:SetScript("OnMouseUp", OnMouseUp) ["SetMaxLetters"] = function (self, num)
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag) self.editBox:SetMaxLetters(num or 0)
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged) end,
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
["DisableButton"] = function(self, disabled)
local editBox = CreateFrame("EditBox", nil, scrollFrame) self.disablebutton = disabled
editBox:SetAllPoints() if disabled then
editBox:SetFontObject(ChatFontNormal) self.button:Hide()
editBox:SetMultiLine(true) else
editBox:EnableMouse(true) self.button:Show()
editBox:SetAutoFocus(false) end
editBox:SetCountInvisibleLetters(false) Layout(self)
editBox:SetScript("OnCursorChanged", OnCursorChanged) end,
editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
editBox:SetScript("OnEnter", OnEnter) ["ClearFocus"] = function(self)
editBox:SetScript("OnEscapePressed", editBox.ClearFocus) self.editBox:ClearFocus()
editBox:SetScript("OnLeave", OnLeave) self.frame:SetScript("OnShow", nil)
editBox:SetScript("OnMouseDown", OnReceiveDrag) end,
editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
editBox:SetScript("OnTextChanged", OnTextChanged) ["SetFocus"] = function(self)
editBox:SetScript("OnTextSet", OnTextSet) self.editBox:SetFocus()
if not self.frame:IsShown() then
scrollFrame:SetScrollChild(editBox) self.frame:SetScript("OnShow", OnShowFocus)
end
local widget = { end,
button = button,
editBox = editBox, ["HighlightText"] = function(self, from, to)
frame = frame, self.editBox:HighlightText(from, to)
label = label, end,
labelHeight = 10,
scrollBar = scrollBar, ["GetCursorPosition"] = function(self)
scrollFrame = scrollFrame, return self.editBox:GetCursorPosition()
type = Type end,
}
for method, func in pairs(methods) do ["SetCursorPosition"] = function(self, ...)
widget[method] = func return self.editBox:SetCursorPosition(...)
end end,
button.obj, editBox.obj, scrollFrame.obj = widget, widget, widget }
AceGUI:RegisterAsWidget(widget) --[[-----------------------------------------------------------------------------
return widget Constructor
end -------------------------------------------------------------------------------]]
local backdrop = {
AceGUI:RegisterWidgetType(Type, Constructor, Version) bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
insets = { left = 4, right = 3, top = 4, bottom = 3 }
}
local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent)
frame:Hide()
local widgetNum = AceGUI:GetNextWidgetNum(Type)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, -4)
label:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -4)
label:SetJustifyH("LEFT")
label:SetText(ACCEPT)
label:SetHeight(10)
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)
button:SetScript("OnClick", OnClick)
button:Disable()
local text = button:GetFontString()
text:ClearAllPoints()
text:SetPoint("TOPLEFT", button, "TOPLEFT", 5, -5)
text:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -5, 1)
text:SetJustifyV("MIDDLE")
local scrollBG = CreateFrame("Frame", nil, frame, "BackdropTemplate")
scrollBG:SetBackdrop(backdrop)
scrollBG:SetBackdropColor(0, 0, 0)
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
local scrollFrame = CreateFrame("ScrollFrame", ("%s%dScrollFrame"):format(Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
scrollBar:ClearAllPoints()
scrollBar:SetPoint("TOP", label, "BOTTOM", 0, -19)
scrollBar:SetPoint("BOTTOM", button, "TOP", 0, 18)
scrollBar:SetPoint("RIGHT", frame, "RIGHT")
scrollBG:SetPoint("TOPRIGHT", scrollBar, "TOPLEFT", 0, 19)
scrollBG:SetPoint("BOTTOMLEFT", button, "TOPLEFT")
scrollFrame:SetPoint("TOPLEFT", scrollBG, "TOPLEFT", 5, -6)
scrollFrame:SetPoint("BOTTOMRIGHT", scrollBG, "BOTTOMRIGHT", -4, 4)
scrollFrame:SetScript("OnEnter", OnEnter)
scrollFrame:SetScript("OnLeave", OnLeave)
scrollFrame:SetScript("OnMouseUp", OnMouseUp)
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
scrollFrame:HookScript("OnScrollRangeChanged", OnScrollRangeChanged)
local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame)
editBox:SetAllPoints()
editBox:SetFontObject(ChatFontNormal)
editBox:SetMultiLine(true)
editBox:EnableMouse(true)
editBox:SetAutoFocus(false)
editBox:SetCountInvisibleLetters(false)
editBox:SetScript("OnCursorChanged", OnCursorChanged)
editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
editBox:SetScript("OnEnter", OnEnter)
editBox:SetScript("OnEscapePressed", editBox.ClearFocus)
editBox:SetScript("OnLeave", OnLeave)
editBox:SetScript("OnMouseDown", OnReceiveDrag)
editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
editBox:SetScript("OnTextChanged", OnTextChanged)
editBox:SetScript("OnTextSet", OnTextSet)
editBox:SetScript("OnEditFocusGained", OnEditFocusGained)
scrollFrame:SetScrollChild(editBox)
local widget = {
button = button,
editBox = editBox,
frame = frame,
label = label,
labelHeight = 10,
numlines = 4,
scrollBar = scrollBar,
scrollBG = scrollBG,
scrollFrame = scrollFrame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
button.obj, editBox.obj, scrollFrame.obj = widget, widget, widget
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -1,281 +1,281 @@
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
Slider Widget Slider Widget
Graphical Slider, like, for Range values. 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) local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs -- Lua APIs
local min, max, floor = math.min, math.max, math.floor local min, max, floor = math.min, math.max, math.floor
local tonumber = tonumber local tonumber, pairs = tonumber, pairs
-- WoW APIs -- WoW APIs
local PlaySound = PlaySound local PlaySound = PlaySound
local CreateFrame, UIParent = CreateFrame, UIParent 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 Support functions
-- GLOBALS: GameFontHighlightSmall -------------------------------------------------------------------------------]]
local function UpdateText(self)
--[[----------------------------------------------------------------------------- local value = self.value or 0
Support functions if self.ispercent then
-------------------------------------------------------------------------------]] self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10))
local function UpdateText(self) else
local value = self.value or 0 self.editbox:SetText(floor(value * 100 + 0.5) / 100)
if self.ispercent then end
self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10)) end
else
self.editbox:SetText(floor(value * 100 + 0.5) / 100) local function UpdateLabels(self)
end local min_value, max_value = (self.min or 0), (self.max or 100)
end if self.ispercent then
self.lowtext:SetFormattedText("%s%%", (min_value * 100))
local function UpdateLabels(self) self.hightext:SetFormattedText("%s%%", (max_value * 100))
local min, max = (self.min or 0), (self.max or 100) else
if self.ispercent then self.lowtext:SetText(min_value)
self.lowtext:SetFormattedText("%s%%", (min * 100)) self.hightext:SetText(max_value)
self.hightext:SetFormattedText("%s%%", (max * 100)) end
else end
self.lowtext:SetText(min)
self.hightext:SetText(max) --[[-----------------------------------------------------------------------------
end Scripts
end -------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
--[[----------------------------------------------------------------------------- frame.obj:Fire("OnEnter")
Scripts end
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame) local function Control_OnLeave(frame)
frame.obj:Fire("OnEnter") frame.obj:Fire("OnLeave")
end end
local function Control_OnLeave(frame) local function Frame_OnMouseDown(frame)
frame.obj:Fire("OnLeave") frame.obj.slider:EnableMouseWheel(true)
end AceGUI:ClearFocus()
end
local function Frame_OnMouseDown(frame)
frame.obj.slider:EnableMouseWheel(true) local function Slider_OnValueChanged(frame, newvalue)
AceGUI:ClearFocus() local self = frame.obj
end if not frame.setup then
if self.step and self.step > 0 then
local function Slider_OnValueChanged(frame) local min_value = self.min or 0
local self = frame.obj newvalue = floor((newvalue - min_value) / self.step + 0.5) * self.step + min_value
if not frame.setup then end
local newvalue = frame:GetValue() if newvalue ~= self.value and not self.disabled then
if newvalue ~= self.value and not self.disabled then self.value = newvalue
self.value = newvalue self:Fire("OnValueChanged", newvalue)
self:Fire("OnValueChanged", newvalue) end
end if self.value then
if self.value then UpdateText(self)
UpdateText(self) end
end end
end end
end
local function Slider_OnMouseUp(frame)
local function Slider_OnMouseUp(frame) local self = frame.obj
local self = frame.obj self:Fire("OnMouseUp", self.value)
self:Fire("OnMouseUp", self.value) end
end
local function Slider_OnMouseWheel(frame, v)
local function Slider_OnMouseWheel(frame, v) local self = frame.obj
local self = frame.obj if not self.disabled then
if not self.disabled then local value = self.value
local value = self.value if v > 0 then
if v > 0 then value = min(value + (self.step or 1), self.max)
value = min(value + (self.step or 1), self.max) else
else value = max(value - (self.step or 1), self.min)
value = max(value - (self.step or 1), self.min) end
end self.slider:SetValue(value)
self.slider:SetValue(value) end
end end
end
local function EditBox_OnEscapePressed(frame)
local function EditBox_OnEscapePressed(frame) frame:ClearFocus()
frame:ClearFocus() end
end
local function EditBox_OnEnterPressed(frame)
local function EditBox_OnEnterPressed(frame) local self = frame.obj
local self = frame.obj local value = frame:GetText()
local value = frame:GetText() if self.ispercent then
if self.ispercent then value = value:gsub('%%', '')
value = value:gsub('%%', '') value = tonumber(value) / 100
value = tonumber(value) / 100 else
else value = tonumber(value)
value = tonumber(value) end
end
if value then
if value then PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
PlaySound("igMainMenuOptionCheckBoxOn") self.slider:SetValue(value)
self.slider:SetValue(value) self:Fire("OnMouseUp", value)
self:Fire("OnMouseUp", value) end
end end
end
local function EditBox_OnEnter(frame)
local function EditBox_OnEnter(frame) frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) end
end
local function EditBox_OnLeave(frame)
local function EditBox_OnLeave(frame) frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8) end
end
--[[-----------------------------------------------------------------------------
--[[----------------------------------------------------------------------------- Methods
Methods -------------------------------------------------------------------------------]]
-------------------------------------------------------------------------------]] local methods = {
local methods = { ["OnAcquire"] = function(self)
["OnAcquire"] = function(self) self:SetWidth(200)
self:SetWidth(200) self:SetHeight(44)
self:SetHeight(44) self:SetDisabled(false)
self:SetDisabled(false) self:SetIsPercent(nil)
self:SetIsPercent(nil) self:SetSliderValues(0,100,1)
self:SetSliderValues(0,100,1) self:SetValue(0)
self:SetValue(0) self.slider:EnableMouseWheel(false)
self.slider:EnableMouseWheel(false) end,
end,
-- ["OnRelease"] = nil,
-- ["OnRelease"] = nil,
["SetDisabled"] = function(self, disabled)
["SetDisabled"] = function(self, disabled) self.disabled = disabled
self.disabled = disabled if disabled then
if disabled then self.slider:EnableMouse(false)
self.slider:EnableMouse(false) self.label:SetTextColor(.5, .5, .5)
self.label:SetTextColor(.5, .5, .5) self.hightext:SetTextColor(.5, .5, .5)
self.hightext:SetTextColor(.5, .5, .5) self.lowtext:SetTextColor(.5, .5, .5)
self.lowtext:SetTextColor(.5, .5, .5) --self.valuetext:SetTextColor(.5, .5, .5)
--self.valuetext:SetTextColor(.5, .5, .5) self.editbox:SetTextColor(.5, .5, .5)
self.editbox:SetTextColor(.5, .5, .5) self.editbox:EnableMouse(false)
self.editbox:EnableMouse(false) self.editbox:ClearFocus()
self.editbox:ClearFocus() else
else self.slider:EnableMouse(true)
self.slider:EnableMouse(true) self.label:SetTextColor(1, .82, 0)
self.label:SetTextColor(1, .82, 0) self.hightext:SetTextColor(1, 1, 1)
self.hightext:SetTextColor(1, 1, 1) self.lowtext:SetTextColor(1, 1, 1)
self.lowtext:SetTextColor(1, 1, 1) --self.valuetext:SetTextColor(1, 1, 1)
--self.valuetext:SetTextColor(1, 1, 1) self.editbox:SetTextColor(1, 1, 1)
self.editbox:SetTextColor(1, 1, 1) self.editbox:EnableMouse(true)
self.editbox:EnableMouse(true) end
end end,
end,
["SetValue"] = function(self, value)
["SetValue"] = function(self, value) self.slider.setup = true
self.slider.setup = true self.slider:SetValue(value)
self.slider:SetValue(value) self.value = value
self.value = value UpdateText(self)
UpdateText(self) self.slider.setup = nil
self.slider.setup = nil end,
end,
["GetValue"] = function(self)
["GetValue"] = function(self) return self.value
return self.value end,
end,
["SetLabel"] = function(self, text)
["SetLabel"] = function(self, text) self.label:SetText(text)
self.label:SetText(text) end,
end,
["SetSliderValues"] = function(self, min_value, max_value, step)
["SetSliderValues"] = function(self, min, max, step) local frame = self.slider
local frame = self.slider frame.setup = true
frame.setup = true self.min = min_value
self.min = min self.max = max_value
self.max = max self.step = step
self.step = step frame:SetMinMaxValues(min_value or 0,max_value or 100)
frame:SetMinMaxValues(min or 0,max or 100) UpdateLabels(self)
UpdateLabels(self) frame:SetValueStep(step or 1)
frame:SetValueStep(step or 1) if self.value then
if self.value then frame:SetValue(self.value)
frame:SetValue(self.value) end
end frame.setup = nil
frame.setup = nil end,
end,
["SetIsPercent"] = function(self, value)
["SetIsPercent"] = function(self, value) self.ispercent = value
self.ispercent = value UpdateLabels(self)
UpdateLabels(self) UpdateText(self)
UpdateText(self) end
end }
}
--[[-----------------------------------------------------------------------------
--[[----------------------------------------------------------------------------- Constructor
Constructor -------------------------------------------------------------------------------]]
-------------------------------------------------------------------------------]] local SliderBackdrop = {
local SliderBackdrop = { bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
bgFile = "Interface\\Buttons\\UI-SliderBar-Background", edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", tile = true, tileSize = 8, edgeSize = 8,
tile = true, tileSize = 8, edgeSize = 8, insets = { left = 3, right = 3, top = 6, bottom = 6 }
insets = { left = 3, right = 3, top = 6, bottom = 6 } }
}
local ManualBackdrop = {
local ManualBackdrop = { bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, edgeSize = 1, tileSize = 5,
tile = true, edgeSize = 1, tileSize = 5, }
}
local function Constructor()
local function Constructor() local frame = CreateFrame("Frame", nil, UIParent)
local frame = CreateFrame("Frame", nil, UIParent)
frame:EnableMouse(true)
frame:EnableMouse(true) frame:SetScript("OnMouseDown", Frame_OnMouseDown)
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") label:SetPoint("TOPLEFT")
label:SetPoint("TOPLEFT") label:SetPoint("TOPRIGHT")
label:SetPoint("TOPRIGHT") label:SetJustifyH("CENTER")
label:SetJustifyH("CENTER") label:SetHeight(15)
label:SetHeight(15)
local slider = CreateFrame("Slider", nil, frame, "BackdropTemplate")
local slider = CreateFrame("Slider", nil, frame) slider:SetOrientation("HORIZONTAL")
slider:SetOrientation("HORIZONTAL") slider:SetHeight(15)
slider:SetHeight(15) slider:SetHitRectInsets(0, 0, -10, 0)
slider:SetHitRectInsets(0, 0, -10, 0) slider:SetBackdrop(SliderBackdrop)
slider:SetBackdrop(SliderBackdrop) slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal")
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") slider:SetPoint("TOP", label, "BOTTOM")
slider:SetPoint("TOP", label, "BOTTOM") slider:SetPoint("LEFT", 3, 0)
slider:SetPoint("LEFT", 3, 0) slider:SetPoint("RIGHT", -3, 0)
slider:SetPoint("RIGHT", -3, 0) slider:SetValue(0)
slider:SetValue(0) slider:SetScript("OnValueChanged",Slider_OnValueChanged)
slider:SetScript("OnValueChanged",Slider_OnValueChanged) slider:SetScript("OnEnter", Control_OnEnter)
slider:SetScript("OnEnter", Control_OnEnter) slider:SetScript("OnLeave", Control_OnLeave)
slider:SetScript("OnLeave", Control_OnLeave) slider:SetScript("OnMouseUp", Slider_OnMouseUp)
slider:SetScript("OnMouseUp", Slider_OnMouseUp) slider:SetScript("OnMouseWheel", Slider_OnMouseWheel)
slider:SetScript("OnMouseWheel", Slider_OnMouseWheel)
local lowtext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
local lowtext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") lowtext:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", 2, 3)
lowtext:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", 2, 3)
local hightext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
local hightext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") hightext:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", -2, 3)
hightext:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", -2, 3)
local editbox = CreateFrame("EditBox", nil, frame, "BackdropTemplate")
local editbox = CreateFrame("EditBox", nil, frame) editbox:SetAutoFocus(false)
editbox:SetAutoFocus(false) editbox:SetFontObject(GameFontHighlightSmall)
editbox:SetFontObject(GameFontHighlightSmall) editbox:SetPoint("TOP", slider, "BOTTOM")
editbox:SetPoint("TOP", slider, "BOTTOM") editbox:SetHeight(14)
editbox:SetHeight(14) editbox:SetWidth(70)
editbox:SetWidth(70) editbox:SetJustifyH("CENTER")
editbox:SetJustifyH("CENTER") editbox:EnableMouse(true)
editbox:EnableMouse(true) editbox:SetBackdrop(ManualBackdrop)
editbox:SetBackdrop(ManualBackdrop) editbox:SetBackdropColor(0, 0, 0, 0.5)
editbox:SetBackdropColor(0, 0, 0, 0.5) editbox:SetBackdropBorderColor(0.3, 0.3, 0.30, 0.80)
editbox:SetBackdropBorderColor(0.3, 0.3, 0.30, 0.80) editbox:SetScript("OnEnter", EditBox_OnEnter)
editbox:SetScript("OnEnter", EditBox_OnEnter) editbox:SetScript("OnLeave", EditBox_OnLeave)
editbox:SetScript("OnLeave", EditBox_OnLeave) editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed) editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
local widget = {
local widget = { label = label,
label = label, slider = slider,
slider = slider, lowtext = lowtext,
lowtext = lowtext, hightext = hightext,
hightext = hightext, editbox = editbox,
editbox = editbox, alignoffset = 25,
alignoffset = 25, frame = frame,
frame = frame, type = Type
type = Type }
} for method, func in pairs(methods) do
for method, func in pairs(methods) do widget[method] = func
widget[method] = func end
end slider.obj, editbox.obj = widget, widget
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) return AceGUI:RegisterAsWidget(widget)
end end
AceGUI:RegisterWidgetType(Type,Constructor,Version) AceGUI:RegisterWidgetType(Type,Constructor,Version)
+1 -1
View File
@@ -2,7 +2,7 @@
## Title: Shadowed Unit Frames ## Title: Shadowed Unit Frames
## Notes: An apple a day keeps the raptor away, or so they say ## Notes: An apple a day keeps the raptor away, or so they say
## Author: Shadowed ## Author: Shadowed
## Version: v3.3.0 ## Version: v3.3.0-coa.2
## SavedVariables: ShadowedUFDB ## SavedVariables: ShadowedUFDB
## OptionalDeps: Ace3, LibSharedMedia-3.0, LibHealComm-4.0, AceGUI-3.0-SharedMediaWidgets ## OptionalDeps: Ace3, LibSharedMedia-3.0, LibHealComm-4.0, AceGUI-3.0-SharedMediaWidgets
## X-Curse-Packaged-Version: v3.2.12 ## X-Curse-Packaged-Version: v3.2.12
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ <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"> ..\FrameXML\UI.xsd">
<Script file="AceDB-3.0.lua"/> <Script file="AceDB-3.0.lua"/>
</Ui> </Ui>
@@ -1,239 +1,202 @@
--[[ $Id: CallbackHandler-1.0.lua 9 2009-09-17 10:38:10Z mikk $ ]] --[[ $Id: CallbackHandler-1.0.lua 25 2022-12-12 15:02:36Z nevcairiel $ ]]
local MAJOR, MINOR = "CallbackHandler-1.0", 5 local MAJOR, MINOR = "CallbackHandler-1.0", 8
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR) local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
if not CallbackHandler then return end -- No upgrade needed if not CallbackHandler then return end -- No upgrade needed
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end} local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
local type = type -- Lua APIs
local pcall = pcall local securecallfunction, error = securecallfunction, error
local pairs = pairs local setmetatable, rawget = setmetatable, rawget
local assert = assert local next, select, pairs, type, tostring = next, select, pairs, type, tostring
local concat = table.concat
local loadstring = loadstring
local next = next local function Dispatch(handlers, ...)
local select = select local index, method = next(handlers)
local type = type if not method then return end
local xpcall = xpcall repeat
securecallfunction(method, ...)
local function errorhandler(err) index, method = next(handlers, index)
return geterrorhandler()(err) until not method
end end
local function CreateDispatcher(argCount) --------------------------------------------------------------------------
local code = [[ -- CallbackHandler:New
local next, xpcall, eh = ... --
-- target - target object to embed public APIs in
local method, ARGS -- RegisterName - name of the callback registration API, default "RegisterCallback"
local function call() method(ARGS) 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.
local function dispatch(handlers, ...)
local index function CallbackHandler.New(_self, target, RegisterName, UnregisterName, UnregisterAllName)
index, method = next(handlers)
if not method then return end RegisterName = RegisterName or "RegisterCallback"
local OLD_ARGS = ARGS UnregisterName = UnregisterName or "UnregisterCallback"
ARGS = ... if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
repeat UnregisterAllName = "UnregisterAllCallbacks"
xpcall(call, eh) end
index, method = next(handlers, index)
until not method -- we declare all objects and exported APIs inside this closure to quickly gain access
ARGS = OLD_ARGS -- to e.g. function names, the "target" parameter, etc
end
return dispatch -- Create the registry object
]] local events = setmetatable({}, meta)
local registry = { recurse=0, events=events }
local ARGS, OLD_ARGS = {}, {}
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end -- registry:Fire() - fires the given event/message into the registry
code = code:gsub("OLD_ARGS", concat(OLD_ARGS, ", ")):gsub("ARGS", concat(ARGS, ", ")) function registry:Fire(eventname, ...)
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler) if not rawget(events, eventname) or not next(events[eventname]) then return end
end local oldrecurse = registry.recurse
registry.recurse = oldrecurse + 1
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
local dispatcher = CreateDispatcher(argCount) Dispatch(events[eventname], eventname, ...)
rawset(self, argCount, dispatcher)
return dispatcher registry.recurse = oldrecurse
end})
if registry.insertQueue and oldrecurse==0 then
-------------------------------------------------------------------------- -- Something in one of our callbacks wanted to register more callbacks; they got queued
-- CallbackHandler:New 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.
-- target - target object to embed public APIs in for object,func in pairs(callbacks) do
-- RegisterName - name of the callback registration API, default "RegisterCallback" events[event][object] = func
-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback" -- fire OnUsed callback?
-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API. if first and registry.OnUsed then
registry.OnUsed(registry, target, event)
function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, OnUsed, OnUnused) first = nil
-- TODO: Remove this after beta has gone out end
assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused") end
end
RegisterName = RegisterName or "RegisterCallback" registry.insertQueue = nil
UnregisterName = UnregisterName or "UnregisterCallback" end
if UnregisterAllName==nil then -- false is used to indicate "don't want this method" end
UnregisterAllName = "UnregisterAllCallbacks"
end -- Registration of a callback, handles:
-- self["method"], leads to self["method"](self, ...)
-- we declare all objects and exported APIs inside this closure to quickly gain access -- self with function ref, leads to functionref(...)
-- to e.g. function names, the "target" parameter, etc -- "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]])
-- Create the registry object if type(eventname) ~= "string" then
local events = setmetatable({}, meta) error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
local registry = { recurse=0, events=events } end
-- registry:Fire() - fires the given event/message into the registry method = method or eventname
function registry:Fire(eventname, ...)
if not rawget(events, eventname) or not next(events[eventname]) then return end 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.
local oldrecurse = registry.recurse
registry.recurse = oldrecurse + 1 if type(method) ~= "string" and type(method) ~= "function" then
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...) end
registry.recurse = oldrecurse local regfunc
if registry.insertQueue and oldrecurse==0 then if type(method) == "string" then
-- Something in one of our callbacks wanted to register more callbacks; they got queued -- self["method"] calling style
for eventname,callbacks in pairs(registry.insertQueue) do if type(self) ~= "table" then
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. error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
for self,func in pairs(callbacks) do elseif self==target then
events[eventname][self] = func error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
-- fire OnUsed callback? elseif type(self[method]) ~= "function" then
if first and registry.OnUsed then error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
registry.OnUsed(registry, target, eventname) end
first = nil
end if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
end local arg=select(1,...)
end regfunc = function(...) self[method](self,arg,...) end
registry.insertQueue = nil else
end regfunc = function(...) self[method](self,...) end
end end
else
-- Registration of a callback, handles: -- function ref with self=object or self="addonId" or self=thread
-- self["method"], leads to self["method"](self, ...) if type(self)~="table" and type(self)~="string" and type(self)~="thread" then
-- self with function ref, leads to functionref(...) error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2)
-- "addonId" (instead of self) with function ref, leads to functionref(...) end
-- 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 select("#",...)>=1 then -- this is not the same as testing for arg==nil!
if type(eventname) ~= "string" then local arg=select(1,...)
error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2) regfunc = function(...) method(arg,...) end
end else
regfunc = method
method = method or eventname end
end
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 if events[eventname][self] or registry.recurse<1 then
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2) -- if registry.recurse<1 then
end -- we're overwriting an existing entry, or not currently recursing. just set it.
events[eventname][self] = regfunc
local regfunc -- fire OnUsed callback?
if registry.OnUsed and first then
if type(method) == "string" then registry.OnUsed(registry, target, eventname)
-- self["method"] calling style end
if type(self) ~= "table" then else
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2) -- we're currently processing a callback in this registry, so delay the registration of this new entry!
elseif self==target then -- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2) registry.insertQueue = registry.insertQueue or setmetatable({},meta)
elseif type(self[method]) ~= "function" then registry.insertQueue[eventname][self] = regfunc
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2) end
end end
if select("#",...)>=1 then -- this is not the same as testing for arg==nil! -- Unregister a callback
local arg=select(1,...) target[UnregisterName] = function(self, eventname)
regfunc = function(...) self[method](self,arg,...) end if not self or self==target then
else error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
regfunc = function(...) self[method](self,...) end end
end if type(eventname) ~= "string" then
else error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
-- function ref with self=object or self="addonId" end
if type(self)~="table" and type(self)~="string" then if rawget(events, eventname) and events[eventname][self] then
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2) events[eventname][self] = nil
end -- Fire OnUnused callback?
if registry.OnUnused and not next(events[eventname]) then
if select("#",...)>=1 then -- this is not the same as testing for arg==nil! registry.OnUnused(registry, target, eventname)
local arg=select(1,...) end
regfunc = function(...) method(arg,...) end end
else if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
regfunc = method registry.insertQueue[eventname][self] = nil
end end
end end
-- OPTIONAL: Unregister all callbacks for given selfs/addonIds
if events[eventname][self] or registry.recurse<1 then if UnregisterAllName then
-- if registry.recurse<1 then target[UnregisterAllName] = function(...)
-- we're overwriting an existing entry, or not currently recursing. just set it. if select("#",...)<1 then
events[eventname][self] = regfunc error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
-- fire OnUsed callback? end
if registry.OnUsed and first then if select("#",...)==1 and ...==target then
registry.OnUsed(registry, target, eventname) error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
end 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 for i=1,select("#",...) do
registry.insertQueue = registry.insertQueue or setmetatable({},meta) local self = select(i,...)
registry.insertQueue[eventname][self] = regfunc if registry.insertQueue then
end for eventname, callbacks in pairs(registry.insertQueue) do
end if callbacks[self] then
callbacks[self] = nil
-- Unregister a callback end
target[UnregisterName] = function(self, eventname) end
if not self or self==target then end
error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2) for eventname, callbacks in pairs(events) do
end if callbacks[self] then
if type(eventname) ~= "string" then callbacks[self] = nil
error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2) -- Fire OnUnused callback?
end if registry.OnUnused and not next(callbacks) then
if rawget(events, eventname) and events[eventname][self] then registry.OnUnused(registry, target, eventname)
events[eventname][self] = nil end
-- Fire OnUnused callback? end
if registry.OnUnused and not next(events[eventname]) then end
registry.OnUnused(registry, target, eventname) end
end end
end end
if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
registry.insertQueue[eventname][self] = nil return registry
end end
end
-- OPTIONAL: Unregister all callbacks for given selfs/addonIds -- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
if UnregisterAllName then -- try to upgrade old implicit embeds since the system is selfcontained and
target[UnregisterAllName] = function(...) -- relies on closures to work.
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.
@@ -1,4 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ <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"> ..\FrameXML\UI.xsd">
<Script file="CallbackHandler-1.0.lua"/> <Script file="CallbackHandler-1.0.lua"/>
</Ui> </Ui>
@@ -1,30 +1,30 @@
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info -- 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 -- 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_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR] local LibStub = _G[LIBSTUB_MAJOR]
if not LibStub or LibStub.minor < LIBSTUB_MINOR then if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} } LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub _G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR LibStub.minor = LIBSTUB_MINOR
function LibStub:NewLibrary(major, minor) function LibStub:NewLibrary(major, minor)
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") 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] local oldminor = self.minors[major]
if oldminor and oldminor >= minor then return nil end if oldminor and oldminor >= minor then return nil end
self.minors[major], self.libs[major] = minor, self.libs[major] or {} self.minors[major], self.libs[major] = minor, self.libs[major] or {}
return self.libs[major], oldminor return self.libs[major], oldminor
end end
function LibStub:GetLibrary(major, silent) function LibStub:GetLibrary(major, silent)
if not self.libs[major] and not silent then if not self.libs[major] and not silent then
error(("Cannot find a library instance of %q."):format(tostring(major)), 2) error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
end end
return self.libs[major], self.minors[major] return self.libs[major], self.minors[major]
end end
function LibStub:IterateLibraries() return pairs(self.libs) end function LibStub:IterateLibraries() return pairs(self.libs) end
setmetatable(LibStub, { __call = LibStub.GetLibrary }) setmetatable(LibStub, { __call = LibStub.GetLibrary })
end end
@@ -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.
@@ -1,227 +1,259 @@
--[[ --[[
Name: LibSharedMedia-3.0 Name: LibSharedMedia-3.0
Revision: $Revision: 53 $ Revision: $Revision: 62 $
Author: Elkano (elkano@gmx.de) Author: Elkano (elkano@gmx.de)
Inspired By: SurfaceLib by Haste/Otravi (troeks@gmail.com) Inspired By: SurfaceLib by Haste/Otravi (troeks@gmail.com)
Website: http://www.wowace.com/projects/libsharedmedia-3-0/ Website: http://www.wowace.com/projects/libsharedmedia-3-0/
Description: Shared handling of media data (fonts, sounds, textures, ...) between addons. Description: Shared handling of media data (fonts, sounds, textures, ...) between addons.
Dependencies: LibStub, CallbackHandler-1.0 Dependencies: LibStub, CallbackHandler-1.0
License: LGPL v2.1 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) local lib = LibStub:NewLibrary(MAJOR, MINOR)
if not lib then return end if not lib then return end
local _G = getfenv(0) local _G = getfenv(0)
local pairs = _G.pairs local pairs = _G.pairs
local type = _G.type local type = _G.type
local band = _G.bit.band local band = _G.bit.band
local table_sort = _G.table.sort
local table_insert = _G.table.insert
local table_sort = _G.table.sort local locale = GetLocale()
local locale_is_western
local locale = GetLocale() local LOCALE_MASK = 0
local locale_is_western lib.LOCALE_BIT_koKR = 1
local LOCALE_MASK = 0 lib.LOCALE_BIT_ruRU = 2
lib.LOCALE_BIT_koKR = 1 lib.LOCALE_BIT_zhCN = 4
lib.LOCALE_BIT_ruRU = 2 lib.LOCALE_BIT_zhTW = 8
lib.LOCALE_BIT_zhCN = 4 lib.LOCALE_BIT_western = 128
lib.LOCALE_BIT_zhTW = 8
lib.LOCALE_BIT_western = 128 local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0") lib.callbacks = lib.callbacks or CallbackHandler:New(lib)
lib.callbacks = lib.callbacks or CallbackHandler:New(lib) lib.DefaultMedia = lib.DefaultMedia or {}
lib.MediaList = lib.MediaList or {}
lib.DefaultMedia = lib.DefaultMedia or {} lib.MediaTable = lib.MediaTable or {}
lib.MediaList = lib.MediaList or {} lib.MediaType = lib.MediaType or {}
lib.MediaTable = lib.MediaTable or {} lib.OverrideMedia = lib.OverrideMedia or {}
lib.MediaType = lib.MediaType or {}
lib.OverrideMedia = lib.OverrideMedia or {} local defaultMedia = lib.DefaultMedia
local mediaList = lib.MediaList
local defaultMedia = lib.DefaultMedia local mediaTable = lib.MediaTable
local mediaList = lib.MediaList local overrideMedia = lib.OverrideMedia
local mediaTable = lib.MediaTable
local overrideMedia = lib.OverrideMedia
-- create mediatype constants
lib.MediaType.BACKGROUND = "background" -- background textures
-- create mediatype constants lib.MediaType.BORDER = "border" -- border textures
lib.MediaType.BACKGROUND = "background" -- background textures lib.MediaType.FONT = "font" -- fonts
lib.MediaType.BORDER = "border" -- border textures lib.MediaType.STATUSBAR = "statusbar" -- statusbar textures
lib.MediaType.FONT = "font" -- fonts lib.MediaType.SOUND = "sound" -- sound files
lib.MediaType.STATUSBAR = "statusbar" -- statusbar textures
lib.MediaType.SOUND = "sound" -- sound files -- populate lib with default Blizzard data
-- BACKGROUND
-- populate lib with default Blizzard data if not lib.MediaTable.background then lib.MediaTable.background = {} end
-- BACKGROUND lib.MediaTable.background["None"] = [[]]
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 Dialog Background"] = [[Interface\DialogFrame\UI-DialogBox-Background]] lib.MediaTable.background["Blizzard Dialog Background Dark"] = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]]
lib.MediaTable.background["Blizzard Low Health"] = [[Interface\FullScreenTextures\LowHealth]] lib.MediaTable.background["Blizzard Dialog Background Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]
lib.MediaTable.background["Blizzard Out of Control"] = [[Interface\FullScreenTextures\OutOfControl]] lib.MediaTable.background["Blizzard Low Health"] = [[Interface\FullScreenTextures\LowHealth]]
lib.MediaTable.background["Blizzard Parchment"] = [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]] lib.MediaTable.background["Blizzard Marble"] = [[Interface\FrameGeneral\UI-Background-Marble]]
lib.MediaTable.background["Blizzard Parchment 2"] = [[Interface\AchievementFrame\UI-Achievement-Parchment]] lib.MediaTable.background["Blizzard Out of Control"] = [[Interface\FullScreenTextures\OutOfControl]]
lib.MediaTable.background["Blizzard Tabard Background"] = [[Interface\TabardFrame\TabardFrameBackground]] lib.MediaTable.background["Blizzard Parchment"] = [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]]
lib.MediaTable.background["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Background]] lib.MediaTable.background["Blizzard Parchment 2"] = [[Interface\AchievementFrame\UI-GuildAchievement-Parchment-Horizontal]]
lib.MediaTable.background["Solid"] = [[Interface\Buttons\WHITE8X8]] lib.MediaTable.background["Blizzard Rock"] = [[Interface\FrameGeneral\UI-Background-Rock]]
lib.MediaTable.background["Blizzard Tabard Background"] = [[Interface\TabardFrame\TabardFrameBackground]]
-- BORDER lib.MediaTable.background["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Background]]
if not lib.MediaTable.border then lib.MediaTable.border = {} end lib.MediaTable.background["Solid"] = [[Interface\Buttons\WHITE8X8]]
lib.MediaTable.border["None"] = [[Interface\None]] lib.DefaultMedia.background = "None"
lib.MediaTable.border["Blizzard Dialog"] = [[Interface\DialogFrame\UI-DialogBox-Border]]
lib.MediaTable.border["Blizzard Dialog Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Border]] -- BORDER
lib.MediaTable.border["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Border]] if not lib.MediaTable.border then lib.MediaTable.border = {} end
lib.MediaTable.border["None"] = [[]]
-- FONT lib.MediaTable.border["Blizzard Achievement Wood"] = [[Interface\AchievementFrame\UI-Achievement-WoodBorder]]
if not lib.MediaTable.font then lib.MediaTable.font = {} end lib.MediaTable.border["Blizzard Chat Bubble"] = [[Interface\Tooltips\ChatBubble-Backdrop]]
local SML_MT_font = lib.MediaTable.font lib.MediaTable.border["Blizzard Dialog"] = [[Interface\DialogFrame\UI-DialogBox-Border]]
if locale == "koKR" then lib.MediaTable.border["Blizzard Dialog Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Border]]
LOCALE_MASK = lib.LOCALE_BIT_koKR lib.MediaTable.border["Blizzard Party"] = [[Interface\CHARACTERFRAME\UI-Party-Border]]
-- lib.MediaTable.border["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Border]]
SML_MT_font["굵은 글꼴"] = [[Fonts\2002B.TTF]] lib.DefaultMedia.border = "None"
SML_MT_font["기본 글꼴"] = [[Fonts\2002.TTF]]
SML_MT_font["데미지 글꼴"] = [[Fonts\K_Damage.TTF]] -- FONT
SML_MT_font["퀘스트 글꼴"] = [[Fonts\K_Pagetext.TTF]] if not lib.MediaTable.font then lib.MediaTable.font = {} end
-- local SML_MT_font = lib.MediaTable.font
lib.DefaultMedia["font"] = "기본 글꼴" -- someone from koKR please adjust if needed if locale == "koKR" then
-- LOCALE_MASK = lib.LOCALE_BIT_koKR
elseif locale == "zhCN" then --
LOCALE_MASK = lib.LOCALE_BIT_zhCN SML_MT_font["굵은 글꼴"] = [[Fonts\2002B.TTF]]
-- SML_MT_font["기본 글꼴"] = [[Fonts\2002.TTF]]
SML_MT_font["伤害数字"] = [[Fonts\ZYKai_C.ttf]] SML_MT_font["데미지 글꼴"] = [[Fonts\K_Damage.TTF]]
SML_MT_font["默认"] = [[Fonts\ZYKai_T.ttf]] SML_MT_font["퀘스트 글꼴"] = [[Fonts\K_Pagetext.TTF]]
SML_MT_font["聊天"] = [[Fonts\ZYHei.ttf]] --
-- lib.DefaultMedia["font"] = "기본 글꼴" -- someone from koKR please adjust if needed
lib.DefaultMedia["font"] = "默认" -- someone from zhCN please adjust if needed --
-- elseif locale == "zhCN" then
elseif locale == "zhTW" then LOCALE_MASK = lib.LOCALE_BIT_zhCN
LOCALE_MASK = lib.LOCALE_BIT_zhTW --
-- SML_MT_font["伤害数字"] = [[Fonts\ARKai_C.ttf]]
SML_MT_font["提示訊息"] = [[Fonts\bHEI00M.ttf]] SML_MT_font["默认"] = [[Fonts\ARKai_T.ttf]]
SML_MT_font["聊天"] = [[Fonts\bHEI01B.ttf]] SML_MT_font["聊天"] = [[Fonts\ARHei.ttf]]
SML_MT_font["傷害數字"] = [[Fonts\bKAI00M.ttf]] --
SML_MT_font["預設"] = [[Fonts\bLEI00D.ttf]] lib.DefaultMedia["font"] = "默认" -- someone from zhCN please adjust if needed
-- --
lib.DefaultMedia["font"] = "預設" -- someone from zhTW please adjust if needed elseif locale == "zhTW" then
LOCALE_MASK = lib.LOCALE_BIT_zhTW
elseif locale == "ruRU" then --
LOCALE_MASK = lib.LOCALE_BIT_ruRU SML_MT_font["提示訊息"] = [[Fonts\bHEI00M.ttf]]
-- SML_MT_font["聊天"] = [[Fonts\bHEI01B.ttf]]
SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]] SML_MT_font["傷害數字"] = [[Fonts\bKAI00M.ttf]]
SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]] SML_MT_font["預設"] = [[Fonts\bLEI00D.ttf]]
SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS.TTF]] --
SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]] lib.DefaultMedia["font"] = "預設" -- someone from zhTW please adjust if needed
SML_MT_font["Skurri"] = [[Fonts\SKURRI.TTF]]
-- elseif locale == "ruRU" then
lib.DefaultMedia.font = "Friz Quadrata TT" LOCALE_MASK = lib.LOCALE_BIT_ruRU
-- --
else SML_MT_font["2002"] = [[Fonts\2002.TTF]]
LOCALE_MASK = lib.LOCALE_BIT_western SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]]
locale_is_western = true SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]]
-- SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]]
SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]] SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]]
SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]] SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS.TTF]] SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT___CYR.TTF]]
SML_MT_font["Skurri"] = [[Fonts\SKURRI.TTF]] SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]]
-- SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]]
lib.DefaultMedia.font = "Friz Quadrata TT" SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
-- SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]]
end --
lib.DefaultMedia.font = "Friz Quadrata TT"
-- STATUSBAR --
if not lib.MediaTable.statusbar then lib.MediaTable.statusbar = {} end else
lib.MediaTable.statusbar["Blizzard"] = [[Interface\TargetingFrame\UI-StatusBar]] LOCALE_MASK = lib.LOCALE_BIT_western
lib.DefaultMedia.statusbar = "Blizzard" locale_is_western = true
--
-- SOUND SML_MT_font["2002"] = [[Fonts\2002.TTF]]
if not lib.MediaTable.sound then lib.MediaTable.sound = {} end SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]]
lib.MediaTable.sound["None"] = [[Interface\Quiet.mp3]] -- Relies on the fact that PlaySound[File] doesn't error on non-existing input. SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]]
lib.DefaultMedia.sound = "None" SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]]
SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]]
local function rebuildMediaList(mediatype) SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
local mtable = mediaTable[mediatype] SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]]
if not mtable then return end SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]]
if not mediaList[mediatype] then mediaList[mediatype] = {} end SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]]
local mlist = mediaList[mediatype] SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
-- list can only get larger, so simply overwrite it SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]]
local i = 0 --
for k in pairs(mtable) do lib.DefaultMedia.font = "Friz Quadrata TT"
i = i + 1 --
mlist[i] = k end
end
table_sort(mlist) -- STATUSBAR
end if not lib.MediaTable.statusbar then lib.MediaTable.statusbar = {} end
lib.MediaTable.statusbar["Blizzard"] = [[Interface\TargetingFrame\UI-StatusBar]]
function lib:Register(mediatype, key, data, langmask) lib.MediaTable.statusbar["Blizzard Character Skills Bar"] = [[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]]
if type(mediatype) ~= "string" then lib.MediaTable.statusbar["Solid"] = [[Interface\Buttons\WHITE8X8]]
error(MAJOR..":Register(mediatype, key, data, langmask) - mediatype must be string, got "..type(mediatype)) lib.DefaultMedia.statusbar = "Blizzard"
end
if type(key) ~= "string" then -- SOUND
error(MAJOR..":Register(mediatype, key, data, langmask) - key must be string, got "..type(key)) if not lib.MediaTable.sound then lib.MediaTable.sound = {} end
end lib.MediaTable.sound["None"] = [[Interface\Quiet.ogg]] -- Relies on the fact that PlaySound[File] doesn't error on these values.
if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then return false end lib.DefaultMedia.sound = "None"
mediatype = mediatype:lower()
if not mediaTable[mediatype] then mediaTable[mediatype] = {} end local function rebuildMediaList(mediatype)
local mtable = mediaTable[mediatype] local mtable = mediaTable[mediatype]
if mtable[key] then return false end if not mtable then return end
if not mediaList[mediatype] then mediaList[mediatype] = {} end
mtable[key] = data local mlist = mediaList[mediatype]
rebuildMediaList(mediatype) -- list can only get larger, so simply overwrite it
self.callbacks:Fire("LibSharedMedia_Registered", mediatype, key) local i = 0
return true for k in pairs(mtable) do
end i = i + 1
mlist[i] = k
function lib:Fetch(mediatype, key, noDefault) end
local mtt = mediaTable[mediatype] table_sort(mlist)
local overridekey = overrideMedia[mediatype] end
local result = mtt and ((overridekey and mtt[overridekey] or mtt[key]) or (not noDefault and defaultMedia[mediatype] and mtt[defaultMedia[mediatype]])) or nil
function lib:Register(mediatype, key, data, langmask)
return result if type(mediatype) ~= "string" then
end error(MAJOR..":Register(mediatype, key, data, langmask) - mediatype must be string, got "..type(mediatype))
end
function lib:IsValid(mediatype, key) if type(key) ~= "string" then
return mediaTable[mediatype] and (not key or mediaTable[mediatype][key]) and true or false error(MAJOR..":Register(mediatype, key, data, langmask) - key must be string, got "..type(key))
end end
mediatype = mediatype:lower()
function lib:HashTable(mediatype) if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then
return mediaTable[mediatype] -- ignore fonts that aren't flagged as supporting local glyphs on non-western clients
end return false
end
function lib:List(mediatype) if mediatype == lib.MediaType.SOUND and type(data) == "string" then
if not mediaTable[mediatype] then local path = data:lower()
return nil if not path:find(".ogg", nil, true) and not path:find(".mp3", nil, true) and not path:find(".wav", nil, true) then
end -- Only wav, ogg and mp3 are valid sounds.
if not mediaList[mediatype] then return false
rebuildMediaList(mediatype) end
end end
return mediaList[mediatype] if not mediaTable[mediatype] then mediaTable[mediatype] = {} end
end local mtable = mediaTable[mediatype]
if mtable[key] then return false end
function lib:GetGlobal(mediatype)
return overrideMedia[mediatype] mtable[key] = data
end rebuildMediaList(mediatype)
self.callbacks:Fire("LibSharedMedia_Registered", mediatype, key)
function lib:SetGlobal(mediatype, key) return true
if not mediaTable[mediatype] then end
return false
end function lib:Fetch(mediatype, key, noDefault)
overrideMedia[mediatype] = (key and mediaTable[mediatype][key]) and key or nil local mtt = mediaTable[mediatype]
self.callbacks:Fire("LibSharedMedia_SetGlobal", mediatype, overrideMedia[mediatype]) local overridekey = overrideMedia[mediatype]
return true local result = mtt and ((overridekey and mtt[overridekey] or mtt[key]) or (not noDefault and defaultMedia[mediatype] and mtt[defaultMedia[mediatype]])) or nil
end return result ~= "" and result or nil
end
function lib:GetDefault(mediatype)
return defaultMedia[mediatype] function lib:IsValid(mediatype, key)
end return mediaTable[mediatype] and (not key or mediaTable[mediatype][key]) and true or false
end
function lib:SetDefault(mediatype, key)
if mediaTable[mediatype] and mediaTable[mediatype][key] and not defaultMedia[mediatype] then function lib:HashTable(mediatype)
defaultMedia[mediatype] = key return mediaTable[mediatype]
return true end
else
return false function lib:List(mediatype)
end if not mediaTable[mediatype] then
end return nil
end
if not mediaList[mediatype] then
rebuildMediaList(mediatype)
end
return mediaList[mediatype]
end
function lib:GetGlobal(mediatype)
return overrideMedia[mediatype]
end
function lib:SetGlobal(mediatype, key)
if not mediaTable[mediatype] then
return false
end
overrideMedia[mediatype] = (key and mediaTable[mediatype][key]) and key or nil
self.callbacks:Fire("LibSharedMedia_SetGlobal", mediatype, overrideMedia[mediatype])
return true
end
function lib:GetDefault(mediatype)
return defaultMedia[mediatype]
end
function lib:SetDefault(mediatype, key)
if mediaTable[mediatype] and mediaTable[mediatype][key] and not defaultMedia[mediatype] then
defaultMedia[mediatype] = key
return true
else
return false
end
end
@@ -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>
+49 -1
View File
@@ -1,6 +1,47 @@
local Auras = {} local Auras = {}
local stealableColor = {r = 1, g = 1, b = 1} local stealableColor = {r = 1, g = 1, b = 1}
local playerUnits = {player = true, vehicle = true, pet = true} 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"] = { Disease = true, Poison = true }, -- Cleansing Idol (AoE)
["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 mainHand, offHand = {time = 0}, {time = 0}
local tempEnchantScan local tempEnchantScan
ShadowUF:RegisterModule(Auras, "auras", ShadowUF.L["Auras"]) ShadowUF:RegisterModule(Auras, "auras", ShadowUF.L["Auras"])
@@ -479,6 +520,13 @@ end
local function scan(parent, frame, type, config, filter) local function scan(parent, frame, type, config, filter)
if( frame.totalAuras >= frame.maxAuras or not config.enabled ) then return end 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 isFriendly = UnitIsFriend(frame.parent.unit, "player")
local index = 0 local index = 0
while( true ) do while( true ) do
@@ -486,7 +534,7 @@ local function scan(parent, frame, type, config, filter)
local name, rank, texture, count, auraType, duration, endTime, caster, isStealable = UnitAura(frame.parent.unit, index, filter) local name, rank, texture, count, auraType, duration, endTime, caster, isStealable = UnitAura(frame.parent.unit, index, filter)
if( not name ) then break end 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.blacklist[type] and not parent.blacklist[name] ) ) then
-- Create any buttons we need -- Create any buttons we need
frame.totalAuras = frame.totalAuras + 1 frame.totalAuras = frame.totalAuras + 1
if( #(frame.buttons) < frame.totalAuras ) then if( #(frame.buttons) < frame.totalAuras ) then
+24 -1
View File
@@ -150,6 +150,29 @@ end
function Highlight:UpdateAura(frame) 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 -- 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) self:Update(frame)
end end
+4 -2
View File
@@ -70,10 +70,12 @@ function Portrait:Update(frame, event)
-- Use class thingy -- Use class thingy
if( type == "class" ) then if( type == "class" ) then
local classToken = select(2, UnitClass(frame.unitOwner)) 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: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 else
-- CoA custom classes (Witchdoctor/Templar/…) have no CLASS_ICON_TCOORDS entry; blank instead of crash
frame.portrait:SetTexture("") frame.portrait:SetTexture("")
end end
-- Use 2D character image -- Use 2D character image
+60 -7
View File
@@ -2,12 +2,32 @@ local Totems = {}
local totemColors = {} local totemColors = {}
local MAX_TOTEMS = MAX_TOTEMS 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 -- 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 MAX_TOTEMS = 1
ShadowUF:RegisterModule(Totems, "totemBar", ShadowUF.L["Guardian bar"], true, "DEATHKNIGHT") ShadowUF:RegisterModule(Totems, "totemBar", ShadowUF.L["Guardian bar"], true, "DEATHKNIGHT")
else 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 end
function Totems:OnEnable(frame) function Totems:OnEnable(frame)
@@ -17,17 +37,33 @@ function Totems:OnEnable(frame)
for id=1, MAX_TOTEMS do for id=1, MAX_TOTEMS do
local totem = ShadowUF.Units:CreateBar(frame) 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:SetMinMaxValues(0, 1)
totem:SetValue(0) totem:SetValue(0)
totem.id = MAX_TOTEMS == 1 and 1 or TOTEM_PRIORITIES[id] 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 if( id > 1 ) then
totem:SetPoint("TOPLEFT", frame.totemBar.totems[id - 1], "TOPRIGHT", 1, 0) totem:SetPoint("TOPLEFT", frame.totemBar.totems[id - 1], "TOPRIGHT", 1, 0)
else else
totem:SetPoint("TOPLEFT", frame.totemBar, "TOPLEFT", 0, 0) totem:SetPoint("TOPLEFT", frame.totemBar, "TOPLEFT", 0, 0)
end end
table.insert(frame.totemBar.totems, totem) table.insert(frame.totemBar.totems, totem)
end end
@@ -74,10 +110,23 @@ end
local function totemMonitor(self, elapsed) local function totemMonitor(self, elapsed)
local time = GetTime() 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 if( time >= self.endTime ) then
self:SetValue(0) self:SetValue(0)
if self.timeText then
self.timeText:SetText("")
self.lastIntSec = nil
end
self:SetScript("OnUpdate", nil) self:SetScript("OnUpdate", nil)
end end
end end
@@ -101,6 +150,10 @@ function Totems:Update(frame)
indicator:SetScript("OnUpdate", nil) indicator:SetScript("OnUpdate", nil)
indicator:SetMinMaxValues(0, 1) indicator:SetMinMaxValues(0, 1)
indicator:SetValue(0) indicator:SetValue(0)
if indicator.timeText then
indicator.timeText:SetText("")
indicator.lastIntSec = nil
end
end end
end end
+9 -1
View File
@@ -753,7 +753,15 @@ function Units:SetHeaderAttributes(frame, type)
frame:SetAttribute("groupFilter", filter or "1,2,3,4,5,6,7,8") frame:SetAttribute("groupFilter", filter or "1,2,3,4,5,6,7,8")
if( config.groupBy == "CLASS" ) then 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") frame:SetAttribute("groupBy", "CLASS")
else else
frame:SetAttribute("groupingOrder", "1,2,3,4,5,6,7,8") frame:SetAttribute("groupingOrder", "1,2,3,4,5,6,7,8")
+71
View File
@@ -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