View Single Post
01-10-15, 03:37 PM   #58
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Could I put my own "custom" tags and other variables (such as texture paths, font paths and text color based on class) into a separate file?
Want to reduce the clutter and clean up the code a bit for my own sanity.
Trying to fiddle with it myself, but not really sure how to call for instance a texture path from "Settings.lua" to "Frames.lua"... Did look through a couple of oUF layouts I knew had a separate file for settings but it didn't really clear things up.

What I've got so far with "Settings.lua"
Lua Code:
  1. local addon, ns = ...
  2.  
  3.  
  4.     Textures = {
  5.         BTexture = [[Interface\\AddOns\\oUF_Kygo\\Media\\normTex2.tga]]
  6.         bgFile = [[Interface\\AddOns\\oUF_Kygo\\Media\\backdrop.tga]]
  7.         edgeFile = [[bgFile = Interface\\AddOns\\oUF_Kygo\\Media\\backdrop_edge.tga]]
  8.         Icon = [[Interface\\AddOns\\oUF_Kygo\\Media\\Neal_border.blp]] --ClassIcons (Soul Shards, Holy power etc)
  9.         CPoint = [[Interface\\AddOns\\oUF_Kygo\\Media\\NCPoint.blp]]
  10. }
  11.    
  12.     ClassPowerText = {
  13.         Priest = {26/255, 160/255, 255/255} --Mana
  14.         Shaman = {26/255, 160/255, 255/255} -- Mana
  15.         Warlock = {26/255, 160/255, 255/255} -- Mana
  16.         Paladin = {26/255, 160/255, 255/255} -- Mana
  17.         MonkMistweaver = {26/255, 160/255, 255/255} --How to check if monk is MW or not status: Unknown atm
  18.         Mage = {26/255, 160/255, 255/255} -- Mana
  19.         DruidResto/Balance = {26/255, 160/255, 255/255} -- Mana
  20.         Warrior = {255/255, 26/255, 48/255} -- Rage
  21.         DruidGuardian = {255/255, 26/255, 48/255} --Rage
  22.         Hunter = {255/255, 128/255, 64/255} -- Focus
  23.         Rogue = {255/255, 225/255, 26/255} -- Energy
  24.         DruidFeral = {255/255, 225/255, 26/255} -- Energy
  25.         DeathKnight = {0.00, 0.82, 1.00} -- Runic Power
  26. }
  27.  
  28.     Tags = {
  29.     oUF.Tags.Events["shorthp"] = "UNIT_HEALTH"
  30.     oUF.Tags.Methods["shorthp"] = function(unit)
  31.         if not UnitIsDeadOrGhost(unit) then
  32.             local hp = UnitHealth(unit)
  33.             return AbbreviateLargeNumbers(hp)
  34.         end
  35.     end
  36.  
  37.     oUF.Tags.Events["shortpp"] = "UNIT_POWER"
  38.     oUF.Tags.Methods["shortpp"] = function(unit)
  39.         if not UnitIsDeadOrGhost(unit) then
  40.             local pp = UnitPower(unit)
  41.             return AbbreviateLargeNumbers(pp)
  42.         end
  43.     end
  44.  
  45.     oUF.Tags.Events["shortname"] = "UNIT_NAME"
  46.     oUF.Tags.Methods["shortname"] = function(unit)
  47.         local name = UnitName(unit)
  48.         return string.sub(UnitName(unit), 1, 20)
  49.     end
  50.  
  51.     oUF.Tags.Events["readycheckicon"] = "DoReadyCheck"
  52.     oUF.Tags.SharedEvents["IsInGroup"] = true
  53.     oUF.Tags.Methods["readycheckicon"] = function(unit)
  54.         if unit == "player" and IsInGroup() then
  55.             return [[|TInterface\RAIDFRAME\ReadyCheck-Ready|t]]
  56.         end
  57.     end
  58.  
  59.     oUF.Tags.Events["rsicon"] = "PLAYER_UPDATE_RESTING"
  60.     oUF.Tags.SharedEvents["PLAYER_UPDATE_RESTING"] = true
  61.     oUF.Tags.Methods["rsicon"] = function(unit)
  62.         if unit == "player" and IsResting() then
  63.             return [[|TInterface\CharacterFrame\UI-StateIcon:0:0:0:-6:64:64:28:6:6:28|t]]
  64.         end
  65.     end
  66.     oUF.Tags.Events["combaticon"] = "PLAYER_REGEN_DISABLED PLAYER_REGEN_ENABLED"
  67.     oUF.Tags.SharedEvents["PLAYER_REGEN_DISABLED"] = true
  68.     oUF.Tags.SharedEvents["PLAYER_REGEN_ENABLED"] = true
  69.     oUF.Tags.Methods["combaticon"] = function(unit)
  70.         if unit == "player" and UnitAffectingCombat("player") then
  71.             return [[|TInterface\CharacterFrame\UI-StateIcon:0:0:0:0:64:64:37:58:5:26|t]]
  72.         end
  73.     end
  74.  
  75.     oUF.Tags.Events["leadericon"] = "GROUP_ROSTER_UPDATE"
  76.     oUF.Tags.SharedEvents["GROUP_ROSTER_UPDATE"] = true
  77.     oUF.Tags.Methods["leadericon"] = function(unit)
  78.         if UnitIsGroupLeader(unit) then
  79.             return [[|TInterface\GroupFrame\UI-Group-LeaderIcon:0|t]]
  80.         elseif UnitInRaid(unit) and UnitIsGroupAssistant(unit) then
  81.             return [[|TInterface\GroupFrame\UI-Group-AssistantIcon:0|t]]
  82.         end
  83.     end
  84.  
  85.     oUF.Tags.Events["mastericon"] = "PARTY_LOOT_METHOD_CHANGED GROUP_ROSTER_UPDATE"
  86.     oUF.Tags.SharedEvents["PARTY_LOOT_METHOD_CHANGED"] = true
  87.     oUF.Tags.SharedEvents["GROUP_ROSTER_UPDATE"] = true
  88.     oUF.Tags.Methods["mastericon"] = function(unit)
  89.         local method, pid, rid = GetLootMethod()
  90.         if method ~= "master" then return end
  91.         local munit
  92.         if pid then
  93.             if pid == 0 then
  94.                 munit = "player"
  95.             else
  96.                 munit = "party" .. pid
  97.             end
  98.         elseif rid then
  99.             munit = "raid" .. rid
  100.         end
  101.         if munit and UnitIsUnit(munit, unit) then
  102.             return [[|TInterface\GroupFrame\UI-Group-MasterLooter:0:0:0:2|t]]
  103.         end
  104.     end
  105.  
  106. }
  107.  
  108. ns.Settings = Settings
  Reply With Quote