怀旧服,猎人标准射击插件!!!

main.lua

local currentVersion = 1.31--Declare all functions used
local CreateFrame = CreateFrame
local UnitGUID = UnitGUID
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
local GetHaste = GetHaste--PUI Dev Functions
local PUI_GenerateFrame = PUI_GenerateFrame        --PUI_GenerateFrame(name)
local PUI_RegisterPanel = PUI_RegisterPanel        --PUI_RegisterPanel(addonID, panelName, parentPanelName)
local PUI_RegisterSlider = PUI_RegisterSlider      --PUI_RegisterSlider(addonID, panelName, sliderID, description, toolTip, width, height, minValue, maxValue, stepValue, decimalPlaces, callback)
local PUI_RegisterCheckBox = PUI_RegisterCheckBox  --PUI_RegisterCheckBox(addonID, "My Addon", "checkboxidxyz", "Checkbox Label", "Stuff happens when you click this checkbox", 25, 25, nil)
local PUI_Round = PUI_Round                    --PUI_Round(num, numDecimalPlaces)--Addon vars
local addonID = "ShotTimer_Classic" --This is required to use PUI Dev (addon ID can be anything, it just must be unique between addons)
local frame = PUI_GenerateFrame("shotTimerFrame")
local playerGUID = UnitGUID("player")local aimedShotString = GetSpellInfo(19434)
local autoShotString = GetSpellInfo(75)
local multiShotString = GetSpellInfo(2643)local shotTimerReload
local shotTimerBackgroundReload
local shotTimerShoot
local shotTimerBackgroundShoot
local shotTimerMultishot
local shotTimerAimedShotlocal reloadTime
local svreloadTime = 0
local shootTime = 0
local multishotTime = 0
local aimedShotTime = 0
local reloadEndTime
local shootEndTime
local multishotEndTime
local aimedShotEndTime
local isReloading
local isShooting
local isMultishotting
local isAimedShottinglocal frameVisible = true
local isInCombat = false
local combatEndTime = GetTime()local quiverHaste = 1.0
local additionalHaste = 1.0local function CalculateShootTimes()if (shotTimerMultishot == nil) thenreturnendlocal width = PA_SHT_DB.vars["width"]local height = PA_SHT_DB.vars["height"]additionalHaste = (100 + GetRangedHaste()) / 100shootTime = ((0.5 / (quiverHaste)) / additionalHaste)multishotTime = shootTimeaimedShotTime = ((3.5 / (quiverHaste)) / additionalHaste)reloadTime = UnitRangedDamage("player") - shootTimeif (svreloadTime ~= reloadTime) then --If reload time changed? This could happen for a variety of reasons including getting a new ranged weapon or on initializationlocal reloadRatio = reloadTime / (reloadTime + shootTime)local shootRatio = shootTime / (reloadTime + shootTime)shotTimerReload:SetWidth(width * reloadRatio)shotTimerBackgroundReload:SetWidth(width * reloadRatio)shotTimerShoot:SetWidth(width * shootRatio)shotTimerBackgroundShoot:SetWidth(width * shootRatio)svreloadTime = reloadTimeendif (reloadTime < 0) thenframe:Hide()elseif (frameVisible) thenframe:Show()endend
endlocal function ResizeFrames()if (shotTimerMultishot == nil) thenreturnendlocal width = PA_SHT_DB.vars["width"]local height = PA_SHT_DB.vars["height"]frame:SetWidth(width)frame:SetHeight(height)shotTimerMultishot:SetHeight(height)shotTimerMultishot:SetWidth(width)shotTimerAimedShot:SetHeight(height)shotTimerAimedShot:SetWidth(width)shotTimerReload:SetHeight(height)shotTimerBackgroundReload:SetHeight(height)shotTimerShoot:SetHeight(height)shotTimerBackgroundShoot:SetHeight(height)
endlocal function SaveFramePosition()local point, relativeTo, relativePoint, xOfs, yOfs = frame:GetPoint()PA_SHT_DB.vars["framePoint"]["point"] = pointPA_SHT_DB.vars["framePoint"]["relativeTo"] = relativeToPA_SHT_DB.vars["framePoint"]["relativePoint"] = relativePointPA_SHT_DB.vars["framePoint"]["xOffset"] = xOfsPA_SHT_DB.vars["framePoint"]["yOffset"] = yOfs
endlocal function UpdateShotFrameColors()local rgba = PA_SHT_DB.vars["multishotRGBA"]shotTimerMultishot:SetStatusBarColor(rgba.r, rgba.g, rgba.b, rgba.a)local rgba = PA_SHT_DB.vars["aimedshotRGBA"]shotTimerAimedShot:SetStatusBarColor(rgba.r, rgba.g, rgba.b, rgba.a)local rgba = PA_SHT_DB.vars["reloadRGBA"]shotTimerReload:SetStatusBarColor(rgba.r, rgba.g, rgba.b, rgba.a)local rgba = PA_SHT_DB.vars["reloadBackgroundRGBA"]shotTimerBackgroundReload:SetStatusBarColor(rgba.r, rgba.g, rgba.b, rgba.a)local rgba = PA_SHT_DB.vars["shootRGBA"]shotTimerShoot:SetStatusBarColor(rgba.r, rgba.g, rgba.b, rgba.a)local rgba = PA_SHT_DB.vars["shootBackgroundRGBA"]shotTimerBackgroundShoot:SetStatusBarColor(rgba.r, rgba.g, rgba.b, rgba.a)
endlocal function GenerateShotTimerFrame()reloadEndTime = GetTime()isReloading = trueisShooting = falseisMultishotting = falseisAimedShotting = falselocal point = PA_SHT_DB.vars["framePoint"]["point"]local relativeTo = PA_SHT_DB.vars["framePoint"]["relativeTo"]local relativePoint = PA_SHT_DB.vars["framePoint"]["relativePoint"]local xOffset = PA_SHT_DB.vars["framePoint"]["xOffset"]local yOffset = PA_SHT_DB.vars["framePoint"]["yOffset"]frame:SetPoint(point, relativeTo, relativePoint, xOffset, yOffset)shotTimerMultishot = CreateFrame("StatusBar", "ShotTimerMultishot", frame)shotTimerMultishot:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)shotTimerMultishot:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")shotTimerMultishot:GetStatusBarTexture():SetHorizTile(false)shotTimerMultishot:GetStatusBarTexture():SetVertTile(false)shotTimerMultishot:SetMinMaxValues(0, 1.0)shotTimerMultishot:SetValue(0.0)shotTimerAimedShot = CreateFrame("StatusBar", "ShotTimerAimedShot", frame)shotTimerAimedShot:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)shotTimerAimedShot:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")shotTimerAimedShot:GetStatusBarTexture():SetHorizTile(false)shotTimerAimedShot:GetStatusBarTexture():SetVertTile(false)shotTimerAimedShot:SetMinMaxValues(0, 1.0)shotTimerAimedShot:SetValue(0)shotTimerReload = CreateFrame("StatusBar", "ShotTimerReload", frame)shotTimerReload:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)shotTimerReload:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")shotTimerReload:GetStatusBarTexture():SetHorizTile(false)shotTimerReload:GetStatusBarTexture():SetVertTile(false)shotTimerReload:SetMinMaxValues(0, 1.0)shotTimerReload:SetValue(1.0)shotTimerBackgroundReload = CreateFrame("StatusBar", "ShotTimerBackgroundReload", frame)shotTimerBackgroundReload:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)shotTimerBackgroundReload:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")shotTimerBackgroundReload:GetStatusBarTexture():SetHorizTile(false)shotTimerBackgroundReload:GetStatusBarTexture():SetVertTile(false)shotTimerBackgroundReload:SetMinMaxValues(0, 1)shotTimerBackgroundReload:SetValue(1.0)shotTimerShoot = CreateFrame("StatusBar", "ShotTimerShoot", frame)shotTimerShoot:SetPoint("TOPLEFT", shotTimerBackgroundReload, "TOPRIGHT", 0, 0)shotTimerShoot:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")shotTimerShoot:GetStatusBarTexture():SetHorizTile(false)shotTimerShoot:GetStatusBarTexture():SetVertTile(false)shotTimerShoot:SetMinMaxValues(0, 1)shotTimerShoot:SetValue(0.0)shotTimerBackgroundShoot = CreateFrame("StatusBar", "ShotTimerBackgroundShoot", frame)shotTimerBackgroundShoot:SetPoint("TOPLEFT", shotTimerBackgroundReload, "TOPRIGHT", 0, 0)shotTimerBackgroundShoot:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")shotTimerBackgroundShoot:GetStatusBarTexture():SetHorizTile(false)shotTimerBackgroundShoot:GetStatusBarTexture():SetVertTile(false)shotTimerBackgroundShoot:SetMinMaxValues(0, 1)shotTimerBackgroundShoot:SetValue(1.0)UpdateShotFrameColors()ResizeFrames()CalculateShootTimes()frame:SetMovable(true)frame:RegisterForDrag("LeftButton")frame:SetClampedToScreen(true)frame:SetScript("OnDragStart", function(self)if not self.isMoving thenself:StartMoving();self.isMoving = true;endend)frame:SetScript("OnDragStop", function(self)if self.isMoving thenself:StopMovingOrSizing();self.isMoving = false;SaveFramePosition()endend)
endlocal function ShowShotFrame()if (frameVisible == false) thenframeVisible = trueframe:Show()endframe:SetAlpha(1)combatEndTime = GetTime()
endlocal deltaTime = 0
local function Addon_OnUpdate(elapsed)deltaTime = deltaTime + elapsedif (deltaTime > 0.01) thenif (PA_SHT_DB.vars["onlyShowInCombat"]) thenif (isInCombat) thenif (frameVisible == false) thenframe:Show()frameVisible = trueendelseif (frameVisible) thenlocal fadeOutTime = PA_SHT_DB.vars["fadeOutTime"]local timeFromExitCombat = GetTime() - combatEndTimelocal alpha = 1-(timeFromExitCombat / fadeOutTime)frame:SetAlpha(alpha)if (timeFromExitCombat > fadeOutTime) thenframe:Hide()frame:SetAlpha(1)frameVisible = falseendendendendif (isReloading) thenlocal t = GetTime()if (t > reloadEndTime) thenisReloading = falseshotTimerReload:SetValue(1.0)elselocal durationLeft = reloadEndTime - tlocal reloadPercentage = 1.0 - (durationLeft)/reloadTimeshotTimerReload:SetValue(reloadPercentage)endendif (isShooting) thenlocal t = GetTime()if (t > shootEndTime) thenisShooting = falseshotTimerShoot:SetValue(0.0)elselocal durationLeft = shootEndTime - tlocal shootPercentage = 1.0 - (durationLeft)/shootTimeshotTimerShoot:SetValue(shootPercentage)endendif (isMultishotting) thenlocal t = GetTime()if (t > multishotEndTime) thenisMultishotting = falseshotTimerMultishot:SetValue(0.0)elselocal durationLeft = multishotEndTime - tlocal shootPercentage = 1.0 - (durationLeft)/multishotTimeshotTimerMultishot:SetValue(shootPercentage)endendif (isAimedShotting) thenlocal t = GetTime()if (t > aimedShotEndTime) thenisAimedShotting = falseshotTimerAimedShot:SetValue(0.0)elselocal durationLeft = aimedShotEndTime - tlocal shootPercentage = 1.0 - (durationLeft)/aimedShotTimeshotTimerAimedShot:SetValue(shootPercentage)endendif (isShooting or isMultishotting or isAimedShotting) thenShowShotFrame()enddeltaTime = 0end
endlocal function CombatLogEventUnfiltered(...)timeStamp, event, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellID, spellName, x3, x4, x5 = CombatLogGetCurrentEventInfo()if (sourceName == nil) thenreturnendif (sourceGUID ~= playerGUID) thenreturnend--print(event)if (event == "SPELL_CAST_START") thenif (spellName == autoShotString) thenisReloading = falseshotTimerReload:SetValue(1)shootEndTime = (GetTime() + shootTime)shotTimerShoot:SetValue(0)isShooting = trueShowShotFrame()endif (spellName == multiShotString) thenCalculateShootTimes()isMultishotting = trueshotTimerMultishot:SetValue(0)multishotEndTime = (GetTime() + multishotTime)ShowShotFrame()endif (spellName == aimedShotString) thenCalculateShootTimes()isAimedShotting = trueshotTimerAimedShot:SetValue(0)aimedShotEndTime = (GetTime() + aimedShotTime)ShowShotFrame()end--print("Start " .. spellName)endif (event == "SPELL_CAST_FAILED") thenif (spellName == autoShotString) thenisShooting = falseshotTimerShoot:SetValue(0)endif (spellName == multiShotString) thenisMultishotting = falseshotTimerMultishot:SetValue(0)endif (spellName == aimedShotString) thenisAimedShotting = falseshotTimerAimedShot:SetValue(0)endendif (event == "SPELL_CAST_SUCCESS") thenif (spellName == autoShotString) thenCalculateShootTimes()isReloading = trueisShooting = falseshotTimerReload:SetValue(0)shotTimerShoot:SetValue(0)reloadEndTime = (GetTime() + reloadTime)endif (spellName == multiShotString) thenisMultishotting = falseshotTimerMultishot:SetValue(0)endif (spellName == aimedShotString) thenisAimedShotting = falseshotTimerAimedShot:SetValue(0)endend
enddefaults = {}
defaults["shotTimerDrag"] = true
defaults["scale"] = 1
defaults["width"] = 200
defaults["height"] = 20
defaults["framePoint"] = {}
defaults["framePoint"]["point"] = "CENTER"
defaults["framePoint"]["relativeTo"] = "UIParent"
defaults["framePoint"]["relativePoint"] = "CENTER"
defaults["framePoint"]["xOffset"] = 0
defaults["framePoint"]["yOffset"] = 0
defaults["reloadBackgroundRGBA"] = {r=0, g=0, b=0, a=0.85}
defaults["shootBackgroundRGBA"] = {r=0, g=0, b=0, a=0.75}
defaults["shootRGBA"] = { r=0.2, g=0.75, b=0.2, a=0.85}
defaults["reloadRGBA"] = { r=0.3, g=0.85, b=0.3, a=0.85}
defaults["multishotRGBA"] = { r=0.7, g=0.2, b=0.7, a=0.85}
defaults["aimedshotRGBA"] = { r=0.85, g=0.85, b=0.2, a=0.65}
defaults["onlyShowInCombat"] = false
defaults["fadeOutTime"] = 5local function HandleVarChange(id)local value = PA_SHT_DB.vars[id]if (id == "shotTimerDrag") thenframe:EnableMouse(value)endif (id == "onlyShowInCombat") thenif (value) thenframe:Show()frameVisible = truecombatEndTime = GetTime()elseframe:Show()frameVisible = trueendendif (id == "scale") thenframe:SetScale(value)endif (id == "width" or id == "height") thensvreloadTime = 0ResizeFrames()CalculateShootTimes()end
endlocal function DBSetup()if (PA_SHT_DB == nil) thenPA_SHT_DB = {}endPA_SHT_DB.version = currentVersionif (PA_SHT_DB.vars == nil) thenPA_SHT_DB.vars = {}endfor k,v in pairs(defaults) doif (PA_SHT_DB.vars[k] == nil) thenPA_SHT_DB.vars[k] = vendend
endlocal function EnteringWorld()if (shotTimerShoot ~= nil) thenreturnendendlocal quiver = {}    --Blizzard's API does not allow me to determine haste from quiver so I have to do it manually.
quiver[2101]  = 1.10 --Light Quiver
quiver[2102]  = 1.10 --Small Ammo Pouch
quiver[2662]  = 1.14 --Ribbly's Quiver
quiver[2663]  = 1.14 --Ribbly's Bandolier
quiver[3573]  = 1.10 --Hunting Quiver
quiver[3574]  = 1.10 --Hunting Ammo Sack
quiver[3604]  = 1.11 --Bandolier of the Night Watch
quiver[3605]  = 1.11 --Quiver of the Night Watch
quiver[5439]  = 1.10 --Small Quiver
quiver[5441]  = 1.10 --Small Shot Pouch
quiver[7278]  = 1.10 --Light Leather Quiver
quiver[7279]  = 1.10 --Small Leather Ammo Pouch
quiver[7371]  = 1.12 --Heavy Quiver
quiver[7372]  = 1.12 --Heavy Leather Ammo Pouch
quiver[8217]  = 1.13 --Quickdraw Quiver
quiver[8218]  = 1.13 --Thick Leather Ammo Pouch
quiver[11362] = 1.10 --Medium Quiver
quiver[11363] = 1.10 --Medium Shot Pouch
quiver[18714] = 1.15 --Ancient Sinew Wrapped Lamina
quiver[19319] = 1.15 --Harpy Hide Quiver
quiver[19320] = 1.15 --Gnoll-Skin Bandolier
local function CalculateQuiverSpeed()quiverHaste = 1.0for i = 1, 4 dolocal invID = ContainerIDToInventoryID(i)  local bagID = GetInventoryItemID("player",invID)if (bagID ~= nil) thenif (quiver[bagID]) thenif (quiverHaste < quiver[bagID]) thenquiverHaste = quiver[bagID]endendendend
endlocal function AddonLoaded(name)if (name ~= "ShotTimer_Classic") thenreturnendDBSetup()local panel = PUI_RegisterPanel(addonID, "Shot Timer")local function Slider_Callback(self, value)value = PUI_Round(value, self.decimalPlaces)self:SetText(self.description .. " [" .. value .. "]")self:SetValue(value)PA_SHT_DB.vars[self.id] = self:GetValue()HandleVarChange(self.id)endPUI_RegisterSlider(addonID, "Shot Timer", "scale", "大小", "Effects the size of the frame.", 200, 20, 0.1, 5, 0.1, 1, Slider_Callback)PUI_RegisterSlider(addonID, "Shot Timer", "width", "宽度", "Effects the width of the frame.", 200, 20, 1, 500, 1, 0, Slider_Callback)PUI_RegisterSlider(addonID, "Shot Timer", "height", "高度", "Effects the height of the frame.", 200, 20, 1, 60, 1, 0, Slider_Callback)local function CheckBox_Callback(self)PA_SHT_DB.vars[self.id] = self:GetChecked()HandleVarChange(self.id)endPUI_RegisterCheckBox(addonID, "Shot Timer", "shotTimerDrag", "解锁", "Enables/disables dragging shot timer.", 20, 20, CheckBox_Callback)PUI_RegisterCheckBox(addonID, "Shot Timer", "onlyShowInCombat", "只在战斗中显示", "If checked, shot timer will only be visible in combat.", 20, 20, CheckBox_Callback)PUI_RegisterSlider(addonID, "Shot Timer", "fadeOutTime", "渐隐时间", "Time in seconds for bar to fade out if bar is hidden outside combat.", 200, 20, 0.1, 10, 0.1, 1, Slider_Callback)   local function ColorPicker_Callback(self)PA_SHT_DB[self.id] = self.rgbaUpdateShotFrameColors()endPUI_RegisterColorPicker(addonID, "Shot Timer", "reloadRGBA", "装弹颜色", "Test tooltip.", 200, 20, ColorPicker_Callback, PA_SHT_DB.vars["reloadRGBA"])PUI_RegisterColorPicker(addonID, "Shot Timer", "shootRGBA", "射出颜色", "Test tooltip.", 200, 20, ColorPicker_Callback, PA_SHT_DB.vars["shootRGBA"])PUI_RegisterColorPicker(addonID, "Shot Timer", "multishotRGBA", "多重射击颜色", "Test tooltip.", 200, 20, ColorPicker_Callback, PA_SHT_DB.vars["multishotRGBA"])PUI_RegisterColorPicker(addonID, "Shot Timer", "aimedshotRGBA", "瞄准射击颜色", "Test tooltip.", 200, 20, ColorPicker_Callback, PA_SHT_DB.vars["aimedshotRGBA"])PUI_RegisterColorPicker(addonID, "Shot Timer", "shootBackgroundRGBA", "射出背景颜色", "Test tooltip.", 200, 20, ColorPicker_Callback, PA_SHT_DB.vars["shootBackgroundRGBA"])PUI_RegisterColorPicker(addonID, "Shot Timer", "reloadBackgroundRGBA", "装弹背景颜色", "Test tooltip.", 200, 20, ColorPicker_Callback, PA_SHT_DB.vars["reloadBackgroundRGBA"])for k,v in pairs(panel.children) doif (v.type == "CHECKBOX") thenv:SetChecked(PA_SHT_DB.vars[v.id])endif (v.type == "SLIDER") thenv:SetValue(PA_SHT_DB.vars[v.id])v:SetText(v.description .. " [" .. v:GetValue() .. "]")endendfor k,v in pairs(PA_SHT_DB.vars) doHandleVarChange(k)endSLASH_ST1 = "/st"SlashCmdList["ST"] = function(msg)if (msg == "reset") thenfor k,v in pairs(defaults) doPA_SHT_DB.vars[k] = vendfor i = 1, 10 do print("Type |c0044DD88/reload" .. "|r to reload your ui for the reset shot timer options.")endelseInterfaceOptionsFrame_OpenToCategory("Shot Timer")InterfaceOptionsFrame_OpenToCategory("Shot Timer")endend endlocal function BagUpdate()CalculateQuiverSpeed()CalculateShootTimes()
endlocal function EnteringWorld()if (shotTimerShoot ~= nil) thenreturnendCalculateQuiverSpeed()frame:RegisterNewEvent("BAG_UPDATE", BagUpdate)GenerateShotTimerFrame()print("Loaded |c0044DD88Shot Timer for Classic Version [" .. currentVersion .. "]|r by MinguasBeef. Type |c00CCCC55/st|r for more options.")frame:RegisterNewEvent("COMBAT_LOG_EVENT_UNFILTERED", CombatLogEventUnfiltered)frame:RegisterNewEvent("PLAYER_REGEN_DISABLED", function(self) isInCombat = true; ShowShotFrame(); end)frame:RegisterNewEvent("PLAYER_REGEN_ENABLED", function(self) isInCombat = false; ShowShotFrame(); end)frame:SetScript("OnUpdate", function(self, elapsed) Addon_OnUpdate(elapsed) end)
endframe:RegisterNewEvent("ADDON_LOADED", AddonLoaded)
frame:RegisterNewEvent("PLAYER_ENTERING_WORLD", EnteringWorld)

PUI_Include.lua

--PUI UI Version 1.0
--Author: Minguas
--Description: PUI UI is intended to make panel development for addons simple and less cluttered.function PUI_Round(num, numDecimalPlaces)local mult = 10^(numDecimalPlaces or 0)return math.floor(num * mult + 0.5) / mult
endfunction PUI_FormatWidgetName(addonID, widgetType, panelName)local formattedPanelName = "PUI_" .. widgetType .. "_" .. addonID .. "_" .. panelNamereturn formattedPanelName
end--Example Usage: local frame = PUI_GenerateFrame()
--               local frame = PUI_GenerateFrame("MyFrameName")
function PUI_GenerateFrame(name)local frame = CreateFrame("Frame", name, UIParent)frame.events = {}function frame:RegisterNewEvent(eventname, eventfunction)frame.events[eventname] = eventfunctionframe:RegisterEvent(eventname)endframe:SetScript("OnEvent", function(self, event, ...)if not frame.events[event] thenreturnendframe.events[event](...)end)return frame
end--Example Usage: PUI_RegisterPanel(addonID, "Main Panel", nil)
--               PUI_RegisterPanel(addonID, "Subpanel","Main Panel")
function PUI_RegisterPanel(addonID, panelName, parentPanelName)local formattedPanelName = PUI_FormatWidgetName(addonID, "PANEL", panelName)local formattedParentName = ""if (parentPanelName == nil) thenformattedParentName = UIParentelseformattedParentName = PUI_FormatWidgetName(addonID, "PANEL",parentPanelName)endif (parentPanelName == nil) then_G[formattedPanelName] = CreateFrame( "Frame", formattedPanelName, UIParent );else_G[formattedPanelName] = CreateFrame( "Frame", formattedPanelName, _G[formattedParentName] );_G[formattedPanelName].parent = _G[formattedParentName].nameend_G[formattedPanelName].name = panelNameInterfaceOptions_AddCategory(_G[formattedPanelName]);_G[formattedPanelName].lastWidget = nil_G[formattedPanelName].children = {}return _G[formattedPanelName]
end--Usage Example: PUI_RegisterSlider(addonID, "My Addon", "slideridxyz", "Test Slider", "This is a test.", 200, 20, 0, 10, 1, 0, nil)
function PUI_RegisterSlider(addonID, panelName, sliderID, description, toolTip, width, height, minValue, maxValue, stepValue, decimalPlaces, callback)local formattedPanelName = PUI_FormatWidgetName(addonID, "PANEL", panelName)local formattedSliderName = PUI_FormatWidgetName(addonID, "SLIDER",sliderID)local slider = CreateFrame("Slider", formattedSliderName, _G[formattedPanelName], "OptionsSliderTemplate")slider:SetWidth(width)slider:SetHeight(height)slider.tooltipText = toolTip --Creates a tooltip on mouseover.slider:SetMinMaxValues(minValue, maxValue)slider:SetValue(minValue)slider:SetValueStep(stepValue)slider:Show()slider:SetPoint("CENTER")slider:SetOrientation('HORIZONTAL')slider.description = descriptionslider.id = sliderIDslider.decimalPlaces = decimalPlacesslider.type = "SLIDER"function slider:SetLowText(text)_G[slider:GetName() .. 'Low']:SetText(text); --Sets the left-side slider text (default is "Low").endfunction slider:SetHighText(text)_G[slider:GetName() .. 'High']:SetText(text); --Sets the right-side slider text (default is "High").endfunction slider:SetText(text)_G[slider:GetName() .. 'Text']:SetText(text); --Set display text above sliderendslider:SetText(description)if (_G[formattedPanelName].lastWidget == nil) thenslider:SetPoint("TOPLEFT", _G[formattedPanelName], "TOPLEFT", 25, -30)elseslider:SetPoint("BOTTOMLEFT", _G[formattedPanelName].lastWidget, "BOTTOMLEFT", 0, -65)end_G[formattedPanelName].lastWidget = sliderif (callback ~= nil) thenslider:SetScript("OnValueChanged", function(self, value) callback(self, value) end)end_G[formattedPanelName].children[formattedSliderName] = slider_G[formattedSliderName] = sliderreturn slider
end--Example Usage:  PUI_RegisterCheckBox(addonID, "My Addon", "checkboxidxyz", "Checkbox Label", "Stuff happens when you click this checkbox", 25, 25, nil)
function PUI_RegisterCheckBox(addonID, panelName, checkboxID, description, toolTip, width, height, callback)local formattedPanelName = PUI_FormatWidgetName(addonID, "PANEL", panelName)local formattedCheckBoxname = PUI_FormatWidgetName(addonID, "CHECKBOX", checkboxID)local checkbutton = CreateFrame("CheckButton", formattedCheckBoxname, _G[formattedPanelName], "ChatConfigCheckButtonTemplate")checkbutton:SetWidth(width)checkbutton:SetHeight(height)checkbutton.tooltip = toolTip --Creates a tooltip on mouseover.checkbutton:SetChecked(defaultValue)checkbutton:Show()checkbutton:SetPoint("CENTER")checkbutton.description = descriptioncheckbutton.id = checkboxIDcheckbutton.type = "CHECKBOX"function checkbutton:SetText(text)_G[checkbutton:GetName() .. 'Text']:SetText(text);endcheckbutton:SetText(description)if (_G[formattedPanelName].lastWidget == nil) thencheckbutton:SetPoint("TOPLEFT", _G[formattedPanelName], "TOPLEFT", 25, -20)elsecheckbutton:SetPoint("BOTTOMLEFT", _G[formattedPanelName].lastWidget, "BOTTOMLEFT", 0, -35)end_G[formattedPanelName].lastWidget = checkbuttonif (callback ~= nil) thencheckbutton:SetScript("OnClick", function(self) callback(self) end)end_G[formattedPanelName].children[formattedCheckBoxname] = checkbuttonreturn checkbutton
endfunction PUI_RegisterColorPicker(addonID, panelName, colorpickerID, description, toolTip, width, height, callback, rgba)local formattedPanelName = PUI_FormatWidgetName(addonID, "PANEL", panelName)local formattedColorPickerName = PUI_FormatWidgetName(addonID, "COLORPICKER", colorpickerID)local cpFrame = CreateFrame("Frame", formattedColorPickerName, _G[formattedPanelName])cpFrame:SetWidth(width)cpFrame:SetHeight(height)cpFrame:SetPoint("CENTER")cpFrame.description = descriptioncpFrame.id = colorpickerIDcpFrame.type = "COLORPICKER"cpFrame.tooltip = toolTiplocal borderThickness = 2local topBorder = CreateFrame("StatusBar", formattedColorPickerName .. "topborder", cpFrame)topBorder:SetWidth(height)topBorder:SetHeight(borderThickness)topBorder:SetPoint("TOPLEFT")topBorder:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")topBorder:SetMinMaxValues(0, 1.0)topBorder:SetValue(1.0)topBorder:SetStatusBarColor(1, 1, 1, 1)topBorder:Show()local botBorder = CreateFrame("StatusBar", formattedColorPickerName .. "botborder", cpFrame)botBorder:SetWidth(height)botBorder:SetHeight(borderThickness)botBorder:SetPoint("BOTTOMLEFT")botBorder:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")botBorder:SetMinMaxValues(0, 1.0)botBorder:SetValue(1.0)botBorder:SetStatusBarColor(1, 1, 1, 1)botBorder:Show()local leftBorder = CreateFrame("StatusBar", formattedColorPickerName .. "leftBorder", cpFrame)leftBorder:SetWidth(borderThickness)leftBorder:SetHeight(height)leftBorder:SetPoint("TOPLEFT")leftBorder:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")leftBorder:SetMinMaxValues(0, 1.0)leftBorder:SetValue(1.0)leftBorder:SetStatusBarColor(1, 1, 1, 1)leftBorder:Show()local rightBorder = CreateFrame("StatusBar", formattedColorPickerName .. "rightBorder", cpFrame)rightBorder:SetWidth(borderThickness)rightBorder:SetHeight(height)rightBorder:SetPoint("TOPLEFT", cpFrame, "TOPLEFT", height-borderThickness, 0)rightBorder:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")rightBorder:SetMinMaxValues(0, 1.0)rightBorder:SetValue(1.0)rightBorder:SetStatusBarColor(1, 1, 1, 1)rightBorder:Show()local coloredInsideFrame = CreateFrame("StatusBar", formattedColorPickerName .. "color", cpFrame)coloredInsideFrame:SetWidth(height-2*borderThickness)coloredInsideFrame:SetHeight(height-2*borderThickness)coloredInsideFrame:Show()coloredInsideFrame:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")coloredInsideFrame:SetPoint("TOPLEFT", cpFrame, "TOPLEFT", borderThickness, -borderThickness)coloredInsideFrame:SetMinMaxValues(0, 1.0)coloredInsideFrame:SetValue(1.0)coloredInsideFrame:SetStatusBarColor(rgba.r, rgba.g, rgba.b, rgba.a)cpFrame.text = cpFrame:CreateFontString(nil,"ARTWORK") cpFrame.text:SetFont("Fonts\\ARHei.ttf", 16, "OUTLINE")cpFrame.text:SetPoint("TOPLEFT", rightBorder, "TOPRIGHT", 5, -borderThickness)cpFrame.text:SetText(description)if (_G[formattedPanelName].lastWidget == nil) thencpFrame:SetPoint("TOPLEFT", _G[formattedPanelName], "TOPLEFT", 25, -20)elsecpFrame:SetPoint("BOTTOMLEFT", _G[formattedPanelName].lastWidget, "BOTTOMLEFT", 0, -35)end_G[formattedPanelName].lastWidget = cpFramelocal function colorFrameCallback(restore)local newR, newG, newB, newA;if restore then-- The user bailed, we extract the old color from the table created by ShowColorPicker.newR, newG, newB, newA = unpack(restore);else-- Something changednewA, newR, newG, newB = OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB();endcpFrame.rgba.r = newRcpFrame.rgba.g = newGcpFrame.rgba.b = newBcpFrame.rgba.a = newAcpFrame.coloredInsideFrame:SetStatusBarColor(cpFrame.rgba.r, cpFrame.rgba.g, cpFrame.rgba.b, cpFrame.rgba.a)cpFrame.callback(cpFrame)endcpFrame.callback = callbackif (callback ~= nil) thencpFrame:SetScript("OnMouseDown", function (self, button)if button=='LeftButton' thenColorPickerFrame.opacity = self.rgba.aColorPickerFrame.previousValues = {self.rgba.r,self.rgba.g,self.rgba.b,self.rgba.a};ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = colorFrameCallback, colorFrameCallback, colorFrameCallback;ColorPickerFrame:SetColorRGB(self.rgba.r,self.rgba.g,self.rgba.b, self.rgba.a);ColorPickerFrame.hasOpacity = trueColorPickerFrame.cpFrame = cpFrameColorPickerFrame:Hide(); -- Need to run the OnShow handler.ColorPickerFrame:Show();endend)endcpFrame.coloredInsideFrame = coloredInsideFramecpFrame.tb = topBordercpFrame.bb = botBordercpFrame.lb = leftBordercpFrame.rb = rightBordercpFrame.rgba = rgbacpFrame:SetScript('OnEnter', function(self) self.tb:SetStatusBarColor(1, 1, 0, 1)self.bb:SetStatusBarColor(1, 1, 0, 1)self.lb:SetStatusBarColor(1, 1, 0, 1)self.rb:SetStatusBarColor(1, 1, 0, 1)end)cpFrame:SetScript('OnLeave', function(self) self.tb:SetStatusBarColor(1, 1, 1, 1)self.bb:SetStatusBarColor(1, 1, 1, 1)self.lb:SetStatusBarColor(1, 1, 1, 1)self.rb:SetStatusBarColor(1, 1, 1, 1)end)_G[formattedPanelName].children[formattedColorPickerName] = cpFramereturn cpFrame
end

ShotTimer_Classic.toc

## Interface: 11302
## Title: Shot Timer [1.31] - |c0055DD55MinguasBeef|r
## Author: |c0055DD55MinguasBeef|r
## Version: 1.31
## SavedVariablesPerCharacter: PA_SHT_DBPUI_Include.lua
main.lua

把上面三个文件,放到  ShotTimer_Classic  文件夹中,没有新建一个就可以了。

效果不乐观:如下,隐隐约约可以看的到

wow bigfoot ShotTimer_Classic相关推荐

  1. 3 css 奖品出现弹出动画_【技术】nuxt中引入wow和animate.css 页面随滚动条出现动画...

    1. 通过nodejs安装 cnpm install wowjs --save-dev 安装成功后在"package.json: "wowjs": "^1.1. ...

  2. 对WoW Shader文件的分析

    Wow的渲染引擎是同时支持固定渲染管线渲染和Shader渲染管线渲染的. bls文件是wow的shader文件,分析它的实现可以学习引擎是怎样渲染的,以及如何做一个兼容固定管线和Shader管线的引擎 ...

  3. hdu4847:Wow! Such Doge!(字符串匹配)

    题目:hdu4847:Wow! Such Doge! 题目大意:在给出的段落里面找出"doge"出现的次数.大写和小写都能够. 解题思路:字符串匹配问题,能够在之前将字母都转换成统 ...

  4. hdu4847 Wow! Such Doge! KMP

    Chen, Adrian (November 7, 2013). "Doge Is An Ac- tually Good Internet Meme. Wow.". Gawker. ...

  5. wow服务器列表不显示,二区所剩无几 新一轮wow大服务器实装公告

    已实装wow大服务器配对列表: 8月6日已完成: 第二大区 格鲁尔 + 第一大区 斯坦索姆 第二大区 安其拉 + 第十大区 盖斯 第十大区 达基萨斯 + 第十大区 冬拥湖 第十大区 阿斯塔洛 + 第三 ...

  6. » Markdown/reST 编辑器 ReText 3.0 发布 Wow! Ubuntu

    » Markdown/reST 编辑器 ReText 3.0 发布 Wow! Ubuntu 您可以用合作网站帐号登录: # 注册 / 登入 最新文章 Canonical 宣布 Ubuntu for P ...

  7. chips of wow

    为什么80%的码农都做不了架构师?>>>    周末在诺森德大陆上奋战一番,同时以玩家和开发者的角度来看wow,觉得有些"只能意会不能言传"的感觉. 普通的技术, ...

  8. HDU4809 Wow! Such City! Dijkstra算法

    点击打开链接 Wow! Such City! Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 102400/102400 K (Jav ...

  9. 娱乐:全方位戒除网瘾 如果你真的想告别WOW

    本文来源于NGACN,作者:cn01261166 原文地址:http://nga.178.com/read.php?tid=4476982&_fp=4转载请在文首保留此行. 魔兽世界 全方位戒 ...

最新文章

  1. R语言应用substr函数和substring函数抽取(extract)、删除(Remove)、替换、匹配(Match)特定的字符串、并对比两个函数的异同、grepl检查子字符串是否存在于字符串中
  2. 「人眼难以承受」的美丽,在地球之外看地球
  3. SeetaFace2 测试
  4. idea+tomcat+struts2 搭建一个web实例
  5. question regarding UI configuration type
  6. 第二天——hibernate讲完了
  7. Java描述设计模式(10):组合模式
  8. sqlalchemy_外键连接表
  9. 剑指offer面试题[42]-反转单词顺序VS左旋转字符串
  10. 入口文件到控制器 php,tp5.0框架隐藏index.php入口文件及模块和控制器的方法分析...
  11. windows环境下创建多个Redis实例
  12. 手持式频谱分析仪推荐哪一款?
  13. c语言99乘法表 倒三角形书写
  14. 兜兜转转,又回到了这里
  15. ASME Y14.5 2018重要更新
  16. 身份证图像识别api
  17. 使用Postman调试API遇到“400 Bad Request”问题
  18. 用Android实现计算器
  19. POP3协议,SMPT协议,IAMP协议介绍:
  20. OpenCV drawMatches出现报错Error: Assertion failed

热门文章

  1. 4月30日世界表白日_世界表白日是什么几月几号啊?
  2. 天气预报webservice调用地址
  3. 肖特基二极管和稳压二极管
  4. 软件测试---冒烟测试和回归测试
  5. 查理·芒格《人类误判心理学》之检查清单
  6. mysql创建1000张表,MySQL快速生成1亿测试数据(100万、1000万、1亿)
  7. android recent键值
  8. 误差、梯度下降、概率分类模型、logistic回归笔记
  9. OpenEuler系统安装MySQL
  10. 刘国军:Imagination支持中国创“芯” 推动汽车百年大变革