Quantcast
need help with mouseovers and hiding frames - WoWInterface
Thread Tools Display Modes
10-06-15, 07:26 AM   #1
coldfiredi
Guest
Posts: n/a
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
  Reply With Quote
10-06-15, 10:02 AM   #2
Nikita S. Doroshenko
A Cyclonian
 
Nikita S. Doroshenko's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 44
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>

Last edited by Nikita S. Doroshenko : 10-06-15 at 10:11 AM.
  Reply With Quote
10-06-15, 10:16 AM   #3
Nikita S. Doroshenko
A Cyclonian
 
Nikita S. Doroshenko's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 44
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.
Attached Files
File Type: zip Test.zip (1.6 KB, 68 views)

Last edited by Nikita S. Doroshenko : 10-06-15 at 10:19 AM.
  Reply With Quote
10-07-15, 12:41 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Nikita S. Doroshenko View Post
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.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
10-07-15, 06:51 AM   #5
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 215
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.
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
  Reply With Quote
10-07-15, 03:03 PM   #6
Nikita S. Doroshenko
A Cyclonian
 
Nikita S. Doroshenko's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 44
Originally Posted by jeruku View Post
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.

Last edited by Nikita S. Doroshenko : 10-07-15 at 03:07 PM.
  Reply With Quote
10-08-15, 02:06 AM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Nikita S. Doroshenko View Post
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.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » need help with mouseovers and hiding frames

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off