Merge branch 'freetype' of https://github.com/Anuken/Mindustry
This commit is contained in:
@@ -174,7 +174,7 @@ public class Vars{
|
||||
customMapDirectory = dataDirectory.child("maps/");
|
||||
saveDirectory = dataDirectory.child("saves/");
|
||||
|
||||
fontScale = Math.max(Unit.dp.scl(1f) / 2f, 0.5f);
|
||||
fontScale = Math.max(Unit.dp.scl(1f), 0.5f);
|
||||
baseCameraScale = Math.round(Unit.dp.scl(4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package io.anuke.mindustry.core;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.mindustry.Vars;
|
||||
@@ -31,6 +34,8 @@ import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.ucore.scene.actions.Actions.*;
|
||||
|
||||
public class UI extends SceneModule{
|
||||
private FreeTypeFontGenerator generator;
|
||||
|
||||
public final MenuFragment menufrag = new MenuFragment();
|
||||
public final HudFragment hudfrag = new HudFragment();
|
||||
public final ChatFragment chatfrag = new ChatFragment();
|
||||
@@ -89,13 +94,29 @@ public class UI extends SceneModule{
|
||||
|
||||
Colors.put("accent", Palette.accent);
|
||||
}
|
||||
|
||||
void generateFonts(){
|
||||
generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/pixel.ttf"));
|
||||
FreeTypeFontParameter param = new FreeTypeFontParameter();
|
||||
param.size = 14*2;
|
||||
param.shadowColor = Color.DARK_GRAY;
|
||||
param.shadowOffsetY = 2;
|
||||
param.incremental = true;
|
||||
|
||||
skin.add("default-font", generator.generateFont(param));
|
||||
skin.add("default-font-chat", generator.generateFont(param));
|
||||
skin.getFont("default-font").getData().markupEnabled = true;
|
||||
skin.getFont("default-font").setOwnsTexture(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadSkin(){
|
||||
skin = new Skin(Gdx.files.internal("ui/uiskin.json"), Core.atlas);
|
||||
skin = new Skin(Core.atlas);
|
||||
generateFonts();
|
||||
skin.load(Gdx.files.internal("ui/uiskin.json"));
|
||||
|
||||
for(BitmapFont font : skin.getAll(BitmapFont.class).values()){
|
||||
font.setUseIntegerPositions(false);
|
||||
font.setUseIntegerPositions(true);
|
||||
font.getData().setScale(Vars.fontScale);
|
||||
}
|
||||
}
|
||||
@@ -167,6 +188,12 @@ public class UI extends SceneModule{
|
||||
Events.fire(new ResizeEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
super.dispose();
|
||||
generator.dispose();
|
||||
}
|
||||
|
||||
public void loadGraphics(Runnable call){
|
||||
loadGraphics("$text.loading", call);
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ public class WaveMission extends Mission{
|
||||
@Override
|
||||
public String displayString(){
|
||||
return state.wave > target ?
|
||||
Bundles.format(
|
||||
Vars.unitGroups[Vars.waveTeam.ordinal()].size() > 1 ?
|
||||
"text.mission.wave.enemies" :
|
||||
"text.mission.wave.enemy", target, target, Vars.unitGroups[Vars.waveTeam.ordinal()].size()) :
|
||||
Bundles.format("text.mission.wave", state.wave, target, (int)(state.wavetime/60));
|
||||
Bundles.format(
|
||||
Vars.unitGroups[Vars.waveTeam.ordinal()].size() > 1 ?
|
||||
"text.mission.wave.enemies" :
|
||||
"text.mission.wave.enemy", target, target, Vars.unitGroups[Vars.waveTeam.ordinal()].size()) :
|
||||
Bundles.format("text.mission.wave", state.wave, target, (int)(state.wavetime/60));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,9 +15,9 @@ public class ItemImage extends Stack{
|
||||
public ItemImage(TextureRegion region, Supplier<CharSequence> text){
|
||||
Table t = new Table().left().bottom();
|
||||
|
||||
t.label(text).color(Color.DARK_GRAY).padBottom(-Core.skin.font().getData().capHeight * 2 / Unit.dp.scl(1f)).get().setFontScale(Unit.dp.scl(0.5f));
|
||||
t.label(text).color(Color.DARK_GRAY).padBottom(-Core.skin.font().getData().capHeight * 2 / Unit.dp.scl(1f));
|
||||
t.row();
|
||||
t.label(text).get().setFontScale(Unit.dp.scl(0.5f));
|
||||
t.label(text);
|
||||
|
||||
add(new Image(region));
|
||||
add(t);
|
||||
@@ -26,9 +26,9 @@ public class ItemImage extends Stack{
|
||||
public ItemImage(ItemStack stack){
|
||||
Table t = new Table().left().bottom();
|
||||
|
||||
t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-Core.skin.font().getData().capHeight * 2 / Unit.dp.scl(1f)).get().setFontScale(Unit.dp.scl(0.5f));
|
||||
t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-Core.skin.font().getData().capHeight * 2 / Unit.dp.scl(1f));
|
||||
t.row();
|
||||
t.add(stack.amount + "").get().setFontScale(Unit.dp.scl(0.5f));
|
||||
t.add(stack.amount + "");
|
||||
|
||||
add(new Image(stack.item.region));
|
||||
add(t);
|
||||
|
||||
Reference in New Issue
Block a user