improve gui
This commit is contained in:
parent
a7dacc36f8
commit
cc2c78d995
41 changed files with 369 additions and 579 deletions
|
@ -457,8 +457,6 @@ public class Client implements IThreadListener {
|
|||
public int fbY;
|
||||
public int mouseX;
|
||||
public int mouseY;
|
||||
public int total;
|
||||
public int progress = -1;
|
||||
|
||||
private long lastTicked = 0L;
|
||||
private long debugUpdateTime = System.currentTimeMillis();
|
||||
|
@ -520,7 +518,6 @@ public class Client implements IThreadListener {
|
|||
public BlockPos pointedLiquid;
|
||||
public DisplayMode vidMode;
|
||||
public String dimensionName;
|
||||
public String message;
|
||||
private ChunkClient emptyChunk;
|
||||
private ChunkClient outsideChunk;
|
||||
|
||||
|
@ -665,7 +662,7 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
|
||||
public void displayConnecting(ServerInfo server) {
|
||||
this.show(GuiLoading.makeWaitTask("Verbinde zu " + (server.getAddress() == null ? "localhost" : server.getAddress()) + ":" + server.getPort() + " ..."));
|
||||
this.show(new GuiLoading("Verbinde zu " + (server.getAddress() == null ? "localhost" : server.getAddress()) + ":" + server.getPort() + " ..."));
|
||||
}
|
||||
|
||||
public void connect(final ServerInfo server) {
|
||||
|
|
|
@ -97,7 +97,7 @@ public class GuiConsole extends Gui implements FieldCallback {
|
|||
}
|
||||
this.logBox = this.add(new ConsoleArea(0, this.full ? Element.BASE_HEIGHT : 0, width, height - Element.BASE_HEIGHT * (this.full ? 2 : 1), this.gm.getBuffer(), this.gm.world != null && !this.gm.charEditor));
|
||||
if(this.full)
|
||||
this.add(new Fill(640, 0, width - 640, 0));
|
||||
this.add(new Fill(640, 0, width - 640, 0, ""));
|
||||
this.inputField = this.add(new Field(0, height - Element.BASE_HEIGHT, width, 0, IPlayer.MAX_CMD_LENGTH, this, ""));
|
||||
this.inputField.setSelected();
|
||||
this.sentHistoryCursor = this.sentMessages.size();
|
||||
|
|
|
@ -1,118 +1,19 @@
|
|||
package client.gui;
|
||||
|
||||
import client.Client;
|
||||
import client.gui.element.Bar;
|
||||
import client.gui.element.Label;
|
||||
|
||||
public class GuiLoading extends Gui {
|
||||
public static interface Callback {
|
||||
void poll(Client gm, GuiLoading gui);
|
||||
}
|
||||
|
||||
private final String message;
|
||||
private final Callback callback;
|
||||
|
||||
private Label headerLabel;
|
||||
private Label taskLabel;
|
||||
private Bar progressBar1;
|
||||
private Bar progressBar2;
|
||||
|
||||
public static GuiLoading makeServerTask(String message) {
|
||||
return new GuiLoading(message, new Callback() {
|
||||
public void poll(Client gm, GuiLoading gui) {
|
||||
int progress = gm.progress;
|
||||
if(progress < 0) {
|
||||
gui.resetBar();
|
||||
}
|
||||
else {
|
||||
gui.setBar(null, "Chunks", Math.max(1, gm.total));
|
||||
gui.setProgress(progress);
|
||||
}
|
||||
gui.setTask(gm.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static GuiLoading makeWaitTask(String message) {
|
||||
return new GuiLoading(message, new Callback() {
|
||||
public void poll(Client gm, GuiLoading gui) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public GuiLoading(String message, Callback callback) {
|
||||
public GuiLoading(String message) {
|
||||
this.message = message;
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
|
||||
public void init(int width, int height) {
|
||||
this.taskLabel = this.add(new Label(0, 40, 500, 0, ""));
|
||||
this.progressBar1 = this.add(new Bar(0, 80, 500, 0));
|
||||
this.progressBar2 = this.add(new Bar(0, 120, 500, 0));
|
||||
this.shift();
|
||||
this.headerLabel = this.add(new Label(0, 40, width, 0, this.message));
|
||||
this.progressBar1.visible = false;
|
||||
this.progressBar2.visible = false;
|
||||
this.add(new Label(0, 40, width, 0, this.message));
|
||||
}
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void setTask(String task) {
|
||||
this.taskLabel.setText(task == null ? "" : task);
|
||||
}
|
||||
|
||||
public void setBar(String desc) {
|
||||
this.progressBar1.visible = true;
|
||||
this.progressBar1.setDescription(desc);
|
||||
}
|
||||
|
||||
public void setBar(String desc, String unit, int total) {
|
||||
this.progressBar1.visible = true;
|
||||
this.progressBar1.setDescription(desc, unit, total);
|
||||
}
|
||||
|
||||
public void setBar(String desc, int total) {
|
||||
this.progressBar1.visible = true;
|
||||
this.progressBar1.setDescription(desc, total);
|
||||
}
|
||||
|
||||
public void setProgress(float progress) {
|
||||
this.progressBar1.setProgress(progress);
|
||||
}
|
||||
|
||||
public void resetBar() {
|
||||
this.progressBar1.resetProgress();
|
||||
this.progressBar1.visible = false;
|
||||
}
|
||||
|
||||
public void setSub(String desc) {
|
||||
this.progressBar2.visible = true;
|
||||
this.progressBar2.setDescription(desc);
|
||||
}
|
||||
|
||||
public void setSub(String desc, String unit, int total) {
|
||||
this.progressBar2.visible = true;
|
||||
this.progressBar2.setDescription(desc, unit, total);
|
||||
}
|
||||
|
||||
public void setSub(String desc, int total) {
|
||||
this.progressBar2.visible = true;
|
||||
this.progressBar2.setDescription(desc, total);
|
||||
}
|
||||
|
||||
public void setSubProgress(float progress) {
|
||||
this.progressBar2.setProgress(progress);
|
||||
}
|
||||
|
||||
public void resetSub() {
|
||||
this.progressBar2.resetProgress();
|
||||
this.progressBar2.visible = false;
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
if(this.callback != null)
|
||||
this.callback.poll(this.gm, this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -390,7 +390,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
this.add(new ActButton(width - 195, height - 30, 193, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiChar.this.gm.player != null) {
|
||||
GuiChar.this.gm.show(GuiLoading.makeWaitTask("Lade Welt ..."));
|
||||
GuiChar.this.gm.show(new GuiLoading("Lade Welt ..."));
|
||||
Dimension dim = GuiChar.this.dimensions.get(GuiChar.this.dimension);
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, DimensionMapping.getId(dim)));
|
||||
|
|
|
@ -26,7 +26,7 @@ public class GuiBrewing extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(Blocks.brewing_stand.getDisplay(), 8, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.label(Blocks.brewing_stand.getDisplay(), 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class GuiChest extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.block.getDisplay(), 8, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.label(this.block.getDisplay(), 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,11 @@ import client.Client;
|
|||
import client.gui.Font;
|
||||
import client.gui.Gui;
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.Bar;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.Field;
|
||||
import client.gui.element.FontLabel;
|
||||
import client.gui.element.FontMultiLabel;
|
||||
import client.gui.element.DisplayLabel;
|
||||
import client.gui.element.InventoryButton;
|
||||
import client.gui.element.Label;
|
||||
import client.gui.element.MultiLabel;
|
||||
|
@ -199,7 +200,19 @@ public abstract class GuiContainer extends Gui
|
|||
public Label label(String text, int x, int y) {
|
||||
x = x * this.container_scale + this.container_x;
|
||||
y = y * this.container_scale + this.container_y;
|
||||
return this.add(new FontLabel(x, y + 10 * this.container_scale, 300, this.container_scale > 1 ? Font.MEDIUM : Font.SMALL, text, true));
|
||||
return this.add(new FontLabel(x, y, 300, this.container_scale > 1 ? Font.LARGE : Font.SMALL, text, true));
|
||||
}
|
||||
|
||||
public DisplayLabel display(String text, int x, int y, int w, int lines) {
|
||||
x = x * this.container_scale + this.container_x;
|
||||
y = y * this.container_scale + this.container_y;
|
||||
return this.add(new DisplayLabel(x, y, w * this.container_scale, lines, this.container_scale > 1 ? Font.LARGE : Font.TINY, text));
|
||||
}
|
||||
|
||||
public Bar bar(int x, int y, int w, int h) {
|
||||
x = x * this.container_scale + this.container_x;
|
||||
y = y * this.container_scale + this.container_y;
|
||||
return this.add(new Bar(x, y, w * this.container_scale, h * this.container_scale, this.container_scale > 1 ? Font.LARGE : Font.TINY));
|
||||
}
|
||||
|
||||
public void rect(int x, int y, int width, int height, int color) {
|
||||
|
@ -286,7 +299,7 @@ public abstract class GuiContainer extends Gui
|
|||
}
|
||||
if(this.gm.itemCheat) {
|
||||
this.cheatLabel = this.add(new FontLabel(this.cheatX, this.cheatY, this.cheatWidth * 18, Font.SMALL, "", true));
|
||||
this.cheatDesc = this.add(new FontMultiLabel(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4 + 18, this.cheatWidth * 18, 60, Font.SMALL, "Vorsicht: Schummeln\nwird mit Keule bestraft!!\n(Halte Strg beim Klick\nfür vollen Stapel)"));
|
||||
this.cheatDesc = this.add(new DisplayLabel(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4 + 18, this.cheatWidth * 18, 4, Font.SMALL, "Vorsicht: Schummeln\nwird mit Keule bestraft!!\n(Halte Strg beim Klick\nfür vollen Stapel)"));
|
||||
this.cheatSearch = this.add(new Field(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4, this.cheatWidth * 18, 0, 128, null, ""));
|
||||
this.cheatLast = "";
|
||||
for(CheatTab tab : CheatTab.values()) {
|
||||
|
|
|
@ -16,7 +16,7 @@ public class GuiCrafting extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label("Handwerk (" + this.type.getDisplay() + ")", 26, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.label(this.type.getDisplay(), 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package client.gui.container;
|
||||
|
||||
import client.gui.element.Bar;
|
||||
import client.gui.element.DisplayLabel;
|
||||
import client.gui.element.Label;
|
||||
import common.inventory.ContainerTile;
|
||||
import common.inventory.IInventory;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.tileentity.Device;
|
||||
import common.tileentity.Device.Status;
|
||||
|
||||
public class GuiDevice extends GuiContainer {
|
||||
private final IInventory playerInv;
|
||||
|
@ -12,28 +15,47 @@ public class GuiDevice extends GuiContainer {
|
|||
private final Device tile;
|
||||
|
||||
private Label header;
|
||||
private Label temp;
|
||||
private Label desc;
|
||||
private DisplayLabel desc;
|
||||
private Bar progress;
|
||||
private Bar temperature;
|
||||
private Bar[] resources;
|
||||
|
||||
public GuiDevice(EntityNPC player, IInventory inv, Device tile) {
|
||||
super(new ContainerTile(player, tile, inv));
|
||||
this.playerInv = player;
|
||||
this.tileInv = tile;
|
||||
this.ySize = 153;
|
||||
this.ySize = 194;
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
this.header.setText(this.tile.getStatus().color + this.tile.getBlockType().getDisplay() + " - " + this.tile.getStatus().name);
|
||||
this.temp.setText(String.format("Temperatur: %d °", this.tile.getTemperature()));
|
||||
this.header.setText(this.tile.getStatus().color + this.tile.getBlockType().getDisplay());
|
||||
this.desc.setText(this.tile.formatDisplay((ContainerTile)this.inventorySlots));
|
||||
if(this.progress != null) {
|
||||
this.progress.setText(this.tile.getTotal() <= 0 || this.tile.getProgress() < 0 ? "" : String.format("%d/%d (%.1f %%)",
|
||||
this.tile.getProgress(), this.tile.getTotal(), ((float)this.tile.getProgress() / (float)this.tile.getTotal()) * 100.0f));
|
||||
this.progress.setProgress(this.tile.getTotal(), this.tile.getProgress());
|
||||
}
|
||||
if(this.temperature != null) {
|
||||
this.temperature.setText(String.format("t: %d °C" + (this.tile.getMaxTemp() == Integer.MAX_VALUE ? "" : " (max. %d °C)"), this.tile.getTemperature(), this.tile.getMaxTemp()));
|
||||
this.temperature.setProgress(this.tile.getMaxTemp() == Integer.MAX_VALUE ? (this.tile.getStatus() == Status.OFF || this.tile.getStatus() == Status.BROKEN ? 0 : this.tile.getTemperature()) : this.tile.getMaxTemp(), this.tile.getTemperature());
|
||||
}
|
||||
for(int z = 0; z < this.resources.length; z++) {
|
||||
this.resources[z].setText(this.tile.getResource(z).format());
|
||||
this.resources[z].setProgress(this.tile.getResource(z).getCapacity(), this.tile.getResource(z).getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.header = this.label("", 8, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.temp = this.label("", 8, 18);
|
||||
this.desc = this.label("", 8, 28);
|
||||
this.header = this.label("", 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
this.desc = this.display("", 8, 18, 160, 4);
|
||||
this.progress = this.tile.hasProgress() ? this.bar(7, 70, 162, 9) : null;
|
||||
this.temperature = this.tile.hasTemperature() ? this.bar(7, this.progress == null ? 70 : 60, 162, 9) : null;
|
||||
this.resources = new Bar[this.tile.getNumResources()];
|
||||
for(int z = 0; z < this.resources.length; z++) {
|
||||
this.resources[z] = this.bar(7, 80 - (this.resources.length + (this.progress == null ? 0 : 1) + (this.temperature == null ? 0 : 1)) * 10 + z * 10, 162, 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class GuiDispenser extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.block.getDisplay(), 8, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.label(this.block.getDisplay(), 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,13 +59,13 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(Blocks.enchanting_table.getDisplay(), 12, 5);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.label(Blocks.enchanting_table.getDisplay(), 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
for(int l = 0; l < 3; ++l) {
|
||||
int i1 = 60;
|
||||
int j1 = i1 + 2;
|
||||
this.labels[l] = this.label("", j1, 16 + 19 * l);
|
||||
this.mana[l] = this.label("", j1, 16 + 19 * l + 7);
|
||||
this.labels[l] = this.label("", j1, 26 + 19 * l);
|
||||
this.mana[l] = this.label("", j1, 26 + 19 * l + 7);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public class GuiEntity extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.title, 8, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.label(this.title, 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ public class GuiFurnace extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.block.getDisplay(), 8, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.label(this.block.getDisplay(), 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels) {
|
||||
|
|
|
@ -13,7 +13,7 @@ public class GuiHopper extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(Blocks.hopper.getDisplay(), 8, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.label(Blocks.hopper.getDisplay(), 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,5 @@ public class GuiInventory extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label("Handwerk", 86, 16);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.title, 8, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
this.label(this.title, 8, 16);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
}
|
||||
|
||||
public void drawOverlays() {
|
||||
|
|
|
@ -30,7 +30,8 @@ public class GuiRepair extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label("Amboss", 60, 6);
|
||||
this.info = this.label("", 60, 67);
|
||||
this.label("Amboss", 8, 16);
|
||||
this.info = this.label("", 60, 77);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,28 @@
|
|||
package client.gui.element;
|
||||
|
||||
import client.gui.Font;
|
||||
import client.renderer.Drawing;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Util;
|
||||
|
||||
public class Bar extends Fill {
|
||||
private int color = 0x00ff00;
|
||||
private int progress = 0;
|
||||
private int total = 0;
|
||||
private String desc = "";
|
||||
private String unit = "";
|
||||
private final Font font;
|
||||
|
||||
public Bar(int x, int y, int w, int h, boolean top, boolean left) {
|
||||
super(x, y, w, h, "", top, left);
|
||||
private int color = 0x00ff00;
|
||||
private int amount = 0;
|
||||
|
||||
public Bar(int x, int y, int w, int h, Font font, boolean top, boolean left) {
|
||||
super(x, y, w, h, top, left);
|
||||
this.font = font;
|
||||
this.setText("");
|
||||
}
|
||||
|
||||
public Bar(int x, int y, int w, int h, boolean left) {
|
||||
super(x, y, w, h, "", left);
|
||||
public Bar(int x, int y, int w, int h, Font font, boolean left) {
|
||||
this(x, y, w, h, font, false, left);
|
||||
}
|
||||
|
||||
public Bar(int x, int y, int w, int h) {
|
||||
super(x, y, w, h, "");
|
||||
public Bar(int x, int y, int w, int h, Font font) {
|
||||
this(x, y, w, h, font, false, false);
|
||||
}
|
||||
|
||||
protected void drawBackground() {
|
||||
|
@ -28,16 +30,24 @@ public class Bar extends Fill {
|
|||
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm);
|
||||
else
|
||||
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.fill_btm, 0.5f), Util.mulColor(this.gm.style.fill_top, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||
if(this.progress > 0) {
|
||||
if(this.amount > 0) {
|
||||
if(this.enabled)
|
||||
Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.progress, this.size_y - 4, this.color | 0xff000000, Util.mixColor(this.color | 0xff000000, 0xff000000));
|
||||
Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.amount, this.size_y - 4, this.color | 0xff000000, Util.mixColor(this.color | 0xff000000, 0xff000000));
|
||||
else
|
||||
Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.progress, this.size_y - 4, Util.mulColor(this.color | 0xff000000, 0.5f), Util.mulColor(Util.mixColor(this.color | 0xff000000, 0xff000000), 0.5f));
|
||||
Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.amount, this.size_y - 4, Util.mulColor(this.color | 0xff000000, 0.5f), Util.mulColor(Util.mixColor(this.color | 0xff000000, 0xff000000), 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||
Font.set(this.font);
|
||||
Drawing.drawText(this.text, x1 + this.text_x, y1 + this.text_y, this.enabled ? this.gm.style.text_label : Util.mulColor(this.gm.style.text_label, 0.5f));
|
||||
Font.unset();
|
||||
}
|
||||
|
||||
public void updateText() {
|
||||
Font.set(this.font);
|
||||
super.updateText();
|
||||
Font.unset();
|
||||
}
|
||||
|
||||
protected int getMarginX() {
|
||||
|
@ -48,50 +58,12 @@ public class Bar extends Fill {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public Bar setDescription(String desc, String unit, int total) {
|
||||
this.desc = desc == null ? "" : (desc + ": ");
|
||||
this.unit = unit == null ? "" : (" " + unit);
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bar setDescription(String desc, int total) {
|
||||
return this.setDescription(desc, null, total);
|
||||
}
|
||||
|
||||
public Bar setDescription(String desc) {
|
||||
this.desc = desc == null ? "" : (desc + ": ");
|
||||
this.unit = "";
|
||||
this.total = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bar resetProgress() {
|
||||
this.setText("");
|
||||
this.progress = 0;
|
||||
this.setDescription(null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bar setProgressFill(int progress) {
|
||||
this.progress = ExtMath.clampi(progress, 0, this.size_x - 4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bar setProgressFill(float progress) {
|
||||
return this.setProgressFill((int)(progress * (float)(this.size_x - 4)));
|
||||
}
|
||||
|
||||
public Bar setProgress(float progress) {
|
||||
if(this.total == 0)
|
||||
this.setText(String.format("%s%.1f %%", this.desc, progress * 100.0f));
|
||||
else
|
||||
this.setText(String.format("%s%d/%d%s (%.1f %%)", this.desc, (int)progress, this.total, this.unit, (progress / (float)this.total) * 100.0f));
|
||||
return this.setProgressFill(this.total == 0 ? progress : (progress / (float)this.total));
|
||||
}
|
||||
|
||||
public Bar setColor(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setProgress(int total, int progress) {
|
||||
this.amount = progress < 0 || total <= 0 ? 0 : ExtMath.clampi((int)(((float)progress / (float)total) * (float)(this.size_x - 4)), 0, this.size_x - 4);
|
||||
}
|
||||
}
|
||||
|
|
41
client/src/main/java/client/gui/element/DisplayLabel.java
Normal file
41
client/src/main/java/client/gui/element/DisplayLabel.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
package client.gui.element;
|
||||
|
||||
import client.gui.Font;
|
||||
import client.renderer.Drawing;
|
||||
import common.util.Util;
|
||||
|
||||
public class DisplayLabel extends MultiLabel {
|
||||
private final Font font;
|
||||
|
||||
public DisplayLabel(int x, int y, int w, int lines, Font font, String text) {
|
||||
super(x, y, w, lines * font.getHeight() + 2, true);
|
||||
this.font = font;
|
||||
this.setText(text);
|
||||
}
|
||||
|
||||
protected void drawBackground() {
|
||||
Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, 0xff000000, 0xff2f2f2f, 0xff5f5f5f);
|
||||
}
|
||||
|
||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||
Font.set(this.font);
|
||||
for(int z = 0; z < this.lines.length; z++) {
|
||||
Drawing.drawText(z == this.lines.length - 1 && Util.ftime() % 1.0f < 0.5f ? this.lines[z] + "_" : this.lines[z], x1, y1 + z * Font.HEIGHT, 0xff00ff00);
|
||||
}
|
||||
Font.unset();
|
||||
}
|
||||
|
||||
public void updateText() {
|
||||
Font.set(this.font);
|
||||
super.updateText();
|
||||
Font.unset();
|
||||
}
|
||||
|
||||
protected int getMarginX() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
protected int getMarginY() {
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -22,16 +22,10 @@ public class Fill extends Element {
|
|||
this(x, y, w, h, text, false, false);
|
||||
}
|
||||
|
||||
public Fill(int x, int y, int w, int h, boolean top, boolean left) {
|
||||
this(x, y, w, h, "", top, left);
|
||||
}
|
||||
|
||||
public Fill(int x, int y, int w, int h, boolean left) {
|
||||
this(x, y, w, h, "", false, left);
|
||||
}
|
||||
|
||||
public Fill(int x, int y, int w, int h) {
|
||||
this(x, y, w, h, "", false, false);
|
||||
protected Fill(int x, int y, int w, int h, boolean top, boolean left) {
|
||||
super(x, y, w, h, null);
|
||||
this.top = top;
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,13 +6,15 @@ public class FontLabel extends Label {
|
|||
private final Font font;
|
||||
|
||||
public FontLabel(int x, int y, int w, int h, Font font, String text, boolean left) {
|
||||
super(x, y, w, h <= 0 ? font.getHeight() : h, text, left);
|
||||
super(x, y, w, h <= 0 ? font.getHeight() : h, false, left);
|
||||
this.font = font;
|
||||
this.setText(text);
|
||||
}
|
||||
|
||||
public FontLabel(int x, int y, int w, Font font, String text, boolean left) {
|
||||
super(x, y - font.getHeight(), w, font.getHeight(), text, left);
|
||||
super(x, y - font.getHeight(), w, font.getHeight(), false, left);
|
||||
this.font = font;
|
||||
this.setText(text);
|
||||
}
|
||||
|
||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||
|
@ -20,4 +22,10 @@ public class FontLabel extends Label {
|
|||
super.drawForeground(x1, y1, x2, y2);
|
||||
Font.unset();
|
||||
}
|
||||
|
||||
public void updateText() {
|
||||
Font.set(this.font);
|
||||
super.updateText();
|
||||
Font.unset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
package client.gui.element;
|
||||
|
||||
import client.gui.Font;
|
||||
|
||||
public class FontMultiLabel extends MultiLabel {
|
||||
private final Font font;
|
||||
|
||||
public FontMultiLabel(int x, int y, int w, int h, Font font, String text) {
|
||||
super(x, y, w, h, text);
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||
Font.set(this.font);
|
||||
super.drawForeground(x1, y1, x2, y2);
|
||||
Font.unset();
|
||||
}
|
||||
}
|
|
@ -29,6 +29,10 @@ public class Label extends Fill {
|
|||
public Label(int x, int y, int w, String text) {
|
||||
super(x, y - LABEL_HEIGHT, w, LABEL_HEIGHT, text);
|
||||
}
|
||||
|
||||
protected Label(int x, int y, int w, int h, boolean top, boolean left) {
|
||||
super(x, y, w, h <= 0 ? LABEL_HEIGHT : h, top, left);
|
||||
}
|
||||
|
||||
protected void drawBackground() {
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import client.renderer.Drawing;
|
|||
import common.util.Util;
|
||||
|
||||
public class MultiLabel extends Fill {
|
||||
private String[] lines;
|
||||
protected String[] lines;
|
||||
|
||||
public MultiLabel(int x, int y, int w, int h, String text, boolean top) {
|
||||
super(x, y, w, h, text, top, true);
|
||||
|
@ -15,6 +15,10 @@ public class MultiLabel extends Fill {
|
|||
super(x, y, w, h, text, false, true);
|
||||
}
|
||||
|
||||
protected MultiLabel(int x, int y, int w, int h, boolean top) {
|
||||
super(x, y, w, h, top, true);
|
||||
}
|
||||
|
||||
public void setText(String str) {
|
||||
super.setText(str);
|
||||
this.lines = str.split("\n", -1);
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.Map.Entry;
|
|||
import client.Client;
|
||||
import client.gui.Gui;
|
||||
import client.gui.GuiConsole;
|
||||
import client.gui.GuiLoading;
|
||||
import client.gui.character.GuiChar;
|
||||
import client.gui.character.GuiCharacters;
|
||||
import client.gui.container.GuiBrewing;
|
||||
|
@ -110,7 +109,6 @@ import common.packet.SPacketEntityVelocity;
|
|||
import common.packet.SPacketHeldItemChange;
|
||||
import common.packet.SPacketJoinGame;
|
||||
import common.packet.SPacketKeepAlive;
|
||||
import common.packet.SPacketLoading;
|
||||
import common.packet.SPacketMapChunkBulk;
|
||||
import common.packet.SPacketMessage;
|
||||
import common.packet.SPacketMultiBlockChange;
|
||||
|
@ -827,25 +825,6 @@ public class ClientPlayer implements IClientPlayer
|
|||
// }
|
||||
}
|
||||
|
||||
public void handleLoading(SPacketLoading packet) {
|
||||
NetHandler.checkThread(packet, this, this.gm);
|
||||
|
||||
if(packet.getMessage() == null) {
|
||||
if(packet.getTask() != null)
|
||||
this.gm.message = packet.getTask();
|
||||
if(packet.getTotal() >= 0)
|
||||
this.gm.total = packet.getTotal();
|
||||
if(packet.getProgress() >= -1)
|
||||
this.gm.progress = packet.getProgress();
|
||||
}
|
||||
else {
|
||||
this.gm.message = "";
|
||||
this.gm.total = 0;
|
||||
this.gm.progress = -1;
|
||||
this.gm.show(GuiLoading.makeServerTask(packet.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
// public void handleMessage(SPacketMessage packetIn)
|
||||
// {
|
||||
// NetHandler.checkThread(packetIn, this, this.gameController);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue