Customize font of floating text

This commit is contained in:
konaka
2025-11-08 12:38:19 +08:00
parent bdcd3c0b41
commit 41f2a2d81b
2 changed files with 95 additions and 11 deletions
+29 -1
View File
@@ -242,6 +242,22 @@ local function UnitXP_SP3_combatTextSP3_fontSize(size)
return UnitXP_SP3_Addon["combatTextSP3_fontSize"];
end
local function UnitXP_SP3_combatTextSP3_fontName(name)
local test, result, reloadResult = pcall(UnitXP, "combatTextSP3", "setFontName", name);
if not test then
if not skipUpdateMessage then
skipUpdateMessage = true;
UnitXP_SP3_Print(
"UnitXP_SP3.dll failed to execute \"combatTextSP3 setFontName\". You might need to update UnitXP_SP3.dll to support this method.");
end
return UnitXP_SP3_Addon["combatTextSP3_fontName"];
end
UnitXP_SP3_Addon["combatTextSP3_fontName"] = result;
return UnitXP_SP3_Addon["combatTextSP3_fontName"];
end
local function UnitXP_SP3_combatTextSP3_nameplateHeight(size)
local test, result = pcall(UnitXP, "combatTextSP3", "setNameplateHeight", size);
@@ -448,6 +464,9 @@ local function UnitXP_SP3_reloadConfig()
UnitXP_SP3_combatTextSP3_nameplateHeight(UnitXP_SP3_Addon["combatTextSP3_nameplateHeight"]);
xpsp3_editBox_combatTextSP3_nameplateHeight:SetNumber(UnitXP_SP3_Addon["combatTextSP3_nameplateHeight"]);
UnitXP_SP3_combatTextSP3_fontName(UnitXP_SP3_Addon["combatTextSP3_fontName"]);
xpsp3_editBox_combatTextSP3_fontName:SetText(UnitXP_SP3_Addon["combatTextSP3_fontName"]);
UnitXP_SP3_setTargetingRangeConeFactor(UnitXP_SP3_Addon["targetingRangeConeFactor"]);
UnitXP_SP3_setCameraHeight(UnitXP_SP3_Addon["cameraHeight"]);
@@ -473,15 +492,19 @@ local function UnitXP_SP3_reloadConfig()
xpsp3_checkButton_combatTextSP3:SetChecked(true);
xpsp3_editBox_combatTextSP3_fontSize:Show();
xpsp3_editBox_combatTextSP3_nameplateHeight:Show();
xpsp3_editBox_combatTextSP3_fontName:Show();
xpsp3_fontString_combatTextSP3_fontSize:Show();
xpsp3_fontString_combatTextSP3_nameplateHeight:Show();
xpsp3_fontString_combatTextSP3_fontName:Show();
else
UnitXP_SP3_combatTextSP3("disable");
xpsp3_checkButton_combatTextSP3:SetChecked(false);
xpsp3_editBox_combatTextSP3_fontSize:Hide();
xpsp3_editBox_combatTextSP3_nameplateHeight:Hide();
xpsp3_editBox_combatTextSP3_fontName:Hide();
xpsp3_fontString_combatTextSP3_fontSize:Hide();
xpsp3_fontString_combatTextSP3_nameplateHeight:Hide();
xpsp3_fontString_combatTextSP3_fontName:Hide();
end
if UnitXP_SP3_Addon["hideEXPtext"] then
@@ -583,6 +606,7 @@ function UnitXP_SP3_UI_OnClick(widget)
xpsp3_editBox_backgroundFPScap:ClearFocus();
xpsp3_editBox_combatTextSP3_fontSize:ClearFocus();
xpsp3_editBox_combatTextSP3_nameplateHeight:ClearFocus();
xpsp3_editBox_combatTextSP3_fontName:ClearFocus();
skipUpdateMessage = false;
@@ -600,6 +624,9 @@ function UnitXP_SP3_UI_OnClick(widget)
if string.find(widget:GetName(), "_combatTextSP3_nameplateHeight") then
UnitXP_SP3_combatTextSP3_nameplateHeight(widget:GetNumber());
end
if string.find(widget:GetName(), "_combatTextSP3_fontName") then
UnitXP_SP3_combatTextSP3_fontName(widget:GetText());
end
end
if string.find(widget:GetName(), "_button_") then
@@ -800,7 +827,7 @@ end
function UnitXP_SP3_OnEvent(event)
if event == "ADDON_LOADED" and arg1 == "UnitXP_SP3_Addon" then
local dataVersion = 31;
local dataVersion = 32;
if UnitXP_SP3_Addon == nil or UnitXP_SP3_Addon["dataVersion"] ~= dataVersion then
UnitXP_SP3_Addon = {};
UnitXP_SP3_Addon["dataVersion"] = dataVersion;
@@ -821,6 +848,7 @@ function UnitXP_SP3_OnEvent(event)
UnitXP_SP3_Addon["combatTextSP3"] = false;
UnitXP_SP3_Addon["combatTextSP3_fontSize"] = 40;
UnitXP_SP3_Addon["combatTextSP3_nameplateHeight"] = 55;
UnitXP_SP3_Addon["combatTextSP3_fontName"] = "Cambria";
UnitXP_SP3_Addon["hideEXPtext"] = false;
UnitXP_SP3_Addon["notify_flashTaskbarIcon"] = {};
+66 -10
View File
@@ -10,7 +10,7 @@ xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interfac
<Frame name="xpsp3Frame" toplevel="true" frameStrata="DIALOG" movable="true" enableMouse="true" hidden="true" parent="UIParent">
<TitleRegion setAllPoints="true"/>
<Size>
<AbsDimension x="550" y="385"/>
<AbsDimension x="550" y="430"/>
</Size>
<Anchors>
<Anchor point="CENTER" relativeTo="UIParent" />
@@ -77,7 +77,7 @@ xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interfac
<Anchors>
<Anchor point="TOPLEFT" relativeTo="xpsp3Frame">
<Offset>
<AbsDimension x="295" y="-260"/>
<AbsDimension x="295" y="-300"/>
</Offset>
</Anchor>
</Anchors>
@@ -87,17 +87,27 @@ xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interfac
<Anchors>
<Anchor point="TOPLEFT" relativeTo="xpsp3Frame">
<Offset>
<AbsDimension x="413" y="-260"/>
<AbsDimension x="413" y="-300"/>
</Offset>
</Anchor>
</Anchors>
</FontString>
<FontString name="xpsp3_fontString_combatTextSP3_fontName" inherits="GameFontNormal" text="Font:" justifyH="LEFT" justifyV="TOP">
<Size x="200" y="440" />
<Anchors>
<Anchor point="TOPLEFT" relativeTo="xpsp3Frame">
<Offset>
<AbsDimension x="295" y="-335"/>
</Offset>
</Anchor>
</Anchors>
</FontString>
<FontString inherits="GameFontNormal" text="Targeting functions could be accessed via Key Bindings Menu" justifyH="CENTER" justifyV="TOP">
<Size x="500" y="440" />
<Size x="550" y="430" />
<Anchors>
<Anchor point="TOPLEFT" relativeTo="xpsp3Frame">
<Offset>
<AbsDimension x="0" y="-325"/>
<AbsDimension x="0" y="-370"/>
</Offset>
</Anchor>
</Anchors>
@@ -440,7 +450,7 @@ xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interfac
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="274" y="-220"/>
<AbsDimension x="274" y="-260"/>
</Offset>
</Anchor>
</Anchors>
@@ -467,7 +477,7 @@ xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interfac
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="274" y="-290"/>
<AbsDimension x="274" y="-220"/>
</Offset>
</Anchor>
</Anchors>
@@ -495,7 +505,7 @@ xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interfac
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="343" y="-250"/>
<AbsDimension x="343" y="-290"/>
</Offset>
</Anchor>
</Anchors>
@@ -542,7 +552,7 @@ xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interfac
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="490" y="-250"/>
<AbsDimension x="490" y="-290"/>
</Offset>
</Anchor>
</Anchors>
@@ -584,7 +594,53 @@ xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interfac
</Scripts>
<FontString inherits="ChatFontNormal" />
</EditBox>
<EditBox name="xpsp3_editBox_combatTextSP3_fontName" autoFocus="false" numeric="false">
<Size x="150" y="32" />
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="336" y="-325"/>
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Left">
<Size x="100" y="32" />
<Anchors>
<Anchor point="LEFT">
<Offset x="-10" y="0" />
</Anchor>
</Anchors>
<TexCoords left="0" right="0.4" top="0" bottom="1.0"/>
</Texture>
<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Right">
<Size x="100" y="32" />
<Anchors>
<Anchor point="RIGHT">
<Offset x="10" y="0" />
</Anchor>
</Anchors>
<TexCoords left="0.6" right="1.0" top="0" bottom="1.0"/>
</Texture>
</Layer>
</Layers>
<Scripts>
<OnEditFocusGained>
xpsp3tooltip:SetOwner(this, "ANCHOR_LEFT");
xpsp3tooltip:SetText("Change the font of combat text");
xpsp3tooltip:AddLine("Input a font name in operating system. Press Enter to confirm",1,1,1);
xpsp3tooltip:Show();
</OnEditFocusGained>
<OnEditFocusLost>
xpsp3tooltip:Hide();
</OnEditFocusLost>
<OnEnterPressed>
UnitXP_SP3_UI_OnClick(this);
</OnEnterPressed>
</Scripts>
<FontString inherits="ChatFontNormal" />
</EditBox>
<EditBox name="xpsp3_editBox_FPScap" letters="3" autoFocus="false" numeric="true">
<Size x="50" y="32" />