2015-05-19 21:54:34 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Shadow Warrior version 1.2
|
|
|
|
|
|
|
|
Shadow Warrior is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
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
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
|
|
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-10-09 16:09:05 +00:00
|
|
|
#include "ns.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "names2.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#include "lists.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "pal.h"
|
2020-08-05 22:18:45 +00:00
|
|
|
#include "misc.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "menus.h"
|
|
|
|
|
2019-03-21 02:24:19 +00:00
|
|
|
#include "network.h"
|
2020-08-15 18:29:13 +00:00
|
|
|
#include "v_font.h"
|
|
|
|
#include "v_draw.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Sets up the game fonts.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
void InitFonts()
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
GlyphSet fontdata;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
// Small font
|
|
|
|
for (int i = 0; i < 95; i++)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
auto tile = tileGetTexture(STARTALPHANUM + i);
|
|
|
|
if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
fontdata.Insert('!' + i, tile);
|
|
|
|
tile->SetOffsetsNotForFont();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 18:29:13 +00:00
|
|
|
SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, 4, false, false, false, &fontdata);
|
|
|
|
fontdata.Clear();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
// Tiny font
|
|
|
|
for (int i = 0; i < 95; i++)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
auto tile = tileGetTexture(2930 + i);
|
|
|
|
if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
fontdata.Insert('!' + i, tile);
|
|
|
|
tile->SetOffsetsNotForFont();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 18:29:13 +00:00
|
|
|
SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, 4, false, false, false, &fontdata);
|
|
|
|
fontdata.Clear();
|
2020-08-15 13:29:47 +00:00
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
const int FONT_LARGE_ALPHA = 3706;
|
|
|
|
const int FONT_LARGE_DIGIT = 3732;
|
2020-08-15 13:29:47 +00:00
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
// Big
|
|
|
|
for (int i = 0; i < 10; i++)
|
2020-08-15 13:29:47 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
auto tile = tileGetTexture(FONT_LARGE_DIGIT + i);
|
|
|
|
if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
|
2020-08-15 13:29:47 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
fontdata.Insert('0' + i, tile);
|
|
|
|
tile->SetOffsetsNotForFont();
|
2020-08-15 13:29:47 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-15 18:29:13 +00:00
|
|
|
for (int i = 0; i < 26; i++)
|
2020-08-15 13:29:47 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
auto tile = tileGetTexture(FONT_LARGE_ALPHA + i);
|
|
|
|
if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
|
2020-08-15 13:29:47 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
fontdata.Insert('A' + i, tile);
|
|
|
|
tile->SetOffsetsNotForFont();
|
2020-08-15 13:29:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, 10, false, false, false, &fontdata);
|
|
|
|
BigFont->SetKerning(1);
|
2020-08-15 13:29:47 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-08-15 13:29:47 +00:00
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
void MNU_DrawStringLarge(int x, int y, const char* string, int shade, int align)
|
2020-08-15 13:29:47 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
if (align > -1)
|
2020-08-15 13:29:47 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
int w = BigFont->StringWidth(string);
|
|
|
|
if (align == 0) x -= w / 2;
|
|
|
|
else x -= w;
|
2020-08-15 13:29:47 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
DrawText(twod, BigFont, CR_UNDEFINED, x, y, string, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
|
|
|
|
DTA_Color, shadeToLight(shade), TAG_DONE);
|
2020-08-15 13:29:47 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2020-08-15 13:29:47 +00:00
|
|
|
//
|
2020-08-15 18:29:13 +00:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-08-15 13:29:47 +00:00
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
void MNU_DrawString(int x, int y, const char* string, int shade, int pal, int align)
|
|
|
|
{
|
2020-08-15 13:29:47 +00:00
|
|
|
if (align > -1)
|
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
int w = SmallFont->StringWidth(string);
|
2020-08-15 13:29:47 +00:00
|
|
|
if (align == 0) x -= w / 2;
|
|
|
|
else x -= w;
|
|
|
|
}
|
2020-08-15 18:29:13 +00:00
|
|
|
DrawText(twod, SmallFont, CR_UNDEFINED, x, y, string, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
|
|
|
|
DTA_Color, shadeToLight(shade), DTA_TranslationIndex, TRANSLATION(Translation_Remap, pal), TAG_DONE);
|
2020-08-15 13:29:47 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-08-15 13:29:47 +00:00
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
void MNU_DrawSmallString(int x, int y, const char* string, int shade, int pal, int align, double alpha)
|
2020-08-15 13:29:47 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
if (align > -1)
|
2020-08-15 13:29:47 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
int w = SmallFont2->StringWidth(string);
|
|
|
|
if (align == 0) x -= w / 2;
|
|
|
|
else x -= w;
|
2020-08-15 13:29:47 +00:00
|
|
|
}
|
2020-08-15 18:29:13 +00:00
|
|
|
DrawText(twod, SmallFont2, CR_UNDEFINED, x, y, string, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
|
|
|
|
DTA_Color, shadeToLight(shade), DTA_TranslationIndex, TRANSLATION(Translation_Remap, pal), DTA_Alpha, alpha, TAG_DONE);
|
2020-08-15 13:29:47 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Notification messages. Native SW-style display should later be
|
|
|
|
// provided by the backend.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-08-15 13:29:47 +00:00
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void PutStringInfo(PLAYERp pp, const char *string)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
if (pp-Player == myconnectindex && hud_messages)
|
|
|
|
Printf(PRINT_MEDIUM|PRINT_NOTIFY, "%s\n", string); // Put it in the console too
|
2019-12-04 20:35:35 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
|
|
|
|
#if 0 // kept as a reminder to reimplement a 'native' looking display option in the backend
|
2015-05-19 21:58:29 +00:00
|
|
|
void PutStringInfoLine(PLAYERp pp, const char *string)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
short GlobInfoStringTime = TEXT_INFO_TIME;
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
short x,y;
|
|
|
|
short w,h;
|
|
|
|
|
|
|
|
if (pp-Player != myconnectindex)
|
|
|
|
return;
|
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
x = 160;
|
2015-05-19 21:54:34 +00:00
|
|
|
y = TEXT_INFO_LINE(0);
|
|
|
|
|
|
|
|
PutStringTimer(pp, x, y, string, GlobInfoStringTime);
|
|
|
|
|
|
|
|
}
|
2020-08-15 18:29:13 +00:00
|
|
|
#endif
|
2020-01-22 21:49:51 +00:00
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|