mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
Runes added to font
This commit is contained in:
parent
2f5abdb7e5
commit
ce5b4fa3f8
3 changed files with 21 additions and 5 deletions
Binary file not shown.
|
|
@ -12,6 +12,7 @@ import mindustry.world.*;
|
|||
|
||||
public class RuneOverlay extends OverlayFloor{
|
||||
public static final int characters = 109;
|
||||
public static final int unicodeOffset = 0x142B;
|
||||
|
||||
public @Load(value = "@#", fallback = "rune-overlay#", length = characters) TextureRegion[] letterRegions;
|
||||
public Color color = Color.white;
|
||||
|
|
@ -24,9 +25,26 @@ public class RuneOverlay extends OverlayFloor{
|
|||
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
|
||||
public void drawBase(Tile tile){
|
||||
|
||||
Draw.color(color);
|
||||
if((tile.overlayData & 0xff) < characters){
|
||||
Draw.rect(letterRegions[tile.overlayData & 0xff], tile.worldx(), tile.worldy());
|
||||
|
|
@ -39,7 +57,6 @@ public class RuneOverlay extends OverlayFloor{
|
|||
return (int)tile.overlayData;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,10 @@ public class IconConverter{
|
|||
Time.mark();
|
||||
Fi.get("fontgen/icons").deleteDirectory();
|
||||
Fi.get("fontgen/icon_parts").deleteDirectory();
|
||||
Fi[] list = new Fi("icons").list();
|
||||
|
||||
Seq<Fi> files = new Seq<>();
|
||||
|
||||
for(Fi img : list){
|
||||
for(Fi img : new Fi("icons").list()){
|
||||
if(img.extension().equals("png")){
|
||||
Fi dst = new Fi("fontgen/icons").child(img.nameWithoutExtension().replace("icon-", "") + ".svg");
|
||||
new IconConverter().convert(new Pixmap(img), dst);
|
||||
|
|
@ -223,7 +222,7 @@ public class IconConverter{
|
|||
|
||||
output.writeString(out.toString());
|
||||
}
|
||||
|
||||
|
||||
void square(float x, float y, float size){
|
||||
rect(x - size/2f, y - size/2f, size, size);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue