flickerstreak@7
|
1 -- ReAction.IColorScheme is an interface to describe color schemes for hotkey labels and
|
flickerstreak@7
|
2 -- icon/border colorization, depending on the current state.
|
flickerstreak@7
|
3 --
|
flickerstreak@7
|
4
|
flickerstreak@7
|
5 local AceOO = AceLibrary("AceOO-2.0")
|
flickerstreak@7
|
6
|
flickerstreak@7
|
7 ReAction.IColorScheme = AceOO.Interface {
|
flickerstreak@7
|
8 GetHotkeyColor = "function", -- r,g,b,a = GetHotkeyColor( isUsable, notEnoughMana, outOfRange, [bindingText] )
|
flickerstreak@7
|
9 GetIconColor = "function", -- r,g,b,a = GetIconColor( isUsable, notEnoughMana, outOfRange )
|
flickerstreak@7
|
10 GetBorderColor = "function", -- r,g,b,a = GetBorderColor( isUsable, notEnoughMana, outOfRange )
|
flickerstreak@7
|
11 }
|
flickerstreak@7
|
12
|
flickerstreak@7
|
13
|
flickerstreak@7
|
14
|
flickerstreak@7
|
15 -- ReAction.DefaultColorScheme is a Mixin implementation of ReAction.IColorScheme which
|
flickerstreak@7
|
16 -- supports the standard Blizzard colorization plus optional hotkey modifier-driven colorization
|
flickerstreak@7
|
17 -- and colorizing icons red (in addition to hotkeys) when out of range.
|
flickerstreak@7
|
18 --
|
flickerstreak@7
|
19 -- DefaultColorScheme makes use of self.config as follows:
|
flickerstreak@7
|
20 --
|
flickerstreak@7
|
21 -- self.config = {
|
flickerstreak@7
|
22 -- keyBindColorCode = true/false, -- color-code keybindings based on modifier key
|
flickerstreak@7
|
23 -- }
|
flickerstreak@7
|
24
|
flickerstreak@7
|
25
|
flickerstreak@7
|
26 ReAction.DefaultColorScheme = AceOO.Mixin {
|
flickerstreak@7
|
27 "GetHotkeyColor",
|
flickerstreak@7
|
28 "GetModifiedHotkeyColor", -- returns the default modified color (if configured)
|
flickerstreak@7
|
29 "GetIconColor",
|
flickerstreak@7
|
30 "GetBorderColor"
|
flickerstreak@7
|
31 }
|
flickerstreak@7
|
32
|
flickerstreak@7
|
33
|
flickerstreak@7
|
34 -- private variables
|
flickerstreak@7
|
35 local hotKeyDefaultColor = { r=1.00, g=1.00, b=1.00, a=1.00 } -- white
|
flickerstreak@7
|
36 local hotKeyDisabledColor = { r=0.60, g=0.60, b=0.60, a=1.00 } -- 60% gray
|
flickerstreak@7
|
37 local hotKeyOutOfRangeColor = { r=1.00, g=0.20, b=0.20, a=1.00 } -- red
|
flickerstreak@7
|
38
|
flickerstreak@7
|
39 local actionUsableColor = { r=1.00, g=1.00, b=1.00, a=1.00 } -- white
|
flickerstreak@7
|
40 local actionNotUsableColor = { r=0.40, g=0.40, b=0.40, a=1.00 } -- 40% gray
|
flickerstreak@7
|
41 local actionNotEnoughManaColor = { r=0.20, g=0.20, b=0.70, a=1.00 } -- medium blue
|
flickerstreak@7
|
42 local actionOutOfRangeColor = { r=1.00, g=0.20, b=0.20, a=1.00 } -- red
|
flickerstreak@7
|
43
|
flickerstreak@7
|
44 local hotKeyModifierColors = {
|
flickerstreak@7
|
45 S = { r=0.60, g=0.60, b=1.00, a=1.00 }, -- shift (blue)
|
flickerstreak@7
|
46 C = { r=1.00, g=0.82, b=0.00, a=1.00 }, -- ctrl (gold)
|
flickerstreak@7
|
47 A = { r=0.10, g=1.00, b=0.10, a=1.00 }, -- alt (green)
|
flickerstreak@7
|
48 M = { r=0.90, g=0.30, b=1.00, a=1.00 }, -- mouse (purple)
|
flickerstreak@7
|
49 }
|
flickerstreak@7
|
50
|
flickerstreak@7
|
51 -- build list of modifier keys (as a string) from table above
|
flickerstreak@7
|
52 local hotKeyModifiers = ""
|
flickerstreak@7
|
53 for k, _ in pairs(hotKeyModifierColors) do
|
flickerstreak@7
|
54 hotKeyModifiers = hotKeyModifiers..k
|
flickerstreak@7
|
55 end
|
flickerstreak@7
|
56
|
flickerstreak@7
|
57 -- private functions
|
flickerstreak@7
|
58 -- extract and return color fields from a table, to be fed into SetVertexColor()/SetTextColor()
|
flickerstreak@7
|
59 local function tcolor(c)
|
flickerstreak@7
|
60 return c.r, c.g, c.b, c.a
|
flickerstreak@7
|
61 end
|
flickerstreak@7
|
62
|
flickerstreak@7
|
63
|
flickerstreak@7
|
64
|
flickerstreak@7
|
65 -- mixin methods
|
flickerstreak@7
|
66
|
flickerstreak@7
|
67 local RADCS = ReAction.DefaultColorScheme
|
flickerstreak@7
|
68
|
flickerstreak@7
|
69 function RADCS:GetHotkeyColor( isUsable, notEnoughMana, outOfRange, bindingTxt )
|
flickerstreak@7
|
70 if isUsable or notEnoughMana then
|
flickerstreak@7
|
71 return tcolor(self:GetModifiedHotkeyColor(bindingTxt))
|
flickerstreak@7
|
72 elseif outOfRange then
|
flickerstreak@7
|
73 return tcolor(hotKeyOutOfRangeColor)
|
flickerstreak@7
|
74 else
|
flickerstreak@7
|
75 return tcolor(hotKeyDisabledColor)
|
flickerstreak@7
|
76 end
|
flickerstreak@7
|
77 end
|
flickerstreak@7
|
78
|
flickerstreak@7
|
79 function RADCS:GetModifiedHotkeyColor(txt)
|
flickerstreak@7
|
80 local c = hotKeyDefaultColor
|
flickerstreak@7
|
81 if txt and self.config.keyBindColorCode then
|
flickerstreak@7
|
82 local modKey = string.match( txt or "", "(["..hotKeyModifiers.."])%-")
|
flickerstreak@7
|
83 c = modKey and hotKeyModifierColors[modKey] or c
|
flickerstreak@7
|
84 end
|
flickerstreak@7
|
85 return c
|
flickerstreak@7
|
86 end
|
flickerstreak@7
|
87
|
flickerstreak@7
|
88 function RADCS:GetIconColor( isUsable, notEnoughMana, outOfRange )
|
flickerstreak@7
|
89 if isUsable then
|
flickerstreak@7
|
90 return tcolor(actionUsableColor)
|
flickerstreak@7
|
91 elseif notEnoughMana then
|
flickerstreak@7
|
92 return tcolor(actionNotEnoughManaColor)
|
flickerstreak@7
|
93 elseif outOfRange then
|
flickerstreak@7
|
94 return tcolor(actionOutOfRangeColor)
|
flickerstreak@7
|
95 else
|
flickerstreak@7
|
96 return tcolor(actionNotUsableColor)
|
flickerstreak@7
|
97 end
|
flickerstreak@7
|
98 end
|
flickerstreak@7
|
99
|
flickerstreak@7
|
100 function RADCS:GetBorderColor( isUsable, notEnoughMana, outOfRange )
|
flickerstreak@7
|
101 if isUsable or notEnoughMana or outOfRange then
|
flickerstreak@7
|
102 return tcolor(actionUsableColor)
|
flickerstreak@7
|
103 else
|
flickerstreak@7
|
104 return tcolor(actionNotUsableColor)
|
flickerstreak@7
|
105 end
|
flickerstreak@7
|
106 end
|
flickerstreak@7
|
107
|