I always wanted to be able to choose from a list of fonts, so I decided to code & release the ability.
Step 1:
main.cpp
{
find this:
replace with this:Code:if( !g_pDefFont->Create("Default", ZTOK_LOCALE_DEFFONT, DEFAULT_FONT_HEIGHT, 1.0f) )
}Code:if( !g_pDefFont->Create("Default", ZGetConfiguration()->GetSelectedFontIndex(), DEFAULT_FONT_HEIGHT, 1.0f) )
MIDLResource.cpp
{
at the top of the file find add this:
find this:Code:#include "../../Gunz/ZConfiguration.h"
replace with this:Code:if (!strcmp(szBuf, "FONTSET"))
{
childElement.GetContents(szFont)
}
in the same function as "FONTSET" find this:Code:if (!strcmp(szBuf, "FONTSET"))
{
childElement.GetChildContents(szFont,ZTOK_ETC_FONT);
}
replace with this:Code:pFont = CreateFont(szItem, szFont, nHeight, bBold, bItalic, nOutlineStyle, bAntialiasing, nColorArg1, nColorArg2);
}Code:pFont = CreateFont(szItem, (char*)ZGetConfiguration()->GetSelectedFontIndex(), nHeight, bBold, bItalic, nOutlineStyle, bAntialiasing, nColorArg1, nColorArg2);
ZConfiguration.h
{
add this in struct ZCONFIG_ETC:
Code:int nFont;
add this with the other ZTOK_ETC and Z_ETCCode:const char* GetSelectedFontIndex();
}Code:#define ZTOK_ETC_FONT "FONT"
#define Z_ETC_FONT (ZGetConfiguration()->GetEtc()->nFont)
ZConfiguration.cpp
{
find this:
add this under it:Code:childElement.GetChildContents(&m_Etc.nCrossHair, ZTOK_ETC_CROSSHAIR);
find this:Code:childElement.GetChildContents(&m_Etc.nFont, ZTOK_ETC_FONT);
add this under it:Code:// crosshair
parentElement.AppendText("\n\t\t");
aElement = parentElement.CreateChildElement(ZTOK_ETC_CROSSHAIR);
sprintf(temp, "%d", m_Etc.nCrossHair);
aElement.SetContents(temp);
add this at the bottom of the file:Code://font
parentElement.AppendText("\n\t\t");
aElement = parentElement.CreateChildElement(ZTOK_ETC_FONT);
sprintf(temp, "%d", m_Etc.nFont);
aElement.SetContents(temp);
}Code:const char* ZConfiguration::GetSelectedFontIndex()
{
switch (m_Etc.nFont)
{
case 0:
return "Arial";
case 1:
return "Georgia";
case 2:
return "Trebuchet";
case 3:
return "Verdana";
default:
return "Arial";
}
return "Arial";
}
ZOptionInterface.cpp
{
add this in initinterfaceoption:
add this in saveinterfaceoption:Code:pWidget = (MComboBox*)pResource->FindWidget("FontSelectComboBox");
if (pWidget){
pWidget->SetSelIndex(ZGetConfiguration()->GetEtc()->nFont);
}
find this:Code:pWidget = (MComboBox*)pResource->FindWidget("FontSelectComboBox");
if (pWidget)
{
Z_ETC_FONT = pWidget->GetSelIndex();
}
replace with this:Code:if (!g_pDefFont->Create("Default", ZTOK_LOCALE_DEFFONT, newFontHeight, 1.0f))
{
mlog("Fail to Recreate default font : MFontR2 / screen resize\n" );
g_pDefFont->Destroy();
SAFE_DELETE( g_pDefFont );
}
}Code:if (!g_pDefFont->Create("Default", ZGetConfiguration()->GetSelectedFontIndex(), newFontHeight, 1.0f))
{
mlog("Fail to Recreate default font : MFontR2 / screen resize\n" );
g_pDefFont->Destroy();
SAFE_DELETE( g_pDefFont );
}
Option.xml:
Templates.xml:Code:<LABEL item="FontSelectLabel" parent="EtcOptionGroup">
<FONT>FONTa9</FONT>
<TEXTCOLOR>
<R>205</R>
<G>205</G>
<B>205</B>
</TEXTCOLOR>
<BOUNDS>
<X>2</X>
<Y>30</Y>
<W>300</W>
<H>24</H>
</BOUNDS>
<TEXT>Fonts</TEXT>
</LABEL>
<COMBOBOX item="FontSelectComboBox" parent="EtcOptionGroup">
<LISTBOXLOOK>CustomListBoxLook</LISTBOXLOOK>
<BUTTONLOOK>ListBoxButtonLook</BUTTONLOOK>
<FONT>FONTa9</FONT>
<TEXTCOLOR>
<R>205</R>
<G>205</G>
<B>205</B>
</TEXTCOLOR>
<TEXTALIGN>
<VALIGN>center</VALIGN>
<HALIGN>left</HALIGN>
</TEXTALIGN>
<BOUNDS>
<X>105</X>
<Y>30</Y>
<W>90</W>
<H>24</H>
</BOUNDS>
<ALIGN>
<HALIGN>right</HALIGN>
</ALIGN>
<LISTITEM selected="true">Arial</LISTITEM>
<LISTITEM>Georgia</LISTITEM>
<LISTITEM>Trebuchet</LISTITEM>
<LISTITEM>Verdana</LISTITEM>
<DROPSIZE>140</DROPSIZE>
<COMBOTYPE>1</COMBOTYPE>
</COMBOBOX>
System.xml:Code:in default.mrs, look for templates.xml, open it and you'll see a bunch of fontsets
remove all the text inbetween <FONTSET></FONTSET>
Find this and delete it:
If anyone has any issues with it reply to the thread & i'll help you out. Also take a note of this, if you change the option it requires a restart. I have a fix for this but I wanted to leave you guys with a some work to do :pCode:<DEFFONT>Arial </DEFFONT>

