-
Notifications
You must be signed in to change notification settings - Fork 0
WIdgtetText Example
[pre] local LibCore = LibStub("LibScriptableLCDCoreLite-1.0") local WidgetText = LibStub("LibScriptableWidgetText-1.0")
-- Create a text that we'll "draw" on. aka, text:SetText() local ctx = UI.CreateContext("My Context") local text = UI.CreateFrame("Text", "My Text", ctx) text:SetPoint("CENTER", UIParent, "CENTER") text:SetVisible(true) text:SetFontSize(50) text:SetBackgroundColor(0, 0, 0, 1)
-- Create our "core" object. -- This just simply fills "envrionment" with plugin functions. local environment = {} local visitor = LibCore:New(environment, "My Core")
-- First we give it a name, then a config. -- This is a 1 second repeating widget. local name = "My Widget" local config = { value="return floor(rand(100))", -- This is your Lua script. color="return ClassColor(unit)", -- unit is provided by widget:Start("player")
repeating = true, -- This widget repeats till widget:Stop() is called.
update = 1000, -- Update at 1 second intervals
} local col, row, layer = 0, 0, 0 -- These are for convenience and optional. local errorLevel = 3 -- Most verbose.
-- we provide the widget with a "draw" callback. -- This is called at the end of each refresh. In our case, every second. local function callback(widget) text:SetText(widget.buffer or "") text:ResizeToText() text:SetFontColor(widget.color.ret1, widget.color.ret2, widget.color.ret3) end
-- Create the widget local widget = WidgetText:New(visitor, name, config, row, col, layer, errorLevel, callback)
-- Make sure player's available before calling ClassColor(unit). table.insert(Event.Unit.Available, { function() widget:Start("player") end, "RotLatency", "System loaded..."}) [/pre]