Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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 (bool should_draw)
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 ( bool should_draw)

Definition at line 68 of file chat.qc.

69{
70 if (!should_draw)
71 return;
73 {
75 {
77 cvar_set("con_chatrect", "0");
78 if (autocvar_con_chat != -1)
79 cvar_set("con_chat", "-1");
80 return;
81 }
82
84 {
86 return;
88 }
89 else
90 {
92 {
93 panel.update_time = time; // forces reload of panel attributes
94 chat_panel_modified = false;
95 }
98 }
99 }
100 else
102
104
105 if (intermission == 2)
106 {
107 // reserve some more space to the mapvote panel
108 // by resizing and moving chat panel to the bottom
113 }
114 if (autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
115 {
118 if (panel.current_panel_bg == "0") // force a border when maximized
119 {
120 string panel_bg = strcat(hud_skin_path, "/border_default");
121 if (precache_pic(panel_bg) == "")
122 panel_bg = "gfx/hud/default/border_default";
123 strcpy(panel.current_panel_bg, panel_bg);
124 chat_panel_modified = true;
125 }
128 }
129
130 vector pos = panel_pos;
131 vector mySize = panel_size;
132
133 // chat messages don't scale properly since they are displayed directly by the engine
136
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 float alpha = 1; // engine can display chat only at full alpha
164 alpha = hud_fade_alpha; // fade only when the settings menu of another panel is open
165 vector chatsize = '1 1 0' * autocvar_con_chatsize;
166 if (cvar_string("con_chatrect_x") != "9001")
167 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
168 string str = textShortenToWidth(_("^3Player^7: This is the chat area."), mySize.x, chatsize, stringwidth_colors);
169 for (int i = 0; i < autocvar_con_chat; ++i)
170 {
171 drawcolorcodedstring(pos, str, chatsize, alpha, DRAWFLAG_NORMAL);
172 pos.y += chatsize.y;
173 }
174 }
175}
#define drawcolorcodedstring(position, text, scale, alpha, flag)
Definition draw.qh:30
float chat_maximized_scroll_ofs
Definition chat.qc:12
float chat_maximized_reset_scroll_time
Definition chat.qc:13
bool autocvar_con_chat
Definition chat.qh:7
float autocvar_con_chatwidth
Definition chat.qh:15
bool autocvar_hud_panel_chat
Definition chat.qh:4
bool autocvar_con_chatrect
Definition chat.qh:12
bool autocvar__con_chat_maximized
Definition chat.qh:6
float autocvar_con_chatsize
Definition chat.qh:8
float alpha
Definition items.qc:13
string textShortenToWidth(string theText, float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition util.qc:1171
const float DRAWFLAG_NORMAL
float time
float intermission
void HUD_Panel_LoadCvars()
Definition hud.qc:215
void HUD_Scale_Disable()
Definition hud.qc:84
entity highlightedPanel
Definition hud.qh:107
vector panel_size
Definition hud.qh:163
float panel_bg_padding
Definition hud.qh:174
bool hud_draw_maximized
Definition hud.qh:69
float panel_bg_border
Definition hud.qh:172
float chat_sizey
Definition hud.qh:183
float hud_fade_alpha
Definition hud.qh:134
#define HUD_Panel_DrawBg()
Definition hud.qh:55
string hud_skin_path
Definition hud.qh:136
vector panel_pos
Definition hud.qh:162
float chat_posy
Definition hud.qh:182
float panel_bg_alpha
Definition hud.qh:170
entity panel
Definition hud.qh:147
bool chat_panel_modified
Definition hud.qh:74
bool autocvar__hud_configure
Definition hud_config.qh:3
float hud_configure_menu_open
Definition hud_config.qh:22
noref float vid_conwidth
Definition draw.qh:8
noref float vid_conheight
Definition draw.qh:9
void cvar_set(string name, string value)
string precache_pic(string name,...)
const string cvar_string(string name)
float min(float f,...)
string ftos(float f)
float fabs(float f)
float floor(float f)
float max(float f,...)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
vector
Definition self.qh:92
#define strcpy(this, s)
Definition string.qh:52
float stringwidth_colors(string s, vector theSize)
Definition string.qh:30

References alpha, 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(), drawcolorcodedstring, DRAWFLAG_NORMAL, fabs(), floor(), ftos(), highlightedPanel, hud_configure_menu_open, hud_draw_maximized, hud_fade_alpha, 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, stringwidth_colors(), textShortenToWidth(), time, vector, vid_conheight, and vid_conwidth.

◆ 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.

15{
17 return false;
18
19 if (bInputType == 3)
20 {
21 mousepos.x = nPrimary;
22 mousepos.y = nSecondary;
23 return true;
24 }
25
26 if (bInputType == 2)
27 return false;
28
29 // at this point bInputType can only be 0 or 1 (key pressed or released)
30 bool key_pressed = bInputType == 0;
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}
vector mousepos
Definition hud.qh:103
float K_PGDN
Definition keycodes.qc:39
float K_MWHEELDOWN
Definition keycodes.qc:133
float K_PGUP
Definition keycodes.qc:40
float K_MWHEELUP
Definition keycodes.qc:132
float cvar(string name)

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().

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().