Subversion Repositories eduke32

Rev

Rev 8658 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5614 terminx 1
//-------------------------------------------------------------------------
2
/*
3
Copyright (C) 2016 EDuke32 developers and contributors
4
 
5
This file is part of EDuke32.
6
 
7
EDuke32 is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License version 2
9
as published by the Free Software Foundation.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 
15
See the GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
*/
21
//-------------------------------------------------------------------------
22
 
23
#pragma once
24
 
8650 hendricks2 25
#include "screentext.h"
6212 hendricks2 26
#include "menus.h"
27
 
5997 hendricks2 28
#ifdef __cplusplus
29
extern "C" {
30
#endif
31
 
5614 terminx 32
#define MAXUSERQUOTES 6
33
 
34
extern int32_t user_quote_time[MAXUSERQUOTES];
35
extern int32_t minitext_lowercase;
36
extern int32_t minitext_yofs;
37
 
8659 hendricks2 38
void G_InitText(void);
39
 
8650 hendricks2 40
enum {
8656 hendricks2 41
    TEXT_INTERNALSPACE   = 0x00000010,
42
    TEXT_TILESPACE       = 0x00000020,
43
    TEXT_INTERNALLINE    = 0x00000040,
44
    TEXT_TILELINE        = 0x00000080,
45
 
8658 hendricks2 46
    TEXT_UPPERCASE       = 0x00002000,
47
    TEXT_INVERTCASE      = 0x00004000,
48
    TEXT_IGNOREESCAPE    = 0x00008000,
49
    TEXT_LITERALESCAPE   = 0x00010000,
50
 
51
    TEXT_CONSTWIDTHNUMS  = 0x00040000,
5614 terminx 52
    TEXT_DIGITALNUMBER   = 0x00080000,
53
    TEXT_BIGALPHANUM     = 0x00100000,
54
    TEXT_GRAYFONT        = 0x00200000,
55
};
56
 
57
extern int32_t minitext_(int32_t x, int32_t y, const char *t, int32_t s, int32_t p, int32_t sb);
6208 hendricks2 58
extern void menutext_(int32_t x, int32_t y, int32_t s, char const *t, int32_t o, int32_t f);
6613 hendricks2 59
extern void captionmenutext(int32_t x, int32_t y, char const *t);
6247 hendricks2 60
extern vec2_t gametext_(int32_t x, int32_t y, const char *t, int32_t s, int32_t p, int32_t o, int32_t a, int32_t f);
6210 hendricks2 61
extern void gametext_simple(int32_t x, int32_t y, const char *t);
6247 hendricks2 62
#define mpgametext_x (5<<16)
63
extern vec2_t mpgametext(int32_t x, int32_t y, char const * t, int32_t s, int32_t o, int32_t a, int32_t f);
64
extern vec2_t mpgametextsize(char const * t, int32_t f);
5614 terminx 65
extern int32_t textsc(int32_t sc);
66
 
67
#define minitextshade(x, y, t, s, p, sb) minitext_(x,y,t,s,p,sb)
68
#define minitext(x, y, t, p, sb) minitext_(x,y,t,0,p,sb)
6208 hendricks2 69
#define menutext(x, y, t) menutext_((x), (y), 0, (t), 10|16, 0)
6702 hendricks2 70
#define menutext_centeralign(x, y, t) menutext_((x), (y), 0, (t), 10|16, TEXT_XCENTER|TEXT_YCENTER)
6208 hendricks2 71
#define menutext_center(y, t) menutext_(160<<16, (y)<<16, 0, (t), 10|16, TEXT_XCENTER)
6210 hendricks2 72
#define gametext(x, y, t) gametext_simple((x)<<16, (y)<<16, (t))
8650 hendricks2 73
#define gametext_widenumber(x, y, t) gametext_((x)<<16, (y)<<16, (t), 0, MF_Bluefont.pal, 1024, 0, TEXT_CONSTWIDTHNUMS)
74
#define gametext_number(x, y, t) gametext_((x)<<16, (y)<<16, (t), 0, MF_Bluefont.pal, 0, 0, TEXT_CONSTWIDTHNUMS)
6247 hendricks2 75
#define gametext_pal(x, y, t, p) gametext_((x)<<16, (y)<<16, (t), 0, (p), 0, 0, 0)
6613 hendricks2 76
#define gametext_center(y, t) gametext_(160<<16, (y)<<16, (t), 0, MF_Bluefont.pal, 0, 0, TEXT_XCENTER)
8650 hendricks2 77
#define gametext_center_number(y, t) gametext_(160<<16, (y)<<16, (t), 0, MF_Bluefont.pal, 0, 0, TEXT_XCENTER|TEXT_CONSTWIDTHNUMS)
6613 hendricks2 78
#define gametext_center_shade(y, t, s) gametext_(160<<16, (y)<<16, (t), (s), MF_Bluefont.pal, 0, 0, TEXT_XCENTER)
6247 hendricks2 79
#define gametext_center_shade_pal(y, t, s, p) gametext_(160<<16, (y)<<16, (t), (s), (p), 0, 0, TEXT_XCENTER)
5614 terminx 80
 
6210 hendricks2 81
extern void G_PrintGameText(int32_t tile, int32_t x, int32_t y, const char *t,
82
                            int32_t s, int32_t p, int32_t o,
83
                            int32_t x1, int32_t y1, int32_t x2, int32_t y2,
84
                            int32_t z, int32_t a);
5614 terminx 85
 
8658 hendricks2 86
extern int32_t G_GetStringTile(int32_t font, char c, int32_t f);
8656 hendricks2 87
extern void G_SetScreenTextEmpty(vec2_t & empty, int32_t font, int32_t f);
5997 hendricks2 88
 
8658 hendricks2 89
uint32_t G_ScreenTextFromString(ScreenTextGlyph_t * text, char const * str, char const * const end, int32_t font, int32_t flags);
90
 
91
static inline int32_t PopulateConstWidth(int32_t font, int32_t flags)
92
{
93
    char numeral = '0'; // this is subject to change as an implementation detail
94
    uint16_t const tile = G_GetStringTile(font, numeral, flags);
95
    Bassert(tile < MAXTILES);
96
    return (tilesiz[tile].x - 1) << 16;
97
}
98
 
8654 hendricks2 99
static inline vec2_t G_ScreenTextSize(const int32_t font,
100
    int32_t x, int32_t y, const int32_t zoom, const int32_t blockangle,
101
    const char * const str, const int32_t o,
102
    int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween,
103
    const int32_t f, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
104
{
8658 hendricks2 105
    ScreenTextSize_t data{};
8654 hendricks2 106
 
8658 hendricks2 107
    data.constwidth = PopulateConstWidth(font, f);
108
 
109
    size_t const strbuflen = strlen(str);
110
    size_t const textbufcount = ((f & TEXT_CONSTWIDTHNUMS) ? strbuflen << 1 : strbuflen) + 1;
111
    auto text = (ScreenTextGlyph_t *)Balloca(sizeof(ScreenTextGlyph_t) * textbufcount);
112
    uint32_t const textlen = G_ScreenTextFromString(text, str, str + strbuflen, font, f);
113
    data.text = text;
114
    data.len = textlen;
115
 
8654 hendricks2 116
    data.pos = {x, y};
117
    data.empty = {xspace, yline};
118
    data.between = {xbetween, ybetween};
119
    data.b1 = {x1, y1};
120
    data.b2 = {x2, y2};
121
    data.zoom = zoom;
122
    data.o = o;
123
    data.f = f;
124
    data.font = font;
125
    data.blockangle = blockangle;
126
 
127
    return screentextGetSize(data);
128
}
129
 
130
static inline vec2_t G_ScreenText(const int32_t font,
131
    int32_t x, int32_t y, const int32_t zoom, const int32_t blockangle, const int32_t charangle,
132
    const char * const str, const int32_t shade, uint32_t pal, int32_t o, int32_t alpha,
133
    int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween, const int32_t f,
134
    const int32_t x1, const int32_t y1, const int32_t x2, const int32_t y2)
135
{
136
    ScreenText_t data{};
137
 
8658 hendricks2 138
    data.constwidth = PopulateConstWidth(font, f);
139
 
140
    size_t const strbuflen = strlen(str);
141
    size_t const textbufcount = ((f & TEXT_CONSTWIDTHNUMS) ? strbuflen << 1 : strbuflen) + 1;
142
    auto text = (ScreenTextGlyph_t *)Balloca(sizeof(ScreenTextGlyph_t) * textbufcount);
143
    uint32_t const textlen = G_ScreenTextFromString(text, str, str + strbuflen, font, f);
144
    data.text = text;
145
    data.len = textlen;
146
 
8654 hendricks2 147
    data.pos = {x, y};
148
    data.empty = {xspace, yline};
149
    data.between = {xbetween, ybetween};
150
    data.b1 = {x1, y1};
151
    data.b2 = {x2, y2};
152
    data.zoom = zoom;
153
    data.o = o;
154
    data.f = f;
155
    data.font = font;
156
    data.blockangle = blockangle;
157
    data.alpha = alpha;
158
    data.charangle = charangle;
159
    data.shade = shade;
160
    data.pal = pal;
161
 
162
    return screentextRender(data);
163
}
164
 
165
static inline vec2_t G_ScreenTextShadow(int32_t sx, int32_t sy, int32_t sp, const int32_t font,
166
    int32_t x, int32_t y, const int32_t zoom, const int32_t blockangle, const int32_t charangle,
167
    const char * const str, const int32_t shade, uint32_t pal, int32_t o, const int32_t alpha,
168
    int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween, const int32_t f,
169
    const int32_t x1, const int32_t y1, const int32_t x2, const int32_t y2)
170
{
171
    ScreenText_t data{};
172
 
8658 hendricks2 173
    Bassert(!(f & TEXT_CONSTWIDTHNUMS));
174
 
175
    size_t const strbuflen = strlen(str);
176
    size_t const textbufcount = strbuflen + 1;
177
    auto text = (ScreenTextGlyph_t *)Balloca(sizeof(ScreenTextGlyph_t) * textbufcount);
178
    uint32_t const textlen = G_ScreenTextFromString(text, str, str + strbuflen, font, f);
179
    data.text = text;
180
    data.len = textlen;
181
 
8654 hendricks2 182
    data.pos = {x, y};
183
    data.empty = {xspace, yline};
184
    data.between = {xbetween, ybetween};
185
    data.b1 = {x1, y1};
186
    data.b2 = {x2, y2};
187
    data.zoom = zoom;
188
    data.o = o;
189
    data.f = f;
190
    data.font = font;
191
    data.blockangle = blockangle;
192
    data.alpha = alpha;
193
    data.charangle = charangle;
194
    data.shade = shade;
195
    data.pal = pal;
196
 
197
    return screentextRenderShadow(data, {sx, sy}, sp);
198
}
199
 
5997 hendricks2 200
#ifdef __cplusplus
201
}
202
#endif