2010-05-25 10:56:00 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010 EDuke32 developers and contributors
|
|
|
|
|
|
|
|
This file is part of EDuke32.
|
|
|
|
|
|
|
|
EDuke32 is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2014-07-20 08:55:56 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-05-25 10:56:00 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2014-04-07 06:17:25 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include "compat.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
#include "duke3d.h"
|
|
|
|
#include "build.h"
|
|
|
|
#include "namesdyn.h"
|
2008-07-19 00:50:20 +00:00
|
|
|
#include "osdfuncs.h"
|
2010-08-02 08:13:51 +00:00
|
|
|
#include "premap.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t osdhightile = 0;
|
2014-04-12 08:45:50 +00:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
double osdscale = 2.0f;
|
|
|
|
#else
|
2014-04-07 06:17:25 +00:00
|
|
|
double osdscale = 1.0f;
|
2014-04-12 08:45:50 +00:00
|
|
|
#endif
|
2014-04-07 06:17:25 +00:00
|
|
|
|
2014-04-13 03:19:50 +00:00
|
|
|
#define OSD_SCALE(x) (int32_t)(osdscale != 1.f ? lround(osdscale*(double)(x)) : x)
|
|
|
|
#define OSD_SCALEDIV(x) (int32_t)lround((x)/osdscale)
|
2008-07-25 04:33:33 +00:00
|
|
|
|
2012-12-25 16:13:50 +00:00
|
|
|
static int32_t GAME_isspace(int32_t ch)
|
|
|
|
{
|
|
|
|
return (ch==32 || ch==9);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t GAME_getchartile(int32_t ch)
|
|
|
|
{
|
|
|
|
int32_t ac = ch-'!'+STARTALPHANUM;
|
|
|
|
if (ac < STARTALPHANUM || ac > ENDALPHANUM)
|
|
|
|
ac = -1;
|
|
|
|
return ac;
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t ac;
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifndef USE_OPENGL
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t usehightile = 0;
|
2008-09-12 02:07:44 +00:00
|
|
|
#endif
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t ht = usehightile;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-12-25 16:13:50 +00:00
|
|
|
if (GAME_isspace(ch)) return;
|
|
|
|
if ((ac = GAME_getchartile(ch)) == -1)
|
|
|
|
return;
|
2014-04-07 06:17:25 +00:00
|
|
|
|
2008-07-26 07:20:57 +00:00
|
|
|
usehightile = (osdhightile && ht);
|
2014-04-07 06:17:25 +00:00
|
|
|
rotatesprite_fs(OSD_SCALE(9*x<<16),
|
|
|
|
OSD_SCALE((y<<3)<<16),
|
|
|
|
OSD_SCALE(65536.f), 0, ac, shade, pal, 8|16);
|
2008-07-25 01:09:39 +00:00
|
|
|
usehightile = ht;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2012-12-25 16:13:50 +00:00
|
|
|
void GAME_drawosdstr(int32_t x, int32_t y, const char *ch, int32_t len, int32_t shade, int32_t pal)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t ac;
|
2012-12-25 16:13:50 +00:00
|
|
|
#ifdef USE_OPENGL
|
|
|
|
const int32_t ht = usehightile;
|
|
|
|
usehightile = (osdhightile && ht);
|
2008-09-12 02:07:44 +00:00
|
|
|
#endif
|
2008-07-25 01:09:39 +00:00
|
|
|
|
2012-12-25 16:13:50 +00:00
|
|
|
x *= 9;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-12-25 16:13:50 +00:00
|
|
|
do
|
2008-08-24 04:35:35 +00:00
|
|
|
{
|
2012-12-25 16:13:50 +00:00
|
|
|
if (!GAME_isspace(*ch))
|
|
|
|
if ((ac = GAME_getchartile(*ch)) >= 0)
|
2008-08-24 04:35:35 +00:00
|
|
|
{
|
2013-11-04 22:56:08 +00:00
|
|
|
OSD_GetShadePal(ch, &shade, &pal);
|
2014-04-07 06:17:25 +00:00
|
|
|
rotatesprite_fs(OSD_SCALE(x<<16), OSD_SCALE((y<<3)<<16),
|
|
|
|
OSD_SCALE(65536.f), 0, ac, shade, pal, 8|16);
|
2008-08-24 04:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
x += OSDCHAR_WIDTH+1;
|
|
|
|
ch++;
|
2008-08-24 06:17:09 +00:00
|
|
|
}
|
|
|
|
while (--len);
|
2008-08-24 04:35:35 +00:00
|
|
|
|
2012-12-25 16:13:50 +00:00
|
|
|
#ifdef USE_OPENGL
|
2008-07-25 01:09:39 +00:00
|
|
|
usehightile = ht;
|
2012-12-25 16:13:50 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void GAME_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t ac;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
if (type) ac = SMALLFNTCURSOR;
|
|
|
|
else ac = '_'-'!'+STARTALPHANUM;
|
|
|
|
|
2014-07-28 06:43:16 +00:00
|
|
|
if (((BGetTime()-lastkeypress) & 0x40)==0)
|
2014-04-07 06:17:25 +00:00
|
|
|
rotatesprite_fs(OSD_SCALE(9*x<<16),
|
|
|
|
OSD_SCALE(((y<<3)+(type?-1:2))<<16),
|
|
|
|
OSD_SCALE(65536.f), 0, ac, 0, 8, 8|16);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t GAME_getcolumnwidth(int32_t w)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2014-04-13 03:19:50 +00:00
|
|
|
return OSD_SCALEDIV(w/9);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 06:17:25 +00:00
|
|
|
int32_t GAME_getrowheight(int32_t h)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2014-04-13 03:19:50 +00:00
|
|
|
return OSD_SCALEDIV(h>>3);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void GAME_onshowosd(int32_t shown)
|
2008-08-04 03:48:46 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
G_UpdateScreenArea();
|
2009-11-15 09:10:50 +00:00
|
|
|
|
2012-12-25 16:13:50 +00:00
|
|
|
UNREFERENCED_PARAMETER(shown);
|
|
|
|
// XXX: it's weird to fake a keypress like this.
|
|
|
|
// if (numplayers == 1 && ((shown && !ud.pause_on) || (!shown && ud.pause_on)))
|
|
|
|
// KB_KeyDown[sc_Pause] = 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2014-04-07 06:17:25 +00:00
|
|
|
|
|
|
|
void GAME_clearbackground(int32_t numcols, int32_t numrows)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(numcols);
|
|
|
|
|
|
|
|
# ifdef USE_OPENGL
|
|
|
|
if (getrendermode() >= REND_POLYMOST && qsetmode==200)
|
|
|
|
{
|
|
|
|
bglPushAttrib(GL_FOG_BIT);
|
|
|
|
bglDisable(GL_FOG);
|
|
|
|
|
|
|
|
setpolymost2dview();
|
|
|
|
bglColor4f(0, 0, 0, 0.67f);
|
|
|
|
bglEnable(GL_BLEND);
|
|
|
|
bglRectd(0, 0, xdim, OSD_SCALE(8*numrows+8));
|
|
|
|
bglColor4f(0, 0, 0, 1);
|
|
|
|
bglRectd(0, OSD_SCALE(8*numrows+4), xdim, OSD_SCALE(8*numrows+8));
|
|
|
|
|
|
|
|
bglPopAttrib();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
|
|
|
|
CLEARLINES2D(0, min(ydim, OSD_SCALE(numrows*8+8)), editorcolors[16]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef OSD_SCALE
|