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 "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
|
|
|
|
2018-11-18 18:05:45 +00:00
|
|
|
int osdhightile = 1;
|
|
|
|
int osdshown = 0;
|
2014-09-30 04:13:14 +00:00
|
|
|
|
2014-12-27 18:36:14 +00:00
|
|
|
#ifdef EDUKE32_TOUCH_DEVICES
|
2014-10-25 03:25:35 +00:00
|
|
|
float osdscale = 2.f, osdrscale = 0.5f;
|
2014-04-12 08:45:50 +00:00
|
|
|
#else
|
2014-10-25 03:25:35 +00:00
|
|
|
float osdscale = 1.f, osdrscale = 1.f;
|
2014-04-12 08:45:50 +00:00
|
|
|
#endif
|
2014-04-07 06:17:25 +00:00
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
#define OSD_SCALE(x) (osdscale != 1.f ? Blrintf(osdscale*(float)(x)) : (x))
|
|
|
|
#define OSD_SCALEDIV(x) Blrintf((float)(x) * osdrscale)
|
2008-07-25 04:33:33 +00:00
|
|
|
|
2017-07-22 04:00:23 +00:00
|
|
|
#define OSDCHAR_WIDTH (tilesiz[STARTALPHANUM + 'A' - '!'].x)
|
|
|
|
#define OSDCHAR_HEIGHT (tilesiz[STARTALPHANUM + 'A' - '!'].y + 1)
|
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
static inline CONSTEXPR int GAME_isspace(int ch)
|
2012-12-25 16:13:50 +00:00
|
|
|
{
|
|
|
|
return (ch==32 || ch==9);
|
|
|
|
}
|
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
static inline int GAME_getchartile(int ch)
|
2012-12-25 16:13:50 +00:00
|
|
|
{
|
2018-11-18 18:06:27 +00:00
|
|
|
const int ac = ch-'!'+STARTALPHANUM;
|
2014-10-25 03:25:35 +00:00
|
|
|
return (ac < STARTALPHANUM || ac > ENDALPHANUM) ? -1 : ac;
|
2012-12-25 16:13:50 +00:00
|
|
|
}
|
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
void GAME_drawosdchar(int x, int y, char ch, int shade, int pal)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2018-11-18 18:06:27 +00:00
|
|
|
int ac;
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifndef USE_OPENGL
|
2018-11-18 18:06:27 +00:00
|
|
|
int usehightile = 0;
|
2008-09-12 02:07:44 +00:00
|
|
|
#endif
|
2018-11-18 18:06:27 +00:00
|
|
|
int 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;
|
2016-06-05 04:46:28 +00:00
|
|
|
|
2008-07-26 07:20:57 +00:00
|
|
|
usehightile = (osdhightile && ht);
|
2017-07-22 04:00:23 +00:00
|
|
|
rotatesprite_fs(OSD_SCALE((OSDCHAR_WIDTH*x)<<16),
|
|
|
|
OSD_SCALE((y*OSDCHAR_HEIGHT)<<16),
|
2014-04-07 06:17:25 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
void GAME_drawosdstr(int x, int y, const char *ch, int len, int shade, int pal)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2018-11-18 18:06:27 +00:00
|
|
|
int ac;
|
2012-12-25 16:13:50 +00:00
|
|
|
#ifdef USE_OPENGL
|
2018-11-18 18:06:27 +00:00
|
|
|
const int ht = usehightile;
|
2012-12-25 16:13:50 +00:00
|
|
|
usehightile = (osdhightile && ht);
|
2008-09-12 02:07:44 +00:00
|
|
|
#endif
|
2008-07-25 01:09:39 +00:00
|
|
|
|
2017-07-22 04:00:23 +00:00
|
|
|
x *= OSDCHAR_WIDTH;
|
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);
|
2017-07-22 04:00:23 +00:00
|
|
|
rotatesprite_fs(OSD_SCALE(x<<16), OSD_SCALE((y*OSDCHAR_HEIGHT)<<16),
|
2014-04-07 06:17:25 +00:00
|
|
|
OSD_SCALE(65536.f), 0, ac, shade, pal, 8|16);
|
2008-08-24 04:35:35 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 04:00:23 +00:00
|
|
|
x += OSDCHAR_WIDTH;
|
2008-08-24 04:35:35 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
void GAME_drawosdcursor(int x, int y, int type, int32_t lastkeypress)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2018-11-18 18:06:27 +00:00
|
|
|
int ac = (type) ? SMALLFNTCURSOR : '_' - '!' + STARTALPHANUM;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-07-28 06:43:16 +00:00
|
|
|
if (((BGetTime()-lastkeypress) & 0x40)==0)
|
2017-07-22 04:00:23 +00:00
|
|
|
rotatesprite_fs(OSD_SCALE((OSDCHAR_WIDTH*x)<<16),
|
|
|
|
OSD_SCALE(((y*OSDCHAR_HEIGHT)+(type?-1:2))<<16),
|
2014-04-07 06:17:25 +00:00
|
|
|
OSD_SCALE(65536.f), 0, ac, 0, 8, 8|16);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
int GAME_getcolumnwidth(int w)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2017-07-22 04:00:23 +00:00
|
|
|
return OSD_SCALEDIV(w/OSDCHAR_WIDTH);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
int GAME_getrowheight(int h)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2017-07-22 04:00:23 +00:00
|
|
|
return OSD_SCALEDIV(h/OSDCHAR_HEIGHT);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
void GAME_onshowosd(int 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
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
mouseLockToWindow((!shown) + 2);
|
2015-01-12 01:54:18 +00:00
|
|
|
|
2014-09-30 04:13:14 +00:00
|
|
|
osdshown = shown;
|
|
|
|
|
2012-12-25 16:13:50 +00:00
|
|
|
// 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
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
void GAME_clearbackground(int numcols, int numrows)
|
2014-04-07 06:17:25 +00:00
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(numcols);
|
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
#ifdef USE_OPENGL
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() >= REND_POLYMOST && in3dmode())
|
2014-04-07 06:17:25 +00:00
|
|
|
{
|
2018-11-18 18:06:27 +00:00
|
|
|
int const i8n8 = OSD_SCALE(OSDCHAR_HEIGHT*numrows);
|
|
|
|
|
2018-03-21 20:41:26 +00:00
|
|
|
polymost_setFogEnabled(false);
|
2018-03-22 07:13:30 +00:00
|
|
|
polymost_useColorOnly(true);
|
2014-04-07 06:17:25 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
polymostSet2dView();
|
2018-02-16 06:38:21 +00:00
|
|
|
glColor4f(0.f, 0.f, 0.f, 0.67f);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glRecti(0, 0, xdim, i8n8+OSDCHAR_HEIGHT);
|
|
|
|
glColor4f(0.f, 0.f, 0.f, 1.f);
|
|
|
|
glRecti(0, i8n8+4, xdim, i8n8+OSDCHAR_HEIGHT);
|
2018-03-22 07:13:30 +00:00
|
|
|
|
|
|
|
polymost_useColorOnly(false);
|
2018-11-18 18:06:27 +00:00
|
|
|
|
2015-02-11 05:22:48 +00:00
|
|
|
if (!nofog)
|
2018-03-21 20:41:26 +00:00
|
|
|
polymost_setFogEnabled(true);
|
2014-04-07 06:17:25 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2018-11-18 18:06:27 +00:00
|
|
|
#endif
|
2014-04-07 06:17:25 +00:00
|
|
|
|
2018-11-18 18:06:27 +00:00
|
|
|
CLEARLINES2D(0, min(ydim, OSD_SCALE(numrows * OSDCHAR_HEIGHT + OSDCHAR_HEIGHT)), editorcolors[16]);
|
2014-04-07 06:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef OSD_SCALE
|