Thread Tools Display Modes
09-01-15, 11:31 AM   #1
XanUI
A Murloc Raider
 
XanUI's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2012
Posts: 9
DisableAddon() only per player!

Hi! First of all i am a total beginner at LUA
I made a little UIcompilation with a setup window which is an addon where you can choose the layout.
Because i only want to see this window once on first login i made a DisableAddon() function.
Now to the issue: when i log into an alt the setup window does not appear because i disabled it for all chars in the first place.
Can anyone help me?
  Reply With Quote
09-01-15, 02:08 PM   #2
syncrow
A Flamescale Wyrmkin
 
syncrow's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 149
Use: SavedVariablesPerCharacter

lua:
Lua Code:
  1. local function DoStuffOnFirstLogin()
  2.     -- load stuff
  3. end
  4.  
  5. local install = CreateFrame("Frame")
  6.  
  7. install:RegisterEvent("ADDON_LOADED")
  8.  
  9. install:SetScript("OnEvent",function(self,event,...)
  10.     if ... == "AddOnName" then
  11.         if AddOnVariable then
  12.             return
  13.         else
  14.             AddOnVariable = true
  15.            
  16.             DoStuffOnFirstLogin()
  17.         end
  18.     end
  19. end)

toc:
Code:
## Interface: 60200
## Title: AddOnName
## Notes: AddOnNotes
## SavedVariablesPerCharacter: AddOnVariable
__________________

Last edited by syncrow : 10-27-15 at 11:15 AM.
  Reply With Quote
09-01-15, 09:38 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Was DisableAddon() changed? It's supposed to only be on a per-character basis.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-02-15, 12:44 AM   #4
XanUI
A Murloc Raider
 
XanUI's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2012
Posts: 9
WoWWiki says:

The first time an addon is disabled (with this function or the user addon panel) it will be disabled for all characters on that realm. Every subsequent time it will enabled/disabled per character.
I have no idea how to use that to my advantage
  Reply With Quote
09-02-15, 07:28 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Ah, I was going off of wowprogramming.

Aha! Looking at the UI source (because there has to be some way to make it for only one character, as the UI can do this with the character dropdown menu)...

Lua Code:
  1. function AddonList_Enable(index, enabled)
  2.     local value
  3.  
  4.     if ( InGlue() ) then
  5.         local character = UIDropDownMenu_GetSelectedValue(AddonCharacterDropDown);
  6.         local setForAll = false;
  7.         if ( character == ALL ) then
  8.             setForAll = true;
  9.             character = nil;
  10.         end
  11.         value = setForAll or character
  12.     else
  13.         value = UIDropDownMenu_GetSelectedValue(AddonCharacterDropDown)
  14.     end
  15.     if ( enabled ) then
  16.         PlaySound("igMainMenuOptionCheckBoxOn");
  17.         EnableAddOn(index,value);
  18.     else
  19.         PlaySound("igMainMenuOptionCheckBoxOff");
  20.         DisableAddOn(index,value);
  21.     end
  22.     AddonList_Update();
  23. end
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
11-27-15, 02:35 PM   #6
XanUI
A Murloc Raider
 
XanUI's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2012
Posts: 9
So here is my Setup Code so far. This is the last problem i am encountering with my UI Compilation as mentioned above: the AddOn XanUISetup is disabled for all other Characters from the same realm after i log in on my first Char and use it.

I want it to show once on every first login on EVERY Charakter.

Code:
local xanuisetup = (...)

local bgtexture = "Interface\\AddOns\\XanUI\\Media\\Textures\\fer2.tga"
local font = "Interface\\AddOns\\XanUI\\Media\\Fonts\\font.ttf"
local border = "Interface\\AddOns\\XanUI\\Media\\Textures\\Caith.tga"
local backdrop = {
			bgFile = bgtexture,
			edgeFile = border,
			edgeSize = 16,
			insets = {
				left = 2,
				right = 2,
				top = 2,
				bottom = 2,
			}
		}

local frame = CreateFrame("frame", nil, UIParent)
    frame:SetFrameStrata("TOOLTIP")
	frame:SetPoint("CENTER")
	frame:SetSize(400, 500)
	frame:SetBackdrop(backdrop)
	frame:SetBackdropColor(0,0,0,0.7)

local HeaderText = frame:CreateFontString()
	HeaderText:SetPoint("TOP",0 , 70)
	HeaderText:SetSize(350,200)
	HeaderText:SetFont(font, 32)
	HeaderText:SetTextColor(0.5, 0, 1)
	HeaderText:SetText("Xan's UI")

local WText = frame:CreateFontString()
	WText:SetPoint("TOP")
	WText:SetSize(350,200)
	WText:SetFont(font, 16)
	WText:SetTextColor(0.5, 0.5, 0.5)
	WText:SetWordWrap(true)
	WText:SetNonSpaceWrap(false)
	WText:SetText("Welcome to XanUI!")

local GText = frame:CreateFontString()
	GText:SetPoint("Bottom", 0, -10)
	GText:SetSize(350, 200)
	GText:SetFont(font, 16)
	GText:SetWordWrap(true)
	GText:SetNonSpaceWrap(false)
	GText:SetText(" |cffc0c0c0 WARNING: Please ensure you have correctly named the folders inside the WTF folder")
	
local FText = frame:CreateFontString()
	FText:SetPoint("BOTTOM", -85, -80)
	FText:SetSize(350,200)
	FText:SetFont(font, 12)
	FText:SetTextColor(0.5, 0, 1)
	FText:SetText("Xan (EU - Blackhand)")
	
--XanUI
local button1 = CreateFrame("Button", nil, frame)
    button1:SetFrameStrata("TOOLTIP")
	button1:SetPoint("CENTER", 0, 60)
	button1:SetSize(350, 50)
	button1:SetBackdrop(backdrop)
	button1:SetBackdropColor(.07,.07,.07,1)
	button1:SetHighlightTexture("Interface\\AddOns\\XanUI\\Media\\Textures\\fer2.tga")
	button1:GetHighlightTexture() :SetVertexColor(0.5, 0, 1);
	button1:SetScript("OnClick", function (self, button, down)
	
	-- This is where the Stuff happens
		TidyPlates:ActivateTheme("Threat Plates")
		TidyPlatesOptions.primary = "Threat Plates"
		TidyPlatesOptions.secondary = "Threat Plates"		
		Gnosis:LoadConfig("XanUI", false, true, true, true)
		MovAny:ChangeProfile("XanUI")
		SlashCmdList["REFLUX"]("switch XanUI")
		DisableAddOn(xanuisetup)
		
		end)
	
	local b1t = button1:CreateFontString()
		b1t:SetPoint("CENTER")
		b1t:SetSize(350, 50)
		b1t:SetFont(font, 16)
		b1t:SetTextColor(1, 1, 1)
		b1t:SetText("Standard Layout")
		
--XanUIHeal
local button2 = CreateFrame("Button", nil, frame)
    button2:SetFrameStrata("TOOLTIP")
	button2:SetPoint("CENTER")
	button2:SetSize(350, 50)
	button2:SetBackdrop(backdrop)
	button2:SetBackdropColor(.07,.07,.07,1)
	button2:SetHighlightTexture("Interface\\AddOns\\XanUI\\Media\\Textures\\fer2.tga")
	button2:GetHighlightTexture() :SetVertexColor(0.5, 0, 1);
	button2:SetScript("OnClick", function (self, button, down)
	
	-- This is where the Stuff happens
		Gnosis:LoadConfig("XanUIHeal", false, true, true, true)
		TidyPlates:ActivateTheme("Threat Plates")
		TidyPlatesOptions.primary = "Threat Plates"
		TidyPlatesOptions.secondary = "Threat Plates"
		MovAny:ChangeProfile("XanUIHeal")
		SlashCmdList["REFLUX"]("switch XanUIHeal")
		DisableAddOn(xanuisetup)
		
		end)
	
	local b2t = button2:CreateFontString()
		b2t:SetPoint("Center")
		b2t:SetSize(350, 50)
		b2t:SetFont(font, 16)
		b2t:SetTextColor(1, 1, 1)
		b2t:SetText("Healing Layout")
		
--Disable	
local button3 = CreateFrame("Button", nil, frame)
    button3:SetFrameStrata("TOOLTIP")
	button3:SetPoint("CENTER", 0, -60)
	button3:SetSize(350, 50)
	button3:SetBackdrop(backdrop)
	button3:SetBackdropColor(.07,.07,.07,1)
	button3:SetHighlightTexture("Interface\\AddOns\\XanUI\\Media\\Textures\\fer2.tga")
	button3:GetHighlightTexture() :SetVertexColor(0.5, 0, 1);
	button3:SetScript("OnClick", function (self, button, down)
		DisableAddOn(xanuisetup)
		ReloadUI()
		end)

local b3t = button3:CreateFontString()
	b3t:SetPoint("CENTER")
	b3t:SetSize(350, 50)
	b3t:SetFont(font, 16)
	b3t:SetTextColor(1, 1, 1)
	b3t:SetText("Disable This Window")
Can u help me (one hopefully last time ) please?
  Reply With Quote
11-30-15, 11:46 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by XanUI View Post
I want it to show once on every first login on EVERY Charakter.
Use a per-char saved variable instead of disabling the addon. Delay everything your addon does until its ADDON_LOADED event fires. When the event fires, check the saved variable. If it doesn't exist, create your addon's UI and do all the stuff, and set the varaiable. If it does exist, just return out without creating any objects or doing anything.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-01-15, 01:39 AM   #8
john21wall
A Kobold Labourer
Join Date: Nov 2015
Posts: 1
Thanks, I was looking for such clues.
__________________
ekobord
  Reply With Quote
12-12-15, 02:39 AM   #9
XanUI
A Murloc Raider
 
XanUI's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2012
Posts: 9
This is what i got so far... sadly the Setup Window doesn't even show up now
hopefully you find the error.

Code:
local xanuisetup = (...)

local function DoStuffOnFirstLogin()
    
local bgtexture = "Interface\\AddOns\\XanUI\\Media\\Textures\\fer2.tga"
local font = "Interface\\AddOns\\XanUI\\Media\\Fonts\\font.ttf"
local border = "Interface\\AddOns\\XanUI\\Media\\Textures\\Caith.tga"
local backdrop = {
			bgFile = bgtexture,
			edgeFile = border,
			edgeSize = 16,
			insets = {
				left = 2,
				right = 2,
				top = 2,
				bottom = 2,
			}
		}

--local frame = CreateFrame("frame", nil, UIParent)
    frame:SetFrameStrata("TOOLTIP")
	frame:SetPoint("CENTER")
	frame:SetSize(400, 500)
	frame:SetBackdrop(backdrop)
	frame:SetBackdropColor(0,0,0,0.7)

local HeaderText = frame:CreateFontString()
	HeaderText:SetPoint("TOP",0 , 70)
	HeaderText:SetSize(350,200)
	HeaderText:SetFont(font, 32)
	HeaderText:SetTextColor(0.5, 0, 1)
	HeaderText:SetText("Xan's UI")

local WText = frame:CreateFontString()
	WText:SetPoint("TOP")
	WText:SetSize(350,200)
	WText:SetFont(font, 16)
	WText:SetTextColor(0.5, 0.5, 0.5)
	WText:SetWordWrap(true)
	WText:SetNonSpaceWrap(false)
	WText:SetText("Welcome to XanUI!")

local GText = frame:CreateFontString()
	GText:SetPoint("Bottom", 0, -10)
	GText:SetSize(350, 200)
	GText:SetFont(font, 16)
	GText:SetWordWrap(true)
	GText:SetNonSpaceWrap(false)
	GText:SetText(" |cffc0c0c0 WARNING: Please ensure you have correctly named the folders inside the WTF folder")
	
local FText = frame:CreateFontString()
	FText:SetPoint("BOTTOM", -85, -80)
	FText:SetSize(350,200)
	FText:SetFont(font, 12)
	FText:SetTextColor(0.5, 0, 1)
	FText:SetText("Xan (EU - Blackhand)")
	
--XanUI
local button1 = CreateFrame("Button", nil, frame)
    button1:SetFrameStrata("TOOLTIP")
	button1:SetPoint("CENTER", 0, 60)
	button1:SetSize(350, 50)
	button1:SetBackdrop(backdrop)
	button1:SetBackdropColor(.07,.07,.07,1)
	button1:SetHighlightTexture("Interface\\AddOns\\XanUI\\Media\\Textures\\fer2.tga")
	button1:GetHighlightTexture() :SetVertexColor(0.5, 0, 1);
	button1:SetScript("OnClick", function (self, button, down)
	
	-- This is where the Stuff happens
		TidyPlates:ActivateTheme("Threat Plates")
		TidyPlatesOptions.primary = "Threat Plates"
		TidyPlatesOptions.secondary = "Threat Plates"		
		Gnosis:LoadConfig("XanUI", false, true, true, true)
		MovAny:ChangeProfile("XanUI")
		SlashCmdList["REFLUX"]("switch XanUI")
		--DisableAddOn(xanuisetup)
		DisableAddOn (xanuisetup,UnitName("player"))
		
		end)
	
	local b1t = button1:CreateFontString()
		b1t:SetPoint("CENTER")
		b1t:SetSize(350, 50)
		b1t:SetFont(font, 16)
		b1t:SetTextColor(1, 1, 1)
		b1t:SetText("Standard Layout")
		
--XanUIHeal
local button2 = CreateFrame("Button", nil, frame)
    button2:SetFrameStrata("TOOLTIP")
	button2:SetPoint("CENTER")
	button2:SetSize(350, 50)
	button2:SetBackdrop(backdrop)
	button2:SetBackdropColor(.07,.07,.07,1)
	button2:SetHighlightTexture("Interface\\AddOns\\XanUI\\Media\\Textures\\fer2.tga")
	button2:GetHighlightTexture() :SetVertexColor(0.5, 0, 1);
	button2:SetScript("OnClick", function (self, button, down)
	
	-- This is where the Stuff happens
		Gnosis:LoadConfig("XanUIHeal", false, true, true, true)
		TidyPlates:ActivateTheme("Threat Plates")
		TidyPlatesOptions.primary = "Threat Plates"
		TidyPlatesOptions.secondary = "Threat Plates"
		MovAny:ChangeProfile("XanUIHeal")
		SlashCmdList["REFLUX"]("switch XanUIHeal")
		--DisableAddOn(xanuisetup)
		DisableAddOn (xanuisetup,UnitName("player"))
		
		end)
	
	local b2t = button2:CreateFontString()
		b2t:SetPoint("Center")
		b2t:SetSize(350, 50)
		b2t:SetFont(font, 16)
		b2t:SetTextColor(1, 1, 1)
		b2t:SetText("Healing Layout")
		
--Disable	
local button3 = CreateFrame("Button", nil, frame)
    button3:SetFrameStrata("TOOLTIP")
	button3:SetPoint("CENTER", 0, -60)
	button3:SetSize(350, 50)
	button3:SetBackdrop(backdrop)
	button3:SetBackdropColor(.07,.07,.07,1)
	button3:SetHighlightTexture("Interface\\AddOns\\XanUI\\Media\\Textures\\fer2.tga")
	button3:GetHighlightTexture() :SetVertexColor(0.5, 0, 1);
	button3:SetScript("OnClick", function (self, button, down)
		DisableAddOn (xanuisetup,UnitName("player"))
		--DisableAddOn(xanuisetup)
		ReloadUI()
		end)

local b3t = button3:CreateFontString()
	b3t:SetPoint("CENTER")
	b3t:SetSize(350, 50)
	b3t:SetFont(font, 16)
	b3t:SetTextColor(1, 1, 1)
	b3t:SetText("Disable This Window")
end

local frame = CreateFrame("frame", nil, UIParent)  --local install = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
 
frame:SetScript("OnEvent",function(self,event,...)
    if ... == "XanUI Setup" then
        if XanuiSetupDB then
            return
        else
            XanuiSetupDB = true         
            DoStuffOnFirstLogin()
        end
    end
end)
toc file:
Code:
## Interface: 60200
## Title: XanUI Setup
## Notes: Setup Box for inital Config. Enable on first use!
## SavedVariablesPerCharacter: XanuiSetupDB
XanUISetup.lua
  Reply With Quote
12-12-15, 03:08 PM   #10
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Lua Code:
  1. frame:SetScript("OnEvent",function(self,event,addon)
  2.     if addon == "XanUI Setup" then
  3.         if XanuiSetupDB then
  4.             return
  5.         else
  6.             XanuiSetupDB = true        
  7.             DoStuffOnFirstLogin()
  8.         end
  9.     end
  10. end)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-12-15, 03:33 PM   #11
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
After downloading "XanUI" (which is 70MB, btw), it would appear the name of the directory is "XanUISetup", not "XanUI Setup", and that's the name you should be checking for in the event handler.

You can avoid this confusion by just fetching the actual addon name inside the addon itself, which you already have from local xanuisetup = (...), eg:
Lua Code:
  1. frame:SetScript("OnEvent", function(self, event, addon)
  2.     if addon == xanuisetup then
  3.         if XanuiSetupDB then
  4.             return
  5.         else
  6.             XanuiSetupDB = true        
  7.             DoStuffOnFirstLogin()
  8.         end
  9.     end
  10. end)

Last edited by semlar : 12-12-15 at 03:41 PM.
  Reply With Quote
12-12-15, 05:04 PM   #12
XanUI
A Murloc Raider
 
XanUI's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2012
Posts: 9
Awesome! It works! It hast 70Mb because of Clean Icons ^^

Thanks Guys!
  Reply With Quote
12-13-15, 01:53 PM   #13
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I would point users towards that download page instead.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » DisableAddon() only per player!


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