]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/miscfunctions.qc
Merge branch 'master' into terencehill/centerprint_stuff
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / miscfunctions.qc
index b351ca6bf116c26c720c40d87ae98f4ee1360dcb..7301fbf0bbf2922fa30b14f83c487e770239da5e 100644 (file)
@@ -8,7 +8,7 @@ void serverAnnouncer()
        // check for pending announcement, play it and remove it
        if(announce_snd != "")
        {
-               sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/", announce_snd, ".wav"), VOL_BASEVOICE, ATTN_NONE);
+               sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/", announce_snd, ".wav"), VOL_BASEVOICE, ATTN_NONE);
                strunzone(announce_snd);
                announce_snd = "";
        }
@@ -20,9 +20,9 @@ void restartAnnouncer_Think() {
        countdown_rounded = floor(0.5 + countdown);
        if(countdown <= 0) {
                if (!spectatee_status) //do cprint only for players
-                       centerprint("^1Begin!");
+                       centerprint_generic(CPID_GAME_STARTING, _("^1Begin!"), 1, 0);
 
-               sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/begin.wav"), VOL_BASEVOICE, ATTN_NONE);
+               sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/begin.wav"), VOL_BASEVOICE, ATTN_NONE);
                //reset maptime announcers now as well
                announcer_5min = announcer_1min = FALSE;
 
@@ -31,10 +31,10 @@ void restartAnnouncer_Think() {
        }
        else {
                if (!spectatee_status) //do cprint only for players
-                       centerprint(strcat("^1Game starts in ", ftos(countdown_rounded), " seconds"));
+                       centerprint_generic(CPID_GAME_STARTING, _("^1Game starts in %d seconds"), 1, countdown_rounded);
 
                if(countdown_rounded <= 3 && countdown_rounded >= 1) {
-                       sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE);
+                       sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE);
                }
 
                self.nextthink = getstatf(STAT_GAMESTARTTIME) - (countdown - 1);
@@ -71,8 +71,7 @@ void maptimeAnnouncer() {
                        //if we're in warmup mode, check whether there's a warmup timelimit
                        if not (warmuplimit == -1 && warmup_stage) {
                                announcer_5min = TRUE;
-                               //dprint("i will play the sound, I promise!\n");
-                               sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/5minutesremain.wav"), VOL_BASEVOICE, ATTN_NONE);
+                               sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/5minutesremain.wav"), VOL_BASEVOICE, ATTN_NONE);
                        }
        }
 
@@ -87,7 +86,7 @@ void maptimeAnnouncer() {
                        //if we're in warmup mode, check whether there's a warmup timelimit
                        if not (warmuplimit == -1 && warmup_stage) {
                                announcer_1min = TRUE;
-                               sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/1minuteremains.wav"), VOL_BASEVOICE, ATTN_NONE);
+                               sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/1minuteremains.wav"), VOL_BASEVOICE, ATTN_NONE);
                        }
        }
 }
@@ -111,12 +110,12 @@ void carrierAnnouncer() {
        blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
 
        if (redflag == 3 && redflag != redflag_prev) {
-               item = "^1RED^7 flag";
+               item = _("^1RED^7 flag");
                pickup = (redflag_prev == 2);
        }
 
        if (blueflag == 3 && blueflag != blueflag_prev) {
-               item = "^4BLUE^7 flag";
+               item = _("^4BLUE^7 flag");
                pickup = (blueflag_prev == 2);
        }
 
@@ -124,11 +123,11 @@ void carrierAnnouncer() {
        {
                if (pickup) {
                        if (autocvar_cl_notify_carried_items & 2)
-                               centerprint(strcat("You picked up the ", item, "!"));
+                               centerprint(sprintf(_("You picked up the %s!"), item));
                }
                else {
                        if (autocvar_cl_notify_carried_items & 1)
-                               centerprint(strcat("You got the ", item, "!"));
+                               centerprint(sprintf(_("You got the %s!"), item));
                }
        }
 
@@ -281,7 +280,7 @@ void RemoveTeam(entity Team)
 
        if(!tm)
        {
-               print("Trying to remove a team which is not in the teamlist!");
+               print(_("Trying to remove a team which is not in the teamlist!"));
                return;
        }
        parent.sort_next = Team.sort_next;
@@ -306,12 +305,6 @@ entity GetTeam(float Team, float add)
        return tm;
 }
 
-void CSQC_CheckEngine()
-{
-       hud_font = FONT_USER+1;
-       hud_bigfont = FONT_USER+2;
-}
-
 vector HUD_GetFontsize(string cvarname)
 {
        vector v;
@@ -326,40 +319,14 @@ vector HUD_GetFontsize(string cvarname)
 
 float PreviewExists(string name)
 {
-       float f;
-       string file;
-
        if(autocvar_cl_readpicture_force)
                return false;
 
-       file = strcat(name, ".tga");
-       f = fopen(file, FILE_READ);
-       if(f >= 0)
-       {
-               fclose(f);
-               return true;
-       }
-       file = strcat(name, ".png");
-       f = fopen(file, FILE_READ);
-       if(f >= 0)
-       {
-               fclose(f);
-               return true;
-       }
-       file = strcat(name, ".jpg");
-       f = fopen(file, FILE_READ);
-       if(f >= 0)
-       {
-               fclose(f);
-               return true;
-       }
-       file = strcat(name, ".pcx");
-       f = fopen(file, FILE_READ);
-       if(f >= 0)
-       {
-               fclose(f);
-               return true;
-       }
+       if (fexists(strcat(name, ".tga"))) return true;
+       if (fexists(strcat(name, ".png"))) return true;
+       if (fexists(strcat(name, ".jpg"))) return true;
+       if (fexists(strcat(name, ".pcx"))) return true;
+
        return false;
 }
 
@@ -382,6 +349,33 @@ string ColorTranslateRGB(string s)
                return s;
 }
 
+string Team_ColorCode(float teamid)
+{
+    if (teamid == COLOR_TEAM1)
+        return "^1";
+    else if (teamid == COLOR_TEAM2)
+        return "^4";
+    else if (teamid == COLOR_TEAM3)
+        return "^3";
+    else if (teamid == COLOR_TEAM4)
+        return "^6";
+    else
+        return "^7";
+}
+
+// decolorizes and team colors the player name when needed
+string playername(string thename, float teamid)
+{
+    string t;
+    if (teamplay)
+    {
+        t = Team_ColorCode(teamid);
+        return strcat(t, strdecolorize(thename));
+    }
+    else
+        return strdecolorize(thename);
+}
+
 float cvar_or(string cv, float v)
 {
        string s;
@@ -508,7 +502,7 @@ void drawpic_aspect_skin_expanding(vector position, string pic, vector scale, ve
        float sz;
        sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
 
-       drawpic_skin(position + expandingbox_resize_centered_box_offset(sz, scale, 1), pic, scale * sz, rgb, alpha * (1 - fadelerp), flag);
+       drawpic_aspect_skin(position + expandingbox_resize_centered_box_offset(sz, scale, 1), pic, scale * sz, rgb, alpha * (1 - fadelerp), flag);
 }
 
 void drawpic_aspect_skin_expanding_two(vector position, string pic, vector scale, vector rgb, float alpha, float flag, float fadelerp)
@@ -757,3 +751,20 @@ void DrawCircleClippedPic(vector centre, float radius, string pic, float f, vect
                R_EndPolygon();
        }
 }
+
+const vector GETPLAYERORIGIN_ERROR = '1123581321 2357111317 3141592653'; // way out of bounds for anything on the map
+vector getplayerorigin(float pl)
+{
+       string s;
+       entity e;
+
+       s = getplayerkey(pl, "TEMPHACK_origin");
+       if(s != "")
+               return stov(s);
+
+       e = entcs_receiver[pl];
+       if(e)
+               return e.origin;
+
+       return GETPLAYERORIGIN_ERROR;
+}