Package gaiasky.util
Class GlobalResources
java.lang.Object
gaiasky.util.GlobalResources
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
angle2d
(com.badlogic.gdx.math.Vector3 v1, com.badlogic.gdx.math.Vector3 v2) Gets the angle in degrees between the two vectorsstatic Vector3d
applyRelativisticAberration
(Vector3d pos, ICamera cam) combination
(List<T> values, int size) Generates all combinations of the given size using the elements in values.static String[]
combinations
(String[] values) Generates all combinations of all sizes of all the strings given in values.static void
static int
countOccurrences
(String haystack, char needle) static void
deleteRecursively
(Path path) Deletes recursively all non-partial files from the path, and all partial files older thanConstants.PART_FILE_MAX_AGE_MS
.static void
doneLoading
(com.badlogic.gdx.assets.AssetManager manager) doubleToDistanceString
(double d, Settings.DistanceUnits du) Converts this double to the string representation of a distancedoubleToDistanceString
(org.apfloat.Apfloat d, Settings.DistanceUnits du) doubleToVelocityString
(double d, Settings.DistanceUnits du) Converts the double to the string representation of a velocity (always in seconds)static boolean
Returns true if the string ends with any of the endingsstatic boolean
Compares a given buffer with another buffer.static long
Recursively count files in a directorystatic long
Count files matching a certain ending in a directory, recursivelyfloatToDistanceString
(float f, Settings.DistanceUnits du) Converts this float to the string representation of a distancecom.badlogic.gdx.graphics.Cursor
static String
com.badlogic.gdx.graphics.Cursor
com.badlogic.gdx.graphics.Cursor
com.badlogic.gdx.graphics.Cursor
com.badlogic.gdx.graphics.glutils.ShaderProgram
com.badlogic.gdx.scenes.scene2d.ui.Skin
getSkin()
com.badlogic.gdx.graphics.g2d.SpriteBatch
com.badlogic.gdx.graphics.glutils.ShaderProgram
static String
humanReadableByteCount
(long bytes, boolean si) Converts bytes to a human-readable formatstatic boolean
isAnyInView
(Vector3d[] points, float coneAngle, Vector3d dir) Computes whether any of the given points is visible by a camera with the given direction and the given cone angle.static boolean
Computes whether a body with the given position is visible by a camera with the given direction and angle.static boolean
Computes whether a body with the given position is visible by a camera with the given direction and angle.static boolean
static com.badlogic.gdx.utils.Array
<Path> listRecursive
(Path f, com.badlogic.gdx.utils.Array<Path> l, String... extensions) Gets all the files with the given extension in the given path f.static com.badlogic.gdx.utils.Array
<Path> listRecursive
(Path f, com.badlogic.gdx.utils.Array<Path> l, DirectoryStream.Filter<Path> filter) static String
msToTimeString
(long ms) static String
nObjectsToString
(long objects) static String[]
Parses the string and creates a string array.void
void
resize
(int width, int height) static String
resolveCubemapSide
(String baseLocation, String... sideSuffixes) void
setEmptyCursor
(com.badlogic.gdx.graphics.Cursor emptyCursor) void
setLinkCursor
(com.badlogic.gdx.graphics.Cursor linkCursor) void
setResizeXCursor
(com.badlogic.gdx.graphics.Cursor resizeXCursor) void
setResizeYCursor
(com.badlogic.gdx.graphics.Cursor resizeYCursor) void
setShapeShader
(com.badlogic.gdx.graphics.glutils.ShaderProgram shapeShader) void
setSkin
(com.badlogic.gdx.scenes.scene2d.ui.Skin skin) static long
Attempts to calculate the size of a file or directory.static <K,
V extends Comparable<? super V>>
Map<K, V> sortByValue
(Map<K, V> map) static float[]
toFloatArray
(double[] array) Transforms the given double array into a float array by casting each of its numbersstatic String
Converts a string array into a string, optionally quoting each entry and with a given separator.static String
Converts the string array into a whitespace-separated string where each element is double-quoted.static String
unpackAssetPath
(String tex) static String
unpackAssetPath
(String path, Settings.GraphicsQuality gq) void
-
Constructor Details
-
GlobalResources
public GlobalResources(com.badlogic.gdx.assets.AssetManager manager)
-
-
Method Details
-
doneLoading
public static void doneLoading(com.badlogic.gdx.assets.AssetManager manager) -
doubleToDistanceString
public static Pair<Double,String> doubleToDistanceString(org.apfloat.Apfloat d, Settings.DistanceUnits du) -
doubleToDistanceString
Converts this double to the string representation of a distance- Parameters:
d
- Distance in internal unitsdu
- The distance units to use- Returns:
- An array containing the float number and the string units
-
doubleToVelocityString
Converts the double to the string representation of a velocity (always in seconds)- Parameters:
d
- Distance in internal unitsdu
- The distance units to use- Returns:
- Array containing the number and the units
-
floatToDistanceString
Converts this float to the string representation of a distance- Parameters:
f
- Distance in internal unitsdu
- The distance units to use- Returns:
- An array containing the float number and the string units
-
toFloatArray
public static float[] toFloatArray(double[] array) Transforms the given double array into a float array by casting each of its numbers- Parameters:
array
- The array of doubles- Returns:
- The array of floats
-
isInView
Computes whether a body with the given position is visible by a camera with the given direction and angle. Coordinates are assumed to be in the camera-origin system- Parameters:
point
- The position of the body in the reference system of the camera (i.e. camera is at origin)len
- The point lengthconeAngle
- The cone angle of the cameradir
- The direction- Returns:
- True if the body is visible
-
isInView
Computes whether a body with the given position is visible by a camera with the given direction and angle. Coordinates are assumed to be in the camera-origin system- Parameters:
point
- The position of the body in the reference system of the camera (i.e. camera is at origin)len
- The point lengthconeAngle
- The cone angle of the cameradir
- The direction- Returns:
- True if the body is visible
-
isAnyInView
Computes whether any of the given points is visible by a camera with the given direction and the given cone angle. Coordinates are assumed to be in the camera-origin system- Parameters:
points
- The array of points to checkconeAngle
- The cone angle of the camera (field of view)dir
- The direction- Returns:
- True if any of the points is in the camera view cone
-
equal
Compares a given buffer with another buffer.- Parameters:
buf
- Buffer to compare againstcompareTo
- Buffer to compare to (content should be ASCII lowercase if possible)- Returns:
- True if the buffers compare favourably, false otherwise
-
countOccurrences
-
listRecursive
public static com.badlogic.gdx.utils.Array<Path> listRecursive(Path f, com.badlogic.gdx.utils.Array<Path> l, String... extensions) Gets all the files with the given extension in the given path f.- Parameters:
f
- The directory to get all the filesl
- The list with the resultsextensions
- The allowed extensions- Returns:
- The list l
-
deleteRecursively
Deletes recursively all non-partial files from the path, and all partial files older thanConstants.PART_FILE_MAX_AGE_MS
.- Parameters:
path
- the path to delete.- Throws:
IOException
- if an I/O error is thrown when accessing the starting file.
-
copyFile
- Throws:
IOException
-
listRecursive
public static com.badlogic.gdx.utils.Array<Path> listRecursive(Path f, com.badlogic.gdx.utils.Array<Path> l, DirectoryStream.Filter<Path> filter) -
fileCount
Recursively count files in a directory- Parameters:
dir
- The directory- Returns:
- The number of files
- Throws:
IOException
- if an I/O error is thrown when accessing the starting file.
-
fileCount
Count files matching a certain ending in a directory, recursively- Parameters:
dir
- The directory- Returns:
- The number of files
- Throws:
IOException
- if an I/O error is thrown when accessing the starting file.
-
endsWith
Returns true if the string ends with any of the endings- Parameters:
s
- The stringendings
- The endings- Returns:
- True if the string ends with any of the endings
-
isNumeric
-
sortByValue
-
angle2d
public static float angle2d(com.badlogic.gdx.math.Vector3 v1, com.badlogic.gdx.math.Vector3 v2) Gets the angle in degrees between the two vectors -
applyRelativisticAberration
-
humanReadableByteCount
Converts bytes to a human-readable format- Parameters:
bytes
- The bytessi
- Whether to use SI units (1000-multiples) or binary (1024-multiples)- Returns:
- The size in a human-readable form
-
size
Attempts to calculate the size of a file or directory.Since the operation is non-atomic, the returned value may be inaccurate. However, this method is quick and does its best.
- Throws:
IOException
-
parseWhitespaceSeparatedList
Parses the string and creates a string array. The string is a list of whitespace-separated tokens, each surrounded by double quotes '"': str = '"a" "bc" "d" "efghi"'- Parameters:
str
- The string- Returns:
- The resulting array
-
toWhitespaceSeparatedList
Converts the string array into a whitespace-separated string where each element is double-quoted.- Parameters:
l
- The string array- Returns:
- The resulting string
-
toString
Converts a string array into a string, optionally quoting each entry and with a given separator.- Parameters:
l
- The listquote
- The quote string to useseparator
- The separator- Returns:
- The resulting string
-
unpackAssetPath
-
unpackAssetPath
-
resolveCubemapSide
public static String resolveCubemapSide(String baseLocation, String... sideSuffixes) throws RuntimeException - Throws:
RuntimeException
-
getGLExtensions
-
combinations
Generates all combinations of all sizes of all the strings given in values.- Parameters:
values
- The input strings to combine.- Returns:
- The resulting combinations.
-
combination
Generates all combinations of the given size using the elements in values.- Type Parameters:
T
- The type- Parameters:
values
- The elements to combinesize
- The size of the combinations- Returns:
- The combinations
-
nObjectsToString
-
msToTimeString
-
reloadDataFiles
public void reloadDataFiles() -
updateSkin
public void updateSkin() -
getShapeShader
public com.badlogic.gdx.graphics.glutils.ShaderProgram getShapeShader() -
setShapeShader
public void setShapeShader(com.badlogic.gdx.graphics.glutils.ShaderProgram shapeShader) -
getSpriteShader
public com.badlogic.gdx.graphics.glutils.ShaderProgram getSpriteShader() -
getSpriteBatch
public com.badlogic.gdx.graphics.g2d.SpriteBatch getSpriteBatch() -
getExtSpriteShader
-
getExtSpriteBatch
-
getLinkCursor
public com.badlogic.gdx.graphics.Cursor getLinkCursor() -
setLinkCursor
public void setLinkCursor(com.badlogic.gdx.graphics.Cursor linkCursor) -
getResizeXCursor
public com.badlogic.gdx.graphics.Cursor getResizeXCursor() -
setResizeXCursor
public void setResizeXCursor(com.badlogic.gdx.graphics.Cursor resizeXCursor) -
getResizeYCursor
public com.badlogic.gdx.graphics.Cursor getResizeYCursor() -
setResizeYCursor
public void setResizeYCursor(com.badlogic.gdx.graphics.Cursor resizeYCursor) -
getEmptyCursor
public com.badlogic.gdx.graphics.Cursor getEmptyCursor() -
setEmptyCursor
public void setEmptyCursor(com.badlogic.gdx.graphics.Cursor emptyCursor) -
getSkin
public com.badlogic.gdx.scenes.scene2d.ui.Skin getSkin() -
setSkin
public void setSkin(com.badlogic.gdx.scenes.scene2d.ui.Skin skin) -
resize
public void resize(int width, int height)
-