Xonotic
chat.qc File Reference
#include "chat.qh"
#include <client/draw.qh>
+ Include dependency graph for chat.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void HUD_Chat ()
 
void HUD_Chat_Export (int fh)
 
float HUD_Panel_Chat_InputEvent (float bInputType, float nPrimary, float nSecondary)
 

Variables

float chat_maximized_reset_scroll_time
 
float chat_maximized_scroll_ofs
 

Function Documentation

◆ HUD_Chat()

void HUD_Chat ( )

Definition at line 68 of file chat.qc.

References autocvar__con_chat_maximized, autocvar__hud_configure, autocvar_con_chat, autocvar_con_chatrect, autocvar_con_chatsize, autocvar_con_chatwidth, autocvar_hud_panel_chat, chat_maximized_reset_scroll_time, chat_maximized_scroll_ofs, chat_panel_modified, chat_posy, chat_sizey, cvar_set(), cvar_string(), fabs(), floor(), ftos(), hud_draw_maximized, HUD_Panel_DrawBg, HUD_Panel_LoadCvars(), HUD_Scale_Disable(), hud_skin_path, intermission, max(), min(), panel, panel_bg_alpha, panel_bg_border, panel_bg_padding, panel_pos, panel_size, precache_pic(), strcat(), strcpy, textShortenToWidth(), time, vector(), vid_conheight, and vid_conwidth.

69 {
71  {
73  {
75  cvar_set("con_chatrect", "0");
76  if (autocvar_con_chat != -1)
77  cvar_set("con_chat", "-1");
78  return;
79  }
80 
82  {
83  if(!hud_draw_maximized) return;
84 
86  }
87  else
88  {
90  {
91  panel.update_time = time; // forces reload of panel attributes
92  chat_panel_modified = false;
93  }
96  }
97  }
98  else
100 
102 
103  if(intermission == 2)
104  {
105  // reserve some more space to the mapvote panel
106  // by resizing and moving chat panel to the bottom
107  panel_size.y = min(panel_size.y, vid_conheight * 0.2);
109  chat_posy = panel_pos.y;
111  }
112  if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
113  {
116  if(panel.current_panel_bg == "0") // force a border when maximized
117  {
118  string panel_bg;
119  panel_bg = strcat(hud_skin_path, "/border_default");
120  if(precache_pic(panel_bg) == "")
121  panel_bg = "gfx/hud/default/border_default";
122  strcpy(panel.current_panel_bg, panel_bg);
123  chat_panel_modified = true;
124  }
127  }
128 
129  vector pos, mySize;
130  pos = panel_pos;
131  mySize = panel_size;
132 
133  // chat messages don't scale properly since they are displayed directly by the engine
136 
137  if(panel_bg_padding)
138  {
139  pos += '1 1 0' * panel_bg_padding;
140  mySize -= '2 2 0' * panel_bg_padding;
141  }
142 
144  cvar_set("con_chatrect", "1");
145 
146  // can't use a name ending with _x, _y and _z for a float autocvar as for autocvar specs
147  // it prevents ambiguity with component names of vector autocvars
148  if (cvar_string("con_chatrect_x") != ftos(pos.x / vid_conwidth))
149  cvar_set("con_chatrect_x", ftos(pos.x / vid_conwidth));
150  if (cvar_string("con_chatrect_y") != ftos(pos.y / vid_conheight))
151  cvar_set("con_chatrect_y", ftos(pos.y / vid_conheight));
152  // can't use direct comparison here, it would always returns true even if
153  // both arguments are equal because con_chatwidth is saved with cvar_set
154  //if (autocvar_con_chatwidth != mySize.x / vid_conwidth)
155  if (fabs(autocvar_con_chatwidth - mySize.x / vid_conwidth) > 0.00001)
156  cvar_set("con_chatwidth", ftos(mySize.x / vid_conwidth));
157  if (autocvar_con_chat != floor(mySize.y / autocvar_con_chatsize - 0.5))
158  cvar_set("con_chat", ftos(floor(mySize.y / autocvar_con_chatsize - 0.5)));
159 
161  {
162  vector chatsize = '1 1 0' * autocvar_con_chatsize;
163  if (cvar_string("con_chatrect_x") != "9001")
164  cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
165  string str = textShortenToWidth(_("^3Player^7: This is the chat area."), mySize.x, chatsize, stringwidth_colors);
166  for(int i = 0; i < autocvar_con_chat; ++i)
167  {
168  // engine displays chat text at full alpha
169  drawcolorcodedstring(pos, str, chatsize, 1, DRAWFLAG_NORMAL);
170  pos.y += chatsize.y;
171  }
172  }
173 }
float chat_maximized_reset_scroll_time
Definition: chat.qc:13
float vid_conheight
bool chat_panel_modified
Definition: hud.qh:73
float panel_bg_border
Definition: hud.qh:169
bool autocvar_hud_panel_chat
Definition: chat.qh:4
bool autocvar__hud_configure
Definition: hud_config.qh:3
vector panel_size
Definition: hud.qh:160
float chat_maximized_scroll_ofs
Definition: chat.qc:12
bool hud_draw_maximized
Definition: hud.qh:68
float autocvar_con_chatsize
Definition: chat.qh:8
float chat_sizey
Definition: hud.qh:180
float intermission
Definition: csprogsdefs.qc:148
void HUD_Scale_Disable()
Definition: hud.qc:83
string textShortenToWidth(string theText, float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition: util.qc:956
float vid_conwidth
#define strcpy(this, s)
Definition: string.qh:49
string hud_skin_path
Definition: hud.qh:133
#define HUD_Panel_DrawBg()
Definition: hud.qh:54
float chat_posy
Definition: hud.qh:179
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
float panel_bg_alpha
Definition: hud.qh:167
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
entity panel
Definition: hud.qh:144
vector panel_pos
Definition: hud.qh:159
vector(float skel, float bonenum) _skel_get_boneabs_hidden
bool autocvar__con_chat_maximized
Definition: chat.qh:6
bool autocvar_con_chatrect
Definition: chat.qh:12
float autocvar_con_chatwidth
Definition: chat.qh:15
bool autocvar_con_chat
Definition: chat.qh:7
float time
Definition: csprogsdefs.qc:16
void HUD_Panel_LoadCvars()
Definition: hud.qc:216
float panel_bg_padding
Definition: hud.qh:171
+ Here is the call graph for this function:

◆ HUD_Chat_Export()

void HUD_Chat_Export ( int  fh)

Definition at line 7 of file chat.qc.

8 {
9  // allow saving cvars that aesthetically change the panel into hud skin files
10 }

◆ HUD_Panel_Chat_InputEvent()

float HUD_Panel_Chat_InputEvent ( float  bInputType,
float  nPrimary,
float  nSecondary 
)

Definition at line 14 of file chat.qc.

References autocvar__con_chat_maximized, chat_maximized_scroll_ofs, cvar(), K_MWHEELDOWN, K_MWHEELUP, K_PGDN, K_PGUP, mousepos, and vid_conheight.

Referenced by CSQC_InputEvent().

15 {
16  if(bInputType == 3)
17  {
18  mousepos.x = nPrimary;
19  mousepos.y = nSecondary;
20  return true;
21  }
22 
23  if(bInputType == 2)
24  return false;
25 
26  // at this point bInputType can only be 0 or 1 (key pressed or released)
27  bool key_pressed = (bInputType == 0);
28 
30  return false;
31 
32  if(nPrimary == K_MWHEELUP)
33  {
34  if (!key_pressed)
35  return true;
36  chat_maximized_scroll_ofs += 5 * cvar("con_chatsize");
37  return true;
38  }
39  else if(nPrimary == K_MWHEELDOWN)
40  {
41  if (!key_pressed)
42  return true;
43  chat_maximized_scroll_ofs -= 5 * cvar("con_chatsize");
46  return true;
47  }
48  else if(nPrimary == K_PGUP)
49  {
50  if (!key_pressed)
51  return true;
53  return true;
54  }
55  else if(nPrimary == K_PGDN)
56  {
57  if (!key_pressed)
58  return true;
62  return true;
63  }
64 
65  return false;
66 }
float vid_conheight
float chat_maximized_scroll_ofs
Definition: chat.qc:12
float K_PGDN
Definition: keycodes.qc:39
float K_MWHEELDOWN
Definition: keycodes.qc:133
bool autocvar__con_chat_maximized
Definition: chat.qh:6
vector mousepos
Definition: hud.qh:102
float K_PGUP
Definition: keycodes.qc:40
float K_MWHEELUP
Definition: keycodes.qc:132
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ chat_maximized_reset_scroll_time

float chat_maximized_reset_scroll_time

Definition at line 13 of file chat.qc.

Referenced by HUD_Chat().

◆ chat_maximized_scroll_ofs

float chat_maximized_scroll_ofs

Definition at line 12 of file chat.qc.

Referenced by HUD_Chat(), and HUD_Panel_Chat_InputEvent().