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