View Single Post
08-19-18, 04:25 PM   #1
Nikita S. Doroshenko
A Cyclonian
 
Nikita S. Doroshenko's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 45
How can I hooksecurefunc with colon like this: "MainMenuBarMixin:OnShow"

I spend so much time trying to figure it out by myself, but unfortunately no luck.

This is blizard code mainMenuBar.lua:
Code:
local MAINMENU_SLIDETIME = 0.30;
local MAINMENU_GONEYPOS = 130;	--Distance off screen for MainMenuBar to be completely hidden
local MAINMENU_XPOS = 0;
MAIN_MENU_BAR_MARGIN = 75;		-- number of art pixels on one side, used by UIParent_ManageFramePositions. It's not the art's full size, don't care about the gryphon's tail.

MainMenuBarMixin = { };
function MainMenuBarMixin:OnStatusBarsUpdated()
	self:SetPositionForStatusBars(); 
end

function MainMenuBarMixin:OnLoad()
	self:RegisterEvent("ACTIONBAR_PAGE_CHANGED");
	self:RegisterEvent("CURRENCY_DISPLAY_UPDATE");
	self:RegisterEvent("UNIT_LEVEL");
	self:RegisterEvent("PLAYER_ENTERING_WORLD");
	self:RegisterEvent("TRIAL_STATUS_UPDATE");
	self:RegisterEvent("DISPLAY_SIZE_CHANGED");
	self:RegisterEvent("UI_SCALE_CHANGED");

	CreateFrame("FRAME", "StatusTrackingBarManager", self, "StatusTrackingBarManagerTemplate");
	
	MAX_PLAYER_LEVEL = MAX_PLAYER_LEVEL_TABLE[GetExpansionLevel()];

	self.state = "player";
	MainMenuBarArtFrame.PageNumber:SetText(GetActionBarPage());
	MicroButtonAndBagsBar:SetFrameLevel(self:GetFrameLevel()+2);
end

function MainMenuBarMixin:OnShow()
	UpdateMicroButtonsParent(MainMenuBarArtFrame);
	MoveMicroButtons("BOTTOMLEFT", MicroButtonAndBagsBar, "BOTTOMLEFT", 6, 3, false);
end

function MainMenuBarMixin:SetYOffset(yOffset)
	self.yOffset = yOffset;
end

function MainMenuBarMixin:GetYOffset()
	return self.yOffset;
end

function MainMenuBarMixin:SetPositionForStatusBars()
	MainMenuBar:ClearAllPoints(); 
	MainMenuBarArtFrame.LeftEndCap:ClearAllPoints(); 
	MainMenuBarArtFrame.RightEndCap:ClearAllPoints(); 
	if ( StatusTrackingBarManager:GetNumberVisibleBars() == 2 ) then 
		self:SetYOffset(17);
		MainMenuBarArtFrame.LeftEndCap:SetPoint("BOTTOMLEFT", MainMenuBar, -98, -17); 
		MainMenuBarArtFrame.RightEndCap:SetPoint("BOTTOMRIGHT", MainMenuBar, 98, -17); 
	elseif ( StatusTrackingBarManager:GetNumberVisibleBars() == 1 ) then
		self:SetYOffset(14);
		MainMenuBarArtFrame.LeftEndCap:SetPoint("BOTTOMLEFT", MainMenuBar, -98, -14); 
		MainMenuBarArtFrame.RightEndCap:SetPoint("BOTTOMRIGHT", MainMenuBar, 98, -14); 
	else 
		self:SetYOffset(0);
		MainMenuBarArtFrame.LeftEndCap:SetPoint("BOTTOMLEFT", MainMenuBar, -98, 0); 
		MainMenuBarArtFrame.RightEndCap:SetPoint("BOTTOMRIGHT", MainMenuBar, 98, 0); 
	end
	if ( IsPlayerInWorld() ) then
		UIParent_ManageFramePositions();
	end
end
I would like to add my code after function MainMenuBarMixin:SetPositionForStatusBars(), so i thought I could just use something like this:
Code:
local function Test()
	print("test")
end
hooksecurefunc(MainMenuBarMixin, "SetPositionForStatusBars", Test);
I tried lots of methods and google alot, the last this I made, came here. Will apreciate any help.
  Reply With Quote