Class GlobalResources
java.lang.Object
gaiasky.util.GlobalResources
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Contains resources that don't change during the runtime of the application.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DecimalFormatDecimal format.static final DecimalFormatScientific format. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatangle2d(com.badlogic.gdx.math.Vector3 v1, com.badlogic.gdx.math.Vector3 v2) Gets the angle in degrees between the two vectorsstatic voidapplyRelativisticAberration(Vector3D pos, ICamera cam) static String[]combinations(String[] values) Generates all combinations of all sizes of all the strings given in values.static voidstatic intcountOccurrences(String haystack, char needle) static voiddeleteRecursively(Path path) Deletes recursively all non-partial files from the path, and all partial files older thanConstants.getPartFileMaxAgeMs().voiddispose()voiddoneLoading(com.badlogic.gdx.assets.AssetManager manager) doubleToDistanceString(double d, Settings.DistanceUnits du) Converts this double to the string representation of a distance.doubleToVelocityString(double d, Settings.DistanceUnits du) Converts the double to the string representation of a velocity (always in seconds).static booleanReturns true if the string ends with any of the endingsstatic booleanCompares a given buffer with another buffer.static StringformatNumber(double number) Formats a given double number.static Stringcom.badlogic.gdx.graphics.glutils.ShaderProgramcom.badlogic.gdx.scenes.scene2d.ui.SkingetSkin()com.badlogic.gdx.graphics.g2d.SpriteBatchcom.badlogic.gdx.graphics.glutils.ShaderProgramcom.badlogic.gdx.graphics.TexturegetTexture(String name) Gets a texture from the map by name.static StringhumanReadableByteCount(long bytes, boolean si) Converts bytes to a human-readable formatvoidinitialize(com.badlogic.gdx.assets.AssetManager manager) static booleanComputes whether a body with the given position is visible by a camera with the given direction and angle.static booleanComputes whether a body with the given position is visible by a camera with the given direction and angle.static booleanstatic voidlistRecursive(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 StringmsToTimeString(long ms) static StringnObjectsToString(long objects) static String[]Parses the string and creates a string array.voidresize(int width, int height) static StringresolveCubemapSide(String baseLocation, String... sideSuffixes) voidsetSkin(com.badlogic.gdx.scenes.scene2d.ui.Skin skin) static longAttempts 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 float[]toFloatArray(int[] array) Transforms the given integer array into a float array by casting each of its numbersstatic float[]toFloatArray(long[] array) Transforms the given long array into a float array by casting each of its numbersstatic StringConverts a string array into a string, optionally quoting each entry and with a given separator.static StringunpackAssetPath(String tex) static StringunpackAssetPath(String path, Settings.GraphicsQuality gq) static StringunpackAssetPath(String path, Settings.GraphicsQuality gq, String... extensions) static StringunpackAssetPathExtensions(String tex, String... extensions)
-
Field Details
-
nf
Decimal format. -
nfSci
Scientific format.
-
-
Constructor Details
-
GlobalResources
public GlobalResources()
-
-
Method Details
-
initialize
public void initialize(com.badlogic.gdx.assets.AssetManager manager) -
doneLoading
public void doneLoading(com.badlogic.gdx.assets.AssetManager manager) -
getTexture
Gets a texture from the map by name.- Parameters:
name- The texture name.- Returns:
- The texture.
-
formatNumber
Formats a given double number. Uses scientific notation for numbers in [-9999,9999], and regular numbers elsewhere.- Parameters:
number- The number to format.- Returns:
- The string representation.
-
doubleToDistanceString
Converts this double to the string representation of a distance.- Parameters:
d- Distance in internal units.du- 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- Velocity in internal units per second.du- The distance units to use.- Returns:
- Array containing the number and the 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
-
toFloatArray
public static float[] toFloatArray(long[] array) Transforms the given long array into a float array by casting each of its numbers- Parameters:
array- The array of longs- Returns:
- The array of floats
-
toFloatArray
public static float[] toFloatArray(int[] array) Transforms the given integer array into a float array by casting each of its numbers- Parameters:
array- The array of ints- 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
-
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
-
deleteRecursively
Deletes recursively all non-partial files from the path, and all partial files older thanConstants.getPartFileMaxAgeMs().- Parameters:
path- the path to delete.- Throws:
IOException- if an I/O error is thrown when accessing the starting file.
-
copyFile
- Throws:
IOException
-
endsWith
-
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
-
toString
-
unpackAssetPath
-
unpackAssetPath
public static String unpackAssetPath(String path, Settings.GraphicsQuality gq, String... extensions) -
unpackAssetPath
-
unpackAssetPathExtensions
-
resolveCubemapSide
public static String resolveCubemapSide(String baseLocation, String... sideSuffixes) throws RuntimeException - Throws:
RuntimeException
-
getGLExtensions
-
combinations
-
nObjectsToString
-
msToTimeString
-
getShapeShader
public com.badlogic.gdx.graphics.glutils.ShaderProgram getShapeShader() -
getSpriteShader
public com.badlogic.gdx.graphics.glutils.ShaderProgram getSpriteShader() -
getSpriteBatch
public com.badlogic.gdx.graphics.g2d.SpriteBatch getSpriteBatch() -
getExtSpriteBatch
-
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) -
dispose
public void dispose()- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable
-