Removed accidentally created files

This commit is contained in:
Natty 2022-04-05 20:40:59 +02:00 committed by Tefek
parent ab63e22438
commit 11105d435f
3 changed files with 0 additions and 208 deletions

View File

@ -1,102 +0,0 @@
package cz.tefek.pluto.engine.graphics.font;
import java.util.HashMap;
import java.util.Map;
import java.io.BufferedReader;
import java.nio.file.Files;
import cz.tefek.pluto.engine.graphics.texture.MagFilter;
import cz.tefek.pluto.engine.graphics.texture.MinFilter;
import cz.tefek.pluto.engine.graphics.texture.Texture;
import cz.tefek.pluto.engine.graphics.texture.WrapMode;
import cz.tefek.pluto.engine.graphics.texture.texture2d.RectangleTexture;
import cz.tefek.pluto.engine.gui.font.CharacterInfo;
import cz.tefek.pluto.engine.gui.font.Font;
import cz.tefek.pluto.io.asl.resource.ResourceAddress;
import cz.tefek.pluto.io.logger.Logger;
import cz.tefek.pluto.io.logger.SmartSeverity;
public class FontManager
{
private static Map<String, Font> fonts = new HashMap<>();
public static void loadFont(ResourceAddress address)
{
String fontname = null;
int width = 0;
int height = 0;
var def = new HashMap<Character, CharacterInfo>();
int row = 0;
try (BufferedReader br = Files.newBufferedReader(address.copy().branch("definitions").fileExtension("txt").toNIOPath()))
{
String line;
while ((line = br.readLine()) != null)
{
if (line.startsWith("//"))
{
continue;
}
if (row == 0)
{
String[] fontinfo;
fontinfo = line.split(",");
fontname = fontinfo[0];
String[] dim = fontinfo[1].split("x");
width = Integer.parseInt(dim[0]);
height = Integer.parseInt(dim[1]);
}
if (row > 0)
{
String[] offs = null;
offs = line.split(" ")[1].split(";");
def.put(line.charAt(0), new CharacterInfo(row - 1, Integer.parseInt(offs[0]), Integer.parseInt(offs[1])));
}
row++;
}
br.close();
}
catch (Exception e)
{
Logger.log(SmartSeverity.ERROR, "Could not load font: " + address.toString());
e.printStackTrace();
}
Font font = new Font(fontname, width, height, def);
RectangleTexture texture = new RectangleTexture();
texture.load(address.copy().branch("tex").fileExtension("png"), MagFilter.NEAREST, MinFilter.LINEAR, WrapMode.CLAMP_TO_EDGE, WrapMode.CLAMP_TO_EDGE);
font.setTexture(texture);
fonts.put(fontname, font);
}
public static void unloadAll()
{
fonts.values().stream().map(Font::getTexture).forEach(Texture::delete);
fonts.clear();
}
public static Font getFontByName(String fontname)
{
var font = fonts.get(fontname);
if (font == null)
{
Logger.log(SmartSeverity.WARNING, "Font with name " + fontname + " could not be found, using the default one instead (if there is one).");
return fonts.get("default");
}
return font;
}
}

View File

@ -1,30 +0,0 @@
package cz.tefek.pluto.engine.gui.font;
public class CharacterInfo
{
int leftOffs;
private int rightOffs;
int number;
public CharacterInfo(int number, int leftOffs, int rightOffs)
{
this.number = number;
this.leftOffs = leftOffs;
this.rightOffs = rightOffs;
}
public int getLeftOffset()
{
return this.leftOffs;
}
public int getNumber()
{
return this.number;
}
public int getRightOffset()
{
return this.rightOffs;
}
}

View File

@ -1,76 +0,0 @@
package cz.tefek.pluto.engine.graphics;
import cz.tefek.pluto.Pluto;
import cz.tefek.pluto.engine.ModLWJGL;
import cz.tefek.pluto.engine.graphics.spritesheet.FramebufferTiledSpriteSheet;
import cz.tefek.pluto.engine.shader.PlutoShaderMod;
import cz.tefek.pluto.engine.shader.RenderShaderBuilder;
import cz.tefek.pluto.io.asl.resource.ResourceSubscriber;
import cz.tefek.pluto.io.logger.Logger;
import cz.tefek.pluto.modloader.Mod;
import cz.tefek.pluto.modloader.ModEntry;
import cz.tefek.pluto.modloader.ModLoaderCore;
import cz.tefek.pluto.modloader.event.ModPreLoad;
import cz.tefek.pluto.modloader.event.ModPreLoadEvent;
import cz.tefek.pluto.modloader.event.ModUnload;
import cz.tefek.pluto.modloader.event.ModUnloadEvent;
@ModEntry(modid = PlutoSpriteSheetMod.MOD_ID,
version = Pluto.VERSION,
dependencies = { ModLWJGL.class, PlutoShaderMod.class },
author = "493msi",
displayName = "Pluto SpriteSheet",
description = "A library to manage, store and draw sprites.")
public class PlutoSpriteSheetMod
{
public static final String MOD_ID = "plutospritesheet";
public static Mod instance;
public static ResourceSubscriber subscriber;
/**
* Strictly internal use only, do NOT use this outside of plutospritesheet
*/
private static Shader2D shader2D;
/**
* Strictly internal use only, do NOT use this outside of plutospritesheet
*/
private static ShaderRectangle2D shaderRectangle2D;
/**
* Strictly internal use only, do NOT use this outside of plutospritesheet
*/
private static ShaderRectangle2D spriteSheetShader;
@ModPreLoad
public static void preLoad(ModPreLoadEvent event)
{
instance = ModLoaderCore.getModByID(MOD_ID);
subscriber = instance.getDefaultResourceSubscriber();
Logger.log("Intializing " + MOD_ID + "...");
shader2D = new RenderShaderBuilder(subscriber, "shaders.v2D#glsl", "shaders.f2D#glsl").build(Shader2D.class, false);
shaderRectangle2D = new RenderShaderBuilder(subscriber, "shaders.VertexRectangle2D#glsl", "shaders.FragmentRectangle2D#glsl").build(ShaderRectangle2D.class, false);
spriteSheetShader = new RenderShaderBuilder(subscriber, "shaders.VertexSpriteSheet#glsl", "shaders.FragmentSpriteSheet#glsl").build(ShaderRectangle2D.class, false);
Renderer2D.load(shader2D);
RectangleRenderer2D.load(shaderRectangle2D);
FramebufferTiledSpriteSheet.setSpriteShader(spriteSheetShader);
}
@ModUnload
public static void unload(ModUnloadEvent unloadEvent)
{
FramebufferTiledSpriteSheet.setSpriteShader(null);
spriteSheetShader.dispose();
shaderRectangle2D.dispose();
shader2D.dispose();
RectangleRenderer2D.unload();
Renderer2D.unload();
}
}