|
|
@ -19,30 +19,18 @@ import mightypork.gamecore.graphics.textures.TxSheet; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final class Res { |
|
|
|
public final class Res { |
|
|
|
|
|
|
|
|
|
|
|
private static TextureRegistry textures; |
|
|
|
private static TextureRegistry textures = new TextureRegistry(); |
|
|
|
private static SoundRegistry sounds; |
|
|
|
private static SoundRegistry sounds = new SoundRegistry(); |
|
|
|
private static FontRegistry fonts; |
|
|
|
private static FontRegistry fonts = new FontRegistry(); |
|
|
|
|
|
|
|
|
|
|
|
private static boolean initialized = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Load on behalf of given base app |
|
|
|
* Get a texture by key |
|
|
|
* |
|
|
|
* |
|
|
|
* @param app app access |
|
|
|
* @param key the key |
|
|
|
|
|
|
|
* @return texture |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static void init() |
|
|
|
public static ITexture texture(String key) |
|
|
|
{ |
|
|
|
|
|
|
|
if (initialized) return; |
|
|
|
|
|
|
|
initialized = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
textures = new TextureRegistry(); |
|
|
|
|
|
|
|
sounds = new SoundRegistry(); |
|
|
|
|
|
|
|
fonts = new FontRegistry(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static ITexture getTexture(String key) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return textures.getTexture(key); |
|
|
|
return textures.getTexture(key); |
|
|
|
} |
|
|
|
} |
|
|
@ -51,10 +39,10 @@ public final class Res { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get a texture sheet by key |
|
|
|
* Get a texture sheet by key |
|
|
|
* |
|
|
|
* |
|
|
|
* @param key |
|
|
|
* @param key the key |
|
|
|
* @return sheet |
|
|
|
* @return sheet |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static TxSheet getTxSheet(String key) |
|
|
|
public static TxSheet txSheet(String key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return textures.getSheet(key); |
|
|
|
return textures.getSheet(key); |
|
|
|
} |
|
|
|
} |
|
|
@ -63,38 +51,94 @@ public final class Res { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get a texture quad by key |
|
|
|
* Get a texture quad by key |
|
|
|
* |
|
|
|
* |
|
|
|
* @param key |
|
|
|
* @param key the key |
|
|
|
* @return quad |
|
|
|
* @return quad |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static TxQuad getTxQuad(String key) |
|
|
|
public static TxQuad txQuad(String key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return textures.getQuad(key); |
|
|
|
return textures.getQuad(key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static LoopPlayer getSoundLoop(String key) |
|
|
|
/** |
|
|
|
|
|
|
|
* Get a sound loop player by key |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param key the key |
|
|
|
|
|
|
|
* @return loop player |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static LoopPlayer loop(String key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return sounds.getLoop(key); |
|
|
|
return sounds.getLoop(key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static EffectPlayer getSoundEffect(String key) |
|
|
|
/** |
|
|
|
|
|
|
|
* Get a sound effect player by key |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param key the key |
|
|
|
|
|
|
|
* @return effect player |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static EffectPlayer sound(String key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return sounds.getEffect(key); |
|
|
|
return sounds.getEffect(key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static IFont getFont(String key) |
|
|
|
/** |
|
|
|
|
|
|
|
* Get a font by key |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param key the key |
|
|
|
|
|
|
|
* @return font |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static IFont font(String key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return fonts.getFont(key); |
|
|
|
return fonts.getFont(key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void load(ResourceSetup binder) |
|
|
|
/** |
|
|
|
|
|
|
|
* Get internal texture registry |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return registry |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static TextureRegistry getTextureRegistry() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return textures; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get internal font registry |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return registry |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static FontRegistry getFontRegistry() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return fonts; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get internal sound registry |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return registry |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static SoundRegistry getSoundRegistry() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return sounds; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Load resources by a resource initializer. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param initializer the resource initializer |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static void load(ResourceInitializer initializer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
binder.addFonts(fonts); |
|
|
|
initializer.addFonts(fonts); |
|
|
|
binder.addTextures(textures); |
|
|
|
initializer.addTextures(textures); |
|
|
|
binder.addSounds(sounds); |
|
|
|
initializer.addSounds(sounds); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|