Custom background renderer support for mods
This commit is contained in:
@@ -50,6 +50,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
/** minZoom = zooming out, maxZoom = zooming in */
|
/** minZoom = zooming out, maxZoom = zooming in */
|
||||||
public float minZoom = 1.5f, maxZoom = 6f;
|
public float minZoom = 1.5f, maxZoom = 6f;
|
||||||
public Seq<EnvRenderer> envRenderers = new Seq<>();
|
public Seq<EnvRenderer> envRenderers = new Seq<>();
|
||||||
|
public ObjectMap<String, Runnable> customBackgrounds = new ObjectMap<>();
|
||||||
public TextureRegion[] bubbles = new TextureRegion[16], splashes = new TextureRegion[12];
|
public TextureRegion[] bubbles = new TextureRegion[16], splashes = new TextureRegion[12];
|
||||||
|
|
||||||
private @Nullable CoreBuild landCore;
|
private @Nullable CoreBuild landCore;
|
||||||
@@ -90,6 +91,10 @@ public class Renderer implements ApplicationListener{
|
|||||||
envRenderers.add(new EnvRenderer(mask, render));
|
envRenderers.add(new EnvRenderer(mask, render));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCustomBackground(String name, Runnable render){
|
||||||
|
customBackgrounds.put(name, render);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
planets = new PlanetRenderer();
|
planets = new PlanetRenderer();
|
||||||
@@ -386,6 +391,10 @@ public class Renderer implements ApplicationListener{
|
|||||||
Draw.rect(Draw.wrap(backgroundBuffer.getTexture()), camera.position.x, camera.position.y, drawSize, -drawSize);
|
Draw.rect(Draw.wrap(backgroundBuffer.getTexture()), camera.position.x, camera.position.y, drawSize, -drawSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(state.rules.customBackgroundCallback != null && customBackgrounds.containsKey(state.rules.customBackgroundCallback)){
|
||||||
|
customBackgrounds.get(state.rules.customBackgroundCallback).run();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateLandParticles(){
|
void updateLandParticles(){
|
||||||
|
|||||||
@@ -122,6 +122,8 @@ public class Rules{
|
|||||||
public boolean borderDarkness = true;
|
public boolean borderDarkness = true;
|
||||||
/** special tags for additional info. */
|
/** special tags for additional info. */
|
||||||
public StringMap tags = new StringMap();
|
public StringMap tags = new StringMap();
|
||||||
|
/** Name of callback to call for background rendering in mods; see Renderer#addCustomBackground. Runs last. */
|
||||||
|
public @Nullable String customBackgroundCallback;
|
||||||
/** path to background texture with extension (e.g. "sprites/space.png")*/
|
/** path to background texture with extension (e.g. "sprites/space.png")*/
|
||||||
public @Nullable String backgroundTexture;
|
public @Nullable String backgroundTexture;
|
||||||
/** background texture move speed scaling - bigger numbers mean slower movement */
|
/** background texture move speed scaling - bigger numbers mean slower movement */
|
||||||
|
|||||||
Reference in New Issue
Block a user