[go: up one dir, main page]

Menu

[904618]: / src / ui.h  Maximize  Restore  History

Download this file

224 lines (177 with data), 6.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
// ----------------------------------------------------------------------------
// :oCCCCOCoc.
// .cCO8OOOOOOOOO8Oo:
// .oOO8OOOOOOOOOOOOOOOCc
// cO8888: .:oOOOOC. TM
// :888888: :CCCc .oOOOOC. ### ### #########
// C888888: .ooo: .C######## ##### ##### ###### ###### ##########
// O888888: .oO### ### ##### ##### ######## ######## #### ###
// C888888: :8O. .C########## ### #### ### ## ## ## ## #### ###
// :8@@@@8: :888c o### ### #### ### ######## ######## ##########
// :8@@@@C C@@@@ oo######## ### ## ### ###### ###### #########
// cO@@@@@@@@@@@@@@@@@Oc0
// :oO8@@@@@@@@@@Oo.
// .oCOOOOOCc. http://remood.org/
// ----------------------------------------------------------------------------
// Copyright (C) 2013-2013 GhostlyDeath <ghostlydeath@remood.org>
// <ghostlydeath@gmail.com>
// ----------------------------------------------------------------------------
// This program 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 3
// 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.
// ----------------------------------------------------------------------------
// DESCRIPTION: User Interface
//
// In terms of old code, replaces:
// * Console
// * Menu
// * HUD
// * Status Bar
#ifndef __UI_H__
#define __UI_H__
/* NOT IN DEDICATED SERVER */
#if !defined(__REMOOD_DEDICATED)
/***************************/
/*****************************************************************************/
/***************
*** INCLUDES ***
***************/
#include "doomtype.h"
#include "i_util.h"
/****************
*** CONSTANTS ***
****************/
/* UI_ImgRef_t -- Type of image reference */
typedef enum UI_ImgRef_e
{
UIIR_WAD, // Reference by WAD
UIIR_RAW, // Reference by Raw Data
UIIR_BOOTLOGO, // Boot Logo
} UI_ImgRef_t;
/* UI_ColorMap_t -- Color Mapping of Image */
typedef enum UI_ColorMap_e
{
UICM_NATIVE, // Native Mapping
UICM_DOOM, // Doom Colors
UICM_HERETIC, // Heretic Colors
UICM_HEXEN, // Hexen Colors
UICM_STRIFE, // Strife Colors
} UI_ColorMap_t;
/* UI_ImgType_t -- Type of image loaded */
typedef enum UI_ImgType_e
{
UIIT_PNG,
UIIT_PATCH,
UIIT_PIC,
UIIT_FLAT,
} UI_ImgType_t;
/*****************
*** STRUCTURES ***
*****************/
/* Define UI_Img_t */
#if !defined(__REMOOD_UIIMG_DEFINED)
typedef struct UI_Img_s UI_Img_t;
#define __REMOOD_UIIMG_DEFINED
#endif
/* Define WL_WADEntry_t */
#if !defined(__REMOOD_WLWADENT_DEFINED)
typedef struct WL_WADEntry_s WL_WADEntry_t;
#define __REMOOD_WLWADENT_DEFINED
#endif
/* Define WL_WADFile_t */
#if !defined(__REMOOD_WLWADFILE_DEFINED)
typedef struct WL_WADFile_s WL_WADFile_t;
#define __REMOOD_WLWADFILE_DEFINED
#endif
/* UI_Img_t -- User Interface Image */
struct UI_Img_s
{
UI_Img_t* Prev; // Previous Image
UI_Img_t* Next; // Next Image
UI_ImgType_t Type; // Image Type
UI_ImgRef_t RefType; // Type of reference
int32_t o[2]; // Offset
int32_t l[2]; // Size
int32_t p, pd; // Pitch, Pitch + Depth
uint32_t Depth; // Depth image exists for
UI_ColorMap_t Map; // Color Mapping
uint8_t* Data; // Image Data (Native)
uint8_t* Mask; // Image Mask
uint32_t GLRef; // OpenGL Reference
int32_t Count; // Reference Count
union
{
struct
{
const WL_WADFile_t* WAD; // WAD This belongs to
const WL_WADEntry_t* Entry; // Entry this belongs to
} WAD; // WAD Storage
struct
{
uint8_t* Data; // Data Reference
size_t Len; // Size of data
} Raw; // Raw data
} Ref; // Reference
};
/* UI_RGB_t -- RGB Table Entry */
typedef struct UI_RGB_s
{
uint8_t r;
uint8_t g;
uint8_t b;
} UI_RGB_t;
/* UI_BufferSpec_t -- Buffer specification */
typedef struct UI_BufferSpec_s
{
uint8_t* Data; // Buffer Data
uint32_t w, h, d, p; // Width, Height, Depth, Pitch
uint32_t pd;
} UI_BufferSpec_t;
/****************
*** FUNCTIONS ***
****************/
/*** UI_VIS.C ***/
bool_t UI_Visible(void);
bool_t UI_GrabMouse(void);
bool_t UI_ShouldFreezeGame(void);
void UI_Ticker(void);
void UI_Drawer(void); // Move to UI_DRAW.C
bool_t UI_HandleEvent(I_EventEx_t* const a_Event, const bool_t a_Early); // Move to UI_EVENT.C
/*** UI_CON.C ***/
void UI_ConBootInit(void);
void UI_ConBootClear(void);
void UI_ConPassLine(const char* const a_Line);
void UI_ConDraw(UI_BufferSpec_t* const a_Spec);
/*** UI_CTRL.C ***/
void UI_Init(void);
void UI_SetBitDepth(const uint32_t a_Depth);
/*** UI_DRAW.C ***/
void UI_DrawBGLayer(UI_BufferSpec_t* const a_Spec);
void UI_DrawFGLayer(UI_BufferSpec_t* const a_Spec);
void UI_DrawLoop(void);
/*** UI_D*.C ***/
extern void (*UI_DrawImg)(UI_BufferSpec_t* const a_Spec, UI_Img_t* const a_Img, const int32_t a_X, const int32_t a_Y);
extern void (*UI_DrawImgScale)(UI_BufferSpec_t* const a_Spec, UI_Img_t* const a_Img, const int32_t a_X, const int32_t a_Y, const fixed_t a_sW, const fixed_t a_sH);
#define UI_DrawImgFull(s,i) UI_DrawImgScale((s), (i), 0, 0, vid.fxdupx, vid.fxdupy)
/*** UI_IMG.C ***/
void UI_ImgDelete(UI_Img_t* const a_Img);
void UI_ImgClearList(void);
void UI_ImgLoadPalette(void);
UI_Img_t* UI_ImgLoadEntC(const WL_WADEntry_t* const a_Entry, const UI_ColorMap_t a_Map);
UI_Img_t* UI_ImgLoadEnt(const WL_WADEntry_t* const a_Entry);
UI_Img_t* UI_ImgLoadEntSC(const char* const a_Name, const UI_ColorMap_t a_Map);
UI_Img_t* UI_ImgLoadEntS(const char* const a_Name);
UI_Img_t* UI_ImgLoadBootLogo(const uint8_t* const a_Data, const size_t a_Len);
int32_t UI_ImgCount(UI_Img_t* const a_Img, const int32_t a_Count);
/*****************************************************************************/
/* NOT IN DEDICATED SERVER */
#endif
/***************************/
#endif /* __UI_H__ */