Skip to content

Commit

Permalink
Fix evil native form button
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghostopheles committed Jan 4, 2024
1 parent 7953784 commit 3d46f48
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
41 changes: 27 additions & 14 deletions Datamine/Modules/Unified/Templates/ModelScene/ModelScene.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion Datamine/Modules/Unified/Templates/ModelScene/ModelScene.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@
<Anchor point="TOP" y="-10" />
</Anchors>
</Frame>
<Button parentKey="NativeFormToggleButton" inherits="DatamineGenericButtonTemplate">
<Button parentKey="NativeFormToggleButton" inherits="DatamineGenericButtonTemplate"
hidden="true" motionScriptsWhileDisabled="false">
<Size x="50" y="50" />
<Anchors>
<Anchor point="TOPRIGHT" x="-15" y="-15" />
Expand Down

0 comments on commit 3d46f48

Please sign in to comment.