[Help Needed] Creating a mods menu for a fonts mod

+
[Help Needed] Creating a mods menu for a fonts mod

Sort of a modding noob here.
(First time I'm trying to create a mods using a mods menu)

I am trying to create a small mod that allows me to change the in-game font with a menu. (Options Slider)
I'll explain how I'm trying to do this.

First

1) I located the file responsible for the game font: \gameplay\gui_new\swf\witcher3\fonts.en.redswf
2) I edited this file with JPEXS Flash Decompiler, and embedded the new font: http://www.fonts2u.com/malefic-font.font
3) As a test I ran this on its own as a replacement. (I packed the edited file with the same name under \gameplay\gui_new\swf\witcher3\)

Worked fine, the font showed up in game.


I have no problem changing the game font, as long as i package the edited .redswf file as a direct replacement for the vanilla one.

Second

Now I am trying to create a mod menu that allows me (at least for now) to switch the font from the Default one to this one.
Later on, I'd like to add more and more.

This is the XML file:
The one under \The Witcher 3\bin\config\r4game\user_config_matrix\pc

Code:
<?xml version="1.0" encoding="UTF-16"?>
<UserConfig>
    <Group id="FontSettings" displayName="Mods.Miscellaneous">
        <VisibleVars>
            <Var id="FontSelection" displayName="Font" displayType="OPTIONS" tags="customNames;customDisplayName">
                <OptionsArray>
                    <Option id="0" displayName="font_Default">
                        <Entry varId="FontSelection" value="0"/>
                    </Option>
                    <Option id="1" displayName="font_Malefic">
                        <Entry varId="FontSelection" value="1"/>
                    </Option> 
                </OptionsArray>
            </Var>
        </VisibleVars>
    </Group>
</UserConfig>

Code:
[FontSettings]
FontSelection=1

This works fine. The menu appears in game, and i am able to use it to change the value output of "FontSelection"

Third

Now I'm trying to get to grips with the w3strings file, and this is where i am most confused.

Here is what i have so far:
Code:
;meta[language=en]
; id      |key(hex)|key(str)| text
2119999100|4d5f8b0c||Mods
2119999101|xxxxxxxx||Font

1) What is the key(hex)? How do i find out what one i need for my files?
2) How do I find out what ID i need?
3) "Text"is fairly self explanatory.

I have found very little in the way of documentation.

These threads helped a bit, but didn't fully explain.
http://forums.cdprojektred.com/foru...new-ids-and-keys-as-standalone-w3strings-file
https://forums.nexusmods.com/index....-one-make-a-mod-that-uses-the-gams-mods-menu/

Forth

Ok, so now i need to actually get the game to read the corresponding file based on user selection.

I planed to swap the font by having multiple .redswf files under \gameplay\gui_new\swf\witcher3\ each with various names

\gameplay\gui_new\swf\witcher3\[Default]fonts_en.redswf
\gameplay\gui_new\swf\witcher3\[Malefic]fonts_en.redswf
etc...
for example

I then would edit this file: \gameplay\gui_new\fonts.xml

I want the code to check which font is selected from the menu (user.settings file) and then tell it to reference a particular file.

The vanilla code:

Code:
<?xml version="1.0" encoding="UTF-16"?>
<fonts fontlib="gfxfontlib">
  <lang name="EN" fontlib="gameplay/gui_new/swf/witcher3/fonts_en.redswf">
        <NormalFont font="PF Din Text Cond Pro"/>
        <ItalicFont font="PF Din Text Cond Pro" italic="1"/>
        <BoldFont font="PF Din Text Cond Pro" bold="1"/>
        <CreditsFont font="PF Din Text Cond Pro"/>
    </lang>
    <lang name="RU" fontlib="gameplay/gui_new/swf/witcher3/fonts_ru.redswf">
        <NormalFont font="PF Din Text Cond Pro"/>
        <ItalicFont font="PF Din Text Cond Pro" italic="1"/>
        <BoldFont font="PF Din Text Cond Pro" bold="1"/>
        <CreditsFont font="PF Din Text Cond Pro"/>
    </lang>
    <lang name="AR" fontlib="gameplay/gui_new/swf/witcher3/fonts_ar.redswf">
        <NormalFont font="Arial"/>
        <ItalicFont font="Arial"/>
        <BoldFont font="Arial" bold="1"/>
        <CreditsFont font="PF Din Text Cond Pro"/>
    </lang>
    <lang name="ZH" glyphcache="1" fontlib="gameplay/gui_new/swf/witcher3/fonts_zh.redswf">
        <NormalFont font="PMingLiU"/>
        <ItalicFont font="PMingLiU"/>
        <BoldFont font="PMingLiU"/>
        <CreditsFont font="PF Din Text Cond Pro"/>
    </lang>
    <lang name="CN" glyphcache="1" fontlib="gameplay/gui_new/swf/witcher3/fonts_zh.redswf">
        <NormalFont font="PMingLiU"/>
        <ItalicFont font="DPMingLiU"/>
        <BoldFont font="PMingLiU"/>
        <CreditsFont font="PF Din Text Cond Pro"/>
    </lang>
    <lang name="JP" glyphcache="1" fontlib="gameplay/gui_new/swf/witcher3/fonts_jp.redswf">
        <NormalFont font="DFMinchoP-W5"/>
        <ItalicFont font="DFMinchoP-W5" />
        <BoldFont font="DFMinchoP-W5"/>
        <CreditsFont font="PF Din Text Cond Pro"/>
    </lang>
    <lang name="KR" fontlib="gameplay/gui_new/swf/witcher3/fonts_kr.redswf">
        <NormalFont font="NanumMyeongjo"/>
        <ItalicFont font="NanumMyeongjo"/>
        <BoldFont font="NanumMyeongjo Bold"/>
        <CreditsFont font="PF Din Text Cond Pro"/>
    </lang>
    <lang name="PL" ref="EN"/>
    <lang name="DE" ref="EN"/>
    <lang name="FR" ref="EN"/>
    <lang name="IT" ref="EN"/>
    <lang name="ES" ref="EN"/>
    <lang name="BR" ref="EN"/>
    <lang name="ESMX" ref="EN"/>
    <lang name="CZ" ref="EN"/>
    <lang name="HU" ref="EN"/>
    <lang name="TR" ref="EN"/>
    <lang name="DEBUG" ref="EN"/>
</fonts>

However i have run into a problem.

As a quick test to see if it would work I changed the directory of the font file to
Code:
  <lang name="EN" fontlib="gameplay/gui_new/swf/witcher3/[Malefic]fonts_en.redswf">

And packed that edited version and the fonts file.
so this:
\gameplay\gui_new\swf\witcher3\[Malefic]fonts_en.redswf
gameplay\gui_new\fonts.xml

The game launches, but gets stuck on a black screen. (I'm guessing the game is trying to find [Malefic]fonts_en.redswf in the vanilla files, not my modded one, and it can't)

So, how do i fix this? (tell it to reference my new file?)

Finally

These are the question i have:

What are the hex values in the w3strings file?
How do I find out these hex values?
What are the ID values in the w3strings file?
How do i link the w3strings file and the the xml files together?
How do i get the edited fonts XML file reference my new packed files?

 
for strings id advise you to just use the string key values, because you can just put that into the "displayName" of the xml.. so for example in the xml you have:
Code:
<OptionsArray>
    <Option id="0" displayName="font_Default">
        <Entry varId="FontSelection" value="0"/>
    </Option>
    <Option id="1" displayName="font_Malefic">
        <Entry varId="FontSelection" value="1"/>
    </Option> 
</OptionsArray>

then in the strings.csv you put:

Code:
2119999100||font_Default|This is the Default Font
2119999101||font_Malefic|This is the Malefix Font

also since these key strings are quite generic you should use your mod name as a prefix..
displayName="modNewFonts_font_Default"

2119999100||modNewFonts_font_Default|This is the Default Font

also for the Tab names you need the prefix PANEL_
preset values have a prefix of PRESET_VALUE_
and preset name has PRESET_Mods_ (i think)


as an unspoker rule the 4 digit String ID space should be your mods ID on nexus



the first 3 numbers will always be 211 and the last 3 are the ID of that ID space
so if i were to go by the picture, it would go like so:
Code:
2112079000
2112079001
2112079002
2112079003
​​​​​​​etc...




As for the font adding itself, you cant add New files with just a mod (textures are the exception i think) the only way to add other new files is via the DLC.. but since no other fonts have been added to the game we have no idea how this is done and there is no Mounter that we know about for them.

what i would try is to embed another font into the fonts_en.redswf without replacing anything else, giving it a name, and then in the xml making another type. Like there are Normal, Bold, Italic, Credits variants...
then in game scripts you might be able to reference that new type.
here are examples of Bold and Credits types being referenced:




Good luck!
 
erxv

Thanks for your input.
Helped me a lot.

Now I have run into a few limitations with the fonts_en.redswf file.
Firstly that if i add more than 3 entries to it, the file will just fail to load, and reverts to the default one. (I'm guess its to do with file size here?)
Secondly I'm unable to change any of the directories for the font variants in the fonts.xml file (that matches the directory in the fonts.en.redswf file) without the game refusing to load fonts at all. (I just get white boxes)
Finally, given the number of times the game's scripts call upon the fonts.xml file, and therefore fonts_en.redswf it wouldn't reasonably be possible to change every single reference made throughout the game, not to mention the compatibility issues it would cause with other mods.

Even if the the above was solved, it would mean every time i wanted to add a new font, I'd have to edit: fonts_en.redswf, fonts.xml, and all game scripts that call upon the font to load, based on menu selection.
The idea with this mod is to allow for basically an unlimited of fonts to be added.

So unfortunately I seem to be stuck with that. :(

So I have tried a new method, one that has had much better success.

The basic idea now is to use a windows batch file to read the "user.setting" file, and based on that copy the correct files (.bundle .metadata) to the needed directory.

Code:
@runmode:hide
@echo off
set File=[I]<Location of user.setting>[/I]
for /f %%m in ('findstr "FontSelection=" "%File%"') do set fontpackagedir=%%m
for /r "%~dp0fontpackage\%fontpackagedir%" %%x in (*) do copy "%%x" "%~dp0content"

What this does it scan user.setting to find the line containing "FontSelection="
It then sets the result of that as a variable: "fontpackagedir"
It then uses that variable to complete the directory of the location of the actual font files, and copies them over to 'content'
This is within the 'modFonts' folder

Mods
---modFonts
------content
------fontpackage
---------font a
---------font b
---------font c
---------font d
---------font e
---------font f

------modFonts.bat

Example:

Default Font.


Poor Richard Font


This does require a game restart, but that's a small price to pay.

This now allows for a lot of flexibility and future expansion.
1) Unlimited number of fonts
2) Very easy to add a font (no modifying game scripts at all, all that is needed is to package a replacement fonts_en.redswf file, and add it to database of fonts in the mod directory. Then create a new entry in the menu xml file. the batch script handles the rest)
3) No compatibility issues with other mods at all.


All that is left to do now is make the batch script run when your launch the game, finish the w3strings file, and it should be more or less finished.

:D

 
erxv;n8557600 said:
what i would try is to embed another font into the fonts_en.redswf without replacing anything else, giving it a name, and then in the xml making another type. Like there are Normal, Bold, Italic, Credits variants... then in game scripts you might be able to reference that new type. here are examples of Bold and Credits types being referenced:

Is it possible to add a new font variant like "VeryBoldFont" but in a seperate .redswf file? I don't want to change the existing .redswf files because that would make it impossible for other mods to change fonts
 
Lim3zer0;n8561270 said:
erxv

Thanks for your input.
Helped me a lot.

Now I have run into a few limitations with the fonts_en.redswf file.
Firstly that if i add more than 3 entries to it, the file will just fail to load, and reverts to the default one. (I'm guess its to do with file size here?)
Secondly I'm unable to change any of the directories for the font variants in the fonts.xml file (that matches the directory in the fonts.en.redswf file) without the game refusing to load fonts at all. (I just get white boxes)
Finally, given the number of times the game's scripts call upon the fonts.xml file, and therefore fonts_en.redswf it wouldn't reasonably be possible to change every single reference made throughout the game, not to mention the compatibility issues it would cause with other mods.

Even if the the above was solved, it would mean every time i wanted to add a new font, I'd have to edit: fonts_en.redswf, fonts.xml, and all game scripts that call upon the font to load, based on menu selection.
The idea with this mod is to allow for basically an unlimited of fonts to be added.

So unfortunately I seem to be stuck with that. :(

So I have tried a new method, one that has had much better success.

The basic idea now is to use a windows batch file to read the "user.setting" file, and based on that copy the correct files (.bundle .metadata) to the needed directory.

Code:
@runmode:hide
@echo off
set File=[I]<Location of user.setting>[/I]
for /f %%m in ('findstr "FontSelection=" "%File%"') do set fontpackagedir=%%m
for /r "%~dp0fontpackage\%fontpackagedir%" %%x in (*) do copy "%%x" "%~dp0content"

What this does it scan user.setting to find the line containing "FontSelection="
It then sets the result of that as a variable: "fontpackagedir"
It then uses that variable to complete the directory of the location of the actual font files, and copies them over to 'content'
This is within the 'modFonts' folder

Mods
---modFonts
------content
------fontpackage
---------font a
---------font b
---------font c
---------font d
---------font e
---------font f

------modFonts.bat

Example:

Default Font.


Poor Richard Font


This does require a game restart, but that's a small price to pay.

This now allows for a lot of flexibility and future expansion.
1) Unlimited number of fonts
2) Very easy to add a font (no modifying game scripts at all, all that is needed is to package a replacement fonts_en.redswf file, and add it to database of fonts in the mod directory. Then create a new entry in the menu xml file. the batch script handles the rest)
3) No compatibility issues with other mods at all.


All that is left to do now is make the batch script run when your launch the game, finish the w3strings file, and it should be more or less finished.

:D

Do you have this batch file? I hit the wall trying to get TheWitcherFont to load.
 
Top Bottom