3 #include <client/draw.qh>
7 void HUD_Chat_Export(int fh)
9 // allow saving cvars that aesthetically change the panel into hud skin files
14 if(!autocvar__hud_configure)
16 if (!autocvar_hud_panel_chat && !autocvar__con_chat_maximized)
18 if (autocvar_con_chatrect)
19 cvar_set("con_chatrect", "0");
20 if (autocvar_con_chat != -1)
21 cvar_set("con_chat", "-1");
24 if(autocvar__con_chat_maximized)
26 if(!hud_draw_maximized) return;
28 else if(chat_panel_modified)
30 panel.update_time = time; // forces reload of panel attributes
31 chat_panel_modified = false;
35 HUD_Panel_LoadCvars();
39 // reserve some more space to the mapvote panel
40 // by resizing and moving chat panel to the bottom
41 panel_size.y = min(panel_size.y, vid_conheight * 0.2);
42 panel_pos.y = vid_conheight - panel_size.y - panel_bg_border * 2;
43 chat_posy = panel_pos.y;
44 chat_sizey = panel_size.y;
46 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
48 panel_pos.y = panel_bg_border;
49 panel_size.y = vid_conheight - panel_bg_border * 2;
50 if(panel.current_panel_bg == "0") // force a border when maximized
53 panel_bg = strcat(hud_skin_path, "/border_default");
54 if(precache_pic(panel_bg) == "")
55 panel_bg = "gfx/hud/default/border_default";
56 strcpy(panel.current_panel_bg, panel_bg);
57 chat_panel_modified = true;
59 panel_bg_alpha = max(0.75, panel_bg_alpha);
66 // chat messages don't scale properly since they are displayed directly by the engine
72 pos += '1 1 0' * panel_bg_padding;
73 mySize -= '2 2 0' * panel_bg_padding;
76 if (!autocvar_con_chatrect)
77 cvar_set("con_chatrect", "1");
79 // can't use a name ending with _x, _y and _z for a float autocvar as for autocvar specs
80 // it prevents ambiguity with component names of vector autocvars
81 if (cvar_string("con_chatrect_x") != ftos(pos.x / vid_conwidth))
82 cvar_set("con_chatrect_x", ftos(pos.x / vid_conwidth));
83 if (cvar_string("con_chatrect_y") != ftos(pos.y / vid_conheight))
84 cvar_set("con_chatrect_y", ftos(pos.y / vid_conheight));
85 // can't use direct comparison here, it would always returns true even if
86 // both arguments are equal because con_chatwidth is saved with cvar_set
87 //if (autocvar_con_chatwidth != mySize.x / vid_conwidth)
88 if (fabs(autocvar_con_chatwidth - mySize.x / vid_conwidth) > 0.00001)
89 cvar_set("con_chatwidth", ftos(mySize.x / vid_conwidth));
90 if (autocvar_con_chat != floor(mySize.y / autocvar_con_chatsize - 0.5))
91 cvar_set("con_chat", ftos(floor(mySize.y / autocvar_con_chatsize - 0.5)));
93 if(autocvar__hud_configure)
95 vector chatsize = '1 1 0' * autocvar_con_chatsize;
96 if (cvar_string("con_chatrect_x") != "9001")
97 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
98 string str = textShortenToWidth(_("^3Player^7: This is the chat area."), mySize.x, chatsize, stringwidth_colors);
99 for(int i = 0; i < autocvar_con_chat; ++i)
101 // engine displays chat text at full alpha
102 drawcolorcodedstring(pos, str, chatsize, 1, DRAWFLAG_NORMAL);