WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Search/Requests (https://www.wowinterface.com/forums/forumdisplay.php?f=6)
-   -   I want to write an addon that changes the position of GW2 UI elements (https://www.wowinterface.com/forums/showthread.php?t=56387)

Krainz 07-19-18 02:07 AM

I want to write an addon that changes the position of GW2 UI elements
 
How do I get started on that?

It's kinda tiresome for me to go in the GW2 UI lua files and change them manually every time the addon is updated.

I'll paste the changes below so you guys have a more precise idea of what I have to do every time:

This is part of GW2_UI

Lua Code:
  1. local function gw_OnEvent(self, event, name)
  2.     if loaded then
  3.         return
  4.     end
  5.     if event ~= "PLAYER_LOGIN" then
  6.         return
  7.     end
  8.     loaded = true
  9.  
  10.     -- setup our frame pool
  11.     GW.Pools = CreatePoolCollection()
  12.  
  13.     -- disable Move Anything bag handling
  14.     disableMABags()
  15.  
  16.     -- hook debug output if relevant
  17.     local dev_dbg_tab = GetSetting("DEV_DBG_CHAT_TAB")
  18.     if dev_dbg_tab and dev_dbg_tab > 0 and _G["ChatFrame" .. dev_dbg_tab] then
  19.         print("hooking Debug to chat tab #" .. dev_dbg_tab)
  20.         dbgTab = dev_dbg_tab
  21.         GW.AlertTestsSetup()
  22.         GW.inDebug = true
  23.     else
  24.         GW.inDebug = false
  25.     end
  26.  
  27.     --Create Settings window
  28.     GW.LoadSettings()
  29.     GW.DisplaySettings()
  30.  
  31.     --Create hud art
  32.     GW.LoadHudArt()
  33.  
  34.     --Create experiencebar
  35.     GW.LoadXPBar()
  36.  
  37.     if GetSetting("FONTS_ENABLED") then
  38.         GW.LoadFonts()
  39.     end
  40.  
  41.     if GetSetting("CASTINGBAR_ENABLED") then
  42.         GW.LoadCastingBar()
  43.     end
  44.  
  45.     if GetSetting("MINIMAP_ENABLED") then
  46.         GW.LoadMinimap()
  47.     end
  48.  
  49.     if GetSetting("QUESTTRACKER_ENABLED") then
  50.         GW.LoadQuestTracker()
  51.     end
  52.  
  53.     if GetSetting("TOOLTIPS_ENABLED") then
  54.         GW.LoadTooltips()
  55.     end
  56.  
  57.     if GetSetting("QUESTVIEW_ENABLED") then
  58.         GW.LoadQuestview()
  59.     end
  60.  
  61.     if GetSetting("CHATFRAME_ENABLED") then
  62.         GW.LoadChat()
  63.     end
  64.  
  65.     --Create player hud
  66.     if GetSetting("HEALTHGLOBE_ENABLED") then
  67.         GW.LoadPlayerHud()
  68.     end
  69.  
  70.     if GetSetting("POWERBAR_ENABLED") then
  71.         GW.LoadPowerBar()
  72.     end
  73.  
  74.     if GetSetting("CLASS_POWER") then
  75.         GW.LoadClassPowers()
  76.     end
  77.  
  78.     if GetSetting("BAGS_ENABLED") then
  79.         GW.LoadBag()
  80.         GW.LoadBank()
  81.     end
  82.  
  83.     if GetSetting("USE_BATTLEGROUND_HUD") then
  84.         GW.LoadBattlegrounds()
  85.     end
  86.  
  87.     GW.LoadCharacter()
  88.  
  89.     GW.LoadBreathMeter()
  90.  
  91.     --Create unitframes
  92.     if GetSetting("FOCUS_ENABLED") then
  93.         GW.LoadFocus()
  94.         if GetSetting("focus_TARGET_ENABLED") then
  95.             GW.LoadTargetOfFocus()
  96.         end
  97.     end
  98.     if GetSetting("TARGET_ENABLED") then
  99.         GW.LoadTarget()
  100.         if GetSetting("target_TARGET_ENABLED") then
  101.             GW.LoadTargetOfTarget()
  102.         end
  103.  
  104.         -- move zone text frame
  105.         if not IsFrameModified("ZoneTextFrame") then
  106.             Debug("moving ZoneTextFrame")
  107.             ZoneTextFrame:ClearAllPoints()
  108.             ZoneTextFrame:SetPoint("TOP", UIParent, "TOP", 0, -175)
  109.         end
  110.  
  111.         -- move error frame
  112.         if not IsFrameModified("UIErrorsFrame") then
  113.             Debug("moving UIErrorsFrame")
  114.             UIErrorsFrame:ClearAllPoints()
  115.             UIErrorsFrame:SetPoint("TOP", UIParent, "TOP", 0, -190)
  116.         end
  117.     end
  118.  
  119.     -- create pet frame
  120.     if GetSetting("PETBAR_ENABLED") then
  121.         GW.LoadPetFrame()
  122.     end
  123.  
  124.     -- create action bars
  125.     if GetSetting("ACTIONBARS_ENABLED") then
  126.         OnUpdateActionBars = GW.LoadActionBars()
  127.     end
  128.  
  129.     -- create buff frame
  130.     if GetSetting("PLAYER_BUFFS_ENABLED") then
  131.         GW.LoadBuffs()
  132.     end
  133.  
  134.     -- create new microbuttons
  135.     --[[
  136.     if GetSetting('CHATBUBBLES_ENABLED') then
  137.         GW.LoadChatBubbles()
  138.     end
  139.     --]]
  140.     GW.LoadMicroMenu()
  141.  
  142.     if GetSetting("GROUP_FRAMES") then
  143.         GW.LoadPartyFrames()
  144.         GW.LoadRaidFrames()
  145.     end
  146.  
  147.     UpdateHudScale()
  148.  
  149.     if (forcedMABags) then
  150.         Notice(GwLocalization["DISABLED_MA_BAGS"])
  151.     end
  152.  
  153.     l:SetScript("OnUpdate", gw_OnUpdate)
  154. end

This is the changed code:

Lua Code:
  1. local function gw_OnEvent(self, event, name)
  2.     if loaded then
  3.         return
  4.     end
  5.     if event ~= "PLAYER_LOGIN" then
  6.         return
  7.     end
  8.     loaded = true
  9.  
  10.     -- setup our frame pool
  11.     GW.Pools = CreatePoolCollection()
  12.  
  13.     -- disable Move Anything bag handling
  14.     disableMABags()
  15.  
  16.     -- hook debug output if relevant
  17.     local dev_dbg_tab = GetSetting("DEV_DBG_CHAT_TAB")
  18.     if dev_dbg_tab and dev_dbg_tab > 0 and _G["ChatFrame" .. dev_dbg_tab] then
  19.         print("hooking Debug to chat tab #" .. dev_dbg_tab)
  20.         dbgTab = dev_dbg_tab
  21.         GW.AlertTestsSetup()
  22.         GW.inDebug = true
  23.     else
  24.         GW.inDebug = false
  25.     end
  26.  
  27.     --Create Settings window
  28.     GW.LoadSettings()
  29.     GW.DisplaySettings()
  30.  
  31.     --Create hud art
  32.     GW.LoadHudArt()
  33.  
  34.     --Create experiencebar
  35.   --  GW.LoadXPBar()
  36.  
  37.   --  if GetSetting("FONTS_ENABLED") then
  38.   --      GW.LoadFonts()
  39.   --  end
  40.  
  41.   --  if GetSetting("CASTINGBAR_ENABLED") then
  42.   --      GW.LoadCastingBar()
  43.   --  end
  44.  
  45.     if GetSetting("MINIMAP_ENABLED") then
  46.         GW.LoadMinimap()
  47.     end
  48.  
  49.     if GetSetting("QUESTTRACKER_ENABLED") then
  50.         GW.LoadQuestTracker()
  51.     end
  52.  
  53. --    if GetSetting("TOOLTIPS_ENABLED") then
  54. --        GW.LoadTooltips()
  55. --    end
  56.  
  57. --    if GetSetting("QUESTVIEW_ENABLED") then
  58. --        GW.LoadQuestview()
  59. --    end
  60.  
  61.     if GetSetting("CHATFRAME_ENABLED") then
  62.         GW.LoadChat()
  63.     end
  64.  
  65.     --Create player hud
  66. --    if GetSetting("HEALTHGLOBE_ENABLED") then
  67. --        GW.LoadPlayerHud()
  68. --    end
  69.  
  70. --    if GetSetting("POWERBAR_ENABLED") then
  71. --        GW.LoadPowerBar()
  72. --    end
  73.  
  74. --    if GetSetting("CLASS_POWER") then
  75. --        GW.LoadClassPowers()
  76. --    end
  77.  
  78. --    if GetSetting("BAGS_ENABLED") then
  79. --        GW.LoadBag()
  80. --        GW.LoadBank()
  81. --    end
  82.  
  83.     if GetSetting("USE_BATTLEGROUND_HUD") then
  84.         GW.LoadBattlegrounds()
  85.     end
  86.  
  87.     GW.LoadCharacter()
  88.  
  89.     GW.LoadBreathMeter()
  90.  
  91.     --Create unitframes
  92.     if GetSetting("FOCUS_ENABLED") then
  93.         GW.LoadFocus()
  94.         if GetSetting("focus_TARGET_ENABLED") then
  95.             GW.LoadTargetOfFocus()
  96.         end
  97.     end
  98.     if GetSetting("TARGET_ENABLED") then
  99.         GW.LoadTarget()
  100.         if GetSetting("target_TARGET_ENABLED") then
  101.             GW.LoadTargetOfTarget()
  102.         end
  103.  
  104.         -- move zone text frame
  105.         if not IsFrameModified("ZoneTextFrame") then
  106.             Debug("moving ZoneTextFrame")
  107.             ZoneTextFrame:ClearAllPoints()
  108.             ZoneTextFrame:SetPoint("TOP", UIParent, "TOP", 0, -175)
  109.         end
  110.  
  111.         -- move error frame
  112.         if not IsFrameModified("UIErrorsFrame") then
  113.             Debug("moving UIErrorsFrame")
  114.             UIErrorsFrame:SetFont( font, 9, outline )
  115.             UIErrorsFrame:ClearAllPoints()
  116.             UIErrorsFrame:SetPoint('TOP',UIParent,'TOP',0,-5)
  117.         end
  118.     end
  119.  
  120.     -- create pet frame
  121.     if GetSetting("PETBAR_ENABLED") then
  122.         GW.LoadPetFrame()
  123.     end
  124.  
  125.     -- create action bars
  126. --    if GetSetting("ACTIONBARS_ENABLED") then
  127. --        OnUpdateActionBars = GW.LoadActionBars()
  128. --    end
  129.  
  130.     -- create buff frame
  131. --    if GetSetting("PLAYER_BUFFS_ENABLED") then
  132. --        GW.LoadBuffs()
  133. --    end
  134.  
  135.     -- create new microbuttons
  136.     --[[
  137.     if GetSetting('CHATBUBBLES_ENABLED') then
  138.         GW.LoadChatBubbles()
  139.     end
  140.     --]]
  141.   --  GW.LoadMicroMenu()
  142.  
  143.   --  if GetSetting("GROUP_FRAMES") then
  144.   --      GW.LoadPartyFrames()
  145.   --      GW.LoadRaidFrames()
  146.   --  end
  147.  
  148.     UpdateHudScale()
  149.  
  150.     if (forcedMABags) then
  151.         Notice(GwLocalization["DISABLED_MA_BAGS"])
  152.     end
  153.  
  154.     l:SetScript("OnUpdate", gw_OnUpdate)
  155. end

Please notice that, despite GW2 UI having modules, some of the functions I disable aren't available to be disabled through modules, such as the experience bar. I don't like it personally, and I have to disable it manually every time. The fonts are another nuisance.

I also change mainbar\hud.lua in this part:

Original:

Lua Code:
  1. local function selectBg()
  2.     if not GetSetting("HUD_SPELL_SWAP") then
  3.         return
  4.     end
  5.     local right = "Interface\\AddOns\\GW2_UI\\textures\\rightshadow"
  6.     local left = "Interface\\AddOns\\GW2_UI\\textures\\leftshadow"
  7.     _G["GwActionBarHudLEFT"]:SetVertexColor(1, 1, 1, 1)
  8.     _G["GwActionBarHudRIGHT"]:SetVertexColor(1, 1, 1, 1)
  9.  
  10.     if UnitIsDeadOrGhost("player") then
  11.         right = "Interface\\AddOns\\GW2_UI\\textures\\rightshadow_dead"
  12.         left = "Interface\\AddOns\\GW2_UI\\textures\\leftshadow_dead"
  13.     end
  14.  
  15.     if UnitAffectingCombat("player") then
  16.         right = "Interface\\AddOns\\GW2_UI\\textures\\rightshadowcombat"
  17.         left = "Interface\\AddOns\\GW2_UI\\textures\\leftshadowcombat"
  18.         _G["GwActionBarHudLEFT"]:SetVertexColor(1, 1, 1, 0.45)
  19.         _G["GwActionBarHudRIGHT"]:SetVertexColor(1, 1, 1, 0.45)
  20.  
  21.         for i = 1, 40 do
  22.             local _, _, _, _, _, _, _, _, _, spellID = UnitBuff("player", i)
  23.             if spellID ~= nil and action_hud_auras[spellID] ~= nil then
  24.                 left = action_hud_auras[spellID]["left"]
  25.                 right = action_hud_auras[spellID]["right"]
  26.             end
  27.         end
  28.     end
  29.  
  30.     if currentTexture ~= left then
  31.         currentTexture = left
  32.         _G["GwActionBarHudLEFT"]:SetTexture(left)
  33.         _G["GwActionBarHudRIGHT"]:SetTexture(right)
  34.     end
  35. end

Changed:
Lua Code:
  1. local function selectBg()
  2.     if not GetSetting("HUD_SPELL_SWAP") then
  3.         return
  4.     end
  5.     local right = "Interface\\AddOns\\GW2_UI\\textures\\rightshadow"
  6.     local left = "Interface\\AddOns\\GW2_UI\\textures\\leftshadow"
  7.  
  8.     if UnitIsDeadOrGhost("player") then
  9.         right = "Interface\\AddOns\\GW2_UI\\textures\\rightshadow_dead"
  10.         left = "Interface\\AddOns\\GW2_UI\\textures\\leftshadow_dead"
  11.     end
  12.  
  13.     if UnitAffectingCombat("player") then
  14.         right = "Interface\\AddOns\\GW2_UI\\textures\\rightshadowcombat"
  15.         left = "Interface\\AddOns\\GW2_UI\\textures\\leftshadowcombat"
  16.  
  17.         for i = 1, 40 do
  18.             local _, _, _, _, _, _, _, _, _, spellID = UnitBuff("player", i)
  19.             if spellID ~= nil and action_hud_auras[spellID] ~= nil then
  20.                 left = action_hud_auras[spellID]["left"]
  21.                 right = action_hud_auras[spellID]["right"]
  22.             end
  23.         end
  24.     end
  25.  
  26.     if currentTexture ~= left then
  27.         currentTexture = left
  28.         _G["GwActionBarHudLEFT"]:SetTexture(left)
  29.         _G["GwActionBarHudRIGHT"]:SetTexture(right)
  30.     end
  31. end

I do so because the in-combat texture is too damn bright. Also, if I could have the standard texture (textures\\leftshadow and textures\\rightshadow) on the background at all times, behind the new ones that get added, it would be perfect. But as I see it, the authors coded the frame element to just change its own texture (when entering combat, activating buffs, etc), and not being new frames on their own.

Finally, I also change the XML file:

Original:
Lua Code:
  1. <Frames>
  2.             <Frame name="GwActionBarHud" frameStrata="BACKGROUND">
  3.                 <Size x="1024" y="256"></Size>
  4.                 <Anchors>
  5.                     <Anchor point="BOTTOM" relativePoint="BOTTOM" x="0" y="14" />
  6.                 </Anchors>
  7.                 <Layers>
  8.                     <Layer level="BACKGROUND">
  9.                         <Texture name="$parentLEFT" file="Interface\AddOns\GW2_UI\textures\leftshadow" parentKey="Background">
  10.                             <Size x="512" y="256"></Size>
  11.                             <Anchors>
  12.                                 <Anchor point="LEFT" relativePoint="LEFT" x="0" y="0" />
  13.                             </Anchors>
  14.                         </Texture>
  15.  
  16.                         <Texture name="$parentRIGHT" file="Interface\AddOns\GW2_UI\textures\rightshadow" parentKey="Background">
  17.                             <Size x="512" y="256"></Size>
  18.                             <Anchors>
  19.                                 <Anchor point="RIGHT" relativePoint="RIGHT" x="0" y="0" />
  20.                             </Anchors>
  21.                         </Texture>
  22.                     </Layer>
  23.  
  24.                     <Layer textureSubLevel="3" level="BACKGROUND">
  25.                         <Texture name="$parentLEFTSWIM" file="Interface\AddOns\GW2_UI\textures\leftshadowswim" parentKey="Background">
  26.                             <Size x="512" y="256"></Size>
  27.                             <Anchors>
  28.                                 <Anchor point="LEFT" relativePoint="LEFT" x="0" y="0" />
  29.                             </Anchors>
  30.                         </Texture>
  31.  
  32.                         <Texture name="$parentRIGHTSWIM" file="Interface\AddOns\GW2_UI\textures\rightshadowswim" parentKey="Background">
  33.                             <Size x="512" y="256"></Size>
  34.                             <Anchors>
  35.                                 <Anchor point="RIGHT" relativePoint="RIGHT" x="0" y="0" />
  36.                             </Anchors>
  37.                         </Texture>
  38.                     </Layer>
  39.                     <Layer textureSubLevel="4" level="BACKGROUND">
  40.                         <Texture name="$parentLEFTBLOOD" file="Interface\AddOns\GW2_UI\textures\bloodLeft" parentKey="Background">
  41.                             <Size x="512" y="256"></Size>
  42.                             <Anchors>
  43.                                 <Anchor point="LEFT" relativePoint="LEFT" x="0" y="0" />
  44.                             </Anchors>
  45.                         </Texture>
  46.  
  47.                         <Texture name="$parentRIGHTBLOOD" file="Interface\AddOns\GW2_UI\textures\bloodRight" parentKey="Background">
  48.                             <Size x="512" y="256"></Size>
  49.                             <Anchors>
  50.                                 <Anchor point="RIGHT" relativePoint="RIGHT" x="0" y="0" />
  51.                             </Anchors>
  52.                         </Texture>
  53.  
  54.                     </Layer>
  55.  
  56.                     <Layer textureSubLevel="5" level="BACKGROUND">
  57.  
  58.                     </Layer>
  59.                 </Layers>
  60.             </Frame>
  61.  
  62.  
  63.         </Frames>
Changed:
Lua Code:
  1. <Frames>
  2.             <Frame name="GwActionBarHud" frameStrata="BACKGROUND">
  3.                 <Size x="1024" y="256"></Size>
  4.                 <Anchors>
  5.                     <Anchor point="BOTTOM" relativePoint="BOTTOM" x="0" y="0" />
  6.                 </Anchors>
  7.                 <Layers>
  8.                     <Layer level="BACKGROUND">
  9.                         <Texture name="$parentLEFT" file="Interface\AddOns\GW2_UI\textures\leftshadow" parentKey="Background">
  10.                             <Size x="512" y="256"></Size>
  11.                             <Anchors>
  12.                                 <Anchor point="LEFT" relativePoint="LEFT" x="0" y="0" />
  13.                             </Anchors>
  14.                         </Texture>
  15.  
  16.                         <Texture name="$parentRIGHT" file="Interface\AddOns\GW2_UI\textures\rightshadow" parentKey="Background">
  17.                             <Size x="512" y="256"></Size>
  18.                             <Anchors>
  19.                                 <Anchor point="RIGHT" relativePoint="RIGHT" x="0" y="0" />
  20.                             </Anchors>
  21.                         </Texture>
  22.                     </Layer>
  23.  
  24.                     <Layer textureSubLevel="3" level="BACKGROUND">
  25.                         <Texture name="$parentLEFTSWIM" file="Interface\AddOns\GW2_UI\textures\leftshadowswim" parentKey="Background">
  26.                             <Size x="512" y="256"></Size>
  27.                             <Anchors>
  28.                                 <Anchor point="LEFT" relativePoint="LEFT" x="0" y="0" />
  29.                             </Anchors>
  30.                         </Texture>
  31.  
  32.                         <Texture name="$parentRIGHTSWIM" file="Interface\AddOns\GW2_UI\textures\rightshadowswim" parentKey="Background">
  33.                             <Size x="512" y="256"></Size>
  34.                             <Anchors>
  35.                                 <Anchor point="RIGHT" relativePoint="RIGHT" x="0" y="0" />
  36.                             </Anchors>
  37.                         </Texture>
  38.                     </Layer>
  39.                     <Layer textureSubLevel="4" level="BACKGROUND">
  40.                         <Texture name="$parentLEFTBLOOD" file="Interface\AddOns\GW2_UI\textures\bloodLeft" parentKey="Background">
  41.                             <Size x="512" y="256"></Size>
  42.                             <Anchors>
  43.                                 <Anchor point="LEFT" relativePoint="LEFT" x="0" y="0" />
  44.                             </Anchors>
  45.                         </Texture>
  46.  
  47.                         <Texture name="$parentRIGHTBLOOD" file="Interface\AddOns\GW2_UI\textures\bloodRight" parentKey="Background">
  48.                             <Size x="512" y="256"></Size>
  49.                             <Anchors>
  50.                                 <Anchor point="RIGHT" relativePoint="RIGHT" x="0" y="0" />
  51.                             </Anchors>
  52.                         </Texture>
  53.  
  54.                     </Layer>
  55.  
  56.                     <Layer textureSubLevel="5" level="BACKGROUND">
  57.  
  58.                     </Layer>
  59.                 </Layers>
  60.             </Frame>
  61.  
  62.  
  63.         </Frames>

I just changed x and y to be 0 because of how my own UI is organized.

I believe all that stuff should be simple to code around. Where do I get started on an addon that alters the positioning of GW2 UI's frames and disables some of its features?


All times are GMT -6. The time now is 04:59 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI