This commit is contained in:
Anuken 2018-11-06 12:55:13 -05:00
parent ffa1aae27c
commit 04b4321ea1
8 changed files with 52 additions and 23 deletions

View File

@ -37,6 +37,12 @@ dependencies {
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
}

View File

@ -95,6 +95,7 @@ project(":desktop") {
compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.0'
}
}
@ -129,6 +130,7 @@ project(":ios") {
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
}
}
@ -157,6 +159,7 @@ project(":core") {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compileOnly project(":annotations")
annotationProcessor project(":annotations")

BIN
core/assets/fonts/pixel.ttf Normal file

Binary file not shown.

View File

@ -1,15 +1,5 @@
{
Font: {
default-font: {
file: square.fnt,
markup: true,
scale: 0.5
},
default-font-chat: {
file: square.fnt,
markup: false,
scale: 0.5
},
trad-chinese: {
file: trad_chinese.fnt,
markup: true,

View File

@ -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(2f), 0.5f);
baseCameraScale = Math.round(Unit.dp.scl(4));
}
}

View File

@ -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,30 @@ 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;
param.gamma = param.borderGamma = 0f;
param.shadowColor = Color.DARK_GRAY;
param.shadowOffsetY = 1;
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 +189,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);
}

View File

@ -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);

View File

@ -21,13 +21,17 @@ import java.time.format.DateTimeFormatter;
public class CrashHandler{
public static void handle(Throwable e){
try{
javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
}catch(Throwable ignored){}
e.printStackTrace();
if(!OS.isMac){
try{
javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
}catch(Throwable ignored){}
}
boolean badGPU = false;
if(e.getMessage() != null && (e.getMessage().contains("Couldn't create window") || e.getMessage().contains("OpenGL 2.0 or higher"))){
if(!OS.isMac && e.getMessage() != null && (e.getMessage().contains("Couldn't create window") || e.getMessage().contains("OpenGL 2.0 or higher"))){
try{
javax.swing.JOptionPane.showMessageDialog(null, "Your graphics card does not support OpenGL 2.0!\n" +
"Try to update your graphics drivers.\n\n" +
@ -37,8 +41,6 @@ public class CrashHandler{
}catch(Throwable ignored){}
}
e.printStackTrace();
//don't create crash logs for me (anuke), as it's expected
//also don't create logs for custom builds
if(System.getProperty("user.name").equals("anuke") || Version.build == -1) return;