-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
d9abf2e
commit b1534f8
Showing
17 changed files
with
83 additions
and
12 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
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
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,49 @@ | ||
package ua.mei.mgui.api.hud.part; | ||
|
||
import ua.mei.mgui.api.hud.ServerHud; | ||
import ua.mei.pfu.api.font.FontResourceManager; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class NumberPart extends HudGroup { | ||
public static final FontResourceManager manager = FontResourceManager.create("mgui", "mgui", "numbers"); | ||
|
||
public final Map<Character, GlyphPart> glyphs; | ||
public final int y; | ||
|
||
protected NumberPart(ServerHud hud, int y) { | ||
super(hud, List.of()); | ||
|
||
this.glyphs = new HashMap<>(); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
glyphs.put((char) ('0' + i), GlyphPart.create(hud, "hud/five/number_" + i + ".png", y, manager)); | ||
} | ||
glyphs.put('-', GlyphPart.create(hud, "hud/five/number_minus.png", y, manager)); | ||
|
||
this.y = y; | ||
|
||
setNumber(0); | ||
} | ||
|
||
public static NumberPart create(ServerHud hud, int y) { | ||
return new NumberPart(hud, y); | ||
} | ||
|
||
public NumberPart setNumber(int number) { | ||
this.parts.clear(); | ||
|
||
int offset = 0; | ||
|
||
for (Character digitChar : String.valueOf(number).toCharArray()) { | ||
GlyphPart glyph = glyphs.get(digitChar); | ||
glyph = new GlyphPart(glyph.hud, glyph.glyph).xOffset(offset); | ||
parts.add(glyph); | ||
offset += glyph.getWidth() + 1; | ||
} | ||
|
||
return this; | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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