diff --git a/annotations/src/main/java/mindustry/annotations/impl/AssetsProcess.java b/annotations/src/main/java/mindustry/annotations/impl/AssetsProcess.java index 95792bafa2..a4b175bd24 100644 --- a/annotations/src/main/java/mindustry/annotations/impl/AssetsProcess.java +++ b/annotations/src/main/java/mindustry/annotations/impl/AssetsProcess.java @@ -32,12 +32,15 @@ public class AssetsProcess extends BaseProcessor{ MethodSpec.Builder load = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC); MethodSpec.Builder loadStyles = MethodSpec.methodBuilder("loadStyles").addModifiers(Modifier.PUBLIC, Modifier.STATIC); MethodSpec.Builder icload = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC); + CodeBlock.Builder ichinit = CodeBlock.builder(); String resources = rootDirectory + "/core/assets-raw/sprites/ui"; Jval icons = Jval.read(Fi.get(rootDirectory + "/core/assets-raw/fontgen/config.json").readString()); ObjectMap texIcons = new OrderedMap<>(); PropertiesUtils.load(texIcons, Fi.get(rootDirectory + "/core/assets/icons/icons.properties").reader()); + StringBuilder iconcAll = new StringBuilder(); + texIcons.each((key, val) -> { String[] split = val.split("\\|"); String name = Strings.kebabToCamel(split[1]).replace("Medium", "").replace("Icon", ""); @@ -49,6 +52,9 @@ public class AssetsProcess extends BaseProcessor{ ictype.addField(FieldSpec.builder(ParameterizedTypeName.get(ObjectMap.class, String.class, TextureRegionDrawable.class), "icons", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("new ObjectMap<>()").build()); + ichtype.addField(FieldSpec.builder(ParameterizedTypeName.get(ObjectIntMap.class, String.class), + "codes", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("new ObjectIntMap<>()").build()); + ObjectSet used = new ObjectSet<>(); for(Jval val : icons.get("glyphs").asArray()){ @@ -57,7 +63,9 @@ public class AssetsProcess extends BaseProcessor{ if(!val.getBool("selected", true) || !used.add(name)) continue; int code = val.getInt("code", 0); + iconcAll.append((char)code); ichtype.addField(FieldSpec.builder(char.class, name, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("(char)" + code).build()); + ichinit.addStatement("codes.put($S, $L)", name, code); ictype.addField(TextureRegionDrawable.class, name + "Small", Modifier.PUBLIC, Modifier.STATIC); icload.addStatement(name + "Small = mindustry.ui.Fonts.getGlyph(mindustry.ui.Fonts.def, (char)" + code + ")"); @@ -69,6 +77,9 @@ public class AssetsProcess extends BaseProcessor{ icload.addStatement("icons.put($S, " + name + "Small)", name + "Small"); } + ichtype.addField(FieldSpec.builder(String.class, "all", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("$S", iconcAll.toString()).build()); + ichtype.addStaticBlock(ichinit.build()); + Fi.get(resources).walk(p -> { if(!p.extEquals("png")) return; diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 90a8ed0f0e..d5678ad724 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -1354,7 +1354,7 @@ public class Blocks implements ContentList{ //region storage coreShard = new CoreBlock("core-shard"){{ - requirements(Category.effect, BuildVisibility.editorOnly, with(Items.copper, 1500, Items.lead, 1000)); + requirements(Category.effect, BuildVisibility.editorOnly, with(Items.copper, 1000, Items.lead, 1000)); alwaysUnlocked = true; unitType = UnitTypes.alpha; diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index a8911a502a..f61572f928 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -18,7 +18,7 @@ import static mindustry.Vars.*; public class Planet extends UnlockableContent{ /** Default spacing between planet orbits in world units. */ - private static final float orbitSpacing = 9f; + private static final float orbitSpacing = 10f; /** intersect() temp var. */ private static final Vec3 intersectResult = new Vec3(); /** Mesh used for rendering. Created on load() - will be null on the server! */ diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 6240ac2ffa..d2d1ee6dba 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -3,16 +3,16 @@ package mindustry.type; import arc.*; import arc.func.*; import arc.graphics.*; +import arc.graphics.g2d.*; import arc.math.*; import arc.math.geom.*; -import arc.scene.style.*; import arc.struct.*; import arc.util.*; import mindustry.*; import mindustry.game.Saves.*; import mindustry.game.*; -import mindustry.gen.*; import mindustry.graphics.g3d.PlanetGrid.*; +import mindustry.ui.*; import mindustry.world.modules.*; import static mindustry.Vars.*; @@ -122,8 +122,8 @@ public class Sector{ } @Nullable - public TextureRegionDrawable icon(){ - return info.icon == null ? null : Icon.icons.get(info.icon); + public TextureRegion icon(){ + return info.icon == null ? null : Fonts.getLargeIcon(info.icon); } public boolean isCaptured(){ diff --git a/core/src/mindustry/ui/Fonts.java b/core/src/mindustry/ui/Fonts.java index c2dec0cc01..0695ab9e08 100644 --- a/core/src/mindustry/ui/Fonts.java +++ b/core/src/mindustry/ui/Fonts.java @@ -25,13 +25,16 @@ import arc.util.*; import mindustry.*; import mindustry.core.*; import mindustry.ctype.*; +import mindustry.gen.*; import java.util.*; public class Fonts{ private static final String mainFont = "fonts/font.woff"; + private static final ObjectSet unscaled = ObjectSet.with("iconLarge"); private static ObjectIntMap unicodeIcons = new ObjectIntMap<>(); private static ObjectMap stringIcons = new ObjectMap<>(); + private static ObjectMap largeIcons = new ObjectMap<>(); private static TextureRegion[] iconTable; private static int lastCid; @@ -39,6 +42,7 @@ public class Fonts{ public static Font outline; public static Font chat; public static Font icon; + public static Font iconLarge; public static Font tech; public static TextureRegion logicIcon(int id){ @@ -67,6 +71,7 @@ public class Fonts{ } public static void loadFonts(){ + largeIcons.clear(); FreeTypeFontParameter param = fontParameter(); Core.assets.load("default", Font.class, new FreeTypeFontLoaderParameter(mainFont, param)).loaded = f -> Fonts.def = (Font)f; @@ -76,6 +81,25 @@ public class Fonts{ incremental = true; characters = "\0"; }})).loaded = f -> Fonts.icon = (Font)f; + Core.assets.load("iconLarge", Font.class, new FreeTypeFontLoaderParameter("fonts/icon.ttf", new FreeTypeFontParameter(){{ + size = 48; + incremental = false; + characters = "\0" + Iconc.all; + borderWidth = Scl.scl(5f); + borderColor = Color.darkGray; + + }})).loaded = f -> Fonts.iconLarge = (Font)f; + } + + public static TextureRegion getLargeIcon(String name){ + return largeIcons.get(name, () -> { + var region = new TextureRegion(); + int code = Iconc.codes.get(name, '\uF8D4'); + var glyph = iconLarge.getData().getGlyph((char)code); + region.set(iconLarge.getRegion().texture); + region.set(glyph.u, glyph.v2, glyph.u2, glyph.v); + return region; + }); } public static void loadContentIcons(){ @@ -150,7 +174,8 @@ public class Fonts{ parameter.fontParameters.borderWidth = Scl.scl(2f); parameter.fontParameters.spaceX -= parameter.fontParameters.borderWidth; } - if(!scaled.contains(parameter.fontParameters)){ + + if(!scaled.contains(parameter.fontParameters) && !unscaled.contains(fileName)){ parameter.fontParameters.size = (int)(Scl.scl(parameter.fontParameters.size)); scaled.add(parameter.fontParameters); } diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 0f0c3cd9a7..a3c4c1b94d 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -326,18 +326,18 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ @Override public void renderProjections(Planet planet){ - float isize = 38f/4f; + float iw = 48f/4f; for(Sector sec : planet.sectors){ if(sec != hovered){ var preficon = sec.icon(); - var icon = (sec.isAttacked() ? Icon.warning : !sec.hasBase() && sec.preset != null && sec.preset.unlocked() && preficon == null ? Icon.terrain : preficon); + var icon = (sec.isAttacked() ? Fonts.getLargeIcon("warning") : !sec.hasBase() && sec.preset != null && sec.preset.unlocked() && preficon == null ? Fonts.getLargeIcon("terrain") : preficon); var color = sec.preset != null && !sec.hasBase() ? Team.derelict.color : Team.sharded.color; if(icon != null){ planets.drawPlane(sec, () -> { Draw.color(color, selectAlpha); - Draw.rect(icon.getRegion(), 0, 0, isize, isize); + Draw.rect(icon, 0, 0, iw, iw * icon.height / icon.width); }); } } @@ -349,10 +349,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ planets.drawPlane(hovered, () -> { Draw.color(hovered.isAttacked() ? Pal.remove : Color.white, Pal.accent, Mathf.absin(5f, 1f)); - var icon = hovered.locked() && !canSelect(hovered) ? Icon.lock : hovered.isAttacked() ? Icon.warning : hovered.icon(); + var icon = hovered.locked() && !canSelect(hovered) ? Fonts.getLargeIcon("lock") : hovered.isAttacked() ? Fonts.getLargeIcon("warning") : hovered.icon(); if(icon != null){ - Draw.rect(icon.getRegion(), 0, 0, isize, isize); + Draw.rect(icon, 0, 0, iw, iw * icon.height / icon.width); } Draw.reset(); @@ -603,7 +603,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ Table stable = sectorTop; if(sector == null){ - //stable.remove(); return; } @@ -769,7 +768,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ float dot = planets.cam.direction.dot(Tmp.v31); stable.color.a = Math.max(dot, 0f)*2f; if(dot*2f <= -0.1f){ - //stable.remove(); selected = null; updateSelected(); }