]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/hud/panel/chat.qc
Merge branch 'terencehill/quickmenu_file_example' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / chat.qc
1 /** Handle chat as a panel (#12) */
2 void HUD_Chat()
3 {
4         if(!autocvar__hud_configure)
5         {
6                 if (!autocvar_hud_panel_chat)
7                 {
8                         if (!autocvar_con_chatrect)
9                                 cvar_set("con_chatrect", "0");
10                         return;
11                 }
12                 if(autocvar__con_chat_maximized)
13                 {
14                         if(!hud_draw_maximized) return;
15                 }
16                 else if(chat_panel_modified)
17                 {
18                         panel.update_time = time; // forces reload of panel attributes
19                         chat_panel_modified = false;
20                 }
21         }
22
23         HUD_Panel_UpdateCvars();
24
25         if(intermission == 2)
26         {
27                 // reserve some more space to the mapvote panel
28                 // by resizing and moving chat panel to the bottom
29                 panel_size.y = min(panel_size.y, vid_conheight * 0.2);
30                 panel_pos.y = vid_conheight - panel_size.y - panel_bg_border * 2;
31                 chat_posy = panel_pos.y;
32                 chat_sizey = panel_size.y;
33         }
34         if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
35         {
36                 panel_pos.y = panel_bg_border;
37                 panel_size.y = vid_conheight - panel_bg_border * 2;
38                 if(panel.current_panel_bg == "0") // force a border when maximized
39                 {
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                         if(panel.current_panel_bg)
45                                 strunzone(panel.current_panel_bg);
46                         panel.current_panel_bg = strzone(panel_bg);
47                         chat_panel_modified = true;
48                 }
49                 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an theAlpha of at least 0.75
50         }
51
52         vector pos, mySize;
53         pos = panel_pos;
54         mySize = panel_size;
55
56         HUD_Panel_DrawBg(1);
57
58         if(panel_bg_padding)
59         {
60                 pos += '1 1 0' * panel_bg_padding;
61                 mySize -= '2 2 0' * panel_bg_padding;
62         }
63
64         if (!autocvar_con_chatrect)
65                 cvar_set("con_chatrect", "1");
66
67         cvar_set("con_chatrect_x", ftos(pos.x/vid_conwidth));
68         cvar_set("con_chatrect_y", ftos(pos.y/vid_conheight));
69
70         cvar_set("con_chatwidth", ftos(mySize.x/vid_conwidth));
71         cvar_set("con_chat", ftos(floor(mySize.y/autocvar_con_chatsize - 0.5)));
72
73         if(autocvar__hud_configure)
74         {
75                 vector chatsize;
76                 chatsize = '1 1 0' * autocvar_con_chatsize;
77                 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over theAlpha and such
78                 float i, a;
79                 for(i = 0; i < autocvar_con_chat; ++i)
80                 {
81                         if(i == autocvar_con_chat - 1)
82                                 a = panel_fg_alpha;
83                         else
84                                 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
85                         drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize.x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
86                         pos.y += chatsize.y;
87                 }
88         }
89 }