mirror of
https://github.com/Lacustat/Freewood-OctoWoW-Core.git
synced 2026-11-04 08:16:56 +00:00
0.1.235: Kanaele: Linksklick auf Chatblase oeffnet verlinktes Item (Tooltip beim Darueberfahren), Rechtsklick-Menue mit Nachricht kopieren und Spieleraktionen [ungeprueft]
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
c6ce03ba60
commit
6c4bcb3e83
@@ -3,7 +3,7 @@
|
||||
## Notes: Base addon of the Freewood family: data storage, UI kit, export/import and the main window.
|
||||
## Notes-deDE: Basis-Addon der Freewood-Familie: Datenspeicher, UI-Bausteine, Export/Import und Hauptfenster.
|
||||
## Author: Lacustat
|
||||
## Version: 0.1.234
|
||||
## Version: 0.1.235
|
||||
## SavedVariables: FreewoodDB
|
||||
## SavedVariablesPerCharacter: FreewoodCharDB
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ FW:AddLocale("enUS", {
|
||||
CHAT_ONLINE_HDR = "Online",
|
||||
CHAT_DATA = "Data channel of the Freewood modules (protocol data, no chat). The members are shown on the right.",
|
||||
CHAT_COPY_MSG = "Message",
|
||||
CHAT_COPY_HINT_SHORT = "- copy",
|
||||
CHAT_COPY_LINK = "Link",
|
||||
CHAT_COPY_HINT = "Ctrl+C copies, Esc closes.",
|
||||
CHAT_MENU_FRIEND = "Add friend",
|
||||
@@ -239,6 +240,7 @@ FW:AddLocale("deDE", {
|
||||
CHAT_ONLINE_HDR = "Online",
|
||||
CHAT_DATA = "Datenkanal der Freewood-Module (Protokolldaten, kein Chat). Die Mitglieder siehst du rechts.",
|
||||
CHAT_COPY_MSG = "Nachricht",
|
||||
CHAT_COPY_HINT_SHORT = "kopieren",
|
||||
CHAT_COPY_LINK = "Link",
|
||||
CHAT_COPY_HINT = "Strg+C kopiert, Esc schließt.",
|
||||
CHAT_MENU_FRIEND = "Freund hinzufügen",
|
||||
|
||||
+72
-1
@@ -860,6 +860,45 @@ local function Build(content)
|
||||
|
||||
local function Plain(t) return CL.Plain(t) end
|
||||
|
||||
-- Links (Items, Quests, Zauber) aus einer Nachricht holen und anzeigen
|
||||
local function ParseLinks(text)
|
||||
local out = {}
|
||||
local pos = 1
|
||||
text = text or ""
|
||||
while true do
|
||||
local a, b, data, name = string.find(text, "|H([^|]+)|h%[(.-)%]|h", pos)
|
||||
if not a then break end
|
||||
out[table.getn(out) + 1] = { data = data, name = name }
|
||||
pos = b + 1
|
||||
if table.getn(out) >= 8 then break end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local function ShowLink(lk)
|
||||
local full = "|cffffffff|H" .. lk.data .. "|h[" .. lk.name .. "]|h|r"
|
||||
if SetItemRef then pcall(SetItemRef, lk.data, full, "LeftButton") end
|
||||
end
|
||||
|
||||
-- Rechtsklick auf eine Blase: Nachricht kopieren plus Spieleraktionen
|
||||
local function MsgMenu(sender, msg, url)
|
||||
local items = {}
|
||||
local function Add(t, fn) items[table.getn(items) + 1] = { t, fn } end
|
||||
Add(L.CHAT_COPY_MSG .. " " .. L.CHAT_COPY_HINT_SHORT, function() ShowCopy(msg, url) end)
|
||||
if url then Add(L.CHAT_COPY_LINK, function() ShowCopy(url, nil) end) end
|
||||
Add(L.CHAN_WHISPER, function()
|
||||
CL.OpenWhisper(sender)
|
||||
selectKey("w:" .. sender)
|
||||
input:SetFocus()
|
||||
end)
|
||||
Add(L.CHAN_INVITE, function() Ch.Invite(sender) end)
|
||||
Add(L.CHAN_IGNORE, function() Ch.Ignore(sender) end)
|
||||
Add(L.CHAT_MENU_FRIEND, function() if _G.AddFriend then pcall(_G.AddFriend, sender) end end)
|
||||
Add(L.CHAT_MENU_WHO, function() CL.Ask(sender, true) end)
|
||||
Add(L.CHAT_MENU_COPY, function() ShowCopy(sender, nil) end)
|
||||
ShowList(sender, items)
|
||||
end
|
||||
|
||||
local function DrawBubbles(key)
|
||||
local lines = CL.Lines(key) or {}
|
||||
local n = table.getn(lines)
|
||||
@@ -935,11 +974,43 @@ local function Build(content)
|
||||
end
|
||||
local msg, sender = Plain(txt), who
|
||||
local url = CL.FirstUrl(txt)
|
||||
local links = ParseLinks(txt)
|
||||
local nl = table.getn(links)
|
||||
b.avBtn:SetScript("OnClick", function() ShowMenu(sender) end)
|
||||
b.panel:SetScript("OnClick", function(_, btn)
|
||||
btn = btn or arg1
|
||||
if btn == "RightButton" then ShowMenu(sender) else ShowCopy(msg, url) end
|
||||
if btn == "RightButton" then
|
||||
MsgMenu(sender, msg, url)
|
||||
elseif nl == 1 then
|
||||
ShowLink(links[1])
|
||||
elseif nl > 1 then
|
||||
local its, q = {}, 1
|
||||
while q <= nl do
|
||||
local lk = links[q]
|
||||
its[q] = { "[" .. lk.name .. "]", function() ShowLink(lk) end }
|
||||
q = q + 1
|
||||
end
|
||||
ShowList(sender, its)
|
||||
else
|
||||
ShowCopy(msg, url)
|
||||
end
|
||||
end)
|
||||
if nl == 1 then
|
||||
local lk = links[1]
|
||||
b.panel:SetScript("OnEnter", function()
|
||||
if GameTooltip then
|
||||
pcall(GameTooltip.SetOwner, GameTooltip, b.panel, "ANCHOR_RIGHT")
|
||||
pcall(GameTooltip.SetHyperlink, GameTooltip, lk.data)
|
||||
pcall(GameTooltip.Show, GameTooltip)
|
||||
end
|
||||
end)
|
||||
b.panel:SetScript("OnLeave", function()
|
||||
if GameTooltip then pcall(GameTooltip.Hide, GameTooltip) end
|
||||
end)
|
||||
else
|
||||
b.panel:SetScript("OnEnter", nil)
|
||||
b.panel:SetScript("OnLeave", nil)
|
||||
end
|
||||
b:Show()
|
||||
y = y + rowH + 8
|
||||
i = i + 1
|
||||
|
||||
Reference in New Issue
Block a user