Skip to content

Commit

Permalink
Refactor|Fonts|Resources: Continued overhauling the Fonts resource co…
Browse files Browse the repository at this point in the history
…llection

Now builds and links. Printing/querying of font resources from the
console is presently disabled (todo).
  • Loading branch information
danij-deng committed Nov 10, 2013
1 parent 3ee51a4 commit d96a1fb
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 161 deletions.
9 changes: 6 additions & 3 deletions doomsday/client/include/dd_main.h
Expand Up @@ -162,6 +162,12 @@ de::String DD_MaterialSchemeNameForTextureScheme(de::String textureSchemeName);
/// @return The application's global ResourceSystem.
ResourceSystem &App_ResourceSystem();

/// @return The application's global Texture collection.
de::Textures &App_Textures();

/// @return The application's global Font collection.
de::Fonts &App_Fonts();

/// @return @c true iff there is presently a game loaded.
boolean App_GameLoaded();

Expand Down Expand Up @@ -189,9 +195,6 @@ de::Materials &App_Materials();
*/
void App_DeleteMaterials();

/// @return The application's global Texture collection.
de::Textures &App_Textures();

fontschemeid_t DD_ParseFontSchemeName(char const *str);

/// @return Symbolic name of the material scheme associated with @a textureSchemeName.
Expand Down
11 changes: 8 additions & 3 deletions doomsday/client/include/resource/fonts.h
Expand Up @@ -211,6 +211,10 @@ class Fonts

} // namespace de

#ifdef __cplusplus
extern "C" {
#endif

/**
* Update the Font according to the supplied definition.
* To be called after an engine update/reset.
Expand All @@ -226,9 +230,6 @@ void Font_RebuildFromFile(struct font_s *font, char const *resourcePath);
fontid_t Fonts_ResolveUriCString2(char const *uri, boolean quiet);
fontid_t Fonts_ResolveUriCString(char const *uri); /*quiet=!(verbose >= 1)*/

struct font_s *R_CreateFontFromFile(Uri *uri, char const *resourcePath);
struct font_s *R_CreateFontFromDef(ded_compositefont_t *def);

/*
* Here follows miscellaneous routines currently awaiting refactoring into the
* revised resource and texture management APIs.
Expand All @@ -245,4 +246,8 @@ void Fonts_CharSize(struct font_s *font, Size2Raw *size, unsigned char ch);
int Fonts_CharHeight(struct font_s *font, unsigned char ch);
int Fonts_CharWidth(struct font_s *font, unsigned char ch);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // DENG_RESOURCE_FONTS_H
4 changes: 2 additions & 2 deletions doomsday/client/src/con_main.cpp
Expand Up @@ -2794,10 +2794,10 @@ D_CMD(Font)
if(!stricmp(argv[1], "name") && argc == 3)
{
de::Uri uri(String(argv[2]), RC_NULL);
fontid_t newFont = Fonts_ResolveUri2(reinterpret_cast<uri_s *>(&uri), true/*quiet please*/);
fontid_t newFont = App_Fonts().resolveUri(reinterpret_cast<uri_s *>(&uri), true/*quiet please*/);
if(newFont)
{
QScopedPointer<de::Uri> uri(reinterpret_cast<de::Uri *>(Fonts_ComposeUri(newFont)));
QScopedPointer<de::Uri> uri(reinterpret_cast<de::Uri *>(App_Fonts().composeUri(newFont)));
Con_SetFont(newFont);
if(!uri->scheme().compareWithoutCase("Game"))
{
Expand Down
12 changes: 8 additions & 4 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -530,6 +530,11 @@ de::Textures &App_Textures()
return App_ResourceSystem().textures();
}

de::Fonts &App_Fonts()
{
return App_ResourceSystem().fonts();
}

void DD_ClearRuntimeTextureSchemes()
{
App_ResourceSystem().clearRuntimeTextureSchemes();
Expand Down Expand Up @@ -1451,7 +1456,7 @@ bool App_ChangeGame(Game &game, bool allowReload)
R_ShutdownSvgs();
R_DestroyColorPalettes();

Fonts_ClearRuntime();
App_Fonts().clearRuntime();
DD_ClearRuntimeTextureSchemes();

Sfx_InitLogical();
Expand Down Expand Up @@ -1812,7 +1817,6 @@ boolean DD_Init(void)
F_Init();
DD_CreateFileSystemSchemes();

Fonts_Init();
FR_Init();

#ifdef __CLIENT__
Expand Down Expand Up @@ -2590,9 +2594,9 @@ void DD_SetVariable(int ddvalue, void *parm)
}

/// @note Part of the Doomsday public API.
fontschemeid_t DD_ParseFontSchemeName(const char* str)
fontschemeid_t DD_ParseFontSchemeName(char const *str)
{
return Fonts_ParseScheme(str);
return App_Fonts().parseScheme(str);
}

String DD_MaterialSchemeNameForTextureScheme(String textureSchemeName)
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/def_main.cpp
Expand Up @@ -1433,7 +1433,7 @@ void Def_Read()
scheme.reset();

invalidateAllMaterials();
Fonts_ClearDefinitionLinks();
App_Fonts().clearDefinitionLinks();

Def_Destroy();
}
Expand All @@ -1457,7 +1457,7 @@ void Def_Read()
// Composite fonts.
for(int i = 0; i < defs.count.compositeFonts.num; ++i)
{
R_CreateFontFromDef(defs.compositeFonts + i);
App_Fonts().createFontFromDef(defs.compositeFonts + i);
}

// Sprite names.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/gl/gl_texmanager.cpp
Expand Up @@ -1130,7 +1130,7 @@ void GL_ReleaseSystemTextures()

GL_ReleaseTexturesByScheme("System");
Rend_ParticleReleaseSystemTextures();
Fonts_ReleaseSystemTextures();
App_Fonts().releaseSystemTextures();

GL_PruneTextureVariantSpecifications();
}
Expand Down Expand Up @@ -1160,7 +1160,7 @@ void GL_ReleaseRuntimeTextures()
GL_ReleaseTexturesForRawImages();

Rend_ParticleReleaseExtraTextures();
Fonts_ReleaseRuntimeTextures();
App_Fonts().releaseRuntimeTextures();

GL_PruneTextureVariantSpecifications();
}
Expand Down
14 changes: 6 additions & 8 deletions doomsday/client/src/render/r_main.cpp
Expand Up @@ -189,11 +189,11 @@ char const *R_ChooseVariableFont(fontstyle_t style, int resX, int resY)
#ifdef __CLIENT__
static fontid_t loadSystemFont(char const *name)
{
DENG_ASSERT(name && name[0]);
DENG2_ASSERT(name != 0 && name[0]);

// Compose the resource name.
struct uri_s *uri = Uri_NewWithPath2("System:", RC_NULL);
Uri_SetPath(uri, name);
de::Uri uri("System:", RC_NULL);
uri.setPath(name);

// Compose the resource data path.
ddstring_t resourcePath; Str_InitStd(&resourcePath);
Expand All @@ -205,17 +205,16 @@ static fontid_t loadSystemFont(char const *name)
#endif
F_ExpandBasePath(&resourcePath, &resourcePath);

font_t *font = R_CreateFontFromFile(uri, Str_Text(&resourcePath));
font_t *font = App_Fonts().createFontFromFile(uri, Str_Text(&resourcePath));
Str_Free(&resourcePath);
Uri_Delete(uri);

if(!font)
{
Con_Error("loadSystemFont: Failed loading font \"%s\".", name);
exit(1); // Unreachable.
}

return Fonts_Id(font);
return App_Fonts().id(font);
}

static void loadFontIfNeeded(char const *uri, fontid_t *fid)
Expand All @@ -232,7 +231,7 @@ void R_LoadSystemFonts()
{
#ifdef __CLIENT__

if(!Fonts_IsInitialized() || isDedicated) return;
if(isDedicated) return;

loadFontIfNeeded(R_ChooseFixedFont(), &fontFixed);
loadFontIfNeeded(R_ChooseVariableFont(FS_NORMAL, DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT), &fontVariable[FS_NORMAL]);
Expand Down Expand Up @@ -576,7 +575,6 @@ void R_Shutdown()
R_ShutdownSvgs();
#ifdef __CLIENT__
R_ShutdownViewWindow();
Fonts_Shutdown();
Rend_Shutdown();
#endif
}
Expand Down

0 comments on commit d96a1fb

Please sign in to comment.