Skip to content

Commit

Permalink
Merge branch 'game-ui-refactoring' into ringzero+master
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Dec 28, 2011
2 parents 3488dfe + 31b74a0 commit 7eac624
Show file tree
Hide file tree
Showing 54 changed files with 3,013 additions and 3,634 deletions.
25 changes: 17 additions & 8 deletions doomsday/engine/api/dd_fontrenderer.h
Expand Up @@ -29,6 +29,8 @@
#ifndef LIBDENG_API_FONT_RENDERER_H
#define LIBDENG_API_FONT_RENDERER_H

//#include "doomsday.h"

/**
* Font attributes are managed as a finite stack of attribute sets.
* This value defines the maximum allowed depth of the attribute stack.
Expand Down Expand Up @@ -164,14 +166,17 @@ void FR_SetCaseScale(boolean value);
* Draw a text block.
*
* @param text Block of text to be drawn.
* @param x X origin/offset at which to begin drawing.
* @param y Y origin/offset at which to begin drawing.
* @param origin Orient drawing about this offset (topleft:[0,0]).
* @param alignFlags @see alignmentFlags
* @param flags @see drawTextFlags
*/
void FR_DrawText3(const char* text, int x, int y, int alignFlags, short flags);
void FR_DrawText2(const char* text, int x, int y, int alignFlags);
void FR_DrawText(const char* text, int x, int y);
void FR_DrawText3(const char* text, const Point2Raw* origin, int alignFlags, short flags);
void FR_DrawText2(const char* text, const Point2Raw* origin, int alignFlags);
void FR_DrawText(const char* text, const Point2Raw* origin);

void FR_DrawTextXY3(const char* text, int x, int y, int alignFlags, short flags);
void FR_DrawTextXY2(const char* text, int x, int y, int alignFlags);
void FR_DrawTextXY(const char* text, int x, int y);

// Utility routines:
void FR_TextSize(Size2Raw* size, const char* text);
Expand All @@ -193,9 +198,13 @@ int FR_TextHeight(const char* text);
* @param alignFlags @see alignmentFlags
* @param flags @see drawTextFlags
*/
void FR_DrawChar3(unsigned char ch, int x, int y, int alignFlags, short flags);
void FR_DrawChar2(unsigned char ch, int x, int y, int alignFlags);
void FR_DrawChar(unsigned char ch, int x, int y);
void FR_DrawChar3(unsigned char ch, const Point2Raw* origin, int alignFlags, short flags);
void FR_DrawChar2(unsigned char ch, const Point2Raw* origin, int alignFlags);
void FR_DrawChar(unsigned char ch, const Point2Raw* origin);

void FR_DrawCharXY3(unsigned char ch, int x, int y, int alignFlags, short flags);
void FR_DrawCharXY2(unsigned char ch, int x, int y, int alignFlags);
void FR_DrawCharXY(unsigned char ch, int x, int y);

// Utility routines:
void FR_CharSize(Size2Raw* size, unsigned char ch);
Expand Down
10 changes: 9 additions & 1 deletion doomsday/engine/api/doomsday.def
@@ -1,6 +1,6 @@
; Doomsday Engine API (Routines exported from Doomsday.exe).
;
; Highest ordinal is currently: --> 695 <--
; Highest ordinal is currently: --> 701 <--
; Other free ordinals:
;
; 126 formerly DGL_DrawRawScreen
Expand Down Expand Up @@ -686,10 +686,18 @@ EXPORTS
FR_DrawText2 @524 NONAME
FR_DrawText3 @525 NONAME

FR_DrawTextXY @696 NONAME
FR_DrawTextXY2 @697 NONAME
FR_DrawTextXY3 @698 NONAME

FR_DrawChar @526 NONAME
FR_DrawChar2 @527 NONAME
FR_DrawChar3 @528 NONAME

FR_DrawCharXY @699 NONAME
FR_DrawCharXY2 @700 NONAME
FR_DrawCharXY3 @701 NONAME

FR_CharSize @529 NONAME
FR_CharWidth @530 NONAME
FR_CharHeight @531 NONAME
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/con_busy.c
Expand Up @@ -515,7 +515,7 @@ static void Con_BusyDrawIndicator(float x, float y, float radius, float pos)
FR_SetFont(busyFont);
FR_LoadDefaultAttrib();
FR_SetColorAndAlpha(1.f, 1.f, 1.f, .66f);
FR_DrawText3(busyTaskName, x+radius, y, ALIGN_LEFT, DTF_ONLY_SHADOW);
FR_DrawTextXY3(busyTaskName, x+radius, y, ALIGN_LEFT, DTF_ONLY_SHADOW);
}

glDisable(GL_TEXTURE_2D);
Expand Down Expand Up @@ -644,7 +644,7 @@ void Con_BusyDrawConsoleOutput(void)
alpha = 1 - (alpha - LINE_COUNT);

FR_SetAlpha(alpha);
FR_DrawText3(line->text, theWindow->geometry.size.width/2, y, ALIGN_TOP, DTF_ONLY_SHADOW);
FR_DrawTextXY3(line->text, theWindow->geometry.size.width/2, y, ALIGN_TOP, DTF_ONLY_SHADOW);
}

glDisable(GL_TEXTURE_2D);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/net_main.c
Expand Up @@ -753,7 +753,7 @@ void Net_DrawDemoOverlay(void)
FR_SetFont(fontFixed);
FR_LoadDefaultAttrib();
FR_SetColorAndAlpha(1, 1, 1, 1);
FR_DrawText3(buf, x, y, ALIGN_TOPRIGHT, DTF_NO_EFFECTS);
FR_DrawTextXY3(buf, x, y, ALIGN_TOPRIGHT, DTF_NO_EFFECTS);

glDisable(GL_TEXTURE_2D);

Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/portable/src/rend_console.c
Expand Up @@ -622,7 +622,7 @@ static void drawSideText(const char* text, int line, float alpha)
}

FR_SetColorAndAlpha(CcolYellow[0], CcolYellow[1], CcolYellow[2], alpha * .75f);
FR_DrawText3(text, ssw - 3, y / scale[1], ALIGN_TOPRIGHT, DTF_NO_TYPEIN|DTF_NO_GLITTER|(!consoleTextShadow?DTF_NO_SHADOW:0));
FR_DrawTextXY3(text, ssw - 3, y / scale[1], ALIGN_TOPRIGHT, DTF_NO_TYPEIN|DTF_NO_GLITTER|(!consoleTextShadow?DTF_NO_SHADOW:0));
}
}

Expand Down Expand Up @@ -761,7 +761,7 @@ static void drawConsole(float consoleAlpha)
calcAvgColor(line->flags, rgb);
FR_SetColorv(rgb);
}
FR_DrawText3(buff, XORIGIN + PADDING + xOffset, YORIGIN + y / scale[1], alignFlags, textFlags);
FR_DrawTextXY3(buff, XORIGIN + PADDING + xOffset, YORIGIN + y / scale[1], alignFlags, textFlags);
}

// Move up.
Expand Down Expand Up @@ -819,7 +819,7 @@ static void drawConsole(float consoleAlpha)
FR_SetColorAndAlpha(1, 1, 1, consoleAlpha);
}

FR_DrawText3(buff, XORIGIN + PADDING, YORIGIN + y / scale[1], ALIGN_TOPLEFT, DTF_NO_TYPEIN|DTF_NO_GLITTER|(!consoleTextShadow?DTF_NO_SHADOW:0));
FR_DrawTextXY3(buff, XORIGIN + PADDING, YORIGIN + y / scale[1], ALIGN_TOPLEFT, DTF_NO_TYPEIN|DTF_NO_GLITTER|(!consoleTextShadow?DTF_NO_SHADOW:0));
glDisable(GL_TEXTURE_2D);

// Draw the cursor in the appropriate place.
Expand Down
79 changes: 60 additions & 19 deletions doomsday/engine/portable/src/rend_font.c
Expand Up @@ -751,24 +751,45 @@ static void textFragmentDrawer(const char* fragment, int x, int y, int alignFlag
}

/// \note Member of the Doomsday public API.
void FR_DrawChar3(unsigned char ch, int x, int y, int alignFlags, short textFlags)
void FR_DrawChar3(unsigned char ch, const Point2Raw* origin, int alignFlags, short textFlags)
{
char str[2];
str[0] = ch;
str[1] = '\0';
FR_DrawText3(str, x, y, alignFlags, textFlags);
FR_DrawText3(str, origin, alignFlags, textFlags);
}

/// \note Member of the Doomsday public API.
void FR_DrawChar2(unsigned char ch, int x, int y, int alignFlags)
void FR_DrawChar2(unsigned char ch, const Point2Raw* origin, int alignFlags)
{
FR_DrawChar3(ch, x, y, alignFlags, DEFAULT_DRAWFLAGS);
FR_DrawChar3(ch, origin, alignFlags, DEFAULT_DRAWFLAGS);
}

/// \note Member of the Doomsday public API.
void FR_DrawChar(unsigned char ch, int x, int y)
void FR_DrawChar(unsigned char ch, const Point2Raw* origin)
{
FR_DrawChar2(ch, x, y, DEFAULT_ALIGNFLAGS);
FR_DrawChar2(ch, origin, DEFAULT_ALIGNFLAGS);
}

/// \note Member of the Doomsday public API.
void FR_DrawCharXY3(unsigned char ch, int x, int y, int alignFlags, short textFlags)
{
Point2Raw origin;
origin.x = x;
origin.y = y;
FR_DrawChar3(ch, &origin, alignFlags, textFlags);
}

/// \note Member of the Doomsday public API.
void FR_DrawCharXY2(unsigned char ch, int x, int y, int alignFlags)
{
FR_DrawCharXY3(ch, x, y, alignFlags, DEFAULT_DRAWFLAGS);
}

/// \note Member of the Doomsday public API.
void FR_DrawCharXY(unsigned char ch, int x, int y)
{
FR_DrawCharXY2(ch, x, y, DEFAULT_ALIGNFLAGS);
}

static void drawChar(unsigned char ch, int posX, int posY, font_t* font,
Expand Down Expand Up @@ -1159,7 +1180,7 @@ static void freeTextBuffer(void)
}

/// \note Member of the Doomsday public API.
void FR_DrawText3(const char* text, int x, int y, int alignFlags, short origTextFlags)
void FR_DrawText3(const char* text, const Point2Raw* origin, int alignFlags, short origTextFlags)
{
fontid_t origFont = FR_Font();
float cx, cy, extraScale;
Expand All @@ -1173,8 +1194,7 @@ void FR_DrawText3(const char* text, int x, int y, int alignFlags, short origText

errorIfNotInited("FR_DrawText");

if(!text || !text[0])
return;
if(!text || !text[0] || !origin) return;

origTextFlags &= ~(DTF_INTERNAL_MASK);

Expand All @@ -1185,8 +1205,8 @@ void FR_DrawText3(const char* text, int x, int y, int alignFlags, short origText
pass < ((origTextFlags & DTF_NO_GLITTER) != 0? 2 : 3); ++pass)
{
// Configure the next pass.
cx = (float) x;
cy = (float) y;
cx = (float) origin->x;
cy = (float) origin->y;
curCase = -1;
charCount = 0;
switch(pass)
Expand Down Expand Up @@ -1224,7 +1244,7 @@ void FR_DrawText3(const char* text, int x, int y, int alignFlags, short origText
{
do
{
cx = (float) x;
cx = (float) origin->x;
cy += state.lastLineHeight * (1+lastLeading);
} while(--numBreaks > 0);
}
Expand Down Expand Up @@ -1311,11 +1331,11 @@ void FR_DrawText3(const char* text, int x, int y, int alignFlags, short origText
// We'll undo the aspect ratio (otherwise the result would be skewed).
/// \fixme Do not assume the aspect ratio and therefore whether
// correction is even needed.
glTranslatef((float)x, (float)y, 0);
glTranslatef((float)origin->x, (float)origin->y, 0);
glScalef(1, 200.0f / 240.0f, 1);
glRotatef(state.angle, 0, 0, 1);
glScalef(1, 240.0f / 200.0f, 1);
glTranslatef(-(float)x, -(float)y, 0);
glTranslatef(-(float)origin->x, -(float)origin->y, 0);
}

glTranslatef(cx + state.offX + alignx, cy + state.offY + (FR_CaseScale() ? state.caseMod[curCase].offset : 0), 0);
Expand All @@ -1336,7 +1356,7 @@ void FR_DrawText3(const char* text, int x, int y, int alignFlags, short origText
if(strlen(fragment) > 0)
state.lastLineHeight = textFragmentHeight(fragment);

cx = (float) x;
cx = (float) origin->x;
cy += newlines * (float) state.lastLineHeight * (1+FR_Leading());
}

Expand All @@ -1355,15 +1375,36 @@ void FR_DrawText3(const char* text, int x, int y, int alignFlags, short origText
}

/// \note Member of the Doomsday public API.
void FR_DrawText2(const char* text, int x, int y, int alignFlags)
void FR_DrawText2(const char* text, const Point2Raw* origin, int alignFlags)
{
FR_DrawText3(text, origin, alignFlags, DEFAULT_DRAWFLAGS);
}

/// \note Member of the Doomsday public API.
void FR_DrawText(const char* text, const Point2Raw* origin)
{
FR_DrawText2(text, origin, DEFAULT_ALIGNFLAGS);
}

/// \note Member of the Doomsday public API.
void FR_DrawTextXY3(const char* text, int x, int y, int alignFlags, short flags)
{
Point2Raw origin;
origin.x = x;
origin.y = y;
FR_DrawText3(text, &origin, alignFlags, flags);
}

/// \note Member of the Doomsday public API.
void FR_DrawTextXY2(const char* text, int x, int y, int alignFlags)
{
FR_DrawText3(text, x, y, alignFlags, DEFAULT_DRAWFLAGS);
FR_DrawTextXY3(text, x, y, alignFlags, DEFAULT_DRAWFLAGS);
}

/// \note Member of the Doomsday public API.
void FR_DrawText(const char* text, int x, int y)
void FR_DrawTextXY(const char* text, int x, int y)
{
FR_DrawText2(text, x, y, DEFAULT_ALIGNFLAGS);
FR_DrawTextXY2(text, x, y, DEFAULT_ALIGNFLAGS);
}

/// \note Member of the Doomsday public API.
Expand Down
10 changes: 5 additions & 5 deletions doomsday/engine/portable/src/s_sfx.c
Expand Up @@ -1245,19 +1245,19 @@ void Sfx_DebugInfo(void)
lh = FR_TextHeight("W") - 3;
if(!sfxAvail)
{
FR_DrawText3("Sfx disabled", 0, 0, ALIGN_TOPLEFT, DTF_NO_EFFECTS);
FR_DrawTextXY3("Sfx disabled", 0, 0, ALIGN_TOPLEFT, DTF_NO_EFFECTS);
glDisable(GL_TEXTURE_2D);
return;
}

if(refMonitor)
FR_DrawText3("!", 0, 0, ALIGN_TOPLEFT, DTF_NO_EFFECTS);
FR_DrawTextXY3("!", 0, 0, ALIGN_TOPLEFT, DTF_NO_EFFECTS);

// Sample cache information.
Sfx_GetCacheInfo(&cachesize, &ccnt);
sprintf(buf, "Cached:%i (%i)", cachesize, ccnt);
FR_SetColor(1, 1, 1);
FR_DrawText3(buf, 10, 0, ALIGN_TOPLEFT, DTF_NO_EFFECTS);
FR_DrawTextXY3(buf, 10, 0, ALIGN_TOPLEFT, DTF_NO_EFFECTS);

// Print a line of info about each channel.
for(i = 0, ch = channels; i < numChannels; ++i, ch++)
Expand All @@ -1276,7 +1276,7 @@ void Sfx_DebugInfo(void)
!(ch->flags & SFXCF_NO_ATTENUATION) ? 'A' : '.',
ch->emitter ? 'E' : '.', ch->volume, ch->frequency,
ch->startTime, ch->buffer ? ch->buffer->endTime : 0);
FR_DrawText3(buf, 5, lh * (1 + i * 2), ALIGN_TOPLEFT, DTF_NO_EFFECTS);
FR_DrawTextXY3(buf, 5, lh * (1 + i * 2), ALIGN_TOPLEFT, DTF_NO_EFFECTS);

if(!ch->buffer)
continue;
Expand All @@ -1291,7 +1291,7 @@ void Sfx_DebugInfo(void)
id : "", ch->buffer->sample ? ch->buffer->sample->size : 0,
ch->buffer->bytes, ch->buffer->rate / 1000, ch->buffer->length,
ch->buffer->cursor, ch->buffer->written);
FR_DrawText3(buf, 5, lh * (2 + i * 2), ALIGN_TOPLEFT, DTF_NO_EFFECTS);
FR_DrawTextXY3(buf, 5, lh * (2 + i * 2), ALIGN_TOPLEFT, DTF_NO_EFFECTS);
}

glDisable(GL_TEXTURE_2D);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/ui2_main.c
Expand Up @@ -1363,7 +1363,7 @@ void FIData_TextDraw(fi_object_t* obj, const float offset[3])
if(t->scale[1].value * y + t->pos[1].value >= -t->scale[1].value * t->lineHeight &&
t->scale[1].value * y + t->pos[1].value < SCREENHEIGHT)
{
FR_DrawChar(ch, (t->alignFlags & ALIGN_LEFT) ? x : x - linew / 2, y);
FR_DrawCharXY(ch, (t->alignFlags & ALIGN_LEFT) ? x : x - linew / 2, y);
x += FR_CharWidth(ch);
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/ui_main.c
Expand Up @@ -2072,7 +2072,7 @@ void UI_TextOutEx2(const char* text, const Point2Raw* origin, ui_color_t* color,
alpha *= uiAlpha;
if(alpha <= 0) return;
FR_SetColorAndAlpha(color->red, color->green, color->blue, alpha);
FR_DrawText3(text, origin->x, origin->y, alignFlags, textFlags);
FR_DrawText3(text, origin, alignFlags, textFlags);
}

void UI_TextOutEx(const char* text, const Point2Raw* origin, ui_color_t* color, float alpha)
Expand Down Expand Up @@ -2119,7 +2119,7 @@ int UI_TextOutWrapEx(const char* text, const Point2Raw* origin, const Size2Raw*
// Can't print any more? (always print the 1st line)
if(t.y + linehgt > origin->y + size->height && t.y != origin->y)
return t.y;
FR_DrawText(word, t.x, t.y);
FR_DrawText(word, &t);
t.x += len;
wp = word;
// React to delimiter.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/ui_panel.c
Expand Up @@ -1067,7 +1067,7 @@ int CP_LabelText(char* label, char* text, const Point2Raw* origin_, const Size2R
FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET);
FR_SetColorAndAlpha(color->red, color->green, color->blue, .5f * alpha * UI_Alpha());

FR_DrawText(label, origin.x, origin.y);
FR_DrawText(label, &origin);

ind = FR_TextWidth(label);
origin.x += ind;
Expand Down
18 changes: 12 additions & 6 deletions doomsday/plugins/common/include/gl_drawpatch.h
Expand Up @@ -29,7 +29,7 @@
#ifndef LIBCOMMON_GRAPHICS_DRAW_PATCH_H
#define LIBCOMMON_GRAPHICS_DRAW_PATCH_H

#include "dd_types.h"
#include "doomsday.h"

/**
* @defGroup drawPatchFlags Draw Patch Flags.
Expand All @@ -42,13 +42,19 @@

/**
* @param patchId Unique identifier of the patch to be drawn.
* @param x X-offset to the draw origin.
* @param y Y-offset to the draw origin.
* @param origin Orient drawing about this offset (topleft:[0,0]).
* @param alignFlags @see alignmentFlags
* @param patchFlags @see drawPatchFlags
*/
void GL_DrawPatch3(patchid_t id, int x, int y, int alignFlags, int patchFlags);
void GL_DrawPatch2(patchid_t id, int x, int y, int alignFlags);
void GL_DrawPatch(patchid_t id, int x, int y);
void GL_DrawPatch3(patchid_t id, const Point2Raw* origin, int alignFlags, int patchFlags);
void GL_DrawPatch2(patchid_t id, const Point2Raw* origin, int alignFlags);
void GL_DrawPatch(patchid_t id, const Point2Raw* origin);

/**
* Same as @a GL_DrawPatch except origin is specified with separate xy coordinates.
*/
void GL_DrawPatchXY3(patchid_t id, int x, int y, int alignFlags, int patchFlags);
void GL_DrawPatchXY2(patchid_t id, int x, int y, int alignFlags);
void GL_DrawPatchXY(patchid_t id, int x, int y);

#endif /* LIBCOMMON_GRAPHICS_DRAW_PATCH_H */

0 comments on commit 7eac624

Please sign in to comment.