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