Skip to content

Commit

Permalink
Refactor|Server|ResourceSystem: The server does not need a Fonts coll…
Browse files Browse the repository at this point in the history
…ection

The collection is no longer initialized and no logical Font resources
are instantiated on server side (Font definitions are parsed, but not
processed into resources).
  • Loading branch information
danij-deng committed Nov 10, 2013
1 parent d96a1fb commit 1c2a92c
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 14 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/include/dd_main.h
Expand Up @@ -165,8 +165,10 @@ ResourceSystem &App_ResourceSystem();
/// @return The application's global Texture collection.
de::Textures &App_Textures();

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

/// @return @c true iff there is presently a game loaded.
boolean App_GameLoaded();
Expand Down
6 changes: 5 additions & 1 deletion doomsday/client/include/resource/resourcesystem.h
Expand Up @@ -23,7 +23,9 @@
#include <de/Error>
#include "resourceclass.h"
#include "Textures"
#include "Fonts"
#ifdef __CLIENT__
# include "Fonts"
#endif

/**
* Logical resources; materials, packages, textures, etc... @ingroup resource
Expand Down Expand Up @@ -77,10 +79,12 @@ class ResourceSystem : public de::System

patchid_t declarePatch(char const *encodedName);

#ifdef __CLIENT__
/**
* Provides access to the Fonts collection.
*/
de::Fonts &fonts();
#endif

public: /// @todo Should be private:
void initCompositeTextures();
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/con_main.cpp
Expand Up @@ -2764,7 +2764,7 @@ D_CMD(Font)
Con_Printf("Usage: %s (cmd) (args)\n", argv[0]);
Con_Printf("Commands: default, leading, name, size, tracking, xsize, ysize.\n");
Con_Printf("Names: ");
list = Fonts_CollectNames(&listCount);
list = AppFonts().collectNames(&listCount);
for(i = 0; i < listCount-1; ++i)
{
Con_Printf("%s, ", Str_Text(list[i]));
Expand All @@ -2780,7 +2780,7 @@ D_CMD(Font)
if(!stricmp(argv[1], "default"))
{
de::Uri uri(R_ChooseFixedFont(), RC_NULL);
fontid_t newFont = Fonts_ResolveUri(reinterpret_cast<uri_s *>(&uri));
fontid_t newFont = App_Fonts().resolveUri(uri);
if(newFont)
{
Con_SetFont(newFont);
Expand All @@ -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 = App_Fonts().resolveUri(reinterpret_cast<uri_s *>(&uri), true/*quiet please*/);
fontid_t newFont = App_Fonts().resolveUri(uri, true/*quiet please*/);
if(newFont)
{
QScopedPointer<de::Uri> uri(reinterpret_cast<de::Uri *>(App_Fonts().composeUri(newFont)));
QScopedPointer<de::Uri> uri(App_Fonts().composeUri(newFont));
Con_SetFont(newFont);
if(!uri->scheme().compareWithoutCase("Game"))
{
Expand Down
8 changes: 8 additions & 0 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -530,10 +530,12 @@ de::Textures &App_Textures()
return App_ResourceSystem().textures();
}

#ifdef __CLIENT__
de::Fonts &App_Fonts()
{
return App_ResourceSystem().fonts();
}
#endif

void DD_ClearRuntimeTextureSchemes()
{
Expand Down Expand Up @@ -1456,7 +1458,9 @@ bool App_ChangeGame(Game &game, bool allowReload)
R_ShutdownSvgs();
R_DestroyColorPalettes();

#ifdef __CLIENT__
App_Fonts().clearRuntime();
#endif
DD_ClearRuntimeTextureSchemes();

Sfx_InitLogical();
Expand Down Expand Up @@ -2596,7 +2600,11 @@ void DD_SetVariable(int ddvalue, void *parm)
/// @note Part of the Doomsday public API.
fontschemeid_t DD_ParseFontSchemeName(char const *str)
{
#ifdef __CLIENT__
return App_Fonts().parseScheme(str);
#else
return FS_INVALID;
#endif
}

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

invalidateAllMaterials();
#ifdef __CLIENT__
App_Fonts().clearDefinitionLinks();
#endif

Def_Destroy();
}
Expand All @@ -1454,11 +1456,13 @@ void Def_Read()
// Any definition hooks?
DD_CallHooks(HOOK_DEFS, 0, &defs);

#ifdef __CLIENT__
// Composite fonts.
for(int i = 0; i < defs.count.compositeFonts.num; ++i)
{
App_Fonts().createFontFromDef(defs.compositeFonts + i);
}
#endif

// Sprite names.
DED_NewEntries((void **) &sprNames, &countSprNames, sizeof(*sprNames), defs.count.sprites.num);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/resource/fonts.cpp
Expand Up @@ -148,8 +148,8 @@ void Font_Release(font_t *font)
{
switch(Font_Type(font))
{
case FT_BITMAP: BitmapFont_DeleteGLTexture(font); break;
case FT_BITMAPCOMPOSITE: BitmapCompositeFont_ReleaseTextures(font); break;
case FT_BITMAP: BitmapFont_DeleteGLTexture(font); return;
case FT_BITMAPCOMPOSITE: BitmapCompositeFont_ReleaseTextures(font); return;
}
DENG2_ASSERT(false);
}
Expand All @@ -158,8 +158,8 @@ void Font_Prepare(font_t *font)
{
switch(Font_Type(font))
{
case FT_BITMAP: BitmapFont_Prepare(font); break;
case FT_BITMAPCOMPOSITE: BitmapCompositeFont_Prepare(font); break;
case FT_BITMAP: BitmapFont_Prepare(font); return;
case FT_BITMAPCOMPOSITE: BitmapCompositeFont_Prepare(font); return;
}
DENG2_ASSERT(false);
}
Expand Down
4 changes: 4 additions & 0 deletions doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -74,7 +74,9 @@ DENG2_PIMPL(ResourceSystem)
QList<PatchName> patchNames;
Textures textures;

#ifdef __CLIENT__
Fonts fonts;
#endif

Instance(Public *i) : Base(i)
{
Expand Down Expand Up @@ -963,7 +965,9 @@ patchid_t ResourceSystem::declarePatch(char const *encodedName)
return 0;
}

#ifdef __CLIENT__
Fonts &ResourceSystem::fonts()
{
return d->fonts;
}
#endif
1 change: 1 addition & 0 deletions doomsday/client/src/world/surface.cpp
Expand Up @@ -28,6 +28,7 @@
#include "de_defs.h" // Def_GetGenerator

#include "Materials"
#include "TextureManifest"

#include "world/map.h"
#include "Plane"
Expand Down
4 changes: 2 additions & 2 deletions doomsday/server/include/server_dummies.h
Expand Up @@ -53,12 +53,12 @@ DENG_EXTERN_C struct font_s* R_CreateFontFromDef(ded_compositefont_t* def);

DENG_EXTERN_C void FR_Init(void);

DENG_EXTERN_C void Fonts_Init(void);
/*DENG_EXTERN_C void Fonts_Init(void);
DENG_EXTERN_C fontschemeid_t Fonts_ParseScheme(const char* str);
//DENG_EXTERN_C fontid_t Fonts_ResolveUri(Uri const *uri);
DENG_EXTERN_C fontid_t Fonts_ResolveUriCString(const char* uri);
DENG_EXTERN_C void Fonts_ClearDefinitionLinks(void);
DENG_EXTERN_C void Fonts_ClearRuntime(void);
DENG_EXTERN_C void Fonts_ClearRuntime(void);*/

DENG_EXTERN_C void Rend_Init(void);
//DENG_EXTERN_C void Rend_DecorInitForMap();
Expand Down
6 changes: 3 additions & 3 deletions doomsday/server/src/server_dummies.cpp
Expand Up @@ -361,7 +361,7 @@ int FR_TextHeight(const char* text)
}
*/

void Fonts_Init(void)
/*void Fonts_Init(void)
{}
fontschemeid_t Fonts_ParseScheme(const char* str)
Expand All @@ -370,13 +370,12 @@ fontschemeid_t Fonts_ParseScheme(const char* str)
return fontschemeid_t(0);
}
/*
fontid_t Fonts_ResolveUri(Uri const *uri)
{
DENG_UNUSED(uri);
return 0;
}
*/
fontid_t Fonts_ResolveUriCString(const char* uri)
{
Expand All @@ -389,6 +388,7 @@ void Fonts_ClearDefinitionLinks(void)
void Fonts_ClearRuntime(void)
{}
*/

/*
void R_InitViewWindow(void)
Expand Down

0 comments on commit 1c2a92c

Please sign in to comment.