2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** v_text.cpp
|
|
|
|
** Draws text to a canvas. Also has a text line-breaker thingy.
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "v_text.h"
|
|
|
|
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "hu_stuff.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "m_swap.h"
|
|
|
|
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "templates.h"
|
|
|
|
|
|
|
|
//
|
2008-11-27 17:43:36 +00:00
|
|
|
// DrawChar
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
2008-11-27 17:43:36 +00:00
|
|
|
// Write a single character using the given font
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
2008-11-27 17:43:36 +00:00
|
|
|
void STACK_ARGS DCanvas::DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, ...)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-11-27 17:43:36 +00:00
|
|
|
if (font == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
2006-08-31 00:16:12 +00:00
|
|
|
if (normalcolor >= NumTextColors)
|
2006-02-24 04:48:15 +00:00
|
|
|
normalcolor = CR_UNTRANSLATED;
|
|
|
|
|
|
|
|
FTexture *pic;
|
|
|
|
int dummy;
|
|
|
|
|
2008-11-27 17:43:36 +00:00
|
|
|
if (NULL != (pic = font->GetChar (character, &dummy)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-11-27 17:43:36 +00:00
|
|
|
const FRemapTable *range = font->GetColorTranslation ((EColorRange)normalcolor);
|
2006-05-24 15:31:21 +00:00
|
|
|
va_list taglist;
|
|
|
|
va_start (taglist, character);
|
- Discovered that Shader Model 1.4 clamps my constants, so I can't use
palettes smaller than 256 entries with the shader I wrote for it. Is there
a list of gotchas like this listed some where? I'd really like to see it.
Well, when compiled with SM2.0, the PalTex shader seems to be every-so-
slightly faster on my GF7950GT than the SM1.4 version, so I guess it's a
minor win for cards that support it.
- Fixed: ST_Endoom() failed to free the bitmap it used.
- Added the DTA_ColorOverlay attribute to blend a color with the texture
being drawn. For software, this (currently) only works with black. For
hardware, it works with any color. The motiviation for this was so I could
rewrite the status bar calls that passed DIM_MAP to DTA_Translation to
draw darker icons into something that didn't require making a whole new
remap table.
- After having an "OMG! How could I have been so stupid?" moment, I have
removed the off-by-one check from D3DFB. I had thought the off-by-one error
was caused by rounding errors by the shader hardware. Not so. Rather, I
wasn't sampling what I thought I was sampling. A texture that uses palette
index 255 passes the value 1.0 to the shader. The shader needs to adjust the
range of its palette indexes, or it will end up trying to read color 256
from the palette texture when it should be reading color 255. Doh!
- The TranslationToTable() function has been added to map from translation
numbers used by actors to the tables those numbers represent. This function
performs validation for the input and returns NULL if the input value
is invalid.
- Major changes to the way translation tables work: No longer are they each a
256-byte array. Instead, the FRemapTable structure is used to represent each
one. It includes a remap array for the software renderer, a palette array
for a hardware renderer, and a native texture pointer for D3DFB. The
translationtables array itself is now an array of TArrays that point to the
real tables. The DTA_Translation attribute must also be passed a pointer
to a FRemapTable, not a byte array as previously.
- Modified DFrameBuffer::DrawRateStuff() so that it can do its thing properly
for D3DFB's 2D mode. Before, any fullscreen graphics (like help images)
covered it up.
SVN r640 (trunk)
2007-12-26 04:42:15 +00:00
|
|
|
DrawTexture (pic, x, y, DTA_Translation, range, TAG_MORE, &taglist);
|
2006-05-24 15:31:21 +00:00
|
|
|
va_end (taglist);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// DrawText
|
|
|
|
//
|
2008-11-27 17:43:36 +00:00
|
|
|
// Write a string using the given font
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
2012-02-11 00:15:03 +00:00
|
|
|
void DCanvas::DrawTextV(FFont *font, int normalcolor, int x, int y, const char *string, va_list taglist)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
INTBOOL boolval;
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
va_list tags;
|
|
|
|
uint32 tag;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-08-31 00:16:12 +00:00
|
|
|
int maxstrlen = INT_MAX;
|
2006-02-24 04:48:15 +00:00
|
|
|
int w, maxwidth;
|
2006-09-14 00:02:31 +00:00
|
|
|
const BYTE *ch;
|
2006-02-24 04:48:15 +00:00
|
|
|
int c;
|
|
|
|
int cx;
|
|
|
|
int cy;
|
|
|
|
int boldcolor;
|
- Discovered that Shader Model 1.4 clamps my constants, so I can't use
palettes smaller than 256 entries with the shader I wrote for it. Is there
a list of gotchas like this listed some where? I'd really like to see it.
Well, when compiled with SM2.0, the PalTex shader seems to be every-so-
slightly faster on my GF7950GT than the SM1.4 version, so I guess it's a
minor win for cards that support it.
- Fixed: ST_Endoom() failed to free the bitmap it used.
- Added the DTA_ColorOverlay attribute to blend a color with the texture
being drawn. For software, this (currently) only works with black. For
hardware, it works with any color. The motiviation for this was so I could
rewrite the status bar calls that passed DIM_MAP to DTA_Translation to
draw darker icons into something that didn't require making a whole new
remap table.
- After having an "OMG! How could I have been so stupid?" moment, I have
removed the off-by-one check from D3DFB. I had thought the off-by-one error
was caused by rounding errors by the shader hardware. Not so. Rather, I
wasn't sampling what I thought I was sampling. A texture that uses palette
index 255 passes the value 1.0 to the shader. The shader needs to adjust the
range of its palette indexes, or it will end up trying to read color 256
from the palette texture when it should be reading color 255. Doh!
- The TranslationToTable() function has been added to map from translation
numbers used by actors to the tables those numbers represent. This function
performs validation for the input and returns NULL if the input value
is invalid.
- Major changes to the way translation tables work: No longer are they each a
256-byte array. Instead, the FRemapTable structure is used to represent each
one. It includes a remap array for the software renderer, a palette array
for a hardware renderer, and a native texture pointer for D3DFB. The
translationtables array itself is now an array of TArrays that point to the
real tables. The DTA_Translation attribute must also be passed a pointer
to a FRemapTable, not a byte array as previously.
- Modified DFrameBuffer::DrawRateStuff() so that it can do its thing properly
for D3DFB's 2D mode. Before, any fullscreen graphics (like help images)
covered it up.
SVN r640 (trunk)
2007-12-26 04:42:15 +00:00
|
|
|
const FRemapTable *range;
|
2006-02-24 04:48:15 +00:00
|
|
|
int height;
|
2007-12-09 03:40:02 +00:00
|
|
|
int forcedwidth = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
int scalex, scaley;
|
|
|
|
int kerning;
|
|
|
|
FTexture *pic;
|
|
|
|
|
2008-11-27 17:43:36 +00:00
|
|
|
if (font == NULL || string == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
2006-08-31 00:16:12 +00:00
|
|
|
if (normalcolor >= NumTextColors)
|
2006-02-24 04:48:15 +00:00
|
|
|
normalcolor = CR_UNTRANSLATED;
|
2006-08-31 00:16:12 +00:00
|
|
|
boldcolor = normalcolor ? normalcolor - 1 : NumTextColors - 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-11-27 17:43:36 +00:00
|
|
|
range = font->GetColorTranslation ((EColorRange)normalcolor);
|
|
|
|
height = font->GetHeight () + 1;
|
|
|
|
kerning = font->GetDefaultKerning ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
ch = (const BYTE *)string;
|
2006-02-24 04:48:15 +00:00
|
|
|
cx = x;
|
|
|
|
cy = y;
|
|
|
|
|
|
|
|
// Parse the tag list to see if we need to adjust for scaling.
|
|
|
|
maxwidth = Width;
|
|
|
|
scalex = scaley = 1;
|
|
|
|
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
#ifndef NO_VA_COPY
|
|
|
|
va_copy(tags, taglist);
|
|
|
|
#else
|
|
|
|
tags = taglist;
|
|
|
|
#endif
|
2012-02-11 00:15:03 +00:00
|
|
|
tag = va_arg(tags, uint32);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
while (tag != TAG_DONE)
|
|
|
|
{
|
2006-05-24 15:31:21 +00:00
|
|
|
va_list *more_p;
|
2006-02-24 04:48:15 +00:00
|
|
|
DWORD data;
|
|
|
|
|
|
|
|
switch (tag)
|
|
|
|
{
|
|
|
|
case TAG_IGNORE:
|
|
|
|
default:
|
|
|
|
data = va_arg (tags, DWORD);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_MORE:
|
2006-05-24 15:31:21 +00:00
|
|
|
more_p = va_arg (tags, va_list*);
|
2006-02-24 04:48:15 +00:00
|
|
|
va_end (tags);
|
2009-04-08 04:47:44 +00:00
|
|
|
#ifndef NO_VA_COPY
|
2009-04-07 07:06:07 +00:00
|
|
|
va_copy (tags, *more_p);
|
2006-05-24 15:31:21 +00:00
|
|
|
#else
|
|
|
|
tags = *more_p;
|
|
|
|
#endif
|
2006-05-06 00:54:41 +00:00
|
|
|
break;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-12-09 03:40:02 +00:00
|
|
|
// We don't handle these. :(
|
2006-02-24 04:48:15 +00:00
|
|
|
case DTA_DestWidth:
|
|
|
|
case DTA_DestHeight:
|
|
|
|
case DTA_Translation:
|
2014-12-25 20:08:31 +00:00
|
|
|
assert("Bad parameter for DrawText" && false);
|
|
|
|
return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-12-25 05:55:51 +00:00
|
|
|
case DTA_CleanNoMove_1:
|
|
|
|
boolval = va_arg (tags, INTBOOL);
|
|
|
|
if (boolval)
|
|
|
|
{
|
|
|
|
scalex = CleanXfac_1;
|
|
|
|
scaley = CleanYfac_1;
|
|
|
|
maxwidth = Width - (Width % scalex);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
case DTA_CleanNoMove:
|
2006-09-14 00:02:31 +00:00
|
|
|
boolval = va_arg (tags, INTBOOL);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (boolval)
|
|
|
|
{
|
|
|
|
scalex = CleanXfac;
|
|
|
|
scaley = CleanYfac;
|
2009-12-25 05:55:51 +00:00
|
|
|
maxwidth = Width - (Width % scalex);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DTA_Clean:
|
|
|
|
case DTA_320x200:
|
2006-09-14 00:02:31 +00:00
|
|
|
boolval = va_arg (tags, INTBOOL);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (boolval)
|
|
|
|
{
|
|
|
|
scalex = scaley = 1;
|
|
|
|
maxwidth = 320;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DTA_VirtualWidth:
|
|
|
|
maxwidth = va_arg (tags, int);
|
|
|
|
scalex = scaley = 1;
|
|
|
|
break;
|
2006-08-31 00:16:12 +00:00
|
|
|
|
|
|
|
case DTA_TextLen:
|
|
|
|
maxstrlen = va_arg (tags, int);
|
|
|
|
break;
|
2007-12-09 03:40:02 +00:00
|
|
|
|
|
|
|
case DTA_CellX:
|
|
|
|
forcedwidth = va_arg (tags, int);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DTA_CellY:
|
|
|
|
height = va_arg (tags, int);
|
|
|
|
break;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
tag = va_arg (tags, uint32);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-02-11 00:15:03 +00:00
|
|
|
va_end(tags);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
height *= scaley;
|
|
|
|
|
2006-08-31 00:16:12 +00:00
|
|
|
while ((const char *)ch - string < maxstrlen)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
c = *ch++;
|
|
|
|
if (!c)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (c == TEXTCOLOR_ESCAPE)
|
|
|
|
{
|
2007-01-09 04:40:58 +00:00
|
|
|
EColorRange newcolor = V_ParseFontColor (ch, normalcolor, boldcolor);
|
|
|
|
if (newcolor != CR_UNDEFINED)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-11-27 17:43:36 +00:00
|
|
|
range = font->GetColorTranslation (newcolor);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c == '\n')
|
|
|
|
{
|
|
|
|
cx = x;
|
|
|
|
cy += height;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-11-27 17:43:36 +00:00
|
|
|
if (NULL != (pic = font->GetChar (c, &w)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
#ifndef NO_VA_COPY
|
|
|
|
va_copy(tags, taglist);
|
|
|
|
#else
|
|
|
|
tags = taglist;
|
|
|
|
#endif
|
2007-12-09 03:40:02 +00:00
|
|
|
if (forcedwidth)
|
|
|
|
{
|
|
|
|
w = forcedwidth;
|
|
|
|
DrawTexture (pic, cx, cy,
|
|
|
|
DTA_Translation, range,
|
|
|
|
DTA_DestWidth, forcedwidth,
|
|
|
|
DTA_DestHeight, height,
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
TAG_MORE, &tags);
|
2007-12-09 03:40:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawTexture (pic, cx, cy,
|
|
|
|
DTA_Translation, range,
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
TAG_MORE, &tags);
|
2007-12-09 03:40:02 +00:00
|
|
|
}
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
va_end (tags);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
cx += (w + kerning) * scalex;
|
|
|
|
}
|
2012-02-11 00:15:03 +00:00
|
|
|
va_end(taglist);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2012-02-11 00:15:03 +00:00
|
|
|
void STACK_ARGS DCanvas::DrawText (FFont *font, int normalcolor, int x, int y, const char *string, ...)
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
{
|
|
|
|
va_list tags;
|
2012-02-11 00:15:03 +00:00
|
|
|
va_start(tags, string);
|
|
|
|
DrawTextV(font, normalcolor, x, y, string, tags);
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// A synonym so that this can still be used in files that #include Windows headers
|
2012-02-11 00:15:03 +00:00
|
|
|
void STACK_ARGS DCanvas::DrawTextA (FFont *font, int normalcolor, int x, int y, const char *string, ...)
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
{
|
|
|
|
va_list tags;
|
2012-02-11 00:15:03 +00:00
|
|
|
va_start(tags, string);
|
|
|
|
DrawTextV(font, normalcolor, x, y, string, tags);
|
- Fixed compilation with FMOD 4.38+. The removal of hardware voices and EAX was a fairly
major change, so I'm making no provisions for using older FMOD DLLs when compiled with the
4.38 API. However, sound positioning is still broken like in 4.28, so you are recommended
to continue building with 4.26. Also, the Freeverb-based DSP unit is no longer present in
FMOD, so the underwater effect is currently unavailable when using 4.38 until I can figure
out how to make it work with the SFX Reverb unit instead. (And on that topic, the Freeverb
DSP was officially only for stereo outputs, so I really shouldn't have been using it in the
first place.)
- Since I would like to eventually figure out the sound positioning issues with the newer
FMODs, the following have been added:
* snd_drawoutput now labels its outputs with the speakers they represent.
* DCanvas::DrawTextA was added as an alias for DrawText, since the Windows headers #define
DrawText to a Unicode/non-Unicode variant.
* The loopsound console command was added to spawn an actor at the player's location and
have it loop a sound infinitely.
Hopefully I can figure it out. FMOD's 3D example works, so I assume the problem lies with
my code, though I don't really know where to begin looking for the problem.
SVN r3350 (trunk)
2012-02-10 00:53:50 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// Find string width using this font
|
|
|
|
//
|
|
|
|
int FFont::StringWidth (const BYTE *string) const
|
|
|
|
{
|
|
|
|
int w = 0;
|
|
|
|
int maxw = 0;
|
|
|
|
|
|
|
|
while (*string)
|
|
|
|
{
|
|
|
|
if (*string == TEXTCOLOR_ESCAPE)
|
|
|
|
{
|
2006-08-31 00:16:12 +00:00
|
|
|
++string;
|
|
|
|
if (*string == '[')
|
|
|
|
{
|
|
|
|
while (*string != '\0' && *string != ']')
|
|
|
|
{
|
|
|
|
++string;
|
|
|
|
}
|
|
|
|
}
|
2010-03-05 03:41:48 +00:00
|
|
|
if (*string != '\0')
|
2006-08-31 00:16:12 +00:00
|
|
|
{
|
2006-02-24 04:48:15 +00:00
|
|
|
++string;
|
2006-08-31 00:16:12 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (*string == '\n')
|
|
|
|
{
|
|
|
|
if (w > maxw)
|
|
|
|
maxw = w;
|
|
|
|
w = 0;
|
|
|
|
++string;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w += GetCharWidth (*string++) + GlobalKerning;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return MAX (maxw, w);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Break long lines of text into multiple lines no longer than maxwidth pixels
|
|
|
|
//
|
2006-09-19 23:25:51 +00:00
|
|
|
static void breakit (FBrokenLines *line, FFont *font, const BYTE *start, const BYTE *stop, FString &linecolor)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-08-31 00:16:12 +00:00
|
|
|
if (!linecolor.IsEmpty())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-08-31 00:16:12 +00:00
|
|
|
line->Text = TEXTCOLOR_ESCAPE;
|
|
|
|
line->Text += linecolor;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-09-19 23:25:51 +00:00
|
|
|
line->Text.AppendCStrPart ((const char *)start, stop - start);
|
|
|
|
line->Width = font->StringWidth (line->Text);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2014-05-24 19:05:00 +00:00
|
|
|
FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const BYTE *string, bool preservecolor)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-08-31 00:16:12 +00:00
|
|
|
FBrokenLines lines[128]; // Support up to 128 lines (should be plenty)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
const BYTE *space = NULL, *start = string;
|
2010-03-18 00:30:45 +00:00
|
|
|
size_t i, ii;
|
|
|
|
int c, w, nw;
|
2006-08-31 00:16:12 +00:00
|
|
|
FString lastcolor, linecolor;
|
|
|
|
bool lastWasSpace = false;
|
2006-09-19 23:25:51 +00:00
|
|
|
int kerning = font->GetDefaultKerning ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
i = w = 0;
|
|
|
|
|
2010-03-05 03:31:20 +00:00
|
|
|
while ( (c = *string++) && i < countof(lines) )
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (c == TEXTCOLOR_ESCAPE)
|
|
|
|
{
|
|
|
|
if (*string)
|
|
|
|
{
|
2006-08-31 00:16:12 +00:00
|
|
|
if (*string == '[')
|
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
const BYTE *start = string;
|
2006-08-31 00:16:12 +00:00
|
|
|
while (*string != ']' && *string != '\0')
|
|
|
|
{
|
|
|
|
string++;
|
|
|
|
}
|
|
|
|
if (*string != '\0')
|
|
|
|
{
|
|
|
|
string++;
|
|
|
|
}
|
|
|
|
lastcolor = FString((const char *)start, string - start);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastcolor = *string++;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isspace(c))
|
|
|
|
{
|
|
|
|
if (!lastWasSpace)
|
|
|
|
{
|
|
|
|
space = string - 1;
|
|
|
|
lastWasSpace = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastWasSpace = false;
|
|
|
|
}
|
|
|
|
|
2006-09-19 23:25:51 +00:00
|
|
|
nw = font->GetCharWidth (c);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if ((w > 0 && w + nw > maxwidth) || c == '\n')
|
|
|
|
{ // Time to break the line
|
|
|
|
if (!space)
|
|
|
|
space = string - 1;
|
|
|
|
|
2006-09-19 23:25:51 +00:00
|
|
|
breakit (&lines[i], font, start, space, linecolor);
|
2014-05-24 19:05:00 +00:00
|
|
|
if (c == '\n' && !preservecolor)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-19 23:25:51 +00:00
|
|
|
lastcolor = ""; // Why, oh why, did I do it like this?
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-09-19 23:25:51 +00:00
|
|
|
linecolor = lastcolor;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
i++;
|
|
|
|
w = 0;
|
|
|
|
lastWasSpace = false;
|
|
|
|
start = space;
|
|
|
|
space = NULL;
|
|
|
|
|
|
|
|
while (*start && isspace (*start) && *start != '\n')
|
|
|
|
start++;
|
|
|
|
if (*start == '\n')
|
|
|
|
start++;
|
|
|
|
else
|
|
|
|
while (*start && isspace (*start))
|
|
|
|
start++;
|
|
|
|
string = start;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w += nw + kerning;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-19 23:25:51 +00:00
|
|
|
// String here is pointing one character after the '\0'
|
2010-03-05 03:31:20 +00:00
|
|
|
if (i < countof(lines) && --string - start >= 1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
const BYTE *s = start;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
while (s < string)
|
|
|
|
{
|
2006-09-19 23:25:51 +00:00
|
|
|
// If there is any non-white space in the remainder of the string, add it.
|
|
|
|
if (!isspace (*s++))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-19 23:25:51 +00:00
|
|
|
breakit (&lines[i++], font, start, string, linecolor);
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-31 00:16:12 +00:00
|
|
|
// Make a copy of the broken lines and return them
|
|
|
|
FBrokenLines *broken = new FBrokenLines[i+1];
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-03-18 00:30:45 +00:00
|
|
|
for (ii = 0; ii < i; ++ii)
|
2006-08-31 00:16:12 +00:00
|
|
|
{
|
2010-03-18 00:30:45 +00:00
|
|
|
broken[ii] = lines[ii];
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-03-18 00:30:45 +00:00
|
|
|
broken[ii].Width = -1;
|
2006-08-31 00:16:12 +00:00
|
|
|
|
|
|
|
return broken;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-08-31 00:16:12 +00:00
|
|
|
void V_FreeBrokenLines (FBrokenLines *lines)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (lines)
|
|
|
|
{
|
|
|
|
delete[] lines;
|
|
|
|
}
|
|
|
|
}
|