mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-10-10 10:30:01 +00:00
v1.4.0 Twow 1.18.1
This commit is contained in:
@@ -6,18 +6,6 @@
|
||||
-- Uses MTH_DS_BeastSkins[familyName] generated by .tools/generators/gen_beast_skins.py
|
||||
-- Skin rendering: PlayerModel:SetUnit(CreatureDisplayInfo.ID)
|
||||
|
||||
local function mv_log(msg)
|
||||
if MTH_DebugFrame and type(MTH_DebugFrame.AddInfo) == "function" then
|
||||
MTH_DebugFrame:AddInfo("[MV] " .. tostring(msg))
|
||||
end
|
||||
end
|
||||
|
||||
local function mv_err(msg)
|
||||
if MTH_DebugFrame and type(MTH_DebugFrame.AddError) == "function" then
|
||||
MTH_DebugFrame:AddError("[MV] " .. tostring(msg))
|
||||
end
|
||||
end
|
||||
|
||||
local MTH_MV = {
|
||||
inited = false,
|
||||
family = nil,
|
||||
@@ -45,10 +33,8 @@ local MTH_MV = {
|
||||
|
||||
local function MTH_MV_ApplyModel(model, skinId)
|
||||
if not model or not skinId then
|
||||
mv_err("ApplyModel: nil model or skinId model="..tostring(model).." id="..tostring(skinId))
|
||||
return
|
||||
end
|
||||
mv_log("ApplyModel id="..tostring(skinId))
|
||||
model:SetUnit(skinId)
|
||||
model:SetPosition(0, 0, 0)
|
||||
model:SetModelScale(1)
|
||||
@@ -106,14 +92,11 @@ MTH_MV_BuildSkinBeastList = function(skinId)
|
||||
end
|
||||
|
||||
local function MTH_MV_Init()
|
||||
if MTH_MV.inited then mv_log("Init: already done") return end
|
||||
mv_log("Init: starting")
|
||||
if MTH_MV.inited then return end
|
||||
local backdrop = getglobal("MTH_BOOK_DetailBackdrop")
|
||||
if not backdrop then
|
||||
mv_err("Init: MTH_BOOK_DetailBackdrop not found")
|
||||
return
|
||||
end
|
||||
mv_log("Init: backdrop found, creating previewFrame")
|
||||
MTH_MV.inited = true
|
||||
|
||||
-- ----------------------------------------------------------------
|
||||
@@ -136,7 +119,6 @@ local function MTH_MV_Init()
|
||||
MTH_MV.previewFrame:SetBackdropBorderColor(0.35, 0.35, 0.35, 0.8)
|
||||
MTH_MV.previewFrame:Hide()
|
||||
|
||||
mv_log("Init: previewFrame created, creating PlayerModel")
|
||||
-- PlayerModel fills the inner area
|
||||
MTH_MV.previewModel = CreateFrame("PlayerModel", nil, MTH_MV.previewFrame)
|
||||
MTH_MV.previewModel:SetPoint("TOPLEFT", MTH_MV.previewFrame, "TOPLEFT", 3, -3)
|
||||
@@ -158,7 +140,6 @@ local function MTH_MV_Init()
|
||||
GameTooltip:Hide()
|
||||
end)
|
||||
|
||||
mv_log("Init: previewModel created, creating popup")
|
||||
-- ----------------------------------------------------------------
|
||||
-- Popup frame (wider: left side = model viewer, right = beast list)
|
||||
-- ----------------------------------------------------------------
|
||||
@@ -343,7 +324,6 @@ local function MTH_MV_Init()
|
||||
end
|
||||
|
||||
MTH_MV.popup = popup
|
||||
mv_log("Init: complete")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
@@ -351,12 +331,10 @@ end
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
function MTH_BOOK_ModelViewer_SetFamily(family, skinId)
|
||||
mv_log("SetFamily: "..tostring(family).." skinId="..tostring(skinId))
|
||||
MTH_MV_Init()
|
||||
if not MTH_MV.inited then mv_err("SetFamily: init failed") return end
|
||||
if not MTH_MV.inited then return end
|
||||
local skins = MTH_DS_BeastSkins and type(MTH_DS_BeastSkins) == "table" and MTH_DS_BeastSkins[family]
|
||||
if not skins or table.getn(skins) == 0 then
|
||||
mv_log("SetFamily: no skins for "..tostring(family).." DS type="..type(MTH_DS_BeastSkins or false))
|
||||
MTH_BOOK_ModelViewer_Clear()
|
||||
return
|
||||
end
|
||||
@@ -380,7 +358,6 @@ function MTH_BOOK_ModelViewer_SetFamily(family, skinId)
|
||||
MTH_BOOK_ModelViewer_Clear()
|
||||
return
|
||||
end
|
||||
mv_log("SetFamily: "..table.getn(filteredSkins).." tameable skins (filtered from "..table.getn(skins)..")")
|
||||
|
||||
MTH_MV.family = family
|
||||
MTH_MV.skins = filteredSkins
|
||||
@@ -392,7 +369,6 @@ function MTH_BOOK_ModelViewer_SetFamily(family, skinId)
|
||||
for i = 1, table.getn(filteredSkins) do
|
||||
if filteredSkins[i].id == skinId then
|
||||
MTH_MV.index = i
|
||||
mv_log("SetFamily: skinId "..skinId.." matched skin index "..i)
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -409,7 +385,6 @@ function MTH_BOOK_ModelViewer_SetFamily(family, skinId)
|
||||
end
|
||||
|
||||
function MTH_BOOK_ModelViewer_Clear()
|
||||
mv_log("Clear")
|
||||
if MTH_MV.previewFrame then MTH_MV.previewFrame:Hide() end
|
||||
if not MTH_MV.keepPopup then
|
||||
if MTH_MV.popup and MTH_MV.popup:IsShown() then MTH_MV.popup:Hide() end
|
||||
@@ -420,10 +395,9 @@ function MTH_BOOK_ModelViewer_Clear()
|
||||
end
|
||||
|
||||
function MTH_BOOK_ModelViewer_OpenPopup()
|
||||
mv_log("OpenPopup skins="..table.getn(MTH_MV.skins))
|
||||
MTH_MV_Init()
|
||||
if not MTH_MV.popup then mv_err("OpenPopup: no popup frame") return end
|
||||
if table.getn(MTH_MV.skins) == 0 then mv_log("OpenPopup: no skins") return end
|
||||
if not MTH_MV.popup then return end
|
||||
if table.getn(MTH_MV.skins) == 0 then return end
|
||||
MTH_MV.popup:Show()
|
||||
MTH_MV.popup:Raise()
|
||||
MTH_MV_DisplayCurrent()
|
||||
|
||||
Reference in New Issue
Block a user