Mercurial > wow > squawk
comparison Squawk.lua @ 16:6c28e55a00cf
hmm
| author | wobin |
|---|---|
| date | Sat, 02 May 2009 23:54:32 +1000 |
| parents | 9e61a930b822 |
| children | 2a73deb7bc54 |
comparison
equal
deleted
inserted
replaced
| 15:9e61a930b822 | 16:6c28e55a00cf |
|---|---|
| 442 return date("%I:%M %p %b %d", stime) | 442 return date("%I:%M %p %b %d", stime) |
| 443 end | 443 end |
| 444 | 444 |
| 445 local LDBFeed = LibStub("LibDataBroker-1.1"):NewDataObject("Squawk", {type = "data source", text = "Awk!"}) | 445 local LDBFeed = LibStub("LibDataBroker-1.1"):NewDataObject("Squawk", {type = "data source", text = "Awk!"}) |
| 446 local QTip = LibStub("LibQTip-1.0") | 446 local QTip = LibStub("LibQTip-1.0") |
| 447 local QTipClick = LibStub("LibQTipClick-1.0") | |
| 448 local tooltip = {} | |
| 449 | |
| 450 local function HideTooltip() | |
| 451 if MouseIsOver(tooltip) then return end | |
| 452 tooltip:SetScript("OnLeave", nil) | |
| 453 tooltip:Hide() | |
| 454 QTip:Release(tooltip) | |
| 455 tooltip = nil | |
| 456 end | |
| 457 | |
| 458 local function ReplyToMe(cell, Owner, event) | |
| 459 View:Print("Replying to @"..Owner) | |
| 460 end | |
| 447 | 461 |
| 448 local function AddLine(tooltip, Line, Number, Owner, TimeStamp) | 462 local function AddLine(tooltip, Line, Number, Owner, TimeStamp) |
| 463 local x,y | |
| 449 if #Line < 79 then | 464 if #Line < 79 then |
| 450 tooltip:AddLine(Number, Owner, Line, TimeStamp) | 465 y,x = tooltip:AddNormalLine(Number, Owner, Line, TimeStamp) |
| 451 else | 466 else |
| 452 tooltip:AddLine(Number, Owner, Line:sub(1, 80).."-", TimeStamp) | 467 y,x = tooltip:AddNormalLine(Number, Owner, Line:sub(1, 80).."-", TimeStamp) |
| 453 AddLine(tooltip, Line:sub(81)) | 468 AddLine(tooltip, Line:sub(81)) |
| 454 end | 469 end |
| 470 if not TimeStamp then return end | |
| 471 | |
| 472 -- Now add the reply clickback | |
| 473 tooltip:SetCell(y, 5, " ", Owner) | |
| 474 tooltip.lines[y].cells[5]:SetBackdrop({bgFile= "Interface\\Addons\\Squawk\\reply"}) | |
| 475 if not tooltip.lines[y].cells[5]:GetScript("OnHide") then | |
| 476 tooltip.lines[y].cells[5]:SetScript("OnHide", function(self) self:SetBackdrop(nil) self:SetScript("OnHide", nil) end) | |
| 477 end | |
| 478 -- Reply clickback finished | |
| 455 end | 479 end |
| 456 | 480 |
| 457 function LDBFeed:OnEnter() | 481 function LDBFeed:OnEnter() |
| 458 local tooltip = QTip:Acquire("Squawk",4, "LEFT", "LEFT", "LEFT", "RIGHT") | 482 tooltip = QTipClick:Acquire("Squawk",5, "LEFT", "CENTER", "LEFT", "RIGHT", "RIGHT") |
| 483 tooltip:Clear() | |
| 484 tooltip:SetCallback("OnMouseDown", ReplyToMe) | |
| 459 self.tooltip = tooltip | 485 self.tooltip = tooltip |
| 460 tooltip:AddHeader('Squawk') | 486 for i,squawk in ipairs(Squawk:GetLast10(Model.Squawks)) do |
| 461 for i,squawk in ipairs(Squawk:GetLast10()) do | |
| 462 if #squawk.Message > 79 then | |
| 463 local head = true | 487 local head = true |
| 464 local message = {strsplit("\n",squawk.Message)} | 488 local message = {strsplit("\n",squawk.Message)} |
| 465 for _,line in ipairs(message) do | 489 for _,line in ipairs(message) do |
| 466 if head then | 490 if head then |
| 467 AddLine(tooltip, line, i..".", squawk.Owner, View:GetTime(squawk.Time)) | 491 AddLine(tooltip, line, i..".", squawk.Owner, View:GetTime(squawk.Time)) |
| 468 head = false | 492 head = false |
| 469 else | 493 else |
| 470 AddLine(tooltip, line) | 494 AddLine(tooltip, line) |
| 471 end | 495 end |
| 472 end | 496 end |
| 473 else | |
| 474 tooltip:AddLine(i..".", squawk.Owner, squawk.Message, View:GetTime(squawk.Time)) | |
| 475 end | |
| 476 end | 497 end |
| 477 tooltip:SmartAnchorTo(self) | 498 tooltip:SmartAnchorTo(self) |
| 499 tooltip:SetScript("OnLeave", HideTooltip) | |
| 478 tooltip:Show() | 500 tooltip:Show() |
| 479 end | 501 end |
| 480 | 502 |
| 481 function LDBFeed:OnTooltipShow() | |
| 482 end | |
| 483 | |
| 484 function LDBFeed:OnLeave() | 503 function LDBFeed:OnLeave() |
| 485 QTip:Release(self.tooltip) | 504 HideTooltip() |
| 486 end | 505 end |
| 506 --[[ | |
| 507 | |
| 508 function LDBFeed:OnClick(button) | |
| 509 editbox:ClearAllPoints() | |
| 510 editbox:SetPoint(GetTipAnchor(self)) | |
| 511 editbox:Show() | |
| 512 end | |
| 513 | |
| 514 local function GetTipAnchor(frame) | |
| 515 if not x or not y then return "TOPLEFT", frame, "BOTTOMLEFT" end | |
| 516 local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or "" | |
| 517 local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM" | |
| 518 return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf | |
| 519 end | |
| 520 | |
| 521 local editbox = CreateFrame('EditBox', nil, UIParent) | |
| 522 editbox:Hide() | |
| 523 editbox:SetAutoFocus(true) | |
| 524 editbox:SetHeight(32) | |
| 525 editbox:SetWidth(350) | |
| 526 editbox:SetFrameStrata("HIGH") | |
| 527 editbox:SetFontObject('GameFontHighlightSmall') | |
| 528 lib.editbox = editbox | |
| 529 | |
| 530 editbox:SetScript("OnEscapePressed", editbox.ClearFocus) | |
| 531 editbox:SetScript("OnEnterPressed", editbox.ClearFocus) | |
| 532 editbox:SetScript("OnEditFocusLost", editbox.Hide) | |
| 533 editbox:SetScript("OnEditFocusGained", editbox.HighlightText) | |
| 534 editbox:SetScript("OnTextChanged", function(self) | |
| 535 self:SetText(self:GetParent().val) | |
| 536 self:HighlightText() | |
| 537 end) | |
| 538 | |
| 539 local left = editbox:CreateTexture(nil, "BACKGROUND") | |
| 540 left:SetWidth(8) left:SetHeight(20) | |
| 541 left:SetPoint("LEFT", -5, 0) | |
| 542 left:SetTexture("Interface\\Common\\Common-Input-Border") | |
| 543 left:SetTexCoord(0, 0.0625, 0, 0.625) | |
| 544 | |
| 545 local right = editbox:CreateTexture(nil, "BACKGROUND") | |
| 546 right:SetWidth(8) right:SetHeight(20) | |
| 547 right:SetPoint("RIGHT", 0, 0) | |
| 548 right:SetTexture("Interface\\Common\\Common-Input-Border") | |
| 549 right:SetTexCoord(0.9375, 1, 0, 0.625) | |
| 550 | |
| 551 local center = editbox:CreateTexture(nil, "BACKGROUND") | |
| 552 center:SetHeight(20) | |
| 553 center:SetPoint("RIGHT", right, "LEFT", 0, 0) | |
| 554 center:SetPoint("LEFT", left, "RIGHT", 0, 0) | |
| 555 center:SetTexture("Interface\\Common\\Common-Input-Border") | |
| 556 center:SetTexCoord(0.0625, 0.9375, 0, 0.625) | |
| 557 | |
| 558 function lib.OpenEditbox(self) | |
| 559 editbox:SetText(self.val) | |
| 560 editbox:SetParent(self) | |
| 561 editbox:SetPoint("LEFT", self) | |
| 562 editbox:SetPoint("RIGHT", self) | |
| 563 editbox:Show() | |
| 564 end | |
| 565 --]] | |
| 566 |
