]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/hud/panel/chat.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / chat.qc
1 #include "chat.qh"
2
3 #include <client/autocvars.qh>
4 #include <client/defs.qh>
5 #include <client/miscfunctions.qh>
6
7 // Chat (#12)
8
9 void HUD_Chat()
10 {
11         if (!autocvar__hud_configure) {
12                 if (!autocvar_hud_panel_chat) {
13                         if (!autocvar_con_chatrect) {
14                                 cvar_set("con_chatrect", "0");
15                         }
16                         return;
17                 }
18                 if (autocvar__con_chat_maximized) {
19                         if (!hud_draw_maximized) { return; }
20                 } else if (chat_panel_modified) {
21                         panel.update_time = time; // forces reload of panel attributes
22                         chat_panel_modified = false;
23                 }
24         }
25
26         HUD_Panel_LoadCvars();
27
28         if (intermission == 2) {
29                 // reserve some more space to the mapvote panel
30                 // by resizing and moving chat panel to the bottom
31                 panel_size.y = min(panel_size.y, vid_conheight * 0.2);
32                 panel_pos.y = vid_conheight - panel_size.y - panel_bg_border * 2;
33                 chat_posy = panel_pos.y;
34                 chat_sizey = panel_size.y;
35         }
36         if (autocvar__con_chat_maximized && !autocvar__hud_configure) { // draw at full screen height if maximized
37                 panel_pos.y = panel_bg_border;
38                 panel_size.y = vid_conheight - panel_bg_border * 2;
39                 if (panel.current_panel_bg == "0") { // force a border when maximized
40                         string panel_bg;
41                         panel_bg = strcat(hud_skin_path, "/border_default");
42                         if (precache_pic(panel_bg) == "") {
43                                 panel_bg = "gfx/hud/default/border_default";
44                         }
45                         if (panel.current_panel_bg) {
46                                 strunzone(panel.current_panel_bg);
47                         }
48                         panel.current_panel_bg = strzone(panel_bg);
49                         chat_panel_modified = true;
50                 }
51                 panel_bg_alpha = max(0.75, panel_bg_alpha);
52         }
53
54         vector pos, mySize;
55         pos = panel_pos;
56         mySize = panel_size;
57
58         // chat messages don't scale properly since they are displayed directly by the engine
59         HUD_Scale_Disable();
60         HUD_Panel_DrawBg();
61
62         if (panel_bg_padding) {
63                 pos += '1 1 0' * panel_bg_padding;
64                 mySize -= '2 2 0' * panel_bg_padding;
65         }
66
67         if (!autocvar_con_chatrect) {
68                 cvar_set("con_chatrect", "1");
69         }
70
71         cvar_set("con_chatrect_x", ftos(pos.x / vid_conwidth));
72         cvar_set("con_chatrect_y", ftos(pos.y / vid_conheight));
73
74         cvar_set("con_chatwidth", ftos(mySize.x / vid_conwidth));
75         cvar_set("con_chat", ftos(floor(mySize.y / autocvar_con_chatsize - 0.5)));
76
77         if (autocvar__hud_configure) {
78                 vector chatsize = '1 1 0' * autocvar_con_chatsize;
79                 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
80                 string str = textShortenToWidth(_("^3Player^7: This is the chat area."), mySize.x, chatsize, stringwidth_colors);
81                 for (int i = 0; i < autocvar_con_chat; ++i) {
82                         // engine displays chat text at full alpha
83                         drawcolorcodedstring(pos, str, chatsize, 1, DRAWFLAG_NORMAL);
84                         pos.y += chatsize.y;
85                 }
86         }
87 }