comparison gui.lua @ 86:703bbe61d12d

Proper class coloring in one place.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 21 Jun 2012 21:14:24 +0000
parents c87bf3e756f3
children 9fea75b0927b
comparison
equal deleted inserted replaced
85:4771ee8eaa81 86:703bbe61d12d
85 local tabs_OnGroupSelected = {} 85 local tabs_OnGroupSelected = {}
86 local mkbutton 86 local mkbutton
87 local tabs_OnGroupSelected_func, tabs_generated_text_OGS 87 local tabs_OnGroupSelected_func, tabs_generated_text_OGS
88 -- Similarly for the popup tips on the right side of the window. 88 -- Similarly for the popup tips on the right side of the window.
89 local noob_tips = {} 89 local noob_tips = {}
90
91 -- Class color support
92 local class_colors-- = {}
93 do
94 local function fill_out_class_colors()
95 class_colors = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS
96 -- If we were dependant on lib-st calling this function (via a
97 -- 'color' field in eoi_st_cols[2]), then this would have to be deep
98 -- copied and an "a=1" field added to each. But as we have to use
99 -- this ourselves via DoCellUpdate, we can just share tables and
100 -- pass an alpha value manually during cell update.
101 --for class,color in pairs(CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS) do
102 -- class_colors[class] = { r = color.r, g = color.g, b = color.b, a = 1 }
103 --end
104 end
105 fill_out_class_colors()
106 if CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS.RegisterCallback then
107 CUSTOM_CLASS_COLORS:RegisterCallback(fill_out_class_colors)
108 end
109 addon.class_colors = class_colors
110 end
111 90
112 do 91 do
113 local replacement_colors = { 92 local replacement_colors = {
114 ["+"]="|cffffffff", -- white 93 ["+"]="|cffffffff", -- white
115 ["<"]="|cff00ff00", -- light green 94 ["<"]="|cff00ff00", -- light green
446 -- table arguments to the lib-st routines (thus 'e' locals). 425 -- table arguments to the lib-st routines (thus 'e' locals).
447 local dotcols = new (col1, col2, col3) 426 local dotcols = new (col1, col2, col3)
448 local st_entry = new() 427 local st_entry = new()
449 st_entry.kind = 'hist' 428 st_entry.kind = 'hist'
450 st_entry.OLwho = player.name 429 st_entry.OLwho = player.name
430 st_entry.OLclass = player.person_class
451 st_entry.cols = dotcols 431 st_entry.cols = dotcols
452 st_entry.itemlink = ilink -- for onenter and onclick 432 st_entry.itemlink = ilink -- for onenter and onclick
453 tinsert (st, st_entry) 433 tinsert (st, st_entry)
454 end 434 end
455 end 435 end
854 addon:Print("Removed %s.", 834 addon:Print("Removed %s.",
855 gone.itemlink or gone.bossname or gone.startday.text) 835 gone.itemlink or gone.bossname or gone.startday.text)
856 if gone.kind == 'loot' and IsShiftKeyDown() then 836 if gone.kind == 'loot' and IsShiftKeyDown() then
857 local okay,err = addon:_delHistoryEntry (gone) 837 local okay,err = addon:_delHistoryEntry (gone)
858 if okay then 838 if okay then
859 addon:Print("Removed history entry %s from '%s'.", 839 addon:Print("Removed history entry %s from %s.",
860 gone.itemlink, gone.person) 840 gone.itemlink, addon:colorize(gone.person,gone.person_class))
861 else 841 else
862 addon:Print(err) 842 addon:Print(err)
863 end 843 end
864 end 844 end
865 end, 845 end,
1235 cellFrame.icontexture = icon 1215 cellFrame.icontexture = icon
1236 end 1216 end
1237 icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[e.person_class])) 1217 icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[e.person_class]))
1238 icon:Show() 1218 icon:Show()
1239 cellFrame.text:SetPoint("LEFT", icon, "RIGHT", 1, 0) 1219 cellFrame.text:SetPoint("LEFT", icon, "RIGHT", 1, 0)
1240 local color = class_colors[e.person_class] 1220 local color = addon.class_colors[e.person_class]
1241 cellFrame.text:SetTextColor(color.r,color.g,color.b,1) 1221 cellFrame.text:SetTextColor(color.r,color.g,color.b,1)
1242 else 1222 else
1243 if cellFrame.icontexture then 1223 if cellFrame.icontexture then
1244 cellFrame.icontexture:Hide() 1224 cellFrame.icontexture:Hide()
1245 cellFrame.text:SetPoint("LEFT", cellFrame, "LEFT") 1225 cellFrame.text:SetPoint("LEFT", cellFrame, "LEFT")
1525 hist_dropdownfuncs = dropdownfuncs{ 1505 hist_dropdownfuncs = dropdownfuncs{
1526 ["Delete this loot event from history"] = function(rowi) 1506 ["Delete this loot event from history"] = function(rowi)
1527 local h = _d:GetUserData("DD history entry") 1507 local h = _d:GetUserData("DD history entry")
1528 local okay,err = addon:_delHistoryEntry (h.cols[2].OLu, h.itemlink) 1508 local okay,err = addon:_delHistoryEntry (h.cols[2].OLu, h.itemlink)
1529 if okay then 1509 if okay then
1530 addon:Print("Removed history entry %s from '%s'.", 1510 addon:Print("Removed history entry %s from %s.",
1531 h.itemlink, h.OLwho) 1511 h.itemlink, addon:colorize(h.OLwho,h.OLclass))
1532 else 1512 else
1533 addon:Print(err) 1513 addon:Print(err)
1534 end 1514 end
1535 end, 1515 end,
1536 1516
1539 local name = h.OLwho 1519 local name = h.OLwho
1540 local player_i = addon.history.byname[name] 1520 local player_i = addon.history.byname[name]
1541 local gone = tremove (addon.history, player_i) 1521 local gone = tremove (addon.history, player_i)
1542 assert(gone.name == name) 1522 assert(gone.name == name)
1543 addon:_build_history_names() 1523 addon:_build_history_names()
1544 addon:Print("Removed player '%s' from history (%d total entries).", 1524 addon:Print("Removed player %s from history (%d total entries).",
1545 name, #gone.unique) 1525 addon:colorize(name,gone.person_class), #gone.unique)
1546 end, 1526 end,
1547 } 1527 }
1548 local hist_general_dropdown = gen_easymenu_table( 1528 local hist_general_dropdown = gen_easymenu_table(
1549 {{ 1529 {{
1550 -- this is the dropdown title, text filled in on the fly 1530 -- this is the dropdown title, text filled in on the fly