Java Code Examples for com.badlogic.gdx.Application#LOG_DEBUG

The following examples show how to use com.badlogic.gdx.Application#LOG_DEBUG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GdxKeyMapper.java    From riiablo with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public int[] load(MappedKey key) {
  String alias = key.getAlias();
  String serializedValue = PREFERENCES.getString(alias);
  if (serializedValue == null || serializedValue.isEmpty()) return null;

  int[] assignments;
  try {
    assignments = IntArrayStringSerializer.INSTANCE.deserialize(serializedValue);
  } catch (SerializeException t) {
    Gdx.app.error(TAG, String.format("removing %s from preferences (invalid save format): %s", alias, t.getMessage()), t);
    PREFERENCES.remove(alias);
    PREFERENCES.flush();
    throw t;
  }

  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) {
    String[] keycodeNames = getKeycodeNames(assignments);
    Gdx.app.debug(TAG, String.format("%s [%s] loaded as %s (raw: \"%s\")",
        key.getName(), key.getAlias(), Arrays.toString(keycodeNames), serializedValue));
  }

  KEYS.put(alias.toLowerCase(), key);
  return assignments;
}
 
Example 2
Source File: GdxKeyMapper.java    From riiablo with Apache License 2.0 6 votes vote down vote up
@Override
public void save(MappedKey key) {
  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG && !isManaging(key)) {
    Gdx.app.debug(TAG, String.format("key %s is being saved by a key mapper not managing it", key));
  }

  int[] assignments = key.getAssignments();
  String serializedValue = IntArrayStringSerializer.INSTANCE.serialize(assignments);
  PREFERENCES.putString(key.getAlias(), serializedValue);
  PREFERENCES.flush();
  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) {
    String[] keycodeNames = getKeycodeNames(assignments);
    Gdx.app.debug(TAG, String.format("%s [%s] saved as %s (raw: \"%s\")",
        key.getName(), key.getAlias(), Arrays.toString(keycodeNames), serializedValue));
  }
}
 
Example 3
Source File: GdxCvarManager.java    From riiablo with Apache License 2.0 6 votes vote down vote up
@Override
public <T> void save(Cvar<T> cvar) {
  String alias = cvar.getAlias();
  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG && !isManaging(cvar)) {
    throw new CvarManagerException("%s must be managed by this CvarManager", alias);
  }

  StringSerializer<T> serializer = ObjectUtils.firstNonNull(cvar.getSerializer(), getSerializer(cvar));
  if (serializer == null) {
    throw new CvarManagerException("%s cannot be saved (no serializer found for %s)", alias, cvar.getType().getName());
  }

  T value = cvar.get();
  String serialization = serializer.serialize(value);
  PREFERENCES.putString(alias, serialization);
  PREFERENCES.flush();
  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) {
    Gdx.app.debug(TAG, String.format("%s saved as \"%s\" (raw: \"%s\")", alias, value, serialization));
  }
}
 
Example 4
Source File: GdxCvarManager.java    From riiablo with Apache License 2.0 6 votes vote down vote up
@Override
public <T> T load(Cvar<T> cvar) {
  String alias = cvar.getAlias();
  StringSerializer<T> serializer = ObjectUtils.firstNonNull(cvar.getSerializer(), getSerializer(cvar));
  if (serializer == null) {
    try {
      throw new CvarManagerException("%s cannot be loaded (no deserializer found for %s)", alias, cvar.getType().getName());
    } finally {
      return cvar.getDefault();
    }
  }

  String serialization = PREFERENCES.getString(alias, null);
  if (serialization == null) return cvar.getDefault();

  T deserialization = serializer.deserialize(serialization);
  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) {
    Gdx.app.debug(TAG, String.format("%s loaded as \"%s\" [%s] (raw: \"%s\")",
        alias, deserialization, deserialization.getClass().getName(), serialization));
  }

  return deserialization;
}
 
Example 5
Source File: MusicController.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public void next() {
  stop();
  if (PLAYLIST.isEmpty()) {
    return;
  }

  this.asset = PLAYLIST.removeFirst();
  ASSETS.load(asset, Music.class);
  ASSETS.finishLoadingAsset(asset);
  this.track = ASSETS.get(asset, Music.class);
  track.setOnCompletionListener(this);
  track.play();
  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) {
    Gdx.app.debug(TAG, "Now playing \"" + asset + "\"");
  }
}
 
Example 6
Source File: GpgsClient.java    From gdx-gamesvcs with Apache License 2.0 5 votes vote down vote up
/**
 * Gdx to Log4j log level mapping
 */
private static Level getLogLevel(int logLevel) {
    switch (logLevel) {
        case Application.LOG_NONE:
            return Level.OFF;
        case Application.LOG_ERROR:
            return Level.SEVERE;
        case Application.LOG_INFO:
            return Level.INFO;
        case Application.LOG_DEBUG:
            return Level.FINEST;
        default:
            return Level.ALL;
    }
}
 
Example 7
Source File: GdxKeyMapper.java    From riiablo with Apache License 2.0 5 votes vote down vote up
@Override
public void onAssigned(MappedKey key, int assignment, int keycode) {
  super.onAssigned(key, assignment, keycode);
  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) {
    Gdx.app.debug(TAG, String.format("assigned [%s] to [%s]", Input.Keys.toString(keycode), key.getAlias()));
  }
}
 
Example 8
Source File: GdxKeyMapper.java    From riiablo with Apache License 2.0 5 votes vote down vote up
@Override
public void onUnassigned(MappedKey key, int assignment, int keycode) {
  super.onUnassigned(key, assignment, keycode);
  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) {
    Gdx.app.debug(TAG, String.format("unassigned [%s] from [%s]", Input.Keys.toString(keycode), key.getAlias()));
  }
}
 
Example 9
Source File: GdxCvarManager.java    From riiablo with Apache License 2.0 5 votes vote down vote up
@Override
public void onChanged(Cvar cvar, Object from, Object to) {
  if (Gdx.app.getLogLevel() >= Application.LOG_DEBUG) {
    Gdx.app.debug(TAG, String.format("%s changed from %s to %s", cvar.getAlias(), from, to));
  }

  super.onChanged(cvar, from, to);
}
 
Example 10
Source File: EngineLogger.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public static void toggle() {
	if (level == Application.LOG_DEBUG)
		level = Application.LOG_ERROR;
	else
		level = Application.LOG_DEBUG;

	Gdx.app.setLogLevel(level);
}
 
Example 11
Source File: EngineLogger.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public static boolean debugMode() {
	if (level == Application.LOG_DEBUG)
		return true;

	return false;
}
 
Example 12
Source File: EngineLogger.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public static void setDebug() {
	level = Application.LOG_DEBUG;

	Gdx.app.setLogLevel(level);
}