mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
labels
This commit is contained in:
@@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|||||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
|
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
|
||||||
import com.badlogic.gdx.math.Matrix4;
|
import com.badlogic.gdx.math.Matrix4;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
import com.github.tommyettinger.textra.TextraLabel;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Class to draw directly on a pixmap
|
Class to draw directly on a pixmap
|
||||||
@@ -26,7 +27,6 @@ public abstract class DrawOnPixmap {
|
|||||||
on.drawPixmap(textureData.consumePixmap(), x, y, from.getRegionX(), from.getRegionY(), from.getRegionWidth(), from.getRegionHeight());
|
on.drawPixmap(textureData.consumePixmap(), x, y, from.getRegionX(), from.getRegionY(), from.getRegionWidth(), from.getRegionHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void drawText(Pixmap drawingMap, String itemText, int x, int y, float width, boolean bigText, Color color) {
|
public static void drawText(Pixmap drawingMap, String itemText, int x, int y, float width, boolean bigText, Color color) {
|
||||||
//used for big numbers on Gold/Life for reward...
|
//used for big numbers on Gold/Life for reward...
|
||||||
BitmapFont font = bigText ? Controls.getBitmapFont("big") : Controls.getBitmapFont("default");
|
BitmapFont font = bigText ? Controls.getBitmapFont("big") : Controls.getBitmapFont("default");
|
||||||
@@ -59,4 +59,37 @@ public abstract class DrawOnPixmap {
|
|||||||
if (bigText) //don't know why this is needed to circumvent bug getting default size for the same pixelfont
|
if (bigText) //don't know why this is needed to circumvent bug getting default size for the same pixelfont
|
||||||
Controls.getBitmapFont("default");
|
Controls.getBitmapFont("default");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void drawText(Pixmap drawingMap, TextraLabel itemText, int modX, int modY) {
|
||||||
|
FrameBuffer frameBuffer = new FrameBuffer(Pixmap.Format.RGB888, drawingMap.getWidth(), drawingMap.getHeight(), false);
|
||||||
|
SpriteBatch batch = new SpriteBatch();
|
||||||
|
|
||||||
|
frameBuffer.begin();
|
||||||
|
|
||||||
|
Gdx.gl.glClearColor(0, 0, 0, 0);
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
Matrix4 matrix = new Matrix4();
|
||||||
|
matrix.setToOrtho2D(0, drawingMap.getHeight(), drawingMap.getWidth(), -drawingMap.getHeight());
|
||||||
|
batch.setProjectionMatrix(matrix);
|
||||||
|
|
||||||
|
batch.begin();
|
||||||
|
//Rendering ends here. Create a new Pixmap to Texture with mipmaps, otherwise will render as full black.
|
||||||
|
Texture texture = new Texture(drawingMap);
|
||||||
|
batch.draw(texture, 0, 0);
|
||||||
|
itemText.setWrap(true);
|
||||||
|
itemText.setAlignment(1);
|
||||||
|
itemText.setWidth(texture.getWidth());
|
||||||
|
itemText.setHeight(texture.getHeight());
|
||||||
|
itemText.setX(itemText.getX()+modX);
|
||||||
|
itemText.setY(itemText.getY()+modY);
|
||||||
|
itemText.draw(batch, 1);
|
||||||
|
batch.end();
|
||||||
|
Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, drawingMap.getWidth(), drawingMap.getHeight());
|
||||||
|
drawingMap.drawPixmap(pixmap, 0, 0);
|
||||||
|
frameBuffer.end();
|
||||||
|
texture.dispose();
|
||||||
|
batch.dispose();
|
||||||
|
pixmap.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ public enum KeyBinding {
|
|||||||
public String getLabelText(boolean pressed) {
|
public String getLabelText(boolean pressed) {
|
||||||
if(Controllers.getCurrent()!=null)
|
if(Controllers.getCurrent()!=null)
|
||||||
{
|
{
|
||||||
return "[%125][+"+controllerPrefix+Input.Keys.toString(bindingController).replace(" Button","")+(pressed?"_pressed]":"]");
|
return "[%120][+"+controllerPrefix+Input.Keys.toString(bindingController).replace(" Button","")+(pressed?"_pressed]":"]");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(GuiBase.isAndroid())
|
if(GuiBase.isAndroid())
|
||||||
return "";
|
return "";
|
||||||
return "[%125][+"+Input.Keys.toString(binding)+(pressed?"_pressed]":"]");
|
return "[%120][+"+Input.Keys.toString(binding)+(pressed?"_pressed]":"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,8 +339,8 @@ public class Assets implements Disposable {
|
|||||||
textrafonts = new ObjectMap<>();
|
textrafonts = new ObjectMap<>();
|
||||||
if (!textrafonts.containsKey("textrafont")) {
|
if (!textrafonts.containsKey("textrafont")) {
|
||||||
Font font = new Font(bitmapFont, 0f, 2f, 0f, 0f);
|
Font font = new Font(bitmapFont, 0f, 2f, 0f, 0f);
|
||||||
font.addAtlas(item_atlas, 0f, 0f, 0f);
|
font.addAtlas(item_atlas, 0f, 4f, 0f);
|
||||||
font.addAtlas(pixelmana_atlas, 0f, -12f, 0f);
|
font.addAtlas(pixelmana_atlas, -90f, 20f, 0f);
|
||||||
font.integerPosition = false;
|
font.integerPosition = false;
|
||||||
textrafonts.put("textrafont", font);
|
textrafonts.put("textrafont", font);
|
||||||
}
|
}
|
||||||
@@ -352,7 +352,7 @@ public class Assets implements Disposable {
|
|||||||
textrafonts = new ObjectMap<>();
|
textrafonts = new ObjectMap<>();
|
||||||
if (!textrafonts.containsKey("keysfont")) {
|
if (!textrafonts.containsKey("keysfont")) {
|
||||||
Font font = new Font(bitmapFont);
|
Font font = new Font(bitmapFont);
|
||||||
font.addAtlas(keys_atlas);
|
font.addAtlas(keys_atlas, 0f, 4f, 0f);
|
||||||
font.integerPosition = false;
|
font.integerPosition = false;
|
||||||
textrafonts.put("keysfont", font);
|
textrafonts.put("keysfont", font);
|
||||||
}
|
}
|
||||||
@@ -364,7 +364,7 @@ public class Assets implements Disposable {
|
|||||||
textrafonts = new ObjectMap<>();
|
textrafonts = new ObjectMap<>();
|
||||||
if (!textrafonts.containsKey(name)) {
|
if (!textrafonts.containsKey(name)) {
|
||||||
Font font = new Font(bitmapFont);
|
Font font = new Font(bitmapFont);
|
||||||
font.addAtlas(items_atlas);
|
font.addAtlas(items_atlas, 0f, 4f, 0f);
|
||||||
font.integerPosition = false;
|
font.integerPosition = false;
|
||||||
textrafonts.put(name, font);
|
textrafonts.put(name, font);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user