]> git.rm.cloudns.org Git - voretournament/voretournament.git/commitdiff
Use independent functions for some tasks, and fix how scale and position are defined
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 2 Feb 2013 14:03:00 +0000 (16:03 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 2 Feb 2013 14:03:00 +0000 (16:03 +0200)
data/hudVT.cfg
data/qcsrc/client/hud.qc

index 0e0e1b02d463ae5dde2758a5f70c2920f0d84387..a965ad829815a8ddf1cb0cf560f950fcde69ee7a 100644 (file)
@@ -16,24 +16,24 @@ set hud_item_armor_text_scale 12
 \r
 set hud_item_ammo_icon_position "0.095 -0.91 0"\r
 set hud_item_ammo_icon_scale "0.025 0.04 0"\r
-set hud_item_ammo_noload_text_position "0.025 0.91 0"\r
+set hud_item_ammo_noload_text_position "0.025 -0.91 0"\r
 set hud_item_ammo_noload_text_scale 16\r
 set hud_item_ammo_load_text_position "0.015 -0.935 0"\r
 set hud_item_ammo_load_text_scale 12\r
 set hud_item_clip_load_text_position "0.03 -0.89 0"\r
 set hud_item_clip_load_text_scale 16\r
 \r
-set hud_item_predator_position "140 450 0"\r
-set hud_item_predator_scale "130 10 0"\r
+set hud_item_predator_position "-0.64 -0.525 0"\r
+set hud_item_predator_scale "0.17 0.0175 0"\r
 set hud_item_predator_colors_location 0\r
 set hud_item_predator_colors_length 0.15\r
 set hud_item_predator_name_location 0.15\r
 set hud_item_predator_name_length 0.85\r
 \r
-set hud_item_preylist_spacing 1.25\r
-set hud_item_preylist_entries 9\r
-set hud_item_preylist_position "110 475 0"\r
-set hud_item_preylist_scale "190 10 0"\r
+set hud_item_preylist_position "-0.72 -0.6 0"\r
+set hud_item_preylist_scale "0.25 0.0175 0"\r
+set hud_item_preylist_entry_spacing "0 -1.25 0"\r
+set hud_item_preylist_entry_number 9\r
 set hud_item_preylist_colors_location 0\r
 set hud_item_preylist_colors_length 0.1\r
 set hud_item_preylist_name_location 0.1\r
index b91c6a26055f1186f38a36ea03fc69a8798b8ad6..c70501497f27be29dfbcc88a7dcee9a6d4050a3d 100644 (file)
@@ -72,15 +72,39 @@ vector Sbar_AccuracyColor(float accuracy)
        return rgb;\r
 }\r
 \r
-void Sbar_DrawPic(string pic, vector position, vector dimensions, float background)\r
+vector Sbar_ConvertToScreen_PicScale(vector dimensions)\r
 {\r
-       vector pos, sz;\r
+       vector sz;\r
        sz_x = vid_conwidth * dimensions_x;\r
        sz_y = vid_conheight * dimensions_y;\r
+       return sz;\r
+}\r
+vector Sbar_ConvertToScreen_PicPosition(vector position, vector dimensions)\r
+{\r
+       vector pos, sz;\r
+       sz = Sbar_ConvertToScreen_PicScale(dimensions);\r
        pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2);\r
        pos_x -= sz_x / 2;\r
        pos_y = (vid_conheight / 2) * bound(0, 1 - position_y, 2);\r
        pos_y -= sz_y / 2;\r
+       return pos;\r
+}\r
+vector Sbar_ConvertToScreen_TextPosition(string text, vector position, float lettersize)\r
+{\r
+       vector pos, sz;\r
+       sz_x = sz_y = lettersize;\r
+       pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2);\r
+       pos_x -= stringwidth(text, FALSE, sz) * 0.5;\r
+       pos_y = (vid_conheight / 2) * bound(0, 1 - position_y, 2);\r
+       pos_y -= sz_y / 2;\r
+       return pos;\r
+}\r
+\r
+void Sbar_DrawPic(string pic, vector position, vector dimensions, float background)\r
+{\r
+       vector pos, sz;\r
+       pos = Sbar_ConvertToScreen_PicPosition(position, dimensions);\r
+       sz = Sbar_ConvertToScreen_PicScale(dimensions);\r
 \r
        if(background)\r
        {\r
@@ -96,11 +120,8 @@ void Sbar_DrawPic(string pic, vector position, vector dimensions, float backgrou
 void Sbar_DrawString(string text, vector position, float lettersize)\r
 {\r
        vector pos, sz;\r
+       pos = Sbar_ConvertToScreen_TextPosition(text, position, lettersize);\r
        sz_x = sz_y = lettersize;\r
-       pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2);\r
-       pos_x -= stringwidth(text, FALSE, sz) * 0.5;\r
-       pos_y = (vid_conheight / 2) * bound(0, 1 - position_y, 2);\r
-       pos_y -= sz_y / 2;\r
 \r
        drawstring(pos, text, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 }\r
@@ -152,11 +173,8 @@ void Sbar_DrawXNum (vector position, float num, float digits, float showminusplu
        final_num = strcat(final_num, str);\r
 \r
        vector pos, sz;\r
+       pos = Sbar_ConvertToScreen_TextPosition(final_num, position, lettersize);\r
        sz_x = sz_y = lettersize;\r
-       pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2);\r
-       pos_x -= stringwidth(final_num, FALSE, sz) * 0.5;\r
-       pos_y = (vid_conheight / 2) * bound(0, 1 - position_y, 2);\r
-       pos_y -= sz_y / 2;\r
 \r
        drawstring(pos, final_num, sz, rgb, alpha, dflags);\r
 }\r
@@ -745,6 +763,44 @@ string Sbar_GetStomachFieldPred(entity pl, float field)
        //return "error";\r
 }\r
 \r
+vector Sbar_GetVoreColor()\r
+{\r
+       // gets color based on vore status\r
+       if(getstati(STAT_VORE_EATEN))\r
+       {\r
+               if(teamplay && (GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(player_localentnum - 1) || GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(spectatee_status - 1))) // same team\r
+                       return stov(cvar_string("sbar_stomachboard_color2"));\r
+               else\r
+                       return stov(cvar_string("sbar_stomachboard_color3"));\r
+       }\r
+       else\r
+               return stov(cvar_string("sbar_stomachboard_color1"));\r
+}\r
+\r
+vector colorfade_current;\r
+vector Sbar_ColorFade(vector target_color)\r
+{\r
+       local float step;\r
+       step = cvar("sbar_stomachboard_status_fade") * frametime;\r
+\r
+       if(colorfade_current_x >= target_color_x + step)\r
+               colorfade_current_x -= step;\r
+       else if(colorfade_current_x <= target_color_x - step)\r
+               colorfade_current_x += step;\r
+\r
+       if(colorfade_current_y >= target_color_y + step)\r
+               colorfade_current_y -= step;\r
+       else if(colorfade_current_y <= target_color_y - step)\r
+               colorfade_current_y += step;\r
+\r
+       if(colorfade_current_z >= target_color_z + step)\r
+               colorfade_current_z -= step;\r
+       else if(colorfade_current_z <= target_color_z - step)\r
+               colorfade_current_z += step;\r
+\r
+       return colorfade_current;\r
+}\r
+\r
 float xmin, xmax, ymin, ymax, sbwidth;\r
 float sbar_fixscoreboardcolumnwidth_len;\r
 float sbar_fixscoreboardcolumnwidth_iconlen;\r
@@ -949,23 +1005,22 @@ void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_num
        }\r
 }\r
 \r
-float fieldcounter;\r
 void Sbar_PrintStomachboardItem(entity pl, vector position, vector dimensions)\r
 {\r
        // lists all players in the stomach\r
 \r
        string str;\r
        float f, field, field_number;\r
-       vector hl_color;\r
        field_number = 3; // the number of components each row has\r
 \r
-       // center defined position on the x axis\r
-       position_x -= dimensions_x / 2;\r
+       position = Sbar_ConvertToScreen_PicPosition(position, dimensions);\r
+       dimensions = Sbar_ConvertToScreen_PicScale(dimensions);\r
 \r
        // set font size to the height of each entry\r
        vector font_sz;\r
        font_sz_x = font_sz_y = dimensions_y;\r
 \r
+       float fieldcounter;\r
        for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)\r
        {\r
                vector pos, sz;\r
@@ -978,16 +1033,7 @@ void Sbar_PrintStomachboardItem(entity pl, vector position, vector dimensions)
                        pos = position;\r
                        sz = dimensions;\r
 \r
-                       if(getstati(STAT_VORE_EATEN))\r
-                       {\r
-                               if(teamplay && (GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(player_localentnum - 1) || GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(spectatee_status - 1))) // same team\r
-                                       hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
-                               else\r
-                                       hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
-                       }\r
-                       else\r
-                               hl_color = stov(cvar_string("sbar_stomachboard_color1"));\r
-                       drawfill(pos, sz, hl_color, cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       drawfill(pos, sz, Sbar_ColorFade(Sbar_GetVoreColor()), cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
 \r
                if(field == ST_NAME) {\r
@@ -1022,27 +1068,26 @@ void Sbar_PrintStomachboardItem(entity pl, vector position, vector dimensions)
        }\r
 }\r
 \r
-float fieldcounter2;\r
 void Sbar_PrintStomachboardItemPred(entity pl, vector position, vector dimensions)\r
 {\r
        // shows the name of our predator\r
 \r
        string str;\r
        float f, field, field_number;\r
-       vector hl_color;\r
        field_number = 2; // the number of components each row has\r
 \r
-       // center defined position on the x axis\r
-       position_x -= dimensions_x / 2;\r
+       position = Sbar_ConvertToScreen_PicPosition(position, dimensions);\r
+       dimensions = Sbar_ConvertToScreen_PicScale(dimensions);\r
 \r
        // set font size to the height of each entry\r
        vector font_sz;\r
        font_sz_x = font_sz_y = dimensions_y;\r
 \r
-       for(fieldcounter2 = 1; fieldcounter2 <= field_number; ++fieldcounter2)\r
+       float fieldcounter;\r
+       for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)\r
        {\r
                vector pos, sz;\r
-               field = -fieldcounter2;\r
+               field = -fieldcounter;\r
                str = Sbar_GetStomachFieldPred(pl, field);\r
 \r
                // row highlighting\r
@@ -1051,16 +1096,7 @@ void Sbar_PrintStomachboardItemPred(entity pl, vector position, vector dimension
                        pos = position;\r
                        sz = dimensions;\r
 \r
-                       if(getstati(STAT_VORE_EATEN))\r
-                       {\r
-                               if(teamplay && (GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(player_localentnum - 1) || GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(spectatee_status - 1))) // same team\r
-                                       hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
-                               else\r
-                                       hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
-                       }\r
-                       else\r
-                               hl_color = stov(cvar_string("sbar_stomachboard_color1"));\r
-                       drawfill(pos, sz, hl_color, cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       drawfill(pos, sz, Sbar_ColorFade(Sbar_GetVoreColor()), cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
 \r
                if(field == STP_NAME) {\r
@@ -2919,30 +2955,6 @@ float vote_prev; // previous state of vote_active to check for a change
 float vote_alpha;\r
 float vote_change; // "time" when vote_active changed\r
 \r
-vector stomachstatus_colorfade_current;\r
-vector StomachStatus_ColorFade(vector target_color)\r
-{\r
-       local float step;\r
-       step = cvar("sbar_stomachboard_status_fade") * frametime;\r
-\r
-       if(stomachstatus_colorfade_current_x >= target_color_x + step)\r
-               stomachstatus_colorfade_current_x -= step;\r
-       else if(stomachstatus_colorfade_current_x <= target_color_x - step)\r
-               stomachstatus_colorfade_current_x += step;\r
-\r
-       if(stomachstatus_colorfade_current_y >= target_color_y + step)\r
-               stomachstatus_colorfade_current_y -= step;\r
-       else if(stomachstatus_colorfade_current_y <= target_color_y - step)\r
-               stomachstatus_colorfade_current_y += step;\r
-\r
-       if(stomachstatus_colorfade_current_z >= target_color_z + step)\r
-               stomachstatus_colorfade_current_z -= step;\r
-       else if(stomachstatus_colorfade_current_z <= target_color_z - step)\r
-               stomachstatus_colorfade_current_z += step;\r
-\r
-       return stomachstatus_colorfade_current;\r
-}\r
-\r
 void Sbar_Draw (void)\r
 {\r
        // vectors for top right, bottom right, bottom and bottom left corners\r
@@ -3202,7 +3214,7 @@ void Sbar_Draw (void)
 \r
                Sbar_Reset();\r
 \r
-               StomachStatus_ColorFade('0 0 0');\r
+               Sbar_ColorFade('0 0 0');\r
        }\r
        else\r
        {\r
@@ -3253,23 +3265,7 @@ void Sbar_Draw (void)
                                }\r
                        }\r
 \r
-                       vector hl_color;\r
-                       string hl_string;\r
-                       if(getstati(STAT_VORE_EATEN))\r
-                       {\r
-                               if(teamplay && (GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(player_localentnum - 1) || GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(spectatee_status - 1))) // same team\r
-                                       hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
-                               else\r
-                                       hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
-                               hl_string = "predator:";\r
-                       }\r
-                       else\r
-                       {\r
-                               hl_color = stov(cvar_string("sbar_stomachboard_color1"));\r
-                               hl_string = "self:";\r
-                       }\r
-                       drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(hl_color), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-                       drawstring(bottomleft - '-80 173 0', hl_string, '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', Sbar_ColorFade(Sbar_GetVoreColor()), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
                        float stomach_load, stomach_maxload; // shows the predator's stomach load when we are eaten, and ours otherwise\r
                        stomach_load = getstati(STAT_VORE_LOAD);\r
@@ -3308,6 +3304,7 @@ void Sbar_Draw (void)
                        hud_total_prey = 0;\r
                        pos = stov(cvar_string("hud_item_preylist_position"));\r
                        vector sz = stov(cvar_string("hud_item_preylist_scale"));\r
+                       vector dir = stov(cvar_string("hud_item_preylist_entry_spacing")) * 2;\r
                        for(pl = players.sort_next; pl; pl = pl.sort_next)\r
                        {\r
                                if(pl.team == COLOR_SPECTATOR)\r
@@ -3325,12 +3322,13 @@ void Sbar_Draw (void)
 \r
                                if(f)\r
                                {\r
-                                       if(l < cvar("hud_item_preylist_entries")) // limit the stomach board to the given number of entries\r
+                                       if(l < cvar("hud_item_preylist_entry_number")) // limit the stomach board to the given number of entries\r
                                        {\r
                                                Sbar_PrintStomachboardItem(pl, pos, sz);\r
 \r
-                                               // advance y position for each entry\r
-                                               pos_y += sz_y * cvar("hud_item_preylist_spacing");\r
+                                               // advance position for each entry\r
+                                               pos_x += sz_x * dir_x;\r
+                                               pos_y += sz_y * dir_y;\r
                                                l += 1;\r
                                        }\r
                                        ++hud_total_prey;\r