From 605bd6f7f2e935c6703ddfa5f216529f82186bc3 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Mon, 21 Jan 2019 00:12:51 -0800 Subject: [PATCH] Added Textures class to store some common solid color textures --- core/src/gdx/diablo/Client.java | 4 ++++ core/src/gdx/diablo/Diablo.java | 1 + core/src/gdx/diablo/Textures.java | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 core/src/gdx/diablo/Textures.java diff --git a/core/src/gdx/diablo/Client.java b/core/src/gdx/diablo/Client.java index 832b611a..884743a2 100644 --- a/core/src/gdx/diablo/Client.java +++ b/core/src/gdx/diablo/Client.java @@ -99,6 +99,7 @@ public class Client extends Game { private Colors colors; private Cursor cursor; private Audio audio; + private Textures textures; private boolean forceWindowed; private boolean forceDrawFps; @@ -219,6 +220,7 @@ public class Client extends Game { Diablo.colors = colors = new Colors(); Diablo.cursor = cursor = new Cursor(); Diablo.audio = audio = new Audio(assets); + Diablo.textures = textures = new Textures(); Collection throwables; Diablo.commands = commands = new GdxCommandManager(); @@ -426,6 +428,7 @@ public class Client extends Game { Diablo.colors = colors; Diablo.cursor = cursor; Diablo.audio = audio; + Diablo.textures = textures; super.resume(); } @@ -458,6 +461,7 @@ public class Client extends Game { Gdx.app.debug(TAG, "Disposing assets..."); palettes.dispose(); colormaps.dispose(); + textures.dispose(); assets.dispose(); try { diff --git a/core/src/gdx/diablo/Diablo.java b/core/src/gdx/diablo/Diablo.java index 852b13bd..a291b622 100644 --- a/core/src/gdx/diablo/Diablo.java +++ b/core/src/gdx/diablo/Diablo.java @@ -48,4 +48,5 @@ public class Diablo { public static DT1s dt1s; public static Cursor cursor; public static Audio audio; + public static Textures textures; } diff --git a/core/src/gdx/diablo/Textures.java b/core/src/gdx/diablo/Textures.java new file mode 100644 index 00000000..c2c0b52d --- /dev/null +++ b/core/src/gdx/diablo/Textures.java @@ -0,0 +1,28 @@ +package gdx.diablo; + +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.utils.Disposable; + +public class Textures implements Disposable { + public final Texture white; + + public Textures() { + white = createTexture(Diablo.colors.white); + } + + public Texture createTexture(Color color) { + Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); + pixmap.setColor(color); + pixmap.fill(); + Texture texture = new Texture(pixmap); + pixmap.dispose(); + return texture; + } + + @Override + public void dispose() { + white.dispose(); + } +}