Skip to content

Commit

Permalink
Remove unused text drawing code to reduce legacy porting woes.
Browse files Browse the repository at this point in the history
  • Loading branch information
perim committed Oct 30, 2010
1 parent 185892f commit aa15317
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 60 deletions.
5 changes: 0 additions & 5 deletions lib/framework/wzapp.cpp
Expand Up @@ -1192,11 +1192,6 @@ void iV_DrawTextRotated(const char* string, float XPos, float YPos, float rotati
pie_SetRendMode(REND_OPAQUE); // beat state machinery into submission
}

void iV_SetTextSize(float size)
{
WzMainWindow::instance()->setFontSize(size);
}

void wzFatalDialog(const char *text)
{
crashing = true;
Expand Down
21 changes: 0 additions & 21 deletions lib/ivis_common/textdraw.h
Expand Up @@ -36,10 +36,6 @@ enum iV_fonts
font_small,
};

#define PIE_TEXT_WHITE (-1)
#define PIE_TEXT_LIGHTBLUE (-2)
#define PIE_TEXT_DARKBLUE (-3)

extern void iV_TextInit(void);
extern void iV_TextShutdown(void);
extern void iV_font(const char *fontName, const char *fontFace, const char *fontFaceBold);
Expand All @@ -55,29 +51,14 @@ extern unsigned int iV_GetCharWidth(uint32_t charCode);
extern unsigned int iV_GetTextHeight(const char* string);
extern void iV_SetTextColour(PIELIGHT colour);

#define ASCII_SPACE (32)
#define ASCII_NEWLINE ('@')
#define ASCII_COLOURMODE ('#')

#define TEXT_UTF8_SPACE " "
#define TEXT_UTF8_NEWLINE "\n"

static const char text_space_utf8[] = TEXT_UTF8_SPACE;
static const char text_newline_utf8[] = TEXT_UTF8_NEWLINE;

// Valid values for "Justify" argument of iV_DrawFormattedText().

enum {
FTEXT_LEFTJUSTIFY, // Left justify.
FTEXT_CENTRE, // Centre justify.
FTEXT_RIGHTJUSTIFY, // Right justify.
};


extern int iV_DrawFormattedText(const char* String, UDWORD x, UDWORD y, UDWORD Width, UDWORD Justify);

extern void iV_SetTextSize(float size);

extern void iV_DrawTextRotated(const char* string, float x, float y, float rotation);

/** Draws text with a printf syntax to the screen.
Expand All @@ -87,8 +68,6 @@ static inline void iV_DrawText(const char* string, float x, float y)
iV_DrawTextRotated(string, x, y, 0.f);
}

extern void iV_DrawTextF(float x, float y, const char* format, ...) WZ_DECL_FORMAT(printf, 3, 4);

#ifdef __cplusplus
}
#endif //__cplusplus
Expand Down
38 changes: 4 additions & 34 deletions lib/ivis_opengl/textdraw.c
Expand Up @@ -32,6 +32,10 @@
#include "lib/ivis_common/textdraw.h"
#include "lib/ivis_common/bitimage.h"

#define ASCII_SPACE (32)
#define ASCII_NEWLINE ('@')
#define ASCII_COLOURMODE ('#')

/** Draws formatted text with word wrap, long word splitting, embedded newlines
* (uses '@' rather than '\n') and colour toggle mode ('#') which enables or
* disables font colouring.
Expand Down Expand Up @@ -180,7 +184,6 @@ int iV_DrawFormattedText(const char* String, UDWORD x, UDWORD y, UDWORD Width, U
}

// draw the text.
//iV_SetTextSize(12.f);
iV_DrawText(FString, jx, jy);

// and move down a line.
Expand All @@ -189,36 +192,3 @@ int iV_DrawFormattedText(const char* String, UDWORD x, UDWORD y, UDWORD Width, U

return jy;
}

static void iV_DrawTextRotatedFv(float x, float y, float rotation, const char* format, va_list ap)
{
va_list aq;
size_t size;
char* str;

/* Required because we're using the va_list ap twice otherwise, which
* results in undefined behaviour. See stdarg(3) for details.
*/
va_copy(aq, ap);

// Allocate a buffer large enough to hold our string on the stack
size = vsnprintf(NULL, 0, format, ap);
str = alloca(size + 1);

// Print into our newly created string buffer
vsprintf(str, format, aq);

va_end(aq);

// Draw the produced string to the screen at the given position and rotation
iV_DrawTextRotated(str, x, y, rotation);
}

void iV_DrawTextF(float x, float y, const char* format, ...)
{
va_list ap;

va_start(ap, format);
iV_DrawTextRotatedFv(x, y, 0.f, format, ap);
va_end(ap);
}

0 comments on commit aa15317

Please sign in to comment.