Skip to content
mooreatv edited this page Jul 10, 2022 · 18 revisions

Legacy backports

Notes on how I back ported modern (bfa, shadowlands, classic, tbc) to legacy (3.3.5a) client

Thanks to Wow Addons; discord #legacy for the help

  C_Timer = {}
  C_Timer.timers = {}
  local timerFrame = CreateFrame("Frame", "C_TimerFrame")
  function ML.TimerOnUpdate(_self, elapsed)
    ML:Debug(9, "C_TimerOnUpdate elapsed %", elapsed)
    for i, v in ipairs(C_Timer.timers) do
      ML:Debug(9, "C_TimerOnUpdate timer %: %", i, v)
      if v.cancelled then
        table.remove(C_Timer.timers, i)
        break
      end
      if v.timeLeft < 0 then
        v.callback()
        if v.iterations ~= nil then
          v.iterations = v.iterations - 1
          if v.iterations <= 0 then
            table.remove(C_Timer.timers, i)
          end
        end
        v.timeLeft = v.duration
      else
        v.timeLeft = v.timeLeft - elapsed
      end
    end
  end
  timerFrame:SetScript("OnUpdate",ML.TimerOnUpdate)
  function C_Timer.NewTicker(duration, callback, iterations)
    local t = {
      duration = duration,
      timeLeft = duration,
      callback = callback,
      iterations = iterations,
      cancelled = false,
      Cancel = function(self)
        self.cancelled = true
      end,
      IsCancelled = function(self)
        return self.cancelled
      end
    }
    table.insert(C_Timer.timers, t)
    return t
  end
  function C_Timer.NewTimer(duration, callback)
    C_Timer.NewTicker(duration, callback, 1)
  end
  function C_Timer.After(duration, callback)
    C_Timer.NewTicker(duration, callback, 1)
  end
  • button don't have a Text fontstring: Try giving the buttons a global name and using _G[c:GetName().."Text"]

  • missing slider:SetStepsPerPage : don't call it. and for Text/Low/High of sliders:

    local name= nil
    if addon.isLegacy then
      name = "MoLib" .. self.name .. "Slider".. tostring(addon:NextId())
    end
    local s = CreateFrame("Slider", name, self, "OptionsSliderTemplate")
    if s.Text == nil then
      s.Text = _G[name.."Text"]
      s.Low = _G[name.."Low"]
      s.High = _G[name.."High"]
    end
  • GetNumGroupMembers() Compat.IsInRaid() and GetNumRaidMembers() or GetNumPartyMembers()

  • C_ChatInfo doesn't exist

  • no UnitFullName: use UnitName and GetRealmName for "player" realm

  • no SetMaxLines on font string -> ignore

  • no CreateLine

  • no GetServerTime

Clone this wiki locally