GuiAssetAdder now allows to add/remove/edit Assets in a Replay. These Assets are not being saved yet.
This commit is contained in:
@@ -36,7 +36,7 @@ public class GuiAdvancedTextField extends GuiTextField implements GuiElement {
|
||||
|
||||
@Override
|
||||
public void drawTextBox() {
|
||||
if (text.isEmpty() && !isFocused()) {
|
||||
if (text.isEmpty() && !isFocused() && hint.length() > 0) {
|
||||
super.setEnabled(false);
|
||||
super.setDisabledTextColour(hintTextColor);
|
||||
text = hint;
|
||||
|
||||
@@ -120,10 +120,10 @@ public class GuiEntryList<T extends GuiEntryListEntry> extends GuiTextField {
|
||||
}
|
||||
|
||||
public void addElement(T element) {
|
||||
if(element == null) return;
|
||||
this.elements.add(element);
|
||||
if(selectionIndex == -1) {
|
||||
selectionIndex = 0;
|
||||
}
|
||||
selectionIndex = elements.size()-1;
|
||||
fireSelectionChangeEvent();
|
||||
}
|
||||
|
||||
public T getElement(int index) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package eu.crushedpixel.replaymod.gui.elements;
|
||||
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.FileChooseListener;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
@@ -15,9 +14,13 @@ import java.util.List;
|
||||
public class GuiFileChooser extends GuiButton {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private File selectedFile;
|
||||
|
||||
public void setSelectedFile(File selectedFile) {
|
||||
this.selectedFile = selectedFile;
|
||||
updateDisplayString();
|
||||
}
|
||||
|
||||
private String baseString;
|
||||
|
||||
private String[] allowedExtensions = null;
|
||||
@@ -70,8 +73,9 @@ public class GuiFileChooser extends GuiButton {
|
||||
fileDialog.setVisible(true);
|
||||
|
||||
String filename = fileDialog.getFile();
|
||||
String directory = fileDialog.getDirectory();
|
||||
if(filename != null) {
|
||||
selectedFile = new File(filename);
|
||||
selectedFile = new File(directory, filename);
|
||||
|
||||
updateDisplayString();
|
||||
|
||||
|
||||
@@ -15,12 +15,9 @@ public class GuiNumberInput extends GuiTextField {
|
||||
this.minimum = minimum;
|
||||
this.maximum = maximum;
|
||||
this.acceptFloats = acceptFloats;
|
||||
setCursorPositionZero();
|
||||
if(defaultValue != null) {
|
||||
if(acceptFloats) {
|
||||
setText("" + defaultValue);
|
||||
} else {
|
||||
setText("" + (int)Math.round(defaultValue));
|
||||
}
|
||||
setValue(defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +26,15 @@ public class GuiNumberInput extends GuiTextField {
|
||||
this(id, fontRenderer, xPos, yPos, width, (double) minimum, (double) maximum, (double) defaultValue, acceptFloats);
|
||||
}
|
||||
|
||||
public void setValue(double value) {
|
||||
if(acceptFloats) {
|
||||
setText("" + value);
|
||||
} else {
|
||||
setText("" + (int)Math.round(value));
|
||||
}
|
||||
setCursorPositionZero();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeText(String text) {
|
||||
String textBefore = getText();
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package eu.crushedpixel.replaymod.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
public class GuiNumberInputWithText extends GuiNumberInput {
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private String suffix;
|
||||
|
||||
public GuiNumberInputWithText(int id, FontRenderer fontRenderer,
|
||||
int xPos, int yPos, int width, Double minimum, Double maximum, Double defaultValue,
|
||||
boolean acceptFloats, String suffix) {
|
||||
|
||||
super(id, fontRenderer, xPos, yPos, width, minimum, maximum, defaultValue, acceptFloats);
|
||||
if(suffix == null) suffix = "";
|
||||
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextBox() {
|
||||
int index = getCursorPosition();
|
||||
String textBefore = getText();
|
||||
setText(textBefore + suffix);
|
||||
setCursorPosition(index);
|
||||
super.drawTextBox();
|
||||
setText(textBefore);
|
||||
setCursorPosition(index);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user