Skip to content

Commit

Permalink
Changed: Turned cvar "menu-effect" into a 3-bit field - 0x1=Use text …
Browse files Browse the repository at this point in the history
…type-in, 0x2=Use text shadow, 0x4=Use text glitter. Setting this cvar to zero now actually does disable all of the menu effects :)
  • Loading branch information
danij-deng committed May 5, 2011
1 parent c2e476d commit 7625abc
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 34 deletions.
15 changes: 15 additions & 0 deletions doomsday/plugins/common/include/m_defs.h
Expand Up @@ -442,6 +442,21 @@ typedef struct mn_rendstate_s {
} mn_rendstate_t;
extern const mn_rendstate_t* mnRendState;

/**
* @defgroup menuEffectFlags Menu Effect Flags
* @{
*/
#define DTFTOMEF_SHIFT (4) // 0x10000 to 0x1

#define MEF_TEXT_TYPEIN (DTF_NO_TYPEIN >> DTFTOMEF_SHIFT)
#define MEF_TEXT_SHADOW (DTF_NO_SHADOW >> DTFTOMEF_SHIFT)
#define MEF_TEXT_GLITTER (DTF_NO_GLITTER >> DTFTOMEF_SHIFT)

#define MEF_EVERYTHING (MEF_TEXT_TYPEIN|MEF_TEXT_SHADOW|MEF_TEXT_GLITTER)
/**@}*/

short MN_MergeMenuEffectWithDrawTextFlags(short f);

/**
* Execute a menu navigation/action command.
*/
Expand Down
15 changes: 7 additions & 8 deletions doomsday/plugins/common/src/hu_menu.c
Expand Up @@ -1190,7 +1190,7 @@ cvartemplate_t menuCVars[] = {
{ "menu-flash-b", 0, CVT_FLOAT, &cfg.menuTextFlashColor[CB], 0, 1 },
{ "menu-flash-speed", 0, CVT_INT, &cfg.menuTextFlashSpeed, 0, 50 },
{ "menu-turningskull", 0, CVT_BYTE, &cfg.menuCursorRotate, 0, 1 },
{ "menu-effect", 0, CVT_INT, &cfg.menuEffects, 0, 1 },
{ "menu-effect", 0, CVT_INT, &cfg.menuEffectFlags, 0, MEF_EVERYTHING },
{ "menu-color-r", 0, CVT_FLOAT, &cfg.menuTextColors[0][CR], 0, 1 },
{ "menu-color-g", 0, CVT_FLOAT, &cfg.menuTextColors[0][CG], 0, 1 },
{ "menu-color-b", 0, CVT_FLOAT, &cfg.menuTextColors[0][CB], 0, 1 },
Expand Down Expand Up @@ -2572,19 +2572,18 @@ int Hu_MenuFallbackResponder(event_t* ev)
return false;
}

short MN_MergeMenuEffectWithDrawTextFlags(short f)
{
return ((~(cfg.menuEffectFlags << DTFTOMEF_SHIFT) & DTF_NO_EFFECTS) | (f & ~DTF_NO_EFFECTS));
}

void M_DrawMenuText5(const char* string, int x, int y, int fontIdx, short flags,
float glitterStrength, float shadowStrength)
{
if(NULL == string || !string[0]) return;

if(cfg.menuEffects == 0)
{
flags |= DTF_NO_TYPEIN|DTF_NO_SHADOW|DTF_NO_GLITTER;
glitterStrength = 0;
shadowStrength = 0;
}

FR_SetFont(FID(fontIdx));
flags = MN_MergeMenuEffectWithDrawTextFlags(flags);
FR_DrawTextFragment7(string, x, y, flags, 0, 0, glitterStrength, shadowStrength, 0, 0);
}

Expand Down
26 changes: 12 additions & 14 deletions doomsday/plugins/common/src/hu_stuff.c
Expand Up @@ -178,9 +178,9 @@ static patchid_t m_pause; // Paused graphic.

// CODE -------------------------------------------------------------------

static __inline short translatePatchToTextDrawFlags(short in)
static short translatePatchToTextDrawFlags(short in)
{
short out = DTF_NO_EFFECTS;
short out = 0;
if(in & DPF_ALIGN_LEFT)
out |= DTF_ALIGN_LEFT;
if(in & DPF_ALIGN_RIGHT)
Expand All @@ -189,7 +189,14 @@ static __inline short translatePatchToTextDrawFlags(short in)
out |= DTF_ALIGN_BOTTOM;
if(in & DPF_ALIGN_TOP)
out |= DTF_ALIGN_TOP;
return out;
/**
* \kludge
* Correct behavior is no-merge but due to the way the state for this is
* managed it means the menu strings do not have text effects applied
* when they should. This should be addressed by redesigning the API for
* patch replacement.
*/
return MN_MergeMenuEffectWithDrawTextFlags(out);
}

/**
Expand Down Expand Up @@ -1232,27 +1239,18 @@ void WI_DrawPatch5(patchid_t patch, int x, int y, const char* altstring,

if(!info.isCustom)
{
short textFlags = translatePatchToTextDrawFlags(flags);
/**
* \kludge Remove the DTF_NO_EFFECTS flag.
* Correct behavior is off but due to the way the state for
* this is managed it means the menu strings don't typein
* and/or shadow when they should. This should be addressed
* by redesigning the API for patch replacement.
*/
if(cfg.menuEffects)
textFlags &= ~DTF_NO_EFFECTS;

// A user replacement?
if(patchString)
{
short textFlags = translatePatchToTextDrawFlags(flags);
FR_DrawText(string, x, y, FID(fontIdx), textFlags, .5f, 0, r, g, b, a, glitter, shadow, false);
return;
}

// A built-in replacement?
if(cfg.usePatchReplacement == 2 && altstring && altstring[0])
{
short textFlags = translatePatchToTextDrawFlags(flags);
FR_DrawText(altstring, x, y, FID(fontIdx), textFlags, .5f, 0, r, g, b, a, glitter, shadow, false);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom/data/conhelp.txt
Expand Up @@ -207,7 +207,7 @@ desc = Menu selection flash speed.
desc = 1=Menu skull turns at slider items.

[menu-effect]
desc = 0=Disable menu effects. 1=type-in.
desc = 3-bit bitfield. 0=Disable menu effects. 0x1= text type-in, 0x2= text shadow, 0x4= text glitter.

[menu-color-r]
desc = Menu color red component.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom/include/d_config.h
Expand Up @@ -96,7 +96,7 @@ typedef struct jdoom_config_s {
int hudFog;

float menuScale;
int menuEffects;
int menuEffectFlags;
float menuShadow;
int menuQuitSound;
byte menuSlam;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom/src/d_main.c
Expand Up @@ -181,7 +181,7 @@ void D_PreInit(void)
cfg.menuTextGlitter = .5f;
cfg.menuShadow = 0.33f;
cfg.menuQuitSound = true;
cfg.menuEffects = 1; // Do type-in effect.
cfg.menuEffectFlags = MEF_TEXT_TYPEIN|MEF_TEXT_SHADOW|MEF_TEXT_GLITTER;
cfg.menuTextFlashColor[0] = .7f;
cfg.menuTextFlashColor[1] = .9f;
cfg.menuTextFlashColor[2] = 1;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom64/data/conhelp.txt
Expand Up @@ -203,7 +203,7 @@ desc = Menu selection flash speed.
desc = 1=Menu skull turns at slider items.

[menu-effect]
desc = 0=Disable menu effects. 1=type-in.
desc = 3-bit bitfield. 0=Disable menu effects. 0x1= text type-in, 0x2= text shadow, 0x4= text glitter.

[menu-color-r]
desc = Menu color red component.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom64/include/d_config.h
Expand Up @@ -98,7 +98,7 @@ typedef struct jdoom64_config_s {
int hudFog;

float menuScale;
int menuEffects;
int menuEffectFlags;
float menuShadow;
int menuQuitSound;
byte menuSlam;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom64/src/d_main.c
Expand Up @@ -184,7 +184,7 @@ void D_PreInit(void)
cfg.menuTextGlitter = .5f;
cfg.menuShadow = 0.33f;
cfg.menuQuitSound = true;
cfg.menuEffects = 1; // Do type-in effect.
cfg.menuEffectFlags = MEF_TEXT_TYPEIN|MEF_TEXT_SHADOW|MEF_TEXT_GLITTER;
cfg.menuNoStretch = false;
cfg.menuTextFlashColor[0] = .7f;
cfg.menuTextFlashColor[1] = .9f;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/data/conhelp.txt
Expand Up @@ -213,7 +213,7 @@ desc = Menu selection flash speed.
desc = 1=Menu skull turns at slider items.

[menu-effect]
desc = 0=Disable menu effects. 1=type-in.
desc = 3-bit bitfield. 0=Disable menu effects. 0x1= text type-in, 0x2= text shadow, 0x4= text glitter.

[menu-color-r]
desc = Menu color red component.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/include/h_config.h
Expand Up @@ -97,7 +97,7 @@ typedef struct jheretic_config_s {
int hudFog;

float menuScale;
int menuEffects;
int menuEffectFlags;
float menuShadow;

byte menuSlam;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/src/h_main.c
Expand Up @@ -339,7 +339,7 @@ void H_PreInit(void)

cfg.weaponCycleSequential = true;

cfg.menuEffects = 0;
cfg.menuEffectFlags = MEF_TEXT_SHADOW;
cfg.hudFog = 5;

cfg.ringFilter = 1;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jhexen/data/conhelp.txt
Expand Up @@ -225,7 +225,7 @@ desc = Menu selection flash speed.
desc = 1=Menu skull turns at slider items.

[menu-effect]
desc = 0=Disable menu effects. 1=type-in.
desc = 3-bit bitfield. 0=Disable menu effects. 0x1= text type-in, 0x2= text shadow, 0x4= text glitter.

[menu-color-r]
desc = Menu color red component.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jhexen/include/x_config.h
Expand Up @@ -154,7 +154,7 @@ typedef struct {
int hudFog;

float menuScale;
int menuEffects;
int menuEffectFlags;
float menuShadow;

byte menuSlam;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jhexen/src/h2_main.c
Expand Up @@ -227,7 +227,7 @@ void X_PreInit(void)
cfg.menuTextColors[2][0] = defFontRGB3[0];
cfg.menuTextColors[2][1] = defFontRGB3[1];
cfg.menuTextColors[2][2] = defFontRGB3[2];
cfg.menuEffects = 0;
cfg.menuEffectFlags = MEF_TEXT_SHADOW;
cfg.menuHotkeys = true;
cfg.menuNoStretch = false;
cfg.confirmQuickGameSave = true;
Expand Down

0 comments on commit 7625abc

Please sign in to comment.