Quantcast
Setting fontsize for ChatFrame1 - WoWInterface
Thread Tools Display Modes
06-16-21, 11:07 AM   #1
DarkruneDOTDK
A Murloc Raider
Join Date: Oct 2015
Posts: 9
Setting fontsize for ChatFrame1

Hi.

I am trying to set the font size for ChatFrame1 (General), but it doesn't seem to update correctly... Doing a /reload will reset the font size to the size it had before the change. It starts by having a font size of 14 on a new character.

Code:
Code:
local name, fontSize, r, g, b, a, shown, locked = FCF_GetChatWindowInfo(1);
local fontFile, _, fontFlags = ChatFrame1:GetFont();
ChatFrame1:SetFont(fontFile, 12, fontFlags);
Is there something I need to do for it to be remembered? - The purpose is to make it easier to setup a new character, so you more or less write a slash command and it does all of it for you.
  Reply With Quote
06-16-21, 11:20 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,418
You've given no context as to the where, when and how this code is called. Makes it almost impossible to comment other than to say the first line doesn't seem to to have anything to do with the other two so maybe there is more code that is missing from your post?


Are you running any chat addons like Prat?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-16-21 at 11:24 AM.
  Reply With Quote
06-16-21, 11:50 AM   #3
DarkruneDOTDK
A Murloc Raider
Join Date: Oct 2015
Posts: 9
Originally Posted by Fizzlemizz View Post
You've given no context as to the where, when and how this code is called. Makes it almost impossible to comment other than to say the first line doesn't seem to to have anything to do with the other two so maybe there is more code that is missing from your post?


Are you running any chat addons like Prat?
Ohh sorry...

The idea is that it is being run with a slash command after the addon has been loaded.
So I have added a SlashCmdHandler like this:
Code:
SLASH_DLU1 = "/dlu";
SlashCmdList.DLU = function(commandName)
	DLU:SlashCmdHandler(commandName);
end
The argument passed is then split like this:
Code:
function DLU:SlashCmdHandler(msg)
	local command, arg2, arg3 = strsplit(" ", msg);
	local arg = command:lower();
if (arg == "test") then
		Test();
	end
end
The Test method would then apply some settings (will be renamed at some point).
Right now I have just looked at the code here (line number 3209) and made a minor change (hard-coded the font size to 12).
I am however not able to call some of the methods in the file, like the ChatFrame_UpdateDefaultChatTarget(self), that I would believe would commit the update to the blizzard servers or something...

Currently I am not using any addon that would modify the chat window at all (actually not using anything that changes the original UI).

Probably also worth mentioning I am doing this in TBC Classic.

Last edited by DarkruneDOTDK : 06-16-21 at 11:52 AM.
  Reply With Quote
06-16-21, 12:24 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,418
To save information between sessions you need to add a setting you your .toc file

for use by ALL characters (or set up a character specific mechanism here):
Code:
## SavedVariables: xxx
Information saved only usable by the current character:
Code:
## SavedVariablesPerCharacter: xxx
If your .toc had
Code:
## SavedVariablesPerCharacter: DarkruneDOTDK_DATA
To save/set the font size you could do something like:

Lua Code:
  1. local function SetFontSize()
  2.     local fontFile, _, fontFlags = ChatFrame1:GetFont();
  3.     ChatFrame1:SetFont(fontFile, DarkruneDOTDK_DATA.fontSize, fontFlags);
  4. end
  5.  
  6. local f = CreateFrame("Frame") -- a frame to handle events
  7. f:SetScript("OnEvent", function(self, event, ...) -- Event handler
  8.     DarkruneDOTDK_DATA = DarkruneDOTDK_DATA or { -- check if your SavedVariables table exists
  9.         fontSize = 12,              -- If not, create it and set some defaults
  10.         someOtherThing = 99,
  11.     }
  12.     SetFontSize() -- Then automatically set the saved font size each login
  13. end)
  14. f:RegisterEvent("PLAYER_LOGIN") -- Event to listen for. This event fires when you login after all addons have loaded
  15.  
  16.  
  17. function DLU:SlashCmdHandler(msg)
  18.     local command, arg2, arg3 = strsplit(" ", msg);
  19.     command = command:lower();
  20.     if command == "size" then -- We want to set a new font size
  21.         DarkruneDOTDK_DATA.fontSize = tonumber(arg2) -- New size, save it to your SavedVariables table
  22.         SetFontSize() -- Update the chat frame with the new size
  23.     end
  24. end
  25.  
  26. SLASH_DLU1 = "/dlu";
  27. SlashCmdList.DLU = function(commandName)
  28.     DLU:SlashCmdHandler(commandName);
  29. end

SavedVariables are global so the name you use for yours should be unique to your addon ie. something like DarkruneDOTDK_DATA
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-16-21 at 12:32 PM.
  Reply With Quote
06-16-21, 02:07 PM   #5
DarkruneDOTDK
A Murloc Raider
Join Date: Oct 2015
Posts: 9
Thanks, seems to work the way I want :-)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Setting fontsize for ChatFrame1

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off