Skip to content

Commit d70fd6a

Browse files
committed
Initial commit
0 parents  commit d70fd6a

8 files changed

Lines changed: 238 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Replace toc-versions
18+
uses: NumyAddon/ToCVersions@v1
19+
20+
- name: Create Retail Package
21+
uses: BigWigsMods/packager@v2
22+
env:
23+
CF_API_KEY: ${{ secrets.CF_API_KEY }}
24+
GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tocBump.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: TOC Bump
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
message:
6+
description: 'Commit message'
7+
required: false
8+
default: 'TOC Bump'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Get next version
18+
uses: reecetech/version-increment@2023.9.3
19+
id: version
20+
with:
21+
scheme: semver
22+
increment: patch
23+
24+
- name: Create & push empty commit
25+
run: |
26+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
27+
git config --global user.name "${{ github.actor }}"
28+
git commit --allow-empty -m "${{ github.event.inputs.message }}"
29+
git push
30+
31+
- name: Publish release
32+
uses: softprops/action-gh-release@v1
33+
with:
34+
# this cannot be ${{ secrets.GITHUB_TOKEN }} because that'll block the on release publish workflow from running
35+
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
36+
name: ${{ steps.version.outputs.v-version }}
37+
tag_name: ${{ steps.version.outputs.v-version }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/libs/*/

.pkgmeta

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
externals:
3+
libs/AceConfig-3.0: https://repos.wowace.com/wow/ace3/trunk/AceConfig-3.0
4+
libs/AceDB-3.0: https://repos.wowace.com/wow/ace3/trunk/AceDB-3.0
5+
libs/AceDBOptions-3.0: https://repos.wowace.com/wow/ace3/trunk/AceDBOptions-3.0
6+
libs/AceGUI-3.0: https://repos.wowace.com/wow/ace3/trunk/AceGUI-3.0
7+
libs/CallbackHandler-1.0: https://repos.wowace.com/wow/ace3/trunk/CallbackHandler-1.0
8+
libs/LibStub: https://repos.wowace.com/wow/ace3/trunk/LibStub

UnifiedProfileManager.lua

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
local name, ns = ...;
2+
3+
local AceDB = LibStub('AceDB-3.0');
4+
local AceDBOptions = LibStub("AceDBOptions-3.0");
5+
local AceConfig = LibStub("AceConfig-3.0");
6+
local AceConfigDialog = LibStub("AceConfigDialog-3.0");
7+
8+
local function SortAddons(name1, name2)
9+
return strcmputf8i(StripHyperlinks(name1), StripHyperlinks(name2)) < 0;
10+
end
11+
12+
ns.resultCache = {};
13+
function ns:FindGlobal(item)
14+
if not self.resultCache[item] then
15+
for k, v in pairs(_G) do
16+
if item == v then
17+
self.resultCache[item] = k;
18+
break;
19+
end
20+
end
21+
end
22+
23+
return self.resultCache[item];
24+
end
25+
26+
function ns:GetDuplicateAddons()
27+
local duplicateAddons = {};
28+
local addonNames = {};
29+
for db, _ in pairs(AceDB.db_registry) do
30+
if not db.parent then
31+
local addonName = self:GetAddonNameForDB(db);
32+
if addonNames[addonName] then
33+
duplicateAddons[addonName] = true;
34+
end
35+
addonNames[addonName] = true;
36+
end
37+
end
38+
39+
return duplicateAddons;
40+
end
41+
42+
ns.dbCache = {};
43+
function ns:GetAddonNameForDB(db)
44+
if not ns.dbCache[db] then
45+
local _, addonName = issecurevariable(db, 'sv');
46+
_, addonName = C_AddOns.GetAddOnInfo(addonName);
47+
ns.dbCache[db] = addonName;
48+
end
49+
50+
return ns.dbCache[db];
51+
end
52+
53+
function ns:GetOptionsTable(skipAddons)
54+
local options = {
55+
type = 'group',
56+
args = {
57+
['allProfiles'] = {
58+
type = 'group',
59+
order = 2,
60+
name = 'All Addons',
61+
desc = 'Overview of all addon profiles',
62+
args = {
63+
desc = {
64+
type = 'description',
65+
name = 'You can change the profile for all addons here. Some addons may need you to reload the UI after switching, to avoid issues',
66+
order = 1,
67+
},
68+
reloadUI = {
69+
type = 'execute',
70+
name = 'Reload UI',
71+
order = 2,
72+
width = 'full',
73+
func = ReloadUI,
74+
},
75+
},
76+
}
77+
},
78+
}
79+
if skipAddons then
80+
return options;
81+
end
82+
83+
local addonNames = {};
84+
local addonOrder = {};
85+
local function getOrder(info)
86+
local addonName = info.option.name;
87+
88+
return addonOrder[addonName] or -1;
89+
end
90+
local increment = CreateCounter(2);
91+
local allProfiles = options.args.allProfiles;
92+
93+
local duplicateAddons = self:GetDuplicateAddons();
94+
95+
for db, _ in pairs(AceDB.db_registry) do
96+
if not db.parent then
97+
local i = increment();
98+
99+
local addonName = self:GetAddonNameForDB(db);
100+
if duplicateAddons[addonName] then
101+
local savedVariableName = self:FindGlobal(db.sv);
102+
addonName = addonName .. (savedVariableName and WHITE_FONT_COLOR:WrapTextInColorCode(' ('..savedVariableName..')') or '');
103+
end
104+
105+
table.insert(addonNames, addonName);
106+
addonOrder[addonName] = i;
107+
108+
local option = CopyTable(AceDBOptions:GetOptionsTable(db), true);
109+
option.order = getOrder;
110+
option.name = addonName;
111+
options.args['profiles'..i] = option;
112+
113+
local choose = CopyTable(option.args.choose);
114+
choose.order = getOrder;
115+
choose.handler = option.handler;
116+
choose.name = addonName;
117+
allProfiles.args['profiles'..i] = choose;
118+
end
119+
end
120+
121+
table.sort(addonNames, SortAddons);
122+
for i, addonName in ipairs(addonNames) do
123+
addonOrder[addonName] = i + 2;
124+
end
125+
126+
return options;
127+
end
128+
129+
function ns:Init()
130+
AceConfig:RegisterOptionsTable(name, ns:GetOptionsTable(true));
131+
local panel, category = AceConfigDialog:AddToBlizOptions(name, name);
132+
133+
local ignoreHook = false;
134+
panel:HookScript('OnShow', function()
135+
if ignoreHook then return; end
136+
ignoreHook = true;
137+
AceConfig:RegisterOptionsTable(name, ns:GetOptionsTable());
138+
panel:Hide();
139+
panel:Show();
140+
RunNextFrame(function() ignoreHook = false; end);
141+
end);
142+
143+
_G.SLASH_UNIFIED_PROFILE_MANAGER1 = '/upm';
144+
_G.SLASH_UNIFIED_PROFILE_MANAGER2 = '/profiles';
145+
SlashCmdList['UNIFIED_PROFILE_MANAGER'] = function()
146+
Settings.OpenToCategory(category);
147+
end;
148+
end
149+
150+
ns:Init();

UnifiedProfileManager.toc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Interface: @toc-version-retail@
2+
## Title: Unified Profile Manager
3+
## Notes: A simple overview of all addon profiles for addons that use AceDB
4+
## Author: Numy
5+
## IconTexture: Interface\Addons\UnifiedProfileManager\media\icon
6+
## Version: @project-version@
7+
## X-Curse-Project-ID: 1033706
8+
9+
libs\libs.xml
10+
UnifiedProfileManager.lua

libs/libs.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Ui xmlns="http://www.blizzard.com/wow/ui/">
2+
<Script file="LibStub\LibStub.lua"/>
3+
<Include file="CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
4+
<Include file="AceDB-3.0\AceDB-3.0.xml"/>
5+
<Include file="AceDBOptions-3.0\AceDBOptions-3.0.xml"/>
6+
<Include file="AceGUI-3.0\AceGUI-3.0.xml"/>
7+
<Include file="AceConfig-3.0\AceConfig-3.0.xml"/>
8+
</Ui>

media/icon.jpeg

15.7 KB
Loading

0 commit comments

Comments
 (0)