-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eea06d6
commit ec5c0ee
Showing
11 changed files
with
355 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Interface: 110005 | ||
## Title: ColorTools Class Colors | ||
## Notes: Custom Class Colors | ||
## Version: @project-version@ | ||
## Author: Muhmiauwau | ||
## SavedVariables: ColorToolsClassColorsDB | ||
## X-Curse-Project-ID: 1118525 | ||
|
||
|
||
Libs/LibStub/LibStub.lua | ||
Libs/AceLocale-3.0/AceLocale-3.0.xml | ||
Libs/LibLodash/LibLodash.lua | ||
|
||
locale/locale.xml | ||
|
||
|
||
frames.xml | ||
|
||
ColorToolsClassColors.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Release AddOn | ||
|
||
on: | ||
push: | ||
tags: | ||
- '**' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
environment: default | ||
|
||
env: | ||
CF_API_KEY: ${{ secrets.CF_API_KEY }} | ||
WAGO_API_TOKEN: ${{ secrets.WAGO_API_TOKEN }} | ||
WOWI_API_TOKEN: ${{ secrets.WOWI_API_TOKEN }} | ||
GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- name: Clone project | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Package and release | ||
uses: BigWigsMods/packager@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Libs/* | ||
test.lua | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package-as: '!ColorToolsClassColors' | ||
|
||
ignore: | ||
- README.md | ||
|
||
|
||
externals: | ||
Libs/LibStub: https://repos.wowace.com/wow/libstub/trunk | ||
Libs/AceLocale-3.0: https://repos.wowace.com/wow/ace3/trunk/AceLocale-3.0 | ||
Libs/LibLodash: https://github.com/muhmiauwauWOW/LibLodash.git | ||
|
||
enable-nolib-creation: no | ||
|
||
tools-used: | ||
- liblodash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
if CUSTOM_CLASS_COLORS then return end | ||
|
||
local addonName, ColorToolsClassColors = ... | ||
local L = LibStub("AceLocale-3.0"):GetLocale("ColorToolsClassColors") | ||
local _ = LibStub("LibLodash-1"):Get() | ||
|
||
|
||
|
||
CUSTOM_CLASS_COLORS = {} | ||
|
||
|
||
local meta = {} | ||
local callbacks = {} | ||
local numCallbacks = 0 | ||
|
||
function meta:RegisterCallback(method, handler) | ||
assert(type(method) == "string" or type(method) == "function", "Bad argument #1 to :RegisterCallback (string or function expected)") | ||
if type(method) == "string" then | ||
assert(type(handler) == "table", "Bad argument #2 to :RegisterCallback (table expected)") | ||
assert(type(handler[method]) == "function", "Bad argument #1 to :RegisterCallback (method \"" .. method .. "\" not found)") | ||
method = handler[method] | ||
end | ||
-- assert(not callbacks[method] "Callback already registered!") | ||
callbacks[method] = handler or true | ||
numCallbacks = numCallbacks + 1 | ||
end | ||
|
||
function meta:UnregisterCallback(method, handler) | ||
assert(type(method) == "string" or type(method) == "function", "Bad argument #1 to :UnregisterCallback (string or function expected)") | ||
if type(method) == "string" then | ||
assert(type(handler) == "table", "Bad argument #2 to :UnregisterCallback (table expected)") | ||
assert(type(handler[method]) == "function", "Bad argument #1 to :UnregisterCallback (method \"" .. method .. "\" not found)") | ||
method = handler[method] | ||
end | ||
-- assert(callbacks[method], "Callback not registered!") | ||
callbacks[method] = nil | ||
numCallbacks = numCallbacks - 1 | ||
end | ||
|
||
local function DispatchCallbacks() | ||
if numCallbacks < 1 then return end | ||
-- print("CUSTOM_CLASS_COLORS: DispatchCallbacks") | ||
for method, handler in pairs(callbacks) do | ||
local ok, err = pcall(method, handler ~= true and handler or nil) | ||
if not ok then | ||
print("ERROR:", err) | ||
end | ||
end | ||
end | ||
|
||
------------------------------------------------------------------------ | ||
|
||
local classes = {} | ||
for class in pairs(RAID_CLASS_COLORS) do | ||
tinsert(classes, class) | ||
end | ||
sort(classes) | ||
|
||
local classTokens = {} | ||
for token, class in pairs(LOCALIZED_CLASS_NAMES_MALE) do | ||
classTokens[class] = token | ||
end | ||
for token, class in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do | ||
classTokens[class] = token | ||
end | ||
|
||
function meta:GetClassToken(className) | ||
return className and classTokens[className] | ||
end | ||
|
||
------------------------------------------------------------------------ | ||
|
||
function meta:NotifyChanges() | ||
-- print("CUSTOM_CLASS_COLORS: NotifyChanges") | ||
local changed | ||
|
||
for i = 1, #classes do | ||
local class = classes[i] | ||
local color = CUSTOM_CLASS_COLORS[class] | ||
local cache = ColorToolsClassColors[class] | ||
|
||
if cache.r ~= color.r or cache.g ~= color.g or cache.b ~= color.b then | ||
print("Change found in", class) | ||
cache = {color:GetRGB()} | ||
|
||
changed = true | ||
end | ||
end | ||
|
||
if changed then | ||
DispatchCallbacks() | ||
end | ||
end | ||
|
||
------------------------------------------------------------------------ | ||
|
||
setmetatable(CUSTOM_CLASS_COLORS, { __index = meta }) | ||
|
||
|
||
|
||
------------------------------------------------------------------------ | ||
------------------------------------------------------------------------ | ||
------------------------------------------------------------------------ | ||
|
||
|
||
|
||
|
||
|
||
local defaultValue = {} | ||
|
||
_.forEach(RAID_CLASS_COLORS, function(entry, key) | ||
defaultValue[key] = {entry:GetRGB()} | ||
end) | ||
|
||
|
||
ColorToolsClassColors.init = CreateFrame("Frame") | ||
ColorToolsClassColors.init:RegisterEvent("ADDON_LOADED") | ||
ColorToolsClassColors.init:SetScript("OnEvent", function(self, event, addon) | ||
if addon ~= "!ColorToolsClassColors" then return end | ||
ColorToolsClassColorsDB = ColorToolsClassColorsDB or defaultValue | ||
ColorToolsClassColors.Options.Init() | ||
end) | ||
|
||
|
||
function ColorToolsClassColors:SetColor(key, value) | ||
local color = CreateColor(table.unpack(value)) | ||
color.colorStr = color:GenerateHexColor() | ||
CUSTOM_CLASS_COLORS[key] = color | ||
end | ||
|
||
|
||
|
||
ColorToolsClassColors.Options = {} | ||
|
||
function ColorToolsClassColors.Options:Init() | ||
local AddOnInfo = {C_AddOns.GetAddOnInfo(addonName)} | ||
local category, layout = Settings.RegisterVerticalLayoutCategory(AddOnInfo[2]) | ||
ColorToolsClassColors.OptionsID = category:GetID() | ||
|
||
-- local initializer = Settings.CreatePanelInitializer("ColorToolsClassColorsDescTemplate", { text = L["Desc"] }); | ||
-- layout:AddInitializer(initializer); | ||
|
||
local classNames = LocalizedClassList() | ||
|
||
for key, entry in pairs(ColorToolsClassColorsDB) do | ||
local setting = Settings.RegisterAddOnSetting(category, "ColorToolsClassColors" .. key, key, ColorToolsClassColorsDB, "table", classNames[key], defaultValue[key]) | ||
|
||
setting:SetValueChangedCallback(function(self) | ||
ColorToolsClassColors:SetColor(key, self:GetValue()) | ||
end) | ||
|
||
Settings.CreateColor(category, setting, nil) | ||
ColorToolsClassColors:SetColor(key, ColorToolsClassColorsDB[key]) | ||
end | ||
|
||
Settings.RegisterAddOnCategory(category) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## ColorTools | ||
ColorTools Color Picker is an enhancement for the build in Color Picker | ||
|
||
Features: | ||
|
||
- history of used colors | ||
- color palettes of Bliizard Colors for fast access | ||
- Input fields for RBG Color format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<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="mixins.lua"/> | ||
|
||
|
||
<Frame name="ColorToolsClassColorsDescTemplate" mixin="ColorToolsClassColorsDescMixin" virtual="true"> | ||
<Size y="12"/> | ||
<Layers> | ||
<Layer level="OVERLAY"> | ||
<FontString parentKey="Text" inherits="Number14FontWhite" justifyH="LEFT" justifyV="TOP" wordwrap="true"> | ||
<Anchors> | ||
<Anchor point="LEFT" x="0" /> | ||
<Anchor point="RIGHT" x="0" /> | ||
</Anchors> | ||
</FontString> | ||
</Layer> | ||
</Layers> | ||
<Scripts> | ||
<OnLoad method="OnLoad"/> | ||
<OnShow method="OnShow"/> | ||
</Scripts> | ||
</Frame> | ||
|
||
|
||
|
||
<Frame name="SettingsColorControlTemplate" inherits="SettingsListElementTemplate" mixin="SettingsColorControlMixin" virtual="true"> | ||
<Size x="280" y="26"/> | ||
<Scripts> | ||
<OnLoad method="OnLoad"/> | ||
</Scripts> | ||
</Frame> | ||
|
||
</Ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local L = LibStub("AceLocale-3.0"):NewLocale("ColorToolsClassColors", "enUS", true) | ||
|
||
if not L then | ||
return | ||
end | ||
|
||
L["Desc"] = "Note that not all addons support this, and you may need to reload the UI before your changes are recognized by all compatible addons." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ | ||
..\FrameXML\UI.xsd"> | ||
<Script file="enUS.lua"/> | ||
</Ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
|
||
|
||
ColorToolsClassColorsDescMixin = {} | ||
|
||
function ColorToolsClassColorsDescMixin:OnLoad() | ||
C_Timer.After(3, function() | ||
local d = self:GetData() | ||
self.text = d.data.text | ||
end) | ||
end | ||
function ColorToolsClassColorsDescMixin:OnShow() | ||
self.Text:SetText(self.text) | ||
self:SetHeight(self.Text:GetStringHeight()) | ||
end | ||
|
||
|
||
|
||
|
||
SettingsColorControlMixin = CreateFromMixins(SettingsControlMixin); | ||
|
||
function SettingsColorControlMixin:OnLoad() | ||
SettingsControlMixin.OnLoad(self); | ||
|
||
|
||
self.Colorswatch = CreateFrame("Button", nil, self); | ||
self.Colorswatch:SetPoint("LEFT", self, "CENTER", -80, 0); | ||
self.Colorswatch:SetSize(20, 20); | ||
self.Colorswatch.Texture = self.Colorswatch:CreateTexture() | ||
self.Colorswatch.Texture:SetAllPoints() | ||
|
||
|
||
self.Colorswatch:SetScript("OnClick", function() | ||
local currentValue = self:GetSetting():GetValue() | ||
local options = { | ||
swatchFunc = function() | ||
local r, g, b = ColorPickerFrame:GetColorRGB(); | ||
self:GetSetting():SetValue({r, g, b}) | ||
end, | ||
cancelFunc = function() | ||
self.Colorswatch.Texture:SetColorTexture(currentValue[1],currentValue[2],currentValue[3]) | ||
end, | ||
hasOpacity = false, | ||
r = currentValue[1], | ||
g = currentValue[2], | ||
b = currentValue[3], | ||
}; | ||
|
||
ColorPickerFrame:SetupColorPickerAndShow(options); | ||
end); | ||
|
||
|
||
self.Tooltip:SetScript("OnMouseUp", function() | ||
if self.Colorswatch:IsEnabled() then | ||
self.Colorswatch:Click(); | ||
end | ||
end); | ||
end | ||
|
||
function SettingsColorControlMixin:Init(initializer) | ||
SettingsControlMixin.Init(self, initializer); | ||
local currentValue = self:GetSetting():GetValue() | ||
self.Colorswatch.Texture:SetColorTexture(table.unpack(currentValue)) | ||
end | ||
|
||
function SettingsColorControlMixin:OnSettingValueChanged(setting, value) | ||
SettingsControlMixin.OnSettingValueChanged(self, setting, value); | ||
self.Colorswatch.Texture:SetColorTexture(value[1], value[2], value[3]) | ||
end | ||
|
||
function SettingsColorControlMixin:Release() | ||
SettingsControlMixin.Release(self); | ||
end | ||
|
||
|
||
|
||
function Settings.CreateColor(category, setting, tooltip) | ||
local initializer = Settings.CreateControlInitializer("SettingsColorControlTemplate", setting, nil, tooltip); | ||
local layout = SettingsPanel:GetLayout(category); | ||
layout:AddInitializer(initializer); | ||
|
||
return initializer; | ||
end |