Mercurial > wow > ouroloot
diff gui.lua @ 103:dc8a23a47b03
- Add 'chatprefix' function for building loot line jump links, and a
'PCFPrint' method which displays them.
- Make use of them for local and remote notifications, boss kills,
and manual insertions.
- Document the additional slash commands and args feature from previous
release. Oops. (Text mostly copied from webpage announcement.)
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Sun, 05 Aug 2012 07:26:06 +0000 |
parents | a57133ee3c9b |
children | 04198c8d0717 |
line wrap: on
line diff
--- a/gui.lua Sat Aug 04 22:03:05 2012 +0000 +++ b/gui.lua Sun Aug 05 07:26:06 2012 +0000 @@ -472,9 +472,9 @@ col2.OLi = li col2.OLu = unique local col3 = new() - col3.value = player.when[unique] + col3.value = assert(player.when[unique]) - local id = player.id[unique] + local id = assert(player.id[unique]) local itexture = GetItemIcon(id) local iname, ilink, iquality = GetItemInfo(id) local textured @@ -1084,6 +1084,7 @@ local function eoi_st_OnEnter (rowFrame, cellFrame, data, cols, row, realrow, column, stable, motion) if (row == nil) or (realrow == nil) then return end -- mouseover column header local e = data[realrow] + if e == nil then return end -- something horrible has happened local kind = e.kind local tt = GameTooltip -- can this be hoisted? does GT ever get securely replaced? @@ -1134,12 +1135,17 @@ local function eoi_st_OnLeave (rowFrame, cellFrame, data, cols, row, realrow, column, stable, motion) GameTooltip:Hide() _hide_debugging_tooltip() - if row and realrow and data[realrow].kind ~= 'loot' then - stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[data[realrow].reason or data[realrow].kind]) + if (row == nil) or (realrow == nil) then return false end + + if stable:GetSelection() ~= realrow then + if data[realrow].kind ~= 'loot' then + stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[data[realrow].reason or data[realrow].kind]) + return true -- do not do anything further + else + return false -- continue with default un-highlighting behavior + end + else return true -- do not do anything further - else - --setstatus("") - return false -- continue with default un-highlighting behavior end end @@ -1155,6 +1161,9 @@ return true -- do not do anything further end + -- Zap any jump-to-line highlighting + stable:ClearSelection() + -- Remaining actions are all right-click if button ~= "RightButton" then return true end _d:SetUserData("DD index", realrow) @@ -1259,6 +1268,35 @@ return true -- do not do anything further end +-- Used for anything not overridden elsewhere. +local function eoi_st_default_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable) + if not fShow then + cellFrame.text:SetText("") + if cellFrame.icontexture then + cellFrame.icontexture:Hide() + end + return + end + + local e = data[realrow] + local cell = e.cols[column] + + cellFrame.text:SetText(cell.value) + -- subset of what the default ST's docellupdate looks for + local color = cols[column].color and cols[column].color(data,cols,realrow,column,stable) + if color then + cellFrame.text:SetTextColor(color.r,color.g,color.b,color.a) + else + cellFrame.text:SetTextColor(1,1,1,1) + end + + if stable:GetSelection() ~= realrow then + stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[e.reason or e.kind or ""]) + else + stable:SetHighLightColor (rowFrame, stable:GetDefaultHighlight()) + end +end + -- Used for EOI column 2 and Hist column 1. Both are player name columns. local function eoi_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable) if not fShow then @@ -1299,11 +1337,11 @@ cellFrame.text:SetTextColor(1,1,1,1) end - --if e.kind ~= 'loot' then + if stable:GetSelection() ~= realrow then stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[e.reason or e.kind or ""]) - --else - -- stable:SetHighLightColor (rowFrame, table:GetDefaultHighlightBlank()) - --end + else + stable:SetHighLightColor (rowFrame, stable:GetDefaultHighlight()) + end end local eoi_st_cols = { @@ -1346,6 +1384,7 @@ _G.OLST = ST end + ST.DoCellUpdate = eoi_st_default_DoCellUpdate if not eoi_st_otherrow_bgcolortable_default then eoi_st_otherrow_bgcolortable_default = ST:GetDefaultHighlightBlank() setmetatable(eoi_st_otherrow_bgcolortable, {__index = function (bg, key) @@ -1367,6 +1406,7 @@ end -- safety check end ST:SetData(g_loot) + ST:EnableSelection(true) ST:RegisterEvents{ OnEnter = eoi_st_OnEnter, OnLeave = eoi_st_OnLeave, @@ -1488,10 +1528,32 @@ <Right>-click any row to display a dropdown menu. The menu is different for the Player column than it is for the Item/Notes columns, and different for -loot entries than it is for other rows.]] ---tabs_CLI_special["eoi"] = function (name) --- -- try and scroll to a specific boss/player? ---end +loot entries than it is for other rows. + +A normal click on a line will remove any highlighting from opening the +display from a chat link.]] +tabs_CLI_special["eoi"] = function (name_or_lineno) + if type(name_or_lineno) == 'string' then + -- uh + elseif type(name_or_lineno) == 'number' then + if name_or_lineno < 1 or name_or_lineno > #g_loot then + return + end + local scrollhere = -9 + repeat + scrollhere = scrollhere + 10 + gui.eoiST.offset = scrollhere + until gui.eoiST:RowIsVisible(name_or_lineno) + -- Value must be in pixels, not "how many rows" + scrollhere = scrollhere * eoi_st_rowheight + -- But not past the bottom, it looks ugly + scrollhere = math.min (scrollhere, + (#gui.eoiST.filtered - eoi_st_displayed_rows) * eoi_st_rowheight) + gui.eoiST:SetSelection(name_or_lineno) + local sf = gui.eoiST.scrollframe + sf:GetScript("OnVerticalScroll")(sf,scrollhere) + end +end -- Tab 2/3 (generated text) @@ -2219,6 +2281,11 @@ tabs_OnGroupSelected_func (unpack(tabs_OnGroupSelected_func_args)) end +function addon:GoToLootLine (line) + local lineno = tonumber(self.lootjumps[line]) + self:OpenMainDisplayToTab ("Loot", lineno) +end + ------ Popup dialogs local function build_my_slider_widget() @@ -2400,8 +2467,11 @@ tinsert(g_loot,data.rowindex,entry) addon:_mark_boss_kill(data.rowindex) gui.eoiST:OuroLoot_Refresh(data.rowindex) + local jumpprefix = addon.chatprefix ("GoToLootLine", data.rowindex) dialog.data = nil -- free up memory - addon:Print("Inserted %s %s at entry %d.", data.kind, data.name, data.rowindex) + addon:PCFPrint (_G.DEFAULT_CHAT_FRAME, jumpprefix, + "Inserted %s %s at entry %d.", + data.kind, data.name, data.rowindex) return end @@ -2452,8 +2522,10 @@ addon:_fill_out_eoi_data(data.rowindex) addon:BuildMainDisplay() local clicky = _new_rebroadcast_hyperlink (entry.unique) + local jumpprefix = addon.chatprefix ("GoToLootLine", data.rowindex) dialog.data = nil - addon:Print ("Inserted %s %s at entry %d. %s", + addon:PCFPrint (_G.DEFAULT_CHAT_FRAME, jumpprefix, + "Inserted %s %s at entry %d. %s", data.kind, data.name, data.rowindex, tostring(clicky)) return end