flickerstreak@7: -- ReAction.IColorScheme is an interface to describe color schemes for hotkey labels and flickerstreak@7: -- icon/border colorization, depending on the current state. flickerstreak@7: -- flickerstreak@7: flickerstreak@7: local AceOO = AceLibrary("AceOO-2.0") flickerstreak@7: flickerstreak@7: ReAction.IColorScheme = AceOO.Interface { flickerstreak@7: GetHotkeyColor = "function", -- r,g,b,a = GetHotkeyColor( isUsable, notEnoughMana, outOfRange, [bindingText] ) flickerstreak@7: GetIconColor = "function", -- r,g,b,a = GetIconColor( isUsable, notEnoughMana, outOfRange ) flickerstreak@7: GetBorderColor = "function", -- r,g,b,a = GetBorderColor( isUsable, notEnoughMana, outOfRange ) flickerstreak@7: } flickerstreak@7: flickerstreak@7: flickerstreak@7: flickerstreak@7: -- ReAction.DefaultColorScheme is a Mixin implementation of ReAction.IColorScheme which flickerstreak@7: -- supports the standard Blizzard colorization plus optional hotkey modifier-driven colorization flickerstreak@7: -- and colorizing icons red (in addition to hotkeys) when out of range. flickerstreak@7: -- flickerstreak@7: -- DefaultColorScheme makes use of self.config as follows: flickerstreak@7: -- flickerstreak@7: -- self.config = { flickerstreak@7: -- keyBindColorCode = true/false, -- color-code keybindings based on modifier key flickerstreak@7: -- } flickerstreak@7: flickerstreak@7: flickerstreak@7: ReAction.DefaultColorScheme = AceOO.Mixin { flickerstreak@7: "GetHotkeyColor", flickerstreak@7: "GetModifiedHotkeyColor", -- returns the default modified color (if configured) flickerstreak@7: "GetIconColor", flickerstreak@7: "GetBorderColor" flickerstreak@7: } flickerstreak@7: flickerstreak@7: flickerstreak@7: -- private variables flickerstreak@7: local hotKeyDefaultColor = { r=1.00, g=1.00, b=1.00, a=1.00 } -- white flickerstreak@7: local hotKeyDisabledColor = { r=0.60, g=0.60, b=0.60, a=1.00 } -- 60% gray flickerstreak@7: local hotKeyOutOfRangeColor = { r=1.00, g=0.20, b=0.20, a=1.00 } -- red flickerstreak@7: flickerstreak@7: local actionUsableColor = { r=1.00, g=1.00, b=1.00, a=1.00 } -- white flickerstreak@7: local actionNotUsableColor = { r=0.40, g=0.40, b=0.40, a=1.00 } -- 40% gray flickerstreak@7: local actionNotEnoughManaColor = { r=0.20, g=0.20, b=0.70, a=1.00 } -- medium blue flickerstreak@7: local actionOutOfRangeColor = { r=1.00, g=0.20, b=0.20, a=1.00 } -- red flickerstreak@7: flickerstreak@7: local hotKeyModifierColors = { flickerstreak@7: S = { r=0.60, g=0.60, b=1.00, a=1.00 }, -- shift (blue) flickerstreak@7: C = { r=1.00, g=0.82, b=0.00, a=1.00 }, -- ctrl (gold) flickerstreak@7: A = { r=0.10, g=1.00, b=0.10, a=1.00 }, -- alt (green) flickerstreak@7: M = { r=0.90, g=0.30, b=1.00, a=1.00 }, -- mouse (purple) flickerstreak@7: } flickerstreak@7: flickerstreak@7: -- build list of modifier keys (as a string) from table above flickerstreak@7: local hotKeyModifiers = "" flickerstreak@7: for k, _ in pairs(hotKeyModifierColors) do flickerstreak@7: hotKeyModifiers = hotKeyModifiers..k flickerstreak@7: end flickerstreak@7: flickerstreak@7: -- private functions flickerstreak@7: -- extract and return color fields from a table, to be fed into SetVertexColor()/SetTextColor() flickerstreak@7: local function tcolor(c) flickerstreak@7: return c.r, c.g, c.b, c.a flickerstreak@7: end flickerstreak@7: flickerstreak@7: flickerstreak@7: flickerstreak@7: -- mixin methods flickerstreak@7: flickerstreak@7: local RADCS = ReAction.DefaultColorScheme flickerstreak@7: flickerstreak@7: function RADCS:GetHotkeyColor( isUsable, notEnoughMana, outOfRange, bindingTxt ) flickerstreak@7: if isUsable or notEnoughMana then flickerstreak@7: return tcolor(self:GetModifiedHotkeyColor(bindingTxt)) flickerstreak@7: elseif outOfRange then flickerstreak@7: return tcolor(hotKeyOutOfRangeColor) flickerstreak@7: else flickerstreak@7: return tcolor(hotKeyDisabledColor) flickerstreak@7: end flickerstreak@7: end flickerstreak@7: flickerstreak@7: function RADCS:GetModifiedHotkeyColor(txt) flickerstreak@7: local c = hotKeyDefaultColor flickerstreak@7: if txt and self.config.keyBindColorCode then flickerstreak@7: local modKey = string.match( txt or "", "(["..hotKeyModifiers.."])%-") flickerstreak@7: c = modKey and hotKeyModifierColors[modKey] or c flickerstreak@7: end flickerstreak@7: return c flickerstreak@7: end flickerstreak@7: flickerstreak@7: function RADCS:GetIconColor( isUsable, notEnoughMana, outOfRange ) flickerstreak@7: if isUsable then flickerstreak@7: return tcolor(actionUsableColor) flickerstreak@7: elseif notEnoughMana then flickerstreak@7: return tcolor(actionNotEnoughManaColor) flickerstreak@7: elseif outOfRange then flickerstreak@7: return tcolor(actionOutOfRangeColor) flickerstreak@7: else flickerstreak@7: return tcolor(actionNotUsableColor) flickerstreak@7: end flickerstreak@7: end flickerstreak@7: flickerstreak@7: function RADCS:GetBorderColor( isUsable, notEnoughMana, outOfRange ) flickerstreak@7: if isUsable or notEnoughMana or outOfRange then flickerstreak@7: return tcolor(actionUsableColor) flickerstreak@7: else flickerstreak@7: return tcolor(actionNotUsableColor) flickerstreak@7: end flickerstreak@7: end flickerstreak@7: