Skip to content

Commit c8f1e9b

Browse files
committed
Merge pull request OpenXcom#1016 from winterheart/custom-fonts-mod
Externalize fonts via modding (second try)
2 parents db48414 + fae972f commit c8f1e9b

5 files changed

Lines changed: 20 additions & 1 deletion

File tree

bin/standard/xcom1/font.rul

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fontName: Font.dat
2+

bin/standard/xcom2/font.rul

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fontName: Font.dat
2+

src/Resource/XcomResourcePack.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ XcomResourcePack::XcomResourcePack(Ruleset *rules) : ResourcePack()
213213
}
214214

215215
// Load fonts
216-
YAML::Node doc = YAML::LoadFile(FileMap::getFilePath("Language/Font.dat"));
216+
std::string fontname = rules->getFontName();
217+
YAML::Node doc = YAML::LoadFile(FileMap::getFilePath("Language/" + fontname));
218+
Log(LOG_INFO) << "Loading font... " << fontname;
217219
Font::setIndex(Language::utf8ToWstr(doc["chars"].as<std::string>()));
218220
for (YAML::const_iterator i = doc["fonts"].begin(); i != doc["fonts"].end(); ++i)
219221
{

src/Ruleset/Ruleset.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ void Ruleset::loadFile(const std::string &filename, size_t spriteOffset)
506506
_timePersonnel = doc["timePersonnel"].as<int>(_timePersonnel);
507507
_initialFunding = doc["initialFunding"].as<int>(_initialFunding);
508508
_alienFuel = doc["alienFuel"].as<std::string>(_alienFuel);
509+
_fontName = doc["fontName"].as<std::string>(_fontName);
509510
_turnAIUseGrenade = doc["turnAIUseGrenade"].as<int>(_turnAIUseGrenade);
510511
_turnAIUseBlaster = doc["turnAIUseBlaster"].as<int>(_turnAIUseBlaster);
511512
for (YAML::const_iterator i = doc["ufoTrajectories"].begin(); i != doc["ufoTrajectories"].end(); ++i)
@@ -1578,6 +1579,15 @@ const std::string Ruleset::getAlienFuel() const
15781579
return _alienFuel;
15791580
}
15801581

1582+
/**
1583+
* Gets name of font collection.
1584+
* @return the name of YAML-file with font data
1585+
*/
1586+
const std::string Ruleset::getFontName() const
1587+
{
1588+
return _fontName;
1589+
}
1590+
15811591
/**
15821592
* Returns the minimum facilitie's radar range.
15831593
* @return The minimum range.

src/Ruleset/Ruleset.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class Ruleset
110110
RuleGlobe *_globe;
111111
int _costSoldier, _costEngineer, _costScientist, _timePersonnel, _initialFunding, _turnAIUseGrenade, _turnAIUseBlaster;
112112
std::string _alienFuel;
113+
std::string _fontName;
113114
YAML::Node _startingBase;
114115
GameTime _startingTime;
115116
std::vector<std::string> _countriesIndex, _regionsIndex, _facilitiesIndex, _craftsIndex, _craftWeaponsIndex, _itemsIndex, _invsIndex, _ufosIndex;
@@ -248,6 +249,8 @@ class Ruleset
248249
Soldier *genSoldier(SavedGame *save) const;
249250
/// Gets the item to be used as fuel for ships.
250251
const std::string getAlienFuel() const;
252+
/// Gets the font name.
253+
const std::string getFontName() const;
251254
/// Gets first turn when AI can use grenade.
252255
int getTurnAIUseGrenade() const {return _turnAIUseGrenade;}
253256
/// Gets first turn when AI can use Blaster launcher.

0 commit comments

Comments
 (0)