|
02-22-14, 07:57 PM | #1 |
Help with some Font settings
EDIT:
Disreguard this post.. Was able to work most of the issues out with the "search" function. for those that might want to see the code im currently using. This code was posted by Phanx and editied to my likeing. Code:
local shorts = { { 1e10, 1e9, "%.0fb" }, -- 10b+ as 12b { 1e9, 1e9, "%.1fb" }, -- 1b+ as 8.3b { 1e7, 1e6, "%.0fm" }, -- 10m+ as 14m { 1e6, 1e6, "%.1fm" }, -- 1m+ as 7.4m { 1e5, 1e3, "%.0fk" }, -- 100k+ as 840k { 1e3, 1e3, "%.1fk" }, -- 1k+ as 2.5k { 0, 1, "%d" }, -- < 1k as 974 } for i = 1, #shorts do shorts[i][4] = shorts[i][3] .. " (%.0f%%)" end hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusBar, fontString, value, valueMin, valueMax) local style = GetCVar("statusTextDisplay") if style == "PERCENT" then return fontString:SetFormattedText("%.0f%%", value / valueMax * 100) end for i = 1, #shorts do local t = shorts[i] if style == "NUMERIC" then if value >= t[1] then return fontString:SetFormattedText(t[3], value / t[2]) end end if style == "BOTH" then if value >= t[1] then return fontString:SetFormattedText(t[4], value / t[2], value / valueMax * 100) end end end end) Coke Last edited by cokedrivers : 02-23-14 at 10:31 AM. |
|
02-22-14, 08:09 PM | #2 |
Öhm.
What is C["unitframes"].fontStyle and where does it come from? |
|
02-23-14, 11:56 AM | #3 |
I've been able to do the following for the player but how would I do this for Arean and boss frames?
Code:
PlayerFrameHealthBarText:SetFont(C["media"].font, C["unitframes"].player.fontSize,"THINOUTLINE"); PlayerFrameManaBarText:SetFont(C["media"].font, C["unitframes"].player.fontSize, "THINOUTLINE"); PlayerFrameAlternateManaBarText:SetFont(C["media"].font, C["unitframes"].player.fontSize, "THINOUTLINE"); |
|
02-23-14, 08:16 PM | #4 | |
I vaguely remember posting that... not sure if it was in my original version, or from your edits, but here's a slightly more efficient version:
Code:
local shorts = { { 1e10, 1e9, "%.0fb" }, -- 10b+ as 12b { 1e9, 1e9, "%.1fb" }, -- 1b+ as 8.3b { 1e7, 1e6, "%.0fm" }, -- 10m+ as 14m { 1e6, 1e6, "%.1fm" }, -- 1m+ as 7.4m { 1e5, 1e3, "%.0fk" }, -- 100k+ as 840k { 1e3, 1e3, "%.1fk" }, -- 1k+ as 2.5k { 0, 1, "%d" }, -- < 1k as 974 } for i = 1, #shorts do shorts[i][4] = shorts[i][3] .. " (%.0f%%)" end hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusBar, fontString, value, valueMin, valueMax) local style = GetCVar("statusTextDisplay") if style == "PERCENT" then return fontString:SetFormattedText("%.0f%%", value / valueMax * 100) end for i = 1, #shorts do local t = shorts[i] if value >= t[1] then if style == "BOTH" then return fontString:SetFormattedText(t[4], value / t[2], value / valueMax * 100) else return fontString:SetFormattedText(t[3], value / t[2]) end end end end)
Code:
local font, _, flags = fontstring:GetFont() fontstring:SetFont(font, 18, flags) -- 18 being your new size Code:
local font, _, flags = TextStatusBarText:GetFont() TextStatusBarText:SetFont(font, 18, flags) -- 18 being your new size
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
||
02-23-14, 10:50 PM | #5 | |
I want to be able to adjust each frames font size individually per what the user wants. I think ill just stick with doing it the long way per frame. Thanks Coke PS this is what im talking about the long way. My current unitframes addon: Code:
local B, C, DB = unpack(select(2, ...)) -- Import: B - function; C - config; DB - Database if C["unitframes"].enable ~= true then return end -- Special Thanks to the guys over at Arena Junkies for most of these scripts -- http://www.arenajunkies.com/topic/222642-default-ui-scripts/ local _G = _G -- Player Frame if C["unitframes"].player.enable then -- Frame Scale _G["PlayerFrame"]:SetScale(C["unitframes"].player.scale); PlayerFrameHealthBarText:SetFont(C["media"].font, C["unitframes"].player.fontSize,"THINOUTLINE"); PlayerFrameManaBarText:SetFont(C["media"].font, C["unitframes"].player.fontSize, "THINOUTLINE"); PlayerFrameAlternateManaBarText:SetFont(C["media"].font, C["unitframes"].player.fontSize, "THINOUTLINE"); PetFrameHealthBarText:SetFont(C["media"].font, C["unitframes"].player.fontSizepet,"THINOUTLINE"); PetFrameManaBarText:SetFont(C["media"].font, C["unitframes"].player.fontSizepet, "THINOUTLINE"); end -- Target Frame if C["unitframes"].target.enable then -- Frame Scale _G["TargetFrame"]:SetScale(C["unitframes"].target.scale); TargetFrameTextureFrameHealthBarText:SetFont(C["media"].font, C["unitframes"].target.fontSize, "THINOUTLINE"); TargetFrameTextureFrameManaBarText:SetFont(C["media"].font, C["unitframes"].target.fontSize, "THINOUTLINE"); end; -- Focus Frame if C["unitframes"].focus.enable then -- Frame Scale _G["FocusFrame"]:SetScale(C["unitframes"].focus.scale) FocusFrameTextureFrameHealthBarText:SetFont(C["media"].font, C["unitframes"].focus.fontSize,"THINOUTLINE") FocusFrameTextureFrameManaBarText:SetFont(C["media"].font, C["unitframes"].focus.fontSize,"THINOUTLINE") end; -- Party Frames -- if C["unitframes"].party.enable then -- Clear all old settings PartyMemberFrame1:ClearAllPoints(); PartyMemberFrame2:ClearAllPoints(); PartyMemberFrame3:ClearAllPoints(); PartyMemberFrame4:ClearAllPoints(); -- Create new locations PartyMemberFrame1:SetPoint(C['unitframes'].party.position.relAnchor, UIParent, C['unitframes'].party.position.offSetX, C['unitframes'].party.position.offSetY); PartyMemberFrame2:SetPoint("TOPLEFT", PartyMemberFrame1, 0, -75); PartyMemberFrame3:SetPoint("TOPLEFT", PartyMemberFrame2, 0, -75); PartyMemberFrame4:SetPoint("TOPLEFT", PartyMemberFrame3, 0, -75); -- Make the new locations stay PartyMemberFrame1.SetPoint = function() end; PartyMemberFrame2.SetPoint = function() end; PartyMemberFrame3.SetPoint = function() end; PartyMemberFrame4.SetPoint = function() end; -- Set the scale of all the frames PartyMemberFrame1:SetScale(C["unitframes"].party.scale); PartyMemberFrame2:SetScale(C["unitframes"].party.scale); PartyMemberFrame3:SetScale(C["unitframes"].party.scale); PartyMemberFrame4:SetScale(C["unitframes"].party.scale); -- Set Font Size PartyMemberFrame1HealthBarText:SetFont(C["media"].font, C["unitframes"].party.fontSize, "THINOUTLINE") PartyMemberFrame1ManaBarText:SetFont(C["media"].font, C["unitframes"].party.fontSize, "THINOUTLINE") PartyMemberFrame2HealthBarText:SetFont(C["media"].font, C["unitframes"].party.fontSize, "THINOUTLINE") PartyMemberFrame2ManaBarText:SetFont(C["media"].font, C["unitframes"].party.fontSize, "THINOUTLINE") PartyMemberFrame3HealthBarText:SetFont(C["media"].font, C["unitframes"].party.fontSize, "THINOUTLINE") PartyMemberFrame3ManaBarText:SetFont(C["media"].font, C["unitframes"].party.fontSize, "THINOUTLINE") PartyMemberFrame4HealthBarText:SetFont(C["media"].font, C["unitframes"].party.fontSize, "THINOUTLINE") PartyMemberFrame4ManaBarText:SetFont(C["media"].font, C["unitframes"].party.fontSize, "THINOUTLINE") end; -- Arena Frames if C["unitframes"].arena.enable then LoadAddOn("Blizzard_ArenaUI"); -- You only need to run this once. You can safely delete any copies of this line. ArenaEnemyFrames:SetScale(C["unitframes"].arena.scale); ArenaEnemyFrame1HealthBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize,"THINOUTLINE"); ArenaEnemyFrame1ManaBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize, "THINOUTLINE"); ArenaEnemyFrame2HealthBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize,"THINOUTLINE"); ArenaEnemyFrame2ManaBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize, "THINOUTLINE"); ArenaEnemyFrame3HealthBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize,"THINOUTLINE"); ArenaEnemyFrame3ManaBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize, "THINOUTLINE"); ArenaEnemyFrame4HealthBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize,"THINOUTLINE"); ArenaEnemyFrame4ManaBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize, "THINOUTLINE"); ArenaEnemyFrame5HealthBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize,"THINOUTLINE"); ArenaEnemyFrame5ManaBarText:SetFont(C["media"].font, C["unitframes"].arena.fontSize, "THINOUTLINE"); if C["unitframes"].arena.tracker == true then trinkets = {}; local arenaFrame,trinket; for i = 1, 5 do arenaFrame = "ArenaEnemyFrame"..i; trinket = CreateFrame("Cooldown", arenaFrame.."Trinket", ArenaEnemyFrames); trinket:SetPoint("TOPRIGHT", arenaFrame, 30, -6); trinket:SetSize(24, 24); trinket.icon = trinket:CreateTexture(nil, "BACKGROUND"); trinket.icon:SetAllPoints(); trinket.icon:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_01"); trinket:Hide(); trinkets["arena"..i] = trinket; end; local events = CreateFrame("Frame"); function events:UNIT_SPELLCAST_SUCCEEDED(unitID, spell, rank, lineID, spellID) if not trinkets[unitID] then return; end ; if spellID == 59752 or spellID == 42292 then CooldownFrame_SetTimer(trinkets[unitID], GetTime(), 120, 1); SendChatMessage("Trinket used by: "..GetUnitName(unitID, true), "PARTY"); end; end; function events:PLAYER_ENTERING_WORLD() local _, instanceType = IsInInstance(); if instanceType == "arena" then self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED"); elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED"); for _, trinket in pairs(trinkets) do trinket:SetCooldown(0, 0); trinket:Hide(); end; end; end; events:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end); events:RegisterEvent("PLAYER_ENTERING_WORLD"); end; end; -- Boss Frames if C["unitframes"].boss.enable then for i = 1,4 do local boss = _G["Boss"..i.."TargetFrame"]; if boss then boss:SetScale(C["unitframes"].boss.scale) boss:ClearAllPoints(); boss:SetPoint(C['unitframes'].boss.position.relAnchor, UIParent, C['unitframes'].boss.position.offSetX, C['unitframes'].boss.position.offSetY); boss.ClearAllPoints = function() end; boss.SetPoint = function() end; end; end; end; -- Font Style thanks to Phanx from WoWinterface. local shorts = { { 1e10, 1e9, "%.0fb" }, -- 10b+ as 12b { 1e9, 1e9, "%.1fb" }, -- 1b+ as 8.3b { 1e7, 1e6, "%.0fm" }, -- 10m+ as 14m { 1e6, 1e6, "%.1fm" }, -- 1m+ as 7.4m { 1e5, 1e3, "%.0fk" }, -- 100k+ as 840k { 1e3, 1e3, "%.1fk" }, -- 1k+ as 2.5k { 0, 1, "%d" }, -- < 1k as 974 } for i = 1, #shorts do shorts[i][4] = shorts[i][3] .. " (%.0f%%)" end hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusBar, fontString, value, valueMin, valueMax) local style = GetCVar("statusTextDisplay") if style == "PERCENT" then return fontString:SetFormattedText("%.0f%%", value / valueMax * 100) end for i = 1, #shorts do local t = shorts[i] if value >= t[1] then if style == "BOTH" then return fontString:SetFormattedText(t[4], value / t[2], value / valueMax * 100) else return fontString:SetFormattedText(t[3], value / t[2]) end end end end) -- Disable healing/damage spam over player/pet frame: PlayerHitIndicator:SetText(nil) PlayerHitIndicator.SetText = function() end PetHitIndicator:SetText(nil) PetHitIndicator.SetText = function() end |
||
03-02-14, 01:57 PM | #6 |
One more question concerning font.
How can I make the following font classcolor to match the person:
Thanks for any help with this. |
|
03-02-14, 07:47 PM | #7 |
The simplest solution is probably going to be to hook the function that sets the text:
Code:
hooksecurefunc("UnitFrame_Update", function(self) if not self.name then return end if UnitIsPlayer(self.unit) then -- Color by class: local _, class = UnitClass(self.unit) local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class] self.name:SetTextColor(color.r, color.g, color.b) else -- Not a player. Return to default color: self.name:SetTextColor(1, 0.82, 0) end end) If you wanted to color pets by their owner's class, the simplest solution would probably be to look at the pet's creature type and just make an assumption -- eg. beast = hunter, demon = warlock, etc.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
03-04-14, 03:18 PM | #8 | |
Thank you for this it works great. Im confused on trying to do the "reaction" part. I've tried: Code:
self.name:SetTextColor(FACTION_BAR_COLORS[reaction].r, FACTION_BAR_COLORS[reaction].g, FACTION_BAR_COLORS[reaction].b) Even tried: Code:
FACTION_BAR_COLORS = { [1] = {r = 0.8, g = 0.3, b = 0.22}, [2] = {r = 0.8, g = 0.3, b = 0.22}, [3] = {r = 0.75, g = 0.27, b = 0}, [4] = {r = 0.9, g = 0.7, b = 0}, [5] = {r = 0, g = 0.6, b = 0.1}, [6] = {r = 0, g = 0.6, b = 0.1}, [7] = {r = 0, g = 0.6, b = 0.1}, [8] = {r = 0, g = 0.6, b = 0.1}, }; local reaction = UnitReaction(self.unit, "player"); self.name:SetTextColor(FACTION_BAR_COLORS[reaction].r, FACTION_BAR_COLORS[reaction].g, FACTION_BAR_COLORS[reaction].b) and thanks again for all your help. Coke P.S. Error I keep getting: Code:
Message: ...ace\AddOns\BasicUI\Modules\Unitframes\Unitframes.lua:199: attempt to index field '?' (a nil value) Time: 03/04/14 13:18:37 Count: 5 Stack: ...ace\AddOns\BasicUI\Modules\Unitframes\Unitframes.lua:199: in function <...ace\AddOns\BasicUI\Modules\Unitframes\Unitframes.lua:188> [C]: in function `UnitFrame_Update' ...terface\AddOns\Blizzard_ArenaUI\Blizzard_ArenaUI.lua:275: in function `ArenaEnemyFrame_UpdatePet' ...terface\AddOns\Blizzard_ArenaUI\Blizzard_ArenaUI.lua:47: in function <...terface\AddOns\Blizzard_ArenaUI\Blizzard_ArenaUI.lua:25> Locals: self = ArenaEnemyFrame5PetFrame { 0 = <userdata> menu = <function> defined @Interface\AddOns\Blizzard_ArenaUI\Blizzard_ArenaUI.lua:295 name = ArenaEnemyFrame5PetFrameName { } DropDown = ArenaEnemyFrame5PetFrameDropDown { } manabar = ArenaEnemyFrame5PetFrameManaBar { } portrait = ArenaEnemyFrame5PetFramePortrait { } healthbar = ArenaEnemyFrame5PetFrameHealthBar { } unit = "arenapet5" } reaction = nil (*temporary) = <function> defined =[C]:-1 (*temporary) = ArenaEnemyFrame5PetFrameName { 0 = <userdata> } (*temporary) = nil (*temporary) = nil (*temporary) = nil (*temporary) = nil (*temporary) = nil (*temporary) = "attempt to index field '?' (a nil value)" Last edited by cokedrivers : 03-04-14 at 03:23 PM. |
||
WoWInterface » Developer Discussions » Lua/XML Help » Help with some Font settings |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Hybrid Mode |
Switch to Threaded Mode |
|
|