icculus quake2 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)
 

Macro Definition Documentation

◆ DISPLAY_ITEMS

#define DISPLAY_ITEMS   17

Definition at line 68 of file cl_inv.c.

Function Documentation

◆ CL_DrawInventory()

void CL_DrawInventory ( void  )

Definition at line 70 of file cl_inv.c.

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

Referenced by SCR_UpdateScreen().

◆ CL_ParseInventory()

void CL_ParseInventory ( void  )

Definition at line 29 of file cl_inv.c.

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

Referenced by CL_ParseServerMessage().

◆ Inv_DrawString()

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

Definition at line 43 of file cl_inv.c.

44 {
45  while (*string)
46  {
47 #ifdef QMAX
48  re.DrawChar (x, y, *string, 256);
49 #else
50  re.DrawChar (x, y, *string);
51 #endif
52  x+=8;
53  string++;
54  }
55 }

Referenced by CL_DrawInventory().

◆ SetStringHighBit()

void SetStringHighBit ( char *  s)

Definition at line 57 of file cl_inv.c.

58 {
59  while (*s)
60  *s++ |= 128;
61 }

Referenced by CL_DrawInventory().

MSG_ReadShort
int MSG_ReadShort(sizebuf_t *msg_read)
Definition: common.c:735
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:43
CS_ITEMS
#define CS_ITEMS
Definition: q_shared.h:1140
x
GLint GLenum GLint x
Definition: qgl_win.c:116
viddef_t::width
int width
Definition: vid.h:29
i
int i
Definition: q_shared.c:305
keybindings
char * keybindings[K_LAST]
Definition: keys.c:39
viddef_t::height
int height
Definition: vid.h:29
SCR_DirtyScreen
void SCR_DirtyScreen(void)
Definition: cl_scrn.c:687
STAT_SELECTED_ITEM
#define STAT_SELECTED_ITEM
Definition: q_shared.h:1037
viddef
viddef_t viddef
Definition: vid_dll.c:49
j
GLint j
Definition: qgl_win.c:150
Key_KeynumToString
char * Key_KeynumToString(int keynum)
Definition: keys.c:482
client_state_t::frame
frame_t frame
Definition: client.h:136
MAX_ITEMS
#define MAX_ITEMS
Definition: q_shared.h:85
refexport_t::DrawPic
void(* DrawPic)(int x, int y, char *name)
Definition: ref.h:196
Q_stricmp
int Q_stricmp(char *s1, char *s2)
Definition: q_shared.c:1192
SetStringHighBit
void SetStringHighBit(char *s)
Definition: cl_inv.c:57
y
GLint y
Definition: qgl_win.c:115
re
refexport_t re
Definition: vid_dll.c:31
frame_t::playerstate
player_state_t playerstate
Definition: client.h:70
DISPLAY_ITEMS
#define DISPLAY_ITEMS
Definition: cl_inv.c:68
client_state_t::inventory
int inventory[MAX_ITEMS]
Definition: client.h:159
client_state_t::configstrings
char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]
Definition: client.h:178
refexport_t::DrawChar
void(* DrawChar)(int x, int y, int c)
Definition: ref.h:193
top
GLdouble GLdouble GLdouble top
Definition: qgl_win.c:159
cls
client_static_t cls
Definition: cl_main.c:105
cl
client_state_t cl
Definition: cl_main.c:106
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1236
player_state_t::stats
short stats[MAX_STATS]
Definition: q_shared.h:1220
client_static_t::realtime
int realtime
Definition: client.h:228