From 3d46f48614a2aa3efd182d23157f2c6634646c24 Mon Sep 17 00:00:00 2001 From: Ghostopheles Date: Thu, 4 Jan 2024 05:28:15 -0600 Subject: [PATCH] Fix evil native form button --- .../Templates/ModelScene/ModelScene.lua | 41 ++++++++++++------- .../Templates/ModelScene/ModelScene.xml | 3 +- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/Datamine/Modules/Unified/Templates/ModelScene/ModelScene.lua b/Datamine/Modules/Unified/Templates/ModelScene/ModelScene.lua index ea18426..e8a525b 100644 --- a/Datamine/Modules/Unified/Templates/ModelScene/ModelScene.lua +++ b/Datamine/Modules/Unified/Templates/ModelScene/ModelScene.lua @@ -173,24 +173,11 @@ function DatamineModelSceneMixin:OnLoad_Custom() self:ReleaseAllActors(); EventUtil.RegisterOnceFrameEventAndCallback("PLAYER_ENTERING_WORLD", function() self:SetFromModelSceneID(596) end); - self.NativeFormToggleButton:SetScript("OnClick", function() - local useNativeForm = self:GetUseNativeForm(); - self:SetUseNativeForm(not useNativeForm); - end); - self.actorTemplate = "DatamineModelSceneActorTemplate"; Registry:RegisterCallback(Events.MODEL_LOADED_INTERNAL, self.OnModelLoaded_Internal, self); - self.NativeFormToggleButton:SetScript("OnEnter", function() - GameTooltip:SetOwner(self.NativeFormToggleButton, "ANCHOR_TOP"); - GameTooltip:SetText("Toggle Alternate Form", 1, 1, 1); - GameTooltip:Show(); - end); - - self.NativeFormToggleButton:SetScript("OnLeave", function() - GameTooltip:Hide(); - end); + self:UpdateNativeFormButton(); end function DatamineModelSceneMixin:OnFirstShow() @@ -263,6 +250,32 @@ function DatamineModelSceneMixin:OnModelLoaded_Internal(actor) Registry:TriggerEvent(Events.MODEL_OUTFIT_UPDATED); end +function DatamineModelSceneMixin:UpdateNativeFormButton() + local _, raceFileName = UnitRace("player"); + if raceFileName == "Dracthyr" or raceFileName == "Worgen" then + self.NativeFormToggleButton:SetScript("OnClick", function() + local useNativeForm = self:GetUseNativeForm(); + self:SetUseNativeForm(not useNativeForm); + end); + + self.NativeFormToggleButton:SetScript("OnEnter", function() + GameTooltip:SetOwner(self.NativeFormToggleButton, "ANCHOR_TOP"); + GameTooltip:SetText("Toggle Alternate Form", 1, 1, 1); + GameTooltip:Show(); + end); + + self.NativeFormToggleButton:SetScript("OnLeave", function() + GameTooltip:Hide(); + end); + + self.NativeFormToggleButton:Show(); + self.NativeFormToggleButton:Enable(); + else + self.NativeFormToggleButton:Hide(); + self.NativeFormToggleButton:Disable(); + end +end + function DatamineModelSceneMixin:StartPanning() self.IsPanning = true; local actor = self:GetActiveActor(); diff --git a/Datamine/Modules/Unified/Templates/ModelScene/ModelScene.xml b/Datamine/Modules/Unified/Templates/ModelScene/ModelScene.xml index facdffc..fefea33 100644 --- a/Datamine/Modules/Unified/Templates/ModelScene/ModelScene.xml +++ b/Datamine/Modules/Unified/Templates/ModelScene/ModelScene.xml @@ -187,7 +187,8 @@ -