PDA

View Full Version : Set fonts for GM only



dllewell
May 12th, 2020, 15:21
I'm working on an extension to set the fonts. I only want these font settings to be modified for the GM, however.

It seems I can use the User.isHost() function to identify that I am the GM.

It appears that I then have 2 options. Either call the file using lua or set the fonts programmatically via lua.

Can anyone give me some hints on how to do either of these options?

My preference would be to use a lua command to call the file so that I could then use that same logic for other settings but I'm also fine with the other option.

So far in my extension.xml I have the following code (which obviously doesn't work as the includefile syntax is not valid inside the script)

-----------------
<script>
function setFont()
if User.isHost() then
<includefile source="graphics_fonts.xml" />;
end
end
</script>
----------------

The graphics_fonts.xml file is a fairly standard set fonts file

----------
<font name="reference-h">
<ttf file="graphics/fonts/MarcellusSC-Regular.ttf" name="Marcellus SC" size="26" />
<color value="#660000" />
</font>
----------

I'm happy to research further if someone can point me to a reference file that might have info on this. I did read through the Fantasy Grounds Developer Guide but did not see anything to do this. Of course, it could be that it is there and I just missed it.


Thank you for your help

Trenloe
May 12th, 2020, 15:35
Unfortunately you can't change the font definitions at run time as they are all built when the layered ruleset and extensions are loaded when the campaign is started.

The best you can do is set the font being used by an individual text control, using setFont: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4096428/textbasecontrol#setFont

Unfortunately, I don't think this works with formatted text controls.

ScriedRaven
May 12th, 2020, 16:00
Something that I ran into that might help is once when I was messing with modifying a default theme, is that when a player loaded in they saw the unmodified theme on their end. You might be able to create a player version and a gm version that still read as the same extension to Fantasy Grounds.

Trenloe
May 12th, 2020, 16:07
Something that I ran into that might help is once when I was messing with modifying a default theme, is that when a player loaded in they saw the unmodified theme on their end. You might be able to create a player version and a gm version that still read as the same extension to Fantasy Grounds.
In theory, that shouldn't happen. Even if the player has an extension of the same name installed locally, if it doesn't match the GMs extension, then the extension from the GM side will be downloaded and used by the player instance for that campaign. Whereas they might have been a glitch or a bug in the coding, that is not working as designed and will probably not work like that reliably or will be "fixed" before too long.

ScriedRaven
May 12th, 2020, 16:34
In theory, that shouldn't happen. Even if the player has an extension of the same name installed locally, if it doesn't match the GMs extension, then the extension from the GM side will be downloaded and used by the player instance for that campaign. Whereas they might have been a glitch or a bug in the coding, that is not working as designed and will probably not work like that reliably or will be "fixed" before too long.

If I remember what I did correctly the change I made was that I deleted a couple image files (the buttons), but I left the coding unchanged. I haven't looked into it, as it doesn't normally affect me, but I might look into this evening

Trenloe
May 12th, 2020, 16:39
If I remember what I did correctly the change I made was that I deleted a couple image files (the buttons), but I left the coding unchanged. I haven't looked into it, as it doesn't normally affect me, but I might look into this evening
Like I said, that is not how the extensions system is designed to work. If it's doing it now, I wouldn't rely on that occurring in future - because it's a defect and may be fixed, or may not have a repeatable functionality. Of course you're free to do whatever you wish with your time. But, I just want to make this clear so that people don't spend time doing custom projects based off this assumption that end up suddenly not working.

Trenloe
May 12th, 2020, 17:05
And to follow up... even if it is possible to load different extensions on the player side (which it shouldn't be), this is not a desirable approach as loading different code to what the GM is loading can lead to unpredictable functionality and so is not recommended (very strongly not recommended).

dllewell
May 12th, 2020, 18:24
Thank you for the answers. So definitely not possible to modify the fonts directly at run time.

What about only calling the graphics_fonts.xml file if the person loading the extension is the host (GM)?

In this case, the players would still have the fonts that were set as part of the ruleset, they just wouldn't have the modified fonts that are present in this extension.

Daniel

Trenloe
May 12th, 2020, 18:35
What about only calling the graphics_fonts.xml file if the person loading the extension is the host (GM)?
Nope. The GM loads everything that's enabled and then pushes all of that down to the players when they connect.

dllewell
May 12th, 2020, 18:44
OK. A little disappointing. It seems a little clunky to force players to all have the same look and feel ... but in the grand scheme of things, it's fairly minor.

Thank you for taking the time to answer my questions. It's very much appreciated.

Daniel

LordEntrails
May 13th, 2020, 00:36
Its not so much that the design is that players have the same look and feel (theme) but rather that they have the same codebase because themes are not differentiated from game mechanics or core functionality. So if you allowed different extensions between the player and the GM, then a player might be able to load an extension that gave them +1 on all attack rolls, or calculated something else differently. This way, by design everyone uses the same codebase.

It does have shortcomings, such as with themes, that might one day be rectified, but for now its a core architecture decision about the program that would not be easy to change.

dllewell
May 13th, 2020, 01:24
That makes sense. I play with a group of friends I've known for years so that's not even something that crossed my mind. But it makes perfect sense when you think about playing with people you have never personally met ... who may, or may not, be completely honest.