vkQuake2 doxygen  1.0 dev
cl_inv.c File Reference
#include "client.h"

Go to the source code of this file.

Macros

#define DISPLAY_ITEMS   17
 

Functions

void CL_ParseInventory (void)
 
void Inv_DrawString (int x, int y, char *string)
 
void SetStringHighBit (char *s)
 
void CL_DrawInventory (void)
 

Variables

cvar_tvid_hudscale
 

Macro Definition Documentation

◆ DISPLAY_ITEMS

#define DISPLAY_ITEMS   17

Definition at line 66 of file cl_inv.c.

Function Documentation

◆ CL_DrawInventory()

void CL_DrawInventory ( void  )

Definition at line 68 of file cl_inv.c.

69 {
70  int i, j;
71  int num, selected_num, item;
72  int index[MAX_ITEMS];
73  char string[1024];
74  int x, y;
75  char binding[1024];
76  char *bind;
77  int selected;
78  int top;
79 
81 
82  num = 0;
83  selected_num = 0;
84  for (i=0 ; i<MAX_ITEMS ; i++)
85  {
86  if (i==selected)
87  selected_num = num;
88  if (cl.inventory[i])
89  {
90  index[num] = i;
91  num++;
92  }
93  }
94 
95  // determine scroll point
96  top = selected_num - DISPLAY_ITEMS/2;
97  if (num - top < DISPLAY_ITEMS)
98  top = num - DISPLAY_ITEMS;
99  if (top < 0)
100  top = 0;
101 
102  x = (viddef.width-256 * vid_hudscale->value)/2;
103  y = (viddef.height-240 * vid_hudscale->value)/2;
104 
105  // repaint everything next frame
106  SCR_DirtyScreen ();
107 
108  re.DrawPic (x, y + 8 * vid_hudscale->value, "inventory");
109 
110  y += 24 * vid_hudscale->value;
111  x += 24 * vid_hudscale->value;
112  Inv_DrawString (x, y, "hotkey ### item");
113  Inv_DrawString (x, y+8*vid_hudscale->value, "------ --- ----");
114  y += 16 * vid_hudscale->value;
115  for (i=top ; i<num && i < top+DISPLAY_ITEMS ; i++)
116  {
117  item = index[i];
118  // search for a binding
119  Com_sprintf (binding, sizeof(binding), "use %s", cl.configstrings[CS_ITEMS+item]);
120  bind = "";
121  for (j=0 ; j<256 ; j++)
122  if (keybindings[j] && !Q_stricmp (keybindings[j], binding))
123  {
124  bind = Key_KeynumToString(j);
125  break;
126  }
127 
128  Com_sprintf (string, sizeof(string), "%6s %3i %s", bind, cl.inventory[item],
129  cl.configstrings[CS_ITEMS+item] );
130  if (item != selected)
131  SetStringHighBit (string);
132  else // draw a blinky cursor by the selected item
133  {
134  if ( (int)(cls.realtime*10) & 1)
135  re.DrawChar (x - 8 * vid_hudscale->value, y * vid_hudscale->value, 15);
136  }
137  Inv_DrawString (x, y, string);
138  y += 8 * vid_hudscale->value;
139  }
140 
141 
142 }

Referenced by SCR_UpdateScreen().

◆ CL_ParseInventory()

void CL_ParseInventory ( void  )

Definition at line 31 of file cl_inv.c.

32 {
33  int i;
34 
35  for (i=0 ; i<MAX_ITEMS ; i++)
37 }

Referenced by CL_ParseServerMessage().

◆ Inv_DrawString()

void Inv_DrawString ( int  x,
int  y,
char *  string 
)

Definition at line 45 of file cl_inv.c.

46 {
47  while (*string)
48  {
49  re.DrawChar (x, y, *string);
50  x+=8 * vid_hudscale->value;
51  string++;
52  }
53 }

Referenced by CL_DrawInventory().

◆ SetStringHighBit()

void SetStringHighBit ( char *  s)

Definition at line 55 of file cl_inv.c.

56 {
57  while (*s)
58  *s++ |= 128;
59 }

Referenced by CL_DrawInventory().

Variable Documentation

◆ vid_hudscale

cvar_t* vid_hudscale

Definition at line 48 of file vid_dll.c.

Referenced by CL_DrawInventory(), and Inv_DrawString().

MSG_ReadShort
int MSG_ReadShort(sizebuf_t *msg_read)
Definition: common.c:716
net_message
sizebuf_t net_message
Definition: net_chan.c:82
Inv_DrawString
void Inv_DrawString(int x, int y, char *string)
Definition: cl_inv.c:45
CS_ITEMS
#define CS_ITEMS
Definition: q_shared.h:1116
x
GLint GLenum GLint x
Definition: qgl_win.c:116
i
int i
Definition: q_shared.c:305
vid_hudscale
cvar_t * vid_hudscale
Definition: vid_dll.c:48
SCR_DirtyScreen
void SCR_DirtyScreen(void)
Definition: cl_scrn.c:681
STAT_SELECTED_ITEM
#define STAT_SELECTED_ITEM
Definition: q_shared.h:1013
viddef
viddef_t viddef
Definition: vid_dll.c:54
j
GLint j
Definition: qgl_win.c:150
viddef_t::width
unsigned width
Definition: vid.h:29
Key_KeynumToString
char * Key_KeynumToString(int keynum)
Definition: keys.c:479
viddef_t::height
unsigned height
Definition: vid.h:29
cvar_s::value
float value
Definition: q_shared.h:331
client_state_t::frame
frame_t frame
Definition: client.h:116
MAX_ITEMS
#define MAX_ITEMS
Definition: q_shared.h:92
refexport_t::DrawPic
void(* DrawPic)(int x, int y, char *name)
Definition: ref.h:167
Q_stricmp
int Q_stricmp(char *s1, char *s2)
Definition: q_shared.c:1180
SetStringHighBit
void SetStringHighBit(char *s)
Definition: cl_inv.c:55
s
static fixed16_t s
Definition: r_scan.c:30
y
GLint y
Definition: qgl_win.c:115
re
refexport_t re
Definition: vid_dll.c:32
frame_t::playerstate
player_state_t playerstate
Definition: client.h:50
DISPLAY_ITEMS
#define DISPLAY_ITEMS
Definition: cl_inv.c:66
client_state_t::inventory
int inventory[MAX_ITEMS]
Definition: client.h:139
client_state_t::configstrings
char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]
Definition: client.h:158
refexport_t::DrawChar
void(* DrawChar)(int x, int y, int c)
Definition: ref.h:169
top
GLdouble GLdouble GLdouble top
Definition: qgl_win.c:159
cls
client_static_t cls
Definition: cl_main.c:90
keybindings
char * keybindings[256]
Definition: keys.c:40
cl
client_state_t cl
Definition: cl_main.c:91
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1223
player_state_t::stats
short stats[MAX_STATS]
Definition: q_shared.h:1196
client_static_t::realtime
int realtime
Definition: client.h:208