-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
194 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 21 additions & 41 deletions
62
src/main/java/dan200/computercraft/client/gui/FontDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,53 @@ | ||
package dan200.computercraft.client.gui; | ||
|
||
import net.minecraft.util.ResourceLocation; | ||
import java.util.List; | ||
|
||
import scala.actors.threadpool.Arrays; | ||
|
||
public class FontDefinition { | ||
|
||
private final ResourceLocation font; | ||
private final int fontHeight; | ||
private final int fontWidth; | ||
private final double texHeight; | ||
private final double texWidth; | ||
private final int maxChars; | ||
private final int charsPerLine; | ||
private final String name; | ||
private final boolean blending; | ||
private final FontPart[] parts; | ||
|
||
protected FontDefinition(String name, ResourceLocation font, int fontHeight, int fontWidth, int maxChars, int charsPerLine, double texWidth, double texHeight, boolean blending) { | ||
protected FontDefinition(String name, int maxChars, boolean blending, FontPart... parts) { | ||
this.name = name; | ||
this.font = font; | ||
this.fontHeight = fontHeight; | ||
this.fontWidth = fontWidth; | ||
this.maxChars = maxChars; | ||
this.charsPerLine = charsPerLine; | ||
this.texWidth = texWidth; | ||
this.texHeight = texHeight; | ||
this.blending = blending; | ||
this.parts = parts; | ||
} | ||
|
||
public String name() | ||
{ | ||
return this.name; | ||
} | ||
|
||
public ResourceLocation font() | ||
{ | ||
return this.font; | ||
} | ||
|
||
public int fontHeight() | ||
@SuppressWarnings("unchecked") | ||
public List<FontPart> getParts() | ||
{ | ||
return this.fontHeight; | ||
} | ||
|
||
public int fontWidth() | ||
{ | ||
return this.fontWidth; | ||
return Arrays.asList(this.parts); | ||
} | ||
|
||
public int maxChars() | ||
{ | ||
return this.maxChars; | ||
} | ||
|
||
public int charsPerLine() | ||
{ | ||
return this.charsPerLine; | ||
} | ||
|
||
public double texWidth() | ||
{ | ||
return texWidth; | ||
} | ||
|
||
public double texHeight() | ||
{ | ||
return texHeight; | ||
} | ||
|
||
public boolean isBlending() { | ||
return blending; | ||
} | ||
|
||
public FontPart getPart(int codepoint) | ||
{ | ||
for (final FontPart part : this.parts) | ||
{ | ||
if (codepoint >= part.begin() && codepoint <= part.end()) | ||
{ | ||
return part; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/dan200/computercraft/client/gui/FontPart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package dan200.computercraft.client.gui; | ||
|
||
import net.minecraft.util.ResourceLocation; | ||
|
||
public class FontPart { | ||
|
||
private final ResourceLocation font; | ||
private final int fontHeight; | ||
private final int fontWidth; | ||
private final double texHeight; | ||
private final double texWidth; | ||
private final int begin; | ||
private final int end; | ||
private final int charsPerLine; | ||
|
||
protected FontPart(ResourceLocation font, int fontHeight, int fontWidth, int begin, int end, int charsPerLine, double texWidth, double texHeight) { | ||
this.font = font; | ||
this.fontHeight = fontHeight; | ||
this.fontWidth = fontWidth; | ||
this.charsPerLine = charsPerLine; | ||
this.texWidth = texWidth; | ||
this.texHeight = texHeight; | ||
this.begin = begin; | ||
this.end = end; | ||
} | ||
|
||
public ResourceLocation font() | ||
{ | ||
return this.font; | ||
} | ||
|
||
public int fontHeight() | ||
{ | ||
return this.fontHeight; | ||
} | ||
|
||
public int fontWidth() | ||
{ | ||
return this.fontWidth; | ||
} | ||
|
||
public int charsPerLine() | ||
{ | ||
return this.charsPerLine; | ||
} | ||
|
||
public double texWidth() | ||
{ | ||
return texWidth; | ||
} | ||
|
||
public double texHeight() | ||
{ | ||
return texHeight; | ||
} | ||
|
||
public int begin() { | ||
return begin; | ||
} | ||
|
||
public int end() { | ||
return end; | ||
} | ||
|
||
} |