WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   need help with mouseovers and hiding frames (https://www.wowinterface.com/forums/showthread.php?t=52801)

coldfiredi 10-06-15 07:26 AM

need help with mouseovers and hiding frames
 
Im trying to make a minimal UI because there are a lot of frames i dont need, Below is what im trying to accomplish in lua.


mouseover for action bar 1, so unless i put my mouse over the bar it is always alpha 0 or hidden.

Always have the objective tracker frames minimized, UNLESS I click to expand it myself. (if its possible to just hide it, id like that more)

hide minimap or have minimap only show on mouseover

i currently use the following and it does not work, it instead remove the textures and make the map transparent.
Code:

Minimap:SetAlpha(0)

Minimap:SetScript("OnEnter", function() Minimap:SetAlhpa(1) end)
Minimap:SetScript("OnLeave", function() Minimap:SetAlpha(0) end)

I would like to remove or hide all uniteframes like target, self, focus. party, raid, etc ( i will use grid2 for my raid frames)

this is pretty much what i want to achieve, this isnt mine. http://i.imgur.com/a02VGtn.jpg

Nikita S. Doroshenko 10-06-15 10:02 AM

This should works perfectly, this code will Hide your Minimap and Objective tracker frame, and it will show Minimap onEnter event:

Lua Code:
  1. local function HideAdvancedInderface()
  2.     -- [[ ###### HIDE CERTAIN FRAMES ###### ]]
  3.     local objects = { MinimapCluster, ObjectiveTrackerFrame } -- [[We can add here more frames for hiding on Login, for example: UIErrorsFrame, PlayerFrame, TargetFrame, PetFrame, MainMenuBar and so on...]]
  4.     for _,object in pairs(objects) do
  5.         if object then
  6.             object:Hide()
  7.         end
  8.     end
  9.     -- [[ ###### HIDE/SHOW MINIMAP ON MOUSE ENTER/LEAVE ###### ]]
  10.     local function MinimapTrigger()
  11.         local frame = CreateFrame("FRAME","MinimapTrigger",UIParent)
  12.         frame:SetAllPoints(MinimapCluster)
  13.         frame:Show()
  14.         frame:SetScript("OnEnter", function() MinimapCluster:Show() end)
  15.         frame:SetScript("OnLeave", function() MinimapCluster:Hide() end)
  16.     end
  17.     MinimapTrigger()
  18. end
  19. HideAdvancedInderface()

If you want to hide special frame, for example target, self, focus. party, raid, then change this line:
Lua Code:
  1. local objects = { MinimapCluster, ObjectiveTrackerFrame }
To something like this:
Lua Code:
  1. local objects = { MinimapCluster, ObjectiveTrackerFrame, UIErrorsFrame, PlayerFrame, TargetFrame, PetFrame }
You can find Frame names by typing in game chat "/fstack" without quotes. Then hover over frame that you want to hide, and search for Orange Fame Name, and add it to the list of objects to hide:
Lua Code:
  1. local objects = {  }

For your action bars I suggest you to use Bartender of other similar AddOns.

Remember that you can't :Hide() and :Show() Action Bars in combat (Blizzard block this for security and anti-cheat/bot reason), but you can :SetAlpha([value])

P.S. Use this code after "PLAYER_ENTERING_WORLD" Event to make thing works correctly, for sure hide all frames when LogIn, other way, some frames might not be hidden.
I use XML to load my AddOn, and track an events (but most of AddOn authors uses lua), this is XML i use to load my own AddOns:

Code:

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
       
        <Script file="MyAddOnLuaFile.lua"/>
        <Frame>
                <Scripts>
                        <OnLoad>
                                self:RegisterEvent("PLAYER_ENTERING_WORLD")
                        </OnLoad>
                        <OnEvent>
                                self:UnregisterEvent("PLAYER_ENTERING_WORLD")
                                MyGlobalFunction()
                        </OnEvent>
                </Scripts>
        </Frame>
</Ui>


Nikita S. Doroshenko 10-06-15 10:16 AM

1 Attachment(s)
Just to make everything easier for you, I build and pack all above in to simple AddOn.

For hiding PlayerFrame and TargetFrame i suggest you to use code from this topic.

Phanx 10-07-15 12:41 AM

Quote:

Originally Posted by Nikita S. Doroshenko (Post 311347)
Lua Code:
  1. local function HideAdvancedInderface()
  2.     -- code
  3. end
  4. HideAdvancedInderface()

Just FYI, there's absolutely no benefit to wrapping one-time code in a function, then immediately calling the function. Just write the code and skip the function wrapper.

jeruku 10-07-15 06:51 AM

As Phanx pointed out that is not necessary. If you are concerned about variable scoping you can use a do-end block.

Lua Code:
  1. local scopeA = 4
  2. do
  3.    local scopeB = 5
  4.    scopeA = scopeA + scopeB
  5. end
  6. print(scopeA, scopeB)
That will output "9 nil" since scopeB ended with the block.

Nikita S. Doroshenko 10-07-15 03:03 PM

Quote:

Originally Posted by jeruku (Post 311380)
As Phanx pointed out that is not necessary. If you are concerned about variable scoping you can use a do-end block.

Lua Code:
  1. local scopeA = 4
  2. do
  3.    local scopeB = 5
  4.    scopeA = scopeA + scopeB
  5. end
  6. print(scopeA, scopeB)
That will output "9 nil" since scopeB ended with the block.

Thank you for pointing me guys, I just like to separate my code in to blocks (I like this way of code organization), so in my AddOn, all my code packed in to different functions.
I never programmed before, so I don't know any languages at all, only a bit of lua, and I'm learing the best practice. And for sure, i want to write my code well and in correct way.
But even when i see Blizzard's code (who could think, it's one of the top game company in a world, and most known company), and their interface code looks messy in some files, and style of code different, and looks like that they don't even have a code standard, I find this very strange. Same thing about graphic UI standard, there are lot's of little bugs or mess.

Phanx 10-08-15 02:06 AM

Quote:

Originally Posted by Nikita S. Doroshenko (Post 311388)
But even when i see Blizzard's code (who could think, it's one of the top game company in a world, and most known company), and their interface code looks messy in some files, and style of code different, and looks like that they don't even have a code standard, I find this very strange.

Don't use Blizzard's code as an example of anything other than basic API usage (eg. what values are returned by what functions). It is indeed messy and inconsistent, and often is not just stylistically bad, but functionally bad as well. It's full of unnecessary globals, excess table and function creations, and other unsavory habits. There are also plenty of examples to be found in there of code written by someone who clearly was not familiar with Lua at all... this is my all-time favorite right here:

https://www.townlong-yak.com/framexm...arent.lua#3627

Whoever wrote that apparently did not know about string.upper. :rolleyes:


All times are GMT -6. The time now is 01:46 PM.

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