raze/source/games/sw/src/text.cpp
Christoph Oelckers fc11f537f7 - project cleanup
* moved all games into the 'games' folder.
* fixed project to include all sources and move them to the proper folders.
2021-01-10 20:31:32 +01:00

155 lines
4.9 KiB
C++

//-------------------------------------------------------------------------
/*
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
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "names2.h"
#include "panel.h"
#include "lists.h"
#include "game.h"
#include "pal.h"
#include "misc.h"
#include "menus.h"
#include "network.h"
#include "v_font.h"
#include "v_draw.h"
BEGIN_SW_NS
//==========================================================================
//
// Sets up the game fonts.
//
//==========================================================================
void InitFonts()
{
GlyphSet fontdata;
// Small font
for (int i = 0; i < 95; i++)
{
auto tile = tileGetTexture(STARTALPHANUM + i);
if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
{
fontdata.Insert('!' + i, tile);
tile->SetOffsetsNotForFont();
}
}
SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, 4, false, false, false, &fontdata);
fontdata.Clear();
// Tiny font
for (int i = 0; i < 95; i++)
{
auto tile = tileGetTexture(2930 + i);
if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
{
fontdata.Insert('!' + i, tile);
tile->SetOffsetsNotForFont();
}
}
SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, 4, false, false, false, &fontdata);
fontdata.Clear();
const int FONT_LARGE_ALPHA = 3706;
const int FONT_LARGE_DIGIT = 3732;
// Big
for (int i = 0; i < 10; i++)
{
auto tile = tileGetTexture(FONT_LARGE_DIGIT + i);
if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
{
fontdata.Insert('0' + i, tile);
tile->SetOffsetsNotForFont();
}
}
for (int i = 0; i < 26; i++)
{
auto tile = tileGetTexture(FONT_LARGE_ALPHA + i);
if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
{
fontdata.Insert('A' + i, tile);
tile->SetOffsetsNotForFont();
}
}
BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, 10, false, false, false, &fontdata);
BigFont->SetKerning(1);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void MNU_DrawString(int x, int y, const char* string, int shade, int pal, int align)
{
if (align > -1)
{
int w = SmallFont->StringWidth(string);
if (align == 0) x -= w / 2;
else x -= w;
}
DrawText(twod, SmallFont, CR_UNDEFINED, x, y, string, DTA_FullscreenScale, FSMode_Fit320x200,
DTA_Color, shadeToLight(shade), DTA_TranslationIndex, TRANSLATION(Translation_Remap, pal), TAG_DONE);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void MNU_DrawSmallString(int x, int y, const char* string, int shade, int pal, int align, double alpha)
{
if (align > -1)
{
int w = SmallFont2->StringWidth(string);
if (align == 0) x -= w / 2;
else x -= w;
}
DrawText(twod, SmallFont2, CR_UNDEFINED, x, y, string, DTA_FullscreenScale, FSMode_Fit320x200,
DTA_Color, shadeToLight(shade), DTA_TranslationIndex, TRANSLATION(Translation_Remap, pal), DTA_Alpha, alpha, TAG_DONE);
}
//---------------------------------------------------------------------------
//
// Notification messages. Native SW-style display should later be
// provided by the backend.
//
//---------------------------------------------------------------------------
void PutStringInfo(PLAYERp pp, const char *string)
{
if (pp-Player == myconnectindex)
Printf(PRINT_MEDIUM|PRINT_NOTIFY, "%s\n", string); // Put it in the console too
}
END_SW_NS