Package com.badlogic.gdx.utils

Examples of com.badlogic.gdx.utils.GdxRuntimeException


  /** @param fileName the asset file name
   * @param type the asset type
   * @return the asset */
  public synchronized <T> T get (String fileName, Class<T> type) {
    ObjectMap<String, RefCountedContainer> assetsByType = assets.get(type);
    if (assetsByType == null) throw new GdxRuntimeException("Asset '" + fileName + "' not loaded");
    RefCountedContainer assetContainer = assetsByType.get(fileName);
    if (assetContainer == null) throw new GdxRuntimeException("Asset '" + fileName + "' not loaded");
    T asset = assetContainer.getObject(type);
    if (asset == null) throw new GdxRuntimeException("Asset '" + fileName + "' not loaded");
    return asset;
  }
View Full Code Here


      }
    }
   
    // get the asset and its type
    Class type = assetTypes.get(fileName);
    if(type == null) throw new GdxRuntimeException("Asset '" + fileName + "' not loaded");
    RefCountedContainer assetRef = assets.get(type).get(fileName);

    // if it is reference counted, decrement ref count and check if we can really get rid of it.
    assetRef.decRefCount();
    if(assetRef.getRefCount() <= 0) {
View Full Code Here

   * @param fileName the file name (interpretation depends on {@link AssetLoader})
   * @param type the type of the asset.
   * @param parameter parameters for the AssetLoader. */
  public synchronized <T> void load (String fileName, Class<T> type, AssetLoaderParameters<T> parameter) {
    AssetLoader loader = loaders.get(type);
    if (loader == null) throw new GdxRuntimeException("No loader for type '" + type.getSimpleName() + "'");

    if (loadQueue.size == 0) {
      loaded = 0;
      toLoad = 0;
    }
   
    // check if an asset with the same name but a different type has already been added.
   
    // check preload queue
    for(int i = 0; i < loadQueue.size; i++) {
      AssetDescriptor desc = loadQueue.get(i);
      if(desc.fileName.equals(fileName) && !desc.type.equals(type)) throw new GdxRuntimeException("Asset with name '" + fileName + "' already in preload queue, but has different type (expected: " + type.getSimpleName() + ", found: " + desc.type.getSimpleName());
    }
   
    // check task list
    for(int i = 0; i < tasks.size(); i++) {
      AssetDescriptor desc = tasks.get(i).assetDesc;
      if(desc.fileName.equals(fileName) && !desc.type.equals(type)) throw new GdxRuntimeException("Asset with name '" + fileName + "' already in task list, but has different type (expected: " + type.getSimpleName() + ", found: " + desc.type.getSimpleName());
    }
   
    // check loaded assets
    Class otherType = assetTypes.get(fileName);
    if(otherType != null && !otherType.equals(type)) throw new GdxRuntimeException("Asset with name '" + fileName + "' already loaded, but has different type (expected: " + type.getSimpleName() + ", found: " + otherType.getSimpleName());
   
    toLoad++;
    AssetDescriptor assetDesc = new AssetDescriptor(fileName, type, parameter);
    loadQueue.add(assetDesc);
    log.log("Added asset '" + assetDesc + "' to preload queue");
View Full Code Here

  /** Adds a {@link AssetLoadingTask} to the task stack for the given asset.
   * @param assetDesc */
  private void addTask (AssetDescriptor assetDesc) {
    AssetLoader loader = loaders.get(assetDesc.type);
    if (loader == null) throw new GdxRuntimeException("No loader for type '" + assetDesc.type.getSimpleName() + "'");
    tasks.push(new AssetLoadingTask(this, assetDesc, loader, threadPool));
  }
View Full Code Here

  }

  /** Handles a runtime/loading error in {@link #update()} by optionally invoking the {@link AssetErrorListener}.
   * @param t */
  private void handleTaskError (Throwable t) {
    if (tasks.isEmpty()) throw new GdxRuntimeException(t);

    // pop the faulty task from the stack
    AssetLoadingTask task = tasks.pop();
    AssetDescriptor assetDesc = task.assetDesc;

    // remove all dependencies
    if (task.dependenciesLoaded && task.dependencies != null) {
      for (AssetDescriptor desc : task.dependencies) {
        unload(desc.fileName);
      }
    }

    // clear the rest of the stack
    tasks.clear();

    // inform the listener that something bad happened
    if (listener != null) {
      listener.error(assetDesc.fileName, assetDesc.type, t);
    } else {
      t.printStackTrace();
      throw new GdxRuntimeException(t);
    }
  }
View Full Code Here

    clear();
    threadPool.shutdown();
    try {
      threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
      new GdxRuntimeException("Couldn't shutdown loading thread");
    }
  }
View Full Code Here

   * Returns the reference count of an asset.
   * @param fileName
   */
  public synchronized int getReferenceCount(String fileName) {
    Class type = assetTypes.get(fileName);
    if(type == null) throw new GdxRuntimeException("Asset not loaded");
    return assets.get(type).get(fileName).getRefCount();
  }
View Full Code Here

   * Returns the reference count of an asset.
   * @param fileName
   */
  public synchronized void setReferenceCount(String fileName, int refCount) {
    Class type = assetTypes.get(fileName);
    if(type == null) throw new GdxRuntimeException("Asset not loaded");
    assets.get(type).get(fileName).setRefCount(refCount);
  }
View Full Code Here

      if (child instanceof Label) {
        ((Label)child).setText(text);
        return;
      }
    }
    throw new GdxRuntimeException("No child label was found.");
  }
View Full Code Here

  public String getText () {
    for (int i = 0; i < children.size(); i++) {
      Actor child = children.get(i);
      if (child instanceof Label) return ((Label)child).getText();
    }
    throw new GdxRuntimeException("No child label was found.");
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.utils.GdxRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.