Quake II RTX doxygen  1.0 dev
playerconfig.c File Reference
#include "ui.h"

Go to the source code of this file.

Classes

struct  m_player_s
 

Macros

#define ID_MODEL   103
 
#define ID_SKIN   104
 

Typedefs

typedef struct m_player_s m_player_t
 

Functions

static void ReloadMedia (void)
 
static void RunFrame (void)
 
static void Draw (menuFrameWork_t *self)
 
static void Size (menuFrameWork_t *self)
 
static menuSound_t Change (menuCommon_t *self)
 
static void Pop (menuFrameWork_t *self)
 
static qboolean Push (menuFrameWork_t *self)
 
static void Free (menuFrameWork_t *self)
 
void M_Menu_PlayerConfig (void)
 

Variables

static m_player_t m_player
 
cvar_t * vid_rtx
 
static const char * handedness []
 
static const char * viewmodes []
 
static dlight_t dlights []
 

Macro Definition Documentation

◆ ID_MODEL

#define ID_MODEL   103

Definition at line 30 of file playerconfig.c.

◆ ID_SKIN

#define ID_SKIN   104

Definition at line 31 of file playerconfig.c.

Typedef Documentation

◆ m_player_t

typedef struct m_player_s m_player_t

Function Documentation

◆ Change()

static menuSound_t Change ( menuCommon_t self)
static

Definition at line 206 of file playerconfig.c.

207 {
208  switch (self->id) {
209  case ID_MODEL:
212  m_player.skin.curvalue = 0;
214  // fall through
215  case ID_SKIN:
216  ReloadMedia();
217  break;
218  default:
219  break;
220  }
221  return QMS_MOVE;
222 }

Referenced by M_Menu_PlayerConfig().

◆ Draw()

static void Draw ( menuFrameWork_t self)
static

Definition at line 125 of file playerconfig.c.

126 {
127  float backlerp;
128  int i;
129 
130  m_player.refdef.time = uis.realtime * 0.001f;
131 
132  RunFrame();
133 
134  if (m_player.time == m_player.oldTime) {
135  backlerp = 0;
136  } else {
137  backlerp = 1 - (float)(uis.realtime - m_player.oldTime) /
138  (float)(m_player.time - m_player.oldTime);
139  }
140 
141  for (i = 0; i < m_player.refdef.num_entities; i++) {
142  m_player.entities[i].backlerp = backlerp;
143  }
144 
145  Menu_Draw(self);
146 
148 
150 }

Referenced by M_Menu_PlayerConfig().

◆ Free()

static void Free ( menuFrameWork_t self)
static

Definition at line 317 of file playerconfig.c.

318 {
319  memset(&m_player, 0, sizeof(m_player));
320 }

Referenced by M_Menu_PlayerConfig().

◆ M_Menu_PlayerConfig()

void M_Menu_PlayerConfig ( void  )

Definition at line 322 of file playerconfig.c.

323 {
324  static const vec3_t origin = { 40.0f, 0.0f, 0.0f };
325  static const vec3_t angles = { 0.0f, 260.0f, 0.0f };
326 
327  m_player.menu.name = "players";
329  m_player.menu.pop = Pop;
334 
335  if (vid_rtx->integer)
336  {
337  // Q2RTX: make the player menu transparent so that we can see
338  // the model below: all 2D stuff is rendered after 3D, in stretch_pics.
339  m_player.menu.color.u32 = 0;
340  }
341  else
342  {
343  m_player.menu.color.u32 = MakeColor(0, 0, 0, 255);
344  }
345 
347 
348  m_player.entities[0].flags = RF_FULLBRIGHT;
349  m_player.entities[0].id = 1; // Q2RTX: add entity id to fix motion vectors
350  VectorCopy(angles, m_player.entities[0].angles);
351  VectorCopy(origin, m_player.entities[0].origin);
352  VectorCopy(origin, m_player.entities[0].oldorigin);
353 
354  m_player.entities[1].flags = RF_FULLBRIGHT;
355  m_player.entities[1].id = 2; // Q2RTX: add entity id to fix motion vectors
356  VectorCopy(angles, m_player.entities[1].angles);
357  VectorCopy(origin, m_player.entities[1].origin);
358  VectorCopy(origin, m_player.entities[1].oldorigin);
359 
360  m_player.refdef.num_entities = 0;
361  m_player.refdef.entities = m_player.entities;
362  m_player.refdef.rdflags = RDF_NOWORLDMODEL;
363 
364  if (vid_rtx->integer)
365  {
366  m_player.refdef.num_dlights = sizeof(dlights) / sizeof(*dlights);
367  m_player.refdef.dlights = dlights;
368  }
369  else
370  {
371  m_player.refdef.num_dlights = 0;
372  }
373 
376  m_player.name.generic.name = "name";
377  m_player.name.width = MAX_CLIENT_NAME - 1;
378 
381  m_player.model.generic.name = "model";
383 
386  m_player.skin.generic.name = "skin";
388 
390  m_player.hand.generic.name = "handedness";
391  m_player.hand.itemnames = (char **)handedness;
392 
394  m_player.view.generic.name = "view";
395  m_player.view.itemnames = (char **)viewmodes;
396 
402 
403  List_Append(&ui_menus, &m_player.menu.entry);
404 }

Referenced by UI_Init().

◆ Pop()

static void Pop ( menuFrameWork_t self)
static

Definition at line 224 of file playerconfig.c.

225 {
226  char scratch[MAX_OSPATH];
227 
228  Cvar_SetEx("name", m_player.name.field.text, FROM_CONSOLE);
229 
230  Q_concat(scratch, sizeof(scratch),
233 
234  Cvar_SetEx("skin", scratch, FROM_CONSOLE);
235 
236  Cvar_SetEx("hand", va("%d", m_player.hand.curvalue), FROM_CONSOLE);
237 
238  Cvar_SetEx("cl_player_model", va("%d", m_player.view.curvalue), FROM_CONSOLE);
239 }

Referenced by M_Menu_PlayerConfig().

◆ Push()

static qboolean Push ( menuFrameWork_t self)
static

Definition at line 241 of file playerconfig.c.

242 {
243  char currentdirectory[MAX_QPATH];
244  char currentskin[MAX_QPATH];
245  int i, j;
246  int currentdirectoryindex = 0;
247  int currentskinindex = 0;
248  char *p;
249 
250  // find and register all player models
251  if (!uis.numPlayerModels) {
253  if (!uis.numPlayerModels) {
254  Com_Printf("No player models found.\n");
255  return qfalse;
256  }
257  }
258 
259  Cvar_VariableStringBuffer("skin", currentdirectory, sizeof(currentdirectory));
260 
261  if ((p = strchr(currentdirectory, '/')) || (p = strchr(currentdirectory, '\\'))) {
262  *p++ = 0;
263  Q_strlcpy(currentskin, p, sizeof(currentskin));
264  } else {
265  strcpy(currentdirectory, "male");
266  strcpy(currentskin, "grunt");
267  }
268 
269  for (i = 0; i < uis.numPlayerModels; i++) {
270  m_player.pmnames[i] = uis.pmi[i].directory;
271  if (Q_stricmp(uis.pmi[i].directory, currentdirectory) == 0) {
272  currentdirectoryindex = i;
273 
274  for (j = 0; j < uis.pmi[i].nskins; j++) {
275  if (Q_stricmp(uis.pmi[i].skindisplaynames[j], currentskin) == 0) {
276  currentskinindex = j;
277  break;
278  }
279  }
280  }
281  }
282 
285 
286  m_player.model.curvalue = currentdirectoryindex;
288 
289  m_player.skin.curvalue = currentskinindex;
290  m_player.skin.itemnames = uis.pmi[currentdirectoryindex].skindisplaynames;
291 
293  clamp(m_player.hand.curvalue, 0, 2);
294 
295  m_player.view.curvalue = Cvar_VariableInteger("cl_player_model");
296  clamp(m_player.view.curvalue, 0, 3);
297 
298  m_player.menu.banner = R_RegisterPic("m_banner_plauer_setup");
299  if (m_player.menu.banner) {
302  m_player.menu.title = NULL;
303  } else {
304  m_player.menu.title = "Player Setup";
305  }
306 
307  ReloadMedia();
308 
309  // set up oldframe correctly
310  m_player.time = uis.realtime - 120;
312  RunFrame();
313 
314  return qtrue;
315 }

Referenced by M_Menu_PlayerConfig().

◆ ReloadMedia()

static void ReloadMedia ( void  )
static

Definition at line 74 of file playerconfig.c.

75 {
76  char scratch[MAX_QPATH];
77  char *model = uis.pmi[m_player.model.curvalue].directory;
79 
80  m_player.refdef.num_entities = 0;
81 
82  Q_concat(scratch, sizeof(scratch), "players/", model, "/tris.md2", NULL);
83  m_player.entities[0].model = R_RegisterModel(scratch);
84  if (!m_player.entities[0].model)
85  return;
86 
87  m_player.refdef.num_entities++;
88 
89  Q_concat(scratch, sizeof(scratch), "players/", model, "/", skin, ".pcx", NULL);
90  m_player.entities[0].skin = R_RegisterSkin(scratch);
91 
92  if (!uis.weaponModel[0])
93  return;
94 
95  Q_concat(scratch, sizeof(scratch), "players/", model, "/", uis.weaponModel, NULL);
96  m_player.entities[1].model = R_RegisterModel(scratch);
97  if (!m_player.entities[1].model)
98  return;
99 
100  m_player.refdef.num_entities++;
101 }

Referenced by Change(), and Push().

◆ RunFrame()

static void RunFrame ( void  )
static

Definition at line 103 of file playerconfig.c.

104 {
105  int frame;
106  int i;
107 
108  if (m_player.time < uis.realtime) {
110 
111  m_player.time += 120;
112  if (m_player.time < uis.realtime) {
114  }
115 
116  frame = (m_player.time / 120) % 40;
117 
118  for (i = 0; i < m_player.refdef.num_entities; i++) {
119  m_player.entities[i].oldframe = m_player.entities[i].frame;
120  m_player.entities[i].frame = frame;
121  }
122  }
123 }

Referenced by Draw(), and Push().

◆ Size()

static void Size ( menuFrameWork_t self)
static

Definition at line 152 of file playerconfig.c.

153 {
154  int w = uis.width / uis.scale;
155  int h = uis.height / uis.scale;
156  int x = uis.width / 2;
157  int y = uis.height / 2 - MENU_SPACING * 5 / 2;
158 
159  m_player.refdef.x = w / 2;
160  m_player.refdef.y = h / 10;
161  m_player.refdef.width = w / 2;
162  m_player.refdef.height = h - h / 5;
163 
164  m_player.refdef.fov_x = 90;
165  m_player.refdef.fov_y = V_CalcFov(m_player.refdef.fov_x,
166  m_player.refdef.width, m_player.refdef.height);
167 
168  if (uis.width < 800 && uis.width >= 640) {
169  x -= CHAR_WIDTH * 10;
170  }
171 
172  if (m_player.menu.banner) {
174  m_player.menu.banner_rc.x = x - m_player.menu.banner_rc.width / 2;
175  m_player.menu.banner_rc.y = y - h / 2;
176  y += h / 2;
177  }
178 
179  if (uis.width < 640) {
180  x -= CHAR_WIDTH * 10;
181  m_player.hand.generic.name = "hand";
182  } else {
183  m_player.hand.generic.name = "handedness";
184  }
185 
186  m_player.name.generic.x = x;
187  m_player.name.generic.y = y;
188  y += MENU_SPACING * 2;
189 
190  m_player.model.generic.x = x;
191  m_player.model.generic.y = y;
192  y += MENU_SPACING;
193 
194  m_player.skin.generic.x = x;
195  m_player.skin.generic.y = y;
196  y += MENU_SPACING;
197 
198  m_player.hand.generic.x = x;
199  m_player.hand.generic.y = y;
200  y += MENU_SPACING;
201 
202  m_player.view.generic.x = x;
203  m_player.view.generic.y = y;
204 }

Referenced by M_Menu_PlayerConfig().

Variable Documentation

◆ dlights

dlight_t dlights[]
static
Initial value:
= {
{.origin = { -120.f, -80.f, 80.f },.color = {1.f, 1.f, 1.f},.intensity = 200.f,.radius = 20.f },
{.origin = { 100.f, 80.f, 20.f },.color = {0.5f, 0.5f, 1.f},.intensity = 200.f,.radius = 20.f }
}

Definition at line 69 of file playerconfig.c.

Referenced by M_Menu_PlayerConfig().

◆ handedness

const char* handedness[]
static
Initial value:
= {
"right",
"left",
"center",
0
}

Definition at line 54 of file playerconfig.c.

Referenced by M_Menu_PlayerConfig().

◆ m_player

m_player_t m_player
static

Definition at line 50 of file playerconfig.c.

Referenced by Change(), Draw(), Free(), M_Menu_PlayerConfig(), Pop(), Push(), ReloadMedia(), RunFrame(), and Size().

◆ vid_rtx

cvar_t* vid_rtx

Definition at line 30 of file refresh.c.

Referenced by M_Menu_PlayerConfig().

◆ viewmodes

const char* viewmodes[]
static
Initial value:
= {
"nothing",
"just the gun",
"first person model",
"third person",
0
}

Definition at line 61 of file playerconfig.c.

Referenced by M_Menu_PlayerConfig().

vid_rtx
cvar_t * vid_rtx
Definition: refresh.c:30
menuFrameWork_s::title
char * title
Definition: ui.h:101
viewmodes
static const char * viewmodes[]
Definition: playerconfig.c:61
ReloadMedia
static void ReloadMedia(void)
Definition: playerconfig.c:74
uiStatic_s::transparent
qboolean transparent
Definition: ui.h:301
menuCommon_s::change
menuSound_t(* change)(struct menuCommon_s *)
Definition: ui.h:158
menuCommon_s::type
menuType_t type
Definition: ui.h:141
menuFrameWork_s::name
char * name
Definition: ui.h:101
menuFrameWork_s::size
void(* size)(struct menuFrameWork_s *)
Definition: ui.h:135
Free
static void Free(menuFrameWork_t *self)
Definition: playerconfig.c:317
menuFrameWork_s::free
void(* free)(struct menuFrameWork_s *)
Definition: ui.h:136
menuFrameWork_s::push
qboolean(* push)(struct menuFrameWork_s *)
Definition: ui.h:131
uiStatic_s::height
int height
Definition: ui.h:292
m_player_s::name
menuField_t name
Definition: playerconfig.c:35
menuField_s::generic
menuCommon_t generic
Definition: ui.h:164
menuCommon_s::id
int id
Definition: ui.h:142
menuFrameWork_s::image
qhandle_t image
Definition: ui.h:110
backlerp
static float backlerp
Definition: mesh.c:26
menuFrameWork_s::banner
qhandle_t banner
Definition: ui.h:117
RunFrame
static void RunFrame(void)
Definition: playerconfig.c:103
GENERIC_SPACING
#define GENERIC_SPACING(x)
Definition: ui.h:79
MTYPE_SPINCONTROL
@ MTYPE_SPINCONTROL
Definition: ui.h:44
m_player_s::time
int time
Definition: playerconfig.c:44
Draw
static void Draw(menuFrameWork_t *self)
Definition: playerconfig.c:125
m_player
static m_player_t m_player
Definition: playerconfig.c:50
dlights
static dlight_t dlights[]
Definition: playerconfig.c:69
QMS_MOVE
@ QMS_MOVE
Definition: ui.h:71
uis
uiStatic_t uis
Definition: ui.c:24
uiStatic_s::scale
float scale
Definition: ui.h:293
R_RegisterModel
qhandle_t R_RegisterModel(const char *name)
Definition: models.c:305
QMF_HASFOCUS
#define QMF_HASFOCUS
Definition: ui.h:62
Size
static void Size(menuFrameWork_t *self)
Definition: playerconfig.c:152
Menu_Draw
void Menu_Draw(menuFrameWork_t *menu)
Definition: menu.c:2196
menuCommon_s::x
int x
Definition: ui.h:149
va
char * va(const char *format,...)
Definition: shared.c:429
playerModelInfo_s::directory
char * directory
Definition: ui.h:275
uiStatic_s::weaponModel
char weaponModel[32]
Definition: ui.h:304
m_player_s::hand
menuSpinControl_t hand
Definition: playerconfig.c:38
m_player_s::entities
entity_t entities[2]
Definition: playerconfig.c:42
origin
static vec3_t origin
Definition: mesh.c:27
m_player_s::refdef
refdef_t refdef
Definition: playerconfig.c:41
Pop
static void Pop(menuFrameWork_t *self)
Definition: playerconfig.c:224
menuSpinControl_s::generic
menuCommon_t generic
Definition: ui.h:230
menuField_s::width
int width
Definition: ui.h:167
Cvar_VariableInteger
int Cvar_VariableInteger(const char *var_name)
Definition: cvar.c:105
Q_strlcpy
size_t Q_strlcpy(char *dst, const char *src, size_t size)
Definition: shared.c:715
Menu_AddItem
void Menu_AddItem(menuFrameWork_t *menu, void *item)
Definition: menu.c:1785
menuSpinControl_s::itemnames
char ** itemnames
Definition: ui.h:233
IF_Replace
void IF_Replace(inputField_t *field, const char *text)
Definition: field.c:67
ui_menus
list_t ui_menus
playerModelInfo_s::skindisplaynames
char ** skindisplaynames
Definition: ui.h:274
ID_SKIN
#define ID_SKIN
Definition: playerconfig.c:31
menuCommon_s::y
int y
Definition: ui.h:149
Change
static menuSound_t Change(menuCommon_t *self)
Definition: playerconfig.c:206
menuFrameWork_s::color
color_t color
Definition: ui.h:111
handedness
static const char * handedness[]
Definition: playerconfig.c:54
Push
static qboolean Push(menuFrameWork_t *self)
Definition: playerconfig.c:241
V_CalcFov
float V_CalcFov(float fov_x, float width, float height)
Definition: view.c:379
uiStatic_s::pmi
playerModelInfo_t pmi[MAX_PLAYERMODELS]
Definition: ui.h:303
m_player_s::pmnames
char * pmnames[MAX_PLAYERMODELS]
Definition: playerconfig.c:47
menuCommon_s::flags
int flags
Definition: ui.h:152
m_player_s::menu
menuFrameWork_t menu
Definition: playerconfig.c:34
R_GetPicSize
qboolean R_GetPicSize(int *w, int *h, qhandle_t pic)
Definition: images.c:1289
menuCommon_s::name
char * name
Definition: ui.h:143
R_RenderFrame
void(* R_RenderFrame)(refdef_t *fd)
Definition: refresh.c:408
m_player_s::model
menuSpinControl_t model
Definition: playerconfig.c:36
uiStatic_s::width
int width
Definition: ui.h:292
menuFrameWork_s::banner_rc
vrect_t banner_rc
Definition: ui.h:118
uiStatic_s::realtime
int realtime
Definition: ui.h:291
m_player_s::oldTime
int oldTime
Definition: playerconfig.c:45
MTYPE_FIELD
@ MTYPE_FIELD
Definition: ui.h:46
uiStatic_s::backgroundHandle
qhandle_t backgroundHandle
Definition: ui.h:306
R_SetScale
void(* R_SetScale)(float scale)
Definition: refresh.c:415
menuFrameWork_s::entry
list_t entry
Definition: ui.h:99
m_player_s::skin
menuSpinControl_t skin
Definition: playerconfig.c:37
ID_MODEL
#define ID_MODEL
Definition: playerconfig.c:30
menuFrameWork_s::draw
void(* draw)(struct menuFrameWork_s *)
Definition: ui.h:134
Cvar_VariableString
char * Cvar_VariableString(const char *var_name)
Definition: cvar.c:122
Cvar_SetEx
cvar_t * Cvar_SetEx(const char *var_name, const char *value, from_t from)
Definition: cvar.c:417
Q_concat
size_t Q_concat(char *dest, size_t size,...)
Definition: shared.c:758
playerModelInfo_s::nskins
int nskins
Definition: ui.h:273
menuFrameWork_s::pop
void(* pop)(struct menuFrameWork_s *)
Definition: ui.h:132
m_player_s::view
menuSpinControl_t view
Definition: playerconfig.c:39
IF_Init
void IF_Init(inputField_t *field, size_t visibleChars, size_t maxChars)
Definition: field.c:36
PlayerModel_Load
void PlayerModel_Load(void)
Definition: playermodels.c:67
menuFrameWork_s::transparent
qboolean transparent
Definition: ui.h:107
uiStatic_s::numPlayerModels
int numPlayerModels
Definition: ui.h:302
menuSpinControl_s::curvalue
int curvalue
Definition: ui.h:236
SpinControl_Init
void SpinControl_Init(menuSpinControl_t *s)
Definition: menu.c:543
menuField_s::field
inputField_t field
Definition: ui.h:165
MENU_SPACING
#define MENU_SPACING
Definition: ui.h:81