]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/string.qh
Purge other from blocked
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / string.qh
index 380afb9eeccdbf8a52818efdb5ae29e71fa904f3..2ade29691280beb373c05170f00b9e8d47667190 100644 (file)
@@ -4,7 +4,18 @@
 #include "sort.qh"
 #include "oo.qh"
 
-#ifndef SVQC
+#ifdef CSQC
+       float stringwidth_colors(string s, vector theSize)
+       {
+               return stringwidth_builtin(s, true, theSize);
+       }
+
+       float stringwidth_nocolors(string s, vector theSize)
+       {
+               return stringwidth_builtin(s, false, theSize);
+       }
+#endif
+#ifdef MENUQC
        float stringwidth_colors(string s, vector theSize)
        {
                return stringwidth(s, true, theSize);
@@ -286,22 +297,17 @@ string ftos_decimals(float number, int decimals)
 {
        // inhibit stupid negative zero
        if (number == 0) number = 0;
-       // we have sprintf...
        return sprintf("%.*f", decimals, number);
 }
 
-// strips trailing 0s from a float number, e.g. 1.200000 -> 1.2
+/**
+ * converts a number to a string with the minimum number of decimals
+ */
 string ftos_mindecimals(float number)
 {
-       string s = ftos(number);
-       int k = strstrofs(s, ".", 0);
-       if(k >= 0)
-       {
-               int i = strlen(s);
-               while(substring(s, i - 1, 1) == "0") i--;
-               s = substring(s, 0, i);
-       }
-       return s;
+       // inhibit stupid negative zero
+       if (number == 0) number = 0;
+       return sprintf("%.7g", number);
 }
 
 int vercmp_recursive(string v1, string v2)