mirror of
https://github.com/waynebian01/Shigure.git
synced 2026-09-03 07:15:24 +08:00
为宠物添加支持,包括状态、生命值和更新逻辑
This commit is contained in:
@@ -168,6 +168,7 @@ Fuyutsui.blocks = {}
|
||||
Fuyutsui.target = {}
|
||||
Fuyutsui.focus = {}
|
||||
Fuyutsui.mouseover = {}
|
||||
Fuyutsui.pet = {}
|
||||
Fuyutsui.boss = {}
|
||||
for index = 1, 5 do
|
||||
Fuyutsui.boss["boss" .. index] = {}
|
||||
|
||||
@@ -249,6 +249,9 @@ function Fuyutsui:UNIT_HEALTH(_, unit)
|
||||
if unit == "mouseover" then
|
||||
self:UpdateMouseoverHealth()
|
||||
end
|
||||
if unit == "pet" then
|
||||
self:UpdateUnitHealthBlock(unit)
|
||||
end
|
||||
if unit and unit:match("^boss[1-5]$") then
|
||||
self:UpdateUnitHealthBlock(unit)
|
||||
end
|
||||
@@ -264,6 +267,9 @@ function Fuyutsui:UNIT_MAXHEALTH(_, unit)
|
||||
if unit == "mouseover" then
|
||||
self:UpdateMouseoverHealth()
|
||||
end
|
||||
if unit == "pet" then
|
||||
self:UpdateUnitHealthBlock(unit)
|
||||
end
|
||||
if unit and unit:match("^boss[1-5]$") then
|
||||
self:UpdateUnitHealthBlock(unit)
|
||||
end
|
||||
|
||||
@@ -259,8 +259,8 @@ function Fuyutsui:UpdatePlayerBarInfo()
|
||||
end
|
||||
|
||||
function Fuyutsui:UpdatePlayerPet()
|
||||
state.hasPet = UnitExists("pet") and 1 / 255 or 0
|
||||
self:UpdateStateBlock("状态", "宠物")
|
||||
self:UpdateUnitType("pet")
|
||||
self:UpdateUnitHealthBlock("pet")
|
||||
end
|
||||
|
||||
function Fuyutsui:UpdatePlayerMounted()
|
||||
|
||||
@@ -6,6 +6,7 @@ local state = Fuyutsui.state
|
||||
local target = Fuyutsui.target
|
||||
local focus = Fuyutsui.focus
|
||||
local mouseover = Fuyutsui.mouseover
|
||||
local pet = Fuyutsui.pet
|
||||
local boss = Fuyutsui.boss
|
||||
|
||||
local ColorValue0 = CreateColor(0, 0, 0, 1)
|
||||
@@ -116,7 +117,6 @@ local stateBlockGetters = {
|
||||
["有效性"] = function() return state.valid or 0 end,
|
||||
["战斗时间"] = function() return state.combatTime or 0 end,
|
||||
["移动"] = function() return state.moving or 0 end,
|
||||
["宠物"] = function() return state.hasPet or 0 end,
|
||||
["生命值"] = function() return state.healthPercent or 0 end,
|
||||
["一键辅助"] = function() return state.assistantSpell or 0 end,
|
||||
["插入法术"] = function() return state.insertSpell or 0 end,
|
||||
@@ -268,6 +268,10 @@ local stateBlockGetters = {
|
||||
["引导"] = function(self) return self:GetUnitCastPixel("mouseover", "channel") end,
|
||||
["引导可打断"] = function(self) return self:GetUnitInterruptiblePixel("mouseover", "channel") end,
|
||||
},
|
||||
["宠物"] = {
|
||||
["存在"] = function() return pet.exists or 0 end,
|
||||
["生命值"] = function() return pet.healthPercent or 0 end,
|
||||
},
|
||||
}
|
||||
|
||||
for index = 1, 5 do
|
||||
|
||||
@@ -6,6 +6,7 @@ local state = Fuyutsui.state
|
||||
local target = Fuyutsui.target
|
||||
local focus = Fuyutsui.focus
|
||||
local mouseover = Fuyutsui.mouseover
|
||||
local pet = Fuyutsui.pet
|
||||
local boss = Fuyutsui.boss
|
||||
local nameplate = Fuyutsui.nameplate
|
||||
|
||||
@@ -18,6 +19,7 @@ local unitZHMap = {
|
||||
["target"] = "目标",
|
||||
["focus"] = "焦点",
|
||||
["mouseover"] = "鼠标",
|
||||
["pet"] = "宠物",
|
||||
["boss1"] = "首领1",
|
||||
["boss2"] = "首领2",
|
||||
["boss3"] = "首领3",
|
||||
@@ -29,6 +31,7 @@ local function GetUnitCache(unit)
|
||||
if unit == "target" then return target end
|
||||
if unit == "focus" then return focus end
|
||||
if unit == "mouseover" then return mouseover end
|
||||
if unit == "pet" then return pet end
|
||||
if boss and boss[unit] then return boss[unit] end
|
||||
end
|
||||
|
||||
@@ -87,6 +90,12 @@ function Fuyutsui:UpdateUnitType(unit)
|
||||
local category = unitZHMap[unit]
|
||||
if not cache or not category then return end
|
||||
|
||||
if unit == "pet" then
|
||||
cache.exists = UnitExists(unit) and 1 / 255 or 0
|
||||
self:UpdateStateBlock(category, "存在")
|
||||
return
|
||||
end
|
||||
|
||||
if boss and boss[unit] then
|
||||
cache.type = (cache.canAttack and 1 or 2) / 255
|
||||
self:UpdateStateBlock(category, "类型")
|
||||
@@ -156,6 +165,11 @@ function Fuyutsui:UpdateUnitHealthBlock(unit)
|
||||
local cache = GetUnitCache(unit)
|
||||
local category = unitZHMap[unit]
|
||||
if not cache or not category then return end
|
||||
if not UnitExists(unit) then
|
||||
cache.healthPercent = 0
|
||||
self:UpdateStateBlock(category, "生命值")
|
||||
return
|
||||
end
|
||||
local healthPercent = UnitHealthPercent(unit, false, self.curve100)
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
local _, _, b = healthPercent:GetRGB()
|
||||
|
||||
@@ -56,11 +56,11 @@ function Fuyutsui:LoadPlayerBlocks(specIndex)
|
||||
|
||||
local index = 1
|
||||
|
||||
-- states 支持分类表:状态/能量/物品/配置开关/目标/焦点/鼠标/首领1-5
|
||||
-- states 支持分类表:状态/能量/物品/配置开关/目标/焦点/鼠标/宠物/首领1-5
|
||||
-- blocks.state 键:基础分类用名称本身;单位分类用 分类..名称(如 目标生命值)
|
||||
if type(t.states) == "table" then
|
||||
local stateCategoryOrder = {
|
||||
"状态", "能量", "物品", "配置开关", "目标", "焦点", "鼠标",
|
||||
"状态", "能量", "物品", "配置开关", "目标", "焦点", "鼠标", "宠物",
|
||||
"首领1", "首领2", "首领3", "首领4", "首领5",
|
||||
}
|
||||
local bareKeyCategories = {
|
||||
@@ -71,6 +71,7 @@ function Fuyutsui:LoadPlayerBlocks(specIndex)
|
||||
}
|
||||
local nested = t.states["状态"] or t.states["能量"] or t.states["物品"]
|
||||
or t.states["配置开关"] or t.states["目标"] or t.states["焦点"] or t.states["鼠标"]
|
||||
or t.states["宠物"]
|
||||
or t.states["首领1"] or t.states["首领2"] or t.states["首领3"]
|
||||
or t.states["首领4"] or t.states["首领5"]
|
||||
if nested then
|
||||
|
||||
@@ -22,6 +22,7 @@ internal static class ClassBlocksStore
|
||||
ClassStateCatalog.CategoryTarget,
|
||||
ClassStateCatalog.CategoryFocus,
|
||||
ClassStateCatalog.CategoryMouseover,
|
||||
ClassStateCatalog.CategoryPet,
|
||||
ClassStateCatalog.CategoryBoss1,
|
||||
ClassStateCatalog.CategoryBoss2,
|
||||
ClassStateCatalog.CategoryBoss3,
|
||||
@@ -63,6 +64,7 @@ internal static class ClassBlocksStore
|
||||
[ClassStateCatalog.CategoryTarget] = new List<string>(),
|
||||
[ClassStateCatalog.CategoryFocus] = new List<string>(),
|
||||
[ClassStateCatalog.CategoryMouseover] = new List<string>(),
|
||||
[ClassStateCatalog.CategoryPet] = new List<string>(),
|
||||
[ClassStateCatalog.CategoryBoss1] = new List<string>(),
|
||||
[ClassStateCatalog.CategoryBoss2] = new List<string>(),
|
||||
[ClassStateCatalog.CategoryBoss3] = new List<string>(),
|
||||
|
||||
@@ -14,6 +14,7 @@ internal static class ClassStateCatalog
|
||||
public const string CategoryTarget = "目标";
|
||||
public const string CategoryFocus = "焦点";
|
||||
public const string CategoryMouseover = "鼠标";
|
||||
public const string CategoryPet = "宠物";
|
||||
public const string CategoryBoss1 = "首领1";
|
||||
public const string CategoryBoss2 = "首领2";
|
||||
public const string CategoryBoss3 = "首领3";
|
||||
@@ -29,6 +30,7 @@ internal static class ClassStateCatalog
|
||||
CategoryTarget,
|
||||
CategoryFocus,
|
||||
CategoryMouseover,
|
||||
CategoryPet,
|
||||
CategoryBoss1,
|
||||
CategoryBoss2,
|
||||
CategoryBoss3,
|
||||
@@ -40,7 +42,7 @@ internal static class ClassStateCatalog
|
||||
[
|
||||
(CategoryState,
|
||||
[
|
||||
"职业", "专精", "有效性", "战斗时间", "移动", "宠物",
|
||||
"职业", "专精", "有效性", "战斗时间", "移动",
|
||||
"生命值", "一键辅助", "插入法术", "队伍类型", "队伍人数",
|
||||
"首领战", "难度", "英雄天赋", "施法目标", "施法技能",
|
||||
"敌人数量", "敌人数-无仇恨", "敌人数-有仇恨",
|
||||
@@ -73,6 +75,10 @@ internal static class ClassStateCatalog
|
||||
[
|
||||
"类型", "驱散类型", "生命值", "距离", "施法(倒计时)", "施法(正计时)", "施法可打断", "引导", "引导可打断"
|
||||
]),
|
||||
(CategoryPet,
|
||||
[
|
||||
"存在", "生命值"
|
||||
]),
|
||||
(CategoryBoss1,
|
||||
[
|
||||
"类型", "驱散类型", "生命值", "距离", "施法(倒计时)", "施法(正计时)", "施法可打断", "引导", "引导可打断"
|
||||
|
||||
@@ -35,6 +35,7 @@ internal static class FuyutsuiConfigConverter
|
||||
ClassStateCatalog.CategoryTarget,
|
||||
ClassStateCatalog.CategoryFocus,
|
||||
ClassStateCatalog.CategoryMouseover,
|
||||
ClassStateCatalog.CategoryPet,
|
||||
ClassStateCatalog.CategoryBoss1,
|
||||
ClassStateCatalog.CategoryBoss2,
|
||||
ClassStateCatalog.CategoryBoss3,
|
||||
@@ -545,6 +546,7 @@ internal static class FuyutsuiConfigConverter
|
||||
=> category is ClassStateCatalog.CategoryTarget
|
||||
or ClassStateCatalog.CategoryFocus
|
||||
or ClassStateCatalog.CategoryMouseover
|
||||
or ClassStateCatalog.CategoryPet
|
||||
or ClassStateCatalog.CategoryBoss1
|
||||
or ClassStateCatalog.CategoryBoss2
|
||||
or ClassStateCatalog.CategoryBoss3
|
||||
|
||||
@@ -12,6 +12,7 @@ internal sealed class ModuleDependencyService
|
||||
ClassStateCatalog.CategoryTarget,
|
||||
ClassStateCatalog.CategoryFocus,
|
||||
ClassStateCatalog.CategoryMouseover,
|
||||
ClassStateCatalog.CategoryPet,
|
||||
ClassStateCatalog.CategoryBoss1,
|
||||
ClassStateCatalog.CategoryBoss2,
|
||||
ClassStateCatalog.CategoryBoss3,
|
||||
|
||||
@@ -319,6 +319,7 @@ public sealed class ConditionFieldCatalog
|
||||
=> classification is ClassStateCatalog.CategoryTarget
|
||||
or ClassStateCatalog.CategoryFocus
|
||||
or ClassStateCatalog.CategoryMouseover
|
||||
or ClassStateCatalog.CategoryPet
|
||||
or ClassStateCatalog.CategoryBoss1
|
||||
or ClassStateCatalog.CategoryBoss2
|
||||
or ClassStateCatalog.CategoryBoss3
|
||||
|
||||
@@ -687,7 +687,7 @@ public sealed class StatusForm : Form
|
||||
Margin = new Padding(0)
|
||||
};
|
||||
var copyButton = UiTheme.CreateButton("复制全部", UiTheme.ButtonKind.Secondary);
|
||||
UiTheme.StyleActionButton(copyButton, 96);
|
||||
UiTheme.StyleActionButton(copyButton, 112);
|
||||
copyButton.Margin = new Padding(0, 0, 8, 6);
|
||||
copyButton.Click += (_, _) =>
|
||||
{
|
||||
@@ -697,7 +697,7 @@ public sealed class StatusForm : Form
|
||||
}
|
||||
};
|
||||
var clearButton = UiTheme.CreateButton("清空显示", UiTheme.ButtonKind.Danger);
|
||||
UiTheme.StyleActionButton(clearButton, 96);
|
||||
UiTheme.StyleActionButton(clearButton, 112);
|
||||
clearButton.Margin = new Padding(0, 0, 16, 6);
|
||||
clearButton.Click += (_, _) => _logTextBox.Clear();
|
||||
var autoScroll = new CheckBox
|
||||
@@ -1225,6 +1225,10 @@ public sealed class StatusForm : Form
|
||||
"鼠标",
|
||||
["类型", "生命值", "距离", "施法(倒计时)", "施法(正计时)", "施法可打断", "引导", "引导可打断"],
|
||||
104), 0, 3);
|
||||
fields.Controls.Add(CreateCommonFieldCard(
|
||||
"宠物",
|
||||
["存在", "生命值"],
|
||||
104), 1, 3);
|
||||
|
||||
scrollHost.Controls.Add(fields);
|
||||
return scrollHost;
|
||||
|
||||
Reference in New Issue
Block a user