]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
hud_panel_centerprint_flip to invert messages order
authorterencehill <piuntn@gmail.com>
Tue, 24 May 2011 18:19:00 +0000 (20:19 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 24 May 2011 18:19:00 +0000 (20:19 +0200)
hud_luminos.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc
qcsrc/client/hud_config.qc

index e1ab76507a924bdd0b09ad089935f6d831114ccf..a03e9f50fa5c56e984718dd674fbc2c563a285ec 100644 (file)
@@ -241,6 +241,7 @@ seta hud_panel_centerprint_bg_alpha ""
 seta hud_panel_centerprint_bg_border ""
 seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
+seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
 seta hud_panel_centerprint_time "2"
 
index fc7fd4e9e5b852ba99fc194977507bcaa8141fd1..84bade0c89a22fc908fe35943dbcdf49a25d7081 100644 (file)
@@ -207,6 +207,7 @@ float autocvar_hud_panel_healtharmor_progressbar_gfx_smooth;
 
 float autocvar_hud_panel_centerprint;
 float autocvar_hud_panel_centerprint_align;
+float autocvar_hud_panel_centerprint_flip;
 float autocvar_hud_panel_centerprint_fontscale;
 float autocvar_hud_panel_centerprint_time;
 float autocvar_hud_panel_healtharmor_text;
index 3299648da6f95b78fac741078bad690097ba7825..44ce25192ba7212a0105a6919196dd26f215eb00 100644 (file)
@@ -4409,11 +4409,13 @@ void HUD_CenterPrint (void)
        entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES);
 
        float i, j, k, n;
-       float a, sz, fade, align;
+       float a, sz, fade, align, next_msg_pos_y;
        vector pos;
        string ts;
 
        pos = panel_pos;
+       if (autocvar_hud_panel_centerprint_flip)
+               pos_y += panel_size_y - fontsize_y;
        fade = min(autocvar_hud_panel_centerprint_time/8, 0.25);
        align = bound(0, autocvar_hud_panel_centerprint_align, 1);
        for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
@@ -4435,6 +4437,23 @@ void HUD_CenterPrint (void)
 
                drawfontscale = sz * '1 1 0';
                n = tokenizebyseparator(centerprint_messages[j], "\n");
+               if (autocvar_hud_panel_centerprint_flip)
+               {
+                       // check if the message can be entirely shown
+                       for(k = 0; k < n; ++k)
+                       {
+                               getWrappedLine_remaining = argv(k);
+                               ts = getWrappedLine(panel_size_x, fontsize, stringwidth_colors);
+                               if (ts != "")
+                                       pos_y -= fontsize_y * 1.5;
+                               else
+                                       pos_y -= fontsize_y;
+                               if (pos_y < panel_pos_y) // check if the next line can be shown
+                                       return;
+                       }
+                       next_msg_pos_y = pos_y; // save pos of the next message
+               }
+
                for(k = 0; k < n; ++k)
                {
                        getWrappedLine_remaining = argv(k);
@@ -4450,15 +4469,24 @@ void HUD_CenterPrint (void)
                                }
                                else
                                        pos_y += fontsize_y;
-                               if (pos_y > panel_pos_y + panel_size_y - fontsize_y)
+                               if (pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next line can be shown
                                {
                                        drawfontscale = '1 1 0';
                                        return;
                                }
                        }
                }
-               if (a < 1)
-                       pos_y -= 1.5 * fontsize_y * (1 - a*a);
+               if (autocvar_hud_panel_centerprint_flip)
+               {
+                       pos_y = next_msg_pos_y;
+                       if (a < 1)
+                               pos_y += 1.5 * fontsize_y * (1 - a*a);
+               }
+               else
+               {
+                       if (a < 1)
+                               pos_y -= 1.5 * fontsize_y * (1 - a*a);
+               }
                drawfontscale = '1 1 0';
        }
 }
index 80a28a48a96eec7c8f487bf7c985b64bfe70e9a1..a897bdd33d299b20f84e83f1e5dc9566e58b05f5 100644 (file)
@@ -123,6 +123,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        break;
                                case HUD_PANEL_CENTERPRINT:
                                        HUD_Write_PanelCvar_q("_align");
+                                       HUD_Write_PanelCvar_q("_flip");
                                        HUD_Write_PanelCvar_q("_fontscale");
                                        HUD_Write_PanelCvar_q("_time");
                                        break;