mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
move skin and adventure fonts to Assets
This commit is contained in:
@@ -11,6 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import forge.Forge;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -18,15 +19,10 @@ import java.util.function.Function;
|
||||
* Class to create ui elements in the correct style
|
||||
*/
|
||||
public class Controls {
|
||||
private static Skin SelectedSkin = null;
|
||||
private static BitmapFont defaultfont, bigfont;
|
||||
|
||||
static public TextButton newTextButton(String text) {
|
||||
|
||||
return new TextButton(text, GetSkin());
|
||||
}
|
||||
static public Rectangle getBoundingRect(Actor actor) {
|
||||
|
||||
return new Rectangle(actor.getX(),actor.getY(),actor.getWidth(),actor.getHeight());
|
||||
}
|
||||
static public boolean actorContainsVector (Actor actor, Vector2 point) {
|
||||
@@ -56,8 +52,6 @@ public class Controls {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static public TextField newTextField(String text) {
|
||||
return new TextField(text, GetSkin());
|
||||
}
|
||||
@@ -108,32 +102,28 @@ public class Controls {
|
||||
switch (fontName) {
|
||||
case "blackbig":
|
||||
case "big":
|
||||
return bigfont;
|
||||
return Forge.getAssets().advBigFont;
|
||||
default:
|
||||
return defaultfont;
|
||||
return Forge.getAssets().advDefaultFont;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public Skin GetSkin() {
|
||||
|
||||
if (SelectedSkin == null) {
|
||||
SelectedSkin = new Skin();
|
||||
|
||||
if (Forge.getAssets().skin == null) {
|
||||
Forge.getAssets().skin = new Skin();
|
||||
FileHandle skinFile = Config.instance().getFile(Paths.SKIN);
|
||||
FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas");
|
||||
TextureAtlas atlas = new TextureAtlas(atlasFile);
|
||||
//font
|
||||
defaultfont = new BitmapFont(Config.instance().getFile(Paths.SKIN).sibling("LanaPixel.fnt"));
|
||||
bigfont = new BitmapFont(Config.instance().getFile(Paths.SKIN).sibling("LanaPixel.fnt"));
|
||||
bigfont.getData().setScale(2, 2);
|
||||
SelectedSkin.add("default", defaultfont);
|
||||
SelectedSkin.add("big", bigfont);
|
||||
SelectedSkin.addRegions(atlas);
|
||||
SelectedSkin.load(skinFile);
|
||||
|
||||
Forge.getAssets().advDefaultFont = new BitmapFont(Config.instance().getFile(Paths.SKIN).sibling("LanaPixel.fnt"));
|
||||
Forge.getAssets().advBigFont = new BitmapFont(Config.instance().getFile(Paths.SKIN).sibling("LanaPixel.fnt"));
|
||||
Forge.getAssets().advBigFont.getData().setScale(2, 2);
|
||||
Forge.getAssets().skin.add("default", Forge.getAssets().advDefaultFont);
|
||||
Forge.getAssets().skin.add("big", Forge.getAssets().advBigFont);
|
||||
Forge.getAssets().skin.addRegions(atlas);
|
||||
Forge.getAssets().skin.load(skinFile);
|
||||
}
|
||||
return SelectedSkin;
|
||||
return Forge.getAssets().skin;
|
||||
}
|
||||
|
||||
public static Label newLabel(String name) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.assets.loaders.resolvers.AbsoluteFileHandleResolver;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import forge.gui.GuiBase;
|
||||
@@ -19,6 +20,8 @@ public class Assets implements Disposable {
|
||||
public ObjectMap<String, Texture> generatedCards = new ObjectMap<>(512);
|
||||
public ObjectMap<Integer, Texture> fallback_skins = new ObjectMap<>();
|
||||
public ObjectMap<String, Texture> tmxMap = new ObjectMap<String, Texture>();
|
||||
public Skin skin;
|
||||
public BitmapFont advDefaultFont, advBigFont;
|
||||
public Assets() {
|
||||
//init titlebg fallback
|
||||
fallback_skins.put(0, new Texture(GuiBase.isAndroid()
|
||||
@@ -43,5 +46,11 @@ public class Assets implements Disposable {
|
||||
texture.dispose();
|
||||
for (Texture texture : tmxMap.values())
|
||||
texture.dispose();
|
||||
if (advDefaultFont != null)
|
||||
advDefaultFont.dispose();
|
||||
if (advBigFont != null)
|
||||
advBigFont.dispose();
|
||||
if (skin != null)
|
||||
skin.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user