fixes, cmds

This commit is contained in:
Sen 2025-03-19 02:08:41 +01:00
parent 868a5ed9ea
commit c906760bd4
13 changed files with 295 additions and 134 deletions

View file

@ -2,14 +2,20 @@ package game.gui;
import game.color.TextColor;
import game.gui.element.Dropdown;
import game.gui.element.Element;
import game.gui.element.Fill;
import game.gui.element.Slider;
import game.gui.element.Toggle;
import game.util.Formatter;
import game.window.Button;
import game.window.DisplayMode;
import game.window.Window;
public class GuiDisplay extends GuiOptions {
private static final String[] DISTANCES = new String[] {"Gruselig", "Winzig", "Gering", "Normal", "Weit"};
private Element distanceSlider;
protected GuiDisplay() {
}
@ -66,7 +72,7 @@ public class GuiDisplay extends GuiOptions {
this.addSelector("con_position", 30, 280, 440, 24);
this.addSelector("gl_fov", 30, 360, 440, 24);
this.addSelector("chunk_view_distance", 30, 400, 440, 24);
this.distanceSlider = this.addSelector("chunk_view_distance", 30, 400, 440, 24);
this.addSelector("chunk_build_time", 490, 400, 440, 24);
super.init(width, height);
}
@ -74,4 +80,18 @@ public class GuiDisplay extends GuiOptions {
public String getTitle() {
return "Grafik und Anzeige";
}
private String getDistanceName() {
int distance = this.gm.renderDistance;
distance = distance > 16 ? 16 : distance;
String str = distance < 0 ? DISTANCES[0] : DISTANCES[(distance + 1) / 4];
if(distance > 2 && (((distance + 1) / 2) & 1) == 1)
str = str + "+";
return String.format("Sichtweite: %d Chunks [%d Blöcke, %s]", this.gm.renderDistance, this.gm.renderDistance * 16, str);
}
public void updateScreen() {
if(!Button.isMouseDown())
this.distanceSlider.setText(this.getDistanceName());
}
}

View file

@ -137,7 +137,7 @@ public class GuiMenu extends Gui {
GuiMenu.this.gm.unload(true);
// GuiMenu.this.gm.displayGuiScreen(INSTANCE);
}
}, this.gm.isRemote() ? "Verbindung trennen" : "Welt schließen"));
}, this.gm.isRemote() ? "Server verlassen und Verbindung trennen" : "Welt speichern und schließen"));
this.shift();
}
}

View file

@ -139,8 +139,7 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
}
else
{
this.drawTextureAt(x, y, EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ?
this.charinfo.skin.substring(1) : this.charinfo.skin));
this.drawTextureAt(x, y, EntityTexManager.getNpcSkin(this.charinfo.skin, this.model));
}
}
@ -153,7 +152,7 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
EntityTexManager.altTexture = tex;
EntityTexManager.altLayer = this.dynId;
EntityTexManager.altNpcLayer = this.dynId == -1 && this.charinfo != null ? this.charinfo.skin : null;
drawEntity(x + 32, y + 56, 28.0f
drawEntity(x + 32, y + 60, 28.0f
/ GuiSkin.this.gm.thePlayer.getHeight(), -45.0f, -20.0f, GuiSkin.this.gm.thePlayer);
Render.drawNames = true;
EntityTexManager.altTexture = null;
@ -233,90 +232,6 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
return this.charinfo != null;
}
}
public static BufferedImage loadSkin(File file)
{
BufferedImage img = null;
try {
img = ImageIO.read(file);
}
catch(IOException e) {
return null;
}
if(img == null) {
return null;
}
// if(img.getWidth() != 64 || img.getHeight() != 64) { // || img.getType() != BufferedImage.TYPE_INT_ARGB) {
// return null;
// }
return img;
}
public void load(String currentSkin, ModelType model)
{
this.unload();
File[] files = new File("skins").listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isFile() && pathname.getName().endsWith(".png");
}
});
int pos = 0;
// for(ModelType model : ModelType.values()) {
this.elements.add(new SkinEntry("default", null, null, null, model));
if("default".equals(currentSkin))
this.setSelected(pos);
pos++;
// }
if(files != null) {
Arrays.sort(files);
for(File file : files)
{
BufferedImage img = loadSkin(file);
if(img != null) {
// for(ModelType model : ModelType.values()) {
if(img.getWidth() == model.texWidth && img.getHeight() == model.texHeight) {
this.elements.add(new SkinEntry(file.getName(), file, null, img, model));
if(file.getName().equals(currentSkin))
this.setSelected(pos);
pos++;
}
// }
}
}
}
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
for(CharacterInfo charinfo : species.chars) {
if(charinfo.species.renderer == model) {
// for(Entry<String, ModelType> entry : SpeciesRegistry.SKINS.entrySet()) {
this.elements.add(new SkinEntry(charinfo.skin, null, charinfo, null, charinfo.species.renderer));
if(charinfo.skin.equals(currentSkin))
this.setSelected(pos);
pos++;
}
}
}
}
public void unload()
{
for (SkinEntry entry : this.elements)
{
entry.deleteTexture();
}
this.elements.clear();
}
public int getListWidth()
{
return 254;
}
public int getSlotHeight()
{
return 64 + 4;
}
private class DragAdjust extends Element {
private int mouseX;
@ -367,8 +282,8 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
private ActButton convertButton2;
private ActButton templateButton;
private DragAdjust adjust;
private float yaw;
private float pitch;
private float yaw = -15.0f;
private float pitch = -15.0f;
private GuiSkin() {
}
@ -376,28 +291,28 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
public void init(int width, int height)
{
super.init(width, height);
this.setDimensions(274, height, 52, height - 52);
this.setDimensions(400, height, 52, height - 52);
this.load(null, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel());
this.convertButton1 = this.add(new ActButton(4, 4, 266, 20, new ActButton.Callback() {
this.convertButton1 = this.add(new ActButton(10, height - 48, 200, 20, new ActButton.Callback() {
public void use(ActButton elem, Mode action) {
SkinEntry skin = GuiSkin.this.getSelected();
if(skin != null && skin.getFile() != null && SkinConverter.convertSkin(skin.getFile(), new File("skins"), false))
GuiSkin.this.gm.displayGuiScreen(GuiSkin.this);
}
}, "Konvertieren: Standard"));
this.convertButton2 = this.add(new ActButton(4, 28, 266, 20, new ActButton.Callback() {
this.convertButton2 = this.add(new ActButton(10, height - 24, 200, 20, new ActButton.Callback() {
public void use(ActButton elem, Mode action) {
SkinEntry skin = GuiSkin.this.getSelected();
if(skin != null && skin.getFile() != null && SkinConverter.convertSkin(skin.getFile(), new File("skins"), true))
GuiSkin.this.gm.displayGuiScreen(GuiSkin.this);
}
}, "Konvertieren: Schlank"));
this.add(new ActButton(4, height - 48, 266, 20, new ActButton.Callback() {
this.add(new ActButton(240, height - 48, 150, 20, new ActButton.Callback() {
public void use(ActButton elem, Mode action) {
GuiSkin.this.gm.displayGuiScreen(GuiSkin.this);
}
}, "Neu laden"));
this.templateButton = this.add(new ActButton(4, height - 24, 266, 20, new ActButton.Callback() {
this.templateButton = this.add(new ActButton(240, height - 24, 150, 20, new ActButton.Callback() {
public void use(ActButton elem, Mode action) {
SkinEntry skin = GuiSkin.this.getSelected();
if(skin != null && skin.getLocation() != null) {
@ -431,12 +346,32 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
}
}
}, "Vorlage kopieren"));
this.adjust = this.add(new DragAdjust(274 + 10, 64, width - 274 - 274 - 20, height - 128));
this.adjust = this.add(new DragAdjust(400 + 10, 64, width - 400 - 400 - 20, height - 128));
// final ActButton[] speciesBtns = new ActButton[SpeciesRegistry.SPECIMEN.size()];
for(int z = 0; z < SpeciesRegistry.SPECIMEN.size(); z++) {
final SpeciesInfo species = SpeciesRegistry.SPECIMEN.get(z);
// speciesBtns[z] =
this.add(new ActButton(width - 400 + (z % 2) * 196, 4 + 23 * (z / 2), 194, 20, new ActButton.Callback() {
public void use(ActButton elem, Mode action) {
if(GuiSkin.this.gm.thePlayer != null) {
GuiSkin.this.gm.displayGuiScreen(GuiMenu.INSTANCE);
GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_SPECIES, EntityRegistry.getEntityID(species.clazz)));
// for(ActButton btn : speciesBtns) {
// btn.enabled = btn != elem;
// }
}
}
}, EntityRegistry.getEntityName(EntityRegistry.getEntityString(species.clazz)))) // ;
// speciesBtns[z]
.enabled = this.gm.thePlayer == null || this.gm.thePlayer.getClass() != species.clazz;
}
final ActButton[] alignBtns = new ActButton[Alignment.values().length];
for (int z = 0; z < Alignment.values().length; z++)
{
final Alignment align = Alignment.values()[z];
alignBtns[z] = this.add(new ActButton(width - 274 + (z % 3) * 89, height - 158 + 23 * (z / 3), 86, 20, new ActButton.Callback() {
alignBtns[z] = this.add(new ActButton(width - 400 + (z % 3) * 131, height - 198 + 23 * (z / 3), 129, 20, new ActButton.Callback() {
public void use(ActButton elem, Mode action) {
if(GuiSkin.this.gm.thePlayer != null) {
GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, align.ordinal()));
@ -448,15 +383,15 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
}, align.color + align.display));
alignBtns[z].enabled = this.gm.thePlayer == null || this.gm.thePlayer.getAlignment() != align;
}
this.add(new Slider(width - 274, height - 28 - 54, 264, 20, 1, 120, 320, 180, this.gm.thePlayer == null ? 180 : (int)(this.gm.thePlayer.getSpecies().size * this.gm.thePlayer.getHeight() * 100.0f + 0.5f), new Slider.Callback() {
this.add(new Slider(width - 400, height - 28 - 84, 390, 20, 1, 120, 320, 180, this.gm.thePlayer == null ? 180 : (int)(this.gm.thePlayer.getSpecies().size * this.gm.thePlayer.getHeight() * 100.0f + 0.5f), new Slider.Callback() {
public void use(Slider elem, int value) {
if(GuiSkin.this.gm.thePlayer != null)
GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, value));
}
}, "Spieler-Größe", "cm"));
this.add(new Label(width - 274 + 2, height + 2 - 28 - 24 - 10, 200, 20, "Anzeigename", true));
this.add(new ActButton(width - 274 + 154, height - 28, 264 - 154, 20, GuiMenu.INSTANCE, "Fertig"));
Textbox nameField = this.add(new Textbox(width - 274 + 2, height + 2 - 28 - 24, 260, 16, NetHandlerPlayServer.MAX_NICK_LENGTH, true, new Textbox.Callback() {
this.add(new Label(width - 400, height + 2 - 28 - 24 - 30, 390, 20, "Anzeigename", true));
this.add(new ActButton(width - 274 + 154, height - 24, 264 - 154, 20, GuiMenu.INSTANCE, "Fertig"));
Textbox nameField = this.add(new Textbox(width - 400, height + 2 - 28 - 34, 390, 20, NetHandlerPlayServer.MAX_NICK_LENGTH, true, new Textbox.Callback() {
public void use(Textbox elem, Action value) {
if(value == Action.SEND || value == Action.UNFOCUS) {
String name = elem.getText();
@ -484,7 +419,7 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
public void drawOverlays()
{
drawEntity(274 + (this.gm.fb_x - 274 - 274) / 2, this.gm.fb_y / 2 + 160, 160.0f
drawEntity(400 + (this.gm.fb_x - 400 - 400) / 2, this.gm.fb_y / 2 + 160, 160.0f
/ this.gm.thePlayer.getHeight(), this.yaw, this.pitch, this.gm.thePlayer);
}
@ -492,7 +427,88 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
return "Charakter anpassen";
}
public static BufferedImage loadSkin(File file)
{
BufferedImage img = null;
try {
img = ImageIO.read(file);
}
catch(IOException e) {
return null;
}
if(img == null) {
return null;
}
// if(img.getWidth() != 64 || img.getHeight() != 64) { // || img.getType() != BufferedImage.TYPE_INT_ARGB) {
// return null;
// }
return img;
}
public void load(String currentSkin, ModelType model)
{
this.unload();
File[] files = new File("skins").listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isFile() && pathname.getName().endsWith(".png");
}
});
int pos = 0;
// for(ModelType model : ModelType.values()) {
this.elements.add(new SkinEntry("default", null, null, null, model));
if("default".equals(currentSkin))
this.setSelected(pos);
pos++;
// }
if(files != null) {
Arrays.sort(files);
for(File file : files)
{
BufferedImage img = loadSkin(file);
if(img != null) {
// for(ModelType model : ModelType.values()) {
if(img.getWidth() == model.texWidth && img.getHeight() == model.texHeight) {
this.elements.add(new SkinEntry(file.getName(), file, null, img, model));
if(file.getName().equals(currentSkin))
this.setSelected(pos);
pos++;
}
// }
}
}
}
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
for(CharacterInfo charinfo : species.chars) {
if(charinfo.species.renderer == model) {
// for(Entry<String, ModelType> entry : SpeciesRegistry.SKINS.entrySet()) {
this.elements.add(new SkinEntry(charinfo.skin, null, charinfo, null, charinfo.species.renderer));
if(charinfo.skin.equals(currentSkin))
this.setSelected(pos);
pos++;
}
}
}
}
public void unload()
{
for (SkinEntry entry : this.elements)
{
entry.deleteTexture();
}
this.elements.clear();
}
public int getListWidth()
{
return 400 - 20;
}
public int getSlotHeight()
{
return 64 + 4;
}
// public static void drawEntityOnScreen(int posX, int posY, float scale, float mouseX, float mouseY, EntityLiving ent)