public
Description: WoW Addon - My fork of Ace's AddonLoader... cause I'm not willing to install an SVN client :)
Homepage: http://www.wowace.com/wiki/AddonLoader
Clone URL: git://github.com/tekkub/addonloader.git
tekkub (author)
Sat Jul 19 19:21:10 -0700 2008
commit  97dc0fe94727f6efbc513f4b8389d4715134022f
tree    49bb559d722faa78be6b02dbf203405028290912
parent  43fb50edcbcdf3deca9a8b1422e690abccf3eee9
addonloader / Overrides.lua
100644 153 lines (136 sloc) 4.964 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
local frame = CreateFrame("Frame", nil, UIParent)
frame.name = "Addon Loader"
frame:Hide()
frame:SetScript("OnShow", function(frame)
 
  local dropdown, editbox, reset
  
  local currentAddon
  for k, v in pairs(AddonLoader.conditiontexts) do
    currentAddon = k
  end
 
  local function updatereset()
    if AddonLoader.originals[currentAddon] ~= AddonLoader.conditiontexts[currentAddon] then
      reset:Show()
    else
      reset:Hide()
    end  
  end
  
  local function focuslost()
    local text = editbox:GetText()
    if text ~= AddonLoader.originals[currentAddon] then
      AddonLoaderSV.overrides[currentAddon] = text
      AddonLoader.conditiontexts[currentAddon] = text
    else
      AddonLoaderSV.overrides[currentAddon] = nil
    end
    updatereset()
  end
  
  local function dropdown_onclick()
    focuslost() -- save values
    currentAddon = this.value
    updatereset()
    UIDropDownMenu_SetSelectedValue(dropdown, currentAddon)
    editbox:SetText(AddonLoader.conditiontexts[currentAddon])
  end
  
  local function initdropdown()
    local addonCount = 0
    local info = UIDropDownMenu_CreateInfo()
    local checked
    for addon, text in pairs(AddonLoader.conditiontexts) do
      if addon == currentAddon then
        checked = 1
      else
        checked = nil
      end
      if AddonLoader.conditiontexts[addon] ~= AddonLoader.originals[addon] then
        info.textR = 1
        info.textG = 1
        info.textB = 1
      else
        info.textR = .66
        info.textG = .66
        info.textB = .66
      end
      info.text = addon
      info.func = dropdown_onclick
      info.value = addon
      info.checked = checked
      UIDropDownMenu_AddButton(info)
    end
  end
 
  local title = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
  title:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -15)
  title:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
  title:SetJustifyH("LEFT")
  title:SetJustifyV("TOP")
  title:SetText("AddonLoader")
  
  local check = CreateFrame("CheckButton", "AddonLoaderCheckButton", frame, "UICheckButtonTemplate")
  check:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -50)
  check:SetWidth(24)
  check:SetHeight(24)
  check:SetChecked(AddonLoaderSV.silent)
  AddonLoaderCheckButtonText:SetText(AddonLoader.L.hideloading)
  AddonLoaderCheckButtonText:SetPoint("LEFT", check, "RIGHT")
  check:SetScript("OnClick", function()
    AddonLoaderSV.silent = not AddonLoaderSV.silent
    check:SetChecked(AddonLoaderSV.silent)
  end)
  
  local explain = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  explain:SetTextColor(1,1,1)
  explain:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -80)
  explain:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -15, -80)
  explain:SetJustifyH("LEFT")
  explain:SetJustifyV("TOP")
  explain:SetHeight(50)
  explain:SetText(AddonLoader.L.explain)
  
  local dropdownlabel = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  dropdownlabel:SetPoint("TOPLEFT", explain, "BOTTOMLEFT", 0, -10)
  dropdownlabel:SetText("AddOn")
  dropdownlabel:SetHeight(15)
  dropdownlabel:SetWidth(50)
  
  dropdown = CreateFrame("Frame", "AddonLoaderDropDown", frame, "UIDropDownMenuTemplate")
  dropdown:EnableMouse(true)
  dropdown:SetPoint("TOPLEFT", dropdownlabel, "TOPRIGHT")
  UIDropDownMenu_Initialize(dropdown, initdropdown)
  UIDropDownMenu_SetSelectedValue(dropdown, currentAddon)
  UIDropDownMenu_SetWidth(160, dropdown)
  UIDropDownMenu_JustifyText("LEFT", dropdown)
  AddonLoaderDropDownLeft:SetHeight(50)
  AddonLoaderDropDownMiddle:SetHeight(50)
  AddonLoaderDropDownRight:SetHeight(50)
  AddonLoaderDropDownButton:SetPoint("TOPRIGHT", AddonLoaderDropDownRight, "TOPRIGHT", -16, -12)
 
  reset = CreateFrame("Button","AddonLoaderResetButton",frame,"UIPanelButtonTemplate2")
  reset:SetText(AddonLoader.L.reset)
  reset:SetWidth(80)
  reset:SetPoint("TOPLEFT", dropdown, "TOPRIGHT", 0, 5)
  reset:SetScript("OnClick", function()
    AddonLoaderSV.overrides[currentAddon] = nil
    AddonLoader.conditiontexts[currentAddon] = AddonLoader.originals[currentAddon]
    editbox:SetText(AddonLoader.originals[currentAddon])
    updatereset()
  end)
  updatereset()
  
  editbox = CreateFrame("EditBox", "AddonLoaderEditBox", frame)
  editbox:SetPoint("TOP", dropdown, "BOTTOM")
  editbox:SetPoint("LEFT", 5, 0)
  editbox:SetPoint("BOTTOMRIGHT", -5, 5)
  editbox:SetFontObject(GameFontNormal)
  editbox:SetTextColor(.8,.8,.8)
  editbox:SetTextInsets(8,8,8,8)
  editbox:SetBackdrop({
    bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
    edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
    edgeSize = 16,
    insets = {left = 4, right = 4, top = 4, bottom = 4}
  })
  editbox:SetBackdropColor(.1,.1,.1,.3)
  editbox:SetBackdropBorderColor(.5,.5,.5)
  editbox:SetMultiLine(true)
  editbox:SetAutoFocus(false)
  editbox:SetText(AddonLoader.conditiontexts[currentAddon])
  editbox:SetScript("OnEditFocusLost", focuslost)
  editbox:SetScript("OnEscapePressed", editbox.ClearFocus)
  
  frame:SetScript("OnShow", nil)
end )
 
InterfaceOptions_AddCategory(frame)
 
SLASH_ADDONLOADER1 = "/addonloader"
SlashCmdList.ADDONLOADER = function() InterfaceOptionsFrame_OpenToFrame(frame) end