View Single Post
03-04-14, 08:29 PM   #10
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Entire Code

Sorry about that.

Unitframes.lua:
Lua Code:
  1. local B, C, DB = unpack(select(2, ...)) -- Import:  B - function; C - config; DB - Database
  2.  
  3. if C["unitframes"].enable ~= true then return end
  4.  
  5.  
  6. -- Special Thanks to the guys over at Arena Junkies for most of these scripts
  7. -- [url]http://www.arenajunkies.com/topic/222642-default-ui-scripts/[/url]
  8.  
  9. local _G = _G
  10.  
  11.  
  12. -- Player Frame
  13. if C["unitframes"].player.enable then
  14.  
  15.     -- Frame Scale
  16.     _G["PlayerFrame"]:SetScale(C["unitframes"].player.scale);  
  17.     PlayerFrameHealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].player.fontSize,"THINOUTLINE");
  18.     PlayerFrameManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].player.fontSize, "THINOUTLINE");
  19.     PlayerFrameAlternateManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].player.fontSize, "THINOUTLINE");
  20.     PetFrameHealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].player.fontSizepet,"THINOUTLINE");
  21.     PetFrameManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].player.fontSizepet, "THINOUTLINE");
  22.  
  23. end
  24.  
  25. -- Target Frame
  26. if C["unitframes"].target.enable then
  27.  
  28.     -- Frame Scale
  29.      _G["TargetFrame"]:SetScale(C["unitframes"].target.scale);
  30.     TargetFrameTextureFrameHealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].target.fontSize, "THINOUTLINE");
  31.     TargetFrameTextureFrameManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].target.fontSize, "THINOUTLINE");
  32.  
  33. end;
  34.  
  35. -- Focus Frame
  36. if C["unitframes"].focus.enable then
  37.  
  38.     -- Frame Scale
  39.      _G["FocusFrame"]:SetScale(C["unitframes"].focus.scale)
  40.     FocusFrameTextureFrameHealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].focus.fontSize,"THINOUTLINE")
  41.     FocusFrameTextureFrameManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].focus.fontSize,"THINOUTLINE")
  42.  
  43. end;
  44.  
  45.  
  46. -- Party Frames --
  47. if C["unitframes"].party.enable then
  48.  
  49.     -- Clear all old settings
  50.     PartyMemberFrame1:ClearAllPoints();
  51.     PartyMemberFrame2:ClearAllPoints();
  52.     PartyMemberFrame3:ClearAllPoints();
  53.     PartyMemberFrame4:ClearAllPoints();
  54.  
  55.     -- Create new locations
  56.     PartyMemberFrame1:SetPoint(C['unitframes'].party.position.relAnchor, UIParent, C['unitframes'].party.position.offSetX, C['unitframes'].party.position.offSetY);
  57.     PartyMemberFrame2:SetPoint("TOPLEFT", PartyMemberFrame1, 0, -75);
  58.     PartyMemberFrame3:SetPoint("TOPLEFT", PartyMemberFrame2, 0, -75);
  59.     PartyMemberFrame4:SetPoint("TOPLEFT", PartyMemberFrame3, 0, -75);
  60.  
  61.     -- Make the new locations stay
  62.     PartyMemberFrame1.SetPoint = function() end;
  63.     PartyMemberFrame2.SetPoint = function() end;
  64.     PartyMemberFrame3.SetPoint = function() end;
  65.     PartyMemberFrame4.SetPoint = function() end;
  66.  
  67.     -- Set the scale of all the frames
  68.     PartyMemberFrame1:SetScale(C["unitframes"].party.scale);
  69.     PartyMemberFrame2:SetScale(C["unitframes"].party.scale);
  70.     PartyMemberFrame3:SetScale(C["unitframes"].party.scale);
  71.     PartyMemberFrame4:SetScale(C["unitframes"].party.scale);
  72.    
  73.     -- Set Font Size
  74.     PartyMemberFrame1HealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].party.fontSize, "THINOUTLINE")
  75.     PartyMemberFrame1ManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].party.fontSize, "THINOUTLINE")
  76.     PartyMemberFrame2HealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].party.fontSize, "THINOUTLINE")
  77.     PartyMemberFrame2ManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].party.fontSize, "THINOUTLINE")
  78.     PartyMemberFrame3HealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].party.fontSize, "THINOUTLINE")
  79.     PartyMemberFrame3ManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].party.fontSize, "THINOUTLINE")
  80.     PartyMemberFrame4HealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].party.fontSize, "THINOUTLINE")
  81.     PartyMemberFrame4ManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].party.fontSize, "THINOUTLINE")
  82. end;
  83.  
  84.  -- Arena Frames
  85. if C["unitframes"].arena.enable then
  86.     LoadAddOn("Blizzard_ArenaUI"); -- You only need to run this once. You can safely delete any copies of this line.
  87.      
  88.     ArenaEnemyFrames:SetScale(C["unitframes"].arena.scale);
  89.    
  90.     ArenaEnemyFrame1HealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize,"THINOUTLINE");
  91.     ArenaEnemyFrame1ManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize, "THINOUTLINE");
  92.     ArenaEnemyFrame2HealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize,"THINOUTLINE");
  93.     ArenaEnemyFrame2ManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize, "THINOUTLINE");
  94.     ArenaEnemyFrame3HealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize,"THINOUTLINE");
  95.     ArenaEnemyFrame3ManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize, "THINOUTLINE");
  96.     ArenaEnemyFrame4HealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize,"THINOUTLINE");
  97.     ArenaEnemyFrame4ManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize, "THINOUTLINE");
  98.     ArenaEnemyFrame5HealthBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize,"THINOUTLINE");
  99.     ArenaEnemyFrame5ManaBarText:SetFont(C['media'].fontNormal, C["unitframes"].arena.fontSize, "THINOUTLINE");
  100.  
  101.  
  102.     if C["unitframes"].arena.tracker == true then
  103.         trinkets = {};
  104.         local arenaFrame,trinket;
  105.         for i = 1, 5 do
  106.             arenaFrame = "ArenaEnemyFrame"..i;
  107.             trinket = CreateFrame("Cooldown", arenaFrame.."Trinket", ArenaEnemyFrames);
  108.             trinket:SetPoint("TOPRIGHT", arenaFrame, 30, -6);
  109.             trinket:SetSize(24, 24);
  110.             trinket.icon = trinket:CreateTexture(nil, "BACKGROUND");
  111.             trinket.icon:SetAllPoints();
  112.             trinket.icon:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_01");
  113.             trinket:Hide();
  114.             trinkets["arena"..i] = trinket;
  115.         end;
  116.         local events = CreateFrame("Frame");
  117.         function events:UNIT_SPELLCAST_SUCCEEDED(unitID, spell, rank, lineID, spellID)
  118.             if not trinkets[unitID] then
  119.                 return;
  120.             end ;      
  121.             if spellID == 59752 or spellID == 42292 then
  122.                 CooldownFrame_SetTimer(trinkets[unitID], GetTime(), 120, 1);
  123.                 SendChatMessage("Trinket used by: "..GetUnitName(unitID, true), "PARTY");
  124.             end;
  125.         end;
  126.         function events:PLAYER_ENTERING_WORLD()
  127.             local _, instanceType = IsInInstance();
  128.             if instanceType == "arena" then
  129.                 self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED");
  130.             elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then
  131.                 self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED");
  132.                 for _, trinket in pairs(trinkets) do
  133.                     trinket:SetCooldown(0, 0);
  134.                     trinket:Hide();
  135.                 end;        
  136.             end;
  137.         end;
  138.         events:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end);
  139.         events:RegisterEvent("PLAYER_ENTERING_WORLD");
  140.     end;
  141. end;
  142.  
  143.  -- Boss Frames
  144. if C["unitframes"].boss.enable then
  145.     for i = 1,4 do
  146.         local boss = _G["Boss"..i.."TargetFrame"];
  147.         if boss then
  148.             boss:SetScale(C["unitframes"].boss.scale)
  149.             boss:ClearAllPoints();
  150.             boss:SetPoint(C['unitframes'].boss.position.relAnchor, UIParent, C['unitframes'].boss.position.offSetX, C['unitframes'].boss.position.offSetY);
  151.             boss.ClearAllPoints = function() end;
  152.             boss.SetPoint = function() end;    
  153.         end;
  154.     end;
  155. end;
  156.  
  157. -- Font Style thanks to Phanx from WoWinterface.
  158. local shorts = {
  159.     { 1e10, 1e9, "%.0fb" }, --  10b+ as  12b
  160.     {  1e9, 1e9, "%.1fb" }, --   1b+ as 8.3b
  161.     {  1e7, 1e6, "%.0fm" }, --  10m+ as  14m
  162.     {  1e6, 1e6, "%.1fm" }, --   1m+ as 7.4m
  163.     {  1e5, 1e3, "%.0fk" }, -- 100k+ as 840k
  164.     {  1e3, 1e3, "%.1fk" }, --   1k+ as 2.5k
  165.     {    0,   1,    "%d" }, -- < 1k  as  974
  166. }
  167. for i = 1, #shorts do
  168.     shorts[i][4] = shorts[i][3] .. " (%.0f%%)"
  169. end
  170.  
  171. hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusBar, fontString, value, valueMin, valueMax)
  172.     local style = GetCVar("statusTextDisplay")
  173.     if style == "PERCENT" then
  174.         return fontString:SetFormattedText("%.0f%%", value / valueMax * 100)
  175.     end
  176.     for i = 1, #shorts do
  177.         local t = shorts[i]
  178.         if value >= t[1] then
  179.             if style == "BOTH" then
  180.                 return fontString:SetFormattedText(t[4], value / t[2], value / valueMax * 100)
  181.             else
  182.                 return fontString:SetFormattedText(t[3], value / t[2])             
  183.             end
  184.         end
  185.     end
  186. end)
  187.  
  188. hooksecurefunc("UnitFrame_Update", function(self)
  189.     if not self.name then return end
  190.  
  191.     if UnitIsPlayer(self.unit) then
  192.         -- Color by class:
  193.         local _, class = UnitClass(self.unit)
  194.         local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  195.         self.name:SetTextColor(color.r, color.g, color.b)
  196.     else
  197.         -- Not a player. Return to default color:
  198.         local reaction = UnitReaction(self.unit, "player");
  199.         self.name:SetTextColor(FACTION_BAR_COLORS[reaction].r, FACTION_BAR_COLORS[reaction].g, FACTION_BAR_COLORS[reaction].b)
  200.     end
  201. end)
  202.  
  203. -- Disable healing/damage spam over player/pet frame:
  204. PlayerHitIndicator:SetText(nil)
  205. PlayerHitIndicator.SetText = function() end
  206. PetHitIndicator:SetText(nil)
  207. PetHitIndicator.SetText = function() end

Defaults.lua:
Lua Code:
  1. local B, C, DB = unpack(select(2, ...)) -- Import:  B - function; C - config; DB - Database
  2.  
  3. -----------------
  4. -- Media Options
  5. -----------------
  6. DB["media"] = {
  7.     ["fontNormal"] = "BasicUI NORMAL",
  8.     ["fontBold"] = "BasicUI BOLD",
  9.     ["fontItalic"] = "BasicUI ITALIC",
  10.     ["fontBoldItalic"] = "BasicUI BOLD ITALIC",
  11.     ["fontNumber"] = "BasicUI NUMBER",
  12.     ["fontSize"] = 15,
  13. }
  14.  
  15. --------------
  16. -- Unitframes
  17. --------------
  18. DB["unitframes"] = {
  19.    
  20.     ["enable"] = true,
  21.     ["player"] = {
  22.         ["enable"] = true,          -- Enable Player Frame Adjustments
  23.         ["scale"] = 1.15,           -- Player Frame Scale
  24.         ["fontSize"] = 13,          -- Stausbar Font Size
  25.         ["fontSizepet"] = 10,           -- Stausbar Font Size
  26.     },
  27.     ["target"] = {
  28.         ["enable"] = true,          -- Enable Target Frame Adjustments
  29.         ["scale"] = 1.15,           -- Target Frame Scale
  30.         ["fontSize"] = 13,          -- Stausbar Font Size
  31.     },
  32.     ["focus"] = {
  33.         ["enable"] = true,          -- Enable Focus Frame Adjustments
  34.         ["scale"] = 1.15,           -- Focus Frame Scale
  35.         ["fontSize"] = 13,          -- Stausbar Font Size
  36.     },
  37.     ["party"] = {
  38.         ["enable"] = true,
  39.         ["scale"] = 1.15,
  40.         ["fontSize"] = 11,          -- Stausbar Font Size
  41.         ["position"] = {
  42.             ["relAnchor"] = "TOPLEFT",
  43.             ["offSetX"] = 10,       -- Controls the X offset. (Left - Right)
  44.             ["offSetY"] = -150,     -- Controls the Y offset. (Up - Down)
  45.         },
  46.     },
  47.     ["arena"] = {
  48.         ["enable"] = true,
  49.         ["scale"] = 1.5,
  50.         ["fontSize"] = 11,          -- Stausbar Font Size
  51.         ["tracker"] = true,
  52.     },
  53.     ["boss"] = {
  54.         ["enable"] = true,
  55.         ["scale"] = 1.15,
  56.         ["fontSize"] = 13,          -- Stausbar Font Size  
  57.         ["position"] = {
  58.             ["relAnchor"] = "TOPRIGHT",
  59.             ["offSetX"] = -50,      -- Controls the X offset. (Left - Right)
  60.             ["offSetY"] = -250,     -- Controls the Y offset. (Up - Down)
  61.         },
  62.     },
  63. }

Engine.lua:
Lua Code:
  1. ----------------------------------
  2. -- Engine to make all files communicate.
  3.  
  4. -- Credit Nightcracker
  5. ----------------------------------
  6.  
  7. -- including system
  8. local addon, engine = ...
  9. engine[1] = {} -- B, functions, constants
  10. engine[2] = {} -- C, config
  11. engine[3] = {} -- DB, database, post config load
  12.  
  13. BasicUI = engine --Allow other addons to use Engine

Config.lua:
Lua Code:
  1. ----------------------------------------------------------------------------
  2. -- This Module loads new user settings if BasicUI_Config is loaded
  3. ----------------------------------------------------------------------------
  4. local B, C, DB = unpack(select(2, ...)) -- Import:  B - function; C - config; DB - Database
  5.  
  6. --Convert default database
  7. for group,options in pairs(DB) do
  8.     if not C[group] then C[group] = {} end
  9.     for option, value in pairs(options) do
  10.         C[group][option] = value
  11.     end
  12. end
  13.  
  14. if IsAddOnLoaded("BasicUI_Config") then
  15.     local BasicUIConfig = LibStub("AceAddon-3.0"):GetAddon("BasicUIConfig")
  16.     BasicUIConfig:Load()
  17.  
  18.     --Load settings from BasicUIConfig database
  19.     for group, options in pairs(BasicUIConfig.db.profile) do
  20.         if C[group] then
  21.             for option, value in pairs(options) do
  22.                 C[group][option] = value
  23.             end
  24.         end
  25.     end
  26.        
  27.     B.SavePath = BasicUIConfig.db.profile
  28. end

Is there any other code that you might need?

Coke

Last edited by cokedrivers : 03-04-14 at 08:34 PM.
  Reply With Quote