Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Dec 20, 2011
1 parent c3217d5 commit 9191ae3
Show file tree
Hide file tree
Showing 17 changed files with 737 additions and 759 deletions.
11 changes: 6 additions & 5 deletions doomsday/plugins/common/include/hu_lib.h
Expand Up @@ -757,8 +757,8 @@ typedef struct uiwidget_s {
/// Current font used for text child objects of this widget.
fontid_t font;

/// Current opacity value for this widget. Used during render.
float alpha;
/// Current opacity value for this widget.
float opacity;

void (*updateGeometry) (struct uiwidget_s* obj);
void (*drawer) (struct uiwidget_s* obj, const Point2Raw* origin);
Expand All @@ -771,12 +771,13 @@ typedef struct uiwidget_s {
boolean GUI_RunGameTicTrigger(timespan_t ticLength);
boolean GUI_GameTicTriggerIsSharp(void);

void GUI_DrawWidget(uiwidget_t* obj, int x, int y);
void GUI_DrawWidget(uiwidget_t* obj, const Point2Raw* origin);
void GUI_DrawWidgetXY(uiwidget_t* obj, int x, int y);

/// @return @see alignmentFlags
int UIWidget_Alignment(uiwidget_t* obj);

float UIWidget_Alpha(uiwidget_t* obj);
float UIWidget_Opacity(uiwidget_t* obj);

const RectRaw* UIWidget_Geometry(uiwidget_t* obj);

Expand All @@ -793,7 +794,7 @@ int UIWidget_Player(uiwidget_t* obj);

void UIWidget_RunTic(uiwidget_t* obj, timespan_t ticLength);

void UIWidget_SetAlpha(uiwidget_t* obj, float alpha);
void UIWidget_SetOpacity(uiwidget_t* obj, float alpha);

/**
* @param alignFlags @see alignmentFlags
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/p_player.h
Expand Up @@ -57,7 +57,7 @@ void P_FreeWeaponSlots(void);
boolean P_SetWeaponSlot(weapontype_t type, byte slot);
byte P_GetWeaponSlot(weapontype_t type);

int P_IterateWeaponsInSlot(byte slot, boolean reverse,
int P_IterateWeaponsBySlot(byte slot, boolean reverse,
int (*callback) (weapontype_t, void* context),
void* context);
// A specialized iterator for weapon slot cycling.
Expand Down
16 changes: 6 additions & 10 deletions doomsday/plugins/common/src/hu_automap.c
Expand Up @@ -192,7 +192,7 @@ void UIAutomap_ClearLists(uiwidget_t* obj)
void UIAutomap_LoadResources(void)
{
#if !__JDOOM64__
{ int i;
int i;
char patchName[9];
for(i = 0; i < 10; ++i)
{
Expand All @@ -202,7 +202,7 @@ void UIAutomap_LoadResources(void)
sprintf(patchName, "fonta%d", 16+i);
# endif
pPointMarkers[i] = R_DeclarePatch(patchName);
}}
}
#endif

if(autopageLumpNum >= 0)
Expand Down Expand Up @@ -233,12 +233,11 @@ void UIAutomap_ReleaseResources(void)

void UIAutomap_Reset(uiwidget_t* obj)
{
assert(NULL != obj && obj->type == GUI_AUTOMAP);
{
guidata_automap_t* am = (guidata_automap_t*)obj->typedata;
assert(obj->type == GUI_AUTOMAP);

UIAutomap_ClearLists(obj);
am->constructMap = true;
}
}

/**
Expand All @@ -249,14 +248,13 @@ static void rendLine2(uiwidget_t* obj, float x1, float y1, float x2, float y2,
boolean glowOnly, boolean scaleGlowWithView, boolean caps, blendmode_t blend,
boolean drawNormal, boolean addToLists)
{
assert(NULL != obj && obj->type == GUI_AUTOMAP);
{
//guidata_automap_t* am = (guidata_automap_t*)obj->typedata;
const float alpha = uiRendState->pageAlpha;
//automapcfg_t* mcfg = am->mcfg;
float a[2], b[2];
float length, dx, dy;
float normal[2], unit[2];
assert(obj->type == GUI_AUTOMAP);

// Scale into map, screen space units.
a[VX] = x1;
Expand All @@ -267,8 +265,7 @@ static void rendLine2(uiwidget_t* obj, float x1, float y1, float x2, float y2,
dx = b[VX] - a[VX];
dy = b[VY] - a[VY];
length = sqrt(dx * dx + dy * dy);
if(length <= 0)
return;
if(length <= 0) return;

unit[VX] = dx / length;
unit[VY] = dy / length;
Expand Down Expand Up @@ -586,7 +583,6 @@ static void rendLine2(uiwidget_t* obj, float x1, float y1, float x2, float y2,

#undef NORMTAIL_LENGTH
}
}
}

static int rendSeg(void* seg_, void* data)
Expand Down
68 changes: 45 additions & 23 deletions doomsday/plugins/common/src/hu_lib.c
Expand Up @@ -154,14 +154,14 @@ static uiwidget_t* allocateWidget(guiwidgettype_t type, uiwidgetid_t id, int pla
}

static uiwidget_t* createWidget(guiwidgettype_t type, int player, fontid_t fontId,
float alpha, int alignFlags, void (*updateGeometry) (uiwidget_t* obj),
float opacity, int alignFlags, void (*updateGeometry) (uiwidget_t* obj),
void (*drawer) (uiwidget_t* obj, const Point2Raw* origin),
void (*ticker) (uiwidget_t* obj, timespan_t ticLength), void* typedata)
{
uiwidget_t* obj = allocateWidget(type, nextUnusedId(), player, typedata);
assert(updateGeometry);
obj->font = fontId;
obj->alpha = alpha;
obj->opacity = opacity;
obj->alignFlags = alignFlags;
obj->updateGeometry = updateGeometry;
obj->drawer = drawer;
Expand Down Expand Up @@ -362,7 +362,7 @@ void UIGroup_UpdateGeometry(uiwidget_t* obj)
Size2Raw childSize = { 0, 0 };

if(UIWidget_MaximumWidth(child) > 0 && UIWidget_MaximumHeight(child) > 0 &&
UIWidget_Alpha(child) > 0)
UIWidget_Opacity(child) > 0)
{
child->updateGeometry(child);
child->geometry.origin.x = x;
Expand Down Expand Up @@ -424,28 +424,39 @@ void UIGroup_UpdateGeometry(uiwidget_t* obj)
}
}

static void drawWidget2(uiwidget_t* obj, int x, int y)
static void drawWidget2(uiwidget_t* obj, const Point2Raw* _origin)
{
Point2Raw origin;
assert(obj);
if(!obj->drawer || obj->alpha <= 0) return;

uiRS.pageAlpha = obj->alpha;
if(!obj->drawer || obj->opacity <= 0) return;

uiRS.pageAlpha = obj->opacity;

origin.x = obj->geometry.origin.x;
origin.y = obj->geometry.origin.y;
// An offset?
if(_origin)
{
origin.x = _origin->x;
origin.y = _origin->y;
}

origin.x = x + obj->geometry.origin.x;
origin.y = y + obj->geometry.origin.y;
obj->drawer(obj, &origin);
}

static void drawWidget(uiwidget_t* obj, int x, int y)
static void drawWidget(uiwidget_t* obj, const Point2Raw* origin)
{
assert(obj);

DGL_MatrixMode(DGL_MODELVIEW);
DGL_Translatef(x, y, 0);
if(origin)
{
DGL_MatrixMode(DGL_MODELVIEW);
DGL_Translatef(origin->x, origin->y, 0);
}

// First we draw ourself.
drawWidget2(obj, 0, 0);
drawWidget2(obj, NULL/*no origin offset*/);

if(obj->type == GUI_GROUP)
{
Expand All @@ -455,30 +466,41 @@ static void drawWidget(uiwidget_t* obj, int x, int y)
for(i = 0; i < grp->widgetIdCount; ++i)
{
uiwidget_t* child = GUI_MustFindObjectById(grp->widgetIds[i]);
drawWidget(child, 0, 0);
drawWidget(child, NULL/*no origin offset*/);
}
}

DGL_MatrixMode(DGL_MODELVIEW);
DGL_Translatef(-x, -y, 0);
if(origin)
{
DGL_MatrixMode(DGL_MODELVIEW);
DGL_Translatef(-origin->x, -origin->y, 0);
}
}

void GUI_DrawWidget(uiwidget_t* obj, int x, int y)
void GUI_DrawWidget(uiwidget_t* obj, const Point2Raw* origin)
{
if(!obj) return;
if(UIWidget_MaximumWidth(obj) < 1 || UIWidget_MaximumHeight(obj) < 1) return;
if(UIWidget_Alpha(obj) <= 0) return;
if(UIWidget_Opacity(obj) <= 0) return;

obj->updateGeometry(obj);

FR_PushAttrib();
FR_LoadDefaultAttrib();

drawWidget(obj, x, y);
drawWidget(obj, origin);

FR_PopAttrib();
}

void GUI_DrawWidgetXY(uiwidget_t* obj, int x, int y)
{
Point2Raw origin;
origin.x = x;
origin.y = y;
GUI_DrawWidget(obj, &origin);
}

void UIWidget_RunTic(uiwidget_t* obj, timespan_t ticLength)
{
assert(obj);
Expand Down Expand Up @@ -604,23 +626,23 @@ void UIWidget_SetAlignment(uiwidget_t* obj, int alignFlags)
obj->alignFlags = alignFlags;
}

float UIWidget_Alpha(uiwidget_t* obj)
float UIWidget_Opacity(uiwidget_t* obj)
{
assert(obj);
return obj->alpha;
return obj->opacity;
}

void UIWidget_SetAlpha(uiwidget_t* obj, float alpha)
void UIWidget_SetOpacity(uiwidget_t* obj, float opacity)
{
assert(obj);
obj->alpha = alpha;
obj->opacity = opacity;
if(obj->type == GUI_GROUP)
{
guidata_group_t* grp = (guidata_group_t*)obj->typedata;
int i;
for(i = 0; i < grp->widgetIdCount; ++i)
{
UIWidget_SetAlpha(GUI_MustFindObjectById(grp->widgetIds[i]), alpha);
UIWidget_SetOpacity(GUI_MustFindObjectById(grp->widgetIds[i]), opacity);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/p_player.c
Expand Up @@ -234,7 +234,7 @@ weapontype_t P_WeaponSlotCycle(weapontype_t type, boolean prev)
* @return Non-zero if no weapon is bound to the slot @a slot,
* or callback @a callback signals an end to iteration.
*/
int P_IterateWeaponsInSlot(byte slot, boolean reverse,
int P_IterateWeaponsBySlot(byte slot, boolean reverse,
int (*callback) (weapontype_t, void* context),
void* context)
{
Expand Down
9 changes: 8 additions & 1 deletion doomsday/plugins/jdoom/include/st_stuff.h
Expand Up @@ -46,7 +46,9 @@

#define ST_AUTOMAP_OBSCURE_TOLERANCE (.9999f)

/// Register the console commands, variables, etc..., of this module.
void ST_Register(void);

void ST_Init(void);
void ST_Shutdown(void);

Expand Down Expand Up @@ -131,7 +133,12 @@ boolean ST_AutomapHasReveal(int player);

void ST_RebuildAutomap(int player);

/// Call when it might be neccessary for the hud to unhide.
/**
* Unhides the current HUD display if hidden.
*
* @param player Player whoose HUD to (maybe) unhide.
* @param event Event type trigger.
*/
void ST_HUDUnHide(int player, hueevent_t event);

D_CMD(ChatOpen);
Expand Down
15 changes: 13 additions & 2 deletions doomsday/plugins/jdoom/src/d_refresh.c
Expand Up @@ -143,10 +143,21 @@ boolean R_ViewFilterColor(float rgba[4], int filter)

void R_UpdateViewFilter(int player)
{
#define RADIATIONPAL (13) // Radiation suit, green shift.
#define RADIATIONPAL (13) /// Radiation suit, green shift.

player_t* plr = players + player;
int palette = 0, cnt, bzc;
player_t* plr = &players[player];

if(player < 0 || player >= MAXPLAYERS)
{
#if _DEBUG
Con_Message("Warning:R_UpdateViewFilter: Invalid player #%i, ignoring.\n", player);
#endif
return;
}

// Not currently present?
if(!plr->plr->inGame) return;

cnt = plr->damageCount;

Expand Down

0 comments on commit 9191ae3

Please sign in to comment.