Hiveworkshop· Tasyen·· 2 小时前AI 评分8
TasLog
TasLog
AI 导读
TasLog V2 由 Tasyen 开发,是一款自定义日志 UI 工具,可在多人游戏中向本地玩家显示游戏消息并支持提取到文本编辑器。该工具钩接 DisplayTextToPlayer、DisplayTimedTextToPlayer 与 SetCinematicScene 函数,通过 InitTasLog() 启动后无依赖开箱即用。
正文
if Debug then Debug.beginFile "TasLog" end
--[[ TasLog V2 by Tasyen
Custom Log UI displays game msg to the local player (no player chat), works in Multiplayer.
Can put all msgs into a editbox to get them out into a text editor or something.
hooks
DisplayTextToPlayer
DisplayTimedTextToPlayer
SetCinematicScene
No Dependices, works out of the box after your started it with InitTasLog()
TasLog.Disabled = true, dont add new msgs
--]]
do
local this = {}
this.Texts = {}
this.TextsCount = 0
TasLog = this
local function CreateFrames()
this.Disabled = true -- stop adding text while making the frames
-- TasLog inside the ESC Menu
--this.ParentSuper = BlzCreateFrameByType("FRAME", "TasLogParentSuper", BlzGetFrameByName("InsideMainPanel", 0), "", 0)
-- TasLog inside the normal gameplay Screen
this.ParentSuper = BlzCreateFrameByType("FRAME", "TasLogParentSuper", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
this.ButtonOpen = BlzCreateFrameByType("GLUETEXTBUTTON", "TasLogButtonOpen",this.ParentSuper, "ScriptDialogButton", 0)
this.Parent = BlzCreateFrameByType("FRAME", "TasLogParent", this.ParentSuper, "Leaderboard", 0)
-- size & position of the TasLog display
BlzFrameSetAbsPoint(this.Parent, FRAMEPOINT_TOPRIGHT, 0.79, 0.59)
BlzFrameSetSize(this.Parent, 0.4, 0.35)
-- setup for Open TextButton
BlzFrameSetText(this.ButtonOpen, "TasLog")
BlzFrameSetSize(this.ButtonOpen, 0.1, 0.035)
BlzFrameSetAbsPoint(this.ButtonOpen, FRAMEPOINT_TOPLEFT, 0, 0.57)
this.TextArea = BlzCreateFrameByType("TEXTAREA", "TasLogTextArea", this.Parent, "", 0)
this.ButtonClose = BlzCreateFrameByType("GLUETEXTBUTTON", "TasLogButtonClose",this.Parent, "ScriptDialogButton", 0)
this.ButtonIntoOutput = BlzCreateFrameByType("GLUETEXTBUTTON", "TasLogButtonGenOutPut",this.Parent, "ScriptDialogButton", 0)
this.EditBoxBox = BlzCreateFrameByType("BACKDROP", "TasLogButtonGenOutPutBackdrop",this.Parent, "QuestButtonPushedBackdropTemplate", 0)
this.EditBox = BlzCreateFrameByType("EDITBOX", "TasLogButtonGenOutPut",this.Parent, "", 0)
this.EditBoxTooltip = BlzCreateFrameByType("FRAME", "TasLogParent", this.ParentSuper, "Leaderboard", 0)
this.EditBoxTooltipText = BlzCreateFrameByType("TEXT", "TasLogParent", this.EditBoxTooltip, "", 0)
BlzFrameSetAllPoints(this.TextArea, this.Parent)
BlzFrameSetAllPoints(this.EditBoxBox, this.EditBox)
BlzFrameSetPoint(this.EditBoxTooltip, FRAMEPOINT_TOPLEFT, this.EditBoxTooltipText, FRAMEPOINT_TOPLEFT, -0.01, 0.01)
BlzFrameSetPoint(this.EditBoxTooltip, FRAMEPOINT_BOTTOMRIGHT, this.EditBoxTooltipText, FRAMEPOINT_BOTTOMRIGHT, 0.01, -0.01)
BlzFrameSetTooltip(this.ButtonIntoOutput, this.EditBoxTooltip)
BlzFrameSetPoint(this.EditBoxTooltipText, FRAMEPOINT_BOTTOM, this.ButtonIntoOutput, FRAMEPOINT_TOP, 0, 0)
BlzFrameSetText(this.EditBoxTooltipText, "Click to copy text into the textfield next to the button|ncopy paste Select Editbox ctrl+pos1 shift+ende ctrl+c ctrl+v")
BlzFrameSetText(this.ButtonClose, "X")
BlzFrameSetSize(this.ButtonClose, 0.035, 0.035)
BlzFrameSetPoint(this.ButtonClose, FRAMEPOINT_TOPRIGHT, this.Parent, FRAMEPOINT_TOPRIGHT, 0, 0)
BlzTriggerRegisterFrameEvent(this.TriggerClose, this.ButtonClose, FRAMEEVENT_CONTROL_CLICK)
BlzTriggerRegisterFrameEvent(this.TriggerOpen, this.ButtonOpen, FRAMEEVENT_CONTROL_CLICK)
BlzTriggerRegisterFrameEvent(this.TriggerOutPut, this.ButtonIntoOutput, FRAMEEVENT_CONTROL_CLICK)
BlzFrameSetText(this.ButtonIntoOutput, "Extract")
BlzFrameSetSize(this.ButtonIntoOutput, 0.1, 0.035)
BlzFrameSetSize(this.EditBox, 0.1, 0.035)
BlzFrameSetPoint(this.ButtonIntoOutput, FRAMEPOINT_TOPLEFT, this.Parent, FRAMEPOINT_BOTTOMLEFT, 0, 0)
BlzFrameSetPoint(this.EditBox, FRAMEPOINT_LEFT, this.ButtonIntoOutput, FRAMEPOINT_RIGHT, 0, 0)
BlzFrameSetScale(this.ButtonOpen, 0.7)
BlzFrameSetScale(this.ButtonClose, 0.7)
BlzFrameSetVisible(this.Parent, false)
-- add all texts into the textarea mostly for Save&Load
for i, text in ipairs(this.Texts) do BlzFrameAddText(this.TextArea, text) end
this.Disabled = false -- enable text adding again
end
local function FocusClear()
BlzFrameSetEnable(BlzGetTriggerFrame(), false)
BlzFrameSetEnable(BlzGetTriggerFrame(), true)
end
function InitTasLog()
InitTasLog = DoNothing -- do this only once
this.TriggerClose = CreateTrigger()
TriggerAddAction(this.TriggerClose, function() FocusClear() if GetLocalPlayer() == GetTriggerPlayer() then BlzFrameSetVisible(this.Parent, false) end end)
this.TriggerOpen = CreateTrigger()
TriggerAddAction(this.TriggerOpen, function() FocusClear() if GetLocalPlayer() == GetTriggerPlayer() then BlzFrameSetVisible(this.Parent, not BlzFrameIsVisible(this.Parent)) end end)
this.TriggerOutPut = CreateTrigger()
TriggerAddAction(this.TriggerOutPut, function() FocusClear() if GetLocalPlayer() == GetTriggerPlayer() then BlzFrameSetText(this.EditBox, table.concat(this.Texts, "\n")) end end)
CreateFrames()
-- Save&Load
if FrameLoaderAdd then FrameLoaderAdd(CreateFrames) end
local function AddText(player, text, text2)
text = GetLocalizedString(text) -- convert fixed strings TRIGSTR_005 -> "my real text"
if text2 then
text2 = GetLocalizedString(text2)
text = "|cffffcc00"..text ..":|r " .. text2 -- mimic Transmission display from SetCinematicScene
end
if GetLocalPlayer() == player then
this.TextsCount = this.TextsCount + 1
this.Texts[this.TextsCount] = text
BlzFrameAddText(this.TextArea, text)
end
end
local realDisplayText = DisplayTextToPlayer
function DisplayTextToPlayer(toPlayer, x, y, text)
if not this.Disabled then AddText(toPlayer, text) end
return realDisplayText(toPlayer, x, y, text)
end
local realDisplayTimedText = DisplayTimedTextToPlayer
function DisplayTimedTextToPlayer(toPlayer, x, y, duration, text)
if not this.Disabled then AddText(toPlayer, text) end
return realDisplayTimedText(toPlayer, x, y, duration, text)
end
local realSetCinematicScene = SetCinematicScene
function SetCinematicScene(portraitUnitId, color, speakerTitle, text, sceneDuration, voiceoverDuration)
if not this.Disabled then AddText(GetLocalPlayer(), speakerTitle, text) end
return realSetCinematicScene(portraitUnitId, color, speakerTitle, text, sceneDuration, voiceoverDuration)
end
end
end
if Debug then Debug.endFile() end
--InitTasLog()来源:Hiveworkshop · hiveworkshop.com