-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20ed993
commit b3e23c3
Showing
5 changed files
with
141 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef D_FONT_MANAGER_H | ||
#define D_FONT_MANAGER_H | ||
|
||
#include <d/d_dvd.h> | ||
#include <nw4r/ut/ut_ResFont.h> | ||
|
||
|
||
class dFontMng_c { | ||
public: | ||
dFontMng_c(); | ||
~dFontMng_c(); | ||
|
||
static nw4r::ut::ResFont *getFont(u8 type); | ||
void setFontFile(int idx, void *fileData); | ||
static dFontMng_c *getFontManager(int idx); | ||
static u8 getFontMgrIdx(u8 type); | ||
static const char *getFontPath(u8 idx); | ||
|
||
static bool create(); | ||
|
||
private: | ||
static char special_01[]; | ||
static char special_00[]; | ||
static char normal_01[]; | ||
static char normal_00[]; | ||
|
||
nw4r::ut::ResFont mFont; | ||
dDvd::loader_c mLoader; | ||
// The purpose of these two is a bit unclear because they appear | ||
// to be set to the same thing? | ||
nw4r::ut::BinaryFileHeader *mpFontFile; | ||
void *mpFileData; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include <d/d_font_manager.h> | ||
#include <d/d_heap.h> | ||
#include <sized_string.h> | ||
|
||
static dFontMng_c l_dFontMng_obj[3]; | ||
|
||
static char *systemFonts[] = {"normal_00.brfnt", "special_00.brfnt", "picture_00.brfnt"}; | ||
static char *fonts[] = {"normal_00.brfnt", "normal_01.brfnt", "special_00.brfnt", "special_01.brfnt", | ||
"picture_00.brfnt"}; | ||
|
||
// TODO What's up with these? | ||
char dFontMng_c::normal_01[] = "normal_01.brfnt"; | ||
char dFontMng_c::normal_00[] = "normal_00.brfnt"; | ||
char dFontMng_c::special_01[] = "special_01.brfnt"; | ||
char dFontMng_c::special_00[] = "special_00.brfnt"; | ||
|
||
const u32 fontMgrIndex[] = {0, 0, 1, 1, 2}; | ||
|
||
dFontMng_c::dFontMng_c() { | ||
l_dFontMng_obj[0].mpFileData = nullptr; | ||
l_dFontMng_obj[1].mpFileData = nullptr; | ||
l_dFontMng_obj[2].mpFileData = nullptr; | ||
} | ||
|
||
dFontMng_c::~dFontMng_c() {} | ||
|
||
nw4r::ut::ResFont *dFontMng_c::getFont(u8 type) { | ||
u8 index = getFontMgrIdx(type); | ||
return &l_dFontMng_obj[index].mFont; | ||
} | ||
|
||
char *getFontName(u8 type) { | ||
return fonts[type]; | ||
} | ||
|
||
dFontMng_c *dFontMng_c::getFontManager(int idx) { | ||
return &l_dFontMng_obj[idx]; | ||
} | ||
|
||
u8 dFontMng_c::getFontMgrIdx(u8 type) { | ||
return fontMgrIndex[type]; | ||
} | ||
|
||
void dFontMng_c::setFontFile(int idx, void *fileData) { | ||
l_dFontMng_obj[idx].mpFileData = fileData; | ||
} | ||
|
||
// getUsedLanguageString | ||
extern "C" const char *fn_801B2DB0(); | ||
|
||
const char *dFontMng_c::getFontPath(u8 idx) { | ||
static SizedString<128> TEMP_FONT_NAME; | ||
if (idx == 2) { | ||
TEMP_FONT_NAME.sprintf("/Font/%s", systemFonts[idx]); | ||
} else { | ||
TEMP_FONT_NAME.sprintf("/US/Font/%s/%s", fn_801B2DB0(), systemFonts[idx]); | ||
} | ||
return &TEMP_FONT_NAME; | ||
} | ||
|
||
bool dFontMng_c::create() { | ||
for (u8 i = 0; i < 3; i++) { | ||
if (l_dFontMng_obj[i].mpFontFile == nullptr) { | ||
const char *path = getFontPath(i); | ||
nw4r::ut::BinaryFileHeader *file = static_cast<nw4r::ut::BinaryFileHeader *>( | ||
l_dFontMng_obj[i].mLoader.request(path, 0, dHeap::fontHeap.heap)); | ||
if (file == nullptr) { | ||
return false; | ||
} | ||
l_dFontMng_obj[i].mpFontFile = file; | ||
getFontManager(i)->setFontFile(i, l_dFontMng_obj[i].mpFontFile); | ||
l_dFontMng_obj[i].mFont.SetResource(l_dFontMng_obj[i].mpFontFile); | ||
} | ||
} | ||
|
||
return true; | ||
} |