Advertisement
Galvin

Untitled

Jul 8th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.73 KB | None | 0 0
  1. --
  2. -- UiMisc.lua
  3. -------------------------------------------------------------------------------
  4.  
  5. -------------------------------------------------------------------------------
  6. -- Locals
  7. --
  8. -- UIErrorsOn              Flag to keep track of errors on or off.
  9. -- UiMisc_Hidden           If true then errors are hidden.
  10. -- UiMisc_InCombat         If true then in combat.
  11. -- UiMisc_Bubble           Flag to prevent bubbles from getting turned on automatically.
  12. -- FirstTime               Flag for player entering world initialization.
  13.  
  14. -- TeamP2
  15. -- TeamP3
  16. -- teamP5                  These three variables were used by /acalc. No longer used.
  17. -------------------------------------------------------------------------------
  18. local ErrorRedirect_Org_AddMessage
  19. local UIErrorsOn = nil
  20. local UiMisc_Hidden = 1
  21. local UiMisc_InCombat = nil
  22. local UiMisc_Bubble = false
  23. local TeamP2 = 0.76
  24. local TeamP3 = 0.88
  25. local TeamP5 = 1.0
  26. local FirstTime = false
  27.  
  28. -------------------------------------------------------------------------------
  29. -- GLOBAL modifcation to blizzard UI here
  30. -------------------------------------------------------------------------------
  31. -- CHAT_FRAME_TAB_SELECTED_MOUSEOVER_ALPHA = 1
  32. CHAT_FRAME_TAB_SELECTED_NOMOUSE_ALPHA = 0
  33. -- Opacity of the currently selected chat tab.
  34. -- Defaults are 1 and 0.4.
  35.  
  36. -- CHAT_FRAME_TAB_ALERTING_MOUSEOVER_ALPHA = 1
  37. CHAT_FRAME_TAB_ALERTING_NOMOUSE_ALPHA = 0
  38. -- Opacity of currently alerting chat tabs.
  39. -- Defaults are 1 and 1.
  40.  
  41. -- CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA = 1
  42. CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA = 0
  43. -- Opacity of non-selected, non-alerting chat tabs.
  44. -- Defaults are 0.6 and 0.2.
  45.  
  46.  
  47. -- Unsticky the current channels
  48.   ChatTypeInfo["WHISPER"].sticky = 0
  49.   ChatTypeInfo["CHANNEL"].sticky = 0
  50.   ChatTypeInfo["OFFICER"].sticky = 0
  51.   ChatTypeInfo["BN_WHISPER"].sticky = 0
  52.  
  53. -- Removes the colored border in the chatframe edit box
  54. local e = ChatFrame1EditBox
  55. e.focusLeft.Show = e.focusLeft.Hide
  56. e.focusRight.Show = e.focusRight.Hide
  57. e.focusMid.Show = e.focusMid.Hide
  58.  
  59. -- Removes the social button from the chat box
  60. FriendsMicroButton:Hide()
  61.  
  62. -- Mature language filter - false
  63. BNSetMatureLanguageFilter(false)
  64. --[[
  65. local a = CreateFrame("Frame")
  66. local Imsg = ''
  67. a:SetScript ("OnEvent", function(self, event, ...)
  68. local aEvent = select(2, ...)
  69. local aUser = select(4, ...)
  70. local spellID = select(12, ...)
  71. local spellName=select (10,...)
  72. local destName=select (7,...)
  73.  
  74.     if (aEvent == "SPELL_INTERRUPT") or (aEvent=="SPELL_CAST_SUCCESS" and spellName=="Skull Bash") then
  75.             if aUser==UnitName("player") and Imsg ~= '' then
  76.               SendChatMessage(Imsg, "SAY")
  77.               Imsg = ""
  78. --            SendChatMessage(GetSpellLink(spellID).." successfully interrupted "..destName, "SAY" )
  79.         end
  80.         end
  81. end)
  82. a:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  83.  
  84. local function Imsg_SlashHandler(arg1)
  85.   Imsg = arg1
  86. end
  87.  
  88. SLASH_IMSG1 = "/imsg"
  89. SlashCmdList["IMSG"] = Imsg_SlashHandler
  90.  
  91.  
  92.  
  93.  
  94. --]]
  95.  
  96. -------------------------------------------------------------------------------
  97. -- Events defined here
  98. -------------------------------------------------------------------------------
  99. local UIMiscEvents = CreateFrame("Frame", nil, UIParent)
  100.  -- UIMiscEvents:RegisterEvent("RAID_ROSTER_UPDATE")
  101.   UIMiscEvents:RegisterEvent("PLAYER_REGEN_DISABLED") -- in combat got aggro (shapeshift bar code)
  102.   UIMiscEvents:RegisterEvent("PLAYER_REGEN_ENABLED") -- out of combat no aggro (shapeshift bar code)
  103.   UIMiscEvents:RegisterEvent("UPDATE_MOUSEOVER_UNIT") -- Mousing over player/mob tooltips
  104.   UIMiscEvents:RegisterEvent("PLAYER_LOGIN") -- Load UiMiscInit_OnLoad on login
  105.   UIMiscEvents:SetScript("OnEvent", function(self, event, ...)
  106.                                       return UIMiscEvents[event](self, event, ...)
  107.                                     end)
  108. -------------------------------------------------------------------------------
  109. -- Showhelp and status
  110. -------------------------------------------------------------------------------
  111. local function UiMisc_Chat(msg)
  112.   if ( DEFAULT_CHAT_FRAME ) then
  113.     DEFAULT_CHAT_FRAME:AddMessage(msg, 1.0, 1.0, 0.0)
  114.   end
  115. end
  116.  
  117. local function UiMisc_ShowHelp()
  118.   UiMisc_Chat("user Interface Miscellaneous mod")
  119.   UiMisc_Chat("/rl              reloads the user interface")
  120.   UiMisc_Chat("/uierr hide      turn off error output")
  121.   UiMisc_Chat("/uierr show      turn on error output")
  122.   UiMisc_Chat("/uishow          show the shapeshift bar")
  123.   UiMisc_Chat("/uihide          hide the shapeshift bar")
  124.   UiMisc_Chat("/uiphide         hide ping name on minimap (saves)")
  125.   UiMisc_Chat("/uipshow          show ping name on minimap (saves)")
  126.   UiMisc_Chat("/uiraid          Hides the raids frames on the left side")
  127.   UiMisc_Chat("/uiboff          Turns off automatic bubble hiding when in combat")
  128.   UiMisc_Chat("/uibon           Turns on automatic bubble hiding")
  129.   UiMisc_Chat("/calc <exp>      Returns value of <exp>")
  130.   UiMisc_Chat("/uimisc status   Shows the current settings")
  131. end
  132.  
  133. local function UiMisc_ShowStatus()
  134.   local uierrstatus1, uierrstatus2, uibubblestatus
  135.   if UIErrorsOn then
  136.     uierrstatus1 = "ON"
  137.   else
  138.     uierrstatus1 = "OFF"
  139.   end
  140.   if UiMisc_Bubble then
  141.     uibubblestatus = "ON"
  142.   else
  143.     uibubblestatus = "OFF"
  144.   end
  145.   UiMisc_Chat("UI MISC SETTINGS")
  146.   UiMisc_Chat("Errors Shown (not saved): " .. uierrstatus1)
  147.   UiMisc_Chat("Bubbles (not saved): " .. uibubblestatus)
  148. end
  149.  
  150. -----------------------------------------------------------------------------------
  151. -- Returns up to two parameters
  152. -- example: a, b = UiMisc_GetCmd("parm1 parm2")
  153. -- a = "parm1" b = "parm2"
  154. -----------------------------------------------------------------------------------
  155. local function UiMisc_GetCmd(msg)
  156.   if msg then
  157.     local a,b,c=strfind(msg, "(%S+)") --contiguous string of non-space characters
  158.     if a then
  159.       return c, strsub(msg, b+2)
  160.     else
  161.       return ""
  162.     end
  163.   else
  164.     return ""
  165.   end
  166. end
  167.  
  168. local function UiMisc_SlashHandler(arg1)
  169.   local command, args = UiMisc_GetCmd(arg1)
  170.   if (command > "") then
  171.     command = strlower(command)
  172.     if (command == "status") then
  173.       UiMisc_ShowStatus()
  174.     end
  175.   else
  176.     command = ""
  177.     UiMisc_ShowHelp()
  178.   end
  179. end
  180.  
  181. -----------------------------------------------------------------------------------
  182. -- Raid detection code here
  183. -----------------------------------------------------------------------------------
  184. --function UIMiscEvents:RAID_ROSTER_UPDATE()
  185. --  if (GetNumGroupMembers() > 0) then
  186. --    CompactRaidFrameContainer:Hide()
  187. --    CompactRaidFrameManager:Hide()
  188. --  else
  189. --    CompactRaidFrameContainer:Show()
  190. --    CompactRaidFrameManager:Hide()
  191. --  end
  192. --end
  193.  
  194. -----------------------------------------------------------------------------------
  195. -- Combat log event register remmed out DONT'T DELETE *****************************
  196. -----------------------------------------------------------------------------------
  197.  
  198. --  local UIMiscBossE = CreateFrame("Frame", nil, UIParent)
  199. --  UIMiscBossE:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  200. --  UIMiscBossE:SetScript("OnEvent", function(self, event, ...) self[event](...) end)
  201.  
  202. -----------------------------------------------------------------------------------
  203. -- UI Errors system stuff goes here
  204. -- /uierr hide - will not display red error messages above characters head
  205. -- /uierr show - will allow messages in red to appear above charactrs head
  206. -----------------------------------------------------------------------------------
  207.  
  208. local function UIBubbles_On()
  209.   UiMisc_Bubble = true
  210. end
  211.  
  212. local function UIBubbles_Off()
  213.   UiMisc_Bubble = false
  214. end
  215.  
  216. local function UIError_Hide()
  217.   UIErrorsOn = nil
  218. end
  219.  
  220. local function UIError_Show()
  221.   UIErrorsOn = 1
  222. end
  223.  
  224. local function UIError_Update()
  225.   if (UIErrorsOn) then
  226.     UIErrorsFrame:Show()
  227.   else
  228.     UIErrorsFrame:Hide()
  229.   end
  230. end
  231.  
  232. local function UIErrors_SlashHandler(arg1)
  233.   local command, _ = UiMisc_GetCmd(arg1)
  234.   if (command > "") then
  235.     command = strlower(command)
  236.   else
  237.     command = ""
  238.   end
  239.   if (command == "hide") then
  240.     UIError_Hide()
  241.   end
  242.   if (command == "show") then
  243.     UIError_Show()
  244.   end
  245.   UIError_Update()
  246. end
  247.  
  248. -----------------------------------------------------------------------------------
  249. -- Shapeshift realted stuff goes here
  250. -- Hides the shapeshift bar
  251. -- wow calls their own bar_update function
  252. -----------------------------------------------------------------------------------
  253.  
  254. local function HideShapeshiftBar_Update()
  255.   if not UiMisc_InCombat then
  256.     if UiMisc_Hidden then
  257.       RegisterStateDriver(StanceBarFrame, "visibility", "hide")
  258.     else
  259.       RegisterStateDriver(StanceBarFrame, "visibility", "show")
  260.     end
  261.   end
  262. end
  263.  
  264. local function HideShapeshiftBar_Set()
  265.   UiMisc_Hidden = 1
  266.   HideShapeshiftBar_Update()
  267. end
  268.  
  269. local function ShowShapeshiftBar_Set()
  270.   UiMisc_Hidden = nil
  271.   HideShapeshiftBar_Update()
  272. end
  273.  
  274. -----------------------------------------------------------------------------------
  275. -- Event trigger for boss fights This uses the UIMiscBossE frame
  276. -- Current boss fights supported
  277. -- Anub'arak
  278. -----------------------------------------------------------------------------------
  279. --function UIMiscBossE:COMBAT_LOG_EVENT_UNFILTERED(...)
  280. --  local event, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags = select(1, ...)
  281. --  if event == "SPELL_CAST_START" then
  282. --    local spellId, spellName, spellSchool = select(8, ...)
  283. --    if srcName == "Anub'arak" and spellName == "Leeching Swarm" then
  284. --      local buffs = {
  285. --        47440,  -- Commanding Shout
  286. --        1243,   -- Power Word: Fortitude
  287. --        21562,  -- Prayer of Fortitude
  288. --    69377   -- Runescroll of Fortitude
  289. --      }
  290. --      for i, buff in next, buffs do
  291. --        CancelUnitBuff("player", (GetSpellInfo(buff)))
  292. --      end
  293. --    end
  294. --  end
  295. --end
  296.  
  297. -----------------------------------------------------------------------------------
  298. -- Tooltip hiding stuff here.
  299. -- Hiding mouse over players when in a raid during combat
  300. -----------------------------------------------------------------------------------
  301. local function GameTooltip_Hide()
  302.   if UiMisc_InCombat then
  303.     if (GetNumGroupMembers() > 0) then
  304.       GameTooltip:Hide()
  305.     end
  306.   else
  307.     GameTooltip:Show()
  308.   end
  309. end
  310.  
  311. function UIMiscEvents:UPDATE_MOUSEOVER_UNIT()
  312.   GameTooltip_Hide()
  313. end
  314.  
  315. local function HideGameTooltip_OnLoad()
  316.   hooksecurefunc(GameTooltip, "SetUnit", GameTooltip_Hide)
  317. end
  318.  
  319. -----------------------------------------------------------------------------------
  320. -- /calc returns the result of a math equation
  321. -----------------------------------------------------------------------------------
  322. local function Calc_SlashHandler(arg1)
  323.   if (not arg1 or arg1 == "") then
  324.     return
  325.   end
  326.   RunScript(string.format([[DEFAULT_CHAT_FRAME:AddMessage("calc: %s", 1.0, 1.0, 1.0)
  327.                             DEFAULT_CHAT_FRAME:AddMessage(%s, 1.0, 1.0, 1.0)]], arg1, arg1))
  328. end
  329.  
  330. -------------------------------------------------------------------------------
  331. -- Event handlers
  332. -------------------------------------------------------------------------------
  333. function UIMiscEvents:PLAYER_REGEN_ENABLED()
  334.   UiMisc_InCombat = nil -- player out of combat
  335.   HideShapeshiftBar_Update()
  336.  
  337.   -- Turn off chat bubbles when out of combat
  338.   SetCVar("ChatBubbles", "0")
  339. end
  340.  
  341. function UIMiscEvents:PLAYER_REGEN_DISABLED()
  342.   UiMisc_InCombat = 1 -- player in combat
  343.   HideShapeshiftBar_Update()
  344.  
  345.   -- Check to see if we're in a pvp battle ground
  346.   local InInstance, IsPvP = IsInInstance()
  347.   -- Turn on chat bubbles if in a raid and in combat
  348.   if (GetNumGroupMembers() > 0) and (IsPvP ~= 'pvp') and UiMisc_Bubble then
  349.     SetCVar("ChatBubbles", "1")
  350.   end
  351. end
  352.  
  353. -----------------------------------------------------------------------------------
  354. -- Hide blizzard raid frame
  355. -----------------------------------------------------------------------------------
  356. local function HideRaidFrame()
  357.   -- Hide the blizzard raid frames
  358.   CompactRaidFrameManager:UnregisterAllEvents()
  359.   CompactRaidFrameManager:Hide()
  360.   CompactRaidFrameContainer:UnregisterAllEvents()
  361.   CompactRaidFrameContainer:Hide()
  362. end
  363.  
  364. -----------------------------------------------------------------------------------
  365. -- UiMiscInit_OnLoad() : loads stuff at startup only
  366. -----------------------------------------------------------------------------------
  367. function UIMiscEvents:PLAYER_LOGIN()
  368.  
  369.   HideRaidFrame()
  370.  
  371.   -- Hide the clock
  372.   TimeManagerClockButton:Hide()
  373.  
  374.   -- Set camera to max distance.
  375.   SetCVar("cameraDistanceMax",30)
  376.   SetCVar("cameraDistanceMaxFactor","4")
  377.  
  378. --  ChatFrame1EditBox:SetTexture(nil)
  379.   -- Hide/show the shapeshift bar.
  380.   HideShapeshiftBar_Update()
  381.  
  382.   -- Hide/show errors.
  383.   UIError_Update()
  384.  
  385.   -- Hiding mouse over players when in a raid during combat
  386.   HideGameTooltip_OnLoad()
  387.  
  388.   -- Hide the icons on each side of the menu bar.
  389.   MainMenuBarLeftEndCap:Hide()
  390.   MainMenuBarRightEndCap:Hide()
  391.  
  392.   -- Initialize slash commands
  393.   SLASH_UIMISC1 = "/uimisc"
  394.   SlashCmdList["UIMISC"] = UiMisc_SlashHandler
  395.   SLASH_RL1 = "/rl"
  396.   SlashCmdList["RL"] = function() ReloadUI() end
  397.   SLASH_UIERRORS1 = "/uierr"
  398.   SlashCmdList["UIERRORS"] = UIErrors_SlashHandler
  399.   SLASH_UIHIDE1 = "/uihide"
  400.   SlashCmdList["UIHIDE"] = HideShapeshiftBar_Set
  401.   SLASH_UISHOW1 = "/uishow"
  402.   SlashCmdList["UISHOW"] = ShowShapeshiftBar_Set
  403.   SLASH_CALC1 = "/calc"
  404.   SlashCmdList["CALC"] = Calc_SlashHandler
  405.   SLASH_UIPHIDE1 = "/uiphide"
  406.   SlashCmdList["UIPHIDE"] = UIHidePingName_Set
  407.   SLASH_UIPSHOW1 = "/uipshow"
  408.   SlashCmdList["UIPSHOW"] = UIShowPingName_Set
  409.   SLASH_UIRAID1 = "/uiraid"
  410.   SlashCmdList["UIRAID"] = HideRaidFrame
  411.   SLASH_UIBON1 = "/uibon"
  412.   SlashCmdList["UIBON"] = UIBubbles_On
  413.   SLASH_UIBOFF1 = "/uiboff"
  414.   SlashCmdList["UIBOFF"] = UIBubbles_Off
  415. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement