Package gaiasky.util

Class GlobalResources

java.lang.Object
gaiasky.util.GlobalResources

public class GlobalResources extends Object
Holds and initialises resources utilised globally.
  • Field Details

    • shapeShader

      public static com.badlogic.gdx.graphics.glutils.ShaderProgram shapeShader
    • spriteShader

      public static com.badlogic.gdx.graphics.glutils.ShaderProgram spriteShader
    • spriteBatch

      public static com.badlogic.gdx.graphics.g2d.SpriteBatch spriteBatch
      Global all-purpose sprite batch
    • spriteBatchVR

      public static com.badlogic.gdx.graphics.g2d.SpriteBatch spriteBatchVR
      Global all-purpose sprite batch
    • extSpriteShader

      public static ExtShaderProgram extSpriteShader
    • extSpriteBatch

      public static ExtSpriteBatch extSpriteBatch
      Sprite batch using int indices
    • linkCursor

      public static com.badlogic.gdx.graphics.Cursor linkCursor
      Cursors
    • resizeXCursor

      public static com.badlogic.gdx.graphics.Cursor resizeXCursor
      Cursors
    • resizeYCursor

      public static com.badlogic.gdx.graphics.Cursor resizeYCursor
      Cursors
    • emptyCursor

      public static com.badlogic.gdx.graphics.Cursor emptyCursor
      Cursors
    • skin

      public static com.badlogic.gdx.scenes.scene2d.ui.Skin skin
      The global skin
  • Constructor Details

    • GlobalResources

      public GlobalResources()
  • Method Details

    • initialize

      public static void initialize(com.badlogic.gdx.assets.AssetManager manager)
    • updateSkin

      public static void updateSkin()
    • doneLoading

      public static void doneLoading(com.badlogic.gdx.assets.AssetManager manager)
    • doubleToDistanceString

      public static Pair<Double,​String> doubleToDistanceString(org.apfloat.Apfloat d)
    • doubleToDistanceString

      public static Pair<Double,​String> doubleToDistanceString(double d)
      Converts this double to the string representation of a distance
      Parameters:
      d - In internal units
      Returns:
      An array containing the float number and the string units
    • doubleToVelocityString

      public static Pair<Double,​String> doubleToVelocityString(double d)
      Converts the double to the string representation of a velocity (always in seconds)
      Parameters:
      d - In internal units
      Returns:
      Array containing the number and the units
    • floatToDistanceString

      public static Pair<Float,​String> floatToDistanceString(float f)
      Converts this float to the string representation of a distance
      Parameters:
      f - In internal units
      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

      public static boolean isInView(Vector3b point, double len, float coneAngle, Vector3d dir)
      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 length
      coneAngle - The cone angle of the camera
      dir - The direction
      Returns:
      True if the body is visible
    • isInView

      public static boolean isInView(Vector3d point, double len, float coneAngle, Vector3d dir)
      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 length
      coneAngle - The cone angle of the camera
      dir - The direction
      Returns:
      True if the body is visible
    • isAnyInView

      public static 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. Coordinates are assumed to be in the camera-origin system
      Parameters:
      points - The array of points to check
      coneAngle - 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

      public static boolean equal(String buf, char[] compareTo, boolean ignoreCase)
      Compares a given buffer with another buffer.
      Parameters:
      buf - Buffer to compare against
      compareTo - Buffer to compare to (content should be ASCII lowercase if possible)
      Returns:
      True if the buffers compare favourably, false otherwise
    • countOccurrences

      public static int countOccurrences(String haystack, char needle)
    • nthIndexOf

      public static int nthIndexOf(String text, char needle, int n)
    • listRec

      public static com.badlogic.gdx.utils.Array<Path> listRec(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 files
      l - The list with the results
      extensions - The allowed extensions
      Returns:
      The list l
    • deleteRecursively

      public static void deleteRecursively(Path path) throws IOException
      Deletes recursively all non-partial files from the path.
      Parameters:
      path - The path to delete.
      Throws:
      IOException
    • copyFile

      public static void copyFile(Path sourceFile, Path destFile, boolean ow) throws IOException
      Throws:
      IOException
    • listRec

      public static com.badlogic.gdx.utils.Array<Path> listRec(Path f, com.badlogic.gdx.utils.Array<Path> l, DirectoryStream.Filter<Path> filter)
    • fileCount

      public static long fileCount(Path dir) throws IOException
      Recursively count files in a directory
      Parameters:
      dir - The directory
      Returns:
      The number of files
      Throws:
      IOException
    • fileCount

      public static long fileCount(Path dir, String[] extensions) throws IOException
      Count files matching a certain ending in a directory, recursively
      Parameters:
      dir - The directory
      Returns:
      The number of files
      Throws:
      IOException
    • endsWith

      public static boolean endsWith(String s, String[] endings)
      Returns true if the string ends with any of the endings
      Parameters:
      s - The string
      endings - The endings
      Returns:
      True if the string ends with any of the endings
    • isNumeric

      public static boolean isNumeric(String str)
    • sortByValue

      public static <K,​ V extends Comparable<? super V>> Map<K,​V> sortByValue(Map<K,​V> map)
    • textureToPixmap

      public static com.badlogic.gdx.graphics.Pixmap textureToPixmap(com.badlogic.gdx.graphics.g2d.TextureRegion tex)
      Converts a texture to a pixmap by drawing it to a frame buffer and getting the data
      Parameters:
      tex - The texture to convert
      Returns:
      The resulting pixmap
    • invertMap

      public static final <T,​ U> Map<U,​List<T>> invertMap(Map<T,​U> map)
      Inverts a map
      Parameters:
      map - The map to invert
      Returns:
      The inverted map
    • 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

      public static Vector3d applyRelativisticAberration(Vector3d pos, ICamera cam)
    • humanReadableByteCount

      public static String humanReadableByteCount(long bytes, boolean si)
      Converts bytes to a human readable format
      Parameters:
      bytes - The bytes
      si - Whether to use SI units (1000-multiples) or binary (1024-multiples)
      Returns:
      The size in a human readable form
    • size

      public static long size(Path path) throws IOException
      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

      public static String[] parseWhitespaceSeparatedList(String str)
      Parses the string and creates a string array. The string is a list of whitespace-separated tokens, each surrounded by double qutotes '"': str = '"a" "bc" "d" "efghi"'
      Parameters:
      str - The string
      Returns:
      The resulting array
    • toWhitespaceSeparatedList

      public static String toWhitespaceSeparatedList(String[] l)
      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

      public static String toString(String[] l, String quote, String separator)
      Converts a string array into a string, optionally quoting each entry and with a given separator.
      Parameters:
      l - The list
      quote - The quote string to use
      separator - The separator
      Returns:
      The resulting string
    • unpackAssetPath

      public static String unpackAssetPath(String path, GlobalConf.SceneConf.GraphicsQuality gq)
    • unpackAssetPath

      public static String unpackAssetPath(String tex)
    • unpackSkyboxSide

      public static String unpackSkyboxSide(String skyboxLoc, String side) throws RuntimeException
      Throws:
      RuntimeException
    • getGLExtensions

      public static String getGLExtensions()
    • combinations

      public static String[] combinations(String[] values)
      Generates all combinations of all sizes of all the strings given in values
      Parameters:
      values - The input strings to combine
      Returns:
      The combinations
    • combination

      public static <T> List<List<T>> combination(List<T> values, int size)
      Generates all combinations of the given size using the elements in values.
      Type Parameters:
      T - The type
      Parameters:
      values - The elements to combine
      size - The size of the combinations
      Returns:
      The combinations
    • nObjectsToString

      public static String nObjectsToString(long objs)
    • msToTimeString

      public static String msToTimeString(long ms)