Runes added to font
This commit is contained in:
Binary file not shown.
@@ -12,6 +12,7 @@ import mindustry.world.*;
|
|||||||
|
|
||||||
public class RuneOverlay extends OverlayFloor{
|
public class RuneOverlay extends OverlayFloor{
|
||||||
public static final int characters = 109;
|
public static final int characters = 109;
|
||||||
|
public static final int unicodeOffset = 0x142B;
|
||||||
|
|
||||||
public @Load(value = "@#", fallback = "rune-overlay#", length = characters) TextureRegion[] letterRegions;
|
public @Load(value = "@#", fallback = "rune-overlay#", length = characters) TextureRegion[] letterRegions;
|
||||||
public Color color = Color.white;
|
public Color color = Color.white;
|
||||||
@@ -24,9 +25,26 @@ public class RuneOverlay extends OverlayFloor{
|
|||||||
editorConfigurable = true;
|
editorConfigurable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Encodes rune data bytes into a string that can be displayed in the font. */
|
||||||
|
public static String bytesToString(byte[] data){
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for(byte b : data){
|
||||||
|
result.append((char)(b & 0xff + unicodeOffset));
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Converts a displayable string into rune data bytes. Will generate garbage data if the string doesn't contain the right character set. */
|
||||||
|
public static byte[] stringToBytes(String s){
|
||||||
|
byte[] bytes = new byte[s.length()];
|
||||||
|
for(int i = 0; i < s.length(); i++){
|
||||||
|
bytes[i] = (byte)(s.charAt(i) - unicodeOffset);
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawBase(Tile tile){
|
public void drawBase(Tile tile){
|
||||||
|
|
||||||
Draw.color(color);
|
Draw.color(color);
|
||||||
if((tile.overlayData & 0xff) < characters){
|
if((tile.overlayData & 0xff) < characters){
|
||||||
Draw.rect(letterRegions[tile.overlayData & 0xff], tile.worldx(), tile.worldy());
|
Draw.rect(letterRegions[tile.overlayData & 0xff], tile.worldx(), tile.worldy());
|
||||||
@@ -39,7 +57,6 @@ public class RuneOverlay extends OverlayFloor{
|
|||||||
return (int)tile.overlayData;
|
return (int)tile.overlayData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,10 @@ public class IconConverter{
|
|||||||
Time.mark();
|
Time.mark();
|
||||||
Fi.get("fontgen/icons").deleteDirectory();
|
Fi.get("fontgen/icons").deleteDirectory();
|
||||||
Fi.get("fontgen/icon_parts").deleteDirectory();
|
Fi.get("fontgen/icon_parts").deleteDirectory();
|
||||||
Fi[] list = new Fi("icons").list();
|
|
||||||
|
|
||||||
Seq<Fi> files = new Seq<>();
|
Seq<Fi> files = new Seq<>();
|
||||||
|
|
||||||
for(Fi img : list){
|
for(Fi img : new Fi("icons").list()){
|
||||||
if(img.extension().equals("png")){
|
if(img.extension().equals("png")){
|
||||||
Fi dst = new Fi("fontgen/icons").child(img.nameWithoutExtension().replace("icon-", "") + ".svg");
|
Fi dst = new Fi("fontgen/icons").child(img.nameWithoutExtension().replace("icon-", "") + ".svg");
|
||||||
new IconConverter().convert(new Pixmap(img), dst);
|
new IconConverter().convert(new Pixmap(img), dst);
|
||||||
@@ -223,7 +222,7 @@ public class IconConverter{
|
|||||||
|
|
||||||
output.writeString(out.toString());
|
output.writeString(out.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void square(float x, float y, float size){
|
void square(float x, float y, float size){
|
||||||
rect(x - size/2f, y - size/2f, size, size);
|
rect(x - size/2f, y - size/2f, size, size);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user