comparison 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
comparison
equal deleted inserted replaced
102:fe04f5c4114a 103:dc8a23a47b03
470 for li,unique in ipairs(player.unique) do 470 for li,unique in ipairs(player.unique) do
471 local col2 = new() 471 local col2 = new()
472 col2.OLi = li 472 col2.OLi = li
473 col2.OLu = unique 473 col2.OLu = unique
474 local col3 = new() 474 local col3 = new()
475 col3.value = player.when[unique] 475 col3.value = assert(player.when[unique])
476 476
477 local id = player.id[unique] 477 local id = assert(player.id[unique])
478 local itexture = GetItemIcon(id) 478 local itexture = GetItemIcon(id)
479 local iname, ilink, iquality = GetItemInfo(id) 479 local iname, ilink, iquality = GetItemInfo(id)
480 local textured 480 local textured
481 if itexture and iname then 481 if itexture and iname then
482 textured = eoi_st_textured_item_format:format (itexture, 482 textured = eoi_st_textured_item_format:format (itexture,
1082 ... Any arguments generated by the '''NORMAL''' Blizzard event triggered by the frame are passed as is. 1082 ... Any arguments generated by the '''NORMAL''' Blizzard event triggered by the frame are passed as is.
1083 ]] 1083 ]]
1084 local function eoi_st_OnEnter (rowFrame, cellFrame, data, cols, row, realrow, column, stable, motion) 1084 local function eoi_st_OnEnter (rowFrame, cellFrame, data, cols, row, realrow, column, stable, motion)
1085 if (row == nil) or (realrow == nil) then return end -- mouseover column header 1085 if (row == nil) or (realrow == nil) then return end -- mouseover column header
1086 local e = data[realrow] 1086 local e = data[realrow]
1087 if e == nil then return end -- something horrible has happened
1087 local kind = e.kind 1088 local kind = e.kind
1088 local tt = GameTooltip -- can this be hoisted? does GT ever get securely replaced? 1089 local tt = GameTooltip -- can this be hoisted? does GT ever get securely replaced?
1089 1090
1090 if gui._do_debugging_tooltip and column == 1 and kind ~= 'hist' then 1091 if gui._do_debugging_tooltip and column == 1 and kind ~= 'hist' then
1091 _build_debugging_tooltip (cellFrame, realrow) 1092 _build_debugging_tooltip (cellFrame, realrow)
1132 return false -- continue with default highlighting behavior 1133 return false -- continue with default highlighting behavior
1133 end 1134 end
1134 local function eoi_st_OnLeave (rowFrame, cellFrame, data, cols, row, realrow, column, stable, motion) 1135 local function eoi_st_OnLeave (rowFrame, cellFrame, data, cols, row, realrow, column, stable, motion)
1135 GameTooltip:Hide() 1136 GameTooltip:Hide()
1136 _hide_debugging_tooltip() 1137 _hide_debugging_tooltip()
1137 if row and realrow and data[realrow].kind ~= 'loot' then 1138 if (row == nil) or (realrow == nil) then return false end
1138 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[data[realrow].reason or data[realrow].kind]) 1139
1140 if stable:GetSelection() ~= realrow then
1141 if data[realrow].kind ~= 'loot' then
1142 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[data[realrow].reason or data[realrow].kind])
1143 return true -- do not do anything further
1144 else
1145 return false -- continue with default un-highlighting behavior
1146 end
1147 else
1139 return true -- do not do anything further 1148 return true -- do not do anything further
1140 else
1141 --setstatus("")
1142 return false -- continue with default un-highlighting behavior
1143 end 1149 end
1144 end 1150 end
1145 1151
1146 local function eoi_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, down) 1152 local function eoi_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, down)
1147 if (row == nil) or (realrow == nil) then return true end -- click column header, suppress reordering 1153 if (row == nil) or (realrow == nil) then return true end -- click column header, suppress reordering
1152 if IsModifiedClick("CHATLINK") and kind == 'loot' and column == 1 1158 if IsModifiedClick("CHATLINK") and kind == 'loot' and column == 1
1153 then 1159 then
1154 ChatEdit_InsertLink (e.itemlink) 1160 ChatEdit_InsertLink (e.itemlink)
1155 return true -- do not do anything further 1161 return true -- do not do anything further
1156 end 1162 end
1163
1164 -- Zap any jump-to-line highlighting
1165 stable:ClearSelection()
1157 1166
1158 -- Remaining actions are all right-click 1167 -- Remaining actions are all right-click
1159 if button ~= "RightButton" then return true end 1168 if button ~= "RightButton" then return true end
1160 _d:SetUserData("DD index", realrow) 1169 _d:SetUserData("DD index", realrow)
1161 1170
1257 end 1266 end
1258 1267
1259 return true -- do not do anything further 1268 return true -- do not do anything further
1260 end 1269 end
1261 1270
1271 -- Used for anything not overridden elsewhere.
1272 local function eoi_st_default_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable)
1273 if not fShow then
1274 cellFrame.text:SetText("")
1275 if cellFrame.icontexture then
1276 cellFrame.icontexture:Hide()
1277 end
1278 return
1279 end
1280
1281 local e = data[realrow]
1282 local cell = e.cols[column]
1283
1284 cellFrame.text:SetText(cell.value)
1285 -- subset of what the default ST's docellupdate looks for
1286 local color = cols[column].color and cols[column].color(data,cols,realrow,column,stable)
1287 if color then
1288 cellFrame.text:SetTextColor(color.r,color.g,color.b,color.a)
1289 else
1290 cellFrame.text:SetTextColor(1,1,1,1)
1291 end
1292
1293 if stable:GetSelection() ~= realrow then
1294 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[e.reason or e.kind or ""])
1295 else
1296 stable:SetHighLightColor (rowFrame, stable:GetDefaultHighlight())
1297 end
1298 end
1299
1262 -- Used for EOI column 2 and Hist column 1. Both are player name columns. 1300 -- Used for EOI column 2 and Hist column 1. Both are player name columns.
1263 local function eoi_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable) 1301 local function eoi_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable)
1264 if not fShow then 1302 if not fShow then
1265 cellFrame.text:SetText("") 1303 cellFrame.text:SetText("")
1266 if cellFrame.icontexture then 1304 if cellFrame.icontexture then
1297 cellFrame.text:SetPoint("LEFT", cellFrame, "LEFT") 1335 cellFrame.text:SetPoint("LEFT", cellFrame, "LEFT")
1298 end 1336 end
1299 cellFrame.text:SetTextColor(1,1,1,1) 1337 cellFrame.text:SetTextColor(1,1,1,1)
1300 end 1338 end
1301 1339
1302 --if e.kind ~= 'loot' then 1340 if stable:GetSelection() ~= realrow then
1303 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[e.reason or e.kind or ""]) 1341 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[e.reason or e.kind or ""])
1304 --else 1342 else
1305 -- stable:SetHighLightColor (rowFrame, table:GetDefaultHighlightBlank()) 1343 stable:SetHighLightColor (rowFrame, stable:GetDefaultHighlight())
1306 --end 1344 end
1307 end 1345 end
1308 1346
1309 local eoi_st_cols = { 1347 local eoi_st_cols = {
1310 { -- col 1 1348 { -- col 1
1311 name = "Item", 1349 name = "Item",
1344 gui.eoiST = assert(ST) 1382 gui.eoiST = assert(ST)
1345 if addon.author_debug then 1383 if addon.author_debug then
1346 _G.OLST = ST 1384 _G.OLST = ST
1347 end 1385 end
1348 1386
1387 ST.DoCellUpdate = eoi_st_default_DoCellUpdate
1349 if not eoi_st_otherrow_bgcolortable_default then 1388 if not eoi_st_otherrow_bgcolortable_default then
1350 eoi_st_otherrow_bgcolortable_default = ST:GetDefaultHighlightBlank() 1389 eoi_st_otherrow_bgcolortable_default = ST:GetDefaultHighlightBlank()
1351 setmetatable(eoi_st_otherrow_bgcolortable, {__index = function (bg, key) 1390 setmetatable(eoi_st_otherrow_bgcolortable, {__index = function (bg, key)
1352 return eoi_st_otherrow_bgcolortable_default 1391 return eoi_st_otherrow_bgcolortable_default
1353 end}) 1392 end})
1365 tabledump(e) 1404 tabledump(e)
1366 end 1405 end
1367 end 1406 end
1368 -- safety check end 1407 -- safety check end
1369 ST:SetData(g_loot) 1408 ST:SetData(g_loot)
1409 ST:EnableSelection(true)
1370 ST:RegisterEvents{ 1410 ST:RegisterEvents{
1371 OnEnter = eoi_st_OnEnter, 1411 OnEnter = eoi_st_OnEnter,
1372 OnLeave = eoi_st_OnLeave, 1412 OnLeave = eoi_st_OnLeave,
1373 OnClick = eoi_st_OnClick, 1413 OnClick = eoi_st_OnClick,
1374 OnDoubleClick = eoi_st_OnDoubleClick, 1414 OnDoubleClick = eoi_st_OnDoubleClick,
1486 noob_tips["eoi"] = _markup[[ 1526 noob_tips["eoi"] = _markup[[
1487 <Shift-Left> while over an item link to paste it into chat. 1527 <Shift-Left> while over an item link to paste it into chat.
1488 1528
1489 <Right>-click any row to display a dropdown menu. The menu is different for 1529 <Right>-click any row to display a dropdown menu. The menu is different for
1490 the Player column than it is for the Item/Notes columns, and different for 1530 the Player column than it is for the Item/Notes columns, and different for
1491 loot entries than it is for other rows.]] 1531 loot entries than it is for other rows.
1492 --tabs_CLI_special["eoi"] = function (name) 1532
1493 -- -- try and scroll to a specific boss/player? 1533 A normal click on a line will remove any highlighting from opening the
1494 --end 1534 display from a chat link.]]
1535 tabs_CLI_special["eoi"] = function (name_or_lineno)
1536 if type(name_or_lineno) == 'string' then
1537 -- uh
1538 elseif type(name_or_lineno) == 'number' then
1539 if name_or_lineno < 1 or name_or_lineno > #g_loot then
1540 return
1541 end
1542 local scrollhere = -9
1543 repeat
1544 scrollhere = scrollhere + 10
1545 gui.eoiST.offset = scrollhere
1546 until gui.eoiST:RowIsVisible(name_or_lineno)
1547 -- Value must be in pixels, not "how many rows"
1548 scrollhere = scrollhere * eoi_st_rowheight
1549 -- But not past the bottom, it looks ugly
1550 scrollhere = math.min (scrollhere,
1551 (#gui.eoiST.filtered - eoi_st_displayed_rows) * eoi_st_rowheight)
1552 gui.eoiST:SetSelection(name_or_lineno)
1553 local sf = gui.eoiST.scrollframe
1554 sf:GetScript("OnVerticalScroll")(sf,scrollhere)
1555 end
1556 end
1495 1557
1496 1558
1497 -- Tab 2/3 (generated text) 1559 -- Tab 2/3 (generated text)
1498 function tabs_generated_text_OGS (container, specials, text_kind) 1560 function tabs_generated_text_OGS (container, specials, text_kind)
1499 container:SetLayout("Fill") 1561 container:SetLayout("Fill")
2217 -- Essentially a re-click on the current tab (if the current tab were clickable). 2279 -- Essentially a re-click on the current tab (if the current tab were clickable).
2218 function addon:redisplay () 2280 function addon:redisplay ()
2219 tabs_OnGroupSelected_func (unpack(tabs_OnGroupSelected_func_args)) 2281 tabs_OnGroupSelected_func (unpack(tabs_OnGroupSelected_func_args))
2220 end 2282 end
2221 2283
2284 function addon:GoToLootLine (line)
2285 local lineno = tonumber(self.lootjumps[line])
2286 self:OpenMainDisplayToTab ("Loot", lineno)
2287 end
2288
2222 2289
2223 ------ Popup dialogs 2290 ------ Popup dialogs
2224 local function build_my_slider_widget() 2291 local function build_my_slider_widget()
2225 local s = CreateFrame("Slider", "OuroLootSlider", nil, "OptionsSliderTemplate") 2292 local s = CreateFrame("Slider", "OuroLootSlider", nil, "OptionsSliderTemplate")
2226 s.text = OuroLootSliderText 2293 s.text = OuroLootSliderText
2398 } 2465 }
2399 local entry = tremove(g_loot,boss_index) 2466 local entry = tremove(g_loot,boss_index)
2400 tinsert(g_loot,data.rowindex,entry) 2467 tinsert(g_loot,data.rowindex,entry)
2401 addon:_mark_boss_kill(data.rowindex) 2468 addon:_mark_boss_kill(data.rowindex)
2402 gui.eoiST:OuroLoot_Refresh(data.rowindex) 2469 gui.eoiST:OuroLoot_Refresh(data.rowindex)
2470 local jumpprefix = addon.chatprefix ("GoToLootLine", data.rowindex)
2403 dialog.data = nil -- free up memory 2471 dialog.data = nil -- free up memory
2404 addon:Print("Inserted %s %s at entry %d.", data.kind, data.name, data.rowindex) 2472 addon:PCFPrint (_G.DEFAULT_CHAT_FRAME, jumpprefix,
2473 "Inserted %s %s at entry %d.",
2474 data.kind, data.name, data.rowindex)
2405 return 2475 return
2406 end 2476 end
2407 2477
2408 -- third click 2478 -- third click
2409 if data.name and data.instance then 2479 if data.name and data.instance then
2450 local entry = tremove(g_loot,loot_index) 2520 local entry = tremove(g_loot,loot_index)
2451 tinsert(g_loot,data.rowindex,entry) 2521 tinsert(g_loot,data.rowindex,entry)
2452 addon:_fill_out_eoi_data(data.rowindex) 2522 addon:_fill_out_eoi_data(data.rowindex)
2453 addon:BuildMainDisplay() 2523 addon:BuildMainDisplay()
2454 local clicky = _new_rebroadcast_hyperlink (entry.unique) 2524 local clicky = _new_rebroadcast_hyperlink (entry.unique)
2525 local jumpprefix = addon.chatprefix ("GoToLootLine", data.rowindex)
2455 dialog.data = nil 2526 dialog.data = nil
2456 addon:Print ("Inserted %s %s at entry %d. %s", 2527 addon:PCFPrint (_G.DEFAULT_CHAT_FRAME, jumpprefix,
2528 "Inserted %s %s at entry %d. %s",
2457 data.kind, data.name, data.rowindex, tostring(clicky)) 2529 data.kind, data.name, data.rowindex, tostring(clicky))
2458 return 2530 return
2459 end 2531 end
2460 2532
2461 local text = dialog.editBox:GetText():trim() 2533 local text = dialog.editBox:GetText():trim()