Bug 18: Separated SpriteBatch and BitmapFont and Texture
This commit is contained in:
parent
c2811b972e
commit
dbc5d5558b
@ -1,3 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: LibGDX Backend.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package com.pixelgamelibrary.backend.libgdx.files;
|
||||
|
||||
import com.pixelgamelibrary.api.utils.AssetsTxt;
|
||||
|
@ -0,0 +1,88 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: LibGDX Backend.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.graphics;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.pixelgamelibrary.api.files.File;
|
||||
import com.pixelgamelibrary.api.graphics.Color;
|
||||
import com.pixelgamelibrary.api.graphics.SpriteBatch;
|
||||
import com.pixelgamelibrary.api.graphics.TextureRegion;
|
||||
import com.pixelgamelibrary.backend.libgdx.utils.LibGdxBackendUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class LibGdxBitmapFont implements com.pixelgamelibrary.api.graphics.BitmapFont {
|
||||
|
||||
private com.badlogic.gdx.graphics.g2d.BitmapFont internalBitmapFont;
|
||||
private boolean disposed = false;
|
||||
|
||||
public LibGdxBitmapFont(boolean flip) {
|
||||
this.internalBitmapFont = new com.badlogic.gdx.graphics.g2d.BitmapFont(flip);
|
||||
}
|
||||
|
||||
public LibGdxBitmapFont(File fontFile, TextureRegion region, boolean flip) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
}
|
||||
|
||||
public LibGdxBitmapFont(File fontFile, boolean flip) {
|
||||
this.internalBitmapFont = new com.badlogic.gdx.graphics.g2d.BitmapFont(LibGdxBackendUtils.convertToLibGdxFileHandle(fontFile), flip);
|
||||
}
|
||||
|
||||
public LibGdxBitmapFont(File fontFile, File imageFile, boolean flip) {
|
||||
this.internalBitmapFont = new com.badlogic.gdx.graphics.g2d.BitmapFont(
|
||||
LibGdxBackendUtils.convertToLibGdxFileHandle(fontFile),
|
||||
LibGdxBackendUtils.convertToLibGdxFileHandle(imageFile),
|
||||
flip);
|
||||
}
|
||||
|
||||
com.badlogic.gdx.graphics.g2d.BitmapFont getInternalBitmapFont() {
|
||||
return this.internalBitmapFont;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisposed() {
|
||||
return this.disposed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(float f) {
|
||||
this.internalBitmapFont.getData().setScale(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Color color) {
|
||||
this.internalBitmapFont.setColor(LibGdxBackendUtils.convertToLibGdxColor(color));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(SpriteBatch batch, String text, float x, float y) {
|
||||
LibGdxSpriteBatch libGdxSpriteBatch = (LibGdxSpriteBatch) batch;
|
||||
this.internalBitmapFont.draw(libGdxSpriteBatch.getInternalBatch(), text, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
this.internalBitmapFont.dispose();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: LibGDX Backend.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.graphics;
|
||||
|
||||
import com.pixelgamelibrary.api.files.File;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFont;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFontFactory;
|
||||
import com.pixelgamelibrary.api.graphics.TextureRegion;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class LibGdxBitmapFontFactory implements BitmapFontFactory{
|
||||
|
||||
@Override
|
||||
public BitmapFont create(boolean flip) {
|
||||
return new LibGdxBitmapFont(flip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BitmapFont create(File fontFile, TextureRegion region, boolean flip) {
|
||||
return new LibGdxBitmapFont(fontFile, region, flip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BitmapFont create(File fontFile, boolean flip) {
|
||||
return new LibGdxBitmapFont(fontFile, flip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BitmapFont create(File fontFile, File imageFile, boolean flip) {
|
||||
return new LibGdxBitmapFont(fontFile, imageFile, flip);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: LibGDX Backend.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.graphics;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class LibGdxSpriteBatch implements com.pixelgamelibrary.api.graphics.SpriteBatch {
|
||||
|
||||
private com.badlogic.gdx.graphics.g2d.SpriteBatch internalBatch;
|
||||
private boolean disposed = false;
|
||||
|
||||
public LibGdxSpriteBatch() {
|
||||
this(new com.badlogic.gdx.graphics.g2d.SpriteBatch());
|
||||
}
|
||||
|
||||
public LibGdxSpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch libGdxG2dSpriteBatchIn) {
|
||||
this.internalBatch = libGdxG2dSpriteBatchIn;
|
||||
}
|
||||
com.badlogic.gdx.graphics.g2d.SpriteBatch getInternalBatch() {
|
||||
return this.internalBatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void begin() {
|
||||
this.internalBatch.begin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
this.internalBatch.end();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(com.pixelgamelibrary.api.graphics.Texture texture, int x, int y, int width, int height) {
|
||||
LibGdxTexture libGdxTexture = (LibGdxTexture) texture;
|
||||
this.internalBatch.draw(libGdxTexture.getInternalTexture(), x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(com.pixelgamelibrary.api.graphics.Texture texture, int x, int y) {
|
||||
LibGdxTexture libGdxTexture = (LibGdxTexture) texture;
|
||||
this.internalBatch.draw(libGdxTexture.getInternalTexture(), x, y);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDisposed() {
|
||||
return this.disposed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
this.disposed = true;
|
||||
this.internalBatch.dispose();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: LibGDX Backend.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.graphics;
|
||||
|
||||
import com.pixelgamelibrary.api.graphics.SpriteBatch;
|
||||
import com.pixelgamelibrary.api.graphics.SpriteBatchFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class LibGdxSpriteBatchFactory implements SpriteBatchFactory{
|
||||
|
||||
@Override
|
||||
public SpriteBatch create() {
|
||||
return new LibGdxSpriteBatch();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: LibGDX Backend.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.graphics;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.pixelgamelibrary.api.files.File;
|
||||
import com.pixelgamelibrary.api.graphics.ColorMode;
|
||||
import com.pixelgamelibrary.api.graphics.Pixmap;
|
||||
import com.pixelgamelibrary.backend.libgdx.utils.LibGdxBackendUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class LibGdxTexture implements com.pixelgamelibrary.api.graphics.Texture {
|
||||
|
||||
private com.badlogic.gdx.graphics.Texture internalTexture;
|
||||
private boolean disposed = false;
|
||||
|
||||
public LibGdxTexture(com.badlogic.gdx.graphics.Texture internalTextureIn) {
|
||||
this.internalTexture = internalTextureIn;
|
||||
}
|
||||
|
||||
public LibGdxTexture(String assetPath) {
|
||||
this(new com.badlogic.gdx.graphics.Texture(assetPath));
|
||||
}
|
||||
|
||||
public LibGdxTexture(File file) {
|
||||
this(new com.badlogic.gdx.graphics.Texture(LibGdxBackendUtils.convertToLibGdxFileHandle(file)));
|
||||
}
|
||||
|
||||
public LibGdxTexture(Pixmap pixmap) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
public LibGdxTexture(int width, int height) {
|
||||
this(new com.badlogic.gdx.graphics.Texture(width, height, Format.RGBA8888));
|
||||
}
|
||||
|
||||
com.badlogic.gdx.graphics.Texture getInternalTexture() {
|
||||
return this.internalTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
this.disposed = true;
|
||||
this.internalTexture.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Pixmap pixmap, int x, int y) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.internalTexture.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.internalTexture.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDepth() {
|
||||
return this.internalTexture.getDepth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeColorTransparent(int r, int g, int b) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(double d) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorMode(ColorMode colorMode, int bitCount) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisposed() {
|
||||
return this.disposed;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: LibGDX Backend.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.graphics;
|
||||
|
||||
import com.pixelgamelibrary.api.files.File;
|
||||
import com.pixelgamelibrary.api.graphics.Pixmap;
|
||||
import com.pixelgamelibrary.api.graphics.Texture;
|
||||
import com.pixelgamelibrary.api.graphics.TextureFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class LibGdxTextureFactory implements TextureFactory{
|
||||
|
||||
|
||||
@Override
|
||||
public Texture create(String assetPath) {
|
||||
return new LibGdxTexture(assetPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture create(File file) {
|
||||
return new LibGdxTexture(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture create(Pixmap pixmap) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture create(int width, int height) {
|
||||
return new LibGdxTexture(width, height);
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import static com.badlogic.gdx.Application.ApplicationType.Android;
|
||||
@ -137,7 +137,31 @@ public class AppLibGDXImpl implements App {
|
||||
|
||||
@Override
|
||||
public void setLogLevel(LogLevel logLevel) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
|
||||
// public static final int LOG_NONE = 0;
|
||||
// public static final int LOG_DEBUG = 3;
|
||||
// public static final int LOG_INFO = 2;
|
||||
// public static final int LOG_ERROR = 1;
|
||||
switch (logLevel) {
|
||||
case NONE:
|
||||
Gdx.app.setLogLevel(Gdx.app.LOG_NONE);
|
||||
break;
|
||||
case FATAL:
|
||||
case ERROR:
|
||||
Gdx.app.setLogLevel(Gdx.app.LOG_ERROR);
|
||||
break;
|
||||
case INFO:
|
||||
case WARN:
|
||||
Gdx.app.setLogLevel(Gdx.app.LOG_INFO);
|
||||
break;
|
||||
case DEBUG:
|
||||
case TRACE:
|
||||
Gdx.app.setLogLevel(Gdx.app.LOG_DEBUG);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("This LogLevel is not supported: " + logLevel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.pixelgamelibrary.api.audio.Music;
|
||||
import com.pixelgamelibrary.api.audio.Sound;
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.badlogic.gdx.utils.XmlReader;
|
||||
import com.pixelgamelibrary.api.interfaces.XmlElement;
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.pixelgamelibrary.backend.libgdx.files.FileSystemFactory;
|
||||
import com.pixelgamelibrary.api.interfaces.Files;
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Graphics;
|
||||
@ -28,7 +28,10 @@ import com.pixelgamelibrary.api.graphics.Monitor;
|
||||
import com.pixelgamelibrary.api.graphics.Pixmap;
|
||||
import com.pixelgamelibrary.api.graphics.SpriteBatchFactory;
|
||||
import com.pixelgamelibrary.api.graphics.TextureFactory;
|
||||
import com.pixelgamelibrary.backend.libgdx.graphics.LibGdxBitmapFontFactory;
|
||||
import com.pixelgamelibrary.backend.libgdx.graphics.LibGdxMonitor;
|
||||
import com.pixelgamelibrary.backend.libgdx.graphics.LibGdxSpriteBatchFactory;
|
||||
import com.pixelgamelibrary.backend.libgdx.graphics.LibGdxTextureFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -98,17 +101,17 @@ public class GraphicsLibGDXImpl implements com.pixelgamelibrary.api.interfaces.G
|
||||
|
||||
@Override
|
||||
public TextureFactory getTextureFactory() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
return new LibGdxTextureFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpriteBatchFactory newSpriteBatchFactory() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
return new LibGdxSpriteBatchFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BitmapFontFactory newBitmapFontFactory() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
return new LibGdxBitmapFontFactory();
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.pixelgamelibrary.api.input.DeviceOrientation;
|
||||
import com.pixelgamelibrary.api.input.InputProcessor;
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.pixelgamelibrary.api.interfaces.Internal;
|
||||
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.pixelgamelibrary.api.interfaces.Net;
|
||||
import com.pixelgamelibrary.api.net.http.HttpRequest;
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.pixelgamelibrary.api.interfaces.PixelBackend;
|
||||
import com.pixelgamelibrary.api.interfaces.Files;
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx;
|
||||
package com.pixelgamelibrary.backend.libgdx.interfaces;
|
||||
|
||||
import com.badlogic.gdx.utils.Base64Coder;
|
||||
import com.badlogic.gdx.utils.XmlReader;
|
@ -0,0 +1,70 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel: LibGDX Backend.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.pixelgamelibrary.backend.libgdx.utils;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.pixelgamelibrary.api.files.File;
|
||||
import com.pixelgamelibrary.api.files.FileException;
|
||||
import com.pixelgamelibrary.api.files.FileSystemType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class LibGdxBackendUtils {
|
||||
|
||||
private LibGdxBackendUtils() {
|
||||
//Not meant to be instantiated.
|
||||
}
|
||||
|
||||
public static FileHandle convertToLibGdxFileHandle(File file) {
|
||||
boolean android = Pixel.app().getPlatform().isAndroid();
|
||||
boolean web = Pixel.app().getPlatform().isWeb();
|
||||
|
||||
FileSystemType fileSystemType = file.getFileSystem().getFileSystemType();
|
||||
switch (fileSystemType) {
|
||||
case ASSETS:
|
||||
return android || web ? Gdx.files.internal(file.path()) : Gdx.files.classpath(file.path().startsWith("/") ? file.path().substring(1) : file.path());
|
||||
case LOCAL:
|
||||
return Gdx.files.local(file.path());
|
||||
case EXTERNAL:
|
||||
return Gdx.files.external(file.path());
|
||||
case RELATIVE:
|
||||
return Gdx.files.local(file.path());
|
||||
case ABSOLUTE:
|
||||
return Gdx.files.absolute(file.path());
|
||||
case TMP:
|
||||
throw new FileException("Unsupported FileSystemType: " + fileSystemType);
|
||||
case UNDEFINED:
|
||||
throw new FileException("Unsupported FileSystemType: " + fileSystemType);
|
||||
default:
|
||||
throw new FileException("Unsupported FileSystemType: " + fileSystemType);
|
||||
}
|
||||
|
||||
}
|
||||
public static com.badlogic.gdx.graphics.Color convertToLibGdxColor(com.pixelgamelibrary.api.graphics.Color color) {
|
||||
return new com.badlogic.gdx.graphics.Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
|
||||
}
|
||||
public static com.pixelgamelibrary.api.graphics.Color convertToPixelColor(com.badlogic.gdx.graphics.Color color) {
|
||||
return new com.pixelgamelibrary.api.graphics.Color(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user