Skip to content

Commit

Permalink
Changed jDoom: Use the original STCFN* lumps (rather than the FONTA* …
Browse files Browse the repository at this point in the history
…lumps in jDOOM.pk3) for the small graphic font (desaturate and amplify at load time).

Moved all game-side font drawing routines used for both small and large fonts to hu_stuff.c
  • Loading branch information
danij committed May 12, 2009
1 parent 1a1dba3 commit 0cef181
Show file tree
Hide file tree
Showing 96 changed files with 726 additions and 697 deletions.
16 changes: 8 additions & 8 deletions doomsday/plugins/common/include/hu_lib.h
Expand Up @@ -36,8 +36,7 @@
// Text Line widget, (parent of Scrolling Text and Input Text widgets).
typedef struct {
int x, y; // Left-justified position of scrolling text window.
struct dpatch_s* f; // Font.
int sc; // Start character.
gamefontid_t font;
char l[HU_MAXLINELENGTH + 1]; // Line of text.
int len; // Current line length.
int needsupdate; // Whether this line needs to be udpated.
Expand All @@ -64,21 +63,22 @@ void HUlib_init(void);

void HUlib_clearTextLine(hu_textline_t* t);
void HUlib_initTextLine(hu_textline_t* t, int x, int y,
dpatch_t* f, int sc);
gamefontid_t font);
boolean HUlib_addCharToTextLine(hu_textline_t* t, char ch);
boolean HUlib_delCharFromTextLine(hu_textline_t* t);
void HUlib_drawTextLine(hu_textline_t* l, boolean drawcursor);
void HUlib_eraseTextLine(hu_textline_t* l);

void HUlib_initSText(hu_stext_t* s, int x, int y, int h,
dpatch_t* font, int startchar, boolean* on);
gamefontid_t font,boolean* on);

void HUlib_addLineToSText(hu_stext_t* s);
void HUlib_addMessageToSText(hu_stext_t* s, char* prefix, char* msg);
void HUlib_addMessageToSText(hu_stext_t* s, char* prefix,
char* msg);
void HUlib_drawSText(hu_stext_t* s);
void HUlib_eraseSText(hu_stext_t* s);

void HUlib_initIText(hu_itext_t* it, int x, int y, dpatch_t* font,
int startchar, boolean* on);
void HUlib_initIText(hu_itext_t* it, int x, int y,
gamefontid_t font, boolean* on);
void HUlib_delCharFromIText(hu_itext_t* it);
void HUlib_eraseLineFromIText(hu_itext_t* it);
void HUlib_resetIText(hu_itext_t* it);
Expand Down
84 changes: 57 additions & 27 deletions doomsday/plugins/common/include/hu_stuff.h
Expand Up @@ -34,6 +34,11 @@

#include "r_common.h"

typedef enum border_e {
BORDERUP = 1,
BORDERDOWN
} border_t;

enum {
ALIGN_LEFT = 0,
ALIGN_CENTER,
Expand All @@ -46,16 +51,22 @@ enum {
// Calculate # of glyphs in font.
#define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1)

typedef enum border_e {
BORDERUP = 1,
BORDERDOWN
} border_t;

// The fonts.
extern dpatch_t huFont[HU_FONTSIZE];
extern dpatch_t huFontA[HU_FONTSIZE], huFontB[HU_FONTSIZE];
extern dpatch_t huMinus;
typedef enum {
GF_FIRST = 0,
GF_FONTA = GF_FIRST,
GF_FONTB,
NUM_GAME_FONTS
} gamefontid_t;

typedef struct gamefont_s {
struct gamefont_char_s {
char lumpname[9];
dpatch_t patch;
} chars[HU_FONTSIZE];
} gamefont_t;

extern dpatch_t huMinus;
#if __JHERETIC__ || __JHEXEN__
extern dpatch_t dpSmallNumbers[10];
#endif
Expand Down Expand Up @@ -95,37 +106,56 @@ void Hu_FogEffectSetAlphaTarget(float alpha);

// Implements patch replacement.
void WI_DrawPatch(int x, int y, float r, float g, float b, float a,
const dpatch_t* patch, const char *altstring,
const dpatch_t* patch, const char* altstring,
boolean builtin, int halign);

void WI_DrawParamText(int x, int y, const char* string,
dpatch_t* defFont, float defRed, float defGreen,
float defBlue, float defAlpha, boolean defCase,
boolean defTypeIn, int halign);

gamefontid_t font, float defRed,
float defGreen, float defBlue, float defAlpha,
boolean defCase, boolean defTypeIn,
int halign);
void M_WriteText(int x, int y, const char *string);
void M_WriteText2(int x, int y, const char *string, dpatch_t *font, float red,
void M_WriteText2(int x, int y, const char *string,
gamefontid_t font, float red,
float green, float blue, float alpha);
void M_WriteText3(int x, int y, const char *string, dpatch_t *font,
float red, float green, float blue, float alpha,
boolean doTypeIn, int initialCount);

void M_WriteText3(int x, int y, const char *string,
gamefontid_t font, float red, float green,
float blue, float alpha, boolean doTypeIn,
int initialCount);
void HUlib_drawTextLine2(int x, int y, const char* string,
size_t len, gamefontid_t font,
boolean drawcursor);
void M_DrawChar(int x, int y, int ch, gamefontid_t font);
#if __JHERETIC__ || __JHEXEN__
void Hu_DrawSmallNum(int val, int numDigits, int x, int y, float alpha);
void Hu_DrawSmallNum(int val, int numDigits, int x, int y,
float alpha);
#endif
#if __JHERETIC__
void HU_DrawBNumber(signed int val, int x, int y, float red,
float green, float blue, float alpha);
void IN_DrawNumber(int val, int x, int y, int digits, float r, float g,
float b, float a);
void IN_DrawShadowChar(int x, int y, int ch, gamefontid_t font);
#endif
#if __JHEXEN__
void DrBNumber(int val, int x, int y, float red, float green, float blue,
float alpha);
#endif

int M_DrawText(int x, int y, boolean direct, char *string);
void M_DrawTitle(char *text, int y);

int M_StringWidth(const char* string, dpatch_t* font);
int M_StringHeight(const char* string, dpatch_t* font);
void M_DrawBackgroundBox(float x, float y, float w, float h, float red, float green,
float blue, float alpha, boolean background,
int M_StringWidth(const char* string, gamefontid_t font);
int M_CharWidth(int ch, gamefontid_t font);
int M_StringHeight(const char* string, gamefontid_t font);

void M_DrawBackgroundBox(float x, float y, float w, float h,
float red, float green, float blue,
float alpha, boolean background,
int border);
#if __JHERETIC__ || __JHEXEN__ || __JSTRIFE__
#if __JHERETIC__ || __JHEXEN__
void M_DrawSlider(int x, int y, int width, int slot, float alpha);
#else
void M_DrawSlider(int x, int y, int width, int height, int slot, float alpha);
void M_DrawSlider(int x, int y, int width, int height, int slot,
float alpha);
#endif

void Draw_BeginZoom(float s, float originX, float originY);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/include/m_defs.h
Expand Up @@ -66,12 +66,12 @@ typedef struct {
int flags;
int x;
int y;
void (*drawFunc) (void);
void (*drawFunc) (void);
int itemCount;
const menuitem_t* items;
int lastOn;
int prevMenu; // menutype_t
dpatch_t* font; // Font for menu items.
gamefontid_t font; // Font for menu items.
float* color;
char* background; // Background lump name for this menu (if any).
boolean backgroundIsRaw;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/am_map.c
Expand Up @@ -1928,7 +1928,7 @@ menu_t MapDef = {
13, MAPItems,
#endif
0, MENU_OPTIONS,
huFontA,
GF_FONTA,
cfg.menuColor2,
NULL, false,
LINEHEIGHT_A,
Expand Down
14 changes: 3 additions & 11 deletions doomsday/plugins/common/src/f_infine.c
Expand Up @@ -1468,11 +1468,10 @@ int FI_CharWidth(int ch, boolean fontb)
if(ch < 33)
return 4;

return fontb ? huFontB[ch - HU_FONTSTART].width :
huFontA[ch - HU_FONTSTART].width;
return M_CharWidth(ch - HU_FONTSTART, fontb? GF_FONTB : GF_FONTA);
}

int FI_GetLineWidth(char *text, boolean fontb)
int FI_GetLineWidth(char* text, boolean fontb)
{
int width = 0;

Expand All @@ -1497,18 +1496,11 @@ int FI_GetLineWidth(char *text, boolean fontb)

int FI_DrawChar(int x, int y, int ch, boolean fontb)
{
lumpnum_t lump;

ch = FI_FilterChar(ch);

if(fontb)
lump = huFontB[ch - HU_FONTSTART].lump;
else
lump = huFontA[ch - HU_FONTSTART].lump;

// Draw the character. Don't try to draw spaces.
if(ch > 32)
GL_DrawPatch_CS(x, y, lump);
M_DrawChar(x, y, ch - HU_FONTSTART, fontb? GF_FONTB : GF_FONTA);

return FI_CharWidth(ch, fontb);
}
Expand Down

0 comments on commit 0cef181

Please sign in to comment.